From 537b911af1db1258a6db226de3b7c55cb5779e21 Mon Sep 17 00:00:00 2001 From: Thomas Winget Date: Fri, 6 Jun 2014 17:18:57 -0400 Subject: [PATCH] stupid signed arithmetic. --- src/crypto/electrum-words.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/crypto/electrum-words.cpp b/src/crypto/electrum-words.cpp index a11d287b2..96a392d04 100644 --- a/src/crypto/electrum-words.cpp +++ b/src/crypto/electrum-words.cpp @@ -54,7 +54,9 @@ namespace crypto w2 = wordsMap.at(wlist[i*3 + 1]); w3 = wordsMap.at(wlist[i*3 + 2]); - val = w1 + n * ((w2 - w1) % n) + n * n * ((w3 - w2) % n); + val = w1 + n * (((n - w1) + w2) % n) + n * n * (((n - w2) + w3) % n); + + if (!(val % n == w1)) return false; memcpy(dst.data + i * 4, &val, 4); // copy 4 bytes to position } @@ -67,11 +69,6 @@ namespace crypto wlist_copy += words; } - std::string back_to_words; - bytes_to_words(dst, back_to_words); - - assert(wlist_copy == back_to_words); // sanity check - return true; }