diff --git a/.changelog/unreleased/miscellaneous/1958-zeroize-secret-keys.md b/.changelog/unreleased/miscellaneous/1958-zeroize-secret-keys.md new file mode 100644 index 0000000000..f606d9d7ef --- /dev/null +++ b/.changelog/unreleased/miscellaneous/1958-zeroize-secret-keys.md @@ -0,0 +1,2 @@ +- Tag `ed25519` keys with `ZeroizeOnDrop` + ([\#1958](https://github.com/anoma/namada/pull/1958)) \ No newline at end of file diff --git a/core/src/types/key/ed25519.rs b/core/src/types/key/ed25519.rs index faf6076ea2..12863cca09 100644 --- a/core/src/types/key/ed25519.rs +++ b/core/src/types/key/ed25519.rs @@ -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, @@ -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); impl super::SecretKey for SecretKey { @@ -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);