diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2014-11-06 01:17:48 -0800 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2014-11-23 10:47:39 +0100 |
commit | d0c41a73501a0bf94fca91be5fb38ab039490843 (patch) | |
tree | 46da9cfe49a652b7853fcb3d1fb4ba0e6c52a9d7 /src/test | |
parent | cbf28c6619fe348a258dfd7d08bdbd2392d07511 (diff) |
Add sanity check after key generation
Add a sanity check to prevent cosmic rays from flipping a bit in the
generated public key, or bugs in the elliptic curve code. This is
simply done by signing a (randomized) message, and verifying the
result.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/key_tests.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/key_tests.cpp b/src/test/key_tests.cpp index b32f3774fe..f9e35e0166 100644 --- a/src/test/key_tests.cpp +++ b/src/test/key_tests.cpp @@ -82,6 +82,26 @@ BOOST_AUTO_TEST_CASE(key_test1) CPubKey pubkey1C = key1C.GetPubKey(); CPubKey pubkey2C = key2C.GetPubKey(); + BOOST_CHECK(key1.VerifyPubKey(pubkey1)); + BOOST_CHECK(!key1.VerifyPubKey(pubkey1C)); + BOOST_CHECK(!key1.VerifyPubKey(pubkey2)); + BOOST_CHECK(!key1.VerifyPubKey(pubkey2C)); + + BOOST_CHECK(!key1C.VerifyPubKey(pubkey1)); + BOOST_CHECK(key1C.VerifyPubKey(pubkey1C)); + BOOST_CHECK(!key1C.VerifyPubKey(pubkey2)); + BOOST_CHECK(!key1C.VerifyPubKey(pubkey2C)); + + BOOST_CHECK(!key2.VerifyPubKey(pubkey1)); + BOOST_CHECK(!key2.VerifyPubKey(pubkey1C)); + BOOST_CHECK(key2.VerifyPubKey(pubkey2)); + BOOST_CHECK(!key2.VerifyPubKey(pubkey2C)); + + BOOST_CHECK(!key2C.VerifyPubKey(pubkey1)); + BOOST_CHECK(!key2C.VerifyPubKey(pubkey1C)); + BOOST_CHECK(!key2C.VerifyPubKey(pubkey2)); + BOOST_CHECK(key2C.VerifyPubKey(pubkey2C)); + BOOST_CHECK(addr1.Get() == CTxDestination(pubkey1.GetID())); BOOST_CHECK(addr2.Get() == CTxDestination(pubkey2.GetID())); BOOST_CHECK(addr1C.Get() == CTxDestination(pubkey1C.GetID())); |