diff --git a/Cargo-minimal.lock b/Cargo-minimal.lock
index d3fe48f75..8a4f6c6ba 100644
--- a/Cargo-minimal.lock
+++ b/Cargo-minimal.lock
@@ -8,12 +8,6 @@ version = "0.7.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
 
-[[package]]
-name = "base-x"
-version = "0.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fe9ad92e7876f320bf1ba3325acb19d1bfcfdfdf52d15cbe7bd38314cf81854d"
-
 [[package]]
 name = "bincode"
 version = "1.3.3"
@@ -23,22 +17,37 @@ dependencies = [
  "serde",
 ]
 
+[[package]]
+name = "bitcoin-internals"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2b854212e29b96c8f0fe04cab11d57586c8f3257de0d146c76cb3b42b3eb9118"
+
 [[package]]
 name = "bitcoin-io"
-version = "0.1.2"
+version = "0.2.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "340e09e8399c7bd8912f495af6aa58bea0c9214773417ffaa8f6460f93aaee56"
+checksum = "26792cd2bf245069a1c5acb06aa7ad7abe1de69b507c90b490bca81e0665d0ee"
+dependencies = [
+ "bitcoin-internals",
+]
 
 [[package]]
 name = "bitcoin_hashes"
-version = "0.14.0"
+version = "0.16.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bb18c03d0db0247e147a21a6faafd5a7eb851c743db062de72018b6b7e8e4d16"
+checksum = "7e5d09f16329cd545d7e6008b2c6b2af3a90bc678cf41ac3d2f6755943301b16"
 dependencies = [
  "bitcoin-io",
  "hex-conservative",
 ]
 
+[[package]]
+name = "bitflags"
+version = "2.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
+
 [[package]]
 name = "bumpalo"
 version = "3.2.1"
@@ -47,9 +56,9 @@ checksum = "12ae9db68ad7fac5fe51304d20f016c911539251075a214f8e663babefa35187"
 
 [[package]]
 name = "byteorder"
-version = "1.0.0"
+version = "1.5.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c40977b0ee6b9885c9013cd41d9feffdd22deb3bb4dc3a71d901cc7a77de18c8"
+checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
 
 [[package]]
 name = "cc"
@@ -79,29 +88,16 @@ dependencies = [
  "wasm-bindgen",
 ]
 
-[[package]]
-name = "discard"
-version = "1.0.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9a9117502da3c5657cb8e2ca7ffcf52d659f00c78c5127d1ebadc2ebe76465be"
-
-[[package]]
-name = "dtoa"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5edd69c67b2f8e0911629b7e6b8a34cb3956613cd7c6e6414966dee349c2db4f"
-
 [[package]]
 name = "getrandom"
-version = "0.2.0"
+version = "0.3.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ee8025cf36f917e6a52cce185b7c7177689b838b7ec138364e50cc2277a56cf4"
+checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8"
 dependencies = [
- "cfg-if 0.1.2",
+ "cfg-if 1.0.0",
  "libc",
- "stdweb",
  "wasi",
- "wasm-bindgen",
+ "windows-targets",
 ]
 
 [[package]]
@@ -112,9 +108,9 @@ checksum = "ee6c0438de3ca4d8cac2eec62b228e2f8865cfe9ebefea720406774223fa2d2e"
 
 [[package]]
 name = "hex-conservative"
-version = "0.2.1"
+version = "0.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5313b072ce3c597065a808dbf612c4c8e8590bdbf8b579508bf7a762c5eae6cd"
+checksum = "4afe881d0527571892c4034822e59bb10c6c991cce6abe8199b6f5cf10766f55"
 dependencies = [
  "arrayvec",
 ]
@@ -125,12 +121,6 @@ version = "0.1.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "3011d1213f159867b13cfd6ac92d2cd5f1345762c63be3554e84092d85a50bbd"
 
-[[package]]
-name = "itoa"
-version = "0.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "91fd9dc2c587067de817fec4ad355e3818c3d893a78cab32a0a474c7a15bb8d5"
-
 [[package]]
 name = "js-sys"
 version = "0.3.46"
@@ -148,9 +138,9 @@ checksum = "c8f31047daa365f19be14b47c29df4f7c3b581832407daabe6ae77397619237d"
 
 [[package]]
 name = "libc"
-version = "0.2.64"
+version = "0.2.170"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "74dfca3d9957906e8d1e6a0b641dc9a59848e793f1da2165889fd4f62d10d79c"
+checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828"
 
 [[package]]
 name = "log"
@@ -161,77 +151,49 @@ dependencies = [
  "cfg-if 0.1.2",
 ]
 
-[[package]]
-name = "num-traits"
-version = "0.1.32"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "51eab148f171aefad295f8cece636fc488b9b392ef544da31ea4b8ef6b9e9c39"
-
 [[package]]
 name = "ppv-lite86"
-version = "0.2.8"
+version = "0.2.20"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea"
-
-[[package]]
-name = "proc-macro2"
-version = "0.4.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1fa93823f53cfd0f5ac117b189aed6cfdfb2cfc0a9d82e956dd7927595ed7d46"
+checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04"
 dependencies = [
- "unicode-xid 0.1.0",
+ "zerocopy 0.7.35",
 ]
 
 [[package]]
 name = "proc-macro2"
-version = "1.0.13"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "53f5ffe53a6b28e37c9c1ce74893477864d64f74778a93a4beb43c8fa167f639"
-dependencies = [
- "unicode-xid 0.2.0",
-]
-
-[[package]]
-name = "quote"
-version = "0.3.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9f0fc799e40f2a2c2be239825b30b686f1bd1d2e0e3d5e943b14c1380db49acf"
-
-[[package]]
-name = "quote"
-version = "0.6.0"
+version = "1.0.93"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b925e6c90a6272d38f6a2f87b3ee68760bc1db9572f8f93dbbb25429fb9e7fe3"
+checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99"
 dependencies = [
- "proc-macro2 0.4.4",
+ "unicode-ident",
 ]
 
 [[package]]
 name = "quote"
-version = "1.0.0"
+version = "1.0.38"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7ab938ebe6f1c82426b5fb82eaf10c3e3028c53deaa3fbe38f5904b37cf4d767"
+checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
 dependencies = [
- "proc-macro2 1.0.13",
+ "proc-macro2",
 ]
 
 [[package]]
 name = "rand"
-version = "0.8.0"
+version = "0.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a76330fb486679b4ace3670f117bbc9e16204005c4bde9c4bd372f45bed34f12"
+checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94"
 dependencies = [
- "libc",
  "rand_chacha",
  "rand_core",
- "rand_hc",
+ "zerocopy 0.8.21",
 ]
 
 [[package]]
 name = "rand_chacha"
-version = "0.3.0"
+version = "0.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d"
+checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
 dependencies = [
  "ppv-lite86",
  "rand_core",
@@ -239,31 +201,13 @@ dependencies = [
 
 [[package]]
 name = "rand_core"
-version = "0.6.2"
+version = "0.9.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7"
+checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
 dependencies = [
  "getrandom",
 ]
 
-[[package]]
-name = "rand_hc"
-version = "0.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
-dependencies = [
- "rand_core",
-]
-
-[[package]]
-name = "rustc_version"
-version = "0.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1e114e275f7c9b5d50bb52b28f9aac1921209f02aa6077c8b255e21eefaf8ffa"
-dependencies = [
- "semver",
-]
-
 [[package]]
 name = "scoped-tls"
 version = "1.0.0"
@@ -295,21 +239,6 @@ dependencies = [
  "libc",
 ]
 
-[[package]]
-name = "semver"
-version = "0.6.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7a3186ec9e65071a2095434b1f5bb24838d4e8e130f584c790f6033c79943537"
-dependencies = [
- "semver-parser",
-]
-
-[[package]]
-name = "semver-parser"
-version = "0.7.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
-
 [[package]]
 name = "serde"
 version = "1.0.103"
@@ -327,39 +256,6 @@ dependencies = [
  "serde",
 ]
 
-[[package]]
-name = "serde_derive"
-version = "1.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6a61ecb8511aaff381424f98b49a059017420ec60e15e8d63b645701af7fa9b8"
-dependencies = [
- "quote 0.3.8",
- "serde_derive_internals",
- "syn 0.11.10",
-]
-
-[[package]]
-name = "serde_derive_internals"
-version = "0.15.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "021c338d22c7e30f957a6ab7e388cb6098499dda9fd4ba1661ee074ca7a180d1"
-dependencies = [
- "syn 0.11.10",
- "synom",
-]
-
-[[package]]
-name = "serde_json"
-version = "1.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e9b1ec939469a124b27e208106550c38358ed4334d2b1b5b3825bc1ee37d946a"
-dependencies = [
- "dtoa",
- "itoa",
- "num-traits",
- "serde",
-]
-
 [[package]]
 name = "serde_test"
 version = "1.0.19"
@@ -369,114 +265,33 @@ dependencies = [
  "serde",
 ]
 
-[[package]]
-name = "sha1"
-version = "0.6.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d"
-
-[[package]]
-name = "stdweb"
-version = "0.4.18"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a68c0ce28cf7400ed022e18da3c4591e14e1df02c70e93573cc59921b3923aeb"
-dependencies = [
- "discard",
- "rustc_version",
- "stdweb-derive",
- "stdweb-internal-macros",
- "stdweb-internal-runtime",
- "wasm-bindgen",
-]
-
-[[package]]
-name = "stdweb-derive"
-version = "0.5.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0e21ebd9179de08f2300a65454268a17ea3de204627458588c84319c4def3930"
-dependencies = [
- "proc-macro2 0.4.4",
- "quote 0.6.0",
- "serde",
- "serde_derive",
- "syn 0.15.0",
-]
-
-[[package]]
-name = "stdweb-internal-macros"
-version = "0.2.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e68f7d08b76979a43e93fe043b66d2626e35d41d68b0b85519202c6dd8ac59fa"
-dependencies = [
- "base-x",
- "proc-macro2 0.4.4",
- "quote 0.6.0",
- "serde",
- "serde_derive",
- "serde_json",
- "sha1",
- "syn 0.15.0",
-]
-
-[[package]]
-name = "stdweb-internal-runtime"
-version = "0.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0e93e3ace205c4c1926b882cf8d8209e86acd445fda5fcf850455c3d178651c7"
-
-[[package]]
-name = "syn"
-version = "0.11.10"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "171b739972d9a1bfb169e8077238b51f9ebeaae4ff6e08072f7ba386a8802da2"
-dependencies = [
- "quote 0.3.8",
- "synom",
- "unicode-xid 0.0.4",
-]
-
-[[package]]
-name = "syn"
-version = "0.15.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a1ec67da440de95ec3a63fa50541afc4f433d1f410f1f0926b6c4b169660c721"
-dependencies = [
- "proc-macro2 0.4.4",
- "quote 0.6.0",
- "unicode-xid 0.1.0",
-]
-
 [[package]]
 name = "syn"
 version = "1.0.27"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "ef781e621ee763a2a40721a8861ec519cb76966aee03bb5d00adb6a31dc1c1de"
 dependencies = [
- "proc-macro2 1.0.13",
- "quote 1.0.0",
- "unicode-xid 0.2.0",
+ "proc-macro2",
+ "quote",
+ "unicode-xid",
 ]
 
 [[package]]
-name = "synom"
-version = "0.11.0"
+name = "syn"
+version = "2.0.98"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8fece1853fb872b0acdc3ff88f37c474018e125ef81cd4cb8c0ca515746b62ed"
+checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1"
 dependencies = [
- "unicode-xid 0.0.4",
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
 ]
 
 [[package]]
-name = "unicode-xid"
-version = "0.0.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
-
-[[package]]
-name = "unicode-xid"
-version = "0.1.0"
+name = "unicode-ident"
+version = "1.0.17"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
+checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe"
 
 [[package]]
 name = "unicode-xid"
@@ -486,9 +301,12 @@ checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
 
 [[package]]
 name = "wasi"
-version = "0.9.0+wasi-snapshot-preview1"
+version = "0.13.3+wasi-0.2.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
+checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2"
+dependencies = [
+ "wit-bindgen-rt",
+]
 
 [[package]]
 name = "wasm-bindgen"
@@ -509,8 +327,8 @@ dependencies = [
  "bumpalo",
  "lazy_static",
  "log",
- "proc-macro2 1.0.13",
- "quote 1.0.0",
+ "proc-macro2",
+ "quote",
  "syn 1.0.27",
  "wasm-bindgen-shared",
 ]
@@ -533,7 +351,7 @@ version = "0.2.69"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "7a6ac8995ead1f084a8dea1e65f194d0973800c7f571f6edd70adf06ecf77084"
 dependencies = [
- "quote 1.0.0",
+ "quote",
  "wasm-bindgen-macro-support",
 ]
 
@@ -543,8 +361,8 @@ version = "0.2.69"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "b5a48c72f299d80557c7c62e37e7225369ecc0c963964059509fbafe917c7549"
 dependencies = [
- "proc-macro2 1.0.13",
- "quote 1.0.0",
+ "proc-macro2",
+ "quote",
  "syn 1.0.27",
  "wasm-bindgen-backend",
  "wasm-bindgen-shared",
@@ -576,8 +394,8 @@ version = "0.3.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "5f093012630c0c14be061ac7a8d99f82a94e2b1cfd74619fa71090705d2c91be"
 dependencies = [
- "proc-macro2 1.0.13",
- "quote 1.0.0",
+ "proc-macro2",
+ "quote",
 ]
 
 [[package]]
@@ -589,3 +407,117 @@ dependencies = [
  "js-sys",
  "wasm-bindgen",
 ]
+
+[[package]]
+name = "windows-targets"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
+dependencies = [
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc",
+ "windows_i686_gnu",
+ "windows_i686_gnullvm",
+ "windows_i686_msvc",
+ "windows_x86_64_gnu",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc",
+]
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
+
+[[package]]
+name = "windows_i686_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
+
+[[package]]
+name = "wit-bindgen-rt"
+version = "0.33.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c"
+dependencies = [
+ "bitflags",
+]
+
+[[package]]
+name = "zerocopy"
+version = "0.7.35"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
+dependencies = [
+ "byteorder",
+ "zerocopy-derive 0.7.35",
+]
+
+[[package]]
+name = "zerocopy"
+version = "0.8.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dcf01143b2dd5d134f11f545cf9f1431b13b749695cb33bcce051e7568f99478"
+dependencies = [
+ "zerocopy-derive 0.8.21",
+]
+
+[[package]]
+name = "zerocopy-derive"
+version = "0.7.35"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.98",
+]
+
+[[package]]
+name = "zerocopy-derive"
+version = "0.8.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "712c8386f4f4299382c9abee219bee7084f78fb939d88b6840fcc1320d5f6da2"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.98",
+]
diff --git a/Cargo-recent.lock b/Cargo-recent.lock
index 71f42992c..1abd79b53 100644
--- a/Cargo-recent.lock
+++ b/Cargo-recent.lock
@@ -17,22 +17,37 @@ dependencies = [
  "serde",
 ]
 
+[[package]]
+name = "bitcoin-internals"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2b854212e29b96c8f0fe04cab11d57586c8f3257de0d146c76cb3b42b3eb9118"
+
 [[package]]
 name = "bitcoin-io"
-version = "0.1.2"
+version = "0.2.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "340e09e8399c7bd8912f495af6aa58bea0c9214773417ffaa8f6460f93aaee56"
+checksum = "26792cd2bf245069a1c5acb06aa7ad7abe1de69b507c90b490bca81e0665d0ee"
+dependencies = [
+ "bitcoin-internals",
+]
 
 [[package]]
 name = "bitcoin_hashes"
-version = "0.14.0"
+version = "0.16.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bb18c03d0db0247e147a21a6faafd5a7eb851c743db062de72018b6b7e8e4d16"
+checksum = "7e5d09f16329cd545d7e6008b2c6b2af3a90bc678cf41ac3d2f6755943301b16"
 dependencies = [
  "bitcoin-io",
  "hex-conservative",
 ]
 
+[[package]]
+name = "bitflags"
+version = "2.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
+
 [[package]]
 name = "bumpalo"
 version = "3.12.0"
@@ -69,15 +84,14 @@ dependencies = [
 
 [[package]]
 name = "getrandom"
-version = "0.2.8"
+version = "0.3.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
+checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8"
 dependencies = [
  "cfg-if",
- "js-sys",
  "libc",
  "wasi",
- "wasm-bindgen",
+ "windows-targets",
 ]
 
 [[package]]
@@ -88,9 +102,9 @@ checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7"
 
 [[package]]
 name = "hex-conservative"
-version = "0.2.1"
+version = "0.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5313b072ce3c597065a808dbf612c4c8e8590bdbf8b579508bf7a762c5eae6cd"
+checksum = "4afe881d0527571892c4034822e59bb10c6c991cce6abe8199b6f5cf10766f55"
 dependencies = [
  "arrayvec",
 ]
@@ -112,9 +126,9 @@ dependencies = [
 
 [[package]]
 name = "libc"
-version = "0.2.140"
+version = "0.2.170"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c"
+checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828"
 
 [[package]]
 name = "log"
@@ -139,38 +153,38 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
 
 [[package]]
 name = "proc-macro2"
-version = "1.0.52"
+version = "1.0.93"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224"
+checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99"
 dependencies = [
  "unicode-ident",
 ]
 
 [[package]]
 name = "quote"
-version = "1.0.26"
+version = "1.0.38"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc"
+checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
 dependencies = [
  "proc-macro2",
 ]
 
 [[package]]
 name = "rand"
-version = "0.8.5"
+version = "0.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
+checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94"
 dependencies = [
- "libc",
  "rand_chacha",
  "rand_core",
+ "zerocopy",
 ]
 
 [[package]]
 name = "rand_chacha"
-version = "0.3.1"
+version = "0.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
+checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
 dependencies = [
  "ppv-lite86",
  "rand_core",
@@ -178,9 +192,9 @@ dependencies = [
 
 [[package]]
 name = "rand_core"
-version = "0.6.4"
+version = "0.9.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
+checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
 dependencies = [
  "getrandom",
 ]
@@ -253,6 +267,17 @@ dependencies = [
  "unicode-ident",
 ]
 
+[[package]]
+name = "syn"
+version = "2.0.98"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
 [[package]]
 name = "unicode-ident"
 version = "1.0.8"
@@ -261,9 +286,12 @@ checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4"
 
 [[package]]
 name = "wasi"
-version = "0.11.0+wasi-snapshot-preview1"
+version = "0.13.3+wasi-0.2.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
+checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2"
+dependencies = [
+ "wit-bindgen-rt",
+]
 
 [[package]]
 name = "wasm-bindgen"
@@ -286,7 +314,7 @@ dependencies = [
  "once_cell",
  "proc-macro2",
  "quote",
- "syn",
+ "syn 1.0.109",
  "wasm-bindgen-shared",
 ]
 
@@ -320,7 +348,7 @@ checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 1.0.109",
  "wasm-bindgen-backend",
  "wasm-bindgen-shared",
 ]
@@ -364,3 +392,96 @@ dependencies = [
  "js-sys",
  "wasm-bindgen",
 ]
+
+[[package]]
+name = "windows-targets"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
+dependencies = [
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc",
+ "windows_i686_gnu",
+ "windows_i686_gnullvm",
+ "windows_i686_msvc",
+ "windows_x86_64_gnu",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc",
+]
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
+
+[[package]]
+name = "windows_i686_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
+
+[[package]]
+name = "wit-bindgen-rt"
+version = "0.33.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c"
+dependencies = [
+ "bitflags",
+]
+
+[[package]]
+name = "zerocopy"
+version = "0.8.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dcf01143b2dd5d134f11f545cf9f1431b13b749695cb33bcce051e7568f99478"
+dependencies = [
+ "zerocopy-derive",
+]
+
+[[package]]
+name = "zerocopy-derive"
+version = "0.8.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "712c8386f4f4299382c9abee219bee7084f78fb939d88b6840fcc1320d5f6da2"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.98",
+]
diff --git a/Cargo.toml b/Cargo.toml
index 639da069c..36a07e616 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -36,12 +36,12 @@ global-context-less-secure = ["global-context"]
 [dependencies]
 secp256k1-sys = { version = "0.11.0", default-features = false, path = "./secp256k1-sys" }
 
-hashes = { package = "bitcoin_hashes", version = "0.14", default-features = false, optional = true }
-rand = { version = "0.8", default-features = false, optional = true }
+hashes = { package = "bitcoin_hashes", version = "0.16", default-features = false, optional = true }
+rand = { version = "0.9", default-features = false, features = ["thread_rng"], optional = true }
 serde = { version = "1.0.103", default-features = false, optional = true }
 
 [dev-dependencies]
-rand_core = "0.6"
+rand_core = "0.9"
 serde_cbor = "0.10.0"
 serde_test = "1.0.19"
 bincode = "1.3.3"
@@ -49,7 +49,7 @@ hex_lit = "0.1.1"
 
 [target.wasm32-unknown-unknown.dev-dependencies]
 wasm-bindgen-test = "0.3"
-getrandom = { version = "0.2", features = ["js"] }
+getrandom = { version = "0.3", default-features = false, features = [] }
 
 [lints.rust]
 unexpected_cfgs = { level = "deny", check-cfg = ['cfg(bench)', 'cfg(secp256k1_fuzz)', 'cfg(rust_secp_no_symbol_renaming)'] }
diff --git a/examples/generate_keys.rs b/examples/generate_keys.rs
index 2a47df19f..ae45bb010 100644
--- a/examples/generate_keys.rs
+++ b/examples/generate_keys.rs
@@ -4,7 +4,7 @@ use secp256k1::{PublicKey, Secp256k1, SecretKey};
 
 fn main() {
     let secp = Secp256k1::new();
-    let mut rng = rand::thread_rng();
+    let mut rng = rand::rng();
     // First option:
     let (seckey, pubkey) = secp.generate_keypair(&mut rng);
 
diff --git a/examples/sign_verify.rs b/examples/sign_verify.rs
index fc5deaa5a..766015146 100644
--- a/examples/sign_verify.rs
+++ b/examples/sign_verify.rs
@@ -1,7 +1,7 @@
 extern crate hashes;
 extern crate secp256k1;
 
-use hashes::{sha256, Hash};
+use hashes::sha256;
 use secp256k1::{ecdsa, Error, Message, PublicKey, Secp256k1, SecretKey, Signing, Verification};
 
 fn verify<C: Verification>(
diff --git a/examples/sign_verify_recovery.rs b/examples/sign_verify_recovery.rs
index a82aa98a8..27f43b4e2 100644
--- a/examples/sign_verify_recovery.rs
+++ b/examples/sign_verify_recovery.rs
@@ -1,7 +1,7 @@
 extern crate hashes;
 extern crate secp256k1;
 
-use hashes::{sha256, Hash};
+use hashes::sha256;
 use secp256k1::{ecdsa, Error, Message, PublicKey, Secp256k1, SecretKey, Signing, Verification};
 
 fn recover<C: Verification>(
diff --git a/src/context.rs b/src/context.rs
index 309809399..d88a6109a 100644
--- a/src/context.rs
+++ b/src/context.rs
@@ -33,7 +33,7 @@ pub mod global {
     /// ```
     /// # #[cfg(all(feature = "global-context", feature = "rand", feature = "std"))] {
     /// use secp256k1::{PublicKey, SECP256K1};
-    /// let _ = SECP256K1.generate_keypair(&mut rand::thread_rng());
+    /// let _ = SECP256K1.generate_keypair(&mut rand::rng());
     /// # }
     /// ```
     pub static SECP256K1: &GlobalContext = &GlobalContext { __private: () };
@@ -180,9 +180,9 @@ mod alloc_only {
         /// ```
         /// # #[cfg(all(feature = "rand", feature = "std"))] {
         /// # use secp256k1::Secp256k1;
-        /// # use secp256k1::rand::{thread_rng, RngCore};
+        /// # use secp256k1::rand::{rng, RngCore};
         /// let mut ctx = Secp256k1::new();
-        /// # let mut rng = thread_rng();
+        /// # let mut rng = rng();
         /// # let mut seed = [0u8; 32];
         /// # rng.fill_bytes(&mut seed);
         /// // let seed = <32 bytes of random data>
@@ -216,7 +216,7 @@ mod alloc_only {
                 not(feature = "global-context-less-secure")
             ))]
             {
-                ctx.randomize(&mut rand::thread_rng());
+                ctx.randomize(&mut rand::rng());
             }
 
             #[allow(clippy::let_and_return)] // as for unusted_mut
diff --git a/src/ecdh.rs b/src/ecdh.rs
index 382b3e440..d8bc7950e 100644
--- a/src/ecdh.rs
+++ b/src/ecdh.rs
@@ -24,8 +24,8 @@ const SHARED_SECRET_SIZE: usize = constants::SECRET_KEY_SIZE;
 /// # use secp256k1::{rand, Secp256k1};
 /// # use secp256k1::ecdh::SharedSecret;
 /// let s = Secp256k1::new();
-/// let (sk1, pk1) = s.generate_keypair(&mut rand::thread_rng());
-/// let (sk2, pk2) = s.generate_keypair(&mut rand::thread_rng());
+/// let (sk1, pk1) = s.generate_keypair(&mut rand::rng());
+/// let (sk2, pk2) = s.generate_keypair(&mut rand::rng());
 /// let sec1 = SharedSecret::new(&pk2, &sk1);
 /// let sec2 = SharedSecret::new(&pk1, &sk2);
 /// assert_eq!(sec1, sec2);
@@ -116,8 +116,8 @@ impl AsRef<[u8]> for SharedSecret {
 /// # use secp256k1::hashes::{Hash, sha512};
 ///
 /// let s = Secp256k1::new();
-/// let (sk1, pk1) = s.generate_keypair(&mut rand::thread_rng());
-/// let (sk2, pk2) = s.generate_keypair(&mut rand::thread_rng());
+/// let (sk1, pk1) = s.generate_keypair(&mut rand::rng());
+/// let (sk2, pk2) = s.generate_keypair(&mut rand::rng());
 ///
 /// let point1 = ecdh::shared_secret_point(&pk2, &sk1);
 /// let secret1 = sha512::Hash::hash(&point1);
@@ -197,8 +197,8 @@ mod tests {
     #[cfg(all(feature = "rand", feature = "std"))]
     fn ecdh() {
         let s = Secp256k1::signing_only();
-        let (sk1, pk1) = s.generate_keypair(&mut rand::thread_rng());
-        let (sk2, pk2) = s.generate_keypair(&mut rand::thread_rng());
+        let (sk1, pk1) = s.generate_keypair(&mut rand::rng());
+        let (sk2, pk2) = s.generate_keypair(&mut rand::rng());
 
         let sec1 = SharedSecret::new(&pk2, &sk1);
         let sec2 = SharedSecret::new(&pk1, &sk2);
@@ -233,8 +233,8 @@ mod tests {
         use crate::ecdh::shared_secret_point;
 
         let s = Secp256k1::signing_only();
-        let (sk1, _) = s.generate_keypair(&mut rand::thread_rng());
-        let (_, pk2) = s.generate_keypair(&mut rand::thread_rng());
+        let (sk1, _) = s.generate_keypair(&mut rand::rng());
+        let (_, pk2) = s.generate_keypair(&mut rand::rng());
 
         let secret_sys = SharedSecret::new(&pk2, &sk1);
 
@@ -286,7 +286,7 @@ mod benches {
     #[bench]
     pub fn bench_ecdh(bh: &mut Bencher) {
         let s = Secp256k1::signing_only();
-        let (sk, pk) = s.generate_keypair(&mut rand::thread_rng());
+        let (sk, pk) = s.generate_keypair(&mut rand::rng());
 
         bh.iter(|| {
             let res = SharedSecret::new(&pk, &sk);
diff --git a/src/ecdsa/mod.rs b/src/ecdsa/mod.rs
index 1cf57c134..65c25d854 100644
--- a/src/ecdsa/mod.rs
+++ b/src/ecdsa/mod.rs
@@ -371,7 +371,7 @@ impl<C: Verification> Secp256k1<C> {
     /// # use secp256k1::{rand, Secp256k1, Message, Error};
     /// #
     /// # let secp = Secp256k1::new();
-    /// # let (secret_key, public_key) = secp.generate_keypair(&mut rand::thread_rng());
+    /// # let (secret_key, public_key) = secp.generate_keypair(&mut rand::rng());
     /// #
     /// let message = Message::from_digest_slice(&[0xab; 32]).expect("32 bytes");
     /// let sig = secp.sign_ecdsa(message, &secret_key);
diff --git a/src/ecdsa/recovery.rs b/src/ecdsa/recovery.rs
index 6a2ebd49f..b1d013b9e 100644
--- a/src/ecdsa/recovery.rs
+++ b/src/ecdsa/recovery.rs
@@ -260,11 +260,11 @@ mod tests {
         let vrfy = Secp256k1::verification_only();
         let full = Secp256k1::new();
 
-        let msg = crate::random_32_bytes(&mut rand::thread_rng());
+        let msg = crate::random_32_bytes(&mut rand::rng());
         let msg = Message::from_digest_slice(&msg).unwrap();
 
         // Try key generation
-        let (sk, pk) = full.generate_keypair(&mut rand::thread_rng());
+        let (sk, pk) = full.generate_keypair(&mut rand::rng());
 
         // Try signing
         assert_eq!(sign.sign_ecdsa_recoverable(msg, &sk), full.sign_ecdsa_recoverable(msg, &sk));
@@ -290,7 +290,7 @@ mod tests {
     #[rustfmt::skip]
     fn sign() {
         let mut s = Secp256k1::new();
-        s.randomize(&mut rand::thread_rng());
+        s.randomize(&mut rand::rng());
 
         let sk = SecretKey::from_slice(&ONE).unwrap();
         let msg = Message::from_digest_slice(&ONE).unwrap();
@@ -315,7 +315,7 @@ mod tests {
     #[rustfmt::skip]
     fn sign_with_noncedata() {
         let mut s = Secp256k1::new();
-        s.randomize(&mut rand::thread_rng());
+        s.randomize(&mut rand::rng());
 
         let sk = SecretKey::from_slice(&ONE).unwrap();
         let msg = Message::from_digest_slice(&ONE).unwrap();
@@ -339,17 +339,17 @@ mod tests {
     #[cfg(all(feature = "rand", feature = "std"))]
     fn sign_and_verify_fail() {
         let mut s = Secp256k1::new();
-        s.randomize(&mut rand::thread_rng());
+        s.randomize(&mut rand::rng());
 
-        let msg = crate::random_32_bytes(&mut rand::thread_rng());
+        let msg = crate::random_32_bytes(&mut rand::rng());
         let msg = Message::from_digest_slice(&msg).unwrap();
 
-        let (sk, pk) = s.generate_keypair(&mut rand::thread_rng());
+        let (sk, pk) = s.generate_keypair(&mut rand::rng());
 
         let sigr = s.sign_ecdsa_recoverable(msg, &sk);
         let sig = sigr.to_standard();
 
-        let msg = crate::random_32_bytes(&mut rand::thread_rng());
+        let msg = crate::random_32_bytes(&mut rand::rng());
         let msg = Message::from_digest_slice(&msg).unwrap();
         assert_eq!(s.verify_ecdsa(msg, &sig, &pk), Err(Error::IncorrectSignature));
 
@@ -361,12 +361,12 @@ mod tests {
     #[cfg(all(feature = "rand", feature = "std"))]
     fn sign_with_recovery() {
         let mut s = Secp256k1::new();
-        s.randomize(&mut rand::thread_rng());
+        s.randomize(&mut rand::rng());
 
-        let msg = crate::random_32_bytes(&mut rand::thread_rng());
+        let msg = crate::random_32_bytes(&mut rand::rng());
         let msg = Message::from_digest_slice(&msg).unwrap();
 
-        let (sk, pk) = s.generate_keypair(&mut rand::thread_rng());
+        let (sk, pk) = s.generate_keypair(&mut rand::rng());
 
         let sig = s.sign_ecdsa_recoverable(msg, &sk);
 
@@ -377,14 +377,14 @@ mod tests {
     #[cfg(all(feature = "rand", feature = "std"))]
     fn sign_with_recovery_and_noncedata() {
         let mut s = Secp256k1::new();
-        s.randomize(&mut rand::thread_rng());
+        s.randomize(&mut rand::rng());
 
-        let msg = crate::random_32_bytes(&mut rand::thread_rng());
+        let msg = crate::random_32_bytes(&mut rand::rng());
         let msg = Message::from_digest_slice(&msg).unwrap();
 
         let noncedata = [42u8; 32];
 
-        let (sk, pk) = s.generate_keypair(&mut rand::thread_rng());
+        let (sk, pk) = s.generate_keypair(&mut rand::rng());
 
         let sig = s.sign_ecdsa_recoverable_with_noncedata(msg, &sk, &noncedata);
 
@@ -395,7 +395,7 @@ mod tests {
     #[cfg(all(feature = "rand", feature = "std"))]
     fn bad_recovery() {
         let mut s = Secp256k1::new();
-        s.randomize(&mut rand::thread_rng());
+        s.randomize(&mut rand::rng());
 
         let msg = Message::from_digest_slice(&[0x55; 32]).unwrap();
 
@@ -467,9 +467,9 @@ mod benches {
     #[bench]
     pub fn bench_recover(bh: &mut Bencher) {
         let s = Secp256k1::new();
-        let msg = crate::random_32_bytes(&mut rand::thread_rng());
+        let msg = crate::random_32_bytes(&mut rand::rng());
         let msg = Message::from_digest_slice(&msg).unwrap();
-        let (sk, _) = s.generate_keypair(&mut rand::thread_rng());
+        let (sk, _) = s.generate_keypair(&mut rand::rng());
         let sig = s.sign_ecdsa_recoverable(&msg, &sk);
 
         bh.iter(|| {
diff --git a/src/key.rs b/src/key.rs
index 0962e00b3..f8f3f44de 100644
--- a/src/key.rs
+++ b/src/key.rs
@@ -48,7 +48,7 @@ use crate::{
 /// use secp256k1::{rand, Secp256k1, SecretKey};
 ///
 /// let secp = Secp256k1::new();
-/// let secret_key = SecretKey::new(&mut rand::thread_rng());
+/// let secret_key = SecretKey::new(&mut rand::rng());
 /// # }
 /// ```
 /// [`bincode`]: https://docs.rs/bincode
@@ -192,7 +192,7 @@ impl SecretKey {
     /// ```
     /// # #[cfg(all(feature = "std", feature =  "rand"))] {
     /// use secp256k1::{rand, SecretKey};
-    /// let secret_key = SecretKey::new(&mut rand::thread_rng());
+    /// let secret_key = SecretKey::new(&mut rand::rng());
     /// # }
     /// ```
     #[inline]
@@ -257,7 +257,7 @@ impl SecretKey {
     /// use secp256k1::{rand, Secp256k1, SecretKey, Keypair};
     ///
     /// let secp = Secp256k1::new();
-    /// let keypair = Keypair::new(&secp, &mut rand::thread_rng());
+    /// let keypair = Keypair::new(&secp, &mut rand::rng());
     /// let secret_key = SecretKey::from_keypair(&keypair);
     /// # }
     /// ```
@@ -433,7 +433,7 @@ impl PublicKey {
     /// use secp256k1::{rand, Secp256k1, SecretKey, PublicKey};
     ///
     /// let secp = Secp256k1::new();
-    /// let secret_key = SecretKey::new(&mut rand::thread_rng());
+    /// let secret_key = SecretKey::new(&mut rand::rng());
     /// let public_key = PublicKey::from_secret_key(&secp, &secret_key);
     /// # }
     /// ```
@@ -524,7 +524,7 @@ impl PublicKey {
     /// use secp256k1::{rand, Secp256k1, PublicKey, Keypair};
     ///
     /// let secp = Secp256k1::new();
-    /// let keypair = Keypair::new(&secp, &mut rand::thread_rng());
+    /// let keypair = Keypair::new(&secp, &mut rand::rng());
     /// let public_key = PublicKey::from_keypair(&keypair);
     /// # }
     /// ```
@@ -657,7 +657,7 @@ impl PublicKey {
     /// use secp256k1::{rand, Secp256k1};
     ///
     /// let secp = Secp256k1::new();
-    /// let mut rng = rand::thread_rng();
+    /// let mut rng = rand::rng();
     /// let (_, pk1) = secp.generate_keypair(&mut rng);
     /// let (_, pk2) = secp.generate_keypair(&mut rng);
     /// let sum = pk1.combine(&pk2).expect("It's improbable to fail for 2 random public keys");
@@ -683,7 +683,7 @@ impl PublicKey {
     /// use secp256k1::{rand, Secp256k1, PublicKey};
     ///
     /// let secp = Secp256k1::new();
-    /// let mut rng = rand::thread_rng();
+    /// let mut rng = rand::rng();
     /// let (_, pk1) = secp.generate_keypair(&mut rng);
     /// let (_, pk2) = secp.generate_keypair(&mut rng);
     /// let (_, pk3) = secp.generate_keypair(&mut rng);
@@ -817,7 +817,7 @@ impl<'de> serde::Deserialize<'de> for PublicKey {
 /// use secp256k1::{rand, Keypair, Secp256k1};
 ///
 /// let secp = Secp256k1::new();
-/// let (secret_key, public_key) = secp.generate_keypair(&mut rand::thread_rng());
+/// let (secret_key, public_key) = secp.generate_keypair(&mut rand::rng());
 /// let keypair = Keypair::from_secret_key(&secp, &secret_key);
 /// # }
 /// ```
@@ -927,7 +927,7 @@ impl Keypair {
     /// use secp256k1::{rand, Secp256k1, SecretKey, Keypair};
     ///
     /// let secp = Secp256k1::new();
-    /// let keypair = Keypair::new(&secp, &mut rand::thread_rng());
+    /// let keypair = Keypair::new(&secp, &mut rand::rng());
     /// # }
     /// ```
     #[inline]
@@ -976,7 +976,7 @@ impl Keypair {
     /// let secp = Secp256k1::new();
     /// let tweak = Scalar::random();
     ///
-    /// let mut keypair = Keypair::new(&secp, &mut rand::thread_rng());
+    /// let mut keypair = Keypair::new(&secp, &mut rand::rng());
     /// let tweaked = keypair.add_xonly_tweak(&secp, &tweak).expect("Improbable to fail with a randomly generated tweak");
     /// # }
     /// ```
@@ -1160,7 +1160,7 @@ impl CPtr for Keypair {
 /// use secp256k1::{rand, Secp256k1, Keypair, XOnlyPublicKey};
 ///
 /// let secp = Secp256k1::new();
-/// let keypair = Keypair::new(&secp, &mut rand::thread_rng());
+/// let keypair = Keypair::new(&secp, &mut rand::rng());
 /// let xonly = XOnlyPublicKey::from_keypair(&keypair);
 /// # }
 /// ```
@@ -1310,7 +1310,7 @@ impl XOnlyPublicKey {
     /// let secp = Secp256k1::new();
     /// let tweak = Scalar::random();
     ///
-    /// let mut keypair = Keypair::new(&secp, &mut rand::thread_rng());
+    /// let mut keypair = Keypair::new(&secp, &mut rand::rng());
     /// let (xonly, _parity) = keypair.x_only_public_key();
     /// let tweaked = xonly.add_tweak(&secp, &tweak).expect("Improbable to fail with a randomly generated tweak");
     /// # }
@@ -1370,7 +1370,7 @@ impl XOnlyPublicKey {
     /// let secp = Secp256k1::new();
     /// let tweak = Scalar::random();
     ///
-    /// let mut keypair = Keypair::new(&secp, &mut rand::thread_rng());
+    /// let mut keypair = Keypair::new(&secp, &mut rand::rng());
     /// let (mut public_key, _) = keypair.x_only_public_key();
     /// let original = public_key;
     /// let (tweaked, parity) = public_key.add_tweak(&secp, &tweak).expect("Improbable to fail with a randomly generated tweak");
@@ -1667,7 +1667,7 @@ mod test {
     fn keypair_slice_round_trip() {
         let s = Secp256k1::new();
 
-        let (sk1, pk1) = s.generate_keypair(&mut rand::thread_rng());
+        let (sk1, pk1) = s.generate_keypair(&mut rand::rng());
         assert_eq!(SecretKey::from_slice(&sk1[..]), Ok(sk1));
         assert_eq!(PublicKey::from_slice(&pk1.serialize()[..]), Ok(pk1));
         assert_eq!(PublicKey::from_slice(&pk1.serialize_uncompressed()[..]), Ok(pk1));
@@ -1733,10 +1733,6 @@ mod test {
                 data[31] = self.0;
                 self.0 -= 1;
             }
-            fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand::Error> {
-                self.fill_bytes(dest);
-                Ok(())
-            }
         }
 
         let s = Secp256k1::new();
@@ -1950,7 +1946,7 @@ mod test {
     fn tweak_add_arbitrary_data() {
         let s = Secp256k1::new();
 
-        let (sk, pk) = s.generate_keypair(&mut rand::thread_rng());
+        let (sk, pk) = s.generate_keypair(&mut rand::rng());
         assert_eq!(PublicKey::from_secret_key(&s, &sk), pk); // Sanity check.
 
         // TODO: This would be better tested with a _lot_ of different tweaks.
@@ -1969,7 +1965,7 @@ mod test {
     fn tweak_add_zero() {
         let s = Secp256k1::new();
 
-        let (sk, pk) = s.generate_keypair(&mut rand::thread_rng());
+        let (sk, pk) = s.generate_keypair(&mut rand::rng());
 
         let tweak = Scalar::ZERO;
 
@@ -1984,7 +1980,7 @@ mod test {
     fn tweak_mul_arbitrary_data() {
         let s = Secp256k1::new();
 
-        let (sk, pk) = s.generate_keypair(&mut rand::thread_rng());
+        let (sk, pk) = s.generate_keypair(&mut rand::rng());
         assert_eq!(PublicKey::from_secret_key(&s, &sk), pk); // Sanity check.
 
         // TODO: This would be better tested with a _lot_ of different tweaks.
@@ -2002,7 +1998,7 @@ mod test {
     #[cfg(all(feature = "rand", feature = "std"))]
     fn tweak_mul_zero() {
         let s = Secp256k1::new();
-        let (sk, _) = s.generate_keypair(&mut rand::thread_rng());
+        let (sk, _) = s.generate_keypair(&mut rand::rng());
 
         let tweak = Scalar::ZERO;
         assert!(sk.mul_tweak(&tweak).is_err())
@@ -2013,7 +2009,7 @@ mod test {
     fn test_negation() {
         let s = Secp256k1::new();
 
-        let (sk, pk) = s.generate_keypair(&mut rand::thread_rng());
+        let (sk, pk) = s.generate_keypair(&mut rand::rng());
 
         assert_eq!(PublicKey::from_secret_key(&s, &sk), pk); // Sanity check.
 
@@ -2047,7 +2043,7 @@ mod test {
         let mut set = HashSet::new();
         const COUNT: usize = 1024;
         for _ in 0..COUNT {
-            let (_, pk) = s.generate_keypair(&mut rand::thread_rng());
+            let (_, pk) = s.generate_keypair(&mut rand::rng());
             let hash = hash(&pk);
             assert!(!set.contains(&hash));
             set.insert(hash);
@@ -2118,8 +2114,8 @@ mod test {
     fn create_pubkey_combine() {
         let s = Secp256k1::new();
 
-        let (sk1, pk1) = s.generate_keypair(&mut rand::thread_rng());
-        let (sk2, pk2) = s.generate_keypair(&mut rand::thread_rng());
+        let (sk1, pk1) = s.generate_keypair(&mut rand::rng());
+        let (sk2, pk2) = s.generate_keypair(&mut rand::rng());
 
         let sum1 = pk1.combine(&pk2);
         assert!(sum1.is_ok());
@@ -2232,7 +2228,7 @@ mod test {
         for _ in 0..10 {
             let tweak = Scalar::random();
 
-            let kp = Keypair::new(&s, &mut rand::thread_rng());
+            let kp = Keypair::new(&s, &mut rand::rng());
             let (xonly, _) = XOnlyPublicKey::from_keypair(&kp);
 
             let tweaked_kp = kp.add_xonly_tweak(&s, &tweak).expect("keypair tweak add failed");
@@ -2486,7 +2482,7 @@ mod test {
     #[cfg(all(feature = "rand", feature = "std"))]
     fn test_keypair_from_str() {
         let ctx = crate::Secp256k1::new();
-        let keypair = Keypair::new(&ctx, &mut rand::thread_rng());
+        let keypair = Keypair::new(&ctx, &mut rand::rng());
         let mut buf = [0_u8; constants::SECRET_KEY_SIZE * 2]; // Holds hex digits.
         let s = to_hex(&keypair.secret_key().secret_bytes(), &mut buf).unwrap();
         let parsed_key = Keypair::from_str(s).unwrap();
diff --git a/src/lib.rs b/src/lib.rs
index de3f8d423..4f0c00d6c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -29,12 +29,12 @@
 //!
 //! ```rust
 //! # #[cfg(all(feature = "rand", feature = "hashes", feature = "std"))] {
-//! use secp256k1::rand::rngs::OsRng;
+//! use secp256k1::rand::rng;
 //! use secp256k1::{Secp256k1, Message};
 //! use secp256k1::hashes::{sha256, Hash};
 //!
 //! let secp = Secp256k1::new();
-//! let (secret_key, public_key) = secp.generate_keypair(&mut OsRng);
+//! let (secret_key, public_key) = secp.generate_keypair(&mut rng());
 //! let digest = sha256::Hash::hash("Hello World!".as_bytes());
 //! let message = Message::from_digest(digest.to_byte_array());
 //!
@@ -50,7 +50,7 @@
 //! use secp256k1::{generate_keypair, Message};
 //! use secp256k1::hashes::{sha256, Hash};
 //!
-//! let (secret_key, public_key) = generate_keypair(&mut rand::thread_rng());
+//! let (secret_key, public_key) = generate_keypair(&mut rand::rng());
 //! let digest = sha256::Hash::hash("Hello World!".as_bytes());
 //! let message = Message::from_digest(digest.to_byte_array());
 //!
@@ -540,7 +540,7 @@ mod tests {
         let sign = unsafe { Secp256k1::from_raw_signing_only(ctx_sign.ctx) };
         let mut vrfy = unsafe { Secp256k1::from_raw_verification_only(ctx_vrfy.ctx) };
 
-        let (sk, pk) = full.generate_keypair(&mut rand::thread_rng());
+        let (sk, pk) = full.generate_keypair(&mut rand::rng());
         let msg = Message::from_digest([2u8; 32]);
         // Try signing
         assert_eq!(sign.sign_ecdsa(msg, &sk), full.sign_ecdsa(msg, &sk));
@@ -607,7 +607,7 @@ mod tests {
         //        drop(buf_vfy); // The buffer can't get dropped before the context.
         //        println!("{:?}", buf_ful[5]); // Can't even read the data thanks to the borrow checker.
 
-        let (sk, pk) = full.generate_keypair(&mut rand::thread_rng());
+        let (sk, pk) = full.generate_keypair(&mut rand::rng());
         let msg = Message::from_digest([2u8; 32]);
         // Try signing
         assert_eq!(sign.sign_ecdsa(msg, &sk), full.sign_ecdsa(msg, &sk));
@@ -625,11 +625,11 @@ mod tests {
         let vrfy = Secp256k1::verification_only();
         let full = Secp256k1::new();
 
-        let msg = crate::random_32_bytes(&mut rand::thread_rng());
+        let msg = crate::random_32_bytes(&mut rand::rng());
         let msg = Message::from_digest(msg);
 
         // Try key generation
-        let (sk, pk) = full.generate_keypair(&mut rand::thread_rng());
+        let (sk, pk) = full.generate_keypair(&mut rand::rng());
 
         // Try signing
         assert_eq!(sign.sign_ecdsa(msg, &sk), full.sign_ecdsa(msg, &sk));
@@ -651,13 +651,13 @@ mod tests {
     #[cfg(all(feature = "rand", feature = "std"))]
     fn signature_serialize_roundtrip() {
         let mut s = Secp256k1::new();
-        s.randomize(&mut rand::thread_rng());
+        s.randomize(&mut rand::rng());
 
         for _ in 0..100 {
-            let msg = crate::random_32_bytes(&mut rand::thread_rng());
+            let msg = crate::random_32_bytes(&mut rand::rng());
             let msg = Message::from_digest(msg);
 
-            let (sk, _) = s.generate_keypair(&mut rand::thread_rng());
+            let (sk, _) = s.generate_keypair(&mut rand::rng());
             let sig1 = s.sign_ecdsa(msg, &sk);
             let der = sig1.serialize_der();
             let sig2 = ecdsa::Signature::from_der(&der[..]).unwrap();
@@ -741,14 +741,14 @@ mod tests {
     #[cfg(all(feature = "rand", feature = "std"))]
     fn sign_and_verify_ecdsa() {
         let mut s = Secp256k1::new();
-        s.randomize(&mut rand::thread_rng());
+        s.randomize(&mut rand::rng());
 
         let noncedata = [42u8; 32];
         for _ in 0..100 {
-            let msg = crate::random_32_bytes(&mut rand::thread_rng());
+            let msg = crate::random_32_bytes(&mut rand::rng());
             let msg = Message::from_digest(msg);
 
-            let (sk, pk) = s.generate_keypair(&mut rand::thread_rng());
+            let (sk, pk) = s.generate_keypair(&mut rand::rng());
             let sig = s.sign_ecdsa(msg, &sk);
             assert_eq!(s.verify_ecdsa(msg, &sig, &pk), Ok(()));
             let noncedata_sig = s.sign_ecdsa_with_noncedata(msg, &sk, &noncedata);
@@ -775,7 +775,7 @@ mod tests {
     #[cfg(all(feature = "rand", feature = "std"))]
     fn sign_and_verify_extreme() {
         let mut s = Secp256k1::new();
-        s.randomize(&mut rand::thread_rng());
+        s.randomize(&mut rand::rng());
 
         // Wild keys: 1, CURVE_ORDER - 1
         // Wild msgs: 1, CURVE_ORDER - 1
@@ -809,16 +809,16 @@ mod tests {
     #[cfg(all(feature = "rand", feature = "std"))]
     fn sign_and_verify_fail() {
         let mut s = Secp256k1::new();
-        s.randomize(&mut rand::thread_rng());
+        s.randomize(&mut rand::rng());
 
-        let msg = crate::random_32_bytes(&mut rand::thread_rng());
+        let msg = crate::random_32_bytes(&mut rand::rng());
         let msg = Message::from_digest(msg);
 
-        let (sk, pk) = s.generate_keypair(&mut rand::thread_rng());
+        let (sk, pk) = s.generate_keypair(&mut rand::rng());
 
         let sig = s.sign_ecdsa(msg, &sk);
 
-        let msg = crate::random_32_bytes(&mut rand::thread_rng());
+        let msg = crate::random_32_bytes(&mut rand::rng());
         let msg = Message::from_digest(msg);
         assert_eq!(s.verify_ecdsa(msg, &sig, &pk), Err(Error::IncorrectSignature));
     }
@@ -854,7 +854,7 @@ mod tests {
 
         use super::to_hex;
 
-        let mut rng = rand::thread_rng();
+        let mut rng = rand::rng();
         const AMOUNT: usize = 1024;
         for i in 0..AMOUNT {
             // 255 isn't a valid utf8 character.
@@ -1026,9 +1026,9 @@ mod benches {
     #[bench]
     pub fn bench_sign_ecdsa(bh: &mut Bencher) {
         let s = Secp256k1::new();
-        let msg = crate::random_32_bytes(&mut rand::thread_rng());
+        let msg = crate::random_32_bytes(&mut rand::rng());
         let msg = Message::from_digest(msg);
-        let (sk, _) = s.generate_keypair(&mut rand::thread_rng());
+        let (sk, _) = s.generate_keypair(&mut rand::rng());
 
         bh.iter(|| {
             let sig = s.sign_ecdsa(msg, &sk);
@@ -1039,9 +1039,9 @@ mod benches {
     #[bench]
     pub fn bench_verify_ecdsa(bh: &mut Bencher) {
         let s = Secp256k1::new();
-        let msg = crate::random_32_bytes(&mut rand::thread_rng());
+        let msg = crate::random_32_bytes(&mut rand::rng());
         let msg = Message::from_digest(msg);
-        let (sk, pk) = s.generate_keypair(&mut rand::thread_rng());
+        let (sk, pk) = s.generate_keypair(&mut rand::rng());
         let sig = s.sign_ecdsa(msg, &sk);
 
         bh.iter(|| {
diff --git a/src/scalar.rs b/src/scalar.rs
index 4bd4d55f4..b67ca740e 100644
--- a/src/scalar.rs
+++ b/src/scalar.rs
@@ -42,7 +42,7 @@ impl Scalar {
 
     /// Generates a random scalar
     #[cfg(all(feature = "rand", feature = "std"))]
-    pub fn random() -> Self { Self::random_custom(rand::thread_rng()) }
+    pub fn random() -> Self { Self::random_custom(rand::rng()) }
 
     /// Generates a random scalar using supplied RNG
     #[cfg(feature = "rand")]
diff --git a/src/schnorr.rs b/src/schnorr.rs
index e4a07a305..fd67072fe 100644
--- a/src/schnorr.rs
+++ b/src/schnorr.rs
@@ -141,7 +141,7 @@ impl<C: Signing> Secp256k1<C> {
     /// generator to generate the auxiliary random data.
     #[cfg(all(feature = "rand", feature = "std"))]
     pub fn sign_schnorr(&self, msg: &[u8], keypair: &Keypair) -> Signature {
-        self.sign_schnorr_with_rng(msg, keypair, &mut rand::thread_rng())
+        self.sign_schnorr_with_rng(msg, keypair, &mut rand::rng())
     }
 
     /// Creates a schnorr signature without using any auxiliary random data.
@@ -253,12 +253,12 @@ mod tests {
     fn sign_helper(sign: fn(&Secp256k1<crate::All>, &[u8], &Keypair, &mut ThreadRng) -> Signature) {
         let secp = Secp256k1::new();
 
-        let mut rng = rand::thread_rng();
+        let mut rng = rand::rng();
         let kp = Keypair::new(&secp, &mut rng);
         let (pk, _parity) = kp.x_only_public_key();
 
         for _ in 0..100 {
-            let msg = crate::random_32_bytes(&mut rand::thread_rng());
+            let msg = crate::random_32_bytes(&mut rand::rng());
 
             let sig = sign(&secp, &msg, &kp, &mut rng);
 
@@ -332,7 +332,7 @@ mod tests {
     #[cfg(all(feature = "rand", feature = "std"))]
     fn test_pubkey_serialize_roundtrip() {
         let secp = Secp256k1::new();
-        let kp = Keypair::new(&secp, &mut rand::thread_rng());
+        let kp = Keypair::new(&secp, &mut rand::rng());
         let (pk, _parity) = kp.x_only_public_key();
 
         let ser = pk.serialize();
diff --git a/src/secret.rs b/src/secret.rs
index f5fc1060d..9f982f7a9 100644
--- a/src/secret.rs
+++ b/src/secret.rs
@@ -14,7 +14,7 @@ macro_rules! impl_display_secret {
         #[cfg(feature = "hashes")]
         impl ::core::fmt::Debug for $thing {
             fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
-                use hashes::{sha256, Hash, HashEngine};
+                use hashes::{sha256, HashEngine};
 
                 let tag = "rust-secp256k1DEBUG";