@@ -13,9 +13,11 @@ use serde::ser::SerializeTuple;
13
13
use crate :: ffi:: types:: c_uint;
14
14
use crate :: ffi:: { self , CPtr } ;
15
15
use crate :: Error :: { self , InvalidPublicKey , InvalidPublicKeySum , InvalidSecretKey } ;
16
- use crate :: { constants, from_hex, schnorr, Message , Scalar , Secp256k1 , Signing , Verification } ;
17
16
#[ 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
+ } ;
19
21
#[ cfg( feature = "bitcoin_hashes" ) ]
20
22
use crate :: { hashes, ThirtyTwoByteHash } ;
21
23
@@ -696,6 +698,16 @@ impl PublicKey {
696
698
( XOnlyPublicKey ( xonly_pk) , parity)
697
699
}
698
700
}
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
+ }
699
711
}
700
712
701
713
/// This trait enables interaction with the FFI layer and even though it is part of the public API
0 commit comments