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.
This commit is contained in:
Andrew Poelstra 2024-08-25 15:25:58 +00:00
parent a16e5ecd49
commit b8ac971745
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 9 additions and 1 deletions

View File

@ -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", &"<hidden>")
.finish()
}
}
impl From<Keypair> for SecretKey {
#[inline]
fn from(pair: Keypair) -> Self { SecretKey::from_keypair(&pair) }