From e816173f99a0be3e0d93c226e8f3eeded567cfcb Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 9 Aug 2023 11:47:40 +1000 Subject: [PATCH] Add a verify function to PublicKey To be uniform with `XOnlyPublicKey` add a `verify` function to the `PublicKey`. --- src/key.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/key.rs b/src/key.rs index ecec1796f..94fefd99e 100644 --- a/src/key.rs +++ b/src/key.rs @@ -696,6 +696,16 @@ impl PublicKey { (XOnlyPublicKey(xonly_pk), parity) } } + + /// Checks that `sig` is a valid ECDSA signature for `msg` using this public key. + pub fn verify( + &self, + secp: &Secp256k1, + msg: &Message, + sig: &ecdsa::Signature, + ) -> Result<(), Error> { + secp.verify_ecdsa(msg, sig, self) + } } /// This trait enables interaction with the FFI layer and even though it is part of the public API