Skip to content

Commit

Permalink
fix(float.circom): add a*b overflow check
Browse files Browse the repository at this point in the history
add a*b overflow check in float.circom
  • Loading branch information
chaosma committed Sep 28, 2022
1 parent efd4617 commit c9a24ba
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion circuits/circom/float.circom
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,17 @@ template MultiplicationFromFloat(W, n) {
assert(10**W < 2**n);

component div = IntegerDivision(n);
// TODO: check a*b is not overflow

// not the best way, but works in our case
component lta = LessThan(252);
lta.in[0] <== a;
lta.in[1] <== 2 ** 126;
lta.out === 1;
component ltb = LessThan(252);
ltb.in[0] <== b;
ltb.in[1] <== 2 ** 126;
ltb.out === 1;

div.a <== a * b;
div.b <== 10**W;
c <== div.c;
Expand Down

0 comments on commit c9a24ba

Please sign in to comment.