diff --git a/Cargo.toml b/Cargo.toml index be37c4e..298496a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ rand-std = ["rand/std"] recovery = ["secp256k1-sys/recovery"] endomorphism = ["secp256k1-sys/endomorphism"] lowmemory = ["secp256k1-sys/lowmemory"] -global-context = [] +global-context = ["std", "rand"] # Use this feature to not compile the bundled libsecp256k1 C symbols, # but use external ones. Use this only if you know what you are doing! diff --git a/src/context.rs b/src/context.rs index 80290e6..0e55d59 100644 --- a/src/context.rs +++ b/src/context.rs @@ -31,7 +31,9 @@ pub mod global { static ONCE: Once = Once::new(); static mut CONTEXT: Option> = None; ONCE.call_once(|| unsafe { - CONTEXT = Some(Secp256k1::new()); + let mut ctx = Secp256k1::new(); + ctx.randomize(&mut rand::thread_rng()); + CONTEXT = Some(ctx); }); unsafe { CONTEXT.as_ref().unwrap() } }