Skip to content

Commit

Permalink
elliptic-curve: bump rand_core to 0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
baloo committed Feb 15, 2025
1 parent 684e9bc commit 7eee24b
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 27 deletions.
21 changes: 9 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,13 @@ members = [
crypto-common = { path = "./crypto-common" }
digest = { path = "./digest" }
signature = { path = "./signature" }

# https://github.com/RustCrypto/crypto-bigint/pull/762
# https://github.com/RustCrypto/crypto-bigint/pull/765
crypto-bigint = { git = "https://github.com/RustCrypto/crypto-bigint.git" }

# https://github.com/zkcrypto/ff/pull/122
ff = { git = "https://github.com/pinkforest/ff.git", branch = "bump-rand-core" }

# https://github.com/zkcrypto/group/pull/56
group = { git = "https://github.com/pinkforest/group.git", branch = "bump-rand-0.9" }
4 changes: 2 additions & 2 deletions elliptic-curve/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ rust-version = "1.83"

[dependencies]
base16ct = "0.2"
crypto-bigint = { version = "0.6", default-features = false, features = ["rand_core", "hybrid-array", "zeroize"] }
crypto-bigint = { version = "0.7.0-pre", default-features = false, features = ["rand_core", "hybrid-array", "zeroize"] }
hybrid-array = { version = "0.2", default-features = false, features = ["zeroize"] }
rand_core = { version = "0.6.4", default-features = false }
rand_core = { version = "0.9.0", default-features = false }
subtle = { version = "2.6", default-features = false }
zeroize = { version = "1.7", default-features = false }

Expand Down
4 changes: 2 additions & 2 deletions elliptic-curve/src/ecdh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use core::{borrow::Borrow, fmt};
use digest::{crypto_common::BlockSizeUser, Digest};
use group::Curve as _;
use hkdf::{hmac::SimpleHmac, Hkdf};
use rand_core::CryptoRngCore;
use rand_core::CryptoRng;
use zeroize::{Zeroize, ZeroizeOnDrop};

/// Low-level Elliptic Curve Diffie-Hellman (ECDH) function.
Expand Down Expand Up @@ -108,7 +108,7 @@ where
C: CurveArithmetic,
{
/// Generate a cryptographically random [`EphemeralSecret`].
pub fn random(rng: &mut impl CryptoRngCore) -> Self {
pub fn random<R: CryptoRng>(rng: &mut R) -> Self {
Self {
scalar: NonZeroScalar::random(rng),
}
Expand Down
4 changes: 2 additions & 2 deletions elliptic-curve/src/point/non_identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use core::ops::{Deref, Mul};

use group::{prime::PrimeCurveAffine, Curve, GroupEncoding};
use rand_core::{CryptoRng, RngCore};
use rand_core::CryptoRng;
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};

#[cfg(feature = "serde")]
Expand Down Expand Up @@ -58,7 +58,7 @@ where
P: ConditionallySelectable + ConstantTimeEq + Curve + Default,
{
/// Generate a random `NonIdentity<ProjectivePoint>`.
pub fn random(mut rng: impl CryptoRng + RngCore) -> Self {
pub fn random<R: CryptoRng>(mut rng: R) -> Self {
loop {
if let Some(point) = Self::new(P::random(&mut rng)).into() {
break point;
Expand Down
6 changes: 3 additions & 3 deletions elliptic-curve/src/scalar/blinded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::Scalar;
use crate::{ops::Invert, CurveArithmetic};
use core::fmt;
use group::ff::Field;
use rand_core::CryptoRngCore;
use rand_core::CryptoRng;
use subtle::CtOption;
use zeroize::Zeroize;

Expand Down Expand Up @@ -37,8 +37,8 @@ impl<C> BlindedScalar<C>
where
C: CurveArithmetic,
{
/// Create a new [`BlindedScalar`] from a scalar and a [`CryptoRngCore`].
pub fn new(scalar: Scalar<C>, rng: &mut impl CryptoRngCore) -> Self {
/// Create a new [`BlindedScalar`] from a scalar and a [`CryptoRng`].
pub fn new<R: CryptoRng>(scalar: Scalar<C>, rng: &mut R) -> Self {
Self {
scalar,
mask: Scalar::<C>::random(rng),
Expand Down
4 changes: 2 additions & 2 deletions elliptic-curve/src/scalar/nonzero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use core::{
};
use crypto_bigint::{ArrayEncoding, Integer};
use ff::{Field, PrimeField};
use rand_core::CryptoRngCore;
use rand_core::CryptoRng;
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};
use zeroize::Zeroize;

Expand Down Expand Up @@ -47,7 +47,7 @@ where
C: CurveArithmetic,
{
/// Generate a random `NonZeroScalar`.
pub fn random(mut rng: &mut impl CryptoRngCore) -> Self {
pub fn random<R: CryptoRng>(mut rng: &mut R) -> Self {
// Use rejection sampling to eliminate zero values.
// While this method isn't constant-time, the attacker shouldn't learn
// anything about unrelated outputs so long as `rng` is a secure `CryptoRng`.
Expand Down
4 changes: 2 additions & 2 deletions elliptic-curve/src/scalar/primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use core::{
ops::{Add, AddAssign, Neg, ShrAssign, Sub, SubAssign},
str,
};
use rand_core::CryptoRngCore;
use rand_core::CryptoRng;
use subtle::{
Choice, ConditionallySelectable, ConstantTimeEq, ConstantTimeGreater, ConstantTimeLess,
CtOption,
Expand Down Expand Up @@ -65,7 +65,7 @@ where
pub const MODULUS: C::Uint = C::ORDER;

/// Generate a random [`ScalarPrimitive`].
pub fn random(rng: &mut impl CryptoRngCore) -> Self {
pub fn random<R: CryptoRng>(rng: &mut R) -> Self {
Self {
inner: C::Uint::random_mod(rng, &NonZero::new(Self::MODULUS).unwrap()),
}
Expand Down
4 changes: 2 additions & 2 deletions elliptic-curve/src/secret_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use subtle::{Choice, ConstantTimeEq};
use zeroize::{Zeroize, ZeroizeOnDrop, Zeroizing};

#[cfg(feature = "arithmetic")]
use crate::{rand_core::CryptoRngCore, CurveArithmetic, NonZeroScalar, PublicKey};
use crate::{rand_core::CryptoRng, CurveArithmetic, NonZeroScalar, PublicKey};

#[cfg(feature = "jwk")]
use crate::jwk::{JwkEcKey, JwkParameters};
Expand Down Expand Up @@ -91,7 +91,7 @@ where

/// Generate a random [`SecretKey`].
#[cfg(feature = "arithmetic")]
pub fn random(rng: &mut impl CryptoRngCore) -> Self
pub fn random<R: CryptoRng>(rng: &mut R) -> Self
where
C: CurveArithmetic,
{
Expand Down

0 comments on commit 7eee24b

Please sign in to comment.