Skip to content

Commit 85949c7

Browse files
committed
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.
1 parent dca5f50 commit 85949c7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/key.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,6 @@ impl<'de> serde::Deserialize<'de> for PublicKey {
772772
/// [`cbor`]: https://docs.rs/cbor
773773
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Hash)]
774774
pub struct Keypair(ffi::Keypair);
775-
impl_display_secret!(Keypair);
776775
impl_fast_comparisons!(Keypair);
777776

778777
impl Keypair {
@@ -972,6 +971,15 @@ impl Keypair {
972971
pub fn non_secure_erase(&mut self) { self.0.non_secure_erase(); }
973972
}
974973

974+
impl fmt::Debug for Keypair {
975+
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
976+
f.debug_struct("Keypair")
977+
.field("pubkey", &self.public_key())
978+
.field("secret", &"<hidden>")
979+
.finish()
980+
}
981+
}
982+
975983
impl From<Keypair> for SecretKey {
976984
#[inline]
977985
fn from(pair: Keypair) -> Self { SecretKey::from_keypair(&pair) }

0 commit comments

Comments
 (0)