Skip to content

Commit

Permalink
keypair: use public key for Debug output
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
apoelstra committed Aug 25, 2024
1 parent dca5f50 commit 85949c7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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", &"<hidden>")
.finish()
}
}

impl From<Keypair> for SecretKey {
#[inline]
fn from(pair: Keypair) -> Self { SecretKey::from_keypair(&pair) }
Expand Down

0 comments on commit 85949c7

Please sign in to comment.