Skip to content

Commit

Permalink
circuit: fix build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
saleel committed May 16, 2024
1 parent 36920c2 commit d667a1c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
8 changes: 4 additions & 4 deletions packages/circuits/email-verifier.circom
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ template EmailVerifier(maxHeadersLength, maxBodyLength, n, k, ignoreBodyHashChec


// Assert `emailHeaderLength` fits in `ceil(log2(maxHeadersLength))`
component n2b = Num2Bits(log2Ceil(maxHeadersLength));
n2b.in <== emailHeaderLength;
component n2bHeaderLength = Num2Bits(log2Ceil(maxHeadersLength));
n2bHeaderLength.in <== emailHeaderLength;


// Assert `emailHeader` data after `emailHeaderLength` are zeros
Expand Down Expand Up @@ -91,8 +91,8 @@ template EmailVerifier(maxHeadersLength, maxBodyLength, n, k, ignoreBodyHashChec


// Assert `emailBodyLength` fits in `ceil(log2(maxBodyLength))`
component n2b = Num2Bits(log2Ceil(maxBodyLength));
n2b.in <== emailBodyLength;
component n2bBodyLength = Num2Bits(log2Ceil(maxBodyLength));
n2bBodyLength.in <== emailBodyLength;


// Assert data after the body (`maxBodyLength - emailBody.length`) is all zeroes
Expand Down
6 changes: 3 additions & 3 deletions packages/circuits/lib/rsa.circom
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ include "./fp.circom";
/// @notice Verifies an RSA signature with exponent 65537.
/// @param n Number of bits per chunk the modulus is split into. Recommended to be 121.
/// @param k Number of chunks the modulus is split into. Recommended to be 17.
/// @input message[k] The message that was signed; assumes to consist of `k` chunks that fit in `n` bits (also contrained implicitly).
/// @input signature[k] The signature to verify; assumes to consist of `k` chunks that fit in `n` bits (also contrained implicitly).
/// @input modulus[k] The modulus of the RSA key (pubkey); assumes to consist of `k` chunks that fit in `n` bits (also contrained implicitly).
/// @input message[k] The message that was signed; assumes to consist of `k` chunks that fit in `n` bits (also constrained implicitly).
/// @input signature[k] The signature to verify; assumes to consist of `k` chunks that fit in `n` bits (also constrained implicitly).
/// @input modulus[k] The modulus of the RSA key (pubkey); assumes to consist of `k` chunks that fit in `n` bits (also constrained implicitly).
template RSAVerifier65537(n, k) {
signal input message[k];
signal input signature[k];
Expand Down
8 changes: 4 additions & 4 deletions packages/circuits/utils/array.circom
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ template ItemAtIndex(maxArrayLen) {

signal output out;

component calcTotal = CalculateTotal(maxArrayLen);
component eqs[maxArrayLen];
component calcTotalValue = CalculateTotal(maxArrayLen);
component calcTotalIndex = CalculateTotal(maxArrayLen);
component eqs[maxArrayLen];

// For each item, check whether its index equals the input index.
for (var i = 0; i < maxArrayLen; i ++) {
Expand All @@ -30,7 +30,7 @@ template ItemAtIndex(maxArrayLen) {
eqs[i].in[1] <== index;

// eqs[i].out is 1 if the index matches - so calcTotal is sum of 0s + 1 * valueAtIndex
calcTotal.nums[i] <== eqs[i].out * in[i];
calcTotalValue.nums[i] <== eqs[i].out * in[i];

// Take the sum of all eqs[i].out and assert that it is at most 1.
calcTotalIndex.nums[i] <== eqs[i].out;
Expand All @@ -39,7 +39,7 @@ template ItemAtIndex(maxArrayLen) {
// Assert that the sum of eqs[i].out is 1. This is to ensure the index passed is valid.
calcTotalIndex.sum === 1;

out <== calcTotal.sum;
out <== calcTotalValue.sum;
}


Expand Down
2 changes: 0 additions & 2 deletions packages/circuits/utils/bytes.circom
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ template DigitBytesToInt(n) {
signal sums[n+1];
sums[0] <== 0;

// TODO: Should we constrain the input ASCII to be between 48 and 57?

for(var i = 0; i < n; i++) {
sums[i + 1] <== 10 * sums[i] + (in[i] - 48);
}
Expand Down

0 comments on commit d667a1c

Please sign in to comment.