aboutsummaryrefslogtreecommitdiff
path: root/src/crypto/crypto.cpp
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/crypto/crypto.cpp
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 '')
-rw-r--r--src/crypto/crypto.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/crypto/crypto.cpp b/src/crypto/crypto.cpp
index 31fc31d5b..98a17a3e4 100644
--- a/src/crypto/crypto.cpp
+++ b/src/crypto/crypto.cpp
@@ -68,12 +68,27 @@ namespace crypto {
* TODO: allow specifiying random value (for wallet recovery)
*
*/
- void crypto_ops::generate_keys(public_key &pub, secret_key &sec) {
+ secret_key crypto_ops::generate_keys(public_key &pub, secret_key &sec, const secret_key& recovery_key, bool recover) {
lock_guard<mutex> lock(random_lock);
ge_p3 point;
- random_scalar(sec);
+
+ secret_key rng;
+
+ if (recover)
+ {
+ rng = recovery_key;
+ }
+ else
+ {
+ random_scalar(rng);
+ }
+ sec = rng;
+ sc_reduce32(&sec); // reduce in case second round of keys (sendkeys)
+
ge_scalarmult_base(&point, &sec);
ge_p3_tobytes(&pub, &point);
+
+ return rng;
}
bool crypto_ops::check_key(const public_key &key) {