|
|
|
@ -170,7 +170,7 @@ CPrivKey CKey::GetPrivKey() const {
|
|
|
|
|
size_t privkeylen;
|
|
|
|
|
privkey.resize(PRIVATE_KEY_SIZE);
|
|
|
|
|
privkeylen = PRIVATE_KEY_SIZE;
|
|
|
|
|
ret = ec_privkey_export_der(secp256k1_context_sign, (unsigned char*) privkey.data(), &privkeylen, begin(), fCompressed ? SECP256K1_EC_COMPRESSED : SECP256K1_EC_UNCOMPRESSED);
|
|
|
|
|
ret = ec_privkey_export_der(secp256k1_context_sign, privkey.data(), &privkeylen, begin(), fCompressed ? SECP256K1_EC_COMPRESSED : SECP256K1_EC_UNCOMPRESSED);
|
|
|
|
|
assert(ret);
|
|
|
|
|
privkey.resize(privkeylen);
|
|
|
|
|
return privkey;
|
|
|
|
@ -199,7 +199,7 @@ bool CKey::Sign(const uint256 &hash, std::vector<unsigned char>& vchSig, uint32_
|
|
|
|
|
secp256k1_ecdsa_signature sig;
|
|
|
|
|
int ret = secp256k1_ecdsa_sign(secp256k1_context_sign, &sig, hash.begin(), begin(), secp256k1_nonce_function_rfc6979, test_case ? extra_entropy : nullptr);
|
|
|
|
|
assert(ret);
|
|
|
|
|
secp256k1_ecdsa_signature_serialize_der(secp256k1_context_sign, (unsigned char*)vchSig.data(), &nSigLen, &sig);
|
|
|
|
|
secp256k1_ecdsa_signature_serialize_der(secp256k1_context_sign, vchSig.data(), &nSigLen, &sig);
|
|
|
|
|
vchSig.resize(nSigLen);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
@ -226,7 +226,7 @@ bool CKey::SignCompact(const uint256 &hash, std::vector<unsigned char>& vchSig)
|
|
|
|
|
secp256k1_ecdsa_recoverable_signature sig;
|
|
|
|
|
int ret = secp256k1_ecdsa_sign_recoverable(secp256k1_context_sign, &sig, hash.begin(), begin(), secp256k1_nonce_function_rfc6979, nullptr);
|
|
|
|
|
assert(ret);
|
|
|
|
|
secp256k1_ecdsa_recoverable_signature_serialize_compact(secp256k1_context_sign, (unsigned char*)&vchSig[1], &rec, &sig);
|
|
|
|
|
secp256k1_ecdsa_recoverable_signature_serialize_compact(secp256k1_context_sign, &vchSig[1], &rec, &sig);
|
|
|
|
|
assert(ret);
|
|
|
|
|
assert(rec != -1);
|
|
|
|
|
vchSig[0] = 27 + rec + (fCompressed ? 4 : 0);
|
|
|
|
|