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

Method Verify

src/pubkey.cpp:273–289  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

271
272
273bool CPubKey::Verify(const uint256 &hash, const std::vector<unsigned char>& vchSig) const {
274 if (!IsValid())
275 return false;
276 secp256k1_pubkey pubkey;
277 secp256k1_ecdsa_signature sig;
278 assert(secp256k1_context_verify && "secp256k1_context_verify must be initialized to use CPubKey.");
279 if (!secp256k1_ec_pubkey_parse(secp256k1_context_verify, &pubkey, vch, size())) {
280 return false;
281 }
282 if (!ecdsa_signature_parse_der_lax(secp256k1_context_verify, &sig, vchSig.data(), vchSig.size())) {
283 return false;
284 }
285 /* libsecp256k1's ECDSA verification requires lower-S signatures, which have
286 * not historically been enforced in Bitcoin, so normalize them first. */
287 secp256k1_ecdsa_signature_normalize(secp256k1_context_verify, &sig, &sig);
288 return secp256k1_ecdsa_verify(secp256k1_context_verify, &sig, hash.begin(), &pubkey);
289}
290
291bool CPubKey::RecoverCompact(const uint256 &hash, const std::vector<unsigned char>& vchSig) {
292 if (vchSig.size() != COMPACT_SIGNATURE_SIZE)

Callers 1

VerifyPubKeyMethod · 0.45

Calls 8

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

Tested by

no test coverage detected