File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -646,6 +646,13 @@ impl<C: Context> Secp256k1<C> {
646
646
pub fn randomize < R : Rng + ?Sized > ( & mut self , rng : & mut R ) {
647
647
let mut seed = [ 0 ; 32 ] ;
648
648
rng. fill_bytes ( & mut seed) ;
649
+ self . seeded_randomize ( & seed) ;
650
+ }
651
+
652
+ /// (Re)randomizes the Secp256k1 context for cheap sidechannel resistance given 32 bytes of
653
+ /// cryptographically-secure random data;
654
+ /// see comment in libsecp256k1 commit d2275795f by Gregory Maxwell.
655
+ pub fn seeded_randomize ( & mut self , seed : & [ u8 ; 32 ] ) {
649
656
unsafe {
650
657
let err = ffi:: secp256k1_context_randomize ( self . ctx , seed. as_c_ptr ( ) ) ;
651
658
// This function cannot fail; it has an error return for future-proofing.
@@ -659,7 +666,6 @@ impl<C: Context> Secp256k1<C> {
659
666
assert_eq ! ( err, 1 ) ;
660
667
}
661
668
}
662
-
663
669
}
664
670
665
671
fn der_length_check ( sig : & ffi:: Signature , max_len : usize ) -> bool {
You can’t perform that action at this time.
0 commit comments