Skip to content

Commit a9fe576

Browse files
author
dmitrmax
committed
Update rand to 0.9.x
1 parent 442de10 commit a9fe576

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ rustdoc-args = ["--cfg", "docsrs"]
1919

2020
[features]
2121
default = ["std"]
22-
std = ["alloc", "secp256k1-sys/std", "rand?/std", "rand?/std_rng", "hashes?/std"]
22+
std = ["alloc", "secp256k1-sys/std", "rand?/std", "rand?/std_rng", "rand?/thread_rng", "hashes?/std"]
2323
# allow use of Secp256k1::new and related API that requires an allocator
2424
alloc = ["secp256k1-sys/alloc"]
2525
recovery = ["secp256k1-sys/recovery"]
@@ -37,7 +37,7 @@ global-context-less-secure = ["global-context"]
3737
secp256k1-sys = { version = "0.11.0", default-features = false, path = "./secp256k1-sys" }
3838

3939
hashes = { package = "bitcoin_hashes", version = "0.14", default-features = false, optional = true }
40-
rand = { version = "0.8", default-features = false, optional = true }
40+
rand = { version = "0.9", default-features = false, optional = true }
4141
serde = { version = "1.0.103", default-features = false, optional = true }
4242

4343
[dev-dependencies]

src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
//! * `lowmemory` - optimize the library for low-memory environments.
135135
//! * `global-context` - enable use of global secp256k1 context (implies `std`).
136136
//! * `serde` - implements serialization and deserialization for types in this crate using `serde`.
137-
//! **Important**: `serde` encoding is **not** the same as consensus encoding!
137+
//! **Important**: `serde` encoding is **not** the same as consensus encoding!
138138
//!
139139
140140
// Coding conventions
@@ -504,8 +504,7 @@ fn to_hex<'a>(src: &[u8], target: &'a mut [u8]) -> Result<&'a str, ()> {
504504

505505
#[cfg(feature = "rand")]
506506
pub(crate) fn random_32_bytes<R: rand::Rng + ?Sized>(rng: &mut R) -> [u8; 32] {
507-
let mut ret = [0u8; 32];
508-
rng.fill(&mut ret);
507+
let ret: [u8;32] = rng.random();
509508
ret
510509
}
511510

src/scalar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl Scalar {
4242

4343
/// Generates a random scalar
4444
#[cfg(all(feature = "rand", feature = "std"))]
45-
pub fn random() -> Self { Self::random_custom(rand::thread_rng()) }
45+
pub fn random() -> Self { Self::random_custom(rand::rng()) }
4646

4747
/// Generates a random scalar using supplied RNG
4848
#[cfg(feature = "rand")]

src/schnorr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl<C: Signing> Secp256k1<C> {
141141
/// generator to generate the auxiliary random data.
142142
#[cfg(all(feature = "rand", feature = "std"))]
143143
pub fn sign_schnorr(&self, msg: &[u8], keypair: &Keypair) -> Signature {
144-
self.sign_schnorr_with_rng(msg, keypair, &mut rand::thread_rng())
144+
self.sign_schnorr_with_rng(msg, keypair, &mut rand::rng())
145145
}
146146

147147
/// Creates a schnorr signature without using any auxiliary random data.

0 commit comments

Comments
 (0)