Check consistency of private keys #782

pull sipa wants to merge 1 commits into bitcoin:master from sipa:checkkeys changing 1 files +2 −0
  1. sipa commented at 2:06 am on January 25, 2012: member
    Reported by onlineproof on IRC: Bitcoin does not verify whether private keys and public keys correspond, when loading a wallet.
  2. 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.
    b25cc627a3
  3. 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

  4. 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.
  5. TheBlueMatt commented at 5:49 am on January 25, 2012: member
    Why not check wkeys as well?
  6. sipa commented at 5:57 am on January 25, 2012: member
    @TheBlueMatt do they exist?
  7. TheBlueMatt commented at 6:37 am on January 25, 2012: member
    Look at the block starting at line 868.
  8. gavinandresen commented at 1:43 pm on January 25, 2012: contributor
    wkeys are dead code that should be removed, if I recall correctly.
  9. gavinandresen referenced this in commit 4c932cca6f on Jan 25, 2012
  10. gavinandresen merged this on Jan 25, 2012
  11. gavinandresen closed this on Jan 25, 2012

  12. 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)

  13. 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
  14. coblee referenced this in commit d319e0a2e8 on Jul 17, 2012
  15. sipa referenced this in commit 52380bf304 on Oct 14, 2020
  16. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-10-05 01:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me