@@ -27,7 +27,7 @@ mod rand;
2727use crate :: { Integer , Limb , NonZero , Uint , Word , Zero , U128 , U64 } ;
2828use alloc:: { boxed:: Box , vec, vec:: Vec } ;
2929use core:: { fmt, mem} ;
30- use subtle:: { Choice , ConditionallySelectable , ConstantTimeEq } ;
30+ use subtle:: { Choice , ConstantTimeEq } ;
3131
3232#[ cfg( feature = "zeroize" ) ]
3333use zeroize:: Zeroize ;
@@ -188,46 +188,6 @@ impl BoxedUint {
188188 self . limbs . len ( )
189189 }
190190
191- /// Conditionally select `a` or `b` in constant time depending on [`Choice`].
192- ///
193- /// NOTE: can't impl `subtle`'s [`ConditionallySelectable`] trait due to its `Copy` bound, so
194- /// this is an inherent function instead.
195- ///
196- /// Panics if `a` and `b` don't have the same precision.
197- pub fn conditional_select ( a : & Self , b : & Self , choice : Choice ) -> Self {
198- debug_assert_eq ! ( a. bits_precision( ) , b. bits_precision( ) ) ;
199- let mut limbs = vec ! [ Limb :: ZERO ; a. nlimbs( ) ] . into_boxed_slice ( ) ;
200-
201- for i in 0 ..a. nlimbs ( ) {
202- limbs[ i] = Limb :: conditional_select ( & a. limbs [ i] , & b. limbs [ i] , choice) ;
203- }
204-
205- Self { limbs }
206- }
207-
208- /// Conditionally assign `other` to `self`, according to `choice`.
209- ///
210- /// This function should execute in constant time.
211- #[ inline]
212- pub fn conditional_assign ( & mut self , other : & Self , choice : Choice ) {
213- debug_assert_eq ! ( self . bits_precision( ) , other. bits_precision( ) ) ;
214-
215- for i in 0 ..self . nlimbs ( ) {
216- self . limbs [ i] = Limb :: conditional_select ( & self . limbs [ i] , & other. limbs [ i] , choice) ;
217- }
218- }
219-
220- /// Conditionally swap `self` and `other` if `choice == 1`; otherwise,
221- /// reassign both unto themselves.
222- ///
223- /// This function should execute in constant time.
224- #[ inline]
225- fn conditional_swap ( a : & mut Self , b : & mut Self , choice : Choice ) {
226- let t = a. clone ( ) ;
227- a. conditional_assign ( b, choice) ;
228- b. conditional_assign ( & t, choice) ;
229- }
230-
231191 /// Widen this type's precision to the given number of bits.
232192 ///
233193 /// Panics if `at_least_bits_precision` is smaller than the current precision.
@@ -507,16 +467,6 @@ mod tests {
507467 use super :: BoxedUint ;
508468 use crate :: Word ;
509469 use alloc:: vec:: Vec ;
510- use subtle:: Choice ;
511-
512- #[ test]
513- fn conditional_select ( ) {
514- let a = BoxedUint :: zero_with_precision ( 128 ) ;
515- let b = BoxedUint :: max ( 128 ) ;
516-
517- assert_eq ! ( a, BoxedUint :: conditional_select( & a, & b, Choice :: from( 0 ) ) ) ;
518- assert_eq ! ( b, BoxedUint :: conditional_select( & a, & b, Choice :: from( 1 ) ) ) ;
519- }
520470
521471 #[ test]
522472 fn from_word_vec ( ) {
0 commit comments