mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-10-18 19:10:30 +08:00
crypto: Add impl Verifier for PublicKey
Add `impl Verifier<Signature> for PublicKey`, to allow using the popular trait from the `signature` crate in verification codepaths.
This commit is contained in:
committed by
Lorenz Leutgeb
parent
01c60388db
commit
768ecf56ba
@@ -174,6 +174,14 @@ impl TryFrom<String> for Signature {
|
||||
)]
|
||||
pub struct PublicKey(pub ed25519::PublicKey);
|
||||
|
||||
impl signature::Verifier<Signature> for PublicKey {
|
||||
fn verify(&self, msg: &[u8], signature: &Signature) -> Result<(), signature::Error> {
|
||||
self.0
|
||||
.verify(msg, signature)
|
||||
.map_err(signature::Error::from_source)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "cyphernet")]
|
||||
impl cyphernet::display::MultiDisplay<cyphernet::display::Encoding> for PublicKey {
|
||||
type Display = String;
|
||||
|
||||
Reference in New Issue
Block a user