From 6575d4ebe5a4c4a6c8eb6bff16120e08563440bb Mon Sep 17 00:00:00 2001 From: Jakob Lind Date: Sat, 2 Aug 2014 18:14:29 +0200 Subject: [PATCH] check its deterministic wallet before printing seed when running the seed command --- src/simplewallet/simplewallet.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 5e636b68f..45dc49bbe 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -46,7 +46,11 @@ #include "version.h" #include "crypto/crypto.h" // for crypto::secret_key definition #include "crypto/electrum-words.h" - +extern "C" +{ +#include "crypto/keccak.h" +#include "crypto/crypto-ops.h" +} #if defined(WIN32) #include #endif @@ -193,8 +197,20 @@ bool simple_wallet::seed(const std::vector &args/* = std::vectorget_account().get_keys().m_spend_secret_key, electrum_words); - success_msg_writer(true) << "\nPLEASE NOTE: the following 24 words can be used to recover access to your wallet. Please write them down and store them somewhere safe and secure. Please do not store them in your email or on file storage services outside of your immediate control.\n"; - std::cout << electrum_words << std::endl; + crypto::secret_key second; + keccak((uint8_t *)&m_wallet->get_account().get_keys().m_spend_secret_key, sizeof(crypto::secret_key), (uint8_t *)&second, sizeof(crypto::secret_key)); + + sc_reduce32((uint8_t *)&second); + + if (memcmp(second.data,m_wallet->get_account().get_keys().m_view_secret_key.data, sizeof(crypto::secret_key))==0) + { + success_msg_writer(true) << "\nPLEASE NOTE: the following 24 words can be used to recover access to your wallet. Please write them down and store them somewhere safe and secure. Please do not store them in your email or on file storage services outside of your immediate control.\n"; + std::cout << electrum_words << std::endl; + } + else + { + fail_msg_writer() << "The wallet is non-deterministic. Cannot display seed."; + } return true; }