diff --git a/.changes/secp256k1-features-fix.md b/.changes/secp256k1-features-fix.md new file mode 100644 index 00000000..e37e07fd --- /dev/null +++ b/.changes/secp256k1-features-fix.md @@ -0,0 +1,5 @@ +--- +"iota-crypto": patch +--- + +Fixed "rand"/"random" feature inconsistencies. diff --git a/src/signatures/secp256k1_ecdsa.rs b/src/signatures/secp256k1_ecdsa.rs index 2ad47682..48d42387 100644 --- a/src/signatures/secp256k1_ecdsa.rs +++ b/src/signatures/secp256k1_ecdsa.rs @@ -19,8 +19,8 @@ pub struct SecretKey(k256::ecdsa::SigningKey); impl SecretKey { pub const LENGTH: usize = 32; - #[cfg(feature = "random")] - #[cfg_attr(docsrs, doc(cfg(feature = "random")))] + #[cfg(all(feature = "rand", feature = "random"))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "rand", feature = "random"))))] pub fn generate() -> Self { let mut rng = rand::rngs::OsRng; Self(k256::ecdsa::SigningKey::random(&mut rng)) diff --git a/tests/secp256k1_ecdsa.rs b/tests/secp256k1_ecdsa.rs index 8fba4b36..0ec21858 100644 --- a/tests/secp256k1_ecdsa.rs +++ b/tests/secp256k1_ecdsa.rs @@ -28,7 +28,7 @@ fn run_secp256k1_sha256(sk: SecretKey, pk: PublicKey) { assert_eq!(pk, sig.recover_sha256(&msg).unwrap()); assert!(pk.verify_sha256(sig2.as_ref(), &msg)); - #[cfg(feature = "rand")] + #[cfg(all(feature = "rand", feature = "random"))] assert!(!SecretKey::generate().public_key().verify_sha256( &Signature::try_from_slice(&sig_bytes[..Signature::LENGTH]).unwrap(), &msg @@ -95,7 +95,7 @@ fn test_secp256k1_sign_verify() { run_secp256k1_keccak256(sk, pk); } -#[cfg(feature = "rand")] +#[cfg(all(feature = "rand", feature = "random"))] #[test] fn test_secp256k1_sign_verify_random() { let sk = SecretKey::generate();