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?
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-
AmirAbrams commented at 8:11 AM on October 11, 2017: contributor
- laanwj added the label Refactoring on Oct 11, 2017
-
promag commented at 11:23 AM on October 11, 2017: member
When
keydatawas added the typedef was already there, see https://github.com/bitcoin/bitcoin/commit/f4d1fc259b5a62580d952c180b1189ccaa6af1bc#diff-dd01571c9de4333a6af0b54c71ae2ad8R32.ACK 21f69f6.
-
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.
-
cbf2d35d6e
Use CPrivKey typedef for keydata in CKey
- keydata uses a secure generic storage of bytes via secure_allocator
-
AmirAbrams commented at 4:54 PM on October 12, 2017: contributor
@sipa, I updated the comment to
//! A generic storage of bytes using secure allocatorsIs that what you had in mind? ThanksOn 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> >; -
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.
-
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.
- laanwj closed this on Dec 20, 2017
- MarcoFalke locked this on Sep 8, 2021