Skip to content

Commit

Permalink
Merge pull request #75 from trilitech/emturner@xukktymprqqr
Browse files Browse the repository at this point in the history
crypto: impl PublicKeyWithHash for PublicKey
  • Loading branch information
vapourismo authored Jun 27, 2024
2 parents 9303b71 + 8834f4e commit fc6ed17
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 fc6ed17

Please sign in to comment.