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