@@ -15,8 +15,13 @@ thread_local! {
15
15
16
16
/// Borrows the global context and does some operation on it.
17
17
///
18
- /// If provided, after the operation is complete, [`rerandomize_global_context`]
19
- /// is called on the context. If you have some random data available,
18
+ /// If `rerandomize_seed` is provided, then [`rerandomize_global_context`] is called on the context
19
+ /// after the operation. This argument should be provided alongside any operation that uses secret
20
+ /// data (e.g. signing, but not verification). If you have random data available, it should be
21
+ /// provided here; it will be mixed with the current random state as well as the system RNG if it is
22
+ /// available. If you do not have any random data, it is fine to provide all zeros, or a counter, or
23
+ /// a weak source of entropy. This is a defense-in-depth measure to protect against side-channel
24
+ /// attacks, and anything helps (and nothing will hurt).
20
25
pub fn with_global_context < T , Ctx : Context , F : FnOnce ( & Secp256k1 < Ctx > ) -> T > (
21
26
f : F ,
22
27
rerandomize_seed : Option < & [ u8 ; 32 ] > ,
@@ -32,8 +37,13 @@ pub fn with_global_context<T, Ctx: Context, F: FnOnce(&Secp256k1<Ctx>) -> T>(
32
37
33
38
/// Borrows the global context as a raw pointer and does some operation on it.
34
39
///
35
- /// If provided, after the operation is complete, [`rerandomize_global_context`]
36
- /// is called on the context. If you have some random data available,
40
+ /// If `rerandomize_seed` is provided, then [`rerandomize_global_context`] is called on the context
41
+ /// after the operation. This argument should be provided alongside any operation that uses secret
42
+ /// data (e.g. signing, but not verification). If you have random data available, it should be
43
+ /// provided here; it will be mixed with the current random state as well as the system RNG if it is
44
+ /// available. If you do not have any random data, it is fine to provide all zeros, or a counter, or
45
+ /// a weak source of entropy. This is a defense-in-depth measure to protect against side-channel
46
+ /// attacks, and anything helps (and nothing will hurt).
37
47
pub fn with_raw_global_context < T , F : FnOnce ( NonNull < ffi:: Context > ) -> T > (
38
48
f : F ,
39
49
rerandomize_seed : Option < & [ u8 ; 32 ] > ,
0 commit comments