From 5e62ce4b3334615feeb27082f1dd6fdf0393fbb3 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Sun, 25 Aug 2024 15:25:58 +0000 Subject: [PATCH] keypair: use public key for Debug output There is no need to hash up the secret for Keypair. It already has a "fingerprint" in the form of its public key. We should just use that. --- src/key.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/key.rs b/src/key.rs index 55786e540..13552832b 100644 --- a/src/key.rs +++ b/src/key.rs @@ -772,7 +772,6 @@ impl<'de> serde::Deserialize<'de> for PublicKey { /// [`cbor`]: https://docs.rs/cbor #[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Hash)] pub struct Keypair(ffi::Keypair); -impl_display_secret!(Keypair); impl_fast_comparisons!(Keypair); impl Keypair { @@ -972,6 +971,15 @@ impl Keypair { pub fn non_secure_erase(&mut self) { self.0.non_secure_erase(); } } +impl fmt::Debug for Keypair { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + f.debug_struct("Keypair") + .field("pubkey", &self.public_key()) + .field("secret", &"") + .finish() + } +} + impl From for SecretKey { #[inline] fn from(pair: Keypair) -> Self { SecretKey::from_keypair(&pair) }