Reported by onlineproof on IRC: Bitcoin does not verify whether private keys and public keys correspond, when loading a wallet.
Check consistency of private keys #782
pull sipa wants to merge 1 commits into bitcoin:master from sipa:checkkeys changing 1 files +2 −0-
sipa commented at 2:06 AM on January 25, 2012: member
-
b25cc627a3
Check consistency of private keys
Reported by onlineproof on IRC: Bitcoin does not verify whether private keys and public keys correspond, when loading a wallet.
-
piratelinux commented at 3:45 AM on January 25, 2012: none
Hi, this is onelineproof from IRC. I think you need to do a bit more than just that...If you're first setting pubkey to be vchpubkey, then obviously they will be equal. But eventually, I can test it to make sure...
If you wanna peek at my code that implements such a function in C, take a look at the function priv_to_pub in https://github.com/piratelinux/cwallet/blob/master/src/util.h
-
sipa commented at 5:30 AM on January 25, 2012: member
@piratelinux: CKey::GetPubKey extracts the public key from the OpenSSL Key structure, which is constructed at the time of the CKey::SetPrivKey() call. The information present there from the CKey::SetPubKey() is only used to know whether the key is compressed.
-
TheBlueMatt commented at 5:49 AM on January 25, 2012: member
Why not check wkeys as well?
-
sipa commented at 5:57 AM on January 25, 2012: member
@TheBlueMatt do they exist?
-
TheBlueMatt commented at 6:37 AM on January 25, 2012: member
Look at the block starting at line 868.
-
gavinandresen commented at 1:43 PM on January 25, 2012: contributor
wkeys are dead code that should be removed, if I recall correctly.
- gavinandresen referenced this in commit 4c932cca6f on Jan 25, 2012
- gavinandresen merged this on Jan 25, 2012
- gavinandresen closed this on Jan 25, 2012
-
TheBlueMatt commented at 3:36 PM on January 25, 2012: member
wkeys were used by very, very old clients instead of keys iirc, No reason to remove support for opening old wallets.
Gavin Andresen reply@reply.github.com wrote:
wkeys are dead code that should be removed, if I recall correctly.
Reply to this email directly or view it on GitHub: #782 (comment)
-
piratelinux commented at 11:18 PM on January 25, 2012: none
I still don't think it will work, because I think what SetPrivKey does is take the public key part of the full private key, but if the secret part (usually 32 bytes) is corrupted, it wouldn't know. I did a rough test, but maybe if you could send me a release that I can compile and you're confident works, then I can do a more thorough test. The master branch of bitcoin is not compiling for me. Thanks. edit: I think it compiles fine now, so I can test with master branch
- coblee referenced this in commit d319e0a2e8 on Jul 17, 2012
- sipa referenced this in commit 52380bf304 on Oct 14, 2020
- DrahtBot locked this on Sep 8, 2021