From deb70248cf154144e3c55cc26b6890241ec8fa74 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Tue, 31 Mar 2026 08:29:38 -0600 Subject: [PATCH] Bump `rand` dependency to v0.10 This also brings us closer to upstream by using the released `rand_xorshift` dependency --- Cargo.lock | 48 ++++++++++++-------------------------------- Cargo.toml | 10 +++------- src/tests/mod.rs | 52 ++++++++++++++++++++++++++++++++++-------------- 3 files changed, 53 insertions(+), 57 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7847b25..23b5b62 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,38 +2,6 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "cfg-if" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" - -[[package]] -name = "chacha20" -version = "0.10.0-rc.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c536927023d1c432e6e23a25ef45f6756094eac2ab460db5fb17a772acdfd312" -dependencies = [ - "cfg-if", - "cpufeatures", - "rand_core", -] - -[[package]] -name = "cpufeatures" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" -dependencies = [ - "libc", -] - -[[package]] -name = "libc" -version = "0.2.180" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" - [[package]] name = "memuse" version = "0.2.2" @@ -42,8 +10,9 @@ checksum = "3d97bbf43eb4f088f8ca469930cde17fa036207c9a5e02ccc5107c4e8b17c964" [[package]] name = "rand" -version = "0.10.0-rc.8" -source = "git+https://github.com/rust-random/rand#9c98f59e8b042e5c7c714e933e49b384a4ce75a6" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc266eb313df6c5c09c1c7b1fbe2510961e5bcd3add930c1e31f7ed9da0feff8" dependencies = [ "rand_core", ] @@ -54,6 +23,15 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c8d0fd677905edcbeedbf2edb6494d676f0e98d54d5cf9bda0b061cb8fb8aba" +[[package]] +name = "rand_xorshift" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60aa6af80be32871323012e02e6e65f8a7cc7890931ae421d217ad8fe0df2ccf" +dependencies = [ + "rand_core", +] + [[package]] name = "rustcrypto-ff" version = "0.14.0-rc.0" @@ -68,10 +46,10 @@ dependencies = [ name = "rustcrypto-group" version = "0.14.0-rc.0" dependencies = [ - "chacha20", "memuse", "rand", "rand_core", + "rand_xorshift", "rustcrypto-ff", "subtle", ] diff --git a/Cargo.toml b/Cargo.toml index b3d224c..56f5588 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,11 +16,10 @@ homepage = "https://github.com/RustCrypto/group" repository = "https://github.com/RustCrypto/group" [dependencies] -chacha20 = { version = "0.10.0-rc.10", optional = true, default-features = false, features = ["rng"] } ff = { version = "0.14.0-rc.0", package = "rustcrypto-ff", default-features = false } -rand = { version = "0.10.0-rc.8", optional = true, default-features = false } +rand = { version = "0.10", optional = true, default-features = false } rand_core = { version = "0.10", default-features = false } -#rand_xorshift = { version = "0.5.0-rc.0", optional = true } +rand_xorshift = { version = "0.5", optional = true } subtle = { version = "2.2.1", default-features = false } # Crate for exposing the dynamic memory usage of the w-NAF structs. @@ -29,11 +28,8 @@ memuse = { version = "0.2", optional = true } [features] default = ["alloc"] alloc = [] -tests = ["alloc", "chacha20", "rand"] # "rand_xorshift"] +tests = ["alloc", "rand", "rand_xorshift"] wnaf-memuse = ["alloc", "memuse"] [badges] maintenance = { status = "actively-developed" } - -[patch.crates-io.rand] -git = "https://github.com/rust-random/rand" diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 71bb753..c81a926 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -1,8 +1,8 @@ use alloc::vec::Vec; -use chacha20::ChaCha8Rng; use core::ops::{Mul, Neg}; use ff::{Field, PrimeField}; use rand::SeedableRng; +use rand_xorshift::XorShiftRng; use crate::{ prime::{PrimeCurve, PrimeCurveAffine}, @@ -10,13 +10,11 @@ use crate::{ GroupEncoding, UncompressedEncoding, }; -const RNG_SEED: [u8; 32] = [ - 0x1f, 0x64, 0x25, 0xd1, 0x6c, 0xb5, 0xdf, 0x2, 0x6a, 0x72, 0xf6, 0x90, 0xa, 0x7a, 0xe1, 0x38, - 0x22, 0xb7, 0xa8, 0x11, 0xb, 0xcf, 0xf4, 0x74, 0x25, 0xd, 0x63, 0x24, 0x17, 0x96, 0xc8, 0x58, -]; - pub fn curve_tests() { - let mut rng = ChaCha8Rng::from_seed(RNG_SEED); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); // Negation edge case with identity. { @@ -74,7 +72,10 @@ pub fn curve_tests() { pub fn random_wnaf_tests() { use crate::wnaf::*; - let mut rng = ChaCha8Rng::from_seed(RNG_SEED); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); { let mut table = vec![]; @@ -188,7 +189,10 @@ pub fn random_wnaf_tests() { } fn random_negation_tests() { - let mut rng = ChaCha8Rng::from_seed(RNG_SEED); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); for _ in 0..1000 { let r = G::random(&mut rng); @@ -215,7 +219,10 @@ fn random_negation_tests() { } fn random_doubling_tests() { - let mut rng = ChaCha8Rng::from_seed(RNG_SEED); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); for _ in 0..1000 { let mut a = G::random(&mut rng); @@ -240,7 +247,10 @@ fn random_doubling_tests() { } fn random_multiplication_tests() { - let mut rng = ChaCha8Rng::from_seed(RNG_SEED); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); for _ in 0..1000 { let mut a = G::random(&mut rng); @@ -272,7 +282,10 @@ fn random_multiplication_tests() { } fn random_addition_tests() { - let mut rng = ChaCha8Rng::from_seed(RNG_SEED); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); for _ in 0..1000 { let a = G::random(&mut rng); @@ -349,7 +362,10 @@ fn random_addition_tests() { } fn random_transformation_tests() { - let mut rng = ChaCha8Rng::from_seed(RNG_SEED); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); for _ in 0..1000 { let g = G::random(&mut rng); @@ -383,7 +399,10 @@ fn random_transformation_tests() { } fn random_compressed_encoding_tests() { - let mut rng = ChaCha8Rng::from_seed(RNG_SEED); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); assert_eq!( G::Affine::from_bytes(&G::Affine::identity().to_bytes()).unwrap(), @@ -409,7 +428,10 @@ pub fn random_uncompressed_encoding_tests() where ::Affine: UncompressedEncoding, { - let mut rng = ChaCha8Rng::from_seed(RNG_SEED); + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); assert_eq!( G::Affine::from_uncompressed(&G::Affine::identity().to_uncompressed()).unwrap(),