@@ -241,21 +241,16 @@ impl ConstChoice {
241241 x & self . as_u32_mask ( )
242242 }
243243
244+ /// WARNING: this method should only be used in contexts that aren't constant-time critical!
244245 #[ inline]
245- pub ( crate ) const fn is_true_vartime ( & self ) -> bool {
246- self . 0 == ConstChoice :: TRUE . 0
246+ pub ( crate ) const fn to_bool_vartime ( & self ) -> bool {
247+ self . 0 != 0
247248 }
248249
249250 #[ inline]
250251 pub ( crate ) const fn to_u8 ( self ) -> u8 {
251252 ( self . 0 as u8 ) & 1
252253 }
253-
254- /// WARNING: this method should only be used in contexts that aren't constant-time critical!
255- #[ inline]
256- pub ( crate ) const fn to_bool_vartime ( self ) -> bool {
257- self . to_u8 ( ) != 0
258- }
259254}
260255
261256/// `const` equivalent of `u32::max(a, b)`.
@@ -284,7 +279,7 @@ impl From<Choice> for ConstChoice {
284279
285280impl From < ConstChoice > for bool {
286281 fn from ( choice : ConstChoice ) -> Self {
287- choice. is_true_vartime ( )
282+ choice. to_bool_vartime ( )
288283 }
289284}
290285
@@ -351,7 +346,7 @@ impl<T> ConstCtOption<T> {
351346 #[ track_caller]
352347 pub fn unwrap ( self ) -> T {
353348 assert ! (
354- self . is_some. is_true_vartime ( ) ,
349+ self . is_some. to_bool_vartime ( ) ,
355350 "called `ConstCtOption::unwrap()` on a `None` value"
356351 ) ;
357352 self . value
@@ -403,7 +398,7 @@ impl<const LIMBS: usize> ConstCtOption<Uint<LIMBS>> {
403398 #[ inline]
404399 #[ track_caller]
405400 pub const fn expect ( self , msg : & str ) -> Uint < LIMBS > {
406- assert ! ( self . is_some. is_true_vartime ( ) , "{}" , msg) ;
401+ assert ! ( self . is_some. to_bool_vartime ( ) , "{}" , msg) ;
407402 self . value
408403 }
409404
@@ -424,7 +419,7 @@ impl<const LIMBS: usize> ConstCtOption<(Uint<LIMBS>, Uint<LIMBS>)> {
424419 #[ inline]
425420 #[ track_caller]
426421 pub const fn expect ( self , msg : & str ) -> ( Uint < LIMBS > , Uint < LIMBS > ) {
427- assert ! ( self . is_some. is_true_vartime ( ) , "{}" , msg) ;
422+ assert ! ( self . is_some. to_bool_vartime ( ) , "{}" , msg) ;
428423 self . value
429424 }
430425}
@@ -439,7 +434,7 @@ impl<const LIMBS: usize> ConstCtOption<NonZero<Uint<LIMBS>>> {
439434 #[ inline]
440435 #[ track_caller]
441436 pub const fn expect ( self , msg : & str ) -> NonZero < Uint < LIMBS > > {
442- assert ! ( self . is_some. is_true_vartime ( ) , "{}" , msg) ;
437+ assert ! ( self . is_some. to_bool_vartime ( ) , "{}" , msg) ;
443438 self . value
444439 }
445440}
@@ -454,7 +449,7 @@ impl<const LIMBS: usize> ConstCtOption<Odd<Uint<LIMBS>>> {
454449 #[ inline]
455450 #[ track_caller]
456451 pub const fn expect ( self , msg : & str ) -> Odd < Uint < LIMBS > > {
457- assert ! ( self . is_some. is_true_vartime ( ) , "{}" , msg) ;
452+ assert ! ( self . is_some. to_bool_vartime ( ) , "{}" , msg) ;
458453 self . value
459454 }
460455}
@@ -475,7 +470,7 @@ impl<const LIMBS: usize> ConstCtOption<Int<LIMBS>> {
475470 #[ inline]
476471 #[ track_caller]
477472 pub const fn expect ( self , msg : & str ) -> Int < LIMBS > {
478- assert ! ( self . is_some. is_true_vartime ( ) , "{}" , msg) ;
473+ assert ! ( self . is_some. to_bool_vartime ( ) , "{}" , msg) ;
479474 self . value
480475 }
481476}
@@ -490,7 +485,7 @@ impl<const LIMBS: usize> ConstCtOption<NonZeroInt<LIMBS>> {
490485 #[ inline]
491486 #[ track_caller]
492487 pub const fn expect ( self , msg : & str ) -> NonZeroInt < LIMBS > {
493- assert ! ( self . is_some. is_true_vartime ( ) , "{}" , msg) ;
488+ assert ! ( self . is_some. to_bool_vartime ( ) , "{}" , msg) ;
494489 self . value
495490 }
496491}
@@ -505,7 +500,7 @@ impl<const LIMBS: usize> ConstCtOption<OddInt<LIMBS>> {
505500 #[ inline]
506501 #[ track_caller]
507502 pub const fn expect ( self , msg : & str ) -> OddInt < LIMBS > {
508- assert ! ( self . is_some. is_true_vartime ( ) , "{}" , msg) ;
503+ assert ! ( self . is_some. to_bool_vartime ( ) , "{}" , msg) ;
509504 self . value
510505 }
511506}
@@ -520,7 +515,7 @@ impl ConstCtOption<NonZero<Limb>> {
520515 #[ inline]
521516 #[ track_caller]
522517 pub const fn expect ( self , msg : & str ) -> NonZero < Limb > {
523- assert ! ( self . is_some. is_true_vartime ( ) , "{}" , msg) ;
518+ assert ! ( self . is_some. to_bool_vartime ( ) , "{}" , msg) ;
524519 self . value
525520 }
526521}
@@ -535,7 +530,7 @@ impl<const LIMBS: usize> ConstCtOption<SafeGcdInverter<LIMBS>> {
535530 #[ inline]
536531 #[ track_caller]
537532 pub const fn expect ( self , msg : & str ) -> SafeGcdInverter < LIMBS > {
538- assert ! ( self . is_some. is_true_vartime ( ) , "{}" , msg) ;
533+ assert ! ( self . is_some. to_bool_vartime ( ) , "{}" , msg) ;
539534 self . value
540535 }
541536}
@@ -555,7 +550,7 @@ impl<MOD: ConstMontyParams<LIMBS>, const LIMBS: usize> ConstCtOption<ConstMontyF
555550 #[ inline]
556551 #[ track_caller]
557552 pub const fn expect ( self , msg : & str ) -> ConstMontyForm < MOD , LIMBS > {
558- assert ! ( self . is_some. is_true_vartime ( ) , "{}" , msg) ;
553+ assert ! ( self . is_some. to_bool_vartime ( ) , "{}" , msg) ;
559554 self . value
560555 }
561556}
0 commit comments