| 180 | } |
| 181 | |
| 182 | bool CPubKey::VerifyECDSA(const uint256 &hash, |
| 183 | const std::vector<uint8_t> &vchSig) const { |
| 184 | if (!IsValid()) { |
| 185 | return false; |
| 186 | } |
| 187 | |
| 188 | secp256k1_pubkey pubkey; |
| 189 | secp256k1_ecdsa_signature sig; |
| 190 | if (!secp256k1_ec_pubkey_parse(secp256k1_context_static, &pubkey, vch, |
| 191 | size())) { |
| 192 | return false; |
| 193 | } |
| 194 | if (!ecdsa_signature_parse_der_lax(&sig, vchSig.data(), vchSig.size())) { |
| 195 | return false; |
| 196 | } |
| 197 | /** |
| 198 | * libsecp256k1's ECDSA verification requires lower-S signatures, which have |
| 199 | * not historically been enforced in Bitcoin, so normalize them first. |
| 200 | */ |
| 201 | secp256k1_ecdsa_signature_normalize(secp256k1_context_static, &sig, &sig); |
| 202 | return secp256k1_ecdsa_verify(secp256k1_context_static, &sig, hash.begin(), |
| 203 | &pubkey); |
| 204 | } |
| 205 | |
| 206 | bool CPubKey::VerifySchnorr( |
| 207 | const uint256 &hash, const std::array<uint8_t, SCHNORR_SIZE> &sig) const { |