Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ and this library adheres to Rust's notion of
### Changed
- MSRV is now 1.63.0.
- Migrated to `rand_core 0.9`.
- `ff::Field::random(rng: impl RngCore) -> Self` has been changed back to
`Field::random<R: RngCore + ?Sized>(rng: &mut R) -> Self`, to enable passing a
trait object as the RNG.

### Removed
- `derive_bits` feature flag (use `bits` instead).
Expand Down
2 changes: 1 addition & 1 deletion ff_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ fn prime_field_impl(
const ONE: Self = R;

/// Computes a uniformly random element using rejection sampling.
fn random(mut rng: impl ::ff::derive::rand_core::RngCore) -> Self {
fn random<R: ::ff::derive::rand_core::RngCore + ?Sized>(rng: &mut R) -> Self {
loop {
let mut tmp = {
let mut repr = [0u64; #limbs];
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub trait Field:
const ONE: Self;

/// Returns an element chosen uniformly at random using a user-provided RNG.
fn random(rng: impl RngCore) -> Self;
fn random<R: RngCore + ?Sized>(rng: &mut R) -> Self;

/// Returns true iff this element is zero.
fn is_zero(&self) -> Choice {
Expand Down
2 changes: 1 addition & 1 deletion tests/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ mod full_limbs {
fn random_masking_does_not_overflow() {
use ff::Field;

let _ = F384p::random(rand::rng());
let _ = F384p::random(&mut rand::rng());
}
}

Expand Down