Randomize context on initialization
Signed-off-by: Sebastian Geisler <sebastian@blockstream.io>
This commit is contained in:
parent
a959de4174
commit
2046a40905
|
@ -29,7 +29,7 @@ rand-std = ["rand/std"]
|
||||||
recovery = ["secp256k1-sys/recovery"]
|
recovery = ["secp256k1-sys/recovery"]
|
||||||
endomorphism = ["secp256k1-sys/endomorphism"]
|
endomorphism = ["secp256k1-sys/endomorphism"]
|
||||||
lowmemory = ["secp256k1-sys/lowmemory"]
|
lowmemory = ["secp256k1-sys/lowmemory"]
|
||||||
global-context = []
|
global-context = ["std", "rand"]
|
||||||
|
|
||||||
# Use this feature to not compile the bundled libsecp256k1 C symbols,
|
# 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!
|
# but use external ones. Use this only if you know what you are doing!
|
||||||
|
|
|
@ -31,7 +31,9 @@ pub mod global {
|
||||||
static ONCE: Once = Once::new();
|
static ONCE: Once = Once::new();
|
||||||
static mut CONTEXT: Option<Secp256k1<All>> = None;
|
static mut CONTEXT: Option<Secp256k1<All>> = None;
|
||||||
ONCE.call_once(|| unsafe {
|
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() }
|
unsafe { CONTEXT.as_ref().unwrap() }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue