Skip to content

Commit

Permalink
Rebase fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
tarcieri committed Dec 2, 2023
1 parent 681db1b commit 8b24d2e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/uint/div.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! [`Uint`] division operations.

use super::div_limb::{div_rem_limb_with_reciprocal, Reciprocal};
use crate::{CheckedDiv, CtChoice, Limb, NonZero, Uint, Wrapping};
use crate::{CheckedDiv, CtChoice, Limb, NonZero, Uint, Word, Wrapping};
use core::ops::{Div, DivAssign, Rem, RemAssign};
use subtle::CtOption;

Expand Down Expand Up @@ -58,16 +58,16 @@ impl<const LIMBS: usize> Uint<LIMBS> {
let mut done = CtChoice::FALSE;
loop {
let (mut r, borrow) = rem.sbb(&c, Limb::ZERO);
rem = Self::ct_select(&r, &rem, CtChoice::from_mask(borrow.0).or(done));
rem = Self::ct_select(&r, &rem, CtChoice::from_word_mask(borrow.0).or(done));
r = quo.bitor(&Self::ONE);
quo = Self::ct_select(&r, &quo, CtChoice::from_mask(borrow.0).or(done));
quo = Self::ct_select(&r, &quo, CtChoice::from_word_mask(borrow.0).or(done));
if i == 0 {
break;
}
i -= 1;
// when `i < mb`, the computation is actually done, so we ensure `quo` and `rem`
// aren't modified further (but do the remaining iterations anyway to be constant-time)
done = Limb::ct_lt(Limb(i as Word), Limb(mb as Word));
done = CtChoice::from_word_lt(i as Word, mb as Word);
c = c.shr_vartime(1);
quo = Self::ct_select(&quo.shl_vartime(1), &quo, done);
}
Expand Down
2 changes: 1 addition & 1 deletion src/uint/sqrt.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! [`Uint`] square root operations.

use super::Uint;
use crate::CtChoice;
use subtle::{ConstantTimeEq, CtOption};

impl<const LIMBS: usize> Uint<LIMBS> {
Expand All @@ -21,6 +20,7 @@ impl<const LIMBS: usize> Uint<LIMBS> {

// Repeat enough times to guarantee result has stabilized.
// See Hast, "Note on computation of integer square roots" for a proof of this bound.
// https://github.com/RustCrypto/crypto-bigint/files/12600669/ct_sqrt.pdf
let mut i = 0;
while i < usize::BITS - Self::BITS.leading_zeros() {
guess = xn;
Expand Down

0 comments on commit 8b24d2e

Please sign in to comment.