From 4b17eb6657d6e8231e3aacf81e41c15366b21408 Mon Sep 17 00:00:00 2001 From: Eric Frias Date: Thu, 25 May 2017 12:21:48 -0400 Subject: [PATCH] Add get_private_key_from_password from steem commit 27ee20fdc0a11b721c760685b8a6956c592287cb --- libraries/wallet/include/graphene/wallet/wallet.hpp | 6 ++++++ libraries/wallet/wallet.cpp | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index a40f38d4..4d109171 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -580,6 +580,11 @@ class wallet_api */ brain_key_info suggest_brain_key()const; + /** + * @param role - active | owner | memo + */ + pair get_private_key_from_password( string account, string role, string password )const; + /** Converts a signed_transaction in JSON form to its binary representation. * * TODO: I don't see a broadcast_transaction() function, do we need one? @@ -1656,6 +1661,7 @@ FC_API( graphene::wallet::wallet_api, (import_account_keys) (import_balance) (suggest_brain_key) + (get_private_key_from_password) (register_account) (upgrade_account) (create_account_with_brain_key) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 456536c6..19b6ddd7 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -3379,6 +3379,14 @@ brain_key_info wallet_api::suggest_brain_key()const return result; } +pair wallet_api::get_private_key_from_password( string account, string role, string password )const { + auto seed = account + role + password; + FC_ASSERT( seed.size() ); + auto secret = fc::sha256::hash( seed.c_str(), seed.size() ); + auto priv = fc::ecc::private_key::regenerate( secret ); + return std::make_pair( public_key_type( priv.get_public_key() ), key_to_wif( priv ) ); +} + string wallet_api::serialize_transaction( signed_transaction tx )const { return fc::to_hex(fc::raw::pack(tx));