| 281 | |
| 282 | |
| 283 | bool CPubKey::Verify(const uint256 &hash, const std::vector<unsigned char>& vchSig) const { |
| 284 | if (!IsValid()) |
| 285 | return false; |
| 286 | secp256k1_pubkey pubkey; |
| 287 | secp256k1_ecdsa_signature sig; |
| 288 | if (!secp256k1_ec_pubkey_parse(secp256k1_context_static, &pubkey, vch, size())) { |
| 289 | return false; |
| 290 | } |
| 291 | if (!ecdsa_signature_parse_der_lax(&sig, vchSig.data(), vchSig.size())) { |
| 292 | return false; |
| 293 | } |
| 294 | /* libsecp256k1's ECDSA verification requires lower-S signatures, which have |
| 295 | * not historically been enforced in Bitcoin, so normalize them first. */ |
| 296 | secp256k1_ecdsa_signature_normalize(secp256k1_context_static, &sig, &sig); |
| 297 | return secp256k1_ecdsa_verify(secp256k1_context_static, &sig, hash.begin(), &pubkey); |
| 298 | } |
| 299 | |
| 300 | bool CPubKey::RecoverCompact(const uint256 &hash, const std::vector<unsigned char>& vchSig) { |
| 301 | if (vchSig.size() != COMPACT_SIGNATURE_SIZE) |
no test coverage detected