Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address circomspect warnings #11

Merged
merged 1 commit into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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