@@ -9,11 +9,11 @@ use Secp256k1;
99#[ cfg_attr( docsrs, doc( cfg( any( feature = "std" , feature = "alloc" ) ) ) ) ]
1010pub use self :: alloc_only:: * ;
1111
12- #[ cfg( all( feature = "global-context-less-secure " , feature = "std" ) ) ]
13- #[ cfg_attr( docsrs, doc( cfg( any ( feature = "global-context" , feature = "global-context-less-secure " ) ) ) ) ]
12+ #[ cfg( all( feature = "global-context" , feature = "std" ) ) ]
13+ #[ cfg_attr( docsrs, doc( cfg( all ( feature = "global-context" , feature = "std " ) ) ) ) ]
1414/// Module implementing a singleton pattern for a global `Secp256k1` context
1515pub mod global {
16- #[ cfg( feature = "global-context " ) ]
16+ #[ cfg( feature = "rand-std " ) ]
1717 use rand;
1818
1919 use std:: ops:: Deref ;
@@ -26,22 +26,29 @@ pub mod global {
2626 __private : ( ) ,
2727 }
2828
29- /// A global, static context to avoid repeatedly creating contexts where one can't be passed
29+ /// A global static context to avoid repeatedly creating contexts.
3030 ///
31- /// If the global-context feature is enabled (and not just the global-context-less-secure),
32- /// this will have been randomized.
31+ /// If `rand-std` feature is enabled, context will have been randomized using `thread_rng`.
32+ ///
33+ /// ```
34+ /// # #[cfg(all(feature = "global-context", feature = "rand-std"))] {
35+ /// use secp256k1::{PublicKey, SECP256K1};
36+ /// use secp256k1::rand::thread_rng;
37+ /// let _ = SECP256K1.generate_keypair(&mut thread_rng());
38+ /// # }
39+ /// ```
3340 pub static SECP256K1 : & GlobalContext = & GlobalContext { __private : ( ) } ;
3441
3542 impl Deref for GlobalContext {
3643 type Target = Secp256k1 < All > ;
3744
38- #[ allow( unused_mut) ] // Unused when "global-context" is not enabled.
45+ #[ allow( unused_mut) ] // Unused when `rand-std` is not enabled.
3946 fn deref ( & self ) -> & Self :: Target {
4047 static ONCE : Once = Once :: new ( ) ;
4148 static mut CONTEXT : Option < Secp256k1 < All > > = None ;
4249 ONCE . call_once ( || unsafe {
4350 let mut ctx = Secp256k1 :: new ( ) ;
44- #[ cfg( feature = "global-context " ) ]
51+ #[ cfg( feature = "rand-std " ) ]
4552 {
4653 ctx. randomize ( & mut rand:: thread_rng ( ) ) ;
4754 }
0 commit comments