diff options
author | Thomas Winget <tewinget@gmail.com> | 2014-06-06 17:18:57 -0400 |
---|---|---|
committer | Thomas Winget <tewinget@gmail.com> | 2014-06-12 19:05:52 -0400 |
commit | 537b911af1db1258a6db226de3b7c55cb5779e21 (patch) | |
tree | 595c4e632b8c359f9a0fd2f0e4b7f971c46953c3 | |
parent | more pointer-based derp (diff) | |
download | monero-537b911af1db1258a6db226de3b7c55cb5779e21.tar.xz |
stupid signed arithmetic.
-rw-r--r-- | src/crypto/electrum-words.cpp | 9 |
1 files 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; } |