Skip to content

Commit 326cef9

Browse files
authored
fix: add assertions and strictness to supress warnings from circomspect (#11)
1 parent e6eb2a4 commit 326cef9

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

packages/utils/src/float.circom

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ include "mux1.circom";
88
template MSB(n) {
99
signal input in;
1010
signal output out;
11+
12+
// Ensure the input is less than 2^254 within the finite field for BN254.
13+
assert(in < (2 ** 254));
1114

1215
// Convert the number to its bit representation.
1316
var n2b[n];

packages/utils/src/safe-comparators.circom

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,9 @@ template SafeLessThan(n) {
1111
signal input in[2];
1212
signal output out;
1313

14-
// Convert both inputs to their bit representations to ensure
15-
// they fit within 'n' bits.
16-
var n2b1[n];
17-
n2b1 = Num2Bits(n)(in[0]);
18-
19-
var n2b2[n];
20-
n2b2 = Num2Bits(n)(in[1]);
21-
2214
// Additional conversion to handle arithmetic operation and capture the comparison result.
23-
var n2b[n+1];
24-
n2b = Num2Bits(n + 1)(in[0] + (1<<n) - in[1]);
15+
var n2b[254];
16+
n2b = Num2Bits_strict()(in[0] + (1<<n) - in[1]);
2517

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

0 commit comments

Comments
 (0)