File tree Expand file tree Collapse file tree 2 files changed +5
-10
lines changed Expand file tree Collapse file tree 2 files changed +5
-10
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,9 @@ include "mux1.circom";
8
8
template MSB (n ) {
9
9
signal input in ;
10
10
signal output out;
11
+
12
+ // Ensure the input is less than 2^254 within the finite field for BN254.
13
+ assert(in < (2 ** 254 ));
11
14
12
15
// Convert the number to its bit representation.
13
16
var n2b[n];
Original file line number Diff line number Diff line change @@ -11,17 +11,9 @@ template SafeLessThan(n) {
11
11
signal input in [2 ];
12
12
signal output out;
13
13
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
-
22
14
// 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 ]);
25
17
26
18
// Determine if in[0] is less than in[1] based on the most significant bit.
27
19
out <== 1 - n2b[n];
You can’t perform that action at this time.
0 commit comments