Skip to content

Commit f5d0769

Browse files
committed
Merge #788: Update rand to 0.9.x
993b4b7 Update rand to 0.9.x, getrandom to 0.3 and js-sys to 0.3.77 (dmitrmax) Pull request description: Closes #789 ACKs for top commit: apoelstra: ACK 993b4b7; successfully ran local tests Tree-SHA512: 01b5fa2df0c462c9d4646701e46185b14b9439981f8c76626606c8c8ce930a318028860f31ba082018a89e07cb98ee5f7eed02c029284d0ade5e4863b13b1731
2 parents 442de10 + 993b4b7 commit f5d0769

File tree

12 files changed

+288
-400
lines changed

12 files changed

+288
-400
lines changed

Cargo-minimal.lock

+106-266
Large diffs are not rendered by default.

Cargo-recent.lock

+88-32
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ dependencies = [
3333
"hex-conservative",
3434
]
3535

36+
[[package]]
37+
name = "bitflags"
38+
version = "2.9.0"
39+
source = "registry+https://github.com/rust-lang/crates.io-index"
40+
checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
41+
3642
[[package]]
3743
name = "bumpalo"
3844
version = "3.12.0"
@@ -69,13 +75,14 @@ dependencies = [
6975

7076
[[package]]
7177
name = "getrandom"
72-
version = "0.2.8"
78+
version = "0.3.2"
7379
source = "registry+https://github.com/rust-lang/crates.io-index"
74-
checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
80+
checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0"
7581
dependencies = [
7682
"cfg-if",
7783
"js-sys",
7884
"libc",
85+
"r-efi",
7986
"wasi",
8087
"wasm-bindgen",
8188
]
@@ -103,18 +110,19 @@ checksum = "3011d1213f159867b13cfd6ac92d2cd5f1345762c63be3554e84092d85a50bbd"
103110

104111
[[package]]
105112
name = "js-sys"
106-
version = "0.3.61"
113+
version = "0.3.77"
107114
source = "registry+https://github.com/rust-lang/crates.io-index"
108-
checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730"
115+
checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f"
109116
dependencies = [
117+
"once_cell",
110118
"wasm-bindgen",
111119
]
112120

113121
[[package]]
114122
name = "libc"
115-
version = "0.2.140"
123+
version = "0.2.171"
116124
source = "registry+https://github.com/rust-lang/crates.io-index"
117-
checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c"
125+
checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"
118126

119127
[[package]]
120128
name = "log"
@@ -139,52 +147,64 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
139147

140148
[[package]]
141149
name = "proc-macro2"
142-
version = "1.0.52"
150+
version = "1.0.94"
143151
source = "registry+https://github.com/rust-lang/crates.io-index"
144-
checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224"
152+
checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84"
145153
dependencies = [
146154
"unicode-ident",
147155
]
148156

149157
[[package]]
150158
name = "quote"
151-
version = "1.0.26"
159+
version = "1.0.40"
152160
source = "registry+https://github.com/rust-lang/crates.io-index"
153-
checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc"
161+
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
154162
dependencies = [
155163
"proc-macro2",
156164
]
157165

166+
[[package]]
167+
name = "r-efi"
168+
version = "5.2.0"
169+
source = "registry+https://github.com/rust-lang/crates.io-index"
170+
checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5"
171+
158172
[[package]]
159173
name = "rand"
160-
version = "0.8.5"
174+
version = "0.9.0"
161175
source = "registry+https://github.com/rust-lang/crates.io-index"
162-
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
176+
checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94"
163177
dependencies = [
164-
"libc",
165178
"rand_chacha",
166179
"rand_core",
180+
"zerocopy",
167181
]
168182

169183
[[package]]
170184
name = "rand_chacha"
171-
version = "0.3.1"
185+
version = "0.9.0"
172186
source = "registry+https://github.com/rust-lang/crates.io-index"
173-
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
187+
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
174188
dependencies = [
175189
"ppv-lite86",
176190
"rand_core",
177191
]
178192

179193
[[package]]
180194
name = "rand_core"
181-
version = "0.6.4"
195+
version = "0.9.3"
182196
source = "registry+https://github.com/rust-lang/crates.io-index"
183-
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
197+
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
184198
dependencies = [
185199
"getrandom",
186200
]
187201

202+
[[package]]
203+
name = "rustversion"
204+
version = "1.0.20"
205+
source = "registry+https://github.com/rust-lang/crates.io-index"
206+
checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2"
207+
188208
[[package]]
189209
name = "scoped-tls"
190210
version = "1.0.1"
@@ -244,9 +264,9 @@ dependencies = [
244264

245265
[[package]]
246266
name = "syn"
247-
version = "1.0.109"
267+
version = "2.0.100"
248268
source = "registry+https://github.com/rust-lang/crates.io-index"
249-
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
269+
checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0"
250270
dependencies = [
251271
"proc-macro2",
252272
"quote",
@@ -261,29 +281,33 @@ checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4"
261281

262282
[[package]]
263283
name = "wasi"
264-
version = "0.11.0+wasi-snapshot-preview1"
284+
version = "0.14.2+wasi-0.2.4"
265285
source = "registry+https://github.com/rust-lang/crates.io-index"
266-
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
286+
checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3"
287+
dependencies = [
288+
"wit-bindgen-rt",
289+
]
267290

268291
[[package]]
269292
name = "wasm-bindgen"
270-
version = "0.2.84"
293+
version = "0.2.100"
271294
source = "registry+https://github.com/rust-lang/crates.io-index"
272-
checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b"
295+
checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5"
273296
dependencies = [
274297
"cfg-if",
298+
"once_cell",
299+
"rustversion",
275300
"wasm-bindgen-macro",
276301
]
277302

278303
[[package]]
279304
name = "wasm-bindgen-backend"
280-
version = "0.2.84"
305+
version = "0.2.100"
281306
source = "registry+https://github.com/rust-lang/crates.io-index"
282-
checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9"
307+
checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6"
283308
dependencies = [
284309
"bumpalo",
285310
"log",
286-
"once_cell",
287311
"proc-macro2",
288312
"quote",
289313
"syn",
@@ -304,19 +328,19 @@ dependencies = [
304328

305329
[[package]]
306330
name = "wasm-bindgen-macro"
307-
version = "0.2.84"
331+
version = "0.2.100"
308332
source = "registry+https://github.com/rust-lang/crates.io-index"
309-
checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5"
333+
checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407"
310334
dependencies = [
311335
"quote",
312336
"wasm-bindgen-macro-support",
313337
]
314338

315339
[[package]]
316340
name = "wasm-bindgen-macro-support"
317-
version = "0.2.84"
341+
version = "0.2.100"
318342
source = "registry+https://github.com/rust-lang/crates.io-index"
319-
checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6"
343+
checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de"
320344
dependencies = [
321345
"proc-macro2",
322346
"quote",
@@ -327,9 +351,12 @@ dependencies = [
327351

328352
[[package]]
329353
name = "wasm-bindgen-shared"
330-
version = "0.2.84"
354+
version = "0.2.100"
331355
source = "registry+https://github.com/rust-lang/crates.io-index"
332-
checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d"
356+
checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d"
357+
dependencies = [
358+
"unicode-ident",
359+
]
333360

334361
[[package]]
335362
name = "wasm-bindgen-test"
@@ -364,3 +391,32 @@ dependencies = [
364391
"js-sys",
365392
"wasm-bindgen",
366393
]
394+
395+
[[package]]
396+
name = "wit-bindgen-rt"
397+
version = "0.39.0"
398+
source = "registry+https://github.com/rust-lang/crates.io-index"
399+
checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
400+
dependencies = [
401+
"bitflags",
402+
]
403+
404+
[[package]]
405+
name = "zerocopy"
406+
version = "0.8.24"
407+
source = "registry+https://github.com/rust-lang/crates.io-index"
408+
checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879"
409+
dependencies = [
410+
"zerocopy-derive",
411+
]
412+
413+
[[package]]
414+
name = "zerocopy-derive"
415+
version = "0.8.24"
416+
source = "registry+https://github.com/rust-lang/crates.io-index"
417+
checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be"
418+
dependencies = [
419+
"proc-macro2",
420+
"quote",
421+
"syn",
422+
]

Cargo.toml

+4-4
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,19 +37,19 @@ 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]
44-
rand_core = "0.6"
44+
rand_core = "0.9"
4545
serde_cbor = "0.10.0"
4646
serde_test = "1.0.19"
4747
bincode = "1.3.3"
4848
hex_lit = "0.1.1"
4949

5050
[target.wasm32-unknown-unknown.dev-dependencies]
5151
wasm-bindgen-test = "0.3"
52-
getrandom = { version = "0.2", features = ["js"] }
52+
getrandom = { version = "0.3", features = ["wasm_js"] }
5353

5454
[lints.rust]
5555
unexpected_cfgs = { level = "deny", check-cfg = ['cfg(bench)', 'cfg(secp256k1_fuzz)', 'cfg(rust_secp_no_symbol_renaming)'] }

examples/generate_keys.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use secp256k1::{PublicKey, Secp256k1, SecretKey};
44

55
fn main() {
66
let secp = Secp256k1::new();
7-
let mut rng = rand::thread_rng();
7+
let mut rng = rand::rng();
88
// First option:
99
let (seckey, pubkey) = secp.generate_keypair(&mut rng);
1010

no_std_test/src/main.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,10 @@ impl RngCore for FakeRng {
7171
fn next_u64(&mut self) -> u64 {
7272
57
7373
}
74-
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand::Error> {
74+
fn fill_bytes(&mut self, dest: &mut [u8]) {
7575
for i in dest {
7676
*i = 57;
7777
}
78-
Ok(())
79-
}
80-
fn fill_bytes(&mut self, dest: &mut [u8]) {
81-
self.try_fill_bytes(dest).unwrap();
8278
}
8379
}
8480

src/context.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ pub mod global {
2828
/// A global static context to avoid repeatedly creating contexts.
2929
///
3030
/// If `rand` and `std` feature is enabled, context will have been randomized using
31-
/// `thread_rng`.
31+
/// `rng`.
3232
///
3333
/// ```
3434
/// # #[cfg(all(feature = "global-context", feature = "rand", feature = "std"))] {
3535
/// use secp256k1::{PublicKey, SECP256K1};
36-
/// let _ = SECP256K1.generate_keypair(&mut rand::thread_rng());
36+
/// let _ = SECP256K1.generate_keypair(&mut rand::rng());
3737
/// # }
3838
/// ```
3939
pub static SECP256K1: &GlobalContext = &GlobalContext { __private: () };
@@ -174,15 +174,15 @@ mod alloc_only {
174174
/// Lets you create a context in a generic manner (sign/verify/all).
175175
///
176176
/// If `rand` and `std` feature is enabled, context will have been randomized using
177-
/// `thread_rng`.
177+
/// `rng`.
178178
/// If `rand` or `std` feature is not enabled please consider randomizing the context as
179179
/// follows:
180180
/// ```
181181
/// # #[cfg(all(feature = "rand", feature = "std"))] {
182182
/// # use secp256k1::Secp256k1;
183-
/// # use secp256k1::rand::{thread_rng, RngCore};
183+
/// # use secp256k1::rand::{rng, RngCore};
184184
/// let mut ctx = Secp256k1::new();
185-
/// # let mut rng = thread_rng();
185+
/// # let mut rng = rng();
186186
/// # let mut seed = [0u8; 32];
187187
/// # rng.fill_bytes(&mut seed);
188188
/// // let seed = <32 bytes of random data>
@@ -216,7 +216,7 @@ mod alloc_only {
216216
not(feature = "global-context-less-secure")
217217
))]
218218
{
219-
ctx.randomize(&mut rand::thread_rng());
219+
ctx.randomize(&mut rand::rng());
220220
}
221221

222222
#[allow(clippy::let_and_return)] // as for unusted_mut
@@ -228,7 +228,7 @@ mod alloc_only {
228228
/// Creates a new Secp256k1 context with all capabilities.
229229
///
230230
/// If `rand` and `std` feature is enabled, context will have been randomized using
231-
/// `thread_rng`.
231+
/// `rng`.
232232
/// If `rand` or `std` feature is not enabled please consider randomizing the context (see
233233
/// docs for `Secp256k1::gen_new()`).
234234
pub fn new() -> Secp256k1<All> { Secp256k1::gen_new() }
@@ -238,7 +238,7 @@ mod alloc_only {
238238
/// Creates a new Secp256k1 context that can only be used for signing.
239239
///
240240
/// If `rand` and `std` feature is enabled, context will have been randomized using
241-
/// `thread_rng`.
241+
/// `rng`.
242242
/// If `rand` or `std` feature is not enabled please consider randomizing the context (see
243243
/// docs for `Secp256k1::gen_new()`).
244244
pub fn signing_only() -> Secp256k1<SignOnly> { Secp256k1::gen_new() }
@@ -248,7 +248,7 @@ mod alloc_only {
248248
/// Creates a new Secp256k1 context that can only be used for verification.
249249
///
250250
/// If `rand` and `std` feature is enabled, context will have been randomized using
251-
/// `thread_rng`.
251+
/// `rng`.
252252
/// If `rand` or `std` feature is not enabled please consider randomizing the context (see
253253
/// docs for `Secp256k1::gen_new()`).
254254
pub fn verification_only() -> Secp256k1<VerifyOnly> { Secp256k1::gen_new() }

0 commit comments

Comments
 (0)