From 748284633bbabca8ff1f17fe7ed260e3cee5c480 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Thu, 14 Jul 2022 14:06:41 +0000 Subject: [PATCH 1/3] apply `global-context-not-secure` logic to Secp256k1::new Disable auto-rerandomization for both global and local contexts. --- src/context.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/context.rs b/src/context.rs index 12afb0f98..9f6dd8fb8 100644 --- a/src/context.rs +++ b/src/context.rs @@ -202,7 +202,7 @@ mod alloc_only { size, }; - #[cfg(feature = "rand-std")] + #[cfg(all(feature = "rand-std", not(feature = "global-context-less-secure")))] { ctx.randomize(&mut rand::thread_rng()); } From b01337cfb5ca87243d0fcee573480f3ab5747ffd Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Thu, 14 Jul 2022 14:08:04 +0000 Subject: [PATCH 2/3] context: unconditionally disable auto-rerandomization on wasm This causes panics. We can't add catch the panic, we can't change its output, we can't detect if it'll happen, etc. Rather than dealing with confused bug reports let's just drop this. If users want to rerandomize their contexts they can do so manually. There is probably a better solution to this but it is still under debate, even upstream in the C library, what this should look like. Meanwhile we have bug reports now. --- src/context.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/context.rs b/src/context.rs index 9f6dd8fb8..fca1dc4ef 100644 --- a/src/context.rs +++ b/src/context.rs @@ -47,7 +47,7 @@ pub mod global { static mut CONTEXT: Option> = None; ONCE.call_once(|| unsafe { let mut ctx = Secp256k1::new(); - #[cfg(all(feature = "rand-std", not(feature = "global-context-less-secure")))] + #[cfg(all(not(target_arch = "wasm32"), feature = "rand-std", not(feature = "global-context-less-secure")))] { ctx.randomize(&mut rand::thread_rng()); } @@ -202,7 +202,7 @@ mod alloc_only { size, }; - #[cfg(all(feature = "rand-std", not(feature = "global-context-less-secure")))] + #[cfg(all(not(target_arch = "wasm32"), feature = "rand-std", not(feature = "global-context-less-secure")))] { ctx.randomize(&mut rand::thread_rng()); } From d206891eaaaee32e1b982f6d1439a3e19d0ebfe8 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Thu, 14 Jul 2022 14:10:59 +0000 Subject: [PATCH 3/3] bump version to 0.23.4 --- CHANGELOG.md | 4 ++++ Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9cbe6c21..aacd9f0f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.23.4 - 2022-07-14 + +* [Disable automatic rerandomization of contexts under WASM](https://github.com/rust-bitcoin/rust-secp256k1/pull/474) + # 0.23.3 - 2022-06-29 * [Add must_use for mut self key manipulation methods](https://github.com/rust-bitcoin/rust-secp256k1/pull/465) diff --git a/Cargo.toml b/Cargo.toml index 03af3d338..de7ff34a3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "secp256k1" -version = "0.23.3" +version = "0.23.4" authors = [ "Dawid Ciężarkiewicz ", "Andrew Poelstra " ] license = "CC0-1.0"