Merge #14195: Pass privkey export DER compression flag correctly

9a565a8282236f29334a6ec2de6a03358f5ce86e Pass export privkey DER compression flag correctly (liuyujun)

Tree-SHA512: 3fa1d7568ce133cd22708f453f3252c1138b1c40a821e90546d83bee4aac117ac8d848fa46cb45efad1031ce03cd5ba2d6c89b459abca6703aa2a957531e7edf
This commit is contained in:
Wladimir J. van der Laan 2018-09-13 09:59:12 +02:00 committed by pasta
parent 2291ab7e59
commit cdcd166819

View File

@ -89,7 +89,7 @@ static int ec_privkey_import_der(const secp256k1_context* ctx, unsigned char *ou
* will be set to the number of bytes used in the buffer. * will be set to the number of bytes used in the buffer.
* key32 must point to a 32-byte raw private key. * key32 must point to a 32-byte raw private key.
*/ */
static int ec_privkey_export_der(const secp256k1_context *ctx, unsigned char *privkey, size_t *privkeylen, const unsigned char *key32, int compressed) { static int ec_privkey_export_der(const secp256k1_context *ctx, unsigned char *privkey, size_t *privkeylen, const unsigned char *key32, bool compressed) {
assert(*privkeylen >= CKey::PRIVATE_KEY_SIZE); assert(*privkeylen >= CKey::PRIVATE_KEY_SIZE);
secp256k1_pubkey pubkey; secp256k1_pubkey pubkey;
size_t pubkeylen = 0; size_t pubkeylen = 0;
@ -170,7 +170,7 @@ CPrivKey CKey::GetPrivKey() const {
size_t privkeylen; size_t privkeylen;
privkey.resize(PRIVATE_KEY_SIZE); privkey.resize(PRIVATE_KEY_SIZE);
privkeylen = PRIVATE_KEY_SIZE; privkeylen = PRIVATE_KEY_SIZE;
ret = ec_privkey_export_der(secp256k1_context_sign, privkey.data(), &privkeylen, begin(), fCompressed ? SECP256K1_EC_COMPRESSED : SECP256K1_EC_UNCOMPRESSED); ret = ec_privkey_export_der(secp256k1_context_sign, privkey.data(), &privkeylen, begin(), fCompressed);
assert(ret); assert(ret);
privkey.resize(privkeylen); privkey.resize(privkeylen);
return privkey; return privkey;