Skip to content

Commit

Permalink
Use ct_gt instead of gt
Browse files Browse the repository at this point in the history
  • Loading branch information
xuganyu96 committed Dec 18, 2023
1 parent ad95de0 commit 89816e7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
7 changes: 0 additions & 7 deletions src/uint/boxed/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ use subtle::{
};

impl BoxedUint {
/// Returns the truthy value if `self >= rhs` and the falsy value otherwise.
#[inline]
pub(crate) fn gt(lhs: &Self, rhs: &Self) -> ConstChoice {
let (_res, borrow) = rhs.sbb(lhs, Limb::ZERO);
ConstChoice::from_word_mask(borrow.0)
}

/// Returns the Ordering between `self` and `rhs` in variable time.
pub fn cmp_vartime(&self, rhs: &Self) -> Ordering {
debug_assert_eq!(self.limbs.len(), rhs.limbs.len());
Expand Down
4 changes: 2 additions & 2 deletions src/uint/boxed/sqrt.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! [`BoxedUint`] square root operations.

use subtle::{ConstantTimeEq, CtOption};
use subtle::{ConstantTimeEq, ConstantTimeGreater, CtOption};

use crate::{BoxedUint, NonZero};

Expand Down Expand Up @@ -48,7 +48,7 @@ impl BoxedUint {
// At this point `x_prev == x_{n}` and `x == x_{n+1}`
// where `n == i - 1 == LOG2_BITS + 1 == floor(log2(BITS)) + 1`.
// Thus, according to Hast, `sqrt(self) = min(x_n, x_{n+1})`.
Self::conditional_select(&x_prev, &x, Self::gt(&x_prev, &x).into())
Self::conditional_select(&x_prev, &x, Self::ct_gt(&x_prev, &x))
}

/// Computes √(`self`)
Expand Down

0 comments on commit 89816e7

Please sign in to comment.