Skip to content

Commit

Permalink
fix: add assertions and strictness to supress warnings from circomspe…
Browse files Browse the repository at this point in the history
…ct (#11)
  • Loading branch information
0xjei authored Jul 14, 2024
1 parent e6eb2a4 commit 326cef9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
3 changes: 3 additions & 0 deletions packages/utils/src/float.circom
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ include "mux1.circom";
template MSB(n) {
signal input in;
signal output out;

// Ensure the input is less than 2^254 within the finite field for BN254.
assert(in < (2 ** 254));

// Convert the number to its bit representation.
var n2b[n];
Expand Down
12 changes: 2 additions & 10 deletions packages/utils/src/safe-comparators.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,9 @@ template SafeLessThan(n) {
signal input in[2];
signal output out;

// Convert both inputs to their bit representations to ensure
// they fit within 'n' bits.
var n2b1[n];
n2b1 = Num2Bits(n)(in[0]);

var n2b2[n];
n2b2 = Num2Bits(n)(in[1]);

// Additional conversion to handle arithmetic operation and capture the comparison result.
var n2b[n+1];
n2b = Num2Bits(n + 1)(in[0] + (1<<n) - in[1]);
var n2b[254];
n2b = Num2Bits_strict()(in[0] + (1<<n) - in[1]);

// Determine if in[0] is less than in[1] based on the most significant bit.
out <== 1 - n2b[n];
Expand Down

0 comments on commit 326cef9

Please sign in to comment.