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

Method RecoverCompact

src/pubkey.cpp:187–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187bool CPubKey::RecoverCompact(const uint256 &hash, const std::vector<unsigned char>& vchSig) {
188 if (vchSig.size() != 65)
189 return false;
190 int recid = (vchSig[0] - 27) & 3;
191 bool fComp = ((vchSig[0] - 27) & 4) != 0;
192 secp256k1_pubkey pubkey;
193 secp256k1_ecdsa_recoverable_signature sig;
194 if (!secp256k1_ecdsa_recoverable_signature_parse_compact(secp256k1_context_verify, &sig, &vchSig[1], recid)) {
195 return false;
196 }
197 if (!secp256k1_ecdsa_recover(secp256k1_context_verify, &pubkey, &sig, hash.begin())) {
198 return false;
199 }
200 unsigned char pub[65];
201 size_t publen = 65;
202 secp256k1_ec_pubkey_serialize(secp256k1_context_verify, pub, &publen, &pubkey, fComp ? SECP256K1_EC_COMPRESSED : SECP256K1_EC_UNCOMPRESSED);
203 Set(pub, pub + publen);
204 return true;
205}
206
207bool CPubKey::IsFullyValid() const {
208 if (!IsValid())

Callers 3

verifymessageFunction · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80

Calls 5

secp256k1_ecdsa_recoverFunction · 0.85
sizeMethod · 0.45
beginMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.64