@@ -115,6 +115,9 @@ mod alloc_only {
115
115
#[ cfg( not( feature = "std" ) ) ]
116
116
use alloc:: alloc;
117
117
118
+ #[ cfg( feature = "rand-std" ) ]
119
+ use rand;
120
+
118
121
impl private:: Sealed for SignOnly { }
119
122
impl private:: Sealed for All { }
120
123
impl private:: Sealed for VerifyOnly { }
@@ -191,16 +194,32 @@ mod alloc_only {
191
194
}
192
195
193
196
impl Secp256k1 < All > {
194
- /// Creates a new Secp256k1 context with all capabilities
197
+ /// Creates a new Secp256k1 context with all capabilities.
198
+ ///
199
+ /// If `rand-std` feature is enabled, context will have been randomized using `thread_rng`.
200
+ #[ allow( unused_mut) ] // Unused when `rand-std` is not enabled.
195
201
pub fn new ( ) -> Secp256k1 < All > {
196
- Secp256k1 :: gen_new ( )
202
+ let mut ctx = Secp256k1 :: gen_new ( ) ;
203
+ #[ cfg( feature = "rand-std" ) ]
204
+ {
205
+ ctx. randomize ( & mut rand:: thread_rng ( ) ) ;
206
+ }
207
+ ctx
197
208
}
198
209
}
199
210
200
211
impl Secp256k1 < SignOnly > {
201
212
/// Creates a new Secp256k1 context that can only be used for signing
213
+ ///
214
+ /// If `rand-std` feature is enabled, context will have been randomized using `thread_rng`.
215
+ #[ allow( unused_mut) ] // Unused when `rand-std` is not enabled.
202
216
pub fn signing_only ( ) -> Secp256k1 < SignOnly > {
203
- Secp256k1 :: gen_new ( )
217
+ let mut ctx = Secp256k1 :: gen_new ( ) ;
218
+ #[ cfg( feature = "rand-std" ) ]
219
+ {
220
+ ctx. randomize ( & mut rand:: thread_rng ( ) ) ;
221
+ }
222
+ ctx
204
223
}
205
224
}
206
225
0 commit comments