| 289 | } |
| 290 | |
| 291 | bool CPubKey::RecoverCompact(const uint256 &hash, const std::vector<unsigned char>& vchSig) { |
| 292 | if (vchSig.size() != COMPACT_SIGNATURE_SIZE) |
| 293 | return false; |
| 294 | int recid = (vchSig[0] - 27) & 3; |
| 295 | bool fComp = ((vchSig[0] - 27) & 4) != 0; |
| 296 | secp256k1_pubkey pubkey; |
| 297 | secp256k1_ecdsa_recoverable_signature sig; |
| 298 | assert(secp256k1_context_verify && "secp256k1_context_verify must be initialized to use CPubKey."); |
| 299 | if (!secp256k1_ecdsa_recoverable_signature_parse_compact(secp256k1_context_verify, &sig, &vchSig[1], recid)) { |
| 300 | return false; |
| 301 | } |
| 302 | if (!secp256k1_ecdsa_recover(secp256k1_context_verify, &pubkey, &sig, hash.begin())) { |
| 303 | return false; |
| 304 | } |
| 305 | unsigned char pub[SIZE]; |
| 306 | size_t publen = SIZE; |
| 307 | secp256k1_ec_pubkey_serialize(secp256k1_context_verify, pub, &publen, &pubkey, fComp ? SECP256K1_EC_COMPRESSED : SECP256K1_EC_UNCOMPRESSED); |
| 308 | Set(pub, pub + publen); |
| 309 | return true; |
| 310 | } |
| 311 | |
| 312 | bool CPubKey::IsFullyValid() const { |
| 313 | if (!IsValid()) |