Skip to content

Commit b01337c

Browse files
committed
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.
1 parent 7482846 commit b01337c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub mod global {
4747
static mut CONTEXT: Option<Secp256k1<All>> = None;
4848
ONCE.call_once(|| unsafe {
4949
let mut ctx = Secp256k1::new();
50-
#[cfg(all(feature = "rand-std", not(feature = "global-context-less-secure")))]
50+
#[cfg(all(not(target_arch = "wasm32"), feature = "rand-std", not(feature = "global-context-less-secure")))]
5151
{
5252
ctx.randomize(&mut rand::thread_rng());
5353
}
@@ -202,7 +202,7 @@ mod alloc_only {
202202
size,
203203
};
204204

205-
#[cfg(all(feature = "rand-std", not(feature = "global-context-less-secure")))]
205+
#[cfg(all(not(target_arch = "wasm32"), feature = "rand-std", not(feature = "global-context-less-secure")))]
206206
{
207207
ctx.randomize(&mut rand::thread_rng());
208208
}

0 commit comments

Comments
 (0)