Skip to content

Commit

Permalink
Implement Debug for (ed25519|secp256k1)::(Keypair|SecretKey)
Browse files Browse the repository at this point in the history
  • Loading branch information
c410-f3r committed Oct 24, 2019
1 parent 206e4e7 commit f26cc10
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions core/src/identity/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@

//! Ed25519 keys.

use core::fmt;
use ed25519_dalek as ed25519;
use failure::Fail;
use super::error::DecodingError;
use zeroize::Zeroize;

/// An Ed25519 keypair.
#[derive(Debug)]
pub struct Keypair(ed25519::Keypair);

impl Keypair {
Expand Down Expand Up @@ -135,6 +137,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 {
Expand Down
9 changes: 8 additions & 1 deletion core/src/identity/secp256k1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ 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)]
#[derive(Clone, Debug)]
pub struct Keypair {
secret: SecretKey,
public: PublicKey
Expand Down Expand Up @@ -70,6 +71,12 @@ impl From<Keypair> 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 {
Expand Down

0 comments on commit f26cc10

Please sign in to comment.