aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core
diff options
context:
space:
mode:
authorThomas Winget <tewinget@gmail.com>2014-06-06 14:18:11 -0400
committerThomas Winget <tewinget@gmail.com>2014-06-12 19:05:51 -0400
commitd22e458c6c680f4b5dcf56a58a37a5f79912e65c (patch)
tree05a150051c892903c87d913dddf321996c035079 /src/cryptonote_core
parentmissing '.at' on two map calls. built on some machines, very strange... (diff)
downloadmonero-d22e458c6c680f4b5dcf56a58a37a5f79912e65c.tar.xz
builds, but doesn't link. other than that, electrum-style recovery implemented (but not tested\!)
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r--src/cryptonote_core/account.cpp13
-rw-r--r--src/cryptonote_core/account.h2
2 files changed, 11 insertions, 4 deletions
diff --git a/src/cryptonote_core/account.cpp b/src/cryptonote_core/account.cpp
index 9a96de2f0..bd47c8ba4 100644
--- a/src/cryptonote_core/account.cpp
+++ b/src/cryptonote_core/account.cpp
@@ -10,6 +10,7 @@
#include "account.h"
#include "warnings.h"
#include "crypto/crypto.h"
+#include "crypto/blake256.h"
#include "cryptonote_core/cryptonote_basic_impl.h"
#include "cryptonote_core/cryptonote_format_utils.h"
using namespace std;
@@ -29,11 +30,17 @@ DISABLE_VS_WARNINGS(4244 4345)
m_keys = account_keys();
}
//-----------------------------------------------------------------
- void account_base::generate(const crypto::secret_key& recovery_key, bool recover)
+ crypto::secret_key account_base::generate(const crypto::secret_key& recovery_key, bool recover)
{
- 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, 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 745da0897..f07d4dd79 100644
--- a/src/cryptonote_core/account.h
+++ b/src/cryptonote_core/account.h
@@ -31,7 +31,7 @@ namespace cryptonote
{
public:
account_base();
- void generate(const crypto::secret_key& recovery_key = crypto::secret_key(), bool recover = false);
+ crypto::secret_key generate(const crypto::secret_key& recovery_key = crypto::secret_key(), bool recover = false);
const account_keys& get_keys() const;
std::string get_public_address_str();