From e1ab2e5c0fd4cd8ee7823b60d830aaa1aedbe42c Mon Sep 17 00:00:00 2001 From: Pablo Lozano Date: Mon, 11 Dec 2023 11:32:52 +0100 Subject: [PATCH] feat: add zeroize support --- Cargo.toml | 4 +++- src/key.rs | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b555101..9908d6b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,13 +23,15 @@ ff = "0.13" group = "0.13" pairing_lib = { version = "0.23.0", package = "pairing" } -bls12_381 = { version = "0.8.0", optional = true, features = ["experimental"] } +bls12_381 = { version = "0.8.0", optional = true, features = ["experimental", "zeroize"] } sha2 = { version = "0.9", optional = true } hkdf = { version = "0.11.0", optional = true } blst_lib = { version = "0.3.10", optional = true, package = "blst" } blstrs = { version = "0.7.0", optional = true } +zeroize = { version = "1.7", features = ["derive"] } + [features] default = ["pairing", "multicore"] multicore = ["rayon"] diff --git a/src/key.rs b/src/key.rs index 95df77e..bc26dec 100644 --- a/src/key.rs +++ b/src/key.rs @@ -10,6 +10,7 @@ use bls12_381::{hash_to_curve::HashToField, G1Affine, G1Projective, Scalar}; use hkdf::Hkdf; #[cfg(feature = "pairing")] use sha2::{digest::generic_array::typenum::U48, digest::generic_array::GenericArray, Sha256}; +use zeroize::Zeroize; #[cfg(feature = "blst")] use blstrs::{G1Affine, G1Projective, G2Affine, Scalar}; @@ -26,7 +27,7 @@ pub(crate) const G1_COMPRESSED_SIZE: usize = 48; #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub struct PublicKey(pub(crate) G1Projective); -#[derive(Debug, Copy, Clone, Eq, PartialEq)] +#[derive(Debug, Copy, Clone, Eq, PartialEq, Zeroize)] pub struct PrivateKey(pub(crate) Scalar); impl From for PublicKey {