Skip to content

Commit

Permalink
Remove start index check from SelectRegexReveal
Browse files Browse the repository at this point in the history
  • Loading branch information
SoraSuegami committed Aug 31, 2024
1 parent d6bd03f commit 6bb9af8
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 22 deletions.
18 changes: 0 additions & 18 deletions packages/circuits/tests/select-regex-reveal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,4 @@ describe("Select Regex Reveal", () => {
expect((error as Error).message).toMatch("Assert Failed");
}
});

it("should fail when startIndex is larger than max length", async function () {
let input = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
const startIndex = Math.floor(Math.random() * 24);
const revealed = Array.from("zk email").map(char => char.charCodeAt(0));
for (let i = 0; i < revealed.length; i++) {
input[startIndex + i] = revealed[i];
}
try {
const witness = await circuit.calculateWitness({
in: input,
startIndex: 32
});
await circuit.checkConstraints(witness);
} catch (error) {
expect((error as Error).message).toMatch("Assert Failed");
}
});
});
4 changes: 0 additions & 4 deletions packages/circuits/utils/regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ template SelectRegexReveal(maxArrayLen, maxRevealLen) {
signal isPreviousZero[maxArrayLen];
signal isAboveMaxRevealLen[maxArrayLen];

// Assert startIndex < maxArrayLen
signal isValidStartIndex <== LessThan(bitLength)([startIndex, maxArrayLen]);
isValidStartIndex === 1;

isPreviousZero[0] <== 1;
for(var i = 0; i < maxArrayLen; i++) {
isStartIndex[i] <== IsEqual()([i, startIndex]);
Expand Down

0 comments on commit 6bb9af8

Please sign in to comment.