diff options
author | monero-project <sempre.amaro@gmail.com> | 2014-06-12 19:14:25 -0400 |
---|---|---|
committer | monero-project <sempre.amaro@gmail.com> | 2014-06-12 19:14:25 -0400 |
commit | c3203c86c671d41ed4a07231c8a5054124d2e7d2 (patch) | |
tree | 06a7aceb34d1e53ca4bfd28d3fbc13b5ef0d8a30 /src/cryptonote_core | |
parent | new error code for rpc (diff) | |
parent | allow two-random-numbers wallet generation (but not as default) (diff) | |
download | monero-c3203c86c671d41ed4a07231c8a5054124d2e7d2.tar.xz |
Merge pull request #34 from tewinget/master
Add electrum-seed wallet backup/recovery
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r-- | src/cryptonote_core/account.cpp | 16 | ||||
-rw-r--r-- | src/cryptonote_core/account.h | 2 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/cryptonote_core/account.cpp b/src/cryptonote_core/account.cpp index ba39b9b77..7da1c6745 100644 --- a/src/cryptonote_core/account.cpp +++ b/src/cryptonote_core/account.cpp @@ -10,6 +10,10 @@ #include "account.h" #include "warnings.h" #include "crypto/crypto.h" +extern "C" +{ +#include "crypto/blake256.h" +} #include "cryptonote_core/cryptonote_basic_impl.h" #include "cryptonote_core/cryptonote_format_utils.h" using namespace std; @@ -29,11 +33,17 @@ DISABLE_VS_WARNINGS(4244 4345) m_keys = account_keys(); } //----------------------------------------------------------------- - void account_base::generate() + crypto::secret_key account_base::generate(const crypto::secret_key& recovery_key, bool recover, bool two_random) { - generate_keys(m_keys.m_account_address.m_spend_public_key, m_keys.m_spend_secret_key); - generate_keys(m_keys.m_account_address.m_view_public_key, m_keys.m_view_secret_key); + crypto::secret_key first = generate_keys(m_keys.m_account_address.m_spend_public_key, m_keys.m_spend_secret_key, recovery_key, recover); + + // rng for generating second set of keys is hash of first rng. means only one set of electrum-style words needed for recovery + crypto::secret_key second; + blake256_hash((uint8_t *)&second, (uint8_t *)&first, sizeof(crypto::secret_key)); + + generate_keys(m_keys.m_account_address.m_view_public_key, m_keys.m_view_secret_key, second, two_random ? false : true); m_creation_timestamp = time(NULL); + return first; } //----------------------------------------------------------------- const account_keys& account_base::get_keys() const diff --git a/src/cryptonote_core/account.h b/src/cryptonote_core/account.h index 8b525da97..cb77d7c4e 100644 --- a/src/cryptonote_core/account.h +++ b/src/cryptonote_core/account.h @@ -31,7 +31,7 @@ namespace cryptonote { public: account_base(); - void generate(); + crypto::secret_key generate(const crypto::secret_key& recovery_key = crypto::secret_key(), bool recover = false, bool two_random = false); const account_keys& get_keys() const; std::string get_public_address_str(); |