Skip to content

Commit

Permalink
Merge #407: restore global-context-less-secure feature
Browse files Browse the repository at this point in the history
2a25e5e restore `global-context-less-secure` feature (Andrew Poelstra)

Pull request description:

  We can't remove a feature in a minor release, and also I believe this feature is actually necessary in some niche applications.

ACKs for top commit:
  elichai:
    utACK 2a25e5e

Tree-SHA512: bad6e40dcf625d231568e7336c0996e8b7d1aed8883c7ea475dd7248a98232a27796bbd1cae23ffbd81336d08e3ebaab4b2d559bf9f6f5f17801e91588871b58
  • Loading branch information
apoelstra committed Feb 21, 2022
2 parents ef59aea + 2a25e5e commit 082a638
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ rand-std = ["rand/std"]
recovery = ["secp256k1-sys/recovery"]
lowmemory = ["secp256k1-sys/lowmemory"]
global-context = ["std"]
# disable re-randomization of the global context, which provides some
# defense-in-depth against sidechannel attacks. You should only use
# this feature if you expect the `rand` crate's thread_rng to panic.
# (If you are sure the `rand-std` feature will not be enabled, e.g.
# if you are doing a no-std build, then this feature does nothing
# and is not necessary.)
global-context-less-secure = []

[dependencies]
secp256k1-sys = { version = "0.4.2", default-features = false, path = "./secp256k1-sys" }
Expand Down
2 changes: 1 addition & 1 deletion src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub mod global {
static mut CONTEXT: Option<Secp256k1<All>> = None;
ONCE.call_once(|| unsafe {
let mut ctx = Secp256k1::new();
#[cfg(feature = "rand-std")]
#[cfg(all(feature = "rand-std", not(feature = "global-context-less-secure")))]
{
ctx.randomize(&mut rand::thread_rng());
}
Expand Down

0 comments on commit 082a638

Please sign in to comment.