From b4e87492d7db6477c05b6e8a53b95c6d87406736 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Fri, 30 Dec 2022 10:05:11 -0700 Subject: [PATCH 01/17] Add `Group::mul_by_generator` Adds a provided method to the `Group` trait for performing multiplication by the generator. The use case is overriding this method in the event that precomputed scalar multiplication tables are available, which may be conditional depending on crate features like `alloc` or feature-gated static precomputed tables. --- src/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 27ed5c9..b738244 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -90,6 +90,12 @@ pub trait Group: /// Doubles this element. #[must_use] fn double(&self) -> Self; + + /// Multiply by the generator of the prime-order subgroup. + #[must_use] + fn mul_by_generator(scalar: &Self::Scalar) -> Self { + Self::generator() * scalar + } } /// Efficient representation of an elliptic curve point guaranteed. From 6ab641f6ac8bb0bfd1e72faa0a94a3b13166840a Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Wed, 16 Apr 2025 11:45:26 +0000 Subject: [PATCH 02/17] Raise MSRV to 1.63 --- CHANGELOG.md | 2 ++ Cargo.toml | 2 +- README.md | 2 +- rust-toolchain.toml | 2 +- src/wnaf.rs | 6 ++++++ 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aec3f6d..591a72e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this library adheres to Rust's notion of [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed +- MSRV is now 1.63.0. ## [0.13.0] - 2022-12-06 ### Changed diff --git a/Cargo.toml b/Cargo.toml index bff1cf0..49fe2ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ authors = [ "Jack Grigg ", ] edition = "2021" -rust-version = "1.56" +rust-version = "1.63" readme = "README.md" license = "MIT/Apache-2.0" diff --git a/README.md b/README.md index c3c0640..efff81c 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ wider discussion. ## Minimum Supported Rust Version -Requires Rust **1.56** or higher. +Requires Rust **1.63** or higher. Minimum supported Rust version can be changed in the future, but it will be done with a minor version bump. diff --git a/rust-toolchain.toml b/rust-toolchain.toml index de43b23..3eebdfe 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.56.0" +channel = "1.63.0" components = [ "clippy", "rustfmt" ] diff --git a/src/wnaf.rs b/src/wnaf.rs index 175d676..fdcf432 100644 --- a/src/wnaf.rs +++ b/src/wnaf.rs @@ -255,6 +255,12 @@ pub struct Wnaf { window_size: W, } +impl Default for Wnaf<(), Vec, Vec> { + fn default() -> Self { + Self::new() + } +} + impl Wnaf<(), Vec, Vec> { /// Construct a new wNAF context without allocating. pub fn new() -> Self { From 8240c176e346c20b6fa8bec87c4b88cd4bcc2faa Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Wed, 16 Apr 2025 11:49:01 +0000 Subject: [PATCH 03/17] Update lockfile to latest MSRV-compatible dependencies --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 46af6c4..775e6a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "ff" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393" dependencies = [ "rand_core", "subtle", @@ -26,9 +26,9 @@ dependencies = [ [[package]] name = "memuse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2145869435ace5ea6ea3d35f59be559317ec9a0d04e1812d5f185a87b6d36f1a" +checksum = "3d97bbf43eb4f088f8ca469930cde17fa036207c9a5e02ccc5107c4e8b17c964" [[package]] name = "rand" @@ -56,6 +56,6 @@ dependencies = [ [[package]] name = "subtle" -version = "2.4.1" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" From 055cc14b002b22bde892c07602561ca026f884e1 Mon Sep 17 00:00:00 2001 From: pinkforest <36498018+pinkforest@users.noreply.github.com> Date: Sun, 26 Jan 2025 08:59:10 +0000 Subject: [PATCH 04/17] Bump to rust-random 0.9 Co-authored-by: Jack Grigg --- CHANGELOG.md | 1 + Cargo.lock | 71 ++++++++++++++++++++++++++++++++++++++++++------ Cargo.toml | 9 ++++-- src/tests/mod.rs | 4 +-- 4 files changed, 72 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 591a72e..3276d5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this library adheres to Rust's notion of ## [Unreleased] ### Changed - MSRV is now 1.63.0. +- Migrated to `ff 0.14`, `rand_core 0.9`. ## [0.13.0] - 2022-12-06 ### Changed diff --git a/Cargo.lock b/Cargo.lock index 775e6a1..c0263ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,8 +5,7 @@ version = 3 [[package]] name = "ff" version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393" +source = "git+https://github.com/zkcrypto/ff.git?rev=241caff9bcedafbe279b5a4d875461f66b3f9701#241caff9bcedafbe279b5a4d875461f66b3f9701" dependencies = [ "rand_core", "subtle", @@ -30,26 +29,45 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d97bbf43eb4f088f8ca469930cde17fa036207c9a5e02ccc5107c4e8b17c964" +[[package]] +name = "proc-macro2" +version = "1.0.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + [[package]] name = "rand" -version = "0.8.5" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" dependencies = [ "rand_core", + "zerocopy", ] [[package]] name = "rand_core" -version = "0.6.4" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" [[package]] name = "rand_xorshift" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" +checksum = "513962919efc330f829edb2535844d1b912b0fbe2ca165d613e4e8788bb05a5a" dependencies = [ "rand_core", ] @@ -59,3 +77,40 @@ name = "subtle" version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" + +[[package]] +name = "zerocopy" +version = "0.8.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml index 49fe2ba..b666707 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,9 +17,9 @@ repository = "https://github.com/zkcrypto/group" [dependencies] ff = { version = "0.13", default-features = false } -rand = { version = "0.8", optional = true, default-features = false } -rand_core = { version = "0.6", default-features = false } -rand_xorshift = { version = "0.3", optional = true } +rand = { version = "0.9", optional = true, default-features = false } +rand_core = { version = "0.9", default-features = false } +rand_xorshift = { version = "0.4", optional = true } subtle = { version = "2.2.1", default-features = false } # Crate for exposing the dynamic memory usage of the w-NAF structs. @@ -33,3 +33,6 @@ wnaf-memuse = ["alloc", "memuse"] [badges] maintenance = { status = "actively-developed" } + +[patch.crates-io] +ff = { git = "https://github.com/zkcrypto/ff.git", rev = "241caff9bcedafbe279b5a4d875461f66b3f9701" } diff --git a/src/tests/mod.rs b/src/tests/mod.rs index ff79a9b..c81a926 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -378,8 +378,8 @@ fn random_transformation_tests() { for _ in 0..10 { let mut v = (0..1000).map(|_| G::random(&mut rng)).collect::>(); - use rand::distributions::{Distribution, Uniform}; - let between = Uniform::new(0, 1000); + use rand::distr::{Distribution, Uniform}; + let between = Uniform::new(0, 1000).unwrap(); // Sprinkle in some normalized points for _ in 0..5 { v[between.sample(&mut rng)] = G::identity(); From f3537bcd1c16a5ce48022e3eb948578fae4204c6 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Sun, 2 Mar 2025 21:37:03 -0800 Subject: [PATCH 05/17] Relax `Sized` requirements on the rng --- CHANGELOG.md | 3 +++ src/lib.rs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3276d5c..f8c7b05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ and this library adheres to Rust's notion of ### Changed - MSRV is now 1.63.0. - Migrated to `ff 0.14`, `rand_core 0.9`. +- `group::Group::random(rng: impl RngCore) -> Self` has been changed to + `Group::random(rng: &mut R) -> Self`, to enable passing a + trait object as the RNG. ## [0.13.0] - 2022-12-06 ### Changed diff --git a/src/lib.rs b/src/lib.rs index 27ed5c9..b59c590 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -76,7 +76,7 @@ pub trait Group: /// this group. /// /// This function is non-deterministic, and samples from the user-provided RNG. - fn random(rng: impl RngCore) -> Self; + fn random(rng: &mut R) -> Self; /// Returns the additive identity, also known as the "neutral element". fn identity() -> Self; From 4456de88184251b95c98e089a74a5c107b494f14 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Sun, 2 Mar 2025 21:37:03 -0800 Subject: [PATCH 06/17] Provide a `Group::try_from_rng` --- CHANGELOG.md | 2 ++ src/lib.rs | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8c7b05..d7434ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ and this library adheres to Rust's notion of - `group::Group::random(rng: impl RngCore) -> Self` has been changed to `Group::random(rng: &mut R) -> Self`, to enable passing a trait object as the RNG. +- `group::Group::try_from_rng` is a new trait method that must be implemented by + downstreams. `Group::random` now has a default implementation that calls it. ## [0.13.0] - 2022-12-06 ### Changed diff --git a/src/lib.rs b/src/lib.rs index b59c590..3116649 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,11 +9,12 @@ extern crate alloc; // Re-export ff to make version-matching easier. pub use ff; +use core::convert::Infallible; use core::fmt; use core::iter::Sum; use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign}; use ff::PrimeField; -use rand_core::RngCore; +use rand_core::{RngCore, TryRngCore}; use subtle::{Choice, CtOption}; pub mod cofactor; @@ -76,7 +77,22 @@ pub trait Group: /// this group. /// /// This function is non-deterministic, and samples from the user-provided RNG. - fn random(rng: &mut R) -> Self; + fn random(rng: &mut R) -> Self { + Self::try_from_rng(rng) + .map_err(|e: Infallible| e) + .expect("Infallible failed") + + // NOTE: once MSRV gets to 1.82 remove the map_err/expect and use + // let Ok(out) = Self::try_from_rng(rng); + // out + // See: https://blog.rust-lang.org/2024/10/17/Rust-1.82.0.html#omitting-empty-types-in-pattern-matching + } + + /// Returns an element chosen uniformly at random from the non-identity elements of + /// this group. + /// + /// This function is non-deterministic, and samples from the user-provided RNG. + fn try_from_rng(rng: &mut R) -> Result; /// Returns the additive identity, also known as the "neutral element". fn identity() -> Self; From a2604792918e9a60c4ddf28d4572a0ac3378e968 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Thu, 17 Apr 2025 17:41:39 +0000 Subject: [PATCH 07/17] Preview 0.14.0-pre.0 --- Cargo.lock | 7 ++++--- Cargo.toml | 7 ++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c0263ce..cffd341 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,8 +4,9 @@ version = 3 [[package]] name = "ff" -version = "0.13.1" -source = "git+https://github.com/zkcrypto/ff.git?rev=241caff9bcedafbe279b5a4d875461f66b3f9701#241caff9bcedafbe279b5a4d875461f66b3f9701" +version = "0.14.0-pre.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d42dd26f5790eda47c1a2158ea4120e32c35ddc9a7743c98a292accc01b54ef3" dependencies = [ "rand_core", "subtle", @@ -13,7 +14,7 @@ dependencies = [ [[package]] name = "group" -version = "0.13.0" +version = "0.14.0-pre.0" dependencies = [ "ff", "memuse", diff --git a/Cargo.toml b/Cargo.toml index b666707..a153e74 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "group" -version = "0.13.0" +version = "0.14.0-pre.0" authors = [ "Sean Bowe ", "Jack Grigg ", @@ -16,7 +16,7 @@ homepage = "https://github.com/zkcrypto/group" repository = "https://github.com/zkcrypto/group" [dependencies] -ff = { version = "0.13", default-features = false } +ff = { version = "=0.14.0-pre.0", default-features = false } rand = { version = "0.9", optional = true, default-features = false } rand_core = { version = "0.9", default-features = false } rand_xorshift = { version = "0.4", optional = true } @@ -33,6 +33,3 @@ wnaf-memuse = ["alloc", "memuse"] [badges] maintenance = { status = "actively-developed" } - -[patch.crates-io] -ff = { git = "https://github.com/zkcrypto/ff.git", rev = "241caff9bcedafbe279b5a4d875461f66b3f9701" } From b1e077799c7107b645fb7fa840f3d1084a67c121 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Fri, 21 Nov 2025 16:49:24 -0700 Subject: [PATCH 08/17] Fork `group` as `rustcrypto-group` (#2) Adds a `rustcrypto-*` prefix to the crate name so we can do our own releases, since we're having trouble getting updates merged upstream: zkcrypto/group#69 --- .github/workflows/ci.yml | 6 +++--- Cargo.lock | 24 ++++++++++++------------ Cargo.toml | 10 +++++----- README.md | 6 +++++- src/lib.rs | 2 +- 5 files changed, 26 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 39f9e7b..e3c5b1e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] + os: [ ubuntu-latest, windows-latest, macOS-latest ] steps: - uses: actions/checkout@v4 - name: Run tests @@ -24,7 +24,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] + os: [ ubuntu-latest, windows-latest, macOS-latest ] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable @@ -66,7 +66,7 @@ jobs: - name: Add group as a dependency of the synthetic crate working-directory: ./ci-build # run: cargo add --no-default-features --path ../crate_root - run: sed -i 's;\[dependencies\];\[dependencies\]\ngroup = { path = "../crate_root", default-features = false };g' ./Cargo.toml + run: sed -i 's;\[dependencies\];\[dependencies\]\nrustcrypto-group = { path = "../crate_root", default-features = false };g' ./Cargo.toml - name: Add target working-directory: ./ci-build run: rustup target add ${{ matrix.target }} diff --git a/Cargo.lock b/Cargo.lock index cffd341..195723b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12,18 +12,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "group" -version = "0.14.0-pre.0" -dependencies = [ - "ff", - "memuse", - "rand", - "rand_core", - "rand_xorshift", - "subtle", -] - [[package]] name = "memuse" version = "0.2.2" @@ -73,6 +61,18 @@ dependencies = [ "rand_core", ] +[[package]] +name = "rustcrypto-group" +version = "0.14.0-pre" +dependencies = [ + "ff", + "memuse", + "rand", + "rand_core", + "rand_xorshift", + "subtle", +] + [[package]] name = "subtle" version = "2.6.1" diff --git a/Cargo.toml b/Cargo.toml index a153e74..b954b3c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "group" -version = "0.14.0-pre.0" +name = "rustcrypto-group" +version = "0.14.0-pre" authors = [ "Sean Bowe ", "Jack Grigg ", @@ -11,9 +11,9 @@ readme = "README.md" license = "MIT/Apache-2.0" description = "Elliptic curve group traits and utilities" -documentation = "https://docs.rs/group/" -homepage = "https://github.com/zkcrypto/group" -repository = "https://github.com/zkcrypto/group" +documentation = "https://docs.rs/rustcrypto-group/" +homepage = "https://github.com/RustCrypto/group" +repository = "https://github.com/RustCrypto/group" [dependencies] ff = { version = "=0.14.0-pre.0", default-features = false } diff --git a/README.md b/README.md index efff81c..1c4c3cc 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ -# group [![Crates.io](https://img.shields.io/crates/v/group.svg)](https://crates.io/crates/group) # +# [RustCrypto]: group [![Crates.io](https://img.shields.io/crates/v/group.svg)](https://crates.io/crates/group) # `group` is a crate for working with groups over elliptic curves. +This is a fork of: https://github.com/zkcrypto/group + ## RFC process This crate follows the [zkcrypto RFC process](https://zkcrypto.github.io/rfcs/). @@ -32,3 +34,5 @@ Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. + +[RustCrypto]: https://github.com/rustcrypto/ diff --git a/src/lib.rs b/src/lib.rs index cd3cf5e..0217640 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -141,7 +141,7 @@ pub trait GroupEncoding: Sized { /// The `Default` implementation is not required to return a valid point encoding. The /// bound is present to enable encodings to be constructed generically: /// ``` - /// # use group::GroupEncoding; + /// # use rustcrypto_group::GroupEncoding; /// # use subtle::CtOption; /// # struct G; /// # impl GroupEncoding for G { From e143feed620fc22100ba1b2aa2f746a689079c58 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Fri, 21 Nov 2025 17:09:17 -0700 Subject: [PATCH 09/17] Bump `rand_core` dependency to v0.10.0-rc-2 (#3) This brings a new MSRV of 1.85 --- .github/workflows/ci.yml | 2 +- Cargo.lock | 88 ++++++++-------------------------------- Cargo.toml | 10 ++--- README.md | 2 +- rust-toolchain.toml | 4 +- 5 files changed, 25 insertions(+), 81 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e3c5b1e..c0aaa97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,7 @@ jobs: strategy: matrix: target: - - wasm32-wasi + - wasm32-wasip1 - thumbv6m-none-eabi - thumbv7em-none-eabihf steps: diff --git a/Cargo.lock b/Cargo.lock index 195723b..b2cea80 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,16 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 - -[[package]] -name = "ff" -version = "0.14.0-pre.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d42dd26f5790eda47c1a2158ea4120e32c35ddc9a7743c98a292accc01b54ef3" -dependencies = [ - "rand_core", - "subtle", -] +version = 4 [[package]] name = "memuse" @@ -19,57 +9,48 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d97bbf43eb4f088f8ca469930cde17fa036207c9a5e02ccc5107c4e8b17c964" [[package]] -name = "proc-macro2" -version = "1.0.95" +name = "rand" +version = "0.10.0-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +checksum = "be866deebbade98028b705499827ad6967c8bb1e21f96a2609913c8c076e9307" dependencies = [ - "unicode-ident", + "rand_core", ] [[package]] -name = "quote" -version = "1.0.40" +name = "rand_core" +version = "0.10.0-rc-2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" -dependencies = [ - "proc-macro2", -] +checksum = "104a23e4e8b77312a823b6b5613edbac78397e2f34320bc7ac4277013ec4478e" [[package]] -name = "rand" -version = "0.9.0" +name = "rand_xorshift" +version = "0.5.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" +checksum = "436a253927905fba96fc027756937b9d20e8e654e2622a6192a8037c3340dc35" dependencies = [ "rand_core", - "zerocopy", ] [[package]] -name = "rand_core" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" - -[[package]] -name = "rand_xorshift" -version = "0.4.0" +name = "rustcrypto-ff" +version = "0.14.0-pre.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "513962919efc330f829edb2535844d1b912b0fbe2ca165d613e4e8788bb05a5a" +checksum = "aa9cd37111549306f79b09aa2618e15b1e8241b7178c286821e3dd71579db4db" dependencies = [ "rand_core", + "subtle", ] [[package]] name = "rustcrypto-group" version = "0.14.0-pre" dependencies = [ - "ff", "memuse", "rand", "rand_core", "rand_xorshift", + "rustcrypto-ff", "subtle", ] @@ -78,40 +59,3 @@ name = "subtle" version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" - -[[package]] -name = "syn" -version = "2.0.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "unicode-ident" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" - -[[package]] -name = "zerocopy" -version = "0.8.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.8.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] diff --git a/Cargo.toml b/Cargo.toml index b954b3c..a276aad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ authors = [ "Jack Grigg ", ] edition = "2021" -rust-version = "1.63" +rust-version = "1.85" readme = "README.md" license = "MIT/Apache-2.0" @@ -16,10 +16,10 @@ homepage = "https://github.com/RustCrypto/group" repository = "https://github.com/RustCrypto/group" [dependencies] -ff = { version = "=0.14.0-pre.0", default-features = false } -rand = { version = "0.9", optional = true, default-features = false } -rand_core = { version = "0.9", default-features = false } -rand_xorshift = { version = "0.4", optional = true } +ff = { version = "=0.14.0-pre.0", package = "rustcrypto-ff", default-features = false } +rand = { version = "0.10.0-rc.1", optional = true, default-features = false } +rand_core = { version = "0.10.0-rc-2", default-features = false } +rand_xorshift = { version = "0.5.0-rc.0", optional = true } subtle = { version = "2.2.1", default-features = false } # Crate for exposing the dynamic memory usage of the w-NAF structs. diff --git a/README.md b/README.md index 1c4c3cc..c3b4dc0 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ wider discussion. ## Minimum Supported Rust Version -Requires Rust **1.63** or higher. +Requires Rust **1.85** or higher. Minimum supported Rust version can be changed in the future, but it will be done with a minor version bump. diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 3eebdfe..e22c344 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.63.0" -components = [ "clippy", "rustfmt" ] +channel = "1.85.0" +components = ["clippy", "rustfmt"] From dbd8e6cfc110f28d38e7304bfb9a36e477810cc1 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Fri, 21 Nov 2025 17:11:18 -0700 Subject: [PATCH 10/17] v0.14.0-pre.0 (#4) --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b2cea80..6a57778 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,7 +44,7 @@ dependencies = [ [[package]] name = "rustcrypto-group" -version = "0.14.0-pre" +version = "0.14.0-pre.0" dependencies = [ "memuse", "rand", diff --git a/Cargo.toml b/Cargo.toml index a276aad..8bcf843 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustcrypto-group" -version = "0.14.0-pre" +version = "0.14.0-pre.0" authors = [ "Sean Bowe ", "Jack Grigg ", From 82ce1a72749960b11233f0b6fc9da73e86c52490 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Sat, 24 Jan 2026 12:48:26 -0700 Subject: [PATCH 11/17] Bump `rand_core` to v0.10.0-rc-6 (#5) --- .github/workflows/ci.yml | 73 ++++++++++++++++++++-------------------- Cargo.lock | 52 +++++++++++++++++++--------- Cargo.toml | 13 ++++--- src/lib.rs | 6 ++-- src/tests/mod.rs | 52 +++++++++------------------- 5 files changed, 101 insertions(+), 95 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c0aaa97..b156653 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,42 +37,43 @@ jobs: - name: Verify working directory is clean (excluding lockfile) run: git diff --exit-code ':!Cargo.lock' - build-nodefault: - name: Build target ${{ matrix.target }} - runs-on: ubuntu-latest - strategy: - matrix: - target: - - wasm32-wasip1 - - thumbv6m-none-eabi - - thumbv7em-none-eabihf - steps: - - uses: actions/checkout@v4 - with: - path: crate_root - # We use a synthetic crate to ensure no dev-dependencies are enabled, which can - # be incompatible with some of these targets. - - name: Create synthetic crate for testing - run: cargo init --edition 2021 --lib ci-build - - name: Copy Rust version into synthetic crate - run: cp crate_root/rust-toolchain.toml ci-build/ - - name: Copy patch directives into synthetic crate - run: | - echo "[patch.crates-io]" >> ./ci-build/Cargo.toml - cat ./crate_root/Cargo.toml | sed "0,/.\+\(patch.crates.\+\)/d" >> ./ci-build/Cargo.toml - - name: Add no_std pragma to lib.rs - run: | - echo "#![no_std]" > ./ci-build/src/lib.rs - - name: Add group as a dependency of the synthetic crate - working-directory: ./ci-build - # run: cargo add --no-default-features --path ../crate_root - run: sed -i 's;\[dependencies\];\[dependencies\]\nrustcrypto-group = { path = "../crate_root", default-features = false };g' ./Cargo.toml - - name: Add target - working-directory: ./ci-build - run: rustup target add ${{ matrix.target }} - - name: Build for target - working-directory: ./ci-build - run: cargo build --verbose --target ${{ matrix.target }} + # The scripts embedded in this job are having trouble parsing our branch names + # build-nodefault: + # name: Build target ${{ matrix.target }} + # runs-on: ubuntu-latest + # strategy: + # matrix: + # target: + # - wasm32-wasip1 + # - thumbv6m-none-eabi + # - thumbv7em-none-eabihf + # steps: + # - uses: actions/checkout@v4 + # with: + # path: crate_root + # # We use a synthetic crate to ensure no dev-dependencies are enabled, which can + # # be incompatible with some of these targets. + # - name: Create synthetic crate for testing + # run: cargo init --edition 2021 --lib ci-build + # - name: Copy Rust version into synthetic crate + # run: cp crate_root/rust-toolchain.toml ci-build/ + # - name: Copy patch directives into synthetic crate + # run: | + # echo "[patch.crates-io]" >> ./ci-build/Cargo.toml + # cat ./crate_root/Cargo.toml | sed "0,/.\+\(patch.crates.\+\)/d" >> ./ci-build/Cargo.toml + # - name: Add no_std pragma to lib.rs + # run: | + # echo "#![no_std]" > ./ci-build/src/lib.rs + # - name: Add group as a dependency of the synthetic crate + # working-directory: ./ci-build + # # run: cargo add --no-default-features --path ../crate_root + # run: sed -i 's;\[dependencies\];\[dependencies\]\nrustcrypto-group = { path = "../crate_root", default-features = false };g' ./Cargo.toml + # - name: Add target + # working-directory: ./ci-build + # run: rustup target add ${{ matrix.target }} + # - name: Build for target + # working-directory: ./ci-build + # run: cargo build --verbose --target ${{ matrix.target }} doc-links: name: Intra-doc links diff --git a/Cargo.lock b/Cargo.lock index 6a57778..5ddc847 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,40 +3,62 @@ version = 4 [[package]] -name = "memuse" -version = "0.2.2" +name = "cfg-if" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d97bbf43eb4f088f8ca469930cde17fa036207c9a5e02ccc5107c4e8b17c964" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] -name = "rand" -version = "0.10.0-rc.5" +name = "chacha20" +version = "0.10.0-rc.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be866deebbade98028b705499827ad6967c8bb1e21f96a2609913c8c076e9307" +checksum = "c81d916c6ae06736ec667b51f95ee5ff660a75f4ea6ce1bd932c942365c0ea43" dependencies = [ + "cfg-if", + "cpufeatures", "rand_core", ] [[package]] -name = "rand_core" -version = "0.10.0-rc-2" +name = "cpufeatures" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "104a23e4e8b77312a823b6b5613edbac78397e2f34320bc7ac4277013ec4478e" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] [[package]] -name = "rand_xorshift" -version = "0.5.0-rc.0" +name = "libc" +version = "0.2.180" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436a253927905fba96fc027756937b9d20e8e654e2622a6192a8037c3340dc35" +checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" + +[[package]] +name = "memuse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d97bbf43eb4f088f8ca469930cde17fa036207c9a5e02ccc5107c4e8b17c964" + +[[package]] +name = "rand" +version = "0.10.0-rc.7" +source = "git+https://github.com/rust-random/rand?branch=rand_core%2Fv0.10.0-rc-6#79d9026b7284bc574401fe39cc763af09d6d092c" dependencies = [ "rand_core", ] +[[package]] +name = "rand_core" +version = "0.10.0-rc-6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70765ff7112b0fb2d272d24d9a2f907fc206211304328fe58b2db15a5649ef28" + [[package]] name = "rustcrypto-ff" -version = "0.14.0-pre.0" +version = "0.14.0-pre.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa9cd37111549306f79b09aa2618e15b1e8241b7178c286821e3dd71579db4db" +checksum = "36fdf8f956089df8343b9479045c026932f9eb004d0f32d8497b4d133b316a66" dependencies = [ "rand_core", "subtle", @@ -46,10 +68,10 @@ dependencies = [ name = "rustcrypto-group" version = "0.14.0-pre.0" dependencies = [ + "chacha20", "memuse", "rand", "rand_core", - "rand_xorshift", "rustcrypto-ff", "subtle", ] diff --git a/Cargo.toml b/Cargo.toml index 8bcf843..d4cf03f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,10 +16,11 @@ homepage = "https://github.com/RustCrypto/group" repository = "https://github.com/RustCrypto/group" [dependencies] -ff = { version = "=0.14.0-pre.0", package = "rustcrypto-ff", default-features = false } +chacha20 = { version = "0.10.0-rc.9", optional = true, default-features = false, features = ["rng"] } +ff = { version = "=0.14.0-pre.1", package = "rustcrypto-ff", default-features = false } rand = { version = "0.10.0-rc.1", optional = true, default-features = false } -rand_core = { version = "0.10.0-rc-2", default-features = false } -rand_xorshift = { version = "0.5.0-rc.0", optional = true } +rand_core = { version = "0.10.0-rc-6", default-features = false } +#rand_xorshift = { version = "0.5.0-rc.0", optional = true } subtle = { version = "2.2.1", default-features = false } # Crate for exposing the dynamic memory usage of the w-NAF structs. @@ -28,8 +29,12 @@ memuse = { version = "0.2", optional = true } [features] default = ["alloc"] alloc = [] -tests = ["alloc", "rand", "rand_xorshift"] +tests = ["alloc", "chacha20", "rand"] # "rand_xorshift"] wnaf-memuse = ["alloc", "memuse"] [badges] maintenance = { status = "actively-developed" } + +[patch.crates-io.rand] +git = "https://github.com/rust-random/rand" +branch = "rand_core/v0.10.0-rc-6" diff --git a/src/lib.rs b/src/lib.rs index 0217640..a41714e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,7 +14,7 @@ use core::fmt; use core::iter::Sum; use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign}; use ff::PrimeField; -use rand_core::{RngCore, TryRngCore}; +use rand_core::{Rng, TryRng}; use subtle::{Choice, CtOption}; pub mod cofactor; @@ -77,7 +77,7 @@ pub trait Group: /// this group. /// /// This function is non-deterministic, and samples from the user-provided RNG. - fn random(rng: &mut R) -> Self { + fn random(rng: &mut R) -> Self { Self::try_from_rng(rng) .map_err(|e: Infallible| e) .expect("Infallible failed") @@ -92,7 +92,7 @@ pub trait Group: /// this group. /// /// This function is non-deterministic, and samples from the user-provided RNG. - fn try_from_rng(rng: &mut R) -> Result; + fn try_from_rng(rng: &mut R) -> Result; /// Returns the additive identity, also known as the "neutral element". fn identity() -> Self; diff --git a/src/tests/mod.rs b/src/tests/mod.rs index c81a926..71bb753 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,11 +10,13 @@ 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 = XorShiftRng::from_seed([ - 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, - 0xe5, - ]); + let mut rng = ChaCha8Rng::from_seed(RNG_SEED); // Negation edge case with identity. { @@ -72,10 +74,7 @@ pub fn curve_tests() { pub fn random_wnaf_tests() { use crate::wnaf::*; - let mut rng = XorShiftRng::from_seed([ - 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, - 0xe5, - ]); + let mut rng = ChaCha8Rng::from_seed(RNG_SEED); { let mut table = vec![]; @@ -189,10 +188,7 @@ pub fn random_wnaf_tests() { } fn random_negation_tests() { - let mut rng = XorShiftRng::from_seed([ - 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, - 0xe5, - ]); + let mut rng = ChaCha8Rng::from_seed(RNG_SEED); for _ in 0..1000 { let r = G::random(&mut rng); @@ -219,10 +215,7 @@ fn random_negation_tests() { } fn random_doubling_tests() { - let mut rng = XorShiftRng::from_seed([ - 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, - 0xe5, - ]); + let mut rng = ChaCha8Rng::from_seed(RNG_SEED); for _ in 0..1000 { let mut a = G::random(&mut rng); @@ -247,10 +240,7 @@ fn random_doubling_tests() { } fn random_multiplication_tests() { - let mut rng = XorShiftRng::from_seed([ - 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, - 0xe5, - ]); + let mut rng = ChaCha8Rng::from_seed(RNG_SEED); for _ in 0..1000 { let mut a = G::random(&mut rng); @@ -282,10 +272,7 @@ fn random_multiplication_tests() { } fn random_addition_tests() { - let mut rng = XorShiftRng::from_seed([ - 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, - 0xe5, - ]); + let mut rng = ChaCha8Rng::from_seed(RNG_SEED); for _ in 0..1000 { let a = G::random(&mut rng); @@ -362,10 +349,7 @@ fn random_addition_tests() { } fn random_transformation_tests() { - let mut rng = XorShiftRng::from_seed([ - 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, - 0xe5, - ]); + let mut rng = ChaCha8Rng::from_seed(RNG_SEED); for _ in 0..1000 { let g = G::random(&mut rng); @@ -399,10 +383,7 @@ fn random_transformation_tests() { } fn random_compressed_encoding_tests() { - let mut rng = XorShiftRng::from_seed([ - 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, - 0xe5, - ]); + let mut rng = ChaCha8Rng::from_seed(RNG_SEED); assert_eq!( G::Affine::from_bytes(&G::Affine::identity().to_bytes()).unwrap(), @@ -428,10 +409,7 @@ pub fn random_uncompressed_encoding_tests() where ::Affine: UncompressedEncoding, { - let mut rng = XorShiftRng::from_seed([ - 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, - 0xe5, - ]); + let mut rng = ChaCha8Rng::from_seed(RNG_SEED); assert_eq!( G::Affine::from_uncompressed(&G::Affine::identity().to_uncompressed()).unwrap(), From 1be1a554c12fde40c36eae9a7c64af12b42701c2 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Sat, 24 Jan 2026 12:54:23 -0700 Subject: [PATCH 12/17] v0.14.0-pre.1 (#6) --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5ddc847..2ba7e14 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,7 +66,7 @@ dependencies = [ [[package]] name = "rustcrypto-group" -version = "0.14.0-pre.0" +version = "0.14.0-pre.1" dependencies = [ "chacha20", "memuse", diff --git a/Cargo.toml b/Cargo.toml index d4cf03f..095bd27 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustcrypto-group" -version = "0.14.0-pre.0" +version = "0.14.0-pre.1" authors = [ "Sean Bowe ", "Jack Grigg ", From dfc80811c70fe4aeb3370fe1f5e9d0b976df74b4 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Mon, 2 Feb 2026 11:14:48 -0700 Subject: [PATCH 13/17] Bump `rand_core` dependency to v0.10 (#7) Also bumps `rustcrypto-ff` to v0.14.0-rc.0 --- Cargo.lock | 16 ++++++++-------- Cargo.toml | 9 ++++----- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2ba7e14..2111fb7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,9 +10,9 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "chacha20" -version = "0.10.0-rc.9" +version = "0.10.0-rc.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c81d916c6ae06736ec667b51f95ee5ff660a75f4ea6ce1bd932c942365c0ea43" +checksum = "c536927023d1c432e6e23a25ef45f6756094eac2ab460db5fb17a772acdfd312" dependencies = [ "cfg-if", "cpufeatures", @@ -42,23 +42,23 @@ checksum = "3d97bbf43eb4f088f8ca469930cde17fa036207c9a5e02ccc5107c4e8b17c964" [[package]] name = "rand" -version = "0.10.0-rc.7" -source = "git+https://github.com/rust-random/rand?branch=rand_core%2Fv0.10.0-rc-6#79d9026b7284bc574401fe39cc763af09d6d092c" +version = "0.10.0-rc.8" +source = "git+https://github.com/rust-random/rand#9c98f59e8b042e5c7c714e933e49b384a4ce75a6" dependencies = [ "rand_core", ] [[package]] name = "rand_core" -version = "0.10.0-rc-6" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70765ff7112b0fb2d272d24d9a2f907fc206211304328fe58b2db15a5649ef28" +checksum = "0c8d0fd677905edcbeedbf2edb6494d676f0e98d54d5cf9bda0b061cb8fb8aba" [[package]] name = "rustcrypto-ff" -version = "0.14.0-pre.1" +version = "0.14.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36fdf8f956089df8343b9479045c026932f9eb004d0f32d8497b4d133b316a66" +checksum = "c5db129183b2c139d7d87d08be57cba626c715789db17aec65c8866bfd767d1f" dependencies = [ "rand_core", "subtle", diff --git a/Cargo.toml b/Cargo.toml index 095bd27..f712080 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,10 +16,10 @@ homepage = "https://github.com/RustCrypto/group" repository = "https://github.com/RustCrypto/group" [dependencies] -chacha20 = { version = "0.10.0-rc.9", optional = true, default-features = false, features = ["rng"] } -ff = { version = "=0.14.0-pre.1", package = "rustcrypto-ff", default-features = false } -rand = { version = "0.10.0-rc.1", optional = true, default-features = false } -rand_core = { version = "0.10.0-rc-6", default-features = false } +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_core = { version = "0.10", default-features = false } #rand_xorshift = { version = "0.5.0-rc.0", optional = true } subtle = { version = "2.2.1", default-features = false } @@ -37,4 +37,3 @@ maintenance = { status = "actively-developed" } [patch.crates-io.rand] git = "https://github.com/rust-random/rand" -branch = "rand_core/v0.10.0-rc-6" From 5203ec9c4a46e8843f73e712849c504fedd0fa74 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Mon, 2 Feb 2026 11:17:32 -0700 Subject: [PATCH 14/17] v0.14.0-rc.0 (#8) --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2111fb7..7847b25 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,7 +66,7 @@ dependencies = [ [[package]] name = "rustcrypto-group" -version = "0.14.0-pre.1" +version = "0.14.0-rc.0" dependencies = [ "chacha20", "memuse", diff --git a/Cargo.toml b/Cargo.toml index f712080..b3d224c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustcrypto-group" -version = "0.14.0-pre.1" +version = "0.14.0-rc.0" authors = [ "Sean Bowe ", "Jack Grigg ", From 50ad1c4508b5e93575ca6ca39f505a1a8de37bc1 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Tue, 31 Mar 2026 08:31:31 -0600 Subject: [PATCH 15/17] Bump `rand` dependency to v0.10 (#11) 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(), From 1de70abfdcf55f5bf0820a654e0943f96313f0fd Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Tue, 31 Mar 2026 09:56:18 -0600 Subject: [PATCH 16/17] Have wNAF use `PrimeField::to_le_repr` for scalars (#12) The wNAF implementation assumes a little endian representation for scalars, but `PrimeField::to_repr` returns an opaque representation which may be big endian and is in the case of our implementations of the NIST P-curves. RustCrypto/ff#10 added a stopgap API: `PrimeField::to_le_repr`, which is guaranteed to return a little endian representation. This commit switches `(rustcrypto-)group` to use it, which should make it compatible with our curves which otherwise use a big endian SEC1 representation. --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- src/wnaf.rs | 13 ++++++++++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 23b5b62..ae10e5b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,9 +34,9 @@ dependencies = [ [[package]] name = "rustcrypto-ff" -version = "0.14.0-rc.0" +version = "0.14.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5db129183b2c139d7d87d08be57cba626c715789db17aec65c8866bfd767d1f" +checksum = "fd2a8adb347447693cd2ba0d218c4b66c62da9b0a5672b17b981e4291ec65ff6" dependencies = [ "rand_core", "subtle", diff --git a/Cargo.toml b/Cargo.toml index 56f5588..e8e57ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ homepage = "https://github.com/RustCrypto/group" repository = "https://github.com/RustCrypto/group" [dependencies] -ff = { version = "0.14.0-rc.0", package = "rustcrypto-ff", default-features = false } +ff = { version = "0.14.0-rc.1", package = "rustcrypto-ff", 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", optional = true } diff --git a/src/wnaf.rs b/src/wnaf.rs index fdcf432..63c886c 100644 --- a/src/wnaf.rs +++ b/src/wnaf.rs @@ -144,6 +144,13 @@ pub(crate) fn wnaf_form>(wnaf: &mut Vec, c: S, window: usize pos += window; } } + + // If there is a remaining carry (the scalar used all `bit_len` bits + // and the last wNAF digit was negative), emit it so the + // representation is exact. + if carry != 0 { + wnaf.push(carry as i64); + } } /// Performs w-NAF exponentiation with the provided window table and w-NAF form scalar. @@ -315,7 +322,7 @@ impl Wnaf<(), Vec, Vec> { let window_size = 4; // Compute the wNAF form of the scalar. - wnaf_form(&mut self.scalar, scalar.to_repr(), window_size); + wnaf_form(&mut self.scalar, scalar.to_le_repr(), window_size); // Return a Wnaf object that mutably borrows the base storage location, but // immutably borrows the computed wNAF form scalar location. @@ -393,7 +400,7 @@ impl>> Wnaf { where B: AsRef<[G]>, { - wnaf_form(self.scalar.as_mut(), scalar.to_repr(), self.window_size); + wnaf_form(self.scalar.as_mut(), scalar.to_le_repr(), self.window_size); wnaf_exp(self.base.as_ref(), self.scalar.as_mut()) } } @@ -428,7 +435,7 @@ impl WnafScalar { let mut wnaf = vec![]; // Compute the w-NAF form of the scalar. - wnaf_form(&mut wnaf, scalar.to_repr(), WINDOW_SIZE); + wnaf_form(&mut wnaf, scalar.to_le_repr(), WINDOW_SIZE); WnafScalar { wnaf, From 04930ff47d555bcc1477b544e6779c782dd8c6a2 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Tue, 31 Mar 2026 13:30:06 -0600 Subject: [PATCH 17/17] v0.14.0-rc.1 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ae10e5b..24c6046 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,7 +44,7 @@ dependencies = [ [[package]] name = "rustcrypto-group" -version = "0.14.0-rc.0" +version = "0.14.0-rc.1" dependencies = [ "memuse", "rand", diff --git a/Cargo.toml b/Cargo.toml index e8e57ce..361f4b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustcrypto-group" -version = "0.14.0-rc.0" +version = "0.14.0-rc.1" authors = [ "Sean Bowe ", "Jack Grigg ",