| 298 | } |
| 299 | |
| 300 | bool 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 | |
| 320 | bool CPubKey::IsFullyValid() const { |
| 321 | if (!IsValid()) |