From 5aa9bfc60e1741cb5fb88bd33da61313dcec9b92 Mon Sep 17 00:00:00 2001 From: SoraSuegami Date: Mon, 30 Sep 2024 19:09:39 +0900 Subject: [PATCH] Remove space from invitation code --- .../circuits/src/regexes/invitation_code.json | 2 +- .../src/regexes/invitation_code_regex.circom | 88 +++++++------- .../regexes/invitation_code_with_prefix.json | 2 +- .../invitation_code_with_prefix_regex.circom | 111 +++++++++--------- .../tests/invitation_code_regex.test.ts | 54 +++++---- 5 files changed, 128 insertions(+), 129 deletions(-) diff --git a/packages/circuits/src/regexes/invitation_code.json b/packages/circuits/src/regexes/invitation_code.json index c5c5aca4..19e8b809 100644 --- a/packages/circuits/src/regexes/invitation_code.json +++ b/packages/circuits/src/regexes/invitation_code.json @@ -2,7 +2,7 @@ "parts": [ { "is_public": false, - "regex_def": "( )?(c|C)ode( )?" + "regex_def": "( )(c|C)ode( )?" }, { "is_public": true, diff --git a/packages/circuits/src/regexes/invitation_code_regex.circom b/packages/circuits/src/regexes/invitation_code_regex.circom index 973366f9..93f51a0b 100644 --- a/packages/circuits/src/regexes/invitation_code_regex.circom +++ b/packages/circuits/src/regexes/invitation_code_regex.circom @@ -2,7 +2,7 @@ pragma circom 2.1.5; include "@zk-email/zk-regex-circom/circuits/regex_helpers.circom"; -// regex: ( )?(c|C)ode( )?(0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f)+ +// regex: ( )(c|C)ode( )?(0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f)+ template InvitationCodeRegex(msg_bytes) { signal input msg[msg_bytes]; signal output out; @@ -15,7 +15,7 @@ template InvitationCodeRegex(msg_bytes) { } component eq[19][num_bytes]; - component and[10][num_bytes]; + component and[9][num_bytes]; component multi_or[3][num_bytes]; signal states[num_bytes+1][8]; signal states_tmp[num_bytes+1][8]; @@ -32,52 +32,49 @@ template InvitationCodeRegex(msg_bytes) { states[i][0] <== 1; eq[0][i] = IsEqual(); eq[0][i].in[0] <== in[i]; - eq[0][i].in[1] <== 67; - eq[1][i] = IsEqual(); - eq[1][i].in[0] <== in[i]; - eq[1][i].in[1] <== 99; + eq[0][i].in[1] <== 32; and[0][i] = AND(); and[0][i].a <== states[i][0]; - multi_or[0][i] = MultiOR(2); - multi_or[0][i].in[0] <== eq[0][i].out; - multi_or[0][i].in[1] <== eq[1][i].out; - and[0][i].b <== multi_or[0][i].out; - and[1][i] = AND(); - and[1][i].a <== states[i][2]; - and[1][i].b <== multi_or[0][i].out; - states_tmp[i+1][1] <== and[1][i].out; + and[0][i].b <== eq[0][i].out; + states_tmp[i+1][1] <== 0; + eq[1][i] = IsEqual(); + eq[1][i].in[0] <== in[i]; + eq[1][i].in[1] <== 67; eq[2][i] = IsEqual(); eq[2][i].in[0] <== in[i]; - eq[2][i].in[1] <== 32; - and[2][i] = AND(); - and[2][i].a <== states[i][0]; - and[2][i].b <== eq[2][i].out; - states_tmp[i+1][2] <== 0; + eq[2][i].in[1] <== 99; + and[1][i] = AND(); + and[1][i].a <== states[i][1]; + multi_or[0][i] = MultiOR(2); + multi_or[0][i].in[0] <== eq[1][i].out; + multi_or[0][i].in[1] <== eq[2][i].out; + and[1][i].b <== multi_or[0][i].out; + states[i+1][2] <== and[1][i].out; eq[3][i] = IsEqual(); eq[3][i].in[0] <== in[i]; eq[3][i].in[1] <== 111; - and[3][i] = AND(); - and[3][i].a <== states[i][1]; - and[3][i].b <== eq[3][i].out; - states[i+1][3] <== and[3][i].out; + and[2][i] = AND(); + and[2][i].a <== states[i][2]; + and[2][i].b <== eq[3][i].out; + states[i+1][3] <== and[2][i].out; eq[4][i] = IsEqual(); eq[4][i].in[0] <== in[i]; eq[4][i].in[1] <== 100; - and[4][i] = AND(); - and[4][i].a <== states[i][3]; - and[4][i].b <== eq[4][i].out; - states[i+1][4] <== and[4][i].out; + and[3][i] = AND(); + and[3][i].a <== states[i][3]; + and[3][i].b <== eq[4][i].out; + states[i+1][4] <== and[3][i].out; eq[5][i] = IsEqual(); eq[5][i].in[0] <== in[i]; eq[5][i].in[1] <== 101; + and[4][i] = AND(); + and[4][i].a <== states[i][4]; + and[4][i].b <== eq[5][i].out; + states[i+1][5] <== and[4][i].out; and[5][i] = AND(); - and[5][i].a <== states[i][4]; - and[5][i].b <== eq[5][i].out; - states[i+1][5] <== and[5][i].out; - and[6][i] = AND(); - and[6][i].a <== states[i][5]; - and[6][i].b <== eq[2][i].out; - states[i+1][6] <== and[6][i].out; + and[5][i].a <== states[i][5]; + and[5][i].b <== eq[0][i].out; + states[i+1][6] <== and[5][i].out; eq[6][i] = IsEqual(); eq[6][i].in[0] <== in[i]; eq[6][i].in[1] <== 48; @@ -117,8 +114,8 @@ template InvitationCodeRegex(msg_bytes) { eq[18][i] = IsEqual(); eq[18][i].in[0] <== in[i]; eq[18][i].in[1] <== 102; - and[7][i] = AND(); - and[7][i].a <== states[i][5]; + and[6][i] = AND(); + and[6][i].a <== states[i][5]; multi_or[1][i] = MultiOR(16); multi_or[1][i].in[0] <== eq[6][i].out; multi_or[1][i].in[1] <== eq[7][i].out; @@ -132,25 +129,24 @@ template InvitationCodeRegex(msg_bytes) { multi_or[1][i].in[9] <== eq[15][i].out; multi_or[1][i].in[10] <== eq[16][i].out; multi_or[1][i].in[11] <== eq[17][i].out; - multi_or[1][i].in[12] <== eq[1][i].out; + multi_or[1][i].in[12] <== eq[2][i].out; multi_or[1][i].in[13] <== eq[4][i].out; multi_or[1][i].in[14] <== eq[5][i].out; multi_or[1][i].in[15] <== eq[18][i].out; + and[6][i].b <== multi_or[1][i].out; + and[7][i] = AND(); + and[7][i].a <== states[i][6]; and[7][i].b <== multi_or[1][i].out; and[8][i] = AND(); - and[8][i].a <== states[i][6]; + and[8][i].a <== states[i][7]; and[8][i].b <== multi_or[1][i].out; - and[9][i] = AND(); - and[9][i].a <== states[i][7]; - and[9][i].b <== multi_or[1][i].out; multi_or[2][i] = MultiOR(3); - multi_or[2][i].in[0] <== and[7][i].out; - multi_or[2][i].in[1] <== and[8][i].out; - multi_or[2][i].in[2] <== and[9][i].out; + multi_or[2][i].in[0] <== and[6][i].out; + multi_or[2][i].in[1] <== and[7][i].out; + multi_or[2][i].in[2] <== and[8][i].out; states[i+1][7] <== multi_or[2][i].out; - from_zero_enabled[i] <== MultiNOR(7)([states_tmp[i+1][1], states_tmp[i+1][2], states[i+1][3], states[i+1][4], states[i+1][5], states[i+1][6], states[i+1][7]]); + from_zero_enabled[i] <== MultiNOR(7)([states_tmp[i+1][1], states[i+1][2], states[i+1][3], states[i+1][4], states[i+1][5], states[i+1][6], states[i+1][7]]); states[i+1][1] <== MultiOR(2)([states_tmp[i+1][1], from_zero_enabled[i] * and[0][i].out]); - states[i+1][2] <== MultiOR(2)([states_tmp[i+1][2], from_zero_enabled[i] * and[2][i].out]); state_changed[i].in[0] <== states[i+1][1]; state_changed[i].in[1] <== states[i+1][2]; state_changed[i].in[2] <== states[i+1][3]; diff --git a/packages/circuits/src/regexes/invitation_code_with_prefix.json b/packages/circuits/src/regexes/invitation_code_with_prefix.json index e92abb45..5782b86f 100644 --- a/packages/circuits/src/regexes/invitation_code_with_prefix.json +++ b/packages/circuits/src/regexes/invitation_code_with_prefix.json @@ -2,7 +2,7 @@ "parts": [ { "is_public": true, - "regex_def": "( )?(c|C)ode( )?(0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f)+" + "regex_def": "( )(c|C)ode( )?(0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f)+" } ] } \ No newline at end of file diff --git a/packages/circuits/src/regexes/invitation_code_with_prefix_regex.circom b/packages/circuits/src/regexes/invitation_code_with_prefix_regex.circom index 979a9a5e..bd7c85c4 100644 --- a/packages/circuits/src/regexes/invitation_code_with_prefix_regex.circom +++ b/packages/circuits/src/regexes/invitation_code_with_prefix_regex.circom @@ -2,7 +2,7 @@ pragma circom 2.1.5; include "@zk-email/zk-regex-circom/circuits/regex_helpers.circom"; -// regex: ( )?(c|C)ode( )?(0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f)+ +// regex: ( )(c|C)ode( )?(0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f)+ template InvitationCodeWithPrefixRegex(msg_bytes) { signal input msg[msg_bytes]; signal output out; @@ -15,7 +15,7 @@ template InvitationCodeWithPrefixRegex(msg_bytes) { } component eq[19][num_bytes]; - component and[10][num_bytes]; + component and[9][num_bytes]; component multi_or[3][num_bytes]; signal states[num_bytes+1][8]; signal states_tmp[num_bytes+1][8]; @@ -32,52 +32,49 @@ template InvitationCodeWithPrefixRegex(msg_bytes) { states[i][0] <== 1; eq[0][i] = IsEqual(); eq[0][i].in[0] <== in[i]; - eq[0][i].in[1] <== 67; - eq[1][i] = IsEqual(); - eq[1][i].in[0] <== in[i]; - eq[1][i].in[1] <== 99; + eq[0][i].in[1] <== 32; and[0][i] = AND(); and[0][i].a <== states[i][0]; - multi_or[0][i] = MultiOR(2); - multi_or[0][i].in[0] <== eq[0][i].out; - multi_or[0][i].in[1] <== eq[1][i].out; - and[0][i].b <== multi_or[0][i].out; - and[1][i] = AND(); - and[1][i].a <== states[i][2]; - and[1][i].b <== multi_or[0][i].out; - states_tmp[i+1][1] <== and[1][i].out; + and[0][i].b <== eq[0][i].out; + states_tmp[i+1][1] <== 0; + eq[1][i] = IsEqual(); + eq[1][i].in[0] <== in[i]; + eq[1][i].in[1] <== 67; eq[2][i] = IsEqual(); eq[2][i].in[0] <== in[i]; - eq[2][i].in[1] <== 32; - and[2][i] = AND(); - and[2][i].a <== states[i][0]; - and[2][i].b <== eq[2][i].out; - states_tmp[i+1][2] <== 0; + eq[2][i].in[1] <== 99; + and[1][i] = AND(); + and[1][i].a <== states[i][1]; + multi_or[0][i] = MultiOR(2); + multi_or[0][i].in[0] <== eq[1][i].out; + multi_or[0][i].in[1] <== eq[2][i].out; + and[1][i].b <== multi_or[0][i].out; + states[i+1][2] <== and[1][i].out; eq[3][i] = IsEqual(); eq[3][i].in[0] <== in[i]; eq[3][i].in[1] <== 111; - and[3][i] = AND(); - and[3][i].a <== states[i][1]; - and[3][i].b <== eq[3][i].out; - states[i+1][3] <== and[3][i].out; + and[2][i] = AND(); + and[2][i].a <== states[i][2]; + and[2][i].b <== eq[3][i].out; + states[i+1][3] <== and[2][i].out; eq[4][i] = IsEqual(); eq[4][i].in[0] <== in[i]; eq[4][i].in[1] <== 100; - and[4][i] = AND(); - and[4][i].a <== states[i][3]; - and[4][i].b <== eq[4][i].out; - states[i+1][4] <== and[4][i].out; + and[3][i] = AND(); + and[3][i].a <== states[i][3]; + and[3][i].b <== eq[4][i].out; + states[i+1][4] <== and[3][i].out; eq[5][i] = IsEqual(); eq[5][i].in[0] <== in[i]; eq[5][i].in[1] <== 101; + and[4][i] = AND(); + and[4][i].a <== states[i][4]; + and[4][i].b <== eq[5][i].out; + states[i+1][5] <== and[4][i].out; and[5][i] = AND(); - and[5][i].a <== states[i][4]; - and[5][i].b <== eq[5][i].out; - states[i+1][5] <== and[5][i].out; - and[6][i] = AND(); - and[6][i].a <== states[i][5]; - and[6][i].b <== eq[2][i].out; - states[i+1][6] <== and[6][i].out; + and[5][i].a <== states[i][5]; + and[5][i].b <== eq[0][i].out; + states[i+1][6] <== and[5][i].out; eq[6][i] = IsEqual(); eq[6][i].in[0] <== in[i]; eq[6][i].in[1] <== 48; @@ -117,8 +114,8 @@ template InvitationCodeWithPrefixRegex(msg_bytes) { eq[18][i] = IsEqual(); eq[18][i].in[0] <== in[i]; eq[18][i].in[1] <== 102; - and[7][i] = AND(); - and[7][i].a <== states[i][5]; + and[6][i] = AND(); + and[6][i].a <== states[i][5]; multi_or[1][i] = MultiOR(16); multi_or[1][i].in[0] <== eq[6][i].out; multi_or[1][i].in[1] <== eq[7][i].out; @@ -132,25 +129,24 @@ template InvitationCodeWithPrefixRegex(msg_bytes) { multi_or[1][i].in[9] <== eq[15][i].out; multi_or[1][i].in[10] <== eq[16][i].out; multi_or[1][i].in[11] <== eq[17][i].out; - multi_or[1][i].in[12] <== eq[1][i].out; + multi_or[1][i].in[12] <== eq[2][i].out; multi_or[1][i].in[13] <== eq[4][i].out; multi_or[1][i].in[14] <== eq[5][i].out; multi_or[1][i].in[15] <== eq[18][i].out; + and[6][i].b <== multi_or[1][i].out; + and[7][i] = AND(); + and[7][i].a <== states[i][6]; and[7][i].b <== multi_or[1][i].out; and[8][i] = AND(); - and[8][i].a <== states[i][6]; + and[8][i].a <== states[i][7]; and[8][i].b <== multi_or[1][i].out; - and[9][i] = AND(); - and[9][i].a <== states[i][7]; - and[9][i].b <== multi_or[1][i].out; multi_or[2][i] = MultiOR(3); - multi_or[2][i].in[0] <== and[7][i].out; - multi_or[2][i].in[1] <== and[8][i].out; - multi_or[2][i].in[2] <== and[9][i].out; + multi_or[2][i].in[0] <== and[6][i].out; + multi_or[2][i].in[1] <== and[7][i].out; + multi_or[2][i].in[2] <== and[8][i].out; states[i+1][7] <== multi_or[2][i].out; - from_zero_enabled[i] <== MultiNOR(7)([states_tmp[i+1][1], states_tmp[i+1][2], states[i+1][3], states[i+1][4], states[i+1][5], states[i+1][6], states[i+1][7]]); + from_zero_enabled[i] <== MultiNOR(7)([states_tmp[i+1][1], states[i+1][2], states[i+1][3], states[i+1][4], states[i+1][5], states[i+1][6], states[i+1][7]]); states[i+1][1] <== MultiOR(2)([states_tmp[i+1][1], from_zero_enabled[i] * and[0][i].out]); - states[i+1][2] <== MultiOR(2)([states_tmp[i+1][2], from_zero_enabled[i] * and[2][i].out]); state_changed[i].in[0] <== states[i+1][1]; state_changed[i].in[1] <== states[i+1][2]; state_changed[i].in[2] <== states[i+1][3]; @@ -172,24 +168,23 @@ template InvitationCodeWithPrefixRegex(msg_bytes) { is_consecutive[msg_bytes-1-i][1] <== state_changed[msg_bytes-i].out * is_consecutive[msg_bytes-1-i][0]; is_consecutive[msg_bytes-1-i][2] <== ORAnd()([(1 - from_zero_enabled[msg_bytes-i+1]), states[num_bytes-i][7], is_consecutive[msg_bytes-1-i][1]]); } - // substrings calculated: [{(0, 1), (0, 2), (1, 3), (2, 1), (3, 4), (4, 5), (5, 6), (5, 7), (6, 7), (7, 7)}] - signal prev_states0[10][msg_bytes]; + // substrings calculated: [{(0, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (5, 7), (6, 7), (7, 7)}] + signal prev_states0[9][msg_bytes]; signal is_substr0[msg_bytes]; signal is_reveal0[msg_bytes]; signal output reveal0[msg_bytes]; for (var i = 0; i < msg_bytes; i++) { - // the 0-th substring transitions: [(0, 1), (0, 2), (1, 3), (2, 1), (3, 4), (4, 5), (5, 6), (5, 7), (6, 7), (7, 7)] + // the 0-th substring transitions: [(0, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (5, 7), (6, 7), (7, 7)] prev_states0[0][i] <== from_zero_enabled[i+1] * states[i+1][0]; - prev_states0[1][i] <== from_zero_enabled[i+1] * states[i+1][0]; - prev_states0[2][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][1]; - prev_states0[3][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][2]; - prev_states0[4][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][3]; - prev_states0[5][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][4]; + prev_states0[1][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][1]; + prev_states0[2][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][2]; + prev_states0[3][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][3]; + prev_states0[4][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][4]; + prev_states0[5][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][5]; prev_states0[6][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][5]; - prev_states0[7][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][5]; - prev_states0[8][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][6]; - prev_states0[9][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][7]; - is_substr0[i] <== MultiOR(10)([prev_states0[0][i] * states[i+2][1], prev_states0[1][i] * states[i+2][2], prev_states0[2][i] * states[i+2][3], prev_states0[3][i] * states[i+2][1], prev_states0[4][i] * states[i+2][4], prev_states0[5][i] * states[i+2][5], prev_states0[6][i] * states[i+2][6], prev_states0[7][i] * states[i+2][7], prev_states0[8][i] * states[i+2][7], prev_states0[9][i] * states[i+2][7]]); + prev_states0[7][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][6]; + prev_states0[8][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][7]; + is_substr0[i] <== MultiOR(9)([prev_states0[0][i] * states[i+2][1], prev_states0[1][i] * states[i+2][2], prev_states0[2][i] * states[i+2][3], prev_states0[3][i] * states[i+2][4], prev_states0[4][i] * states[i+2][5], prev_states0[5][i] * states[i+2][6], prev_states0[6][i] * states[i+2][7], prev_states0[7][i] * states[i+2][7], prev_states0[8][i] * states[i+2][7]]); is_reveal0[i] <== MultiAND(3)([out, is_substr0[i], is_consecutive[i][2]]); reveal0[i] <== in[i+1] * is_reveal0[i]; } diff --git a/packages/circuits/tests/invitation_code_regex.test.ts b/packages/circuits/tests/invitation_code_regex.test.ts index 7cfbc089..3a4f9da2 100644 --- a/packages/circuits/tests/invitation_code_regex.test.ts +++ b/packages/circuits/tests/invitation_code_regex.test.ts @@ -10,7 +10,7 @@ const option = { jest.setTimeout(120000); describe("Invitation Code Regex", () => { it("invitation code", async () => { - const codeStr = "Code 123abc"; + const codeStr = " Code 123abc"; const paddedStr = relayerUtils.padString(codeStr, 256); const circuitInputs = { msg: paddedStr, @@ -94,8 +94,8 @@ describe("Invitation Code Regex", () => { } }); - it("invitation code in the email address", async () => { - const codeStr = "sepolia+code123456@sendeth.org"; + it("prefix + invitation code in the subject", async () => { + const codeStr = "Swap 0.1 ETH to DAI code 123abc"; const paddedStr = relayerUtils.padString(codeStr, 256); const circuitInputs = { msg: paddedStr, @@ -103,7 +103,7 @@ describe("Invitation Code Regex", () => { const circuit = await wasm_tester( path.join( __dirname, - "./circuits/test_invitation_code_regex.circom" + "./circuits/test_invitation_code_with_prefix_regex.circom" ), option ); @@ -111,7 +111,8 @@ describe("Invitation Code Regex", () => { await circuit.checkConstraints(witness); // console.log(witness); expect(1n).toEqual(witness[1]); - const prefixIdxes = relayerUtils.extractInvitationCodeIdxes(codeStr)[0]; + const prefixIdxes = + relayerUtils.extractInvitationCodeWithPrefixIdxes(codeStr)[0]; // const revealedStartIdx = emailWalletUtils.extractSubstrIdxes(codeStr, readFileSync(path.join(__dirname, "../src/regexes/invitation_code.json"), "utf8"))[0][0]; // console.log(emailWalletUtils.extractSubstrIdxes(codeStr, readFileSync(path.join(__dirname, "../src/regexes/invitation_code.json"), "utf8"))); for (let idx = 0; idx < 256; ++idx) { @@ -123,8 +124,9 @@ describe("Invitation Code Regex", () => { } }); - it("prefix + invitation code in the subject", async () => { - const codeStr = "Swap 0.1 ETH to DAI code 123abc"; + it("prefix + invitation code in the subject 2", async () => { + const codeStr = + "Re: Accept guardian request for 0x04884491560f38342C56E26BDD0fEAbb68E2d2FC Code 01eb9b204cc24c3baee11accc37d253a9c53e92b1a2cc07763475c135d575b76"; const paddedStr = relayerUtils.padString(codeStr, 256); const circuitInputs = { msg: paddedStr, @@ -153,9 +155,27 @@ describe("Invitation Code Regex", () => { } }); - it("prefix + invitation code in the subject 2", async () => { - const codeStr = - "Re: Accept guardian request for 0x04884491560f38342C56E26BDD0fEAbb68E2d2FC Code 01eb9b204cc24c3baee11accc37d253a9c53e92b1a2cc07763475c135d575b76"; + + it("invitation code in the email address should fail 1", async () => { + const codeStr = "sepolia+code123456@sendeth.org"; + const paddedStr = relayerUtils.padString(codeStr, 256); + const circuitInputs = { + msg: paddedStr, + }; + const circuit = await wasm_tester( + path.join( + __dirname, + "./circuits/test_invitation_code_regex.circom" + ), + option + ); + const witness = await circuit.calculateWitness(circuitInputs); + await circuit.checkConstraints(witness); + expect(0n).toEqual(witness[1]); + }); + + it("invitation code in the email address should fail 2", async () => { + const codeStr = "sepoliacode123456@sendeth.org"; const paddedStr = relayerUtils.padString(codeStr, 256); const circuitInputs = { msg: paddedStr, @@ -169,18 +189,6 @@ describe("Invitation Code Regex", () => { ); const witness = await circuit.calculateWitness(circuitInputs); await circuit.checkConstraints(witness); - // console.log(witness); - expect(1n).toEqual(witness[1]); - const prefixIdxes = - relayerUtils.extractInvitationCodeWithPrefixIdxes(codeStr)[0]; - // const revealedStartIdx = emailWalletUtils.extractSubstrIdxes(codeStr, readFileSync(path.join(__dirname, "../src/regexes/invitation_code.json"), "utf8"))[0][0]; - // console.log(emailWalletUtils.extractSubstrIdxes(codeStr, readFileSync(path.join(__dirname, "../src/regexes/invitation_code.json"), "utf8"))); - for (let idx = 0; idx < 256; ++idx) { - if (idx >= prefixIdxes[0] && idx < prefixIdxes[1]) { - expect(BigInt(paddedStr[idx])).toEqual(witness[2 + idx]); - } else { - expect(0n).toEqual(witness[2 + idx]); - } - } + expect(0n).toEqual(witness[1]); }); });