Skip to content

Commit

Permalink
Merge pull request #10 from ecnerwala/rangecheckmod
Browse files Browse the repository at this point in the history
BigMod incorrectly omits range checks on the remainder
  • Loading branch information
xu3kev authored Apr 27, 2022
2 parents 14ad152 + d3edd75 commit 08c2c90
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions circuits/bigint.circom
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,15 @@ template BigMod(n, k) {
mod[i] <-- longdiv[1][i];
}
div[k] <-- longdiv[0][k];
component range_checks[k + 1];
component div_range_checks[k + 1];
for (var i = 0; i <= k; i++) {
range_checks[i] = Num2Bits(n);
range_checks[i].in <== div[i];
div_range_checks[i] = Num2Bits(n);
div_range_checks[i].in <== div[i];
}
component mod_range_checks[k];
for (var i = 0; i < k; i++) {
mod_range_checks[i] = Num2Bits(n);
mod_range_checks[i].in <== mod[i];
}

component mul = BigMult(n, k + 1);
Expand Down

0 comments on commit 08c2c90

Please sign in to comment.