File tree 1 file changed +7
-3
lines changed
1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ impl<const LIMBS: usize> Uint<LIMBS> {
22
22
// See Hast, "Note on computation of integer square roots" for a proof of this bound.
23
23
// https://github.com/RustCrypto/crypto-bigint/files/12600669/ct_sqrt.pdf
24
24
let mut i = 0 ;
25
- while i < usize :: BITS - Self :: BITS . leading_zeros ( ) {
25
+ while i < Self :: LOG2_BITS {
26
26
guess = xn;
27
27
xn = {
28
28
let ( q, _, is_some) = self . const_div_rem ( & guess) ;
@@ -53,7 +53,7 @@ impl<const LIMBS: usize> Uint<LIMBS> {
53
53
// Note, xn <= guess at this point.
54
54
55
55
// Repeat while guess decreases.
56
- while Uint :: ct_gt ( & guess , & xn) . is_true_vartime ( ) && xn. ct_is_nonzero ( ) . is_true_vartime ( ) {
56
+ while guess . cmp_vartime ( & xn) . is_gt ( ) && ! xn. cmp_vartime ( & Self :: ZERO ) . is_eq ( ) {
57
57
guess = xn;
58
58
xn = {
59
59
let q = self . wrapping_div_vartime ( & guess) ;
@@ -62,7 +62,11 @@ impl<const LIMBS: usize> Uint<LIMBS> {
62
62
} ;
63
63
}
64
64
65
- Self :: ct_select ( & Self :: ZERO , & guess, self . ct_is_nonzero ( ) )
65
+ if self . ct_is_nonzero ( ) . is_true_vartime ( ) {
66
+ guess
67
+ } else {
68
+ Self :: ZERO
69
+ }
66
70
}
67
71
68
72
/// Wrapped sqrt is just normal √(`self`)
You can’t perform that action at this time.
0 commit comments