Skip to content

Commit

Permalink
Implement ZeroizeOnDrop on ed25519 keys
Browse files Browse the repository at this point in the history
  • Loading branch information
sug0 committed Oct 4, 2023
1 parent 7e4e922 commit 609e70d
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions core/src/types/key/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use data_encoding::HEXLOWER;
#[cfg(feature = "rand")]
use rand::{CryptoRng, RngCore};
use serde::{Deserialize, Serialize};
use zeroize::Zeroize;
use zeroize::{Zeroize, ZeroizeOnDrop};

use super::{
ParsePublicKeyError, ParseSecretKeyError, ParseSignatureError, RefTo,
Expand Down Expand Up @@ -125,7 +125,7 @@ impl FromStr for PublicKey {
}

/// Ed25519 secret key
#[derive(Debug, Serialize, Deserialize, Zeroize)]
#[derive(Debug, Serialize, Deserialize, Zeroize, ZeroizeOnDrop)]
pub struct SecretKey(pub Box<ed25519_consensus::SigningKey>);

impl super::SecretKey for SecretKey {
Expand Down Expand Up @@ -223,12 +223,6 @@ impl FromStr for SecretKey {
}
}

impl Drop for SecretKey {
fn drop(&mut self) {
self.0.zeroize();
}
}

/// Ed25519 signature
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct Signature(pub ed25519_consensus::Signature);
Expand Down

0 comments on commit 609e70d

Please sign in to comment.