MCPcopy Create free account
hub / github.com/ElementsProject/elements / SignCompact

Method SignCompact

src/key.cpp:265–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

263}
264
265bool CKey::SignCompact(const uint256 &hash, std::vector<unsigned char>& vchSig) const {
266 if (!fValid)
267 return false;
268 vchSig.resize(CPubKey::COMPACT_SIGNATURE_SIZE);
269 int rec = -1;
270 secp256k1_ecdsa_recoverable_signature rsig;
271 int ret = secp256k1_ecdsa_sign_recoverable(secp256k1_context_sign, &rsig, hash.begin(), begin(), secp256k1_nonce_function_rfc6979, nullptr);
272 assert(ret);
273 ret = secp256k1_ecdsa_recoverable_signature_serialize_compact(secp256k1_context_sign, &vchSig[1], &rec, &rsig);
274 assert(ret);
275 assert(rec != -1);
276 vchSig[0] = 27 + rec + (fCompressed ? 4 : 0);
277 // Additional verification step to prevent using a potentially corrupted signature
278 secp256k1_pubkey epk, rpk;
279 ret = secp256k1_ec_pubkey_create(secp256k1_context_sign, &epk, begin());
280 assert(ret);
281 ret = secp256k1_ecdsa_recover(GetVerifyContext(), &rpk, &rsig, hash.begin());
282 assert(ret);
283 ret = secp256k1_ec_pubkey_cmp(GetVerifyContext(), &epk, &rpk);
284 assert(ret == 0);
285 return true;
286}
287
288bool CKey::SignSchnorr(const uint256& hash, Span<unsigned char> sig, const uint256* merkle_root, const uint256& aux) const
289{

Callers 3

BOOST_AUTO_TEST_CASEFunction · 0.80
FUZZ_TARGET_INITFunction · 0.80
MessageSignFunction · 0.80

Calls 9

beginFunction · 0.85
secp256k1_ecdsa_recoverFunction · 0.85
GetVerifyContextFunction · 0.85
secp256k1_ec_pubkey_cmpFunction · 0.85
resizeMethod · 0.45
beginMethod · 0.45

Tested by 2

BOOST_AUTO_TEST_CASEFunction · 0.64
FUZZ_TARGET_INITFunction · 0.64