@@ -49,12 +49,12 @@ impl<const LIMBS: usize> Uint<LIMBS> {
4949
5050 /// Returns the truthy value if `self == rhs` or the falsy value otherwise.
5151 #[ inline]
52- pub ( crate ) const fn ct_eq ( & self , rhs : & Self ) -> CtChoice {
52+ pub ( crate ) const fn ct_eq ( lhs : & Self , rhs : & Self ) -> CtChoice {
5353 let mut acc = 0 ;
5454 let mut i = 0 ;
5555
5656 while i < LIMBS {
57- acc |= self . limbs [ i] . 0 ^ rhs. limbs [ i] . 0 ;
57+ acc |= lhs . limbs [ i] . 0 ^ rhs. limbs [ i] . 0 ;
5858 i += 1 ;
5959 }
6060
@@ -64,40 +64,40 @@ impl<const LIMBS: usize> Uint<LIMBS> {
6464
6565 /// Returns the truthy value if `self <= rhs` and the falsy value otherwise.
6666 #[ inline]
67- pub ( crate ) const fn ct_lt ( & self , rhs : & Self ) -> CtChoice {
67+ pub ( crate ) const fn ct_lt ( lhs : & Self , rhs : & Self ) -> CtChoice {
6868 // We could use the same approach as in Limb::ct_lt(),
6969 // but since we have to use Uint::wrapping_sub(), which calls `sbb()`,
7070 // there are no savings compared to just calling `sbb()` directly.
71- let ( _res, borrow) = self . sbb ( rhs, Limb :: ZERO ) ;
71+ let ( _res, borrow) = lhs . sbb ( rhs, Limb :: ZERO ) ;
7272 CtChoice :: from_mask ( borrow. 0 )
7373 }
7474
7575 /// Returns the truthy value if `self <= rhs` and the falsy value otherwise.
7676 #[ inline]
77- pub ( crate ) const fn ct_gt ( & self , rhs : & Self ) -> CtChoice {
78- let ( _res, borrow) = rhs. sbb ( self , Limb :: ZERO ) ;
77+ pub ( crate ) const fn ct_gt ( lhs : & Self , rhs : & Self ) -> CtChoice {
78+ let ( _res, borrow) = rhs. sbb ( lhs , Limb :: ZERO ) ;
7979 CtChoice :: from_mask ( borrow. 0 )
8080 }
8181}
8282
8383impl < const LIMBS : usize > ConstantTimeEq for Uint < LIMBS > {
8484 #[ inline]
8585 fn ct_eq ( & self , other : & Self ) -> Choice {
86- self . ct_eq ( other) . into ( )
86+ Uint :: ct_eq ( self , other) . into ( )
8787 }
8888}
8989
9090impl < const LIMBS : usize > ConstantTimeGreater for Uint < LIMBS > {
9191 #[ inline]
9292 fn ct_gt ( & self , other : & Self ) -> Choice {
93- self . ct_gt ( other) . into ( )
93+ Uint :: ct_gt ( self , other) . into ( )
9494 }
9595}
9696
9797impl < const LIMBS : usize > ConstantTimeLess for Uint < LIMBS > {
9898 #[ inline]
9999 fn ct_lt ( & self , other : & Self ) -> Choice {
100- self . ct_lt ( other) . into ( )
100+ Uint :: ct_lt ( self , other) . into ( )
101101 }
102102}
103103
@@ -154,10 +154,10 @@ mod tests {
154154 let a = U128 :: ZERO ;
155155 let b = U128 :: MAX ;
156156
157- assert ! ( bool :: from( ConstantTimeEq :: ct_eq( & a , & a) ) ) ;
158- assert ! ( !bool :: from( ConstantTimeEq :: ct_eq( & a , & b) ) ) ;
159- assert ! ( !bool :: from( ConstantTimeEq :: ct_eq( & b , & a) ) ) ;
160- assert ! ( bool :: from( ConstantTimeEq :: ct_eq( & b , & b) ) ) ;
157+ assert ! ( bool :: from( a . ct_eq( & a) ) ) ;
158+ assert ! ( !bool :: from( a . ct_eq( & b) ) ) ;
159+ assert ! ( !bool :: from( b . ct_eq( & a) ) ) ;
160+ assert ! ( bool :: from( b . ct_eq( & b) ) ) ;
161161 }
162162
163163 #[ test]
@@ -166,17 +166,17 @@ mod tests {
166166 let b = U128 :: ONE ;
167167 let c = U128 :: MAX ;
168168
169- assert ! ( bool :: from( ConstantTimeGreater :: ct_gt( & b , & a) ) ) ;
170- assert ! ( bool :: from( ConstantTimeGreater :: ct_gt( & c , & a) ) ) ;
171- assert ! ( bool :: from( ConstantTimeGreater :: ct_gt( & c , & b) ) ) ;
169+ assert ! ( bool :: from( b . ct_gt( & a) ) ) ;
170+ assert ! ( bool :: from( c . ct_gt( & a) ) ) ;
171+ assert ! ( bool :: from( c . ct_gt( & b) ) ) ;
172172
173- assert ! ( !bool :: from( ConstantTimeGreater :: ct_gt( & a , & a) ) ) ;
174- assert ! ( !bool :: from( ConstantTimeGreater :: ct_gt( & b , & b) ) ) ;
175- assert ! ( !bool :: from( ConstantTimeGreater :: ct_gt( & c , & c) ) ) ;
173+ assert ! ( !bool :: from( a . ct_gt( & a) ) ) ;
174+ assert ! ( !bool :: from( b . ct_gt( & b) ) ) ;
175+ assert ! ( !bool :: from( c . ct_gt( & c) ) ) ;
176176
177- assert ! ( !bool :: from( ConstantTimeGreater :: ct_gt( & a , & b) ) ) ;
178- assert ! ( !bool :: from( ConstantTimeGreater :: ct_gt( & a , & c) ) ) ;
179- assert ! ( !bool :: from( ConstantTimeGreater :: ct_gt( & b , & c) ) ) ;
177+ assert ! ( !bool :: from( a . ct_gt( & b) ) ) ;
178+ assert ! ( !bool :: from( a . ct_gt( & c) ) ) ;
179+ assert ! ( !bool :: from( b . ct_gt( & c) ) ) ;
180180 }
181181
182182 #[ test]
@@ -185,16 +185,16 @@ mod tests {
185185 let b = U128 :: ONE ;
186186 let c = U128 :: MAX ;
187187
188- assert ! ( bool :: from( ConstantTimeLess :: ct_lt( & a , & b) ) ) ;
189- assert ! ( bool :: from( ConstantTimeLess :: ct_lt( & a , & c) ) ) ;
190- assert ! ( bool :: from( ConstantTimeLess :: ct_lt( & b , & c) ) ) ;
188+ assert ! ( bool :: from( a . ct_lt( & b) ) ) ;
189+ assert ! ( bool :: from( a . ct_lt( & c) ) ) ;
190+ assert ! ( bool :: from( b . ct_lt( & c) ) ) ;
191191
192- assert ! ( !bool :: from( ConstantTimeLess :: ct_lt( & a , & a) ) ) ;
193- assert ! ( !bool :: from( ConstantTimeLess :: ct_lt( & b , & b) ) ) ;
194- assert ! ( !bool :: from( ConstantTimeLess :: ct_lt( & c , & c) ) ) ;
192+ assert ! ( !bool :: from( a . ct_lt( & a) ) ) ;
193+ assert ! ( !bool :: from( b . ct_lt( & b) ) ) ;
194+ assert ! ( !bool :: from( c . ct_lt( & c) ) ) ;
195195
196- assert ! ( !bool :: from( ConstantTimeLess :: ct_lt( & b , & a) ) ) ;
197- assert ! ( !bool :: from( ConstantTimeLess :: ct_lt( & c , & a) ) ) ;
198- assert ! ( !bool :: from( ConstantTimeLess :: ct_lt( & c , & b) ) ) ;
196+ assert ! ( !bool :: from( b . ct_lt( & a) ) ) ;
197+ assert ! ( !bool :: from( c . ct_lt( & a) ) ) ;
198+ assert ! ( !bool :: from( c . ct_lt( & b) ) ) ;
199199 }
200200}
0 commit comments