Skip to content

Commit 5a6ddc6

Browse files
committed
update rand to 0.9
1 parent e08a6b4 commit 5a6ddc6

File tree

5 files changed

+108
-19
lines changed

5 files changed

+108
-19
lines changed

Cargo.lock

Lines changed: 50 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bip32/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ rust-version = "1.81"
1919
[dependencies]
2020
bs58 = { version = "0.5", default-features = false, features = ["check"] }
2121
hmac = { version = "=0.13.0-pre.4", default-features = false }
22-
rand_core = { version = "0.6", default-features = false }
22+
rand_core = { version = "0.9", default-features = false }
2323
ripemd = { version = "=0.2.0-pre.4", default-features = false }
2424
sha2 = { version = "=0.11.0-pre.4", default-features = false }
2525
subtle = { version = "2", default-features = false }
@@ -33,7 +33,7 @@ secp256k1-ffi = { package = "secp256k1", version = "0.29", optional = true, defa
3333

3434
[dev-dependencies]
3535
hex-literal = "0.4"
36-
rand_core = { version = "0.6", features = ["std"] }
36+
rand_core = { version = "0.9", features = ["std"] }
3737

3838
[features]
3939
default = ["bip39", "secp256k1", "std"]

hkd32/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ rust-version = "1.63"
2020

2121
[dependencies]
2222
hmac = { version = "0.12", default-features = false }
23-
rand_core = { version = "0.6", default-features = false }
23+
rand_core = { version = "0.9", default-features = false, features = ["os_rng"] }
2424
sha2 = { version = "0.10", default-features = false }
2525
zeroize = { version = "1", default-features = false }
2626

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

3232
[dev-dependencies]
3333
hex-literal = "0.4"
34-
rand_core = { version = "0.6", features = ["std"] }
34+
rand_core = { version = "0.9", features = ["std"] }
3535

3636
[features]
3737
default = ["alloc", "bech32"]

hkd32/src/lib.rs

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,60 @@
2323
//! # Example
2424
//!
2525
//! ```rust
26-
//! use rand_core::OsRng;
26+
//! use rand_core::{
27+
//! CryptoRng, RngCore,
28+
//! block::{BlockRng, BlockRngCore},
29+
//! };
30+
//! struct SeedRng([u32; 8]);
2731
//!
28-
//! // Parent key
29-
//! let input_key_material = hkd32::KeyMaterial::random(&mut OsRng);
32+
//! impl CryptoRng for SeedRng {}
33+
//!
34+
//! impl RngCore for SeedRng {
35+
//! fn next_u32(&mut self) -> u32 {
36+
//! self.0.iter_mut().next().copied().unwrap()
37+
//! }
38+
//!
39+
//! fn next_u64(&mut self) -> u64 {
40+
//! self.0.iter_mut().next().copied().unwrap() as u64
41+
//! }
42+
//!
43+
//! fn fill_bytes(&mut self, dest: &mut [u8]) {
44+
//! for chunk in dest.chunks_mut(4) {
45+
//! chunk.copy_from_slice(&self.next_u32().to_be_bytes());
46+
//! }
47+
//! }
48+
//! }
49+
//!
50+
//! impl BlockRngCore for SeedRng {
51+
//! type Item = u32;
52+
//! type Results = [u32; 8];
53+
//!
54+
//! fn generate(&mut self, results: &mut Self::Results) {
55+
//! *results = self.0;
56+
//! }
57+
//! }
58+
//!
59+
//! struct CryptoBlockRng(BlockRng<SeedRng>);
60+
//!
61+
//! impl CryptoRng for CryptoBlockRng {}
62+
//!
63+
//! impl RngCore for CryptoBlockRng {
64+
//! fn next_u32(&mut self) -> u32 {
65+
//! self.0.next_u32()
66+
//! }
67+
//!
68+
//! fn next_u64(&mut self) -> u64 {
69+
//! self.0.next_u64()
70+
//! }
71+
//!
72+
//! fn fill_bytes(&mut self, dest: &mut [u8]) {
73+
//! self.0.fill_bytes(dest);
74+
//! }
75+
//! }
76+
// Parent key
77+
//! let backing = [0; 8];
78+
//! let mut rng = CryptoBlockRng(BlockRng::new(SeedRng(backing)));
79+
//! let input_key_material = hkd32::KeyMaterial::random(&mut rng);
3080
//!
3181
//! // Path to the child key
3282
//! let derivation_path = "/foo/bar/baz".parse::<hkd32::PathBuf>().unwrap();

signatory/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ rust-version = "1.65"
1414

1515
[dependencies]
1616
pkcs8 = { version = "0.10", features = ["alloc", "pem"] }
17-
rand_core = "0.6"
17+
rand_core = "0.9"
1818
signature = "2"
1919
zeroize = "1.5"
2020

0 commit comments

Comments
 (0)