@@ -13,9 +13,11 @@ use serde::ser::SerializeTuple;
1313use crate :: ffi:: types:: c_uint;
1414use crate :: ffi:: { self , CPtr } ;
1515use crate :: Error :: { self , InvalidPublicKey , InvalidPublicKeySum , InvalidSecretKey } ;
16- use crate :: { constants, from_hex, schnorr, Message , Scalar , Secp256k1 , Signing , Verification } ;
1716#[ cfg( feature = "global-context" ) ]
18- use crate :: { ecdsa, SECP256K1 } ;
17+ use crate :: SECP256K1 ;
18+ use crate :: {
19+ constants, ecdsa, from_hex, schnorr, Message , Scalar , Secp256k1 , Signing , Verification ,
20+ } ;
1921#[ cfg( feature = "bitcoin_hashes" ) ]
2022use crate :: { hashes, ThirtyTwoByteHash } ;
2123
@@ -696,6 +698,16 @@ impl PublicKey {
696698 ( XOnlyPublicKey ( xonly_pk) , parity)
697699 }
698700 }
701+
702+ /// Checks that `sig` is a valid ECDSA signature for `msg` using this public key.
703+ pub fn verify < C : Verification > (
704+ & self ,
705+ secp : & Secp256k1 < C > ,
706+ msg : & Message ,
707+ sig : & ecdsa:: Signature ,
708+ ) -> Result < ( ) , Error > {
709+ secp. verify_ecdsa ( msg, sig, self )
710+ }
699711}
700712
701713/// This trait enables interaction with the FFI layer and even though it is part of the public API
0 commit comments