| 185 | } |
| 186 | |
| 187 | bool 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 | |
| 207 | bool CPubKey::IsFullyValid() const { |
| 208 | if (!IsValid()) |