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

Method RecoverCompact

src/pubkey.cpp:300–318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

298}
299
300bool CPubKey::RecoverCompact(const uint256 &hash, const std::vector<unsigned char>& vchSig) {
301 if (vchSig.size() != COMPACT_SIGNATURE_SIZE)
302 return false;
303 int recid = (vchSig[0] - 27) & 3;
304 bool fComp = ((vchSig[0] - 27) & 4) != 0;
305 secp256k1_pubkey pubkey;
306 secp256k1_ecdsa_recoverable_signature sig;
307 if (!secp256k1_ecdsa_recoverable_signature_parse_compact(secp256k1_context_static, &sig, &vchSig[1], recid)) {
308 return false;
309 }
310 if (!secp256k1_ecdsa_recover(secp256k1_context_static, &pubkey, &sig, hash.begin())) {
311 return false;
312 }
313 unsigned char pub[SIZE];
314 size_t publen = SIZE;
315 secp256k1_ec_pubkey_serialize(secp256k1_context_static, pub, &publen, &pubkey, fComp ? SECP256K1_EC_COMPRESSED : SECP256K1_EC_UNCOMPRESSED);
316 Set(pub, pub + publen);
317 return true;
318}
319
320bool CPubKey::IsFullyValid() const {
321 if (!IsValid())

Callers 3

BOOST_AUTO_TEST_CASEFunction · 0.80
key.cppFile · 0.80
MessageVerifyFunction · 0.80

Calls 5

secp256k1_ecdsa_recoverFunction · 0.85
sizeMethod · 0.45
beginMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.64