From d0c41a73501a0bf94fca91be5fb38ab039490843 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Thu, 6 Nov 2014 01:17:48 -0800 Subject: 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. --- src/key.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/key.h') diff --git a/src/key.h b/src/key.h index 0bb05482c9..d8c82b6f09 100644 --- a/src/key.h +++ b/src/key.h @@ -136,6 +136,12 @@ public: //! Derive BIP32 child key. bool Derive(CKey& keyChild, unsigned char ccChild[32], unsigned int nChild, const unsigned char cc[32]) const; + /** + * Verify thoroughly whether a private key and a public key match. + * This is done using a different mechanism than just regenerating it. + */ + bool VerifyPubKey(const CPubKey& vchPubKey) const; + //! Load private key and check that public key matches. bool Load(CPrivKey& privkey, CPubKey& vchPubKey, bool fSkipCheck); -- cgit v1.2.3