@@ -9,7 +9,10 @@ impl<const LIMBS: usize> Uint<LIMBS> {
99 /// Computes `self` / `rhs` using a pre-made reciprocal,
1010 /// returns the quotient (q) and remainder (r).
1111 #[ inline( always) ]
12- pub const fn ct_div_rem_limb_with_reciprocal ( & self , reciprocal : & Reciprocal ) -> ( Self , Limb ) {
12+ pub const fn const_div_rem_limb_with_reciprocal (
13+ & self ,
14+ reciprocal : & Reciprocal ,
15+ ) -> ( Self , Limb ) {
1316 div_rem_limb_with_reciprocal ( self , reciprocal)
1417 }
1518
@@ -27,8 +30,8 @@ impl<const LIMBS: usize> Uint<LIMBS> {
2730 /// Returns the truthy value as the third element of the tuple if `rhs != 0`,
2831 /// and the falsy value otherwise.
2932 #[ inline( always) ]
30- pub ( crate ) const fn ct_div_rem_limb ( & self , rhs : Limb ) -> ( Self , Limb , CtChoice ) {
31- let ( reciprocal, is_some) = Reciprocal :: ct_new ( rhs) ;
33+ pub ( crate ) const fn const_div_rem_limb ( & self , rhs : Limb ) -> ( Self , Limb , CtChoice ) {
34+ let ( reciprocal, is_some) = Reciprocal :: const_new ( rhs) ;
3235 let ( quo, rem) = div_rem_limb_with_reciprocal ( self , & reciprocal) ;
3336 ( quo, rem, is_some)
3437 }
@@ -37,7 +40,7 @@ impl<const LIMBS: usize> Uint<LIMBS> {
3740 #[ inline( always) ]
3841 pub fn div_rem_limb ( & self , rhs : NonZero < Limb > ) -> ( Self , Limb ) {
3942 // Guaranteed to succeed since `rhs` is nonzero.
40- let ( quo, rem, _is_some) = self . ct_div_rem_limb ( * rhs) ;
43+ let ( quo, rem, _is_some) = self . const_div_rem_limb ( * rhs) ;
4144 ( quo, rem)
4245 }
4346
@@ -59,9 +62,9 @@ impl<const LIMBS: usize> Uint<LIMBS> {
5962 let mut done = CtChoice :: FALSE ;
6063 loop {
6164 let ( mut r, borrow) = rem. sbb ( & c, Limb :: ZERO ) ;
62- rem = Self :: ct_select ( & r, & rem, CtChoice :: from_word_mask ( borrow. 0 ) . or ( done) ) ;
65+ rem = Self :: select ( & r, & rem, CtChoice :: from_word_mask ( borrow. 0 ) . or ( done) ) ;
6366 r = quo. bitor ( & Self :: ONE ) ;
64- quo = Self :: ct_select ( & r, & quo, CtChoice :: from_word_mask ( borrow. 0 ) . or ( done) ) ;
67+ quo = Self :: select ( & r, & quo, CtChoice :: from_word_mask ( borrow. 0 ) . or ( done) ) ;
6568 if i == 0 {
6669 break ;
6770 }
@@ -70,11 +73,11 @@ impl<const LIMBS: usize> Uint<LIMBS> {
7073 // aren't modified further (but do the remaining iterations anyway to be constant-time)
7174 done = CtChoice :: from_word_lt ( i as Word , mb as Word ) ;
7275 c = c. shr1 ( ) ;
73- quo = Self :: ct_select ( & quo. shl1 ( ) , & quo, done) ;
76+ quo = Self :: select ( & quo. shl1 ( ) , & quo, done) ;
7477 }
7578
76- let is_some = Limb ( mb as Word ) . ct_is_nonzero ( ) ;
77- quo = Self :: ct_select ( & Self :: ZERO , & quo, is_some) ;
79+ let is_some = Limb ( mb as Word ) . is_nonzero ( ) ;
80+ quo = Self :: select ( & Self :: ZERO , & quo, is_some) ;
7881 ( quo, rem, is_some)
7982 }
8083
@@ -97,9 +100,9 @@ impl<const LIMBS: usize> Uint<LIMBS> {
97100
98101 loop {
99102 let ( mut r, borrow) = rem. sbb ( & c, Limb :: ZERO ) ;
100- rem = Self :: ct_select ( & r, & rem, CtChoice :: from_word_mask ( borrow. 0 ) ) ;
103+ rem = Self :: select ( & r, & rem, CtChoice :: from_word_mask ( borrow. 0 ) ) ;
101104 r = quo. bitor ( & Self :: ONE ) ;
102- quo = Self :: ct_select ( & r, & quo, CtChoice :: from_word_mask ( borrow. 0 ) ) ;
105+ quo = Self :: select ( & r, & quo, CtChoice :: from_word_mask ( borrow. 0 ) ) ;
103106 if bd == 0 {
104107 break ;
105108 }
@@ -109,7 +112,7 @@ impl<const LIMBS: usize> Uint<LIMBS> {
109112 }
110113
111114 let is_some = CtChoice :: from_u32_nonzero ( mb) ;
112- quo = Self :: ct_select ( & Self :: ZERO , & quo, is_some) ;
115+ quo = Self :: select ( & Self :: ZERO , & quo, is_some) ;
113116 ( quo, rem, is_some)
114117 }
115118
@@ -129,7 +132,7 @@ impl<const LIMBS: usize> Uint<LIMBS> {
129132
130133 loop {
131134 let ( r, borrow) = rem. sbb ( & c, Limb :: ZERO ) ;
132- rem = Self :: ct_select ( & r, & rem, CtChoice :: from_word_mask ( borrow. 0 ) ) ;
135+ rem = Self :: select ( & r, & rem, CtChoice :: from_word_mask ( borrow. 0 ) ) ;
133136 if bd == 0 {
134137 break ;
135138 }
@@ -164,8 +167,8 @@ impl<const LIMBS: usize> Uint<LIMBS> {
164167 let ( lower_sub, borrow) = lower. sbb ( & c. 0 , Limb :: ZERO ) ;
165168 let ( upper_sub, borrow) = upper. sbb ( & c. 1 , borrow) ;
166169
167- lower = Self :: ct_select ( & lower_sub, & lower, CtChoice :: from_word_mask ( borrow. 0 ) ) ;
168- upper = Self :: ct_select ( & upper_sub, & upper, CtChoice :: from_word_mask ( borrow. 0 ) ) ;
170+ lower = Self :: select ( & lower_sub, & lower, CtChoice :: from_word_mask ( borrow. 0 ) ) ;
171+ upper = Self :: select ( & upper_sub, & upper, CtChoice :: from_word_mask ( borrow. 0 ) ) ;
169172 if bd == 0 {
170173 break ;
171174 }
@@ -191,7 +194,7 @@ impl<const LIMBS: usize> Uint<LIMBS> {
191194
192195 let outmask = Limb ( out. limbs [ limb_num] . 0 & mask) ;
193196
194- out. limbs [ limb_num] = Limb :: ct_select ( out. limbs [ limb_num] , outmask, le) ;
197+ out. limbs [ limb_num] = Limb :: select ( out. limbs [ limb_num] , outmask, le) ;
195198
196199 // TODO: this is not constant-time.
197200 let mut i = limb_num + 1 ;
@@ -305,7 +308,7 @@ impl<const LIMBS: usize> Div<NonZero<Limb>> for Uint<LIMBS> {
305308 type Output = Uint < LIMBS > ;
306309
307310 fn div ( self , rhs : NonZero < Limb > ) -> Self :: Output {
308- let ( q, _, _) = self . ct_div_rem_limb ( * rhs) ;
311+ let ( q, _, _) = self . const_div_rem_limb ( * rhs) ;
309312 q
310313 }
311314}
@@ -394,7 +397,7 @@ impl<const LIMBS: usize> Rem<NonZero<Limb>> for Uint<LIMBS> {
394397 type Output = Limb ;
395398
396399 fn rem ( self , rhs : NonZero < Limb > ) -> Self :: Output {
397- let ( _, r, _) = self . ct_div_rem_limb ( * rhs) ;
400+ let ( _, r, _) = self . const_div_rem_limb ( * rhs) ;
398401 r
399402 }
400403}
0 commit comments