Skip to content
Snippets Groups Projects
Commit 4248310c authored by Bartek Wrona's avatar Bartek Wrona
Browse files

cpp_convert_raw_public_key_to_wif exposed by Wax C++ core

parent 60784255
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !282. Comments created here will be created in the context of that merge request.
......@@ -278,6 +278,28 @@ std::string foundation::cpp_convert_raw_private_key_to_wif(const std::string& he
return fc::ecc::private_key::regenerate(sharedSecret).key_to_wif();
}
std::string foundation::cpp_convert_raw_public_key_to_wif(const std::string& hexData)
{
if(hexData.size() == 2 * sizeof(fc::ecc::public_key_data))
{
/// compressed form
fc::ecc::public_key_data keyData;
detail::convert_from_hex(hexData, keyData);
return fc::ecc::public_key::to_base58_with_prefix(keyData, HIVE_ADDRESS_PREFIX);
}
else
{
FC_ASSERT(hexData.size() == 2 * sizeof(fc::ecc::public_key_point_data), "Invalid size of raw public key buffer: ${s}", ("s", (hexData.size())));
/// uncompressed form
fc::ecc::public_key_point_data keyData;
detail::convert_from_hex(hexData, keyData);
fc::ecc::public_key key(keyData);
return key.to_base58_with_prefix(HIVE_ADDRESS_PREFIX);
}
}
brain_key_data foundation::cpp_suggest_brain_key()
{
......
......@@ -20,6 +20,11 @@ public:
*/
std::string cpp_convert_raw_private_key_to_wif(const std::string& hexData);
/** Allows to convert raw public key form (expressed as hex string) into Hive WIF format (with prefix).
* \param hexData - depending on length compressed or uncompressed key format is chosen
*/
std::string cpp_convert_raw_public_key_to_wif(const std::string& hexData);
brain_key_data cpp_suggest_brain_key();
/** Returns map of hive::protocol constants in form:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment