Refactor key.cpp/.h #2600

pull sipa wants to merge 3 commits into bitcoin:master from sipa:keyrefactor changing 28 files +641 −595
  1. sipa commented at 5:36 AM on May 1, 2013: member

    This pull request changes a few things in key.h/key.cpp

    • CKey is no longer a kitchen-sink for "anything ECDSA related", but just an object representing a private key.
    • Operations that don't use a private key are moved to CPubKey (which is now a fully-featured object representing a public key).
    • All actual OpenSSL-interaction code is moved to an internal class in key.cpp.
    • Representation-wise, CKey now funcions as CSecret (which is gone) with an fCompressed built-in (so no keeping separate booleans necessary anymore).
    • CKey and CPubKey simply encapsulate static byte arrays, and can be created/moved/copied cheaply.
    • Practical upshot: no need to move key/pubkey data from/to CKey anymore before doing something useful with it.

    The reason for writing this is preparing the code to more easily change ECDSA implementation (such as maybe my secp256k1 library at some point), but it seemed useful enough to try to get reviewed and perhaps merged independently of that.

  2. jgarzik commented at 5:44 AM on May 1, 2013: contributor

    Seems correct at first glance. Would prefer init-to-zero over init-to-0xFF but that's nit picking.

  3. BitcoinPullTester commented at 11:54 PM on May 2, 2013: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/b6d07ce7ea07b1b79e96c25d7964f628fc3dbd4e for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.

  4. sipa commented at 10:20 PM on May 3, 2013: member

    @jgarzik 0x00 is a valid serialized EC point (though not a valid ECDSA public key), so I prefer using a certainly-invalid data there, to trigger more errors in case of some out-of-bounds access.

  5. jgarzik commented at 10:22 PM on May 3, 2013: contributor

    Fair enough. ACK.

  6. BitcoinPullTester commented at 2:54 PM on May 4, 2013: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/b7b49b89d1f5b510c6269bb3d516a5300a53087f for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.

  7. BitcoinPullTester commented at 12:32 AM on May 8, 2013: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/fd6e0a58f1b1b4b2ada60ba197ee541f5f0885d4 for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.

  8. sipa cross-referenced this on May 20, 2013 from issue Fix Memory Leak by bytemaster
  9. Make CPubKey statically allocated 5d891489ab
  10. CSecret/CKey -> CKey/CPubKey split/refactor dfa23b94c2
  11. Make signature cache store CPubKeys 896185d7ed
  12. sipa commented at 3:28 AM on May 30, 2013: member

    Rebased.

  13. jgarzik referenced this in commit e2f42142a0 on May 30, 2013
  14. jgarzik merged this on May 30, 2013
  15. jgarzik closed this on May 30, 2013

  16. jgarzik commented at 2:56 PM on May 30, 2013: contributor

    Wanted to get this one in sooner rather than later, so that other work may be based on top of it (it stirs a lot of code)

  17. sipa cross-referenced this on Jun 14, 2013 from issue Cleanup code by using forward declarations and other methods... by brandondahler
  18. bitcoin 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: 2026-05-19 06:55 UTC