Skip to content

Commit

Permalink
Add a verify function to PublicKey
Browse files Browse the repository at this point in the history
To be uniform with `XOnlyPublicKey` add a `verify` function to the
`PublicKey`.
  • Loading branch information
tcharding committed Aug 9, 2023
1 parent 29e1a0c commit 59e473c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<C: Verification>(
&self,
secp: &Secp256k1<C>,
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
Expand Down

0 comments on commit 59e473c

Please sign in to comment.