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

Method Verify

src/pubkey.cpp:167–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165}
166
167bool CPubKey::Verify(const uint256 &hash, const std::vector<unsigned char>& vchSig) const {
168 if (!IsValid())
169 return false;
170 secp256k1_pubkey pubkey;
171 secp256k1_ecdsa_signature sig;
172 if (!secp256k1_ec_pubkey_parse(secp256k1_context_verify, &pubkey, &(*this)[0], size())) {
173 return false;
174 }
175 if (vchSig.size() == 0) {
176 return false;
177 }
178 if (!ecdsa_signature_parse_der_lax(secp256k1_context_verify, &sig, &vchSig[0], vchSig.size())) {
179 return false;
180 }
181 /* libsecp256k1's ECDSA verification requires lower-S signatures, which have
182 * not historically been enforced in Bitcoin, so normalize them first. */
183 secp256k1_ecdsa_signature_normalize(secp256k1_context_verify, &sig, &sig);
184 return secp256k1_ecdsa_verify(secp256k1_context_verify, &sig, hash.begin(), &pubkey);
185}
186
187bool CPubKey::RecoverCompact(const uint256 &hash, const std::vector<unsigned char>& vchSig) {
188 if (vchSig.size() != 65)

Callers 1

VerifyPubKeyMethod · 0.45

Calls 6

secp256k1_ecdsa_verifyFunction · 0.85
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected