Use CPrivKey typedef for keydata in CKey #11482

pull AmirAbrams wants to merge 1 commits into bitcoin:master from AmirAbrams:patch-3 changing 1 files +2 −2
  1. AmirAbrams commented at 8:11 AM on October 11, 2017: contributor

    Seems like the keydata member variable in CKey should be a CPrivKey type. Is there a reason it was re-declared as a std::vector<unsigned char, secure_allocator<unsigned char> > and the CPrivKey typedef isn't used?

  2. laanwj added the label Refactoring on Oct 11, 2017
  3. promag commented at 11:23 AM on October 11, 2017: member
  4. sipa commented at 6:55 PM on October 11, 2017: member

    CPrivKey was intended to be a type for DER-encoded private keys, which the contents of CKey is not.

    If you're changing CPrivKey to be "generic secure storage of bytes", please update the comment above CPrivKey as well.

  5. Use CPrivKey typedef for keydata in CKey
    - keydata uses a secure generic storage of bytes via secure_allocator
    cbf2d35d6e
  6. AmirAbrams commented at 4:54 PM on October 12, 2017: contributor

    @sipa, I updated the comment to //! A generic storage of bytes using secure allocators Is that what you had in mind? Thanks

    On a related subject, in some cases, it might be better to use an alias instead of a typedef because they can be used with templates: Stack Overflow typedef and using in C++11 typedef std::vector<unsigned char, secure_allocator<unsigned char> > CPrivKey;

    to

    using CPrivKey = std::vector<unsigned char, secure_allocator<unsigned char> >;

  7. laanwj commented at 4:30 PM on November 9, 2017: member

    Is that what you had in mind? Thanks

    He means the comment above CPrivKey here: https://github.com/bitcoin/bitcoin/blob/master/src/key.h#L30 This specifically mentions a size and encoding, which is no longer true if you use it as a generic typedef.

  8. laanwj commented at 8:38 AM on December 20, 2017: member

    Closing this for now, feel free to ping me if you want to pick this up again.

  9. laanwj closed this on Dec 20, 2017

  10. MarcoFalke 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-04-22 06:15 UTC

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