From 8834f4ecbfc3efcf82b1d1d4ed5e5bd0ea06f9c9 Mon Sep 17 00:00:00 2001 From: Emma Turner Date: Tue, 25 Jun 2024 15:03:13 +0100 Subject: [PATCH] crypto: impl PublicKeyWithHash for PublicKey --- crypto/src/public_key.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crypto/src/public_key.rs b/crypto/src/public_key.rs index 22a335e10d..e3719a1ff5 100644 --- a/crypto/src/public_key.rs +++ b/crypto/src/public_key.rs @@ -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::*;