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> {
646646 pub fn randomize < R : Rng + ?Sized > ( & mut self , rng : & mut R ) {
647647 let mut seed = [ 0 ; 32 ] ;
648648 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 ] ) {
649656 unsafe {
650657 let err = ffi:: secp256k1_context_randomize ( self . ctx , seed. as_c_ptr ( ) ) ;
651658 // This function cannot fail; it has an error return for future-proofing.
@@ -659,7 +666,6 @@ impl<C: Context> Secp256k1<C> {
659666 assert_eq ! ( err, 1 ) ;
660667 }
661668 }
662-
663669}
664670
665671fn der_length_check ( sig : & ffi:: Signature , max_len : usize ) -> bool {
You can’t perform that action at this time.
0 commit comments