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.
This commit is contained in:
Andrew Poelstra 2022-07-14 14:08:04 +00:00
parent 748284633b
commit b01337cfb5
1 changed files with 2 additions and 2 deletions

View File

@ -47,7 +47,7 @@ pub mod global {
static mut CONTEXT: Option<Secp256k1<All>> = 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());
}