diff --git a/shared/src/types/key/mod.rs b/shared/src/types/key/mod.rs index e7571bb050..9deccf75a9 100644 --- a/shared/src/types/key/mod.rs +++ b/shared/src/types/key/mod.rs @@ -415,26 +415,31 @@ macro_rules! sigscheme_test { println!("Public key: {}", public_key); println!("Secret key: {}", secret_key); } - - #[test] - fn zeroize_keypair() { - use rand::thread_rng; - - let sk = ed25519::SecretKey(Box::new( - ed25519_consensus::SigningKey::new(thread_rng()), - )); - let len = sk.0.as_bytes().len(); - let ptr = sk.0.as_bytes().as_ptr(); - - drop(sk); - - assert_eq!(&[0u8; 32], unsafe { - core::slice::from_raw_parts(ptr, len) - }); - } } }; } #[cfg(test)] sigscheme_test! {ed25519_test, ed25519::SigScheme} + +#[cfg(test)] +mod more_tests { + use super::*; + + #[test] + fn zeroize_keypair_ed25519() { + use rand::thread_rng; + + let sk = ed25519::SecretKey(Box::new( + ed25519_consensus::SigningKey::new(thread_rng()), + )); + let len = sk.0.as_bytes().len(); + let ptr = sk.0.as_bytes().as_ptr(); + + drop(sk); + + assert_eq!(&[0u8; 32], unsafe { + core::slice::from_raw_parts(ptr, len) + }); + } +}