diff --git a/core/src/identity/ed25519.rs b/core/src/identity/ed25519.rs index 1c6662c2aec9..8306c3d6bfb6 100644 --- a/core/src/identity/ed25519.rs +++ b/core/src/identity/ed25519.rs @@ -20,6 +20,7 @@ //! Ed25519 keys. +use core::fmt; use ed25519_dalek as ed25519; use failure::Fail; use super::error::DecodingError; @@ -66,6 +67,16 @@ impl Keypair { } } +impl fmt::Debug for Keypair { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, + "Keypair( ed25519::Keypair {{ secret: \"Secret Key\", public: \"{:?}\" }} )", + &self.0.public + ) + } +} + impl Clone for Keypair { fn clone(&self) -> Keypair { let mut sk_bytes = self.0.secret.to_bytes(); @@ -135,6 +146,12 @@ impl Clone for SecretKey { } } +impl fmt::Debug for SecretKey { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "Secret Key") + } +} + 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 5b6ef6b5bc61..6a630e6035ae 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 { + write!(f, "Keypair {{ secret: \"Secret Key\", public: \"{:?}\" }}", &self.public) + } +} + /// 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, "Secret Key") + } +} + impl SecretKey { /// Generate a new Secp256k1 secret key. pub fn generate() -> SecretKey {