diff --git a/core/src/identity/ed25519.rs b/core/src/identity/ed25519.rs index 1c6662c2aec..8cb049451e0 100644 --- a/core/src/identity/ed25519.rs +++ b/core/src/identity/ed25519.rs @@ -24,6 +24,7 @@ use ed25519_dalek as ed25519; use failure::Fail; use super::error::DecodingError; use zeroize::Zeroize; +use core::fmt; /// An Ed25519 keypair. pub struct Keypair(ed25519::Keypair); @@ -66,6 +67,12 @@ impl Keypair { } } +impl fmt::Debug for Keypair { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Keypair").field("public", &self.0.public).finish() + } +} + impl Clone for Keypair { fn clone(&self) -> Keypair { let mut sk_bytes = self.0.secret.to_bytes(); @@ -135,6 +142,12 @@ impl Clone for SecretKey { } } +impl fmt::Debug for SecretKey { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "SecretKey") + } +} + impl SecretKey { /// Generate a new Ed25519 secret key. pub fn generate() -> SecretKey { diff --git a/core/src/identity/secp256k1.rs b/core/src/identity/secp256k1.rs index 5b6ef6b5bc6..686aedbe960 100644 --- a/core/src/identity/secp256k1.rs +++ b/core/src/identity/secp256k1.rs @@ -26,6 +26,7 @@ use sha2::{Digest as ShaDigestTrait, Sha256}; use secp256k1::{Message, Signature}; use super::error::{DecodingError, SigningError}; use zeroize::Zeroize; +use core::fmt; /// A Secp256k1 keypair. #[derive(Clone)] @@ -51,6 +52,12 @@ impl Keypair { } } +impl fmt::Debug for Keypair { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Keypair").field("public", &self.public).finish() + } +} + /// Promote a Secp256k1 secret key into a keypair. impl From for Keypair { fn from(secret: SecretKey) -> Keypair { @@ -70,6 +77,12 @@ impl From for SecretKey { #[derive(Clone)] pub struct SecretKey(secp256k1::SecretKey); +impl fmt::Debug for SecretKey { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "SecretKey") + } +} + impl SecretKey { /// Generate a new Secp256k1 secret key. pub fn generate() -> SecretKey {