Skip to content

Commit

Permalink
crypto: impl PublicKeyWithHash for PublicKey
Browse files Browse the repository at this point in the history
  • Loading branch information
emturner committed Jun 27, 2024
1 parent 2d4b4ae commit 8834f4e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions crypto/src/public_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@ impl PublicKeySignatureVerifier for PublicKey {
}
}

impl crate::PublicKeyWithHash for PublicKey {
type Hash = crate::public_key_hash::PublicKeyHash;

fn pk_hash(&self) -> Self::Hash {
match self {
Self::Ed25519(pk) => Self::Hash::Ed25519(pk.pk_hash()),
Self::Secp256k1(pk) => Self::Hash::Secp256k1(pk.pk_hash()),
Self::P256(pk) => Self::Hash::P256(pk.pk_hash()),
}
}
}

#[cfg(test)]
mod test {
use super::*;
Expand Down

0 comments on commit 8834f4e

Please sign in to comment.