Skip to content

Commit

Permalink
Add a verify function to PublicKey
Browse files Browse the repository at this point in the history
Expose signature verification functionality for schnorr signatures on
the `XOnlyPublicKey` type.
  • Loading branch information
tcharding committed Jun 19, 2023
1 parent 7c8270a commit fa094d1
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 @@ -1316,6 +1316,16 @@ impl XOnlyPublicKey {
pub fn public_key(&self, parity: Parity) -> PublicKey {
PublicKey::from_x_only_public_key(*self, parity)
}

/// Checks that `sig` is a valid schnorr signature for `msg` using this public key.
pub fn verify<C: Verification>(
&self,
secp: &Secp256k1<C>,
msg: &Message,
sig: &schnorr::Signature,
) -> Result<(), Error> {
secp.verify_schnorr(sig, msg, self)
}
}

/// Represents the parity passed between FFI function calls.
Expand Down

0 comments on commit fa094d1

Please sign in to comment.