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

Method RecoverCompact

src/pubkey.cpp:186–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 3

BOOST_AUTO_TEST_CASEFunction · 0.80
verifymessageFunction · 0.80

Calls 5

secp256k1_ecdsa_recoverFunction · 0.85
sizeMethod · 0.45
beginMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.64