From 6bb9af856b8b477ab67312b804374eb6a313e1b6 Mon Sep 17 00:00:00 2001 From: SoraSuegami Date: Sat, 31 Aug 2024 22:25:55 +0900 Subject: [PATCH] Remove start index check from SelectRegexReveal --- .../circuits/tests/select-regex-reveal.test.ts | 18 ------------------ packages/circuits/utils/regex.circom | 4 ---- 2 files changed, 22 deletions(-) diff --git a/packages/circuits/tests/select-regex-reveal.test.ts b/packages/circuits/tests/select-regex-reveal.test.ts index fdf55115..44d1c124 100644 --- a/packages/circuits/tests/select-regex-reveal.test.ts +++ b/packages/circuits/tests/select-regex-reveal.test.ts @@ -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"); - } - }); }); diff --git a/packages/circuits/utils/regex.circom b/packages/circuits/utils/regex.circom index dd7ef74b..1745a6f5 100644 --- a/packages/circuits/utils/regex.circom +++ b/packages/circuits/utils/regex.circom @@ -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]);