File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -191,16 +191,32 @@ mod alloc_only {
191191 }
192192
193193 impl Secp256k1 < All > {
194- /// Creates a new Secp256k1 context with all capabilities
194+ /// Creates a new Secp256k1 context with all capabilities.
195+ ///
196+ /// If `rand-std` feature is enabled, context will have been randomized using `thread_rng`.
197+ #[ allow( unused_mut) ] // Unused when `rand-std` is not enabled.
195198 pub fn new ( ) -> Secp256k1 < All > {
196- Secp256k1 :: gen_new ( )
199+ let mut ctx = Secp256k1 :: gen_new ( ) ;
200+ #[ cfg( feature = "rand-std" ) ]
201+ {
202+ ctx. randomize ( & mut rand:: thread_rng ( ) ) ;
203+ }
204+ ctx
197205 }
198206 }
199207
200208 impl Secp256k1 < SignOnly > {
201209 /// Creates a new Secp256k1 context that can only be used for signing
210+ ///
211+ /// If `rand-std` feature is enabled, context will have been randomized using `thread_rng`.
212+ #[ allow( unused_mut) ] // Unused when `rand-std` is not enabled.
202213 pub fn signing_only ( ) -> Secp256k1 < SignOnly > {
203- Secp256k1 :: gen_new ( )
214+ let mut ctx = Secp256k1 :: gen_new ( ) ;
215+ #[ cfg( feature = "rand-std" ) ]
216+ {
217+ ctx. randomize ( & mut rand:: thread_rng ( ) ) ;
218+ }
219+ ctx
204220 }
205221 }
206222
You can’t perform that action at this time.
0 commit comments