Skip to content

Commit

Permalink
dirty fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Rumata888 committed Jul 12, 2024
1 parent 2f7e8ac commit 7dc34b0
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,14 @@ constexpr std::pair<uintx<base_uint>, uintx<base_uint>> uintx<base_uint>::barret
uintx remainder = x - qm_lo;

// because redc_parameter is an imperfect representation of 2^{2k} / n (might be too small),
// the computed quotient may be off by 1
if (remainder >= uintx(modulus)) {
// the computed quotient may be off by up to 3 (classic algorithm should be up to 1,
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1051): investigate, why)
size_t i = 0;
while (remainder >= uintx(modulus)) {
ASSERT(i < 3);
remainder = remainder - modulus;
quotient = quotient + 1;
i++;
}
return std::make_pair(quotient, remainder);
}
Expand Down

0 comments on commit 7dc34b0

Please sign in to comment.