Skip to content

Commit c73ed28

Browse files
committed
Bump rand_core to v0.10.0-rc-3
Most of the changes in this PR are actually from the associated `rand` crate updates which are happening in rust-random/rand#1697, notably `OsRng` has been renamed to `SysRng` (and is now provided by the `getrandom` crate). We do use some `rand_core` APIs in a few places though, like the STROBE implementation, where this migrates from `rand_core::le` to `rand_core::utils`.
1 parent 0a09c4e commit c73ed28

File tree

20 files changed

+87
-83
lines changed

20 files changed

+87
-83
lines changed

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ opt-level = 2
1414
curve25519-dalek-derive = { path = "./curve25519-dalek-derive" }
1515
curve25519-dalek = { path = "./curve25519-dalek" }
1616
x25519-dalek = { path = "./x25519-dalek" }
17+
18+
# https://github.com/rust-random/rand/pull/1697
19+
rand = { git = "https://github.com/rust-random/rand", rev = "99ae06fb348e5c5fee0fe41d2201bd4cbb107635" }
20+
getrandom = { git = "https://github.com/rust-random/getrandom.git", rev = "f67c70110f706f80d7dd6fa52e38d0920754fe2c" }

curve25519-dalek/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ required-features = ["alloc", "rand_core"]
5050
cfg-if = "1"
5151
ff = { version = "=0.14.0-pre.0", package = "rustcrypto-ff", default-features = false, optional = true }
5252
group = { version = "=0.14.0-pre.0", package = "rustcrypto-group", default-features = false, optional = true }
53-
rand_core = { version = "0.10.0-rc-2", default-features = false, optional = true }
53+
rand_core = { version = "0.10.0-rc-3", default-features = false, optional = true }
5454
digest = { version = "0.11.0-rc.4", default-features = false, optional = true, features = [
5555
"block-api",
5656
] }

curve25519-dalek/benches/dalek_benchmarks.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![allow(non_snake_case)]
22

3-
use rand::{RngCore, TryRngCore, rng, rngs::OsRng};
3+
use rand::{RngCore, TryRngCore, rng, rngs::SysRng};
44

55
use criterion::{
66
BatchSize, BenchmarkGroup, BenchmarkId, Criterion, criterion_main, measurement::Measurement,
@@ -31,7 +31,7 @@ mod edwards_benches {
3131
BenchmarkId::new("Batch EdwardsPoint compression", batch_size),
3232
&batch_size,
3333
|b, &size| {
34-
let mut rng = OsRng.unwrap_err();
34+
let mut rng = SysRng.unwrap_err();
3535
let points: Vec<EdwardsPoint> =
3636
(0..size).map(|_| EdwardsPoint::random(&mut rng)).collect();
3737
b.iter(|| EdwardsPoint::compress_batch_alloc(&points));
@@ -301,7 +301,7 @@ mod ristretto_benches {
301301
BenchmarkId::new("Batch Ristretto double-and-encode", *batch_size),
302302
&batch_size,
303303
|b, &&size| {
304-
let mut rng = OsRng;
304+
let mut rng = SysRng;
305305
let points: Vec<RistrettoPoint> = (0..size)
306306
.map(|_| RistrettoPoint::try_from_rng(&mut rng).unwrap())
307307
.collect();
@@ -388,7 +388,7 @@ mod scalar_benches {
388388
BenchmarkId::new("Batch scalar inversion", *batch_size),
389389
&batch_size,
390390
|b, &&size| {
391-
let mut rng = OsRng.unwrap_err();
391+
let mut rng = SysRng.unwrap_err();
392392
let scalars: Vec<Scalar> =
393393
(0..size).map(|_| Scalar::random(&mut rng)).collect();
394394
b.iter(|| {

curve25519-dalek/src/edwards.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2080,7 +2080,7 @@ mod test {
20802080
/// Check that mul_base_clamped and mul_clamped agree
20812081
#[test]
20822082
fn mul_base_clamped() {
2083-
let mut csprng = rand::rngs::OsRng;
2083+
let mut csprng = rand::rngs::SysRng;
20842084

20852085
// Make a random curve point in the curve. Give it torsion to make things interesting.
20862086
#[cfg(feature = "precomputed-tables")]

curve25519-dalek/src/montgomery.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ mod test {
622622
#[cfg(feature = "rand_core")]
623623
#[test]
624624
fn montgomery_ladder_matches_edwards_scalarmult() {
625-
let mut csprng = rand::rngs::OsRng.unwrap_err();
625+
let mut csprng = rand::rngs::SysRng.unwrap_err();
626626

627627
for _ in 0..100 {
628628
let p_edwards = rand_prime_order_point(&mut csprng);
@@ -641,7 +641,7 @@ mod test {
641641
#[cfg(feature = "rand_core")]
642642
#[test]
643643
fn montgomery_mul_bits_be() {
644-
let mut csprng = rand::rngs::OsRng.unwrap_err();
644+
let mut csprng = rand::rngs::SysRng.unwrap_err();
645645

646646
for _ in 0..100 {
647647
// Make a random prime-order point P
@@ -666,7 +666,7 @@ mod test {
666666
// integers b₁, b₂ and random (curve or twist) point P.
667667
#[test]
668668
fn montgomery_mul_bits_be_twist() {
669-
let mut csprng = rand::rngs::OsRng.unwrap_err();
669+
let mut csprng = rand::rngs::SysRng.unwrap_err();
670670

671671
for _ in 0..100 {
672672
// Make a random point P on the curve or its twist
@@ -699,7 +699,7 @@ mod test {
699699
/// Check that mul_base_clamped and mul_clamped agree
700700
#[test]
701701
fn mul_base_clamped() {
702-
let mut csprng = rand::rngs::OsRng;
702+
let mut csprng = rand::rngs::SysRng;
703703

704704
// Test agreement on a large integer. Even after clamping, this is not reduced mod l.
705705
let a_bytes = [0xff; 32];

curve25519-dalek/src/ristretto.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -543,12 +543,12 @@ impl RistrettoPoint {
543543
#[cfg_attr(feature = "rand_core", doc = "```")]
544544
#[cfg_attr(not(feature = "rand_core"), doc = "```ignore")]
545545
/// # use curve25519_dalek::ristretto::RistrettoPoint;
546-
/// use rand::{rngs::OsRng, TryRngCore};
546+
/// use rand::{rngs::SysRng, TryRngCore};
547547
///
548548
/// # // Need fn main() here in comment so the doctest compiles
549549
/// # // See https://doc.rust-lang.org/book/documentation.html#documentation-as-tests
550550
/// # fn main() {
551-
/// let mut rng = OsRng.unwrap_err();
551+
/// let mut rng = SysRng.unwrap_err();
552552
///
553553
/// let points: Vec<RistrettoPoint> =
554554
/// (0..32).map(|_| RistrettoPoint::random(&mut rng)).collect();
@@ -1278,7 +1278,7 @@ mod test {
12781278
#[cfg(feature = "group")]
12791279
use proptest::prelude::*;
12801280
#[cfg(feature = "rand_core")]
1281-
use rand::{TryRngCore, rngs::OsRng};
1281+
use rand::{TryRngCore, rngs::SysRng};
12821282

12831283
#[test]
12841284
#[cfg(feature = "serde")]
@@ -1472,7 +1472,7 @@ mod test {
14721472
#[cfg(feature = "rand_core")]
14731473
#[test]
14741474
fn four_torsion_random() {
1475-
let mut rng = OsRng.unwrap_err();
1475+
let mut rng = SysRng.unwrap_err();
14761476
let P = RistrettoPoint::mul_base(&Scalar::random(&mut rng));
14771477
let P_coset = P.coset4();
14781478
for point in P_coset {
@@ -1483,7 +1483,7 @@ mod test {
14831483
#[cfg(feature = "rand_core")]
14841484
#[test]
14851485
fn random_roundtrip() {
1486-
let mut rng = OsRng.unwrap_err();
1486+
let mut rng = SysRng.unwrap_err();
14871487
for _ in 0..100 {
14881488
let P = RistrettoPoint::mul_base(&Scalar::random(&mut rng));
14891489
let compressed_P = P.compress();
@@ -1496,7 +1496,7 @@ mod test {
14961496
#[cfg(all(feature = "alloc", feature = "rand_core", feature = "group"))]
14971497
fn double_and_compress_1024_random_points() {
14981498
use group::Group;
1499-
let mut rng = OsRng;
1499+
let mut rng = SysRng;
15001500

15011501
let mut points: Vec<RistrettoPoint> = (0..1024)
15021502
.map(|_| RistrettoPoint::try_from_rng(&mut rng).unwrap())

curve25519-dalek/src/scalar.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,9 +583,9 @@ impl Scalar {
583583
/// # fn main() {
584584
/// use curve25519_dalek::scalar::Scalar;
585585
///
586-
/// use rand::{rngs::OsRng, TryRngCore};
586+
/// use rand::{rngs::SysRng, TryRngCore};
587587
///
588-
/// let mut csprng = OsRng.unwrap_err();
588+
/// let mut csprng = SysRng.unwrap_err();
589589
/// let a: Scalar = Scalar::random(&mut csprng);
590590
/// # }
591591
#[cfg(feature = "rand_core")]

ed25519-dalek/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ subtle = { version = "2.3.0", default-features = false }
3838

3939
# optional features
4040
keccak = { version = "0.2.0-rc.0", default-features = false, optional = true }
41-
rand_core = { version = "0.10.0-rc-2", default-features = false, optional = true }
41+
rand_core = { version = "0.10.0-rc-3", default-features = false, optional = true }
4242
serde = { version = "1.0", default-features = false, optional = true }
4343
zeroize = { version = "1.5", default-features = false, optional = true }
4444

ed25519-dalek/src/batch.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ struct ZeroRng;
5050

5151
impl rand_core::RngCore for ZeroRng {
5252
fn next_u32(&mut self) -> u32 {
53-
rand_core::le::next_u32_via_fill(self)
53+
rand_core::utils::next_word_via_fill(self)
5454
}
5555

5656
fn next_u64(&mut self) -> u64 {
57-
rand_core::le::next_u64_via_fill(self)
57+
rand_core::utils::next_word_via_fill(self)
5858
}
5959

6060
/// A no-op function which leaves the destination bytes for randomness unchanged.
@@ -124,11 +124,11 @@ fn gen_u128<R: RngCore>(rng: &mut R) -> u128 {
124124
/// use ed25519_dalek::{
125125
/// verify_batch, SigningKey, VerifyingKey, Signer, Signature,
126126
/// };
127-
/// use rand::rngs::OsRng;
127+
/// use rand::rngs::SysRng;
128128
/// use rand_core::TryRngCore;
129129
///
130130
/// # fn main() {
131-
/// let mut csprng = OsRng.unwrap_err();
131+
/// let mut csprng = SysRng.unwrap_err();
132132
/// let signing_keys: Vec<_> = (0..64).map(|_| SigningKey::generate(&mut csprng)).collect();
133133
/// let msg: &[u8] = b"They're good dogs Brant";
134134
/// let messages: Vec<_> = (0..64).map(|_| msg).collect();

ed25519-dalek/src/batch/transcript.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,11 @@ pub struct TranscriptRng {
187187

188188
impl rand_core::RngCore for TranscriptRng {
189189
fn next_u32(&mut self) -> u32 {
190-
rand_core::le::next_u32_via_fill(self)
190+
rand_core::utils::next_word_via_fill(self)
191191
}
192192

193193
fn next_u64(&mut self) -> u64 {
194-
rand_core::le::next_u64_via_fill(self)
194+
rand_core::utils::next_word_via_fill(self)
195195
}
196196

197197
fn fill_bytes(&mut self, dest: &mut [u8]) {

0 commit comments

Comments
 (0)