MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / Verify

Method Verify

src/pubkey.cpp:283–298  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281
282
283bool CPubKey::Verify(const uint256 &hash, const std::vector<unsigned char>& vchSig) const {
284 if (!IsValid())
285 return false;
286 secp256k1_pubkey pubkey;
287 secp256k1_ecdsa_signature sig;
288 if (!secp256k1_ec_pubkey_parse(secp256k1_context_static, &pubkey, vch, size())) {
289 return false;
290 }
291 if (!ecdsa_signature_parse_der_lax(&sig, vchSig.data(), vchSig.size())) {
292 return false;
293 }
294 /* libsecp256k1's ECDSA verification requires lower-S signatures, which have
295 * not historically been enforced in Bitcoin, so normalize them first. */
296 secp256k1_ecdsa_signature_normalize(secp256k1_context_static, &sig, &sig);
297 return secp256k1_ecdsa_verify(secp256k1_context_static, &sig, hash.begin(), &pubkey);
298}
299
300bool CPubKey::RecoverCompact(const uint256 &hash, const std::vector<unsigned char>& vchSig) {
301 if (vchSig.size() != COMPACT_SIGNATURE_SIZE)

Callers 1

VerifyPubKeyMethod · 0.45

Calls 8

sizeFunction · 0.85
secp256k1_ecdsa_verifyFunction · 0.85
dataMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected