Skip to content

update rand to 0.9 #1283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
139 changes: 128 additions & 11 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions bip32/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ rust-version = "1.81"
[dependencies]
bs58 = { version = "0.5", default-features = false, features = ["check"] }
hmac = { version = "=0.13.0-pre.4", default-features = false }
rand_core = { version = "0.6", default-features = false }
rand_core = { version = "0.9", default-features = false }
ripemd = { version = "=0.2.0-pre.4", default-features = false }
sha2 = { version = "=0.11.0-pre.4", default-features = false }
subtle = { version = "2", default-features = false }
Expand All @@ -33,7 +33,7 @@ secp256k1-ffi = { package = "secp256k1", version = "0.29", optional = true, defa

[dev-dependencies]
hex-literal = "0.4"
rand_core = { version = "0.6", features = ["std"] }
rand_core = { version = "0.9", features = ["std", "os_rng"] }

[features]
default = ["bip39", "secp256k1", "std"]
Expand Down
5 changes: 3 additions & 2 deletions hkd32/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ rust-version = "1.63"

[dependencies]
hmac = { version = "0.12", default-features = false }
rand_core = { version = "0.6", default-features = false }
rand_core = { version = "0.9", default-features = false }
sha2 = { version = "0.10", default-features = false }
zeroize = { version = "1", default-features = false }

Expand All @@ -31,7 +31,8 @@ subtle-encoding = { version = "=0.6.0-pre", optional = true, default-features =

[dev-dependencies]
hex-literal = "0.4"
rand_core = { version = "0.6", features = ["std"] }
rand_core = { version = "0.9", features = ["std", "os_rng"] }
rand = { version = "0.9", features = ["thread_rng"] }

[features]
default = ["alloc", "bech32"]
Expand Down
3 changes: 1 addition & 2 deletions hkd32/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@
//! # Example
//!
//! ```rust
//! use rand_core::OsRng;
//!
//! // Parent key
//! let input_key_material = hkd32::KeyMaterial::random(&mut OsRng);
//! let input_key_material = hkd32::KeyMaterial::random(&mut rand::rng());
//!
//! // Path to the child key
//! let derivation_path = "/foo/bar/baz".parse::<hkd32::PathBuf>().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion signatory/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ rust-version = "1.65"

[dependencies]
pkcs8 = { version = "0.10", features = ["alloc", "pem"] }
rand_core = "0.6"
rand_core = { version = "0.9", features = ["std", "os_rng"] }
signature = "2"
zeroize = "1.5"

Expand Down
4 changes: 2 additions & 2 deletions signatory/src/ed25519/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{key::store::GeneratePkcs8, Error, Result};
use alloc::boxed::Box;
use core::fmt;
use ed25519_dalek::SECRET_KEY_LENGTH;
use rand_core::{OsRng, RngCore};
use rand_core::{OsRng, TryRngCore};
use signature::Signer;
use zeroize::Zeroizing;

Expand Down Expand Up @@ -55,7 +55,7 @@ impl GeneratePkcs8 for SigningKey {
/// Randomly generate a new PKCS#8 private key.
fn generate_pkcs8() -> pkcs8::SecretDocument {
let mut private_key = Zeroizing::new([0u8; SECRET_KEY_LENGTH]);
OsRng.fill_bytes(&mut *private_key);
OsRng.try_fill_bytes(&mut *private_key).unwrap();
pkcs8::SecretDocument::encode_msg(&pkcs8::PrivateKeyInfo::new(ALGORITHM_ID, &*private_key))
.expect("DER encoding error")
}
Expand Down