| 165 | } |
| 166 | |
| 167 | bool CPubKey::Verify(const uint256 &hash, const std::vector<unsigned char>& vchSig) const { |
| 168 | if (!IsValid()) |
| 169 | return false; |
| 170 | secp256k1_pubkey pubkey; |
| 171 | secp256k1_ecdsa_signature sig; |
| 172 | if (!secp256k1_ec_pubkey_parse(secp256k1_context_verify, &pubkey, &(*this)[0], size())) { |
| 173 | return false; |
| 174 | } |
| 175 | if (vchSig.size() == 0) { |
| 176 | return false; |
| 177 | } |
| 178 | if (!ecdsa_signature_parse_der_lax(secp256k1_context_verify, &sig, &vchSig[0], vchSig.size())) { |
| 179 | return false; |
| 180 | } |
| 181 | /* libsecp256k1's ECDSA verification requires lower-S signatures, which have |
| 182 | * not historically been enforced in Bitcoin, so normalize them first. */ |
| 183 | secp256k1_ecdsa_signature_normalize(secp256k1_context_verify, &sig, &sig); |
| 184 | return secp256k1_ecdsa_verify(secp256k1_context_verify, &sig, hash.begin(), &pubkey); |
| 185 | } |
| 186 | |
| 187 | bool CPubKey::RecoverCompact(const uint256 &hash, const std::vector<unsigned char>& vchSig) { |
| 188 | if (vchSig.size() != 65) |
no test coverage detected