From 69eb7d0fd86b574cbb366c12a340271aac202013 Mon Sep 17 00:00:00 2001 From: SoraSuegami Date: Thu, 2 Nov 2023 13:13:06 +0900 Subject: [PATCH] Optimize the compiler by removing duplicated check --- .../circuits/common/body_hash_regex.circom | 895 +++++------ .../circuits/common/email_addr_regex.circom | 369 ++--- .../common/email_addr_with_name_regex.circom | 1363 +++++------------ .../circuits/common/email_domain_regex.circom | 369 ++--- .../circuits/common/from_all_regex.circom | 224 +-- .../circuits/common/message_id_regex.circom | 353 ++--- .../circuits/common/subject_all_regex.circom | 262 ++-- .../circuits/common/timestamp_regex.circom | 610 +++----- packages/circom/package.json | 2 +- .../tests/circuits/negate1_regex.circom | 67 +- .../circom/tests/circuits/simple_regex.circom | 48 +- packages/compiler/Cargo.toml | 2 +- packages/compiler/package.json | 2 +- packages/compiler/src/gen_circom.js | 55 +- 14 files changed, 1550 insertions(+), 3071 deletions(-) diff --git a/packages/circom/circuits/common/body_hash_regex.circom b/packages/circom/circuits/common/body_hash_regex.circom index 1576425..e841df5 100644 --- a/packages/circom/circuits/common/body_hash_regex.circom +++ b/packages/circom/circuits/common/body_hash_regex.circom @@ -13,9 +13,9 @@ template BodyHashRegex(msg_bytes) { in[i+1] <== msg[i]; } - component eq[90][num_bytes]; - component lt[34][num_bytes]; - component and[56][num_bytes]; + component eq[48][num_bytes]; + component lt[16][num_bytes]; + component and[47][num_bytes]; component multi_or[15][num_bytes]; signal states[num_bytes+1][28]; component state_changed[num_bytes]; @@ -57,679 +57,472 @@ template BodyHashRegex(msg_bytes) { multi_or[0][i].in[0] <== and[2][i].out; multi_or[0][i].in[1] <== eq[0][i].out; and[3][i].b <== multi_or[0][i].out; + and[4][i] = AND(); + and[4][i].a <== states[i][25]; + and[4][i].b <== and[0][i].out; lt[4][i] = LessEqThan(8); - lt[4][i].in[0] <== 97; + lt[4][i].in[0] <== 105; lt[4][i].in[1] <== in[i]; lt[5][i] = LessEqThan(8); lt[5][i].in[0] <== in[i]; lt[5][i].in[1] <== 122; - and[4][i] = AND(); - and[4][i].a <== lt[4][i].out; - and[4][i].b <== lt[5][i].out; and[5][i] = AND(); - and[5][i].a <== states[i][25]; - and[5][i].b <== and[4][i].out; - lt[6][i] = LessEqThan(8); - lt[6][i].in[0] <== 105; - lt[6][i].in[1] <== in[i]; - lt[7][i] = LessEqThan(8); - lt[7][i].in[0] <== in[i]; - lt[7][i].in[1] <== 122; - and[6][i] = AND(); - and[6][i].a <== lt[6][i].out; - and[6][i].b <== lt[7][i].out; + and[5][i].a <== lt[4][i].out; + and[5][i].b <== lt[5][i].out; eq[1][i] = IsEqual(); eq[1][i].in[0] <== in[i]; - eq[1][i].in[1] <== 97; + eq[1][i].in[1] <== 98; eq[2][i] = IsEqual(); eq[2][i].in[0] <== in[i]; - eq[2][i].in[1] <== 98; + eq[2][i].in[1] <== 99; eq[3][i] = IsEqual(); eq[3][i].in[0] <== in[i]; - eq[3][i].in[1] <== 99; + eq[3][i].in[1] <== 100; eq[4][i] = IsEqual(); eq[4][i].in[0] <== in[i]; - eq[4][i].in[1] <== 100; + eq[4][i].in[1] <== 101; eq[5][i] = IsEqual(); eq[5][i].in[0] <== in[i]; - eq[5][i].in[1] <== 101; + eq[5][i].in[1] <== 102; eq[6][i] = IsEqual(); eq[6][i].in[0] <== in[i]; - eq[6][i].in[1] <== 102; - eq[7][i] = IsEqual(); - eq[7][i].in[0] <== in[i]; - eq[7][i].in[1] <== 103; - and[7][i] = AND(); - and[7][i].a <== states[i][26]; + eq[6][i].in[1] <== 103; + and[6][i] = AND(); + and[6][i].a <== states[i][26]; multi_or[1][i] = MultiOR(8); - multi_or[1][i].in[0] <== and[6][i].out; - multi_or[1][i].in[1] <== eq[1][i].out; - multi_or[1][i].in[2] <== eq[2][i].out; - multi_or[1][i].in[3] <== eq[3][i].out; - multi_or[1][i].in[4] <== eq[4][i].out; - multi_or[1][i].in[5] <== eq[5][i].out; - multi_or[1][i].in[6] <== eq[6][i].out; - multi_or[1][i].in[7] <== eq[7][i].out; - and[7][i].b <== multi_or[1][i].out; - lt[8][i] = LessEqThan(8); - lt[8][i].in[0] <== 97; - lt[8][i].in[1] <== in[i]; - lt[9][i] = LessEqThan(8); - lt[9][i].in[0] <== in[i]; - lt[9][i].in[1] <== 122; - and[8][i] = AND(); - and[8][i].a <== lt[8][i].out; - and[8][i].b <== lt[9][i].out; - and[9][i] = AND(); - and[9][i].a <== states[i][27]; - and[9][i].b <== and[8][i].out; + multi_or[1][i].in[0] <== and[5][i].out; + multi_or[1][i].in[1] <== eq[0][i].out; + multi_or[1][i].in[2] <== eq[1][i].out; + multi_or[1][i].in[3] <== eq[2][i].out; + multi_or[1][i].in[4] <== eq[3][i].out; + multi_or[1][i].in[5] <== eq[4][i].out; + multi_or[1][i].in[6] <== eq[5][i].out; + multi_or[1][i].in[7] <== eq[6][i].out; + and[6][i].b <== multi_or[1][i].out; + and[7][i] = AND(); + and[7][i].a <== states[i][27]; + and[7][i].b <== and[0][i].out; multi_or[2][i] = MultiOR(5); multi_or[2][i].in[0] <== and[1][i].out; multi_or[2][i].in[1] <== and[3][i].out; - multi_or[2][i].in[2] <== and[5][i].out; - multi_or[2][i].in[3] <== and[7][i].out; - multi_or[2][i].in[4] <== and[9][i].out; + multi_or[2][i].in[2] <== and[4][i].out; + multi_or[2][i].in[3] <== and[6][i].out; + multi_or[2][i].in[4] <== and[7][i].out; states[i+1][1] <== multi_or[2][i].out; state_changed[i].in[0] <== states[i+1][1]; + lt[6][i] = LessEqThan(8); + lt[6][i].in[0] <== 0; + lt[6][i].in[1] <== in[i]; + lt[7][i] = LessEqThan(8); + lt[7][i].in[0] <== in[i]; + lt[7][i].in[1] <== 58; + and[8][i] = AND(); + and[8][i].a <== lt[6][i].out; + and[8][i].b <== lt[7][i].out; + lt[8][i] = LessEqThan(8); + lt[8][i].in[0] <== 60; + lt[8][i].in[1] <== in[i]; + lt[9][i] = LessEqThan(8); + lt[9][i].in[0] <== in[i]; + lt[9][i].in[1] <== 254; + and[9][i] = AND(); + and[9][i].a <== lt[8][i].out; + and[9][i].b <== lt[9][i].out; + and[10][i] = AND(); + and[10][i].a <== states[i][2]; + multi_or[3][i] = MultiOR(2); + multi_or[3][i].in[0] <== and[8][i].out; + multi_or[3][i].in[1] <== and[9][i].out; + and[10][i].b <== multi_or[3][i].out; lt[10][i] = LessEqThan(8); lt[10][i].in[0] <== 0; lt[10][i].in[1] <== in[i]; lt[11][i] = LessEqThan(8); lt[11][i].in[0] <== in[i]; - lt[11][i].in[1] <== 58; - and[10][i] = AND(); - and[10][i].a <== lt[10][i].out; - and[10][i].b <== lt[11][i].out; + lt[11][i].in[1] <== 42; + and[11][i] = AND(); + and[11][i].a <== lt[10][i].out; + and[11][i].b <== lt[11][i].out; lt[12][i] = LessEqThan(8); - lt[12][i].in[0] <== 60; + lt[12][i].in[0] <== 123; lt[12][i].in[1] <== in[i]; lt[13][i] = LessEqThan(8); lt[13][i].in[0] <== in[i]; lt[13][i].in[1] <== 254; - and[11][i] = AND(); - and[11][i].a <== lt[12][i].out; - and[11][i].b <== lt[13][i].out; and[12][i] = AND(); - and[12][i].a <== states[i][2]; - multi_or[3][i] = MultiOR(2); - multi_or[3][i].in[0] <== and[10][i].out; - multi_or[3][i].in[1] <== and[11][i].out; - and[12][i].b <== multi_or[3][i].out; - lt[14][i] = LessEqThan(8); - lt[14][i].in[0] <== 0; - lt[14][i].in[1] <== in[i]; - lt[15][i] = LessEqThan(8); - lt[15][i].in[0] <== in[i]; - lt[15][i].in[1] <== 42; - and[13][i] = AND(); - and[13][i].a <== lt[14][i].out; - and[13][i].b <== lt[15][i].out; - lt[16][i] = LessEqThan(8); - lt[16][i].in[0] <== 123; - lt[16][i].in[1] <== in[i]; - lt[17][i] = LessEqThan(8); - lt[17][i].in[0] <== in[i]; - lt[17][i].in[1] <== 254; - and[14][i] = AND(); - and[14][i].a <== lt[16][i].out; - and[14][i].b <== lt[17][i].out; + and[12][i].a <== lt[12][i].out; + and[12][i].b <== lt[13][i].out; + eq[7][i] = IsEqual(); + eq[7][i].in[0] <== in[i]; + eq[7][i].in[1] <== 44; eq[8][i] = IsEqual(); eq[8][i].in[0] <== in[i]; - eq[8][i].in[1] <== 44; + eq[8][i].in[1] <== 45; eq[9][i] = IsEqual(); eq[9][i].in[0] <== in[i]; - eq[9][i].in[1] <== 45; + eq[9][i].in[1] <== 46; eq[10][i] = IsEqual(); eq[10][i].in[0] <== in[i]; - eq[10][i].in[1] <== 46; + eq[10][i].in[1] <== 58; eq[11][i] = IsEqual(); eq[11][i].in[0] <== in[i]; - eq[11][i].in[1] <== 58; + eq[11][i].in[1] <== 60; eq[12][i] = IsEqual(); eq[12][i].in[0] <== in[i]; - eq[12][i].in[1] <== 60; + eq[12][i].in[1] <== 62; eq[13][i] = IsEqual(); eq[13][i].in[0] <== in[i]; - eq[13][i].in[1] <== 62; + eq[13][i].in[1] <== 63; eq[14][i] = IsEqual(); eq[14][i].in[0] <== in[i]; - eq[14][i].in[1] <== 63; + eq[14][i].in[1] <== 64; eq[15][i] = IsEqual(); eq[15][i].in[0] <== in[i]; - eq[15][i].in[1] <== 64; + eq[15][i].in[1] <== 91; eq[16][i] = IsEqual(); eq[16][i].in[0] <== in[i]; - eq[16][i].in[1] <== 91; + eq[16][i].in[1] <== 92; eq[17][i] = IsEqual(); eq[17][i].in[0] <== in[i]; - eq[17][i].in[1] <== 92; + eq[17][i].in[1] <== 93; eq[18][i] = IsEqual(); eq[18][i].in[0] <== in[i]; - eq[18][i].in[1] <== 93; + eq[18][i].in[1] <== 94; eq[19][i] = IsEqual(); eq[19][i].in[0] <== in[i]; - eq[19][i].in[1] <== 94; + eq[19][i].in[1] <== 95; eq[20][i] = IsEqual(); eq[20][i].in[0] <== in[i]; - eq[20][i].in[1] <== 95; + eq[20][i].in[1] <== 96; + and[13][i] = AND(); + and[13][i].a <== states[i][3]; + multi_or[4][i] = MultiOR(16); + multi_or[4][i].in[0] <== and[11][i].out; + multi_or[4][i].in[1] <== and[12][i].out; + multi_or[4][i].in[2] <== eq[7][i].out; + multi_or[4][i].in[3] <== eq[8][i].out; + multi_or[4][i].in[4] <== eq[9][i].out; + multi_or[4][i].in[5] <== eq[10][i].out; + multi_or[4][i].in[6] <== eq[11][i].out; + multi_or[4][i].in[7] <== eq[12][i].out; + multi_or[4][i].in[8] <== eq[13][i].out; + multi_or[4][i].in[9] <== eq[14][i].out; + multi_or[4][i].in[10] <== eq[15][i].out; + multi_or[4][i].in[11] <== eq[16][i].out; + multi_or[4][i].in[12] <== eq[17][i].out; + multi_or[4][i].in[13] <== eq[18][i].out; + multi_or[4][i].in[14] <== eq[19][i].out; + multi_or[4][i].in[15] <== eq[20][i].out; + and[13][i].b <== multi_or[4][i].out; + and[14][i] = AND(); + and[14][i].a <== states[i][5]; + multi_or[5][i] = MultiOR(16); + multi_or[5][i].in[0] <== and[11][i].out; + multi_or[5][i].in[1] <== and[12][i].out; + multi_or[5][i].in[2] <== eq[7][i].out; + multi_or[5][i].in[3] <== eq[8][i].out; + multi_or[5][i].in[4] <== eq[9][i].out; + multi_or[5][i].in[5] <== eq[10][i].out; + multi_or[5][i].in[6] <== eq[11][i].out; + multi_or[5][i].in[7] <== eq[12][i].out; + multi_or[5][i].in[8] <== eq[13][i].out; + multi_or[5][i].in[9] <== eq[14][i].out; + multi_or[5][i].in[10] <== eq[15][i].out; + multi_or[5][i].in[11] <== eq[16][i].out; + multi_or[5][i].in[12] <== eq[17][i].out; + multi_or[5][i].in[13] <== eq[18][i].out; + multi_or[5][i].in[14] <== eq[19][i].out; + multi_or[5][i].in[15] <== eq[20][i].out; + and[14][i].b <== multi_or[5][i].out; + and[15][i] = AND(); + and[15][i].a <== states[i][6]; + multi_or[6][i] = MultiOR(2); + multi_or[6][i].in[0] <== and[8][i].out; + multi_or[6][i].in[1] <== and[9][i].out; + and[15][i].b <== multi_or[6][i].out; + multi_or[7][i] = MultiOR(4); + multi_or[7][i].in[0] <== and[10][i].out; + multi_or[7][i].in[1] <== and[13][i].out; + multi_or[7][i].in[2] <== and[14][i].out; + multi_or[7][i].in[3] <== and[15][i].out; + states[i+1][2] <== multi_or[7][i].out; + state_changed[i].in[1] <== states[i+1][2]; eq[21][i] = IsEqual(); eq[21][i].in[0] <== in[i]; - eq[21][i].in[1] <== 96; - and[15][i] = AND(); - and[15][i].a <== states[i][3]; - multi_or[4][i] = MultiOR(16); - multi_or[4][i].in[0] <== and[13][i].out; - multi_or[4][i].in[1] <== and[14][i].out; - multi_or[4][i].in[2] <== eq[8][i].out; - multi_or[4][i].in[3] <== eq[9][i].out; - multi_or[4][i].in[4] <== eq[10][i].out; - multi_or[4][i].in[5] <== eq[11][i].out; - multi_or[4][i].in[6] <== eq[12][i].out; - multi_or[4][i].in[7] <== eq[13][i].out; - multi_or[4][i].in[8] <== eq[14][i].out; - multi_or[4][i].in[9] <== eq[15][i].out; - multi_or[4][i].in[10] <== eq[16][i].out; - multi_or[4][i].in[11] <== eq[17][i].out; - multi_or[4][i].in[12] <== eq[18][i].out; - multi_or[4][i].in[13] <== eq[19][i].out; - multi_or[4][i].in[14] <== eq[20][i].out; - multi_or[4][i].in[15] <== eq[21][i].out; - and[15][i].b <== multi_or[4][i].out; - lt[18][i] = LessEqThan(8); - lt[18][i].in[0] <== 0; - lt[18][i].in[1] <== in[i]; - lt[19][i] = LessEqThan(8); - lt[19][i].in[0] <== in[i]; - lt[19][i].in[1] <== 42; + eq[21][i].in[1] <== 61; and[16][i] = AND(); - and[16][i].a <== lt[18][i].out; - and[16][i].b <== lt[19][i].out; - lt[20][i] = LessEqThan(8); - lt[20][i].in[0] <== 123; - lt[20][i].in[1] <== in[i]; - lt[21][i] = LessEqThan(8); - lt[21][i].in[0] <== in[i]; - lt[21][i].in[1] <== 254; - and[17][i] = AND(); - and[17][i].a <== lt[20][i].out; - and[17][i].b <== lt[21][i].out; + and[16][i].a <== states[i][27]; + and[16][i].b <== eq[21][i].out; + states[i+1][3] <== and[16][i].out; + state_changed[i].in[2] <== states[i+1][3]; eq[22][i] = IsEqual(); eq[22][i].in[0] <== in[i]; - eq[22][i].in[1] <== 44; + eq[22][i].in[1] <== 59; + and[17][i] = AND(); + and[17][i].a <== states[i][2]; + and[17][i].b <== eq[22][i].out; + states[i+1][4] <== and[17][i].out; + state_changed[i].in[3] <== states[i+1][4]; + lt[14][i] = LessEqThan(8); + lt[14][i].in[0] <== 65; + lt[14][i].in[1] <== in[i]; + lt[15][i] = LessEqThan(8); + lt[15][i].in[0] <== in[i]; + lt[15][i].in[1] <== 90; + and[18][i] = AND(); + and[18][i].a <== lt[14][i].out; + and[18][i].b <== lt[15][i].out; eq[23][i] = IsEqual(); eq[23][i].in[0] <== in[i]; - eq[23][i].in[1] <== 45; + eq[23][i].in[1] <== 43; eq[24][i] = IsEqual(); eq[24][i].in[0] <== in[i]; - eq[24][i].in[1] <== 46; + eq[24][i].in[1] <== 47; eq[25][i] = IsEqual(); eq[25][i].in[0] <== in[i]; - eq[25][i].in[1] <== 58; + eq[25][i].in[1] <== 48; eq[26][i] = IsEqual(); eq[26][i].in[0] <== in[i]; - eq[26][i].in[1] <== 60; + eq[26][i].in[1] <== 49; eq[27][i] = IsEqual(); eq[27][i].in[0] <== in[i]; - eq[27][i].in[1] <== 62; + eq[27][i].in[1] <== 50; eq[28][i] = IsEqual(); eq[28][i].in[0] <== in[i]; - eq[28][i].in[1] <== 63; + eq[28][i].in[1] <== 51; eq[29][i] = IsEqual(); eq[29][i].in[0] <== in[i]; - eq[29][i].in[1] <== 64; + eq[29][i].in[1] <== 52; eq[30][i] = IsEqual(); eq[30][i].in[0] <== in[i]; - eq[30][i].in[1] <== 91; + eq[30][i].in[1] <== 53; eq[31][i] = IsEqual(); eq[31][i].in[0] <== in[i]; - eq[31][i].in[1] <== 92; + eq[31][i].in[1] <== 54; eq[32][i] = IsEqual(); eq[32][i].in[0] <== in[i]; - eq[32][i].in[1] <== 93; + eq[32][i].in[1] <== 55; eq[33][i] = IsEqual(); eq[33][i].in[0] <== in[i]; - eq[33][i].in[1] <== 94; + eq[33][i].in[1] <== 56; eq[34][i] = IsEqual(); eq[34][i].in[0] <== in[i]; - eq[34][i].in[1] <== 95; - eq[35][i] = IsEqual(); - eq[35][i].in[0] <== in[i]; - eq[35][i].in[1] <== 96; - and[18][i] = AND(); - and[18][i].a <== states[i][5]; - multi_or[5][i] = MultiOR(16); - multi_or[5][i].in[0] <== and[16][i].out; - multi_or[5][i].in[1] <== and[17][i].out; - multi_or[5][i].in[2] <== eq[22][i].out; - multi_or[5][i].in[3] <== eq[23][i].out; - multi_or[5][i].in[4] <== eq[24][i].out; - multi_or[5][i].in[5] <== eq[25][i].out; - multi_or[5][i].in[6] <== eq[26][i].out; - multi_or[5][i].in[7] <== eq[27][i].out; - multi_or[5][i].in[8] <== eq[28][i].out; - multi_or[5][i].in[9] <== eq[29][i].out; - multi_or[5][i].in[10] <== eq[30][i].out; - multi_or[5][i].in[11] <== eq[31][i].out; - multi_or[5][i].in[12] <== eq[32][i].out; - multi_or[5][i].in[13] <== eq[33][i].out; - multi_or[5][i].in[14] <== eq[34][i].out; - multi_or[5][i].in[15] <== eq[35][i].out; - and[18][i].b <== multi_or[5][i].out; - lt[22][i] = LessEqThan(8); - lt[22][i].in[0] <== 0; - lt[22][i].in[1] <== in[i]; - lt[23][i] = LessEqThan(8); - lt[23][i].in[0] <== in[i]; - lt[23][i].in[1] <== 58; + eq[34][i].in[1] <== 57; and[19][i] = AND(); - and[19][i].a <== lt[22][i].out; - and[19][i].b <== lt[23][i].out; - lt[24][i] = LessEqThan(8); - lt[24][i].in[0] <== 60; - lt[24][i].in[1] <== in[i]; - lt[25][i] = LessEqThan(8); - lt[25][i].in[0] <== in[i]; - lt[25][i].in[1] <== 254; - and[20][i] = AND(); - and[20][i].a <== lt[24][i].out; - and[20][i].b <== lt[25][i].out; - and[21][i] = AND(); - and[21][i].a <== states[i][6]; - multi_or[6][i] = MultiOR(2); - multi_or[6][i].in[0] <== and[19][i].out; - multi_or[6][i].in[1] <== and[20][i].out; - and[21][i].b <== multi_or[6][i].out; - multi_or[7][i] = MultiOR(4); - multi_or[7][i].in[0] <== and[12][i].out; - multi_or[7][i].in[1] <== and[15][i].out; - multi_or[7][i].in[2] <== and[18][i].out; - multi_or[7][i].in[3] <== and[21][i].out; - states[i+1][2] <== multi_or[7][i].out; - state_changed[i].in[1] <== states[i+1][2]; - eq[36][i] = IsEqual(); - eq[36][i].in[0] <== in[i]; - eq[36][i].in[1] <== 61; - and[22][i] = AND(); - and[22][i].a <== states[i][27]; - and[22][i].b <== eq[36][i].out; - states[i+1][3] <== and[22][i].out; - state_changed[i].in[2] <== states[i+1][3]; - eq[37][i] = IsEqual(); - eq[37][i].in[0] <== in[i]; - eq[37][i].in[1] <== 59; - and[23][i] = AND(); - and[23][i].a <== states[i][2]; - and[23][i].b <== eq[37][i].out; - states[i+1][4] <== and[23][i].out; - state_changed[i].in[3] <== states[i+1][4]; - lt[26][i] = LessEqThan(8); - lt[26][i].in[0] <== 65; - lt[26][i].in[1] <== in[i]; - lt[27][i] = LessEqThan(8); - lt[27][i].in[0] <== in[i]; - lt[27][i].in[1] <== 90; - and[24][i] = AND(); - and[24][i].a <== lt[26][i].out; - and[24][i].b <== lt[27][i].out; - lt[28][i] = LessEqThan(8); - lt[28][i].in[0] <== 97; - lt[28][i].in[1] <== in[i]; - lt[29][i] = LessEqThan(8); - lt[29][i].in[0] <== in[i]; - lt[29][i].in[1] <== 122; - and[25][i] = AND(); - and[25][i].a <== lt[28][i].out; - and[25][i].b <== lt[29][i].out; - eq[38][i] = IsEqual(); - eq[38][i].in[0] <== in[i]; - eq[38][i].in[1] <== 43; - eq[39][i] = IsEqual(); - eq[39][i].in[0] <== in[i]; - eq[39][i].in[1] <== 47; - eq[40][i] = IsEqual(); - eq[40][i].in[0] <== in[i]; - eq[40][i].in[1] <== 48; - eq[41][i] = IsEqual(); - eq[41][i].in[0] <== in[i]; - eq[41][i].in[1] <== 49; - eq[42][i] = IsEqual(); - eq[42][i].in[0] <== in[i]; - eq[42][i].in[1] <== 50; - eq[43][i] = IsEqual(); - eq[43][i].in[0] <== in[i]; - eq[43][i].in[1] <== 51; - eq[44][i] = IsEqual(); - eq[44][i].in[0] <== in[i]; - eq[44][i].in[1] <== 52; - eq[45][i] = IsEqual(); - eq[45][i].in[0] <== in[i]; - eq[45][i].in[1] <== 53; - eq[46][i] = IsEqual(); - eq[46][i].in[0] <== in[i]; - eq[46][i].in[1] <== 54; - eq[47][i] = IsEqual(); - eq[47][i].in[0] <== in[i]; - eq[47][i].in[1] <== 55; - eq[48][i] = IsEqual(); - eq[48][i].in[0] <== in[i]; - eq[48][i].in[1] <== 56; - eq[49][i] = IsEqual(); - eq[49][i].in[0] <== in[i]; - eq[49][i].in[1] <== 57; - eq[50][i] = IsEqual(); - eq[50][i].in[0] <== in[i]; - eq[50][i].in[1] <== 61; - and[26][i] = AND(); - and[26][i].a <== states[i][3]; + and[19][i].a <== states[i][3]; multi_or[8][i] = MultiOR(15); - multi_or[8][i].in[0] <== and[24][i].out; - multi_or[8][i].in[1] <== and[25][i].out; - multi_or[8][i].in[2] <== eq[38][i].out; - multi_or[8][i].in[3] <== eq[39][i].out; - multi_or[8][i].in[4] <== eq[40][i].out; - multi_or[8][i].in[5] <== eq[41][i].out; - multi_or[8][i].in[6] <== eq[42][i].out; - multi_or[8][i].in[7] <== eq[43][i].out; - multi_or[8][i].in[8] <== eq[44][i].out; - multi_or[8][i].in[9] <== eq[45][i].out; - multi_or[8][i].in[10] <== eq[46][i].out; - multi_or[8][i].in[11] <== eq[47][i].out; - multi_or[8][i].in[12] <== eq[48][i].out; - multi_or[8][i].in[13] <== eq[49][i].out; - multi_or[8][i].in[14] <== eq[50][i].out; - and[26][i].b <== multi_or[8][i].out; - lt[30][i] = LessEqThan(8); - lt[30][i].in[0] <== 65; - lt[30][i].in[1] <== in[i]; - lt[31][i] = LessEqThan(8); - lt[31][i].in[0] <== in[i]; - lt[31][i].in[1] <== 90; - and[27][i] = AND(); - and[27][i].a <== lt[30][i].out; - and[27][i].b <== lt[31][i].out; - lt[32][i] = LessEqThan(8); - lt[32][i].in[0] <== 97; - lt[32][i].in[1] <== in[i]; - lt[33][i] = LessEqThan(8); - lt[33][i].in[0] <== in[i]; - lt[33][i].in[1] <== 122; - and[28][i] = AND(); - and[28][i].a <== lt[32][i].out; - and[28][i].b <== lt[33][i].out; - eq[51][i] = IsEqual(); - eq[51][i].in[0] <== in[i]; - eq[51][i].in[1] <== 43; - eq[52][i] = IsEqual(); - eq[52][i].in[0] <== in[i]; - eq[52][i].in[1] <== 47; - eq[53][i] = IsEqual(); - eq[53][i].in[0] <== in[i]; - eq[53][i].in[1] <== 48; - eq[54][i] = IsEqual(); - eq[54][i].in[0] <== in[i]; - eq[54][i].in[1] <== 49; - eq[55][i] = IsEqual(); - eq[55][i].in[0] <== in[i]; - eq[55][i].in[1] <== 50; - eq[56][i] = IsEqual(); - eq[56][i].in[0] <== in[i]; - eq[56][i].in[1] <== 51; - eq[57][i] = IsEqual(); - eq[57][i].in[0] <== in[i]; - eq[57][i].in[1] <== 52; - eq[58][i] = IsEqual(); - eq[58][i].in[0] <== in[i]; - eq[58][i].in[1] <== 53; - eq[59][i] = IsEqual(); - eq[59][i].in[0] <== in[i]; - eq[59][i].in[1] <== 54; - eq[60][i] = IsEqual(); - eq[60][i].in[0] <== in[i]; - eq[60][i].in[1] <== 55; - eq[61][i] = IsEqual(); - eq[61][i].in[0] <== in[i]; - eq[61][i].in[1] <== 56; - eq[62][i] = IsEqual(); - eq[62][i].in[0] <== in[i]; - eq[62][i].in[1] <== 57; - eq[63][i] = IsEqual(); - eq[63][i].in[0] <== in[i]; - eq[63][i].in[1] <== 61; - and[29][i] = AND(); - and[29][i].a <== states[i][5]; + multi_or[8][i].in[0] <== and[18][i].out; + multi_or[8][i].in[1] <== and[0][i].out; + multi_or[8][i].in[2] <== eq[23][i].out; + multi_or[8][i].in[3] <== eq[24][i].out; + multi_or[8][i].in[4] <== eq[25][i].out; + multi_or[8][i].in[5] <== eq[26][i].out; + multi_or[8][i].in[6] <== eq[27][i].out; + multi_or[8][i].in[7] <== eq[28][i].out; + multi_or[8][i].in[8] <== eq[29][i].out; + multi_or[8][i].in[9] <== eq[30][i].out; + multi_or[8][i].in[10] <== eq[31][i].out; + multi_or[8][i].in[11] <== eq[32][i].out; + multi_or[8][i].in[12] <== eq[33][i].out; + multi_or[8][i].in[13] <== eq[34][i].out; + multi_or[8][i].in[14] <== eq[21][i].out; + and[19][i].b <== multi_or[8][i].out; + and[20][i] = AND(); + and[20][i].a <== states[i][5]; multi_or[9][i] = MultiOR(15); - multi_or[9][i].in[0] <== and[27][i].out; - multi_or[9][i].in[1] <== and[28][i].out; - multi_or[9][i].in[2] <== eq[51][i].out; - multi_or[9][i].in[3] <== eq[52][i].out; - multi_or[9][i].in[4] <== eq[53][i].out; - multi_or[9][i].in[5] <== eq[54][i].out; - multi_or[9][i].in[6] <== eq[55][i].out; - multi_or[9][i].in[7] <== eq[56][i].out; - multi_or[9][i].in[8] <== eq[57][i].out; - multi_or[9][i].in[9] <== eq[58][i].out; - multi_or[9][i].in[10] <== eq[59][i].out; - multi_or[9][i].in[11] <== eq[60][i].out; - multi_or[9][i].in[12] <== eq[61][i].out; - multi_or[9][i].in[13] <== eq[62][i].out; - multi_or[9][i].in[14] <== eq[63][i].out; - and[29][i].b <== multi_or[9][i].out; + multi_or[9][i].in[0] <== and[18][i].out; + multi_or[9][i].in[1] <== and[0][i].out; + multi_or[9][i].in[2] <== eq[23][i].out; + multi_or[9][i].in[3] <== eq[24][i].out; + multi_or[9][i].in[4] <== eq[25][i].out; + multi_or[9][i].in[5] <== eq[26][i].out; + multi_or[9][i].in[6] <== eq[27][i].out; + multi_or[9][i].in[7] <== eq[28][i].out; + multi_or[9][i].in[8] <== eq[29][i].out; + multi_or[9][i].in[9] <== eq[30][i].out; + multi_or[9][i].in[10] <== eq[31][i].out; + multi_or[9][i].in[11] <== eq[32][i].out; + multi_or[9][i].in[12] <== eq[33][i].out; + multi_or[9][i].in[13] <== eq[34][i].out; + multi_or[9][i].in[14] <== eq[21][i].out; + and[20][i].b <== multi_or[9][i].out; multi_or[10][i] = MultiOR(2); - multi_or[10][i].in[0] <== and[26][i].out; - multi_or[10][i].in[1] <== and[29][i].out; + multi_or[10][i].in[0] <== and[19][i].out; + multi_or[10][i].in[1] <== and[20][i].out; states[i+1][5] <== multi_or[10][i].out; state_changed[i].in[4] <== states[i+1][5]; - eq[64][i] = IsEqual(); - eq[64][i].in[0] <== in[i]; - eq[64][i].in[1] <== 61; - and[30][i] = AND(); - and[30][i].a <== states[i][1]; - and[30][i].b <== eq[64][i].out; - eq[65][i] = IsEqual(); - eq[65][i].in[0] <== in[i]; - eq[65][i].in[1] <== 61; - and[31][i] = AND(); - and[31][i].a <== states[i][26]; - and[31][i].b <== eq[65][i].out; + and[21][i] = AND(); + and[21][i].a <== states[i][1]; + and[21][i].b <== eq[21][i].out; + and[22][i] = AND(); + and[22][i].a <== states[i][26]; + and[22][i].b <== eq[21][i].out; multi_or[11][i] = MultiOR(2); - multi_or[11][i].in[0] <== and[30][i].out; - multi_or[11][i].in[1] <== and[31][i].out; + multi_or[11][i].in[0] <== and[21][i].out; + multi_or[11][i].in[1] <== and[22][i].out; states[i+1][6] <== multi_or[11][i].out; state_changed[i].in[5] <== states[i+1][6]; - eq[66][i] = IsEqual(); - eq[66][i].in[0] <== in[i]; - eq[66][i].in[1] <== 32; - and[32][i] = AND(); - and[32][i].a <== states[i][4]; - and[32][i].b <== eq[66][i].out; - eq[67][i] = IsEqual(); - eq[67][i].in[0] <== in[i]; - eq[67][i].in[1] <== 32; - and[33][i] = AND(); - and[33][i].a <== states[i][8]; - and[33][i].b <== eq[67][i].out; + eq[35][i] = IsEqual(); + eq[35][i].in[0] <== in[i]; + eq[35][i].in[1] <== 32; + and[23][i] = AND(); + and[23][i].a <== states[i][4]; + and[23][i].b <== eq[35][i].out; + and[24][i] = AND(); + and[24][i].a <== states[i][8]; + and[24][i].b <== eq[35][i].out; multi_or[12][i] = MultiOR(2); - multi_or[12][i].in[0] <== and[32][i].out; - multi_or[12][i].in[1] <== and[33][i].out; + multi_or[12][i].in[0] <== and[23][i].out; + multi_or[12][i].in[1] <== and[24][i].out; states[i+1][7] <== multi_or[12][i].out; state_changed[i].in[6] <== states[i+1][7]; - eq[68][i] = IsEqual(); - eq[68][i].in[0] <== in[i]; - eq[68][i].in[1] <== 59; - and[34][i] = AND(); - and[34][i].a <== states[i][5]; - and[34][i].b <== eq[68][i].out; - states[i+1][8] <== and[34][i].out; + and[25][i] = AND(); + and[25][i].a <== states[i][5]; + and[25][i].b <== eq[22][i].out; + states[i+1][8] <== and[25][i].out; state_changed[i].in[7] <== states[i+1][8]; - eq[69][i] = IsEqual(); - eq[69][i].in[0] <== in[i]; - eq[69][i].in[1] <== 13; - and[35][i] = AND(); - and[35][i].a <== states[i][0]; - and[35][i].b <== eq[69][i].out; - eq[70][i] = IsEqual(); - eq[70][i].in[0] <== in[i]; - eq[70][i].in[1] <== 13; - and[36][i] = AND(); - and[36][i].a <== states[i][10]; - and[36][i].b <== eq[70][i].out; + eq[36][i] = IsEqual(); + eq[36][i].in[0] <== in[i]; + eq[36][i].in[1] <== 13; + and[26][i] = AND(); + and[26][i].a <== states[i][0]; + and[26][i].b <== eq[36][i].out; + and[27][i] = AND(); + and[27][i].a <== states[i][10]; + and[27][i].b <== eq[36][i].out; multi_or[13][i] = MultiOR(2); - multi_or[13][i].in[0] <== and[35][i].out; - multi_or[13][i].in[1] <== and[36][i].out; + multi_or[13][i].in[0] <== and[26][i].out; + multi_or[13][i].in[1] <== and[27][i].out; states[i+1][9] <== multi_or[13][i].out; state_changed[i].in[8] <== states[i+1][9]; - eq[71][i] = IsEqual(); - eq[71][i].in[0] <== in[i]; - eq[71][i].in[1] <== 255; - and[37][i] = AND(); - and[37][i].a <== states[i][0]; - and[37][i].b <== eq[71][i].out; - eq[72][i] = IsEqual(); - eq[72][i].in[0] <== in[i]; - eq[72][i].in[1] <== 10; - and[38][i] = AND(); - and[38][i].a <== states[i][9]; - and[38][i].b <== eq[72][i].out; + eq[37][i] = IsEqual(); + eq[37][i].in[0] <== in[i]; + eq[37][i].in[1] <== 255; + and[28][i] = AND(); + and[28][i].a <== states[i][0]; + and[28][i].b <== eq[37][i].out; + eq[38][i] = IsEqual(); + eq[38][i].in[0] <== in[i]; + eq[38][i].in[1] <== 10; + and[29][i] = AND(); + and[29][i].a <== states[i][9]; + and[29][i].b <== eq[38][i].out; multi_or[14][i] = MultiOR(2); - multi_or[14][i].in[0] <== and[37][i].out; - multi_or[14][i].in[1] <== and[38][i].out; + multi_or[14][i].in[0] <== and[28][i].out; + multi_or[14][i].in[1] <== and[29][i].out; states[i+1][10] <== multi_or[14][i].out; state_changed[i].in[9] <== states[i+1][10]; - eq[73][i] = IsEqual(); - eq[73][i].in[0] <== in[i]; - eq[73][i].in[1] <== 100; - and[39][i] = AND(); - and[39][i].a <== states[i][10]; - and[39][i].b <== eq[73][i].out; - states[i+1][11] <== and[39][i].out; + and[30][i] = AND(); + and[30][i].a <== states[i][10]; + and[30][i].b <== eq[3][i].out; + states[i+1][11] <== and[30][i].out; state_changed[i].in[10] <== states[i+1][11]; - eq[74][i] = IsEqual(); - eq[74][i].in[0] <== in[i]; - eq[74][i].in[1] <== 107; - and[40][i] = AND(); - and[40][i].a <== states[i][11]; - and[40][i].b <== eq[74][i].out; - states[i+1][12] <== and[40][i].out; + eq[39][i] = IsEqual(); + eq[39][i].in[0] <== in[i]; + eq[39][i].in[1] <== 107; + and[31][i] = AND(); + and[31][i].a <== states[i][11]; + and[31][i].b <== eq[39][i].out; + states[i+1][12] <== and[31][i].out; state_changed[i].in[11] <== states[i+1][12]; - eq[75][i] = IsEqual(); - eq[75][i].in[0] <== in[i]; - eq[75][i].in[1] <== 105; - and[41][i] = AND(); - and[41][i].a <== states[i][12]; - and[41][i].b <== eq[75][i].out; - states[i+1][13] <== and[41][i].out; + eq[40][i] = IsEqual(); + eq[40][i].in[0] <== in[i]; + eq[40][i].in[1] <== 105; + and[32][i] = AND(); + and[32][i].a <== states[i][12]; + and[32][i].b <== eq[40][i].out; + states[i+1][13] <== and[32][i].out; state_changed[i].in[12] <== states[i+1][13]; - eq[76][i] = IsEqual(); - eq[76][i].in[0] <== in[i]; - eq[76][i].in[1] <== 109; - and[42][i] = AND(); - and[42][i].a <== states[i][13]; - and[42][i].b <== eq[76][i].out; - states[i+1][14] <== and[42][i].out; + eq[41][i] = IsEqual(); + eq[41][i].in[0] <== in[i]; + eq[41][i].in[1] <== 109; + and[33][i] = AND(); + and[33][i].a <== states[i][13]; + and[33][i].b <== eq[41][i].out; + states[i+1][14] <== and[33][i].out; state_changed[i].in[13] <== states[i+1][14]; - eq[77][i] = IsEqual(); - eq[77][i].in[0] <== in[i]; - eq[77][i].in[1] <== 45; - and[43][i] = AND(); - and[43][i].a <== states[i][14]; - and[43][i].b <== eq[77][i].out; - states[i+1][15] <== and[43][i].out; + and[34][i] = AND(); + and[34][i].a <== states[i][14]; + and[34][i].b <== eq[8][i].out; + states[i+1][15] <== and[34][i].out; state_changed[i].in[14] <== states[i+1][15]; - eq[78][i] = IsEqual(); - eq[78][i].in[0] <== in[i]; - eq[78][i].in[1] <== 115; - and[44][i] = AND(); - and[44][i].a <== states[i][15]; - and[44][i].b <== eq[78][i].out; - states[i+1][16] <== and[44][i].out; + eq[42][i] = IsEqual(); + eq[42][i].in[0] <== in[i]; + eq[42][i].in[1] <== 115; + and[35][i] = AND(); + and[35][i].a <== states[i][15]; + and[35][i].b <== eq[42][i].out; + states[i+1][16] <== and[35][i].out; state_changed[i].in[15] <== states[i+1][16]; - eq[79][i] = IsEqual(); - eq[79][i].in[0] <== in[i]; - eq[79][i].in[1] <== 105; - and[45][i] = AND(); - and[45][i].a <== states[i][16]; - and[45][i].b <== eq[79][i].out; - states[i+1][17] <== and[45][i].out; + and[36][i] = AND(); + and[36][i].a <== states[i][16]; + and[36][i].b <== eq[40][i].out; + states[i+1][17] <== and[36][i].out; state_changed[i].in[16] <== states[i+1][17]; - eq[80][i] = IsEqual(); - eq[80][i].in[0] <== in[i]; - eq[80][i].in[1] <== 103; - and[46][i] = AND(); - and[46][i].a <== states[i][17]; - and[46][i].b <== eq[80][i].out; - states[i+1][18] <== and[46][i].out; + and[37][i] = AND(); + and[37][i].a <== states[i][17]; + and[37][i].b <== eq[6][i].out; + states[i+1][18] <== and[37][i].out; state_changed[i].in[17] <== states[i+1][18]; - eq[81][i] = IsEqual(); - eq[81][i].in[0] <== in[i]; - eq[81][i].in[1] <== 110; - and[47][i] = AND(); - and[47][i].a <== states[i][18]; - and[47][i].b <== eq[81][i].out; - states[i+1][19] <== and[47][i].out; + eq[43][i] = IsEqual(); + eq[43][i].in[0] <== in[i]; + eq[43][i].in[1] <== 110; + and[38][i] = AND(); + and[38][i].a <== states[i][18]; + and[38][i].b <== eq[43][i].out; + states[i+1][19] <== and[38][i].out; state_changed[i].in[18] <== states[i+1][19]; - eq[82][i] = IsEqual(); - eq[82][i].in[0] <== in[i]; - eq[82][i].in[1] <== 97; - and[48][i] = AND(); - and[48][i].a <== states[i][19]; - and[48][i].b <== eq[82][i].out; - states[i+1][20] <== and[48][i].out; + and[39][i] = AND(); + and[39][i].a <== states[i][19]; + and[39][i].b <== eq[0][i].out; + states[i+1][20] <== and[39][i].out; state_changed[i].in[19] <== states[i+1][20]; - eq[83][i] = IsEqual(); - eq[83][i].in[0] <== in[i]; - eq[83][i].in[1] <== 116; - and[49][i] = AND(); - and[49][i].a <== states[i][20]; - and[49][i].b <== eq[83][i].out; - states[i+1][21] <== and[49][i].out; + eq[44][i] = IsEqual(); + eq[44][i].in[0] <== in[i]; + eq[44][i].in[1] <== 116; + and[40][i] = AND(); + and[40][i].a <== states[i][20]; + and[40][i].b <== eq[44][i].out; + states[i+1][21] <== and[40][i].out; state_changed[i].in[20] <== states[i+1][21]; - eq[84][i] = IsEqual(); - eq[84][i].in[0] <== in[i]; - eq[84][i].in[1] <== 117; - and[50][i] = AND(); - and[50][i].a <== states[i][21]; - and[50][i].b <== eq[84][i].out; - states[i+1][22] <== and[50][i].out; + eq[45][i] = IsEqual(); + eq[45][i].in[0] <== in[i]; + eq[45][i].in[1] <== 117; + and[41][i] = AND(); + and[41][i].a <== states[i][21]; + and[41][i].b <== eq[45][i].out; + states[i+1][22] <== and[41][i].out; state_changed[i].in[21] <== states[i+1][22]; - eq[85][i] = IsEqual(); - eq[85][i].in[0] <== in[i]; - eq[85][i].in[1] <== 114; - and[51][i] = AND(); - and[51][i].a <== states[i][22]; - and[51][i].b <== eq[85][i].out; - states[i+1][23] <== and[51][i].out; + eq[46][i] = IsEqual(); + eq[46][i].in[0] <== in[i]; + eq[46][i].in[1] <== 114; + and[42][i] = AND(); + and[42][i].a <== states[i][22]; + and[42][i].b <== eq[46][i].out; + states[i+1][23] <== and[42][i].out; state_changed[i].in[22] <== states[i+1][23]; - eq[86][i] = IsEqual(); - eq[86][i].in[0] <== in[i]; - eq[86][i].in[1] <== 101; - and[52][i] = AND(); - and[52][i].a <== states[i][23]; - and[52][i].b <== eq[86][i].out; - states[i+1][24] <== and[52][i].out; + and[43][i] = AND(); + and[43][i].a <== states[i][23]; + and[43][i].b <== eq[4][i].out; + states[i+1][24] <== and[43][i].out; state_changed[i].in[23] <== states[i+1][24]; - eq[87][i] = IsEqual(); - eq[87][i].in[0] <== in[i]; - eq[87][i].in[1] <== 58; - and[53][i] = AND(); - and[53][i].a <== states[i][24]; - and[53][i].b <== eq[87][i].out; - states[i+1][25] <== and[53][i].out; + and[44][i] = AND(); + and[44][i].a <== states[i][24]; + and[44][i].b <== eq[10][i].out; + states[i+1][25] <== and[44][i].out; state_changed[i].in[24] <== states[i+1][25]; - eq[88][i] = IsEqual(); - eq[88][i].in[0] <== in[i]; - eq[88][i].in[1] <== 98; - and[54][i] = AND(); - and[54][i].a <== states[i][7]; - and[54][i].b <== eq[88][i].out; - states[i+1][26] <== and[54][i].out; + and[45][i] = AND(); + and[45][i].a <== states[i][7]; + and[45][i].b <== eq[1][i].out; + states[i+1][26] <== and[45][i].out; state_changed[i].in[25] <== states[i+1][26]; - eq[89][i] = IsEqual(); - eq[89][i].in[0] <== in[i]; - eq[89][i].in[1] <== 104; - and[55][i] = AND(); - and[55][i].a <== states[i][26]; - and[55][i].b <== eq[89][i].out; - states[i+1][27] <== and[55][i].out; + eq[47][i] = IsEqual(); + eq[47][i].in[0] <== in[i]; + eq[47][i].in[1] <== 104; + and[46][i] = AND(); + and[46][i].a <== states[i][26]; + and[46][i].b <== eq[47][i].out; + states[i+1][27] <== and[46][i].out; state_changed[i].in[26] <== states[i+1][27]; states[i+1][0] <== 1 - state_changed[i].out; } diff --git a/packages/circom/circuits/common/email_addr_regex.circom b/packages/circom/circuits/common/email_addr_regex.circom index 8a35b5a..d7cd1c1 100644 --- a/packages/circom/circuits/common/email_addr_regex.circom +++ b/packages/circom/circuits/common/email_addr_regex.circom @@ -13,9 +13,9 @@ template EmailAddrRegex(msg_bytes) { in[i+1] <== msg[i]; } - component eq[72][num_bytes]; - component lt[20][num_bytes]; - component and[15][num_bytes]; + component eq[25][num_bytes]; + component lt[8][num_bytes]; + component and[9][num_bytes]; component multi_or[6][num_bytes]; signal states[num_bytes+1][4]; component state_changed[num_bytes]; @@ -148,301 +148,106 @@ template EmailAddrRegex(msg_bytes) { multi_or[0][i].in[25] <== eq[23][i].out; and[2][i].b <== multi_or[0][i].out; lt[4][i] = LessEqThan(8); - lt[4][i].in[0] <== 65; + lt[4][i].in[0] <== 94; lt[4][i].in[1] <== in[i]; lt[5][i] = LessEqThan(8); lt[5][i].in[0] <== in[i]; - lt[5][i].in[1] <== 90; + lt[5][i].in[1] <== 126; and[3][i] = AND(); and[3][i].a <== lt[4][i].out; and[3][i].b <== lt[5][i].out; - lt[6][i] = LessEqThan(8); - lt[6][i].in[0] <== 94; - lt[6][i].in[1] <== in[i]; - lt[7][i] = LessEqThan(8); - lt[7][i].in[0] <== in[i]; - lt[7][i].in[1] <== 126; and[4][i] = AND(); - and[4][i].a <== lt[6][i].out; - and[4][i].b <== lt[7][i].out; - lt[8][i] = LessEqThan(8); - lt[8][i].in[0] <== 65; - lt[8][i].in[1] <== in[i]; - lt[9][i] = LessEqThan(8); - lt[9][i].in[0] <== in[i]; - lt[9][i].in[1] <== 90; - and[5][i] = AND(); - and[5][i].a <== lt[8][i].out; - and[5][i].b <== lt[9][i].out; - lt[10][i] = LessEqThan(8); - lt[10][i].in[0] <== 95; - lt[10][i].in[1] <== in[i]; - lt[11][i] = LessEqThan(8); - lt[11][i].in[0] <== in[i]; - lt[11][i].in[1] <== 126; - and[6][i] = AND(); - and[6][i].a <== lt[10][i].out; - and[6][i].b <== lt[11][i].out; - eq[24][i] = IsEqual(); - eq[24][i].in[0] <== in[i]; - eq[24][i].in[1] <== 33; - eq[25][i] = IsEqual(); - eq[25][i].in[0] <== in[i]; - eq[25][i].in[1] <== 35; - eq[26][i] = IsEqual(); - eq[26][i].in[0] <== in[i]; - eq[26][i].in[1] <== 36; - eq[27][i] = IsEqual(); - eq[27][i].in[0] <== in[i]; - eq[27][i].in[1] <== 37; - eq[28][i] = IsEqual(); - eq[28][i].in[0] <== in[i]; - eq[28][i].in[1] <== 38; - eq[29][i] = IsEqual(); - eq[29][i].in[0] <== in[i]; - eq[29][i].in[1] <== 39; - eq[30][i] = IsEqual(); - eq[30][i].in[0] <== in[i]; - eq[30][i].in[1] <== 42; - eq[31][i] = IsEqual(); - eq[31][i].in[0] <== in[i]; - eq[31][i].in[1] <== 43; - eq[32][i] = IsEqual(); - eq[32][i].in[0] <== in[i]; - eq[32][i].in[1] <== 45; - eq[33][i] = IsEqual(); - eq[33][i].in[0] <== in[i]; - eq[33][i].in[1] <== 46; - eq[34][i] = IsEqual(); - eq[34][i].in[0] <== in[i]; - eq[34][i].in[1] <== 47; - eq[35][i] = IsEqual(); - eq[35][i].in[0] <== in[i]; - eq[35][i].in[1] <== 48; - eq[36][i] = IsEqual(); - eq[36][i].in[0] <== in[i]; - eq[36][i].in[1] <== 49; - eq[37][i] = IsEqual(); - eq[37][i].in[0] <== in[i]; - eq[37][i].in[1] <== 50; - eq[38][i] = IsEqual(); - eq[38][i].in[0] <== in[i]; - eq[38][i].in[1] <== 51; - eq[39][i] = IsEqual(); - eq[39][i].in[0] <== in[i]; - eq[39][i].in[1] <== 52; - eq[40][i] = IsEqual(); - eq[40][i].in[0] <== in[i]; - eq[40][i].in[1] <== 53; - eq[41][i] = IsEqual(); - eq[41][i].in[0] <== in[i]; - eq[41][i].in[1] <== 54; - eq[42][i] = IsEqual(); - eq[42][i].in[0] <== in[i]; - eq[42][i].in[1] <== 55; - eq[43][i] = IsEqual(); - eq[43][i].in[0] <== in[i]; - eq[43][i].in[1] <== 56; - eq[44][i] = IsEqual(); - eq[44][i].in[0] <== in[i]; - eq[44][i].in[1] <== 57; - eq[45][i] = IsEqual(); - eq[45][i].in[0] <== in[i]; - eq[45][i].in[1] <== 61; - eq[46][i] = IsEqual(); - eq[46][i].in[0] <== in[i]; - eq[46][i].in[1] <== 63; - and[7][i] = AND(); - and[7][i].a <== states[i][1]; + and[4][i].a <== states[i][1]; multi_or[1][i] = MultiOR(27); - multi_or[1][i].in[0] <== and[3][i].out; - multi_or[1][i].in[1] <== and[4][i].out; - multi_or[1][i].in[2] <== and[5][i].out; - multi_or[1][i].in[3] <== and[6][i].out; - multi_or[1][i].in[4] <== eq[24][i].out; - multi_or[1][i].in[5] <== eq[25][i].out; - multi_or[1][i].in[6] <== eq[26][i].out; - multi_or[1][i].in[7] <== eq[27][i].out; - multi_or[1][i].in[8] <== eq[28][i].out; - multi_or[1][i].in[9] <== eq[29][i].out; - multi_or[1][i].in[10] <== eq[30][i].out; - multi_or[1][i].in[11] <== eq[31][i].out; - multi_or[1][i].in[12] <== eq[32][i].out; - multi_or[1][i].in[13] <== eq[33][i].out; - multi_or[1][i].in[14] <== eq[34][i].out; - multi_or[1][i].in[15] <== eq[35][i].out; - multi_or[1][i].in[16] <== eq[36][i].out; - multi_or[1][i].in[17] <== eq[37][i].out; - multi_or[1][i].in[18] <== eq[38][i].out; - multi_or[1][i].in[19] <== eq[39][i].out; - multi_or[1][i].in[20] <== eq[40][i].out; - multi_or[1][i].in[21] <== eq[41][i].out; - multi_or[1][i].in[22] <== eq[42][i].out; - multi_or[1][i].in[23] <== eq[43][i].out; - multi_or[1][i].in[24] <== eq[44][i].out; - multi_or[1][i].in[25] <== eq[45][i].out; - multi_or[1][i].in[26] <== eq[46][i].out; - and[7][i].b <== multi_or[1][i].out; + multi_or[1][i].in[0] <== and[0][i].out; + multi_or[1][i].in[1] <== and[3][i].out; + multi_or[1][i].in[2] <== and[0][i].out; + multi_or[1][i].in[3] <== and[1][i].out; + multi_or[1][i].in[4] <== eq[0][i].out; + multi_or[1][i].in[5] <== eq[1][i].out; + multi_or[1][i].in[6] <== eq[2][i].out; + multi_or[1][i].in[7] <== eq[3][i].out; + multi_or[1][i].in[8] <== eq[4][i].out; + multi_or[1][i].in[9] <== eq[5][i].out; + multi_or[1][i].in[10] <== eq[6][i].out; + multi_or[1][i].in[11] <== eq[7][i].out; + multi_or[1][i].in[12] <== eq[8][i].out; + multi_or[1][i].in[13] <== eq[9][i].out; + multi_or[1][i].in[14] <== eq[10][i].out; + multi_or[1][i].in[15] <== eq[11][i].out; + multi_or[1][i].in[16] <== eq[12][i].out; + multi_or[1][i].in[17] <== eq[13][i].out; + multi_or[1][i].in[18] <== eq[14][i].out; + multi_or[1][i].in[19] <== eq[15][i].out; + multi_or[1][i].in[20] <== eq[16][i].out; + multi_or[1][i].in[21] <== eq[17][i].out; + multi_or[1][i].in[22] <== eq[18][i].out; + multi_or[1][i].in[23] <== eq[19][i].out; + multi_or[1][i].in[24] <== eq[20][i].out; + multi_or[1][i].in[25] <== eq[21][i].out; + multi_or[1][i].in[26] <== eq[22][i].out; + and[4][i].b <== multi_or[1][i].out; multi_or[2][i] = MultiOR(2); multi_or[2][i].in[0] <== and[2][i].out; - multi_or[2][i].in[1] <== and[7][i].out; + multi_or[2][i].in[1] <== and[4][i].out; states[i+1][1] <== multi_or[2][i].out; state_changed[i].in[0] <== states[i+1][1]; - eq[47][i] = IsEqual(); - eq[47][i].in[0] <== in[i]; - eq[47][i].in[1] <== 64; - and[8][i] = AND(); - and[8][i].a <== states[i][1]; - and[8][i].b <== eq[47][i].out; - states[i+1][2] <== and[8][i].out; + eq[24][i] = IsEqual(); + eq[24][i].in[0] <== in[i]; + eq[24][i].in[1] <== 64; + and[5][i] = AND(); + and[5][i].a <== states[i][1]; + and[5][i].b <== eq[24][i].out; + states[i+1][2] <== and[5][i].out; state_changed[i].in[1] <== states[i+1][2]; - lt[12][i] = LessEqThan(8); - lt[12][i].in[0] <== 65; - lt[12][i].in[1] <== in[i]; - lt[13][i] = LessEqThan(8); - lt[13][i].in[0] <== in[i]; - lt[13][i].in[1] <== 90; - and[9][i] = AND(); - and[9][i].a <== lt[12][i].out; - and[9][i].b <== lt[13][i].out; - lt[14][i] = LessEqThan(8); - lt[14][i].in[0] <== 97; - lt[14][i].in[1] <== in[i]; - lt[15][i] = LessEqThan(8); - lt[15][i].in[0] <== in[i]; - lt[15][i].in[1] <== 122; - and[10][i] = AND(); - and[10][i].a <== lt[14][i].out; - and[10][i].b <== lt[15][i].out; - eq[48][i] = IsEqual(); - eq[48][i].in[0] <== in[i]; - eq[48][i].in[1] <== 45; - eq[49][i] = IsEqual(); - eq[49][i].in[0] <== in[i]; - eq[49][i].in[1] <== 46; - eq[50][i] = IsEqual(); - eq[50][i].in[0] <== in[i]; - eq[50][i].in[1] <== 48; - eq[51][i] = IsEqual(); - eq[51][i].in[0] <== in[i]; - eq[51][i].in[1] <== 49; - eq[52][i] = IsEqual(); - eq[52][i].in[0] <== in[i]; - eq[52][i].in[1] <== 50; - eq[53][i] = IsEqual(); - eq[53][i].in[0] <== in[i]; - eq[53][i].in[1] <== 51; - eq[54][i] = IsEqual(); - eq[54][i].in[0] <== in[i]; - eq[54][i].in[1] <== 52; - eq[55][i] = IsEqual(); - eq[55][i].in[0] <== in[i]; - eq[55][i].in[1] <== 53; - eq[56][i] = IsEqual(); - eq[56][i].in[0] <== in[i]; - eq[56][i].in[1] <== 54; - eq[57][i] = IsEqual(); - eq[57][i].in[0] <== in[i]; - eq[57][i].in[1] <== 55; - eq[58][i] = IsEqual(); - eq[58][i].in[0] <== in[i]; - eq[58][i].in[1] <== 56; - eq[59][i] = IsEqual(); - eq[59][i].in[0] <== in[i]; - eq[59][i].in[1] <== 57; - and[11][i] = AND(); - and[11][i].a <== states[i][2]; + lt[6][i] = LessEqThan(8); + lt[6][i].in[0] <== 97; + lt[6][i].in[1] <== in[i]; + lt[7][i] = LessEqThan(8); + lt[7][i].in[0] <== in[i]; + lt[7][i].in[1] <== 122; + and[6][i] = AND(); + and[6][i].a <== lt[6][i].out; + and[6][i].b <== lt[7][i].out; + and[7][i] = AND(); + and[7][i].a <== states[i][2]; multi_or[3][i] = MultiOR(14); - multi_or[3][i].in[0] <== and[9][i].out; - multi_or[3][i].in[1] <== and[10][i].out; - multi_or[3][i].in[2] <== eq[48][i].out; - multi_or[3][i].in[3] <== eq[49][i].out; - multi_or[3][i].in[4] <== eq[50][i].out; - multi_or[3][i].in[5] <== eq[51][i].out; - multi_or[3][i].in[6] <== eq[52][i].out; - multi_or[3][i].in[7] <== eq[53][i].out; - multi_or[3][i].in[8] <== eq[54][i].out; - multi_or[3][i].in[9] <== eq[55][i].out; - multi_or[3][i].in[10] <== eq[56][i].out; - multi_or[3][i].in[11] <== eq[57][i].out; - multi_or[3][i].in[12] <== eq[58][i].out; - multi_or[3][i].in[13] <== eq[59][i].out; - and[11][i].b <== multi_or[3][i].out; - lt[16][i] = LessEqThan(8); - lt[16][i].in[0] <== 65; - lt[16][i].in[1] <== in[i]; - lt[17][i] = LessEqThan(8); - lt[17][i].in[0] <== in[i]; - lt[17][i].in[1] <== 90; - and[12][i] = AND(); - and[12][i].a <== lt[16][i].out; - and[12][i].b <== lt[17][i].out; - lt[18][i] = LessEqThan(8); - lt[18][i].in[0] <== 97; - lt[18][i].in[1] <== in[i]; - lt[19][i] = LessEqThan(8); - lt[19][i].in[0] <== in[i]; - lt[19][i].in[1] <== 122; - and[13][i] = AND(); - and[13][i].a <== lt[18][i].out; - and[13][i].b <== lt[19][i].out; - eq[60][i] = IsEqual(); - eq[60][i].in[0] <== in[i]; - eq[60][i].in[1] <== 45; - eq[61][i] = IsEqual(); - eq[61][i].in[0] <== in[i]; - eq[61][i].in[1] <== 46; - eq[62][i] = IsEqual(); - eq[62][i].in[0] <== in[i]; - eq[62][i].in[1] <== 48; - eq[63][i] = IsEqual(); - eq[63][i].in[0] <== in[i]; - eq[63][i].in[1] <== 49; - eq[64][i] = IsEqual(); - eq[64][i].in[0] <== in[i]; - eq[64][i].in[1] <== 50; - eq[65][i] = IsEqual(); - eq[65][i].in[0] <== in[i]; - eq[65][i].in[1] <== 51; - eq[66][i] = IsEqual(); - eq[66][i].in[0] <== in[i]; - eq[66][i].in[1] <== 52; - eq[67][i] = IsEqual(); - eq[67][i].in[0] <== in[i]; - eq[67][i].in[1] <== 53; - eq[68][i] = IsEqual(); - eq[68][i].in[0] <== in[i]; - eq[68][i].in[1] <== 54; - eq[69][i] = IsEqual(); - eq[69][i].in[0] <== in[i]; - eq[69][i].in[1] <== 55; - eq[70][i] = IsEqual(); - eq[70][i].in[0] <== in[i]; - eq[70][i].in[1] <== 56; - eq[71][i] = IsEqual(); - eq[71][i].in[0] <== in[i]; - eq[71][i].in[1] <== 57; - and[14][i] = AND(); - and[14][i].a <== states[i][3]; + multi_or[3][i].in[0] <== and[0][i].out; + multi_or[3][i].in[1] <== and[6][i].out; + multi_or[3][i].in[2] <== eq[8][i].out; + multi_or[3][i].in[3] <== eq[9][i].out; + multi_or[3][i].in[4] <== eq[11][i].out; + multi_or[3][i].in[5] <== eq[12][i].out; + multi_or[3][i].in[6] <== eq[13][i].out; + multi_or[3][i].in[7] <== eq[14][i].out; + multi_or[3][i].in[8] <== eq[15][i].out; + multi_or[3][i].in[9] <== eq[16][i].out; + multi_or[3][i].in[10] <== eq[17][i].out; + multi_or[3][i].in[11] <== eq[18][i].out; + multi_or[3][i].in[12] <== eq[19][i].out; + multi_or[3][i].in[13] <== eq[20][i].out; + and[7][i].b <== multi_or[3][i].out; + and[8][i] = AND(); + and[8][i].a <== states[i][3]; multi_or[4][i] = MultiOR(14); - multi_or[4][i].in[0] <== and[12][i].out; - multi_or[4][i].in[1] <== and[13][i].out; - multi_or[4][i].in[2] <== eq[60][i].out; - multi_or[4][i].in[3] <== eq[61][i].out; - multi_or[4][i].in[4] <== eq[62][i].out; - multi_or[4][i].in[5] <== eq[63][i].out; - multi_or[4][i].in[6] <== eq[64][i].out; - multi_or[4][i].in[7] <== eq[65][i].out; - multi_or[4][i].in[8] <== eq[66][i].out; - multi_or[4][i].in[9] <== eq[67][i].out; - multi_or[4][i].in[10] <== eq[68][i].out; - multi_or[4][i].in[11] <== eq[69][i].out; - multi_or[4][i].in[12] <== eq[70][i].out; - multi_or[4][i].in[13] <== eq[71][i].out; - and[14][i].b <== multi_or[4][i].out; + multi_or[4][i].in[0] <== and[0][i].out; + multi_or[4][i].in[1] <== and[6][i].out; + multi_or[4][i].in[2] <== eq[8][i].out; + multi_or[4][i].in[3] <== eq[9][i].out; + multi_or[4][i].in[4] <== eq[11][i].out; + multi_or[4][i].in[5] <== eq[12][i].out; + multi_or[4][i].in[6] <== eq[13][i].out; + multi_or[4][i].in[7] <== eq[14][i].out; + multi_or[4][i].in[8] <== eq[15][i].out; + multi_or[4][i].in[9] <== eq[16][i].out; + multi_or[4][i].in[10] <== eq[17][i].out; + multi_or[4][i].in[11] <== eq[18][i].out; + multi_or[4][i].in[12] <== eq[19][i].out; + multi_or[4][i].in[13] <== eq[20][i].out; + and[8][i].b <== multi_or[4][i].out; multi_or[5][i] = MultiOR(2); - multi_or[5][i].in[0] <== and[11][i].out; - multi_or[5][i].in[1] <== and[14][i].out; + multi_or[5][i].in[0] <== and[7][i].out; + multi_or[5][i].in[1] <== and[8][i].out; states[i+1][3] <== multi_or[5][i].out; state_changed[i].in[2] <== states[i+1][3]; states[i+1][0] <== 1 - state_changed[i].out; diff --git a/packages/circom/circuits/common/email_addr_with_name_regex.circom b/packages/circom/circuits/common/email_addr_with_name_regex.circom index 648056c..232e1c4 100644 --- a/packages/circom/circuits/common/email_addr_with_name_regex.circom +++ b/packages/circom/circuits/common/email_addr_with_name_regex.circom @@ -13,9 +13,9 @@ template EmailAddrWithNameRegex(msg_bytes) { in[i+1] <== msg[i]; } - component eq[209][num_bytes]; - component lt[48][num_bytes]; - component and[43][num_bytes]; + component eq[51][num_bytes]; + component lt[22][num_bytes]; + component and[30][num_bytes]; component multi_or[15][num_bytes]; signal states[num_bytes+1][7]; component state_changed[num_bytes]; @@ -121,1080 +121,489 @@ template EmailAddrWithNameRegex(msg_bytes) { and[4][i] = AND(); and[4][i].a <== lt[6][i].out; and[4][i].b <== lt[7][i].out; + and[5][i] = AND(); + and[5][i].a <== states[i][1]; + multi_or[1][i] = MultiOR(16); + multi_or[1][i].in[0] <== and[3][i].out; + multi_or[1][i].in[1] <== and[4][i].out; + multi_or[1][i].in[2] <== and[0][i].out; + multi_or[1][i].in[3] <== and[1][i].out; + multi_or[1][i].in[4] <== eq[0][i].out; + multi_or[1][i].in[5] <== eq[1][i].out; + multi_or[1][i].in[6] <== eq[2][i].out; + multi_or[1][i].in[7] <== eq[3][i].out; + multi_or[1][i].in[8] <== eq[4][i].out; + multi_or[1][i].in[9] <== eq[5][i].out; + multi_or[1][i].in[10] <== eq[6][i].out; + multi_or[1][i].in[11] <== eq[7][i].out; + multi_or[1][i].in[12] <== eq[8][i].out; + multi_or[1][i].in[13] <== eq[9][i].out; + multi_or[1][i].in[14] <== eq[10][i].out; + multi_or[1][i].in[15] <== eq[11][i].out; + and[5][i].b <== multi_or[1][i].out; lt[8][i] = LessEqThan(8); lt[8][i].in[0] <== 14; lt[8][i].in[1] <== in[i]; lt[9][i] = LessEqThan(8); lt[9][i].in[0] <== in[i]; - lt[9][i].in[1] <== 93; - and[5][i] = AND(); - and[5][i].a <== lt[8][i].out; - and[5][i].b <== lt[9][i].out; + lt[9][i].in[1] <== 44; + and[6][i] = AND(); + and[6][i].a <== lt[8][i].out; + and[6][i].b <== lt[9][i].out; lt[10][i] = LessEqThan(8); - lt[10][i].in[0] <== 95; + lt[10][i].in[0] <== 123; lt[10][i].in[1] <== in[i]; lt[11][i] = LessEqThan(8); lt[11][i].in[0] <== in[i]; lt[11][i].in[1] <== 254; - and[6][i] = AND(); - and[6][i].a <== lt[10][i].out; - and[6][i].b <== lt[11][i].out; + and[7][i] = AND(); + and[7][i].a <== lt[10][i].out; + and[7][i].b <== lt[11][i].out; eq[13][i] = IsEqual(); eq[13][i].in[0] <== in[i]; - eq[13][i].in[1] <== 0; + eq[13][i].in[1] <== 47; eq[14][i] = IsEqual(); eq[14][i].in[0] <== in[i]; - eq[14][i].in[1] <== 1; + eq[14][i].in[1] <== 58; eq[15][i] = IsEqual(); eq[15][i].in[0] <== in[i]; - eq[15][i].in[1] <== 2; + eq[15][i].in[1] <== 59; eq[16][i] = IsEqual(); eq[16][i].in[0] <== in[i]; - eq[16][i].in[1] <== 3; + eq[16][i].in[1] <== 61; eq[17][i] = IsEqual(); eq[17][i].in[0] <== in[i]; - eq[17][i].in[1] <== 4; + eq[17][i].in[1] <== 63; eq[18][i] = IsEqual(); eq[18][i].in[0] <== in[i]; - eq[18][i].in[1] <== 5; + eq[18][i].in[1] <== 64; eq[19][i] = IsEqual(); eq[19][i].in[0] <== in[i]; - eq[19][i].in[1] <== 6; + eq[19][i].in[1] <== 91; eq[20][i] = IsEqual(); eq[20][i].in[0] <== in[i]; - eq[20][i].in[1] <== 7; + eq[20][i].in[1] <== 92; eq[21][i] = IsEqual(); eq[21][i].in[0] <== in[i]; - eq[21][i].in[1] <== 8; + eq[21][i].in[1] <== 93; eq[22][i] = IsEqual(); eq[22][i].in[0] <== in[i]; - eq[22][i].in[1] <== 9; + eq[22][i].in[1] <== 94; eq[23][i] = IsEqual(); eq[23][i].in[0] <== in[i]; - eq[23][i].in[1] <== 11; - eq[24][i] = IsEqual(); - eq[24][i].in[0] <== in[i]; - eq[24][i].in[1] <== 12; - and[7][i] = AND(); - and[7][i].a <== states[i][1]; - multi_or[1][i] = MultiOR(16); - multi_or[1][i].in[0] <== and[3][i].out; - multi_or[1][i].in[1] <== and[4][i].out; - multi_or[1][i].in[2] <== and[5][i].out; - multi_or[1][i].in[3] <== and[6][i].out; - multi_or[1][i].in[4] <== eq[13][i].out; - multi_or[1][i].in[5] <== eq[14][i].out; - multi_or[1][i].in[6] <== eq[15][i].out; - multi_or[1][i].in[7] <== eq[16][i].out; - multi_or[1][i].in[8] <== eq[17][i].out; - multi_or[1][i].in[9] <== eq[18][i].out; - multi_or[1][i].in[10] <== eq[19][i].out; - multi_or[1][i].in[11] <== eq[20][i].out; - multi_or[1][i].in[12] <== eq[21][i].out; - multi_or[1][i].in[13] <== eq[22][i].out; - multi_or[1][i].in[14] <== eq[23][i].out; - multi_or[1][i].in[15] <== eq[24][i].out; - and[7][i].b <== multi_or[1][i].out; + eq[23][i].in[1] <== 96; + and[8][i] = AND(); + and[8][i].a <== states[i][2]; + multi_or[2][i] = MultiOR(25); + 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] <== eq[0][i].out; + multi_or[2][i].in[3] <== eq[1][i].out; + multi_or[2][i].in[4] <== eq[2][i].out; + multi_or[2][i].in[5] <== eq[3][i].out; + multi_or[2][i].in[6] <== eq[4][i].out; + multi_or[2][i].in[7] <== eq[5][i].out; + multi_or[2][i].in[8] <== eq[6][i].out; + multi_or[2][i].in[9] <== eq[7][i].out; + multi_or[2][i].in[10] <== eq[8][i].out; + multi_or[2][i].in[11] <== eq[9][i].out; + multi_or[2][i].in[12] <== eq[10][i].out; + multi_or[2][i].in[13] <== eq[11][i].out; + multi_or[2][i].in[14] <== eq[13][i].out; + multi_or[2][i].in[15] <== eq[14][i].out; + multi_or[2][i].in[16] <== eq[15][i].out; + multi_or[2][i].in[17] <== eq[16][i].out; + multi_or[2][i].in[18] <== eq[17][i].out; + multi_or[2][i].in[19] <== eq[18][i].out; + multi_or[2][i].in[20] <== eq[19][i].out; + multi_or[2][i].in[21] <== eq[20][i].out; + multi_or[2][i].in[22] <== eq[21][i].out; + multi_or[2][i].in[23] <== eq[22][i].out; + multi_or[2][i].in[24] <== eq[23][i].out; + and[8][i].b <== multi_or[2][i].out; + and[9][i] = AND(); + and[9][i].a <== states[i][3]; + multi_or[3][i] = MultiOR(14); + multi_or[3][i].in[0] <== and[3][i].out; + multi_or[3][i].in[1] <== and[4][i].out; + multi_or[3][i].in[2] <== eq[0][i].out; + multi_or[3][i].in[3] <== eq[1][i].out; + multi_or[3][i].in[4] <== eq[2][i].out; + multi_or[3][i].in[5] <== eq[3][i].out; + multi_or[3][i].in[6] <== eq[4][i].out; + multi_or[3][i].in[7] <== eq[5][i].out; + multi_or[3][i].in[8] <== eq[6][i].out; + multi_or[3][i].in[9] <== eq[7][i].out; + multi_or[3][i].in[10] <== eq[8][i].out; + multi_or[3][i].in[11] <== eq[9][i].out; + multi_or[3][i].in[12] <== eq[10][i].out; + multi_or[3][i].in[13] <== eq[11][i].out; + and[9][i].b <== multi_or[3][i].out; lt[12][i] = LessEqThan(8); lt[12][i].in[0] <== 14; lt[12][i].in[1] <== in[i]; lt[13][i] = LessEqThan(8); lt[13][i].in[0] <== in[i]; - lt[13][i].in[1] <== 44; - and[8][i] = AND(); - and[8][i].a <== lt[12][i].out; - and[8][i].b <== lt[13][i].out; + lt[13][i].in[1] <== 32; + and[10][i] = AND(); + and[10][i].a <== lt[12][i].out; + and[10][i].b <== lt[13][i].out; lt[14][i] = LessEqThan(8); - lt[14][i].in[0] <== 123; + lt[14][i].in[0] <== 127; lt[14][i].in[1] <== in[i]; lt[15][i] = LessEqThan(8); lt[15][i].in[0] <== in[i]; lt[15][i].in[1] <== 254; - and[9][i] = AND(); - and[9][i].a <== lt[14][i].out; - and[9][i].b <== lt[15][i].out; + and[11][i] = AND(); + and[11][i].a <== lt[14][i].out; + and[11][i].b <== lt[15][i].out; + eq[24][i] = IsEqual(); + eq[24][i].in[0] <== in[i]; + eq[24][i].in[1] <== 34; eq[25][i] = IsEqual(); eq[25][i].in[0] <== in[i]; - eq[25][i].in[1] <== 0; + eq[25][i].in[1] <== 40; eq[26][i] = IsEqual(); eq[26][i].in[0] <== in[i]; - eq[26][i].in[1] <== 1; + eq[26][i].in[1] <== 41; eq[27][i] = IsEqual(); eq[27][i].in[0] <== in[i]; - eq[27][i].in[1] <== 2; + eq[27][i].in[1] <== 44; eq[28][i] = IsEqual(); eq[28][i].in[0] <== in[i]; - eq[28][i].in[1] <== 3; + eq[28][i].in[1] <== 62; + and[12][i] = AND(); + and[12][i].a <== states[i][4]; + multi_or[4][i] = MultiOR(25); + multi_or[4][i].in[0] <== and[10][i].out; + multi_or[4][i].in[1] <== and[11][i].out; + multi_or[4][i].in[2] <== eq[0][i].out; + multi_or[4][i].in[3] <== eq[1][i].out; + multi_or[4][i].in[4] <== eq[2][i].out; + multi_or[4][i].in[5] <== eq[3][i].out; + multi_or[4][i].in[6] <== eq[4][i].out; + multi_or[4][i].in[7] <== eq[5][i].out; + multi_or[4][i].in[8] <== eq[6][i].out; + multi_or[4][i].in[9] <== eq[7][i].out; + multi_or[4][i].in[10] <== eq[8][i].out; + multi_or[4][i].in[11] <== eq[9][i].out; + multi_or[4][i].in[12] <== eq[10][i].out; + multi_or[4][i].in[13] <== eq[11][i].out; + multi_or[4][i].in[14] <== eq[24][i].out; + multi_or[4][i].in[15] <== eq[25][i].out; + multi_or[4][i].in[16] <== eq[26][i].out; + multi_or[4][i].in[17] <== eq[27][i].out; + multi_or[4][i].in[18] <== eq[14][i].out; + multi_or[4][i].in[19] <== eq[15][i].out; + multi_or[4][i].in[20] <== eq[28][i].out; + multi_or[4][i].in[21] <== eq[18][i].out; + multi_or[4][i].in[22] <== eq[19][i].out; + multi_or[4][i].in[23] <== eq[20][i].out; + multi_or[4][i].in[24] <== eq[21][i].out; + and[12][i].b <== multi_or[4][i].out; + and[13][i] = AND(); + and[13][i].a <== states[i][5]; + multi_or[5][i] = MultiOR(24); + multi_or[5][i].in[0] <== and[10][i].out; + multi_or[5][i].in[1] <== and[11][i].out; + multi_or[5][i].in[2] <== eq[0][i].out; + multi_or[5][i].in[3] <== eq[1][i].out; + multi_or[5][i].in[4] <== eq[2][i].out; + multi_or[5][i].in[5] <== eq[3][i].out; + multi_or[5][i].in[6] <== eq[4][i].out; + multi_or[5][i].in[7] <== eq[5][i].out; + multi_or[5][i].in[8] <== eq[6][i].out; + multi_or[5][i].in[9] <== eq[7][i].out; + multi_or[5][i].in[10] <== eq[8][i].out; + multi_or[5][i].in[11] <== eq[9][i].out; + multi_or[5][i].in[12] <== eq[10][i].out; + multi_or[5][i].in[13] <== eq[11][i].out; + multi_or[5][i].in[14] <== eq[24][i].out; + multi_or[5][i].in[15] <== eq[25][i].out; + multi_or[5][i].in[16] <== eq[26][i].out; + multi_or[5][i].in[17] <== eq[27][i].out; + multi_or[5][i].in[18] <== eq[14][i].out; + multi_or[5][i].in[19] <== eq[15][i].out; + multi_or[5][i].in[20] <== eq[28][i].out; + multi_or[5][i].in[21] <== eq[19][i].out; + multi_or[5][i].in[22] <== eq[20][i].out; + multi_or[5][i].in[23] <== eq[21][i].out; + and[13][i].b <== multi_or[5][i].out; + and[14][i] = AND(); + and[14][i].a <== states[i][6]; + multi_or[6][i] = MultiOR(26); + multi_or[6][i].in[0] <== and[6][i].out; + multi_or[6][i].in[1] <== and[7][i].out; + multi_or[6][i].in[2] <== eq[0][i].out; + multi_or[6][i].in[3] <== eq[1][i].out; + multi_or[6][i].in[4] <== eq[2][i].out; + multi_or[6][i].in[5] <== eq[3][i].out; + multi_or[6][i].in[6] <== eq[4][i].out; + multi_or[6][i].in[7] <== eq[5][i].out; + multi_or[6][i].in[8] <== eq[6][i].out; + multi_or[6][i].in[9] <== eq[7][i].out; + multi_or[6][i].in[10] <== eq[8][i].out; + multi_or[6][i].in[11] <== eq[9][i].out; + multi_or[6][i].in[12] <== eq[10][i].out; + multi_or[6][i].in[13] <== eq[11][i].out; + multi_or[6][i].in[14] <== eq[13][i].out; + multi_or[6][i].in[15] <== eq[14][i].out; + multi_or[6][i].in[16] <== eq[15][i].out; + multi_or[6][i].in[17] <== eq[16][i].out; + multi_or[6][i].in[18] <== eq[28][i].out; + multi_or[6][i].in[19] <== eq[17][i].out; + multi_or[6][i].in[20] <== eq[18][i].out; + multi_or[6][i].in[21] <== eq[19][i].out; + multi_or[6][i].in[22] <== eq[20][i].out; + multi_or[6][i].in[23] <== eq[21][i].out; + multi_or[6][i].in[24] <== eq[22][i].out; + multi_or[6][i].in[25] <== eq[23][i].out; + and[14][i].b <== multi_or[6][i].out; + multi_or[7][i] = MultiOR(7); + multi_or[7][i].in[0] <== and[2][i].out; + multi_or[7][i].in[1] <== and[5][i].out; + multi_or[7][i].in[2] <== and[8][i].out; + multi_or[7][i].in[3] <== and[9][i].out; + multi_or[7][i].in[4] <== and[12][i].out; + multi_or[7][i].in[5] <== and[13][i].out; + multi_or[7][i].in[6] <== and[14][i].out; + states[i+1][1] <== multi_or[7][i].out; + state_changed[i].in[0] <== states[i+1][1]; + lt[16][i] = LessEqThan(8); + lt[16][i].in[0] <== 65; + lt[16][i].in[1] <== in[i]; + lt[17][i] = LessEqThan(8); + lt[17][i].in[0] <== in[i]; + lt[17][i].in[1] <== 90; + and[15][i] = AND(); + and[15][i].a <== lt[16][i].out; + and[15][i].b <== lt[17][i].out; + lt[18][i] = LessEqThan(8); + lt[18][i].in[0] <== 97; + lt[18][i].in[1] <== in[i]; + lt[19][i] = LessEqThan(8); + lt[19][i].in[0] <== in[i]; + lt[19][i].in[1] <== 122; + and[16][i] = AND(); + and[16][i].a <== lt[18][i].out; + and[16][i].b <== lt[19][i].out; eq[29][i] = IsEqual(); eq[29][i].in[0] <== in[i]; - eq[29][i].in[1] <== 4; + eq[29][i].in[1] <== 45; eq[30][i] = IsEqual(); eq[30][i].in[0] <== in[i]; - eq[30][i].in[1] <== 5; + eq[30][i].in[1] <== 46; eq[31][i] = IsEqual(); eq[31][i].in[0] <== in[i]; - eq[31][i].in[1] <== 6; + eq[31][i].in[1] <== 48; eq[32][i] = IsEqual(); eq[32][i].in[0] <== in[i]; - eq[32][i].in[1] <== 7; + eq[32][i].in[1] <== 49; eq[33][i] = IsEqual(); eq[33][i].in[0] <== in[i]; - eq[33][i].in[1] <== 8; + eq[33][i].in[1] <== 50; eq[34][i] = IsEqual(); eq[34][i].in[0] <== in[i]; - eq[34][i].in[1] <== 9; + eq[34][i].in[1] <== 51; eq[35][i] = IsEqual(); eq[35][i].in[0] <== in[i]; - eq[35][i].in[1] <== 11; + eq[35][i].in[1] <== 52; eq[36][i] = IsEqual(); eq[36][i].in[0] <== in[i]; - eq[36][i].in[1] <== 12; + eq[36][i].in[1] <== 53; eq[37][i] = IsEqual(); eq[37][i].in[0] <== in[i]; - eq[37][i].in[1] <== 47; + eq[37][i].in[1] <== 54; eq[38][i] = IsEqual(); eq[38][i].in[0] <== in[i]; - eq[38][i].in[1] <== 58; + eq[38][i].in[1] <== 55; eq[39][i] = IsEqual(); eq[39][i].in[0] <== in[i]; - eq[39][i].in[1] <== 59; + eq[39][i].in[1] <== 56; eq[40][i] = IsEqual(); eq[40][i].in[0] <== in[i]; - eq[40][i].in[1] <== 61; + eq[40][i].in[1] <== 57; eq[41][i] = IsEqual(); eq[41][i].in[0] <== in[i]; - eq[41][i].in[1] <== 63; + eq[41][i].in[1] <== 95; + and[17][i] = AND(); + and[17][i].a <== states[i][2]; + multi_or[8][i] = MultiOR(15); + multi_or[8][i].in[0] <== and[15][i].out; + multi_or[8][i].in[1] <== and[16][i].out; + multi_or[8][i].in[2] <== eq[29][i].out; + multi_or[8][i].in[3] <== eq[30][i].out; + multi_or[8][i].in[4] <== eq[31][i].out; + multi_or[8][i].in[5] <== eq[32][i].out; + multi_or[8][i].in[6] <== eq[33][i].out; + multi_or[8][i].in[7] <== eq[34][i].out; + multi_or[8][i].in[8] <== eq[35][i].out; + multi_or[8][i].in[9] <== eq[36][i].out; + multi_or[8][i].in[10] <== eq[37][i].out; + multi_or[8][i].in[11] <== eq[38][i].out; + multi_or[8][i].in[12] <== eq[39][i].out; + multi_or[8][i].in[13] <== eq[40][i].out; + multi_or[8][i].in[14] <== eq[41][i].out; + and[17][i].b <== multi_or[8][i].out; + and[18][i] = AND(); + and[18][i].a <== states[i][6]; + multi_or[9][i] = MultiOR(15); + multi_or[9][i].in[0] <== and[15][i].out; + multi_or[9][i].in[1] <== and[16][i].out; + multi_or[9][i].in[2] <== eq[29][i].out; + multi_or[9][i].in[3] <== eq[30][i].out; + multi_or[9][i].in[4] <== eq[31][i].out; + multi_or[9][i].in[5] <== eq[32][i].out; + multi_or[9][i].in[6] <== eq[33][i].out; + multi_or[9][i].in[7] <== eq[34][i].out; + multi_or[9][i].in[8] <== eq[35][i].out; + multi_or[9][i].in[9] <== eq[36][i].out; + multi_or[9][i].in[10] <== eq[37][i].out; + multi_or[9][i].in[11] <== eq[38][i].out; + multi_or[9][i].in[12] <== eq[39][i].out; + multi_or[9][i].in[13] <== eq[40][i].out; + multi_or[9][i].in[14] <== eq[41][i].out; + and[18][i].b <== multi_or[9][i].out; + multi_or[10][i] = MultiOR(2); + multi_or[10][i].in[0] <== and[17][i].out; + multi_or[10][i].in[1] <== and[18][i].out; + states[i+1][2] <== multi_or[10][i].out; + state_changed[i].in[1] <== states[i+1][2]; + and[19][i] = AND(); + and[19][i].a <== states[i][2]; + and[19][i].b <== eq[28][i].out; + states[i+1][3] <== and[19][i].out; + state_changed[i].in[2] <== states[i+1][3]; eq[42][i] = IsEqual(); eq[42][i].in[0] <== in[i]; - eq[42][i].in[1] <== 64; + eq[42][i].in[1] <== 60; + and[20][i] = AND(); + and[20][i].a <== states[i][1]; + and[20][i].b <== eq[42][i].out; + and[21][i] = AND(); + and[21][i].a <== states[i][2]; + and[21][i].b <== eq[42][i].out; + and[22][i] = AND(); + and[22][i].a <== states[i][3]; + and[22][i].b <== eq[42][i].out; + and[23][i] = AND(); + and[23][i].a <== states[i][4]; + and[23][i].b <== eq[42][i].out; + and[24][i] = AND(); + and[24][i].a <== states[i][5]; + and[24][i].b <== eq[42][i].out; + and[25][i] = AND(); + and[25][i].a <== states[i][6]; + and[25][i].b <== eq[42][i].out; + multi_or[11][i] = MultiOR(6); + multi_or[11][i].in[0] <== and[20][i].out; + multi_or[11][i].in[1] <== and[21][i].out; + multi_or[11][i].in[2] <== and[22][i].out; + multi_or[11][i].in[3] <== and[23][i].out; + multi_or[11][i].in[4] <== and[24][i].out; + multi_or[11][i].in[5] <== and[25][i].out; + states[i+1][4] <== multi_or[11][i].out; + state_changed[i].in[3] <== states[i+1][4]; + lt[20][i] = LessEqThan(8); + lt[20][i].in[0] <== 94; + lt[20][i].in[1] <== in[i]; + lt[21][i] = LessEqThan(8); + lt[21][i].in[0] <== in[i]; + lt[21][i].in[1] <== 126; + and[26][i] = AND(); + and[26][i].a <== lt[20][i].out; + and[26][i].b <== lt[21][i].out; eq[43][i] = IsEqual(); eq[43][i].in[0] <== in[i]; - eq[43][i].in[1] <== 91; + eq[43][i].in[1] <== 33; eq[44][i] = IsEqual(); eq[44][i].in[0] <== in[i]; - eq[44][i].in[1] <== 92; + eq[44][i].in[1] <== 35; eq[45][i] = IsEqual(); eq[45][i].in[0] <== in[i]; - eq[45][i].in[1] <== 93; + eq[45][i].in[1] <== 36; eq[46][i] = IsEqual(); eq[46][i].in[0] <== in[i]; - eq[46][i].in[1] <== 94; + eq[46][i].in[1] <== 37; eq[47][i] = IsEqual(); eq[47][i].in[0] <== in[i]; - eq[47][i].in[1] <== 96; - and[10][i] = AND(); - and[10][i].a <== states[i][2]; - multi_or[2][i] = MultiOR(25); - multi_or[2][i].in[0] <== and[8][i].out; - multi_or[2][i].in[1] <== and[9][i].out; - multi_or[2][i].in[2] <== eq[25][i].out; - multi_or[2][i].in[3] <== eq[26][i].out; - multi_or[2][i].in[4] <== eq[27][i].out; - multi_or[2][i].in[5] <== eq[28][i].out; - multi_or[2][i].in[6] <== eq[29][i].out; - multi_or[2][i].in[7] <== eq[30][i].out; - multi_or[2][i].in[8] <== eq[31][i].out; - multi_or[2][i].in[9] <== eq[32][i].out; - multi_or[2][i].in[10] <== eq[33][i].out; - multi_or[2][i].in[11] <== eq[34][i].out; - multi_or[2][i].in[12] <== eq[35][i].out; - multi_or[2][i].in[13] <== eq[36][i].out; - multi_or[2][i].in[14] <== eq[37][i].out; - multi_or[2][i].in[15] <== eq[38][i].out; - multi_or[2][i].in[16] <== eq[39][i].out; - multi_or[2][i].in[17] <== eq[40][i].out; - multi_or[2][i].in[18] <== eq[41][i].out; - multi_or[2][i].in[19] <== eq[42][i].out; - multi_or[2][i].in[20] <== eq[43][i].out; - multi_or[2][i].in[21] <== eq[44][i].out; - multi_or[2][i].in[22] <== eq[45][i].out; - multi_or[2][i].in[23] <== eq[46][i].out; - multi_or[2][i].in[24] <== eq[47][i].out; - and[10][i].b <== multi_or[2][i].out; - lt[16][i] = LessEqThan(8); - lt[16][i].in[0] <== 14; - lt[16][i].in[1] <== in[i]; - lt[17][i] = LessEqThan(8); - lt[17][i].in[0] <== in[i]; - lt[17][i].in[1] <== 59; - and[11][i] = AND(); - and[11][i].a <== lt[16][i].out; - and[11][i].b <== lt[17][i].out; - lt[18][i] = LessEqThan(8); - lt[18][i].in[0] <== 61; - lt[18][i].in[1] <== in[i]; - lt[19][i] = LessEqThan(8); - lt[19][i].in[0] <== in[i]; - lt[19][i].in[1] <== 254; - and[12][i] = AND(); - and[12][i].a <== lt[18][i].out; - and[12][i].b <== lt[19][i].out; + eq[47][i].in[1] <== 38; eq[48][i] = IsEqual(); eq[48][i].in[0] <== in[i]; - eq[48][i].in[1] <== 0; + eq[48][i].in[1] <== 39; eq[49][i] = IsEqual(); eq[49][i].in[0] <== in[i]; - eq[49][i].in[1] <== 1; + eq[49][i].in[1] <== 42; eq[50][i] = IsEqual(); eq[50][i].in[0] <== in[i]; - eq[50][i].in[1] <== 2; - eq[51][i] = IsEqual(); - eq[51][i].in[0] <== in[i]; - eq[51][i].in[1] <== 3; - eq[52][i] = IsEqual(); - eq[52][i].in[0] <== in[i]; - eq[52][i].in[1] <== 4; - eq[53][i] = IsEqual(); - eq[53][i].in[0] <== in[i]; - eq[53][i].in[1] <== 5; - eq[54][i] = IsEqual(); - eq[54][i].in[0] <== in[i]; - eq[54][i].in[1] <== 6; - eq[55][i] = IsEqual(); - eq[55][i].in[0] <== in[i]; - eq[55][i].in[1] <== 7; - eq[56][i] = IsEqual(); - eq[56][i].in[0] <== in[i]; - eq[56][i].in[1] <== 8; - eq[57][i] = IsEqual(); - eq[57][i].in[0] <== in[i]; - eq[57][i].in[1] <== 9; - eq[58][i] = IsEqual(); - eq[58][i].in[0] <== in[i]; - eq[58][i].in[1] <== 11; - eq[59][i] = IsEqual(); - eq[59][i].in[0] <== in[i]; - eq[59][i].in[1] <== 12; - and[13][i] = AND(); - and[13][i].a <== states[i][3]; - multi_or[3][i] = MultiOR(14); - multi_or[3][i].in[0] <== and[11][i].out; - multi_or[3][i].in[1] <== and[12][i].out; - multi_or[3][i].in[2] <== eq[48][i].out; - multi_or[3][i].in[3] <== eq[49][i].out; - multi_or[3][i].in[4] <== eq[50][i].out; - multi_or[3][i].in[5] <== eq[51][i].out; - multi_or[3][i].in[6] <== eq[52][i].out; - multi_or[3][i].in[7] <== eq[53][i].out; - multi_or[3][i].in[8] <== eq[54][i].out; - multi_or[3][i].in[9] <== eq[55][i].out; - multi_or[3][i].in[10] <== eq[56][i].out; - multi_or[3][i].in[11] <== eq[57][i].out; - multi_or[3][i].in[12] <== eq[58][i].out; - multi_or[3][i].in[13] <== eq[59][i].out; - and[13][i].b <== multi_or[3][i].out; - lt[20][i] = LessEqThan(8); - lt[20][i].in[0] <== 14; - lt[20][i].in[1] <== in[i]; - lt[21][i] = LessEqThan(8); - lt[21][i].in[0] <== in[i]; - lt[21][i].in[1] <== 32; - and[14][i] = AND(); - and[14][i].a <== lt[20][i].out; - and[14][i].b <== lt[21][i].out; - lt[22][i] = LessEqThan(8); - lt[22][i].in[0] <== 127; - lt[22][i].in[1] <== in[i]; - lt[23][i] = LessEqThan(8); - lt[23][i].in[0] <== in[i]; - lt[23][i].in[1] <== 254; - and[15][i] = AND(); - and[15][i].a <== lt[22][i].out; - and[15][i].b <== lt[23][i].out; - eq[60][i] = IsEqual(); - eq[60][i].in[0] <== in[i]; - eq[60][i].in[1] <== 0; - eq[61][i] = IsEqual(); - eq[61][i].in[0] <== in[i]; - eq[61][i].in[1] <== 1; - eq[62][i] = IsEqual(); - eq[62][i].in[0] <== in[i]; - eq[62][i].in[1] <== 2; - eq[63][i] = IsEqual(); - eq[63][i].in[0] <== in[i]; - eq[63][i].in[1] <== 3; - eq[64][i] = IsEqual(); - eq[64][i].in[0] <== in[i]; - eq[64][i].in[1] <== 4; - eq[65][i] = IsEqual(); - eq[65][i].in[0] <== in[i]; - eq[65][i].in[1] <== 5; - eq[66][i] = IsEqual(); - eq[66][i].in[0] <== in[i]; - eq[66][i].in[1] <== 6; - eq[67][i] = IsEqual(); - eq[67][i].in[0] <== in[i]; - eq[67][i].in[1] <== 7; - eq[68][i] = IsEqual(); - eq[68][i].in[0] <== in[i]; - eq[68][i].in[1] <== 8; - eq[69][i] = IsEqual(); - eq[69][i].in[0] <== in[i]; - eq[69][i].in[1] <== 9; - eq[70][i] = IsEqual(); - eq[70][i].in[0] <== in[i]; - eq[70][i].in[1] <== 11; - eq[71][i] = IsEqual(); - eq[71][i].in[0] <== in[i]; - eq[71][i].in[1] <== 12; - eq[72][i] = IsEqual(); - eq[72][i].in[0] <== in[i]; - eq[72][i].in[1] <== 34; - eq[73][i] = IsEqual(); - eq[73][i].in[0] <== in[i]; - eq[73][i].in[1] <== 40; - eq[74][i] = IsEqual(); - eq[74][i].in[0] <== in[i]; - eq[74][i].in[1] <== 41; - eq[75][i] = IsEqual(); - eq[75][i].in[0] <== in[i]; - eq[75][i].in[1] <== 44; - eq[76][i] = IsEqual(); - eq[76][i].in[0] <== in[i]; - eq[76][i].in[1] <== 58; - eq[77][i] = IsEqual(); - eq[77][i].in[0] <== in[i]; - eq[77][i].in[1] <== 59; - eq[78][i] = IsEqual(); - eq[78][i].in[0] <== in[i]; - eq[78][i].in[1] <== 62; - eq[79][i] = IsEqual(); - eq[79][i].in[0] <== in[i]; - eq[79][i].in[1] <== 64; - eq[80][i] = IsEqual(); - eq[80][i].in[0] <== in[i]; - eq[80][i].in[1] <== 91; - eq[81][i] = IsEqual(); - eq[81][i].in[0] <== in[i]; - eq[81][i].in[1] <== 92; - eq[82][i] = IsEqual(); - eq[82][i].in[0] <== in[i]; - eq[82][i].in[1] <== 93; - and[16][i] = AND(); - and[16][i].a <== states[i][4]; - multi_or[4][i] = MultiOR(25); - multi_or[4][i].in[0] <== and[14][i].out; - multi_or[4][i].in[1] <== and[15][i].out; - multi_or[4][i].in[2] <== eq[60][i].out; - multi_or[4][i].in[3] <== eq[61][i].out; - multi_or[4][i].in[4] <== eq[62][i].out; - multi_or[4][i].in[5] <== eq[63][i].out; - multi_or[4][i].in[6] <== eq[64][i].out; - multi_or[4][i].in[7] <== eq[65][i].out; - multi_or[4][i].in[8] <== eq[66][i].out; - multi_or[4][i].in[9] <== eq[67][i].out; - multi_or[4][i].in[10] <== eq[68][i].out; - multi_or[4][i].in[11] <== eq[69][i].out; - multi_or[4][i].in[12] <== eq[70][i].out; - multi_or[4][i].in[13] <== eq[71][i].out; - multi_or[4][i].in[14] <== eq[72][i].out; - multi_or[4][i].in[15] <== eq[73][i].out; - multi_or[4][i].in[16] <== eq[74][i].out; - multi_or[4][i].in[17] <== eq[75][i].out; - multi_or[4][i].in[18] <== eq[76][i].out; - multi_or[4][i].in[19] <== eq[77][i].out; - multi_or[4][i].in[20] <== eq[78][i].out; - multi_or[4][i].in[21] <== eq[79][i].out; - multi_or[4][i].in[22] <== eq[80][i].out; - multi_or[4][i].in[23] <== eq[81][i].out; - multi_or[4][i].in[24] <== eq[82][i].out; - and[16][i].b <== multi_or[4][i].out; - lt[24][i] = LessEqThan(8); - lt[24][i].in[0] <== 14; - lt[24][i].in[1] <== in[i]; - lt[25][i] = LessEqThan(8); - lt[25][i].in[0] <== in[i]; - lt[25][i].in[1] <== 32; - and[17][i] = AND(); - and[17][i].a <== lt[24][i].out; - and[17][i].b <== lt[25][i].out; - lt[26][i] = LessEqThan(8); - lt[26][i].in[0] <== 127; - lt[26][i].in[1] <== in[i]; - lt[27][i] = LessEqThan(8); - lt[27][i].in[0] <== in[i]; - lt[27][i].in[1] <== 254; - and[18][i] = AND(); - and[18][i].a <== lt[26][i].out; - and[18][i].b <== lt[27][i].out; - eq[83][i] = IsEqual(); - eq[83][i].in[0] <== in[i]; - eq[83][i].in[1] <== 0; - eq[84][i] = IsEqual(); - eq[84][i].in[0] <== in[i]; - eq[84][i].in[1] <== 1; - eq[85][i] = IsEqual(); - eq[85][i].in[0] <== in[i]; - eq[85][i].in[1] <== 2; - eq[86][i] = IsEqual(); - eq[86][i].in[0] <== in[i]; - eq[86][i].in[1] <== 3; - eq[87][i] = IsEqual(); - eq[87][i].in[0] <== in[i]; - eq[87][i].in[1] <== 4; - eq[88][i] = IsEqual(); - eq[88][i].in[0] <== in[i]; - eq[88][i].in[1] <== 5; - eq[89][i] = IsEqual(); - eq[89][i].in[0] <== in[i]; - eq[89][i].in[1] <== 6; - eq[90][i] = IsEqual(); - eq[90][i].in[0] <== in[i]; - eq[90][i].in[1] <== 7; - eq[91][i] = IsEqual(); - eq[91][i].in[0] <== in[i]; - eq[91][i].in[1] <== 8; - eq[92][i] = IsEqual(); - eq[92][i].in[0] <== in[i]; - eq[92][i].in[1] <== 9; - eq[93][i] = IsEqual(); - eq[93][i].in[0] <== in[i]; - eq[93][i].in[1] <== 11; - eq[94][i] = IsEqual(); - eq[94][i].in[0] <== in[i]; - eq[94][i].in[1] <== 12; - eq[95][i] = IsEqual(); - eq[95][i].in[0] <== in[i]; - eq[95][i].in[1] <== 34; - eq[96][i] = IsEqual(); - eq[96][i].in[0] <== in[i]; - eq[96][i].in[1] <== 40; - eq[97][i] = IsEqual(); - eq[97][i].in[0] <== in[i]; - eq[97][i].in[1] <== 41; - eq[98][i] = IsEqual(); - eq[98][i].in[0] <== in[i]; - eq[98][i].in[1] <== 44; - eq[99][i] = IsEqual(); - eq[99][i].in[0] <== in[i]; - eq[99][i].in[1] <== 58; - eq[100][i] = IsEqual(); - eq[100][i].in[0] <== in[i]; - eq[100][i].in[1] <== 59; - eq[101][i] = IsEqual(); - eq[101][i].in[0] <== in[i]; - eq[101][i].in[1] <== 62; - eq[102][i] = IsEqual(); - eq[102][i].in[0] <== in[i]; - eq[102][i].in[1] <== 91; - eq[103][i] = IsEqual(); - eq[103][i].in[0] <== in[i]; - eq[103][i].in[1] <== 92; - eq[104][i] = IsEqual(); - eq[104][i].in[0] <== in[i]; - eq[104][i].in[1] <== 93; - and[19][i] = AND(); - and[19][i].a <== states[i][5]; - multi_or[5][i] = MultiOR(24); - multi_or[5][i].in[0] <== and[17][i].out; - multi_or[5][i].in[1] <== and[18][i].out; - multi_or[5][i].in[2] <== eq[83][i].out; - multi_or[5][i].in[3] <== eq[84][i].out; - multi_or[5][i].in[4] <== eq[85][i].out; - multi_or[5][i].in[5] <== eq[86][i].out; - multi_or[5][i].in[6] <== eq[87][i].out; - multi_or[5][i].in[7] <== eq[88][i].out; - multi_or[5][i].in[8] <== eq[89][i].out; - multi_or[5][i].in[9] <== eq[90][i].out; - multi_or[5][i].in[10] <== eq[91][i].out; - multi_or[5][i].in[11] <== eq[92][i].out; - multi_or[5][i].in[12] <== eq[93][i].out; - multi_or[5][i].in[13] <== eq[94][i].out; - multi_or[5][i].in[14] <== eq[95][i].out; - multi_or[5][i].in[15] <== eq[96][i].out; - multi_or[5][i].in[16] <== eq[97][i].out; - multi_or[5][i].in[17] <== eq[98][i].out; - multi_or[5][i].in[18] <== eq[99][i].out; - multi_or[5][i].in[19] <== eq[100][i].out; - multi_or[5][i].in[20] <== eq[101][i].out; - multi_or[5][i].in[21] <== eq[102][i].out; - multi_or[5][i].in[22] <== eq[103][i].out; - multi_or[5][i].in[23] <== eq[104][i].out; - and[19][i].b <== multi_or[5][i].out; - lt[28][i] = LessEqThan(8); - lt[28][i].in[0] <== 14; - lt[28][i].in[1] <== in[i]; - lt[29][i] = LessEqThan(8); - lt[29][i].in[0] <== in[i]; - lt[29][i].in[1] <== 44; - and[20][i] = AND(); - and[20][i].a <== lt[28][i].out; - and[20][i].b <== lt[29][i].out; - lt[30][i] = LessEqThan(8); - lt[30][i].in[0] <== 123; - lt[30][i].in[1] <== in[i]; - lt[31][i] = LessEqThan(8); - lt[31][i].in[0] <== in[i]; - lt[31][i].in[1] <== 254; - and[21][i] = AND(); - and[21][i].a <== lt[30][i].out; - and[21][i].b <== lt[31][i].out; - eq[105][i] = IsEqual(); - eq[105][i].in[0] <== in[i]; - eq[105][i].in[1] <== 0; - eq[106][i] = IsEqual(); - eq[106][i].in[0] <== in[i]; - eq[106][i].in[1] <== 1; - eq[107][i] = IsEqual(); - eq[107][i].in[0] <== in[i]; - eq[107][i].in[1] <== 2; - eq[108][i] = IsEqual(); - eq[108][i].in[0] <== in[i]; - eq[108][i].in[1] <== 3; - eq[109][i] = IsEqual(); - eq[109][i].in[0] <== in[i]; - eq[109][i].in[1] <== 4; - eq[110][i] = IsEqual(); - eq[110][i].in[0] <== in[i]; - eq[110][i].in[1] <== 5; - eq[111][i] = IsEqual(); - eq[111][i].in[0] <== in[i]; - eq[111][i].in[1] <== 6; - eq[112][i] = IsEqual(); - eq[112][i].in[0] <== in[i]; - eq[112][i].in[1] <== 7; - eq[113][i] = IsEqual(); - eq[113][i].in[0] <== in[i]; - eq[113][i].in[1] <== 8; - eq[114][i] = IsEqual(); - eq[114][i].in[0] <== in[i]; - eq[114][i].in[1] <== 9; - eq[115][i] = IsEqual(); - eq[115][i].in[0] <== in[i]; - eq[115][i].in[1] <== 11; - eq[116][i] = IsEqual(); - eq[116][i].in[0] <== in[i]; - eq[116][i].in[1] <== 12; - eq[117][i] = IsEqual(); - eq[117][i].in[0] <== in[i]; - eq[117][i].in[1] <== 47; - eq[118][i] = IsEqual(); - eq[118][i].in[0] <== in[i]; - eq[118][i].in[1] <== 58; - eq[119][i] = IsEqual(); - eq[119][i].in[0] <== in[i]; - eq[119][i].in[1] <== 59; - eq[120][i] = IsEqual(); - eq[120][i].in[0] <== in[i]; - eq[120][i].in[1] <== 61; - eq[121][i] = IsEqual(); - eq[121][i].in[0] <== in[i]; - eq[121][i].in[1] <== 62; - eq[122][i] = IsEqual(); - eq[122][i].in[0] <== in[i]; - eq[122][i].in[1] <== 63; - eq[123][i] = IsEqual(); - eq[123][i].in[0] <== in[i]; - eq[123][i].in[1] <== 64; - eq[124][i] = IsEqual(); - eq[124][i].in[0] <== in[i]; - eq[124][i].in[1] <== 91; - eq[125][i] = IsEqual(); - eq[125][i].in[0] <== in[i]; - eq[125][i].in[1] <== 92; - eq[126][i] = IsEqual(); - eq[126][i].in[0] <== in[i]; - eq[126][i].in[1] <== 93; - eq[127][i] = IsEqual(); - eq[127][i].in[0] <== in[i]; - eq[127][i].in[1] <== 94; - eq[128][i] = IsEqual(); - eq[128][i].in[0] <== in[i]; - eq[128][i].in[1] <== 96; - and[22][i] = AND(); - and[22][i].a <== states[i][6]; - multi_or[6][i] = MultiOR(26); - multi_or[6][i].in[0] <== and[20][i].out; - multi_or[6][i].in[1] <== and[21][i].out; - multi_or[6][i].in[2] <== eq[105][i].out; - multi_or[6][i].in[3] <== eq[106][i].out; - multi_or[6][i].in[4] <== eq[107][i].out; - multi_or[6][i].in[5] <== eq[108][i].out; - multi_or[6][i].in[6] <== eq[109][i].out; - multi_or[6][i].in[7] <== eq[110][i].out; - multi_or[6][i].in[8] <== eq[111][i].out; - multi_or[6][i].in[9] <== eq[112][i].out; - multi_or[6][i].in[10] <== eq[113][i].out; - multi_or[6][i].in[11] <== eq[114][i].out; - multi_or[6][i].in[12] <== eq[115][i].out; - multi_or[6][i].in[13] <== eq[116][i].out; - multi_or[6][i].in[14] <== eq[117][i].out; - multi_or[6][i].in[15] <== eq[118][i].out; - multi_or[6][i].in[16] <== eq[119][i].out; - multi_or[6][i].in[17] <== eq[120][i].out; - multi_or[6][i].in[18] <== eq[121][i].out; - multi_or[6][i].in[19] <== eq[122][i].out; - multi_or[6][i].in[20] <== eq[123][i].out; - multi_or[6][i].in[21] <== eq[124][i].out; - multi_or[6][i].in[22] <== eq[125][i].out; - multi_or[6][i].in[23] <== eq[126][i].out; - multi_or[6][i].in[24] <== eq[127][i].out; - multi_or[6][i].in[25] <== eq[128][i].out; - and[22][i].b <== multi_or[6][i].out; - multi_or[7][i] = MultiOR(7); - multi_or[7][i].in[0] <== and[2][i].out; - multi_or[7][i].in[1] <== and[7][i].out; - multi_or[7][i].in[2] <== and[10][i].out; - multi_or[7][i].in[3] <== and[13][i].out; - multi_or[7][i].in[4] <== and[16][i].out; - multi_or[7][i].in[5] <== and[19][i].out; - multi_or[7][i].in[6] <== and[22][i].out; - states[i+1][1] <== multi_or[7][i].out; - state_changed[i].in[0] <== states[i+1][1]; - lt[32][i] = LessEqThan(8); - lt[32][i].in[0] <== 65; - lt[32][i].in[1] <== in[i]; - lt[33][i] = LessEqThan(8); - lt[33][i].in[0] <== in[i]; - lt[33][i].in[1] <== 90; - and[23][i] = AND(); - and[23][i].a <== lt[32][i].out; - and[23][i].b <== lt[33][i].out; - lt[34][i] = LessEqThan(8); - lt[34][i].in[0] <== 97; - lt[34][i].in[1] <== in[i]; - lt[35][i] = LessEqThan(8); - lt[35][i].in[0] <== in[i]; - lt[35][i].in[1] <== 122; - and[24][i] = AND(); - and[24][i].a <== lt[34][i].out; - and[24][i].b <== lt[35][i].out; - eq[129][i] = IsEqual(); - eq[129][i].in[0] <== in[i]; - eq[129][i].in[1] <== 45; - eq[130][i] = IsEqual(); - eq[130][i].in[0] <== in[i]; - eq[130][i].in[1] <== 46; - eq[131][i] = IsEqual(); - eq[131][i].in[0] <== in[i]; - eq[131][i].in[1] <== 48; - eq[132][i] = IsEqual(); - eq[132][i].in[0] <== in[i]; - eq[132][i].in[1] <== 49; - eq[133][i] = IsEqual(); - eq[133][i].in[0] <== in[i]; - eq[133][i].in[1] <== 50; - eq[134][i] = IsEqual(); - eq[134][i].in[0] <== in[i]; - eq[134][i].in[1] <== 51; - eq[135][i] = IsEqual(); - eq[135][i].in[0] <== in[i]; - eq[135][i].in[1] <== 52; - eq[136][i] = IsEqual(); - eq[136][i].in[0] <== in[i]; - eq[136][i].in[1] <== 53; - eq[137][i] = IsEqual(); - eq[137][i].in[0] <== in[i]; - eq[137][i].in[1] <== 54; - eq[138][i] = IsEqual(); - eq[138][i].in[0] <== in[i]; - eq[138][i].in[1] <== 55; - eq[139][i] = IsEqual(); - eq[139][i].in[0] <== in[i]; - eq[139][i].in[1] <== 56; - eq[140][i] = IsEqual(); - eq[140][i].in[0] <== in[i]; - eq[140][i].in[1] <== 57; - eq[141][i] = IsEqual(); - eq[141][i].in[0] <== in[i]; - eq[141][i].in[1] <== 95; - and[25][i] = AND(); - and[25][i].a <== states[i][2]; - multi_or[8][i] = MultiOR(15); - multi_or[8][i].in[0] <== and[23][i].out; - multi_or[8][i].in[1] <== and[24][i].out; - multi_or[8][i].in[2] <== eq[129][i].out; - multi_or[8][i].in[3] <== eq[130][i].out; - multi_or[8][i].in[4] <== eq[131][i].out; - multi_or[8][i].in[5] <== eq[132][i].out; - multi_or[8][i].in[6] <== eq[133][i].out; - multi_or[8][i].in[7] <== eq[134][i].out; - multi_or[8][i].in[8] <== eq[135][i].out; - multi_or[8][i].in[9] <== eq[136][i].out; - multi_or[8][i].in[10] <== eq[137][i].out; - multi_or[8][i].in[11] <== eq[138][i].out; - multi_or[8][i].in[12] <== eq[139][i].out; - multi_or[8][i].in[13] <== eq[140][i].out; - multi_or[8][i].in[14] <== eq[141][i].out; - and[25][i].b <== multi_or[8][i].out; - lt[36][i] = LessEqThan(8); - lt[36][i].in[0] <== 65; - lt[36][i].in[1] <== in[i]; - lt[37][i] = LessEqThan(8); - lt[37][i].in[0] <== in[i]; - lt[37][i].in[1] <== 90; - and[26][i] = AND(); - and[26][i].a <== lt[36][i].out; - and[26][i].b <== lt[37][i].out; - lt[38][i] = LessEqThan(8); - lt[38][i].in[0] <== 97; - lt[38][i].in[1] <== in[i]; - lt[39][i] = LessEqThan(8); - lt[39][i].in[0] <== in[i]; - lt[39][i].in[1] <== 122; + eq[50][i].in[1] <== 43; and[27][i] = AND(); - and[27][i].a <== lt[38][i].out; - and[27][i].b <== lt[39][i].out; - eq[142][i] = IsEqual(); - eq[142][i].in[0] <== in[i]; - eq[142][i].in[1] <== 45; - eq[143][i] = IsEqual(); - eq[143][i].in[0] <== in[i]; - eq[143][i].in[1] <== 46; - eq[144][i] = IsEqual(); - eq[144][i].in[0] <== in[i]; - eq[144][i].in[1] <== 48; - eq[145][i] = IsEqual(); - eq[145][i].in[0] <== in[i]; - eq[145][i].in[1] <== 49; - eq[146][i] = IsEqual(); - eq[146][i].in[0] <== in[i]; - eq[146][i].in[1] <== 50; - eq[147][i] = IsEqual(); - eq[147][i].in[0] <== in[i]; - eq[147][i].in[1] <== 51; - eq[148][i] = IsEqual(); - eq[148][i].in[0] <== in[i]; - eq[148][i].in[1] <== 52; - eq[149][i] = IsEqual(); - eq[149][i].in[0] <== in[i]; - eq[149][i].in[1] <== 53; - eq[150][i] = IsEqual(); - eq[150][i].in[0] <== in[i]; - eq[150][i].in[1] <== 54; - eq[151][i] = IsEqual(); - eq[151][i].in[0] <== in[i]; - eq[151][i].in[1] <== 55; - eq[152][i] = IsEqual(); - eq[152][i].in[0] <== in[i]; - eq[152][i].in[1] <== 56; - eq[153][i] = IsEqual(); - eq[153][i].in[0] <== in[i]; - eq[153][i].in[1] <== 57; - eq[154][i] = IsEqual(); - eq[154][i].in[0] <== in[i]; - eq[154][i].in[1] <== 95; - and[28][i] = AND(); - and[28][i].a <== states[i][6]; - multi_or[9][i] = MultiOR(15); - multi_or[9][i].in[0] <== and[26][i].out; - multi_or[9][i].in[1] <== and[27][i].out; - multi_or[9][i].in[2] <== eq[142][i].out; - multi_or[9][i].in[3] <== eq[143][i].out; - multi_or[9][i].in[4] <== eq[144][i].out; - multi_or[9][i].in[5] <== eq[145][i].out; - multi_or[9][i].in[6] <== eq[146][i].out; - multi_or[9][i].in[7] <== eq[147][i].out; - multi_or[9][i].in[8] <== eq[148][i].out; - multi_or[9][i].in[9] <== eq[149][i].out; - multi_or[9][i].in[10] <== eq[150][i].out; - multi_or[9][i].in[11] <== eq[151][i].out; - multi_or[9][i].in[12] <== eq[152][i].out; - multi_or[9][i].in[13] <== eq[153][i].out; - multi_or[9][i].in[14] <== eq[154][i].out; - and[28][i].b <== multi_or[9][i].out; - multi_or[10][i] = MultiOR(2); - multi_or[10][i].in[0] <== and[25][i].out; - multi_or[10][i].in[1] <== and[28][i].out; - states[i+1][2] <== multi_or[10][i].out; - state_changed[i].in[1] <== states[i+1][2]; - eq[155][i] = IsEqual(); - eq[155][i].in[0] <== in[i]; - eq[155][i].in[1] <== 62; - and[29][i] = AND(); - and[29][i].a <== states[i][2]; - and[29][i].b <== eq[155][i].out; - states[i+1][3] <== and[29][i].out; - state_changed[i].in[2] <== states[i+1][3]; - eq[156][i] = IsEqual(); - eq[156][i].in[0] <== in[i]; - eq[156][i].in[1] <== 60; - and[30][i] = AND(); - and[30][i].a <== states[i][1]; - and[30][i].b <== eq[156][i].out; - eq[157][i] = IsEqual(); - eq[157][i].in[0] <== in[i]; - eq[157][i].in[1] <== 60; - and[31][i] = AND(); - and[31][i].a <== states[i][2]; - and[31][i].b <== eq[157][i].out; - eq[158][i] = IsEqual(); - eq[158][i].in[0] <== in[i]; - eq[158][i].in[1] <== 60; - and[32][i] = AND(); - and[32][i].a <== states[i][3]; - and[32][i].b <== eq[158][i].out; - eq[159][i] = IsEqual(); - eq[159][i].in[0] <== in[i]; - eq[159][i].in[1] <== 60; - and[33][i] = AND(); - and[33][i].a <== states[i][4]; - and[33][i].b <== eq[159][i].out; - eq[160][i] = IsEqual(); - eq[160][i].in[0] <== in[i]; - eq[160][i].in[1] <== 60; - and[34][i] = AND(); - and[34][i].a <== states[i][5]; - and[34][i].b <== eq[160][i].out; - eq[161][i] = IsEqual(); - eq[161][i].in[0] <== in[i]; - eq[161][i].in[1] <== 60; - and[35][i] = AND(); - and[35][i].a <== states[i][6]; - and[35][i].b <== eq[161][i].out; - multi_or[11][i] = MultiOR(6); - multi_or[11][i].in[0] <== and[30][i].out; - multi_or[11][i].in[1] <== and[31][i].out; - multi_or[11][i].in[2] <== and[32][i].out; - multi_or[11][i].in[3] <== and[33][i].out; - multi_or[11][i].in[4] <== and[34][i].out; - multi_or[11][i].in[5] <== and[35][i].out; - states[i+1][4] <== multi_or[11][i].out; - state_changed[i].in[3] <== states[i+1][4]; - lt[40][i] = LessEqThan(8); - lt[40][i].in[0] <== 65; - lt[40][i].in[1] <== in[i]; - lt[41][i] = LessEqThan(8); - lt[41][i].in[0] <== in[i]; - lt[41][i].in[1] <== 90; - and[36][i] = AND(); - and[36][i].a <== lt[40][i].out; - and[36][i].b <== lt[41][i].out; - lt[42][i] = LessEqThan(8); - lt[42][i].in[0] <== 94; - lt[42][i].in[1] <== in[i]; - lt[43][i] = LessEqThan(8); - lt[43][i].in[0] <== in[i]; - lt[43][i].in[1] <== 126; - and[37][i] = AND(); - and[37][i].a <== lt[42][i].out; - and[37][i].b <== lt[43][i].out; - eq[162][i] = IsEqual(); - eq[162][i].in[0] <== in[i]; - eq[162][i].in[1] <== 33; - eq[163][i] = IsEqual(); - eq[163][i].in[0] <== in[i]; - eq[163][i].in[1] <== 35; - eq[164][i] = IsEqual(); - eq[164][i].in[0] <== in[i]; - eq[164][i].in[1] <== 36; - eq[165][i] = IsEqual(); - eq[165][i].in[0] <== in[i]; - eq[165][i].in[1] <== 37; - eq[166][i] = IsEqual(); - eq[166][i].in[0] <== in[i]; - eq[166][i].in[1] <== 38; - eq[167][i] = IsEqual(); - eq[167][i].in[0] <== in[i]; - eq[167][i].in[1] <== 39; - eq[168][i] = IsEqual(); - eq[168][i].in[0] <== in[i]; - eq[168][i].in[1] <== 42; - eq[169][i] = IsEqual(); - eq[169][i].in[0] <== in[i]; - eq[169][i].in[1] <== 43; - eq[170][i] = IsEqual(); - eq[170][i].in[0] <== in[i]; - eq[170][i].in[1] <== 45; - eq[171][i] = IsEqual(); - eq[171][i].in[0] <== in[i]; - eq[171][i].in[1] <== 46; - eq[172][i] = IsEqual(); - eq[172][i].in[0] <== in[i]; - eq[172][i].in[1] <== 47; - eq[173][i] = IsEqual(); - eq[173][i].in[0] <== in[i]; - eq[173][i].in[1] <== 48; - eq[174][i] = IsEqual(); - eq[174][i].in[0] <== in[i]; - eq[174][i].in[1] <== 49; - eq[175][i] = IsEqual(); - eq[175][i].in[0] <== in[i]; - eq[175][i].in[1] <== 50; - eq[176][i] = IsEqual(); - eq[176][i].in[0] <== in[i]; - eq[176][i].in[1] <== 51; - eq[177][i] = IsEqual(); - eq[177][i].in[0] <== in[i]; - eq[177][i].in[1] <== 52; - eq[178][i] = IsEqual(); - eq[178][i].in[0] <== in[i]; - eq[178][i].in[1] <== 53; - eq[179][i] = IsEqual(); - eq[179][i].in[0] <== in[i]; - eq[179][i].in[1] <== 54; - eq[180][i] = IsEqual(); - eq[180][i].in[0] <== in[i]; - eq[180][i].in[1] <== 55; - eq[181][i] = IsEqual(); - eq[181][i].in[0] <== in[i]; - eq[181][i].in[1] <== 56; - eq[182][i] = IsEqual(); - eq[182][i].in[0] <== in[i]; - eq[182][i].in[1] <== 57; - eq[183][i] = IsEqual(); - eq[183][i].in[0] <== in[i]; - eq[183][i].in[1] <== 61; - eq[184][i] = IsEqual(); - eq[184][i].in[0] <== in[i]; - eq[184][i].in[1] <== 63; - and[38][i] = AND(); - and[38][i].a <== states[i][4]; + and[27][i].a <== states[i][4]; multi_or[12][i] = MultiOR(25); - multi_or[12][i].in[0] <== and[36][i].out; - multi_or[12][i].in[1] <== and[37][i].out; - multi_or[12][i].in[2] <== eq[162][i].out; - multi_or[12][i].in[3] <== eq[163][i].out; - multi_or[12][i].in[4] <== eq[164][i].out; - multi_or[12][i].in[5] <== eq[165][i].out; - multi_or[12][i].in[6] <== eq[166][i].out; - multi_or[12][i].in[7] <== eq[167][i].out; - multi_or[12][i].in[8] <== eq[168][i].out; - multi_or[12][i].in[9] <== eq[169][i].out; - multi_or[12][i].in[10] <== eq[170][i].out; - multi_or[12][i].in[11] <== eq[171][i].out; - multi_or[12][i].in[12] <== eq[172][i].out; - multi_or[12][i].in[13] <== eq[173][i].out; - multi_or[12][i].in[14] <== eq[174][i].out; - multi_or[12][i].in[15] <== eq[175][i].out; - multi_or[12][i].in[16] <== eq[176][i].out; - multi_or[12][i].in[17] <== eq[177][i].out; - multi_or[12][i].in[18] <== eq[178][i].out; - multi_or[12][i].in[19] <== eq[179][i].out; - multi_or[12][i].in[20] <== eq[180][i].out; - multi_or[12][i].in[21] <== eq[181][i].out; - multi_or[12][i].in[22] <== eq[182][i].out; - multi_or[12][i].in[23] <== eq[183][i].out; - multi_or[12][i].in[24] <== eq[184][i].out; - and[38][i].b <== multi_or[12][i].out; - lt[44][i] = LessEqThan(8); - lt[44][i].in[0] <== 65; - lt[44][i].in[1] <== in[i]; - lt[45][i] = LessEqThan(8); - lt[45][i].in[0] <== in[i]; - lt[45][i].in[1] <== 90; - and[39][i] = AND(); - and[39][i].a <== lt[44][i].out; - and[39][i].b <== lt[45][i].out; - lt[46][i] = LessEqThan(8); - lt[46][i].in[0] <== 94; - lt[46][i].in[1] <== in[i]; - lt[47][i] = LessEqThan(8); - lt[47][i].in[0] <== in[i]; - lt[47][i].in[1] <== 126; - and[40][i] = AND(); - and[40][i].a <== lt[46][i].out; - and[40][i].b <== lt[47][i].out; - eq[185][i] = IsEqual(); - eq[185][i].in[0] <== in[i]; - eq[185][i].in[1] <== 33; - eq[186][i] = IsEqual(); - eq[186][i].in[0] <== in[i]; - eq[186][i].in[1] <== 35; - eq[187][i] = IsEqual(); - eq[187][i].in[0] <== in[i]; - eq[187][i].in[1] <== 36; - eq[188][i] = IsEqual(); - eq[188][i].in[0] <== in[i]; - eq[188][i].in[1] <== 37; - eq[189][i] = IsEqual(); - eq[189][i].in[0] <== in[i]; - eq[189][i].in[1] <== 38; - eq[190][i] = IsEqual(); - eq[190][i].in[0] <== in[i]; - eq[190][i].in[1] <== 39; - eq[191][i] = IsEqual(); - eq[191][i].in[0] <== in[i]; - eq[191][i].in[1] <== 42; - eq[192][i] = IsEqual(); - eq[192][i].in[0] <== in[i]; - eq[192][i].in[1] <== 43; - eq[193][i] = IsEqual(); - eq[193][i].in[0] <== in[i]; - eq[193][i].in[1] <== 45; - eq[194][i] = IsEqual(); - eq[194][i].in[0] <== in[i]; - eq[194][i].in[1] <== 46; - eq[195][i] = IsEqual(); - eq[195][i].in[0] <== in[i]; - eq[195][i].in[1] <== 47; - eq[196][i] = IsEqual(); - eq[196][i].in[0] <== in[i]; - eq[196][i].in[1] <== 48; - eq[197][i] = IsEqual(); - eq[197][i].in[0] <== in[i]; - eq[197][i].in[1] <== 49; - eq[198][i] = IsEqual(); - eq[198][i].in[0] <== in[i]; - eq[198][i].in[1] <== 50; - eq[199][i] = IsEqual(); - eq[199][i].in[0] <== in[i]; - eq[199][i].in[1] <== 51; - eq[200][i] = IsEqual(); - eq[200][i].in[0] <== in[i]; - eq[200][i].in[1] <== 52; - eq[201][i] = IsEqual(); - eq[201][i].in[0] <== in[i]; - eq[201][i].in[1] <== 53; - eq[202][i] = IsEqual(); - eq[202][i].in[0] <== in[i]; - eq[202][i].in[1] <== 54; - eq[203][i] = IsEqual(); - eq[203][i].in[0] <== in[i]; - eq[203][i].in[1] <== 55; - eq[204][i] = IsEqual(); - eq[204][i].in[0] <== in[i]; - eq[204][i].in[1] <== 56; - eq[205][i] = IsEqual(); - eq[205][i].in[0] <== in[i]; - eq[205][i].in[1] <== 57; - eq[206][i] = IsEqual(); - eq[206][i].in[0] <== in[i]; - eq[206][i].in[1] <== 61; - eq[207][i] = IsEqual(); - eq[207][i].in[0] <== in[i]; - eq[207][i].in[1] <== 63; - and[41][i] = AND(); - and[41][i].a <== states[i][5]; + multi_or[12][i].in[0] <== and[15][i].out; + multi_or[12][i].in[1] <== and[26][i].out; + multi_or[12][i].in[2] <== eq[43][i].out; + multi_or[12][i].in[3] <== eq[44][i].out; + multi_or[12][i].in[4] <== eq[45][i].out; + multi_or[12][i].in[5] <== eq[46][i].out; + multi_or[12][i].in[6] <== eq[47][i].out; + multi_or[12][i].in[7] <== eq[48][i].out; + multi_or[12][i].in[8] <== eq[49][i].out; + multi_or[12][i].in[9] <== eq[50][i].out; + multi_or[12][i].in[10] <== eq[29][i].out; + multi_or[12][i].in[11] <== eq[30][i].out; + multi_or[12][i].in[12] <== eq[13][i].out; + multi_or[12][i].in[13] <== eq[31][i].out; + multi_or[12][i].in[14] <== eq[32][i].out; + multi_or[12][i].in[15] <== eq[33][i].out; + multi_or[12][i].in[16] <== eq[34][i].out; + multi_or[12][i].in[17] <== eq[35][i].out; + multi_or[12][i].in[18] <== eq[36][i].out; + multi_or[12][i].in[19] <== eq[37][i].out; + multi_or[12][i].in[20] <== eq[38][i].out; + multi_or[12][i].in[21] <== eq[39][i].out; + multi_or[12][i].in[22] <== eq[40][i].out; + multi_or[12][i].in[23] <== eq[16][i].out; + multi_or[12][i].in[24] <== eq[17][i].out; + and[27][i].b <== multi_or[12][i].out; + and[28][i] = AND(); + and[28][i].a <== states[i][5]; multi_or[13][i] = MultiOR(25); - multi_or[13][i].in[0] <== and[39][i].out; - multi_or[13][i].in[1] <== and[40][i].out; - multi_or[13][i].in[2] <== eq[185][i].out; - multi_or[13][i].in[3] <== eq[186][i].out; - multi_or[13][i].in[4] <== eq[187][i].out; - multi_or[13][i].in[5] <== eq[188][i].out; - multi_or[13][i].in[6] <== eq[189][i].out; - multi_or[13][i].in[7] <== eq[190][i].out; - multi_or[13][i].in[8] <== eq[191][i].out; - multi_or[13][i].in[9] <== eq[192][i].out; - multi_or[13][i].in[10] <== eq[193][i].out; - multi_or[13][i].in[11] <== eq[194][i].out; - multi_or[13][i].in[12] <== eq[195][i].out; - multi_or[13][i].in[13] <== eq[196][i].out; - multi_or[13][i].in[14] <== eq[197][i].out; - multi_or[13][i].in[15] <== eq[198][i].out; - multi_or[13][i].in[16] <== eq[199][i].out; - multi_or[13][i].in[17] <== eq[200][i].out; - multi_or[13][i].in[18] <== eq[201][i].out; - multi_or[13][i].in[19] <== eq[202][i].out; - multi_or[13][i].in[20] <== eq[203][i].out; - multi_or[13][i].in[21] <== eq[204][i].out; - multi_or[13][i].in[22] <== eq[205][i].out; - multi_or[13][i].in[23] <== eq[206][i].out; - multi_or[13][i].in[24] <== eq[207][i].out; - and[41][i].b <== multi_or[13][i].out; + multi_or[13][i].in[0] <== and[15][i].out; + multi_or[13][i].in[1] <== and[26][i].out; + multi_or[13][i].in[2] <== eq[43][i].out; + multi_or[13][i].in[3] <== eq[44][i].out; + multi_or[13][i].in[4] <== eq[45][i].out; + multi_or[13][i].in[5] <== eq[46][i].out; + multi_or[13][i].in[6] <== eq[47][i].out; + multi_or[13][i].in[7] <== eq[48][i].out; + multi_or[13][i].in[8] <== eq[49][i].out; + multi_or[13][i].in[9] <== eq[50][i].out; + multi_or[13][i].in[10] <== eq[29][i].out; + multi_or[13][i].in[11] <== eq[30][i].out; + multi_or[13][i].in[12] <== eq[13][i].out; + multi_or[13][i].in[13] <== eq[31][i].out; + multi_or[13][i].in[14] <== eq[32][i].out; + multi_or[13][i].in[15] <== eq[33][i].out; + multi_or[13][i].in[16] <== eq[34][i].out; + multi_or[13][i].in[17] <== eq[35][i].out; + multi_or[13][i].in[18] <== eq[36][i].out; + multi_or[13][i].in[19] <== eq[37][i].out; + multi_or[13][i].in[20] <== eq[38][i].out; + multi_or[13][i].in[21] <== eq[39][i].out; + multi_or[13][i].in[22] <== eq[40][i].out; + multi_or[13][i].in[23] <== eq[16][i].out; + multi_or[13][i].in[24] <== eq[17][i].out; + and[28][i].b <== multi_or[13][i].out; multi_or[14][i] = MultiOR(2); - multi_or[14][i].in[0] <== and[38][i].out; - multi_or[14][i].in[1] <== and[41][i].out; + multi_or[14][i].in[0] <== and[27][i].out; + multi_or[14][i].in[1] <== and[28][i].out; states[i+1][5] <== multi_or[14][i].out; state_changed[i].in[4] <== states[i+1][5]; - eq[208][i] = IsEqual(); - eq[208][i].in[0] <== in[i]; - eq[208][i].in[1] <== 64; - and[42][i] = AND(); - and[42][i].a <== states[i][5]; - and[42][i].b <== eq[208][i].out; - states[i+1][6] <== and[42][i].out; + and[29][i] = AND(); + and[29][i].a <== states[i][5]; + and[29][i].b <== eq[18][i].out; + states[i+1][6] <== and[29][i].out; state_changed[i].in[5] <== states[i+1][6]; states[i+1][0] <== 1 - state_changed[i].out; } diff --git a/packages/circom/circuits/common/email_domain_regex.circom b/packages/circom/circuits/common/email_domain_regex.circom index 1af82a6..4bfddd6 100644 --- a/packages/circom/circuits/common/email_domain_regex.circom +++ b/packages/circom/circuits/common/email_domain_regex.circom @@ -13,9 +13,9 @@ template EmailDomainRegex(msg_bytes) { in[i+1] <== msg[i]; } - component eq[72][num_bytes]; - component lt[20][num_bytes]; - component and[15][num_bytes]; + component eq[25][num_bytes]; + component lt[8][num_bytes]; + component and[9][num_bytes]; component multi_or[6][num_bytes]; signal states[num_bytes+1][4]; component state_changed[num_bytes]; @@ -148,301 +148,106 @@ template EmailDomainRegex(msg_bytes) { multi_or[0][i].in[25] <== eq[23][i].out; and[2][i].b <== multi_or[0][i].out; lt[4][i] = LessEqThan(8); - lt[4][i].in[0] <== 65; + lt[4][i].in[0] <== 94; lt[4][i].in[1] <== in[i]; lt[5][i] = LessEqThan(8); lt[5][i].in[0] <== in[i]; - lt[5][i].in[1] <== 90; + lt[5][i].in[1] <== 126; and[3][i] = AND(); and[3][i].a <== lt[4][i].out; and[3][i].b <== lt[5][i].out; - lt[6][i] = LessEqThan(8); - lt[6][i].in[0] <== 94; - lt[6][i].in[1] <== in[i]; - lt[7][i] = LessEqThan(8); - lt[7][i].in[0] <== in[i]; - lt[7][i].in[1] <== 126; and[4][i] = AND(); - and[4][i].a <== lt[6][i].out; - and[4][i].b <== lt[7][i].out; - lt[8][i] = LessEqThan(8); - lt[8][i].in[0] <== 65; - lt[8][i].in[1] <== in[i]; - lt[9][i] = LessEqThan(8); - lt[9][i].in[0] <== in[i]; - lt[9][i].in[1] <== 90; - and[5][i] = AND(); - and[5][i].a <== lt[8][i].out; - and[5][i].b <== lt[9][i].out; - lt[10][i] = LessEqThan(8); - lt[10][i].in[0] <== 95; - lt[10][i].in[1] <== in[i]; - lt[11][i] = LessEqThan(8); - lt[11][i].in[0] <== in[i]; - lt[11][i].in[1] <== 126; - and[6][i] = AND(); - and[6][i].a <== lt[10][i].out; - and[6][i].b <== lt[11][i].out; - eq[24][i] = IsEqual(); - eq[24][i].in[0] <== in[i]; - eq[24][i].in[1] <== 33; - eq[25][i] = IsEqual(); - eq[25][i].in[0] <== in[i]; - eq[25][i].in[1] <== 35; - eq[26][i] = IsEqual(); - eq[26][i].in[0] <== in[i]; - eq[26][i].in[1] <== 36; - eq[27][i] = IsEqual(); - eq[27][i].in[0] <== in[i]; - eq[27][i].in[1] <== 37; - eq[28][i] = IsEqual(); - eq[28][i].in[0] <== in[i]; - eq[28][i].in[1] <== 38; - eq[29][i] = IsEqual(); - eq[29][i].in[0] <== in[i]; - eq[29][i].in[1] <== 39; - eq[30][i] = IsEqual(); - eq[30][i].in[0] <== in[i]; - eq[30][i].in[1] <== 42; - eq[31][i] = IsEqual(); - eq[31][i].in[0] <== in[i]; - eq[31][i].in[1] <== 43; - eq[32][i] = IsEqual(); - eq[32][i].in[0] <== in[i]; - eq[32][i].in[1] <== 45; - eq[33][i] = IsEqual(); - eq[33][i].in[0] <== in[i]; - eq[33][i].in[1] <== 46; - eq[34][i] = IsEqual(); - eq[34][i].in[0] <== in[i]; - eq[34][i].in[1] <== 47; - eq[35][i] = IsEqual(); - eq[35][i].in[0] <== in[i]; - eq[35][i].in[1] <== 48; - eq[36][i] = IsEqual(); - eq[36][i].in[0] <== in[i]; - eq[36][i].in[1] <== 49; - eq[37][i] = IsEqual(); - eq[37][i].in[0] <== in[i]; - eq[37][i].in[1] <== 50; - eq[38][i] = IsEqual(); - eq[38][i].in[0] <== in[i]; - eq[38][i].in[1] <== 51; - eq[39][i] = IsEqual(); - eq[39][i].in[0] <== in[i]; - eq[39][i].in[1] <== 52; - eq[40][i] = IsEqual(); - eq[40][i].in[0] <== in[i]; - eq[40][i].in[1] <== 53; - eq[41][i] = IsEqual(); - eq[41][i].in[0] <== in[i]; - eq[41][i].in[1] <== 54; - eq[42][i] = IsEqual(); - eq[42][i].in[0] <== in[i]; - eq[42][i].in[1] <== 55; - eq[43][i] = IsEqual(); - eq[43][i].in[0] <== in[i]; - eq[43][i].in[1] <== 56; - eq[44][i] = IsEqual(); - eq[44][i].in[0] <== in[i]; - eq[44][i].in[1] <== 57; - eq[45][i] = IsEqual(); - eq[45][i].in[0] <== in[i]; - eq[45][i].in[1] <== 61; - eq[46][i] = IsEqual(); - eq[46][i].in[0] <== in[i]; - eq[46][i].in[1] <== 63; - and[7][i] = AND(); - and[7][i].a <== states[i][1]; + and[4][i].a <== states[i][1]; multi_or[1][i] = MultiOR(27); - multi_or[1][i].in[0] <== and[3][i].out; - multi_or[1][i].in[1] <== and[4][i].out; - multi_or[1][i].in[2] <== and[5][i].out; - multi_or[1][i].in[3] <== and[6][i].out; - multi_or[1][i].in[4] <== eq[24][i].out; - multi_or[1][i].in[5] <== eq[25][i].out; - multi_or[1][i].in[6] <== eq[26][i].out; - multi_or[1][i].in[7] <== eq[27][i].out; - multi_or[1][i].in[8] <== eq[28][i].out; - multi_or[1][i].in[9] <== eq[29][i].out; - multi_or[1][i].in[10] <== eq[30][i].out; - multi_or[1][i].in[11] <== eq[31][i].out; - multi_or[1][i].in[12] <== eq[32][i].out; - multi_or[1][i].in[13] <== eq[33][i].out; - multi_or[1][i].in[14] <== eq[34][i].out; - multi_or[1][i].in[15] <== eq[35][i].out; - multi_or[1][i].in[16] <== eq[36][i].out; - multi_or[1][i].in[17] <== eq[37][i].out; - multi_or[1][i].in[18] <== eq[38][i].out; - multi_or[1][i].in[19] <== eq[39][i].out; - multi_or[1][i].in[20] <== eq[40][i].out; - multi_or[1][i].in[21] <== eq[41][i].out; - multi_or[1][i].in[22] <== eq[42][i].out; - multi_or[1][i].in[23] <== eq[43][i].out; - multi_or[1][i].in[24] <== eq[44][i].out; - multi_or[1][i].in[25] <== eq[45][i].out; - multi_or[1][i].in[26] <== eq[46][i].out; - and[7][i].b <== multi_or[1][i].out; + multi_or[1][i].in[0] <== and[0][i].out; + multi_or[1][i].in[1] <== and[3][i].out; + multi_or[1][i].in[2] <== and[0][i].out; + multi_or[1][i].in[3] <== and[1][i].out; + multi_or[1][i].in[4] <== eq[0][i].out; + multi_or[1][i].in[5] <== eq[1][i].out; + multi_or[1][i].in[6] <== eq[2][i].out; + multi_or[1][i].in[7] <== eq[3][i].out; + multi_or[1][i].in[8] <== eq[4][i].out; + multi_or[1][i].in[9] <== eq[5][i].out; + multi_or[1][i].in[10] <== eq[6][i].out; + multi_or[1][i].in[11] <== eq[7][i].out; + multi_or[1][i].in[12] <== eq[8][i].out; + multi_or[1][i].in[13] <== eq[9][i].out; + multi_or[1][i].in[14] <== eq[10][i].out; + multi_or[1][i].in[15] <== eq[11][i].out; + multi_or[1][i].in[16] <== eq[12][i].out; + multi_or[1][i].in[17] <== eq[13][i].out; + multi_or[1][i].in[18] <== eq[14][i].out; + multi_or[1][i].in[19] <== eq[15][i].out; + multi_or[1][i].in[20] <== eq[16][i].out; + multi_or[1][i].in[21] <== eq[17][i].out; + multi_or[1][i].in[22] <== eq[18][i].out; + multi_or[1][i].in[23] <== eq[19][i].out; + multi_or[1][i].in[24] <== eq[20][i].out; + multi_or[1][i].in[25] <== eq[21][i].out; + multi_or[1][i].in[26] <== eq[22][i].out; + and[4][i].b <== multi_or[1][i].out; multi_or[2][i] = MultiOR(2); multi_or[2][i].in[0] <== and[2][i].out; - multi_or[2][i].in[1] <== and[7][i].out; + multi_or[2][i].in[1] <== and[4][i].out; states[i+1][1] <== multi_or[2][i].out; state_changed[i].in[0] <== states[i+1][1]; - eq[47][i] = IsEqual(); - eq[47][i].in[0] <== in[i]; - eq[47][i].in[1] <== 64; - and[8][i] = AND(); - and[8][i].a <== states[i][1]; - and[8][i].b <== eq[47][i].out; - states[i+1][2] <== and[8][i].out; + eq[24][i] = IsEqual(); + eq[24][i].in[0] <== in[i]; + eq[24][i].in[1] <== 64; + and[5][i] = AND(); + and[5][i].a <== states[i][1]; + and[5][i].b <== eq[24][i].out; + states[i+1][2] <== and[5][i].out; state_changed[i].in[1] <== states[i+1][2]; - lt[12][i] = LessEqThan(8); - lt[12][i].in[0] <== 65; - lt[12][i].in[1] <== in[i]; - lt[13][i] = LessEqThan(8); - lt[13][i].in[0] <== in[i]; - lt[13][i].in[1] <== 90; - and[9][i] = AND(); - and[9][i].a <== lt[12][i].out; - and[9][i].b <== lt[13][i].out; - lt[14][i] = LessEqThan(8); - lt[14][i].in[0] <== 97; - lt[14][i].in[1] <== in[i]; - lt[15][i] = LessEqThan(8); - lt[15][i].in[0] <== in[i]; - lt[15][i].in[1] <== 122; - and[10][i] = AND(); - and[10][i].a <== lt[14][i].out; - and[10][i].b <== lt[15][i].out; - eq[48][i] = IsEqual(); - eq[48][i].in[0] <== in[i]; - eq[48][i].in[1] <== 45; - eq[49][i] = IsEqual(); - eq[49][i].in[0] <== in[i]; - eq[49][i].in[1] <== 46; - eq[50][i] = IsEqual(); - eq[50][i].in[0] <== in[i]; - eq[50][i].in[1] <== 48; - eq[51][i] = IsEqual(); - eq[51][i].in[0] <== in[i]; - eq[51][i].in[1] <== 49; - eq[52][i] = IsEqual(); - eq[52][i].in[0] <== in[i]; - eq[52][i].in[1] <== 50; - eq[53][i] = IsEqual(); - eq[53][i].in[0] <== in[i]; - eq[53][i].in[1] <== 51; - eq[54][i] = IsEqual(); - eq[54][i].in[0] <== in[i]; - eq[54][i].in[1] <== 52; - eq[55][i] = IsEqual(); - eq[55][i].in[0] <== in[i]; - eq[55][i].in[1] <== 53; - eq[56][i] = IsEqual(); - eq[56][i].in[0] <== in[i]; - eq[56][i].in[1] <== 54; - eq[57][i] = IsEqual(); - eq[57][i].in[0] <== in[i]; - eq[57][i].in[1] <== 55; - eq[58][i] = IsEqual(); - eq[58][i].in[0] <== in[i]; - eq[58][i].in[1] <== 56; - eq[59][i] = IsEqual(); - eq[59][i].in[0] <== in[i]; - eq[59][i].in[1] <== 57; - and[11][i] = AND(); - and[11][i].a <== states[i][2]; + lt[6][i] = LessEqThan(8); + lt[6][i].in[0] <== 97; + lt[6][i].in[1] <== in[i]; + lt[7][i] = LessEqThan(8); + lt[7][i].in[0] <== in[i]; + lt[7][i].in[1] <== 122; + and[6][i] = AND(); + and[6][i].a <== lt[6][i].out; + and[6][i].b <== lt[7][i].out; + and[7][i] = AND(); + and[7][i].a <== states[i][2]; multi_or[3][i] = MultiOR(14); - multi_or[3][i].in[0] <== and[9][i].out; - multi_or[3][i].in[1] <== and[10][i].out; - multi_or[3][i].in[2] <== eq[48][i].out; - multi_or[3][i].in[3] <== eq[49][i].out; - multi_or[3][i].in[4] <== eq[50][i].out; - multi_or[3][i].in[5] <== eq[51][i].out; - multi_or[3][i].in[6] <== eq[52][i].out; - multi_or[3][i].in[7] <== eq[53][i].out; - multi_or[3][i].in[8] <== eq[54][i].out; - multi_or[3][i].in[9] <== eq[55][i].out; - multi_or[3][i].in[10] <== eq[56][i].out; - multi_or[3][i].in[11] <== eq[57][i].out; - multi_or[3][i].in[12] <== eq[58][i].out; - multi_or[3][i].in[13] <== eq[59][i].out; - and[11][i].b <== multi_or[3][i].out; - lt[16][i] = LessEqThan(8); - lt[16][i].in[0] <== 65; - lt[16][i].in[1] <== in[i]; - lt[17][i] = LessEqThan(8); - lt[17][i].in[0] <== in[i]; - lt[17][i].in[1] <== 90; - and[12][i] = AND(); - and[12][i].a <== lt[16][i].out; - and[12][i].b <== lt[17][i].out; - lt[18][i] = LessEqThan(8); - lt[18][i].in[0] <== 97; - lt[18][i].in[1] <== in[i]; - lt[19][i] = LessEqThan(8); - lt[19][i].in[0] <== in[i]; - lt[19][i].in[1] <== 122; - and[13][i] = AND(); - and[13][i].a <== lt[18][i].out; - and[13][i].b <== lt[19][i].out; - eq[60][i] = IsEqual(); - eq[60][i].in[0] <== in[i]; - eq[60][i].in[1] <== 45; - eq[61][i] = IsEqual(); - eq[61][i].in[0] <== in[i]; - eq[61][i].in[1] <== 46; - eq[62][i] = IsEqual(); - eq[62][i].in[0] <== in[i]; - eq[62][i].in[1] <== 48; - eq[63][i] = IsEqual(); - eq[63][i].in[0] <== in[i]; - eq[63][i].in[1] <== 49; - eq[64][i] = IsEqual(); - eq[64][i].in[0] <== in[i]; - eq[64][i].in[1] <== 50; - eq[65][i] = IsEqual(); - eq[65][i].in[0] <== in[i]; - eq[65][i].in[1] <== 51; - eq[66][i] = IsEqual(); - eq[66][i].in[0] <== in[i]; - eq[66][i].in[1] <== 52; - eq[67][i] = IsEqual(); - eq[67][i].in[0] <== in[i]; - eq[67][i].in[1] <== 53; - eq[68][i] = IsEqual(); - eq[68][i].in[0] <== in[i]; - eq[68][i].in[1] <== 54; - eq[69][i] = IsEqual(); - eq[69][i].in[0] <== in[i]; - eq[69][i].in[1] <== 55; - eq[70][i] = IsEqual(); - eq[70][i].in[0] <== in[i]; - eq[70][i].in[1] <== 56; - eq[71][i] = IsEqual(); - eq[71][i].in[0] <== in[i]; - eq[71][i].in[1] <== 57; - and[14][i] = AND(); - and[14][i].a <== states[i][3]; + multi_or[3][i].in[0] <== and[0][i].out; + multi_or[3][i].in[1] <== and[6][i].out; + multi_or[3][i].in[2] <== eq[8][i].out; + multi_or[3][i].in[3] <== eq[9][i].out; + multi_or[3][i].in[4] <== eq[11][i].out; + multi_or[3][i].in[5] <== eq[12][i].out; + multi_or[3][i].in[6] <== eq[13][i].out; + multi_or[3][i].in[7] <== eq[14][i].out; + multi_or[3][i].in[8] <== eq[15][i].out; + multi_or[3][i].in[9] <== eq[16][i].out; + multi_or[3][i].in[10] <== eq[17][i].out; + multi_or[3][i].in[11] <== eq[18][i].out; + multi_or[3][i].in[12] <== eq[19][i].out; + multi_or[3][i].in[13] <== eq[20][i].out; + and[7][i].b <== multi_or[3][i].out; + and[8][i] = AND(); + and[8][i].a <== states[i][3]; multi_or[4][i] = MultiOR(14); - multi_or[4][i].in[0] <== and[12][i].out; - multi_or[4][i].in[1] <== and[13][i].out; - multi_or[4][i].in[2] <== eq[60][i].out; - multi_or[4][i].in[3] <== eq[61][i].out; - multi_or[4][i].in[4] <== eq[62][i].out; - multi_or[4][i].in[5] <== eq[63][i].out; - multi_or[4][i].in[6] <== eq[64][i].out; - multi_or[4][i].in[7] <== eq[65][i].out; - multi_or[4][i].in[8] <== eq[66][i].out; - multi_or[4][i].in[9] <== eq[67][i].out; - multi_or[4][i].in[10] <== eq[68][i].out; - multi_or[4][i].in[11] <== eq[69][i].out; - multi_or[4][i].in[12] <== eq[70][i].out; - multi_or[4][i].in[13] <== eq[71][i].out; - and[14][i].b <== multi_or[4][i].out; + multi_or[4][i].in[0] <== and[0][i].out; + multi_or[4][i].in[1] <== and[6][i].out; + multi_or[4][i].in[2] <== eq[8][i].out; + multi_or[4][i].in[3] <== eq[9][i].out; + multi_or[4][i].in[4] <== eq[11][i].out; + multi_or[4][i].in[5] <== eq[12][i].out; + multi_or[4][i].in[6] <== eq[13][i].out; + multi_or[4][i].in[7] <== eq[14][i].out; + multi_or[4][i].in[8] <== eq[15][i].out; + multi_or[4][i].in[9] <== eq[16][i].out; + multi_or[4][i].in[10] <== eq[17][i].out; + multi_or[4][i].in[11] <== eq[18][i].out; + multi_or[4][i].in[12] <== eq[19][i].out; + multi_or[4][i].in[13] <== eq[20][i].out; + and[8][i].b <== multi_or[4][i].out; multi_or[5][i] = MultiOR(2); - multi_or[5][i].in[0] <== and[11][i].out; - multi_or[5][i].in[1] <== and[14][i].out; + multi_or[5][i].in[0] <== and[7][i].out; + multi_or[5][i].in[1] <== and[8][i].out; states[i+1][3] <== multi_or[5][i].out; state_changed[i].in[2] <== states[i+1][3]; states[i+1][0] <== 1 - state_changed[i].out; diff --git a/packages/circom/circuits/common/from_all_regex.circom b/packages/circom/circuits/common/from_all_regex.circom index 66cf2e8..3fefad0 100644 --- a/packages/circom/circuits/common/from_all_regex.circom +++ b/packages/circom/circuits/common/from_all_regex.circom @@ -13,9 +13,9 @@ template FromAllRegex(msg_bytes) { in[i+1] <== msg[i]; } - component eq[35][num_bytes]; - component lt[4][num_bytes]; - component and[15][num_bytes]; + component eq[20][num_bytes]; + component lt[2][num_bytes]; + component and[14][num_bytes]; component multi_or[5][num_bytes]; signal states[num_bytes+1][11]; component state_changed[num_bytes]; @@ -89,162 +89,108 @@ template FromAllRegex(msg_bytes) { multi_or[0][i].in[11] <== eq[10][i].out; multi_or[0][i].in[12] <== eq[11][i].out; and[1][i].b <== multi_or[0][i].out; - lt[2][i] = LessEqThan(8); - lt[2][i].in[0] <== 14; - lt[2][i].in[1] <== in[i]; - lt[3][i] = LessEqThan(8); - lt[3][i].in[0] <== in[i]; - lt[3][i].in[1] <== 254; and[2][i] = AND(); - and[2][i].a <== lt[2][i].out; - and[2][i].b <== lt[3][i].out; - eq[12][i] = IsEqual(); - eq[12][i].in[0] <== in[i]; - eq[12][i].in[1] <== 0; - eq[13][i] = IsEqual(); - eq[13][i].in[0] <== in[i]; - eq[13][i].in[1] <== 1; - eq[14][i] = IsEqual(); - eq[14][i].in[0] <== in[i]; - eq[14][i].in[1] <== 2; - eq[15][i] = IsEqual(); - eq[15][i].in[0] <== in[i]; - eq[15][i].in[1] <== 3; - eq[16][i] = IsEqual(); - eq[16][i].in[0] <== in[i]; - eq[16][i].in[1] <== 4; - eq[17][i] = IsEqual(); - eq[17][i].in[0] <== in[i]; - eq[17][i].in[1] <== 5; - eq[18][i] = IsEqual(); - eq[18][i].in[0] <== in[i]; - eq[18][i].in[1] <== 6; - eq[19][i] = IsEqual(); - eq[19][i].in[0] <== in[i]; - eq[19][i].in[1] <== 7; - eq[20][i] = IsEqual(); - eq[20][i].in[0] <== in[i]; - eq[20][i].in[1] <== 8; - eq[21][i] = IsEqual(); - eq[21][i].in[0] <== in[i]; - eq[21][i].in[1] <== 9; - eq[22][i] = IsEqual(); - eq[22][i].in[0] <== in[i]; - eq[22][i].in[1] <== 11; - eq[23][i] = IsEqual(); - eq[23][i].in[0] <== in[i]; - eq[23][i].in[1] <== 12; - and[3][i] = AND(); - and[3][i].a <== states[i][8]; + and[2][i].a <== states[i][8]; multi_or[1][i] = MultiOR(13); - multi_or[1][i].in[0] <== and[2][i].out; - multi_or[1][i].in[1] <== eq[12][i].out; - multi_or[1][i].in[2] <== eq[13][i].out; - multi_or[1][i].in[3] <== eq[14][i].out; - multi_or[1][i].in[4] <== eq[15][i].out; - multi_or[1][i].in[5] <== eq[16][i].out; - multi_or[1][i].in[6] <== eq[17][i].out; - multi_or[1][i].in[7] <== eq[18][i].out; - multi_or[1][i].in[8] <== eq[19][i].out; - multi_or[1][i].in[9] <== eq[20][i].out; - multi_or[1][i].in[10] <== eq[21][i].out; - multi_or[1][i].in[11] <== eq[22][i].out; - multi_or[1][i].in[12] <== eq[23][i].out; - and[3][i].b <== multi_or[1][i].out; + multi_or[1][i].in[0] <== and[0][i].out; + multi_or[1][i].in[1] <== eq[0][i].out; + multi_or[1][i].in[2] <== eq[1][i].out; + multi_or[1][i].in[3] <== eq[2][i].out; + multi_or[1][i].in[4] <== eq[3][i].out; + multi_or[1][i].in[5] <== eq[4][i].out; + multi_or[1][i].in[6] <== eq[5][i].out; + multi_or[1][i].in[7] <== eq[6][i].out; + multi_or[1][i].in[8] <== eq[7][i].out; + multi_or[1][i].in[9] <== eq[8][i].out; + multi_or[1][i].in[10] <== eq[9][i].out; + multi_or[1][i].in[11] <== eq[10][i].out; + multi_or[1][i].in[12] <== eq[11][i].out; + and[2][i].b <== multi_or[1][i].out; multi_or[2][i] = MultiOR(2); multi_or[2][i].in[0] <== and[1][i].out; - multi_or[2][i].in[1] <== and[3][i].out; + multi_or[2][i].in[1] <== and[2][i].out; states[i+1][1] <== multi_or[2][i].out; state_changed[i].in[0] <== states[i+1][1]; - eq[24][i] = IsEqual(); - eq[24][i].in[0] <== in[i]; - eq[24][i].in[1] <== 13; + eq[12][i] = IsEqual(); + eq[12][i].in[0] <== in[i]; + eq[12][i].in[1] <== 13; + and[3][i] = AND(); + and[3][i].a <== states[i][0]; + and[3][i].b <== eq[12][i].out; and[4][i] = AND(); - and[4][i].a <== states[i][0]; - and[4][i].b <== eq[24][i].out; - eq[25][i] = IsEqual(); - eq[25][i].in[0] <== in[i]; - eq[25][i].in[1] <== 13; - and[5][i] = AND(); - and[5][i].a <== states[i][3]; - and[5][i].b <== eq[25][i].out; + and[4][i].a <== states[i][3]; + and[4][i].b <== eq[12][i].out; multi_or[3][i] = MultiOR(2); - multi_or[3][i].in[0] <== and[4][i].out; - multi_or[3][i].in[1] <== and[5][i].out; + multi_or[3][i].in[0] <== and[3][i].out; + multi_or[3][i].in[1] <== and[4][i].out; states[i+1][2] <== multi_or[3][i].out; state_changed[i].in[1] <== states[i+1][2]; - eq[26][i] = IsEqual(); - eq[26][i].in[0] <== in[i]; - eq[26][i].in[1] <== 255; + eq[13][i] = IsEqual(); + eq[13][i].in[0] <== in[i]; + eq[13][i].in[1] <== 255; + and[5][i] = AND(); + and[5][i].a <== states[i][0]; + and[5][i].b <== eq[13][i].out; + eq[14][i] = IsEqual(); + eq[14][i].in[0] <== in[i]; + eq[14][i].in[1] <== 10; and[6][i] = AND(); - and[6][i].a <== states[i][0]; - and[6][i].b <== eq[26][i].out; - eq[27][i] = IsEqual(); - eq[27][i].in[0] <== in[i]; - eq[27][i].in[1] <== 10; - and[7][i] = AND(); - and[7][i].a <== states[i][2]; - and[7][i].b <== eq[27][i].out; + and[6][i].a <== states[i][2]; + and[6][i].b <== eq[14][i].out; multi_or[4][i] = MultiOR(2); - multi_or[4][i].in[0] <== and[6][i].out; - multi_or[4][i].in[1] <== and[7][i].out; + multi_or[4][i].in[0] <== and[5][i].out; + multi_or[4][i].in[1] <== and[6][i].out; states[i+1][3] <== multi_or[4][i].out; state_changed[i].in[2] <== states[i+1][3]; - eq[28][i] = IsEqual(); - eq[28][i].in[0] <== in[i]; - eq[28][i].in[1] <== 102; - and[8][i] = AND(); - and[8][i].a <== states[i][3]; - and[8][i].b <== eq[28][i].out; - states[i+1][4] <== and[8][i].out; + eq[15][i] = IsEqual(); + eq[15][i].in[0] <== in[i]; + eq[15][i].in[1] <== 102; + and[7][i] = AND(); + and[7][i].a <== states[i][3]; + and[7][i].b <== eq[15][i].out; + states[i+1][4] <== and[7][i].out; state_changed[i].in[3] <== states[i+1][4]; - eq[29][i] = IsEqual(); - eq[29][i].in[0] <== in[i]; - eq[29][i].in[1] <== 114; - and[9][i] = AND(); - and[9][i].a <== states[i][4]; - and[9][i].b <== eq[29][i].out; - states[i+1][5] <== and[9][i].out; + eq[16][i] = IsEqual(); + eq[16][i].in[0] <== in[i]; + eq[16][i].in[1] <== 114; + and[8][i] = AND(); + and[8][i].a <== states[i][4]; + and[8][i].b <== eq[16][i].out; + states[i+1][5] <== and[8][i].out; state_changed[i].in[4] <== states[i+1][5]; - eq[30][i] = IsEqual(); - eq[30][i].in[0] <== in[i]; - eq[30][i].in[1] <== 111; - and[10][i] = AND(); - and[10][i].a <== states[i][5]; - and[10][i].b <== eq[30][i].out; - states[i+1][6] <== and[10][i].out; + eq[17][i] = IsEqual(); + eq[17][i].in[0] <== in[i]; + eq[17][i].in[1] <== 111; + and[9][i] = AND(); + and[9][i].a <== states[i][5]; + and[9][i].b <== eq[17][i].out; + states[i+1][6] <== and[9][i].out; state_changed[i].in[5] <== states[i+1][6]; - eq[31][i] = IsEqual(); - eq[31][i].in[0] <== in[i]; - eq[31][i].in[1] <== 109; - and[11][i] = AND(); - and[11][i].a <== states[i][6]; - and[11][i].b <== eq[31][i].out; - states[i+1][7] <== and[11][i].out; + eq[18][i] = IsEqual(); + eq[18][i].in[0] <== in[i]; + eq[18][i].in[1] <== 109; + and[10][i] = AND(); + and[10][i].a <== states[i][6]; + and[10][i].b <== eq[18][i].out; + states[i+1][7] <== and[10][i].out; state_changed[i].in[6] <== states[i+1][7]; - eq[32][i] = IsEqual(); - eq[32][i].in[0] <== in[i]; - eq[32][i].in[1] <== 58; - and[12][i] = AND(); - and[12][i].a <== states[i][7]; - and[12][i].b <== eq[32][i].out; - states[i+1][8] <== and[12][i].out; + eq[19][i] = IsEqual(); + eq[19][i].in[0] <== in[i]; + eq[19][i].in[1] <== 58; + and[11][i] = AND(); + and[11][i].a <== states[i][7]; + and[11][i].b <== eq[19][i].out; + states[i+1][8] <== and[11][i].out; state_changed[i].in[7] <== states[i+1][8]; - eq[33][i] = IsEqual(); - eq[33][i].in[0] <== in[i]; - eq[33][i].in[1] <== 13; - and[13][i] = AND(); - and[13][i].a <== states[i][1]; - and[13][i].b <== eq[33][i].out; - states[i+1][9] <== and[13][i].out; + and[12][i] = AND(); + and[12][i].a <== states[i][1]; + and[12][i].b <== eq[12][i].out; + states[i+1][9] <== and[12][i].out; state_changed[i].in[8] <== states[i+1][9]; - eq[34][i] = IsEqual(); - eq[34][i].in[0] <== in[i]; - eq[34][i].in[1] <== 10; - and[14][i] = AND(); - and[14][i].a <== states[i][9]; - and[14][i].b <== eq[34][i].out; - states[i+1][10] <== and[14][i].out; + and[13][i] = AND(); + and[13][i].a <== states[i][9]; + and[13][i].b <== eq[14][i].out; + states[i+1][10] <== and[13][i].out; state_changed[i].in[9] <== states[i+1][10]; states[i+1][0] <== 1 - state_changed[i].out; } diff --git a/packages/circom/circuits/common/message_id_regex.circom b/packages/circom/circuits/common/message_id_regex.circom index 59efbfd..3038867 100644 --- a/packages/circom/circuits/common/message_id_regex.circom +++ b/packages/circom/circuits/common/message_id_regex.circom @@ -13,9 +13,9 @@ template MessageIdRegex(msg_bytes) { in[i+1] <== msg[i]; } - component eq[49][num_bytes]; - component lt[8][num_bytes]; - component and[25][num_bytes]; + component eq[28][num_bytes]; + component lt[4][num_bytes]; + component and[23][num_bytes]; component multi_or[5][num_bytes]; signal states[num_bytes+1][19]; component state_changed[num_bytes]; @@ -111,248 +111,167 @@ template MessageIdRegex(msg_bytes) { multi_or[0][i].in[15] <== eq[13][i].out; multi_or[0][i].in[16] <== eq[14][i].out; and[2][i].b <== multi_or[0][i].out; - lt[4][i] = LessEqThan(8); - lt[4][i].in[0] <== 64; - lt[4][i].in[1] <== in[i]; - lt[5][i] = LessEqThan(8); - lt[5][i].in[0] <== in[i]; - lt[5][i].in[1] <== 90; and[3][i] = AND(); - and[3][i].a <== lt[4][i].out; - and[3][i].b <== lt[5][i].out; - lt[6][i] = LessEqThan(8); - lt[6][i].in[0] <== 97; - lt[6][i].in[1] <== in[i]; - lt[7][i] = LessEqThan(8); - lt[7][i].in[0] <== in[i]; - lt[7][i].in[1] <== 122; - and[4][i] = AND(); - and[4][i].a <== lt[6][i].out; - and[4][i].b <== lt[7][i].out; + and[3][i].a <== states[i][18]; + multi_or[1][i] = MultiOR(17); + multi_or[1][i].in[0] <== and[0][i].out; + multi_or[1][i].in[1] <== and[1][i].out; + multi_or[1][i].in[2] <== eq[0][i].out; + multi_or[1][i].in[3] <== eq[1][i].out; + multi_or[1][i].in[4] <== eq[2][i].out; + multi_or[1][i].in[5] <== eq[3][i].out; + multi_or[1][i].in[6] <== eq[4][i].out; + multi_or[1][i].in[7] <== eq[5][i].out; + multi_or[1][i].in[8] <== eq[6][i].out; + multi_or[1][i].in[9] <== eq[7][i].out; + multi_or[1][i].in[10] <== eq[8][i].out; + multi_or[1][i].in[11] <== eq[9][i].out; + multi_or[1][i].in[12] <== eq[10][i].out; + multi_or[1][i].in[13] <== eq[11][i].out; + multi_or[1][i].in[14] <== eq[12][i].out; + multi_or[1][i].in[15] <== eq[13][i].out; + multi_or[1][i].in[16] <== eq[14][i].out; + and[3][i].b <== multi_or[1][i].out; + multi_or[2][i] = MultiOR(2); + multi_or[2][i].in[0] <== and[2][i].out; + multi_or[2][i].in[1] <== and[3][i].out; + states[i+1][1] <== multi_or[2][i].out; + state_changed[i].in[0] <== states[i+1][1]; eq[15][i] = IsEqual(); eq[15][i].in[0] <== in[i]; - eq[15][i].in[1] <== 43; + eq[15][i].in[1] <== 13; + and[4][i] = AND(); + and[4][i].a <== states[i][0]; + and[4][i].b <== eq[15][i].out; + and[5][i] = AND(); + and[5][i].a <== states[i][3]; + and[5][i].b <== eq[15][i].out; + multi_or[3][i] = MultiOR(2); + multi_or[3][i].in[0] <== and[4][i].out; + multi_or[3][i].in[1] <== and[5][i].out; + states[i+1][2] <== multi_or[3][i].out; + state_changed[i].in[1] <== states[i+1][2]; eq[16][i] = IsEqual(); eq[16][i].in[0] <== in[i]; - eq[16][i].in[1] <== 45; + eq[16][i].in[1] <== 255; + and[6][i] = AND(); + and[6][i].a <== states[i][0]; + and[6][i].b <== eq[16][i].out; eq[17][i] = IsEqual(); eq[17][i].in[0] <== in[i]; - eq[17][i].in[1] <== 46; + eq[17][i].in[1] <== 10; + and[7][i] = AND(); + and[7][i].a <== states[i][2]; + and[7][i].b <== eq[17][i].out; + multi_or[4][i] = MultiOR(2); + multi_or[4][i].in[0] <== and[6][i].out; + multi_or[4][i].in[1] <== and[7][i].out; + states[i+1][3] <== multi_or[4][i].out; + state_changed[i].in[2] <== states[i+1][3]; eq[18][i] = IsEqual(); eq[18][i].in[0] <== in[i]; - eq[18][i].in[1] <== 48; + eq[18][i].in[1] <== 62; + and[8][i] = AND(); + and[8][i].a <== states[i][1]; + and[8][i].b <== eq[18][i].out; + states[i+1][4] <== and[8][i].out; + state_changed[i].in[3] <== states[i+1][4]; eq[19][i] = IsEqual(); eq[19][i].in[0] <== in[i]; - eq[19][i].in[1] <== 49; + eq[19][i].in[1] <== 109; + and[9][i] = AND(); + and[9][i].a <== states[i][3]; + and[9][i].b <== eq[19][i].out; + states[i+1][5] <== and[9][i].out; + state_changed[i].in[4] <== states[i+1][5]; + and[10][i] = AND(); + and[10][i].a <== states[i][4]; + and[10][i].b <== eq[15][i].out; + states[i+1][6] <== and[10][i].out; + state_changed[i].in[5] <== states[i+1][6]; + and[11][i] = AND(); + and[11][i].a <== states[i][6]; + and[11][i].b <== eq[17][i].out; + states[i+1][7] <== and[11][i].out; + state_changed[i].in[6] <== states[i+1][7]; eq[20][i] = IsEqual(); eq[20][i].in[0] <== in[i]; - eq[20][i].in[1] <== 50; + eq[20][i].in[1] <== 101; + and[12][i] = AND(); + and[12][i].a <== states[i][5]; + and[12][i].b <== eq[20][i].out; + states[i+1][8] <== and[12][i].out; + state_changed[i].in[7] <== states[i+1][8]; eq[21][i] = IsEqual(); eq[21][i].in[0] <== in[i]; - eq[21][i].in[1] <== 51; + eq[21][i].in[1] <== 115; + and[13][i] = AND(); + and[13][i].a <== states[i][8]; + and[13][i].b <== eq[21][i].out; + states[i+1][9] <== and[13][i].out; + state_changed[i].in[8] <== states[i+1][9]; + and[14][i] = AND(); + and[14][i].a <== states[i][9]; + and[14][i].b <== eq[21][i].out; + states[i+1][10] <== and[14][i].out; + state_changed[i].in[9] <== states[i+1][10]; eq[22][i] = IsEqual(); eq[22][i].in[0] <== in[i]; - eq[22][i].in[1] <== 52; + eq[22][i].in[1] <== 97; + and[15][i] = AND(); + and[15][i].a <== states[i][10]; + and[15][i].b <== eq[22][i].out; + states[i+1][11] <== and[15][i].out; + state_changed[i].in[10] <== states[i+1][11]; eq[23][i] = IsEqual(); eq[23][i].in[0] <== in[i]; - eq[23][i].in[1] <== 53; + eq[23][i].in[1] <== 103; + and[16][i] = AND(); + and[16][i].a <== states[i][11]; + and[16][i].b <== eq[23][i].out; + states[i+1][12] <== and[16][i].out; + state_changed[i].in[11] <== states[i+1][12]; + and[17][i] = AND(); + and[17][i].a <== states[i][12]; + and[17][i].b <== eq[20][i].out; + states[i+1][13] <== and[17][i].out; + state_changed[i].in[12] <== states[i+1][13]; + and[18][i] = AND(); + and[18][i].a <== states[i][13]; + and[18][i].b <== eq[1][i].out; + states[i+1][14] <== and[18][i].out; + state_changed[i].in[13] <== states[i+1][14]; eq[24][i] = IsEqual(); eq[24][i].in[0] <== in[i]; - eq[24][i].in[1] <== 54; + eq[24][i].in[1] <== 105; + and[19][i] = AND(); + and[19][i].a <== states[i][14]; + and[19][i].b <== eq[24][i].out; + states[i+1][15] <== and[19][i].out; + state_changed[i].in[14] <== states[i+1][15]; eq[25][i] = IsEqual(); eq[25][i].in[0] <== in[i]; - eq[25][i].in[1] <== 55; + eq[25][i].in[1] <== 100; + and[20][i] = AND(); + and[20][i].a <== states[i][15]; + and[20][i].b <== eq[25][i].out; + states[i+1][16] <== and[20][i].out; + state_changed[i].in[15] <== states[i+1][16]; eq[26][i] = IsEqual(); eq[26][i].in[0] <== in[i]; - eq[26][i].in[1] <== 56; + eq[26][i].in[1] <== 58; + and[21][i] = AND(); + and[21][i].a <== states[i][16]; + and[21][i].b <== eq[26][i].out; + states[i+1][17] <== and[21][i].out; + state_changed[i].in[16] <== states[i+1][17]; eq[27][i] = IsEqual(); eq[27][i].in[0] <== in[i]; - eq[27][i].in[1] <== 57; - eq[28][i] = IsEqual(); - eq[28][i].in[0] <== in[i]; - eq[28][i].in[1] <== 61; - eq[29][i] = IsEqual(); - eq[29][i].in[0] <== in[i]; - eq[29][i].in[1] <== 95; - and[5][i] = AND(); - and[5][i].a <== states[i][18]; - multi_or[1][i] = MultiOR(17); - multi_or[1][i].in[0] <== and[3][i].out; - multi_or[1][i].in[1] <== and[4][i].out; - multi_or[1][i].in[2] <== eq[15][i].out; - multi_or[1][i].in[3] <== eq[16][i].out; - multi_or[1][i].in[4] <== eq[17][i].out; - multi_or[1][i].in[5] <== eq[18][i].out; - multi_or[1][i].in[6] <== eq[19][i].out; - multi_or[1][i].in[7] <== eq[20][i].out; - multi_or[1][i].in[8] <== eq[21][i].out; - multi_or[1][i].in[9] <== eq[22][i].out; - multi_or[1][i].in[10] <== eq[23][i].out; - multi_or[1][i].in[11] <== eq[24][i].out; - multi_or[1][i].in[12] <== eq[25][i].out; - multi_or[1][i].in[13] <== eq[26][i].out; - multi_or[1][i].in[14] <== eq[27][i].out; - multi_or[1][i].in[15] <== eq[28][i].out; - multi_or[1][i].in[16] <== eq[29][i].out; - and[5][i].b <== multi_or[1][i].out; - multi_or[2][i] = MultiOR(2); - multi_or[2][i].in[0] <== and[2][i].out; - multi_or[2][i].in[1] <== and[5][i].out; - states[i+1][1] <== multi_or[2][i].out; - state_changed[i].in[0] <== states[i+1][1]; - eq[30][i] = IsEqual(); - eq[30][i].in[0] <== in[i]; - eq[30][i].in[1] <== 13; - and[6][i] = AND(); - and[6][i].a <== states[i][0]; - and[6][i].b <== eq[30][i].out; - eq[31][i] = IsEqual(); - eq[31][i].in[0] <== in[i]; - eq[31][i].in[1] <== 13; - and[7][i] = AND(); - and[7][i].a <== states[i][3]; - and[7][i].b <== eq[31][i].out; - multi_or[3][i] = MultiOR(2); - multi_or[3][i].in[0] <== and[6][i].out; - multi_or[3][i].in[1] <== and[7][i].out; - states[i+1][2] <== multi_or[3][i].out; - state_changed[i].in[1] <== states[i+1][2]; - eq[32][i] = IsEqual(); - eq[32][i].in[0] <== in[i]; - eq[32][i].in[1] <== 255; - and[8][i] = AND(); - and[8][i].a <== states[i][0]; - and[8][i].b <== eq[32][i].out; - eq[33][i] = IsEqual(); - eq[33][i].in[0] <== in[i]; - eq[33][i].in[1] <== 10; - and[9][i] = AND(); - and[9][i].a <== states[i][2]; - and[9][i].b <== eq[33][i].out; - multi_or[4][i] = MultiOR(2); - multi_or[4][i].in[0] <== and[8][i].out; - multi_or[4][i].in[1] <== and[9][i].out; - states[i+1][3] <== multi_or[4][i].out; - state_changed[i].in[2] <== states[i+1][3]; - eq[34][i] = IsEqual(); - eq[34][i].in[0] <== in[i]; - eq[34][i].in[1] <== 62; - and[10][i] = AND(); - and[10][i].a <== states[i][1]; - and[10][i].b <== eq[34][i].out; - states[i+1][4] <== and[10][i].out; - state_changed[i].in[3] <== states[i+1][4]; - eq[35][i] = IsEqual(); - eq[35][i].in[0] <== in[i]; - eq[35][i].in[1] <== 109; - and[11][i] = AND(); - and[11][i].a <== states[i][3]; - and[11][i].b <== eq[35][i].out; - states[i+1][5] <== and[11][i].out; - state_changed[i].in[4] <== states[i+1][5]; - eq[36][i] = IsEqual(); - eq[36][i].in[0] <== in[i]; - eq[36][i].in[1] <== 13; - and[12][i] = AND(); - and[12][i].a <== states[i][4]; - and[12][i].b <== eq[36][i].out; - states[i+1][6] <== and[12][i].out; - state_changed[i].in[5] <== states[i+1][6]; - eq[37][i] = IsEqual(); - eq[37][i].in[0] <== in[i]; - eq[37][i].in[1] <== 10; - and[13][i] = AND(); - and[13][i].a <== states[i][6]; - and[13][i].b <== eq[37][i].out; - states[i+1][7] <== and[13][i].out; - state_changed[i].in[6] <== states[i+1][7]; - eq[38][i] = IsEqual(); - eq[38][i].in[0] <== in[i]; - eq[38][i].in[1] <== 101; - and[14][i] = AND(); - and[14][i].a <== states[i][5]; - and[14][i].b <== eq[38][i].out; - states[i+1][8] <== and[14][i].out; - state_changed[i].in[7] <== states[i+1][8]; - eq[39][i] = IsEqual(); - eq[39][i].in[0] <== in[i]; - eq[39][i].in[1] <== 115; - and[15][i] = AND(); - and[15][i].a <== states[i][8]; - and[15][i].b <== eq[39][i].out; - states[i+1][9] <== and[15][i].out; - state_changed[i].in[8] <== states[i+1][9]; - eq[40][i] = IsEqual(); - eq[40][i].in[0] <== in[i]; - eq[40][i].in[1] <== 115; - and[16][i] = AND(); - and[16][i].a <== states[i][9]; - and[16][i].b <== eq[40][i].out; - states[i+1][10] <== and[16][i].out; - state_changed[i].in[9] <== states[i+1][10]; - eq[41][i] = IsEqual(); - eq[41][i].in[0] <== in[i]; - eq[41][i].in[1] <== 97; - and[17][i] = AND(); - and[17][i].a <== states[i][10]; - and[17][i].b <== eq[41][i].out; - states[i+1][11] <== and[17][i].out; - state_changed[i].in[10] <== states[i+1][11]; - eq[42][i] = IsEqual(); - eq[42][i].in[0] <== in[i]; - eq[42][i].in[1] <== 103; - and[18][i] = AND(); - and[18][i].a <== states[i][11]; - and[18][i].b <== eq[42][i].out; - states[i+1][12] <== and[18][i].out; - state_changed[i].in[11] <== states[i+1][12]; - eq[43][i] = IsEqual(); - eq[43][i].in[0] <== in[i]; - eq[43][i].in[1] <== 101; - and[19][i] = AND(); - and[19][i].a <== states[i][12]; - and[19][i].b <== eq[43][i].out; - states[i+1][13] <== and[19][i].out; - state_changed[i].in[12] <== states[i+1][13]; - eq[44][i] = IsEqual(); - eq[44][i].in[0] <== in[i]; - eq[44][i].in[1] <== 45; - and[20][i] = AND(); - and[20][i].a <== states[i][13]; - and[20][i].b <== eq[44][i].out; - states[i+1][14] <== and[20][i].out; - state_changed[i].in[13] <== states[i+1][14]; - eq[45][i] = IsEqual(); - eq[45][i].in[0] <== in[i]; - eq[45][i].in[1] <== 105; - and[21][i] = AND(); - and[21][i].a <== states[i][14]; - and[21][i].b <== eq[45][i].out; - states[i+1][15] <== and[21][i].out; - state_changed[i].in[14] <== states[i+1][15]; - eq[46][i] = IsEqual(); - eq[46][i].in[0] <== in[i]; - eq[46][i].in[1] <== 100; + eq[27][i].in[1] <== 60; and[22][i] = AND(); - and[22][i].a <== states[i][15]; - and[22][i].b <== eq[46][i].out; - states[i+1][16] <== and[22][i].out; - state_changed[i].in[15] <== states[i+1][16]; - eq[47][i] = IsEqual(); - eq[47][i].in[0] <== in[i]; - eq[47][i].in[1] <== 58; - and[23][i] = AND(); - and[23][i].a <== states[i][16]; - and[23][i].b <== eq[47][i].out; - states[i+1][17] <== and[23][i].out; - state_changed[i].in[16] <== states[i+1][17]; - eq[48][i] = IsEqual(); - eq[48][i].in[0] <== in[i]; - eq[48][i].in[1] <== 60; - and[24][i] = AND(); - and[24][i].a <== states[i][17]; - and[24][i].b <== eq[48][i].out; - states[i+1][18] <== and[24][i].out; + and[22][i].a <== states[i][17]; + and[22][i].b <== eq[27][i].out; + states[i+1][18] <== and[22][i].out; state_changed[i].in[17] <== states[i+1][18]; states[i+1][0] <== 1 - state_changed[i].out; } diff --git a/packages/circom/circuits/common/subject_all_regex.circom b/packages/circom/circuits/common/subject_all_regex.circom index d03c6a1..6cf3c33 100644 --- a/packages/circom/circuits/common/subject_all_regex.circom +++ b/packages/circom/circuits/common/subject_all_regex.circom @@ -13,9 +13,9 @@ template SubjectAllRegex(msg_bytes) { in[i+1] <== msg[i]; } - component eq[38][num_bytes]; - component lt[4][num_bytes]; - component and[18][num_bytes]; + component eq[23][num_bytes]; + component lt[2][num_bytes]; + component and[17][num_bytes]; component multi_or[5][num_bytes]; signal states[num_bytes+1][14]; component state_changed[num_bytes]; @@ -89,186 +89,132 @@ template SubjectAllRegex(msg_bytes) { multi_or[0][i].in[11] <== eq[10][i].out; multi_or[0][i].in[12] <== eq[11][i].out; and[1][i].b <== multi_or[0][i].out; - lt[2][i] = LessEqThan(8); - lt[2][i].in[0] <== 14; - lt[2][i].in[1] <== in[i]; - lt[3][i] = LessEqThan(8); - lt[3][i].in[0] <== in[i]; - lt[3][i].in[1] <== 254; and[2][i] = AND(); - and[2][i].a <== lt[2][i].out; - and[2][i].b <== lt[3][i].out; + and[2][i].a <== states[i][12]; + multi_or[1][i] = MultiOR(13); + multi_or[1][i].in[0] <== and[0][i].out; + multi_or[1][i].in[1] <== eq[0][i].out; + multi_or[1][i].in[2] <== eq[1][i].out; + multi_or[1][i].in[3] <== eq[2][i].out; + multi_or[1][i].in[4] <== eq[3][i].out; + multi_or[1][i].in[5] <== eq[4][i].out; + multi_or[1][i].in[6] <== eq[5][i].out; + multi_or[1][i].in[7] <== eq[6][i].out; + multi_or[1][i].in[8] <== eq[7][i].out; + multi_or[1][i].in[9] <== eq[8][i].out; + multi_or[1][i].in[10] <== eq[9][i].out; + multi_or[1][i].in[11] <== eq[10][i].out; + multi_or[1][i].in[12] <== eq[11][i].out; + and[2][i].b <== multi_or[1][i].out; + multi_or[2][i] = MultiOR(2); + multi_or[2][i].in[0] <== and[1][i].out; + multi_or[2][i].in[1] <== and[2][i].out; + states[i+1][1] <== multi_or[2][i].out; + state_changed[i].in[0] <== states[i+1][1]; eq[12][i] = IsEqual(); eq[12][i].in[0] <== in[i]; - eq[12][i].in[1] <== 0; + eq[12][i].in[1] <== 13; + and[3][i] = AND(); + and[3][i].a <== states[i][0]; + and[3][i].b <== eq[12][i].out; + and[4][i] = AND(); + and[4][i].a <== states[i][3]; + and[4][i].b <== eq[12][i].out; + multi_or[3][i] = MultiOR(2); + multi_or[3][i].in[0] <== and[3][i].out; + multi_or[3][i].in[1] <== and[4][i].out; + states[i+1][2] <== multi_or[3][i].out; + state_changed[i].in[1] <== states[i+1][2]; eq[13][i] = IsEqual(); eq[13][i].in[0] <== in[i]; - eq[13][i].in[1] <== 1; + eq[13][i].in[1] <== 255; + and[5][i] = AND(); + and[5][i].a <== states[i][0]; + and[5][i].b <== eq[13][i].out; eq[14][i] = IsEqual(); eq[14][i].in[0] <== in[i]; - eq[14][i].in[1] <== 2; + eq[14][i].in[1] <== 10; + and[6][i] = AND(); + and[6][i].a <== states[i][2]; + and[6][i].b <== eq[14][i].out; + multi_or[4][i] = MultiOR(2); + multi_or[4][i].in[0] <== and[5][i].out; + multi_or[4][i].in[1] <== and[6][i].out; + states[i+1][3] <== multi_or[4][i].out; + state_changed[i].in[2] <== states[i+1][3]; eq[15][i] = IsEqual(); eq[15][i].in[0] <== in[i]; - eq[15][i].in[1] <== 3; + eq[15][i].in[1] <== 115; + and[7][i] = AND(); + and[7][i].a <== states[i][3]; + and[7][i].b <== eq[15][i].out; + states[i+1][4] <== and[7][i].out; + state_changed[i].in[3] <== states[i+1][4]; eq[16][i] = IsEqual(); eq[16][i].in[0] <== in[i]; - eq[16][i].in[1] <== 4; + eq[16][i].in[1] <== 117; + and[8][i] = AND(); + and[8][i].a <== states[i][4]; + and[8][i].b <== eq[16][i].out; + states[i+1][5] <== and[8][i].out; + state_changed[i].in[4] <== states[i+1][5]; eq[17][i] = IsEqual(); eq[17][i].in[0] <== in[i]; - eq[17][i].in[1] <== 5; + eq[17][i].in[1] <== 98; + and[9][i] = AND(); + and[9][i].a <== states[i][5]; + and[9][i].b <== eq[17][i].out; + states[i+1][6] <== and[9][i].out; + state_changed[i].in[5] <== states[i+1][6]; eq[18][i] = IsEqual(); eq[18][i].in[0] <== in[i]; - eq[18][i].in[1] <== 6; + eq[18][i].in[1] <== 106; + and[10][i] = AND(); + and[10][i].a <== states[i][6]; + and[10][i].b <== eq[18][i].out; + states[i+1][7] <== and[10][i].out; + state_changed[i].in[6] <== states[i+1][7]; eq[19][i] = IsEqual(); eq[19][i].in[0] <== in[i]; - eq[19][i].in[1] <== 7; + eq[19][i].in[1] <== 101; + and[11][i] = AND(); + and[11][i].a <== states[i][7]; + and[11][i].b <== eq[19][i].out; + states[i+1][8] <== and[11][i].out; + state_changed[i].in[7] <== states[i+1][8]; eq[20][i] = IsEqual(); eq[20][i].in[0] <== in[i]; - eq[20][i].in[1] <== 8; + eq[20][i].in[1] <== 99; + and[12][i] = AND(); + and[12][i].a <== states[i][8]; + and[12][i].b <== eq[20][i].out; + states[i+1][9] <== and[12][i].out; + state_changed[i].in[8] <== states[i+1][9]; + and[13][i] = AND(); + and[13][i].a <== states[i][1]; + and[13][i].b <== eq[12][i].out; + states[i+1][10] <== and[13][i].out; + state_changed[i].in[9] <== states[i+1][10]; eq[21][i] = IsEqual(); eq[21][i].in[0] <== in[i]; - eq[21][i].in[1] <== 9; + eq[21][i].in[1] <== 116; + and[14][i] = AND(); + and[14][i].a <== states[i][9]; + and[14][i].b <== eq[21][i].out; + states[i+1][11] <== and[14][i].out; + state_changed[i].in[10] <== states[i+1][11]; eq[22][i] = IsEqual(); eq[22][i].in[0] <== in[i]; - eq[22][i].in[1] <== 11; - eq[23][i] = IsEqual(); - eq[23][i].in[0] <== in[i]; - eq[23][i].in[1] <== 12; - and[3][i] = AND(); - and[3][i].a <== states[i][12]; - multi_or[1][i] = MultiOR(13); - multi_or[1][i].in[0] <== and[2][i].out; - multi_or[1][i].in[1] <== eq[12][i].out; - multi_or[1][i].in[2] <== eq[13][i].out; - multi_or[1][i].in[3] <== eq[14][i].out; - multi_or[1][i].in[4] <== eq[15][i].out; - multi_or[1][i].in[5] <== eq[16][i].out; - multi_or[1][i].in[6] <== eq[17][i].out; - multi_or[1][i].in[7] <== eq[18][i].out; - multi_or[1][i].in[8] <== eq[19][i].out; - multi_or[1][i].in[9] <== eq[20][i].out; - multi_or[1][i].in[10] <== eq[21][i].out; - multi_or[1][i].in[11] <== eq[22][i].out; - multi_or[1][i].in[12] <== eq[23][i].out; - and[3][i].b <== multi_or[1][i].out; - multi_or[2][i] = MultiOR(2); - multi_or[2][i].in[0] <== and[1][i].out; - multi_or[2][i].in[1] <== and[3][i].out; - states[i+1][1] <== multi_or[2][i].out; - state_changed[i].in[0] <== states[i+1][1]; - eq[24][i] = IsEqual(); - eq[24][i].in[0] <== in[i]; - eq[24][i].in[1] <== 13; - and[4][i] = AND(); - and[4][i].a <== states[i][0]; - and[4][i].b <== eq[24][i].out; - eq[25][i] = IsEqual(); - eq[25][i].in[0] <== in[i]; - eq[25][i].in[1] <== 13; - and[5][i] = AND(); - and[5][i].a <== states[i][3]; - and[5][i].b <== eq[25][i].out; - multi_or[3][i] = MultiOR(2); - multi_or[3][i].in[0] <== and[4][i].out; - multi_or[3][i].in[1] <== and[5][i].out; - states[i+1][2] <== multi_or[3][i].out; - state_changed[i].in[1] <== states[i+1][2]; - eq[26][i] = IsEqual(); - eq[26][i].in[0] <== in[i]; - eq[26][i].in[1] <== 255; - and[6][i] = AND(); - and[6][i].a <== states[i][0]; - and[6][i].b <== eq[26][i].out; - eq[27][i] = IsEqual(); - eq[27][i].in[0] <== in[i]; - eq[27][i].in[1] <== 10; - and[7][i] = AND(); - and[7][i].a <== states[i][2]; - and[7][i].b <== eq[27][i].out; - multi_or[4][i] = MultiOR(2); - multi_or[4][i].in[0] <== and[6][i].out; - multi_or[4][i].in[1] <== and[7][i].out; - states[i+1][3] <== multi_or[4][i].out; - state_changed[i].in[2] <== states[i+1][3]; - eq[28][i] = IsEqual(); - eq[28][i].in[0] <== in[i]; - eq[28][i].in[1] <== 115; - and[8][i] = AND(); - and[8][i].a <== states[i][3]; - and[8][i].b <== eq[28][i].out; - states[i+1][4] <== and[8][i].out; - state_changed[i].in[3] <== states[i+1][4]; - eq[29][i] = IsEqual(); - eq[29][i].in[0] <== in[i]; - eq[29][i].in[1] <== 117; - and[9][i] = AND(); - and[9][i].a <== states[i][4]; - and[9][i].b <== eq[29][i].out; - states[i+1][5] <== and[9][i].out; - state_changed[i].in[4] <== states[i+1][5]; - eq[30][i] = IsEqual(); - eq[30][i].in[0] <== in[i]; - eq[30][i].in[1] <== 98; - and[10][i] = AND(); - and[10][i].a <== states[i][5]; - and[10][i].b <== eq[30][i].out; - states[i+1][6] <== and[10][i].out; - state_changed[i].in[5] <== states[i+1][6]; - eq[31][i] = IsEqual(); - eq[31][i].in[0] <== in[i]; - eq[31][i].in[1] <== 106; - and[11][i] = AND(); - and[11][i].a <== states[i][6]; - and[11][i].b <== eq[31][i].out; - states[i+1][7] <== and[11][i].out; - state_changed[i].in[6] <== states[i+1][7]; - eq[32][i] = IsEqual(); - eq[32][i].in[0] <== in[i]; - eq[32][i].in[1] <== 101; - and[12][i] = AND(); - and[12][i].a <== states[i][7]; - and[12][i].b <== eq[32][i].out; - states[i+1][8] <== and[12][i].out; - state_changed[i].in[7] <== states[i+1][8]; - eq[33][i] = IsEqual(); - eq[33][i].in[0] <== in[i]; - eq[33][i].in[1] <== 99; - and[13][i] = AND(); - and[13][i].a <== states[i][8]; - and[13][i].b <== eq[33][i].out; - states[i+1][9] <== and[13][i].out; - state_changed[i].in[8] <== states[i+1][9]; - eq[34][i] = IsEqual(); - eq[34][i].in[0] <== in[i]; - eq[34][i].in[1] <== 13; - and[14][i] = AND(); - and[14][i].a <== states[i][1]; - and[14][i].b <== eq[34][i].out; - states[i+1][10] <== and[14][i].out; - state_changed[i].in[9] <== states[i+1][10]; - eq[35][i] = IsEqual(); - eq[35][i].in[0] <== in[i]; - eq[35][i].in[1] <== 116; + eq[22][i].in[1] <== 58; and[15][i] = AND(); - and[15][i].a <== states[i][9]; - and[15][i].b <== eq[35][i].out; - states[i+1][11] <== and[15][i].out; - state_changed[i].in[10] <== states[i+1][11]; - eq[36][i] = IsEqual(); - eq[36][i].in[0] <== in[i]; - eq[36][i].in[1] <== 58; - and[16][i] = AND(); - and[16][i].a <== states[i][11]; - and[16][i].b <== eq[36][i].out; - states[i+1][12] <== and[16][i].out; + and[15][i].a <== states[i][11]; + and[15][i].b <== eq[22][i].out; + states[i+1][12] <== and[15][i].out; state_changed[i].in[11] <== states[i+1][12]; - eq[37][i] = IsEqual(); - eq[37][i].in[0] <== in[i]; - eq[37][i].in[1] <== 10; - and[17][i] = AND(); - and[17][i].a <== states[i][10]; - and[17][i].b <== eq[37][i].out; - states[i+1][13] <== and[17][i].out; + and[16][i] = AND(); + and[16][i].a <== states[i][10]; + and[16][i].b <== eq[14][i].out; + states[i+1][13] <== and[16][i].out; state_changed[i].in[12] <== states[i+1][13]; states[i+1][0] <== 1 - state_changed[i].out; } diff --git a/packages/circom/circuits/common/timestamp_regex.circom b/packages/circom/circuits/common/timestamp_regex.circom index 9c73593..f68c045 100644 --- a/packages/circom/circuits/common/timestamp_regex.circom +++ b/packages/circom/circuits/common/timestamp_regex.circom @@ -13,9 +13,9 @@ template TimestampRegex(msg_bytes) { in[i+1] <== msg[i]; } - component eq[54][num_bytes]; - component lt[24][num_bytes]; - component and[48][num_bytes]; + component eq[35][num_bytes]; + component lt[10][num_bytes]; + component and[41][num_bytes]; component multi_or[13][num_bytes]; signal states[num_bytes+1][27]; component state_changed[num_bytes]; @@ -77,451 +77,331 @@ template TimestampRegex(msg_bytes) { multi_or[0][i].in[5] <== eq[4][i].out; multi_or[0][i].in[6] <== eq[5][i].out; and[3][i].b <== multi_or[0][i].out; + and[4][i] = AND(); + and[4][i].a <== states[i][24]; + and[4][i].b <== and[0][i].out; + and[5][i] = AND(); + and[5][i].a <== states[i][25]; + and[5][i].b <== and[0][i].out; + multi_or[1][i] = MultiOR(4); + multi_or[1][i].in[0] <== and[1][i].out; + multi_or[1][i].in[1] <== and[3][i].out; + multi_or[1][i].in[2] <== and[4][i].out; + multi_or[1][i].in[3] <== and[5][i].out; + states[i+1][1] <== multi_or[1][i].out; + state_changed[i].in[0] <== states[i+1][1]; lt[4][i] = LessEqThan(8); - lt[4][i].in[0] <== 97; + lt[4][i].in[0] <== 0; lt[4][i].in[1] <== in[i]; lt[5][i] = LessEqThan(8); lt[5][i].in[0] <== in[i]; - lt[5][i].in[1] <== 122; - and[4][i] = AND(); - and[4][i].a <== lt[4][i].out; - and[4][i].b <== lt[5][i].out; - and[5][i] = AND(); - and[5][i].a <== states[i][24]; - and[5][i].b <== and[4][i].out; + lt[5][i].in[1] <== 58; + and[6][i] = AND(); + and[6][i].a <== lt[4][i].out; + and[6][i].b <== lt[5][i].out; lt[6][i] = LessEqThan(8); - lt[6][i].in[0] <== 97; + lt[6][i].in[0] <== 60; lt[6][i].in[1] <== in[i]; lt[7][i] = LessEqThan(8); lt[7][i].in[0] <== in[i]; - lt[7][i].in[1] <== 122; - and[6][i] = AND(); - and[6][i].a <== lt[6][i].out; - and[6][i].b <== lt[7][i].out; + lt[7][i].in[1] <== 254; and[7][i] = AND(); - and[7][i].a <== states[i][25]; - and[7][i].b <== and[6][i].out; - multi_or[1][i] = MultiOR(4); - multi_or[1][i].in[0] <== and[1][i].out; - multi_or[1][i].in[1] <== and[3][i].out; - multi_or[1][i].in[2] <== and[5][i].out; - multi_or[1][i].in[3] <== and[7][i].out; - states[i+1][1] <== multi_or[1][i].out; - state_changed[i].in[0] <== states[i+1][1]; + and[7][i].a <== lt[6][i].out; + and[7][i].b <== lt[7][i].out; + and[8][i] = AND(); + and[8][i].a <== states[i][2]; + multi_or[2][i] = MultiOR(2); + multi_or[2][i].in[0] <== and[6][i].out; + multi_or[2][i].in[1] <== and[7][i].out; + and[8][i].b <== multi_or[2][i].out; lt[8][i] = LessEqThan(8); lt[8][i].in[0] <== 0; lt[8][i].in[1] <== in[i]; lt[9][i] = LessEqThan(8); lt[9][i].in[0] <== in[i]; - lt[9][i].in[1] <== 58; - and[8][i] = AND(); - and[8][i].a <== lt[8][i].out; - and[8][i].b <== lt[9][i].out; - lt[10][i] = LessEqThan(8); - lt[10][i].in[0] <== 60; - lt[10][i].in[1] <== in[i]; - lt[11][i] = LessEqThan(8); - lt[11][i].in[0] <== in[i]; - lt[11][i].in[1] <== 254; + lt[9][i].in[1] <== 47; and[9][i] = AND(); - and[9][i].a <== lt[10][i].out; - and[9][i].b <== lt[11][i].out; - and[10][i] = AND(); - and[10][i].a <== states[i][2]; - multi_or[2][i] = MultiOR(2); - multi_or[2][i].in[0] <== and[8][i].out; - multi_or[2][i].in[1] <== and[9][i].out; - and[10][i].b <== multi_or[2][i].out; - lt[12][i] = LessEqThan(8); - lt[12][i].in[0] <== 0; - lt[12][i].in[1] <== in[i]; - lt[13][i] = LessEqThan(8); - lt[13][i].in[0] <== in[i]; - lt[13][i].in[1] <== 47; - and[11][i] = AND(); - and[11][i].a <== lt[12][i].out; - and[11][i].b <== lt[13][i].out; - lt[14][i] = LessEqThan(8); - lt[14][i].in[0] <== 60; - lt[14][i].in[1] <== in[i]; - lt[15][i] = LessEqThan(8); - lt[15][i].in[0] <== in[i]; - lt[15][i].in[1] <== 254; - and[12][i] = AND(); - and[12][i].a <== lt[14][i].out; - and[12][i].b <== lt[15][i].out; + and[9][i].a <== lt[8][i].out; + and[9][i].b <== lt[9][i].out; eq[6][i] = IsEqual(); eq[6][i].in[0] <== in[i]; eq[6][i].in[1] <== 58; - and[13][i] = AND(); - and[13][i].a <== states[i][3]; + and[10][i] = AND(); + and[10][i].a <== states[i][3]; multi_or[3][i] = MultiOR(3); - multi_or[3][i].in[0] <== and[11][i].out; - multi_or[3][i].in[1] <== and[12][i].out; + multi_or[3][i].in[0] <== and[9][i].out; + multi_or[3][i].in[1] <== and[7][i].out; multi_or[3][i].in[2] <== eq[6][i].out; - and[13][i].b <== multi_or[3][i].out; - lt[16][i] = LessEqThan(8); - lt[16][i].in[0] <== 0; - lt[16][i].in[1] <== in[i]; - lt[17][i] = LessEqThan(8); - lt[17][i].in[0] <== in[i]; - lt[17][i].in[1] <== 58; - and[14][i] = AND(); - and[14][i].a <== lt[16][i].out; - and[14][i].b <== lt[17][i].out; - lt[18][i] = LessEqThan(8); - lt[18][i].in[0] <== 60; - lt[18][i].in[1] <== in[i]; - lt[19][i] = LessEqThan(8); - lt[19][i].in[0] <== in[i]; - lt[19][i].in[1] <== 254; - and[15][i] = AND(); - and[15][i].a <== lt[18][i].out; - and[15][i].b <== lt[19][i].out; - and[16][i] = AND(); - and[16][i].a <== states[i][7]; + and[10][i].b <== multi_or[3][i].out; + and[11][i] = AND(); + and[11][i].a <== states[i][7]; multi_or[4][i] = MultiOR(2); - multi_or[4][i].in[0] <== and[14][i].out; - multi_or[4][i].in[1] <== and[15][i].out; - and[16][i].b <== multi_or[4][i].out; - lt[20][i] = LessEqThan(8); - lt[20][i].in[0] <== 0; - lt[20][i].in[1] <== in[i]; - lt[21][i] = LessEqThan(8); - lt[21][i].in[0] <== in[i]; - lt[21][i].in[1] <== 47; - and[17][i] = AND(); - and[17][i].a <== lt[20][i].out; - and[17][i].b <== lt[21][i].out; - lt[22][i] = LessEqThan(8); - lt[22][i].in[0] <== 60; - lt[22][i].in[1] <== in[i]; - lt[23][i] = LessEqThan(8); - lt[23][i].in[0] <== in[i]; - lt[23][i].in[1] <== 254; - and[18][i] = AND(); - and[18][i].a <== lt[22][i].out; - and[18][i].b <== lt[23][i].out; - eq[7][i] = IsEqual(); - eq[7][i].in[0] <== in[i]; - eq[7][i].in[1] <== 58; - and[19][i] = AND(); - and[19][i].a <== states[i][26]; + multi_or[4][i].in[0] <== and[6][i].out; + multi_or[4][i].in[1] <== and[7][i].out; + and[11][i].b <== multi_or[4][i].out; + and[12][i] = AND(); + and[12][i].a <== states[i][26]; multi_or[5][i] = MultiOR(3); - multi_or[5][i].in[0] <== and[17][i].out; - multi_or[5][i].in[1] <== and[18][i].out; - multi_or[5][i].in[2] <== eq[7][i].out; - and[19][i].b <== multi_or[5][i].out; + multi_or[5][i].in[0] <== and[9][i].out; + multi_or[5][i].in[1] <== and[7][i].out; + multi_or[5][i].in[2] <== eq[6][i].out; + and[12][i].b <== multi_or[5][i].out; multi_or[6][i] = MultiOR(4); - multi_or[6][i].in[0] <== and[10][i].out; - multi_or[6][i].in[1] <== and[13][i].out; - multi_or[6][i].in[2] <== and[16][i].out; - multi_or[6][i].in[3] <== and[19][i].out; + multi_or[6][i].in[0] <== and[8][i].out; + multi_or[6][i].in[1] <== and[10][i].out; + multi_or[6][i].in[2] <== and[11][i].out; + multi_or[6][i].in[3] <== and[12][i].out; states[i+1][2] <== multi_or[6][i].out; state_changed[i].in[1] <== states[i+1][2]; + eq[7][i] = IsEqual(); + eq[7][i].in[0] <== in[i]; + eq[7][i].in[1] <== 48; eq[8][i] = IsEqual(); eq[8][i].in[0] <== in[i]; - eq[8][i].in[1] <== 48; + eq[8][i].in[1] <== 49; eq[9][i] = IsEqual(); eq[9][i].in[0] <== in[i]; - eq[9][i].in[1] <== 49; + eq[9][i].in[1] <== 50; eq[10][i] = IsEqual(); eq[10][i].in[0] <== in[i]; - eq[10][i].in[1] <== 50; + eq[10][i].in[1] <== 51; eq[11][i] = IsEqual(); eq[11][i].in[0] <== in[i]; - eq[11][i].in[1] <== 51; + eq[11][i].in[1] <== 52; eq[12][i] = IsEqual(); eq[12][i].in[0] <== in[i]; - eq[12][i].in[1] <== 52; + eq[12][i].in[1] <== 53; eq[13][i] = IsEqual(); eq[13][i].in[0] <== in[i]; - eq[13][i].in[1] <== 53; + eq[13][i].in[1] <== 54; eq[14][i] = IsEqual(); eq[14][i].in[0] <== in[i]; - eq[14][i].in[1] <== 54; + eq[14][i].in[1] <== 55; eq[15][i] = IsEqual(); eq[15][i].in[0] <== in[i]; - eq[15][i].in[1] <== 55; + eq[15][i].in[1] <== 56; eq[16][i] = IsEqual(); eq[16][i].in[0] <== in[i]; - eq[16][i].in[1] <== 56; + eq[16][i].in[1] <== 57; + and[13][i] = AND(); + and[13][i].a <== states[i][3]; + multi_or[7][i] = MultiOR(10); + multi_or[7][i].in[0] <== eq[7][i].out; + multi_or[7][i].in[1] <== eq[8][i].out; + multi_or[7][i].in[2] <== eq[9][i].out; + multi_or[7][i].in[3] <== eq[10][i].out; + multi_or[7][i].in[4] <== eq[11][i].out; + multi_or[7][i].in[5] <== eq[12][i].out; + multi_or[7][i].in[6] <== eq[13][i].out; + multi_or[7][i].in[7] <== eq[14][i].out; + multi_or[7][i].in[8] <== eq[15][i].out; + multi_or[7][i].in[9] <== eq[16][i].out; + and[13][i].b <== multi_or[7][i].out; + and[14][i] = AND(); + and[14][i].a <== states[i][26]; + multi_or[8][i] = MultiOR(10); + multi_or[8][i].in[0] <== eq[7][i].out; + multi_or[8][i].in[1] <== eq[8][i].out; + multi_or[8][i].in[2] <== eq[9][i].out; + multi_or[8][i].in[3] <== eq[10][i].out; + multi_or[8][i].in[4] <== eq[11][i].out; + multi_or[8][i].in[5] <== eq[12][i].out; + multi_or[8][i].in[6] <== eq[13][i].out; + multi_or[8][i].in[7] <== eq[14][i].out; + multi_or[8][i].in[8] <== eq[15][i].out; + multi_or[8][i].in[9] <== eq[16][i].out; + and[14][i].b <== multi_or[8][i].out; + multi_or[9][i] = MultiOR(2); + multi_or[9][i].in[0] <== and[13][i].out; + multi_or[9][i].in[1] <== and[14][i].out; + states[i+1][3] <== multi_or[9][i].out; + state_changed[i].in[2] <== states[i+1][3]; eq[17][i] = IsEqual(); eq[17][i].in[0] <== in[i]; - eq[17][i].in[1] <== 57; - and[20][i] = AND(); - and[20][i].a <== states[i][3]; - multi_or[7][i] = MultiOR(10); - multi_or[7][i].in[0] <== eq[8][i].out; - multi_or[7][i].in[1] <== eq[9][i].out; - multi_or[7][i].in[2] <== eq[10][i].out; - multi_or[7][i].in[3] <== eq[11][i].out; - multi_or[7][i].in[4] <== eq[12][i].out; - multi_or[7][i].in[5] <== eq[13][i].out; - multi_or[7][i].in[6] <== eq[14][i].out; - multi_or[7][i].in[7] <== eq[15][i].out; - multi_or[7][i].in[8] <== eq[16][i].out; - multi_or[7][i].in[9] <== eq[17][i].out; - and[20][i].b <== multi_or[7][i].out; + eq[17][i].in[1] <== 59; + and[15][i] = AND(); + and[15][i].a <== states[i][2]; + and[15][i].b <== eq[17][i].out; + states[i+1][4] <== and[15][i].out; + state_changed[i].in[3] <== states[i+1][4]; + and[16][i] = AND(); + and[16][i].a <== states[i][3]; + and[16][i].b <== eq[17][i].out; + states[i+1][5] <== and[16][i].out; + state_changed[i].in[4] <== states[i+1][5]; eq[18][i] = IsEqual(); eq[18][i].in[0] <== in[i]; - eq[18][i].in[1] <== 48; + eq[18][i].in[1] <== 32; + and[17][i] = AND(); + and[17][i].a <== states[i][4]; + and[17][i].b <== eq[18][i].out; + and[18][i] = AND(); + and[18][i].a <== states[i][5]; + and[18][i].b <== eq[18][i].out; + multi_or[10][i] = MultiOR(2); + multi_or[10][i].in[0] <== and[17][i].out; + multi_or[10][i].in[1] <== and[18][i].out; + states[i+1][6] <== multi_or[10][i].out; + state_changed[i].in[5] <== states[i+1][6]; eq[19][i] = IsEqual(); eq[19][i].in[0] <== in[i]; - eq[19][i].in[1] <== 49; + eq[19][i].in[1] <== 61; + and[19][i] = AND(); + and[19][i].a <== states[i][1]; + and[19][i].b <== eq[19][i].out; + states[i+1][7] <== and[19][i].out; + state_changed[i].in[6] <== states[i+1][7]; eq[20][i] = IsEqual(); eq[20][i].in[0] <== in[i]; - eq[20][i].in[1] <== 50; + eq[20][i].in[1] <== 13; + and[20][i] = AND(); + and[20][i].a <== states[i][0]; + and[20][i].b <== eq[20][i].out; + and[21][i] = AND(); + and[21][i].a <== states[i][9]; + and[21][i].b <== eq[20][i].out; + multi_or[11][i] = MultiOR(2); + multi_or[11][i].in[0] <== and[20][i].out; + multi_or[11][i].in[1] <== and[21][i].out; + states[i+1][8] <== multi_or[11][i].out; + state_changed[i].in[7] <== states[i+1][8]; eq[21][i] = IsEqual(); eq[21][i].in[0] <== in[i]; - eq[21][i].in[1] <== 51; + eq[21][i].in[1] <== 255; + and[22][i] = AND(); + and[22][i].a <== states[i][0]; + and[22][i].b <== eq[21][i].out; eq[22][i] = IsEqual(); eq[22][i].in[0] <== in[i]; - eq[22][i].in[1] <== 52; + eq[22][i].in[1] <== 10; + and[23][i] = AND(); + and[23][i].a <== states[i][8]; + and[23][i].b <== eq[22][i].out; + multi_or[12][i] = MultiOR(2); + multi_or[12][i].in[0] <== and[22][i].out; + multi_or[12][i].in[1] <== and[23][i].out; + states[i+1][9] <== multi_or[12][i].out; + state_changed[i].in[8] <== states[i+1][9]; eq[23][i] = IsEqual(); eq[23][i].in[0] <== in[i]; - eq[23][i].in[1] <== 53; + eq[23][i].in[1] <== 100; + and[24][i] = AND(); + and[24][i].a <== states[i][9]; + and[24][i].b <== eq[23][i].out; + states[i+1][10] <== and[24][i].out; + state_changed[i].in[9] <== states[i+1][10]; eq[24][i] = IsEqual(); eq[24][i].in[0] <== in[i]; - eq[24][i].in[1] <== 54; + eq[24][i].in[1] <== 107; + and[25][i] = AND(); + and[25][i].a <== states[i][10]; + and[25][i].b <== eq[24][i].out; + states[i+1][11] <== and[25][i].out; + state_changed[i].in[10] <== states[i+1][11]; eq[25][i] = IsEqual(); eq[25][i].in[0] <== in[i]; - eq[25][i].in[1] <== 55; + eq[25][i].in[1] <== 105; + and[26][i] = AND(); + and[26][i].a <== states[i][11]; + and[26][i].b <== eq[25][i].out; + states[i+1][12] <== and[26][i].out; + state_changed[i].in[11] <== states[i+1][12]; eq[26][i] = IsEqual(); eq[26][i].in[0] <== in[i]; - eq[26][i].in[1] <== 56; + eq[26][i].in[1] <== 109; + and[27][i] = AND(); + and[27][i].a <== states[i][12]; + and[27][i].b <== eq[26][i].out; + states[i+1][13] <== and[27][i].out; + state_changed[i].in[12] <== states[i+1][13]; eq[27][i] = IsEqual(); eq[27][i].in[0] <== in[i]; - eq[27][i].in[1] <== 57; - and[21][i] = AND(); - and[21][i].a <== states[i][26]; - multi_or[8][i] = MultiOR(10); - multi_or[8][i].in[0] <== eq[18][i].out; - multi_or[8][i].in[1] <== eq[19][i].out; - multi_or[8][i].in[2] <== eq[20][i].out; - multi_or[8][i].in[3] <== eq[21][i].out; - multi_or[8][i].in[4] <== eq[22][i].out; - multi_or[8][i].in[5] <== eq[23][i].out; - multi_or[8][i].in[6] <== eq[24][i].out; - multi_or[8][i].in[7] <== eq[25][i].out; - multi_or[8][i].in[8] <== eq[26][i].out; - multi_or[8][i].in[9] <== eq[27][i].out; - and[21][i].b <== multi_or[8][i].out; - multi_or[9][i] = MultiOR(2); - multi_or[9][i].in[0] <== and[20][i].out; - multi_or[9][i].in[1] <== and[21][i].out; - states[i+1][3] <== multi_or[9][i].out; - state_changed[i].in[2] <== states[i+1][3]; + eq[27][i].in[1] <== 45; + and[28][i] = AND(); + and[28][i].a <== states[i][13]; + and[28][i].b <== eq[27][i].out; + states[i+1][14] <== and[28][i].out; + state_changed[i].in[13] <== states[i+1][14]; eq[28][i] = IsEqual(); eq[28][i].in[0] <== in[i]; - eq[28][i].in[1] <== 59; - and[22][i] = AND(); - and[22][i].a <== states[i][2]; - and[22][i].b <== eq[28][i].out; - states[i+1][4] <== and[22][i].out; - state_changed[i].in[3] <== states[i+1][4]; + eq[28][i].in[1] <== 115; + and[29][i] = AND(); + and[29][i].a <== states[i][14]; + and[29][i].b <== eq[28][i].out; + states[i+1][15] <== and[29][i].out; + state_changed[i].in[14] <== states[i+1][15]; + and[30][i] = AND(); + and[30][i].a <== states[i][15]; + and[30][i].b <== eq[25][i].out; + states[i+1][16] <== and[30][i].out; + state_changed[i].in[15] <== states[i+1][16]; eq[29][i] = IsEqual(); eq[29][i].in[0] <== in[i]; - eq[29][i].in[1] <== 59; - and[23][i] = AND(); - and[23][i].a <== states[i][3]; - and[23][i].b <== eq[29][i].out; - states[i+1][5] <== and[23][i].out; - state_changed[i].in[4] <== states[i+1][5]; + eq[29][i].in[1] <== 103; + and[31][i] = AND(); + and[31][i].a <== states[i][16]; + and[31][i].b <== eq[29][i].out; + states[i+1][17] <== and[31][i].out; + state_changed[i].in[16] <== states[i+1][17]; eq[30][i] = IsEqual(); eq[30][i].in[0] <== in[i]; - eq[30][i].in[1] <== 32; - and[24][i] = AND(); - and[24][i].a <== states[i][4]; - and[24][i].b <== eq[30][i].out; + eq[30][i].in[1] <== 110; + and[32][i] = AND(); + and[32][i].a <== states[i][17]; + and[32][i].b <== eq[30][i].out; + states[i+1][18] <== and[32][i].out; + state_changed[i].in[17] <== states[i+1][18]; eq[31][i] = IsEqual(); eq[31][i].in[0] <== in[i]; - eq[31][i].in[1] <== 32; - and[25][i] = AND(); - and[25][i].a <== states[i][5]; - and[25][i].b <== eq[31][i].out; - multi_or[10][i] = MultiOR(2); - multi_or[10][i].in[0] <== and[24][i].out; - multi_or[10][i].in[1] <== and[25][i].out; - states[i+1][6] <== multi_or[10][i].out; - state_changed[i].in[5] <== states[i+1][6]; + eq[31][i].in[1] <== 97; + and[33][i] = AND(); + and[33][i].a <== states[i][18]; + and[33][i].b <== eq[31][i].out; + states[i+1][19] <== and[33][i].out; + state_changed[i].in[18] <== states[i+1][19]; eq[32][i] = IsEqual(); eq[32][i].in[0] <== in[i]; - eq[32][i].in[1] <== 61; - and[26][i] = AND(); - and[26][i].a <== states[i][1]; - and[26][i].b <== eq[32][i].out; - states[i+1][7] <== and[26][i].out; - state_changed[i].in[6] <== states[i+1][7]; + eq[32][i].in[1] <== 116; + and[34][i] = AND(); + and[34][i].a <== states[i][19]; + and[34][i].b <== eq[32][i].out; + states[i+1][20] <== and[34][i].out; + state_changed[i].in[19] <== states[i+1][20]; + and[35][i] = AND(); + and[35][i].a <== states[i][20]; + and[35][i].b <== eq[0][i].out; + states[i+1][21] <== and[35][i].out; + state_changed[i].in[20] <== states[i+1][21]; eq[33][i] = IsEqual(); eq[33][i].in[0] <== in[i]; - eq[33][i].in[1] <== 13; - and[27][i] = AND(); - and[27][i].a <== states[i][0]; - and[27][i].b <== eq[33][i].out; + eq[33][i].in[1] <== 114; + and[36][i] = AND(); + and[36][i].a <== states[i][21]; + and[36][i].b <== eq[33][i].out; + states[i+1][22] <== and[36][i].out; + state_changed[i].in[21] <== states[i+1][22]; eq[34][i] = IsEqual(); eq[34][i].in[0] <== in[i]; - eq[34][i].in[1] <== 13; - and[28][i] = AND(); - and[28][i].a <== states[i][9]; - and[28][i].b <== eq[34][i].out; - multi_or[11][i] = MultiOR(2); - multi_or[11][i].in[0] <== and[27][i].out; - multi_or[11][i].in[1] <== and[28][i].out; - states[i+1][8] <== multi_or[11][i].out; - state_changed[i].in[7] <== states[i+1][8]; - eq[35][i] = IsEqual(); - eq[35][i].in[0] <== in[i]; - eq[35][i].in[1] <== 255; - and[29][i] = AND(); - and[29][i].a <== states[i][0]; - and[29][i].b <== eq[35][i].out; - eq[36][i] = IsEqual(); - eq[36][i].in[0] <== in[i]; - eq[36][i].in[1] <== 10; - and[30][i] = AND(); - and[30][i].a <== states[i][8]; - and[30][i].b <== eq[36][i].out; - multi_or[12][i] = MultiOR(2); - multi_or[12][i].in[0] <== and[29][i].out; - multi_or[12][i].in[1] <== and[30][i].out; - states[i+1][9] <== multi_or[12][i].out; - state_changed[i].in[8] <== states[i+1][9]; - eq[37][i] = IsEqual(); - eq[37][i].in[0] <== in[i]; - eq[37][i].in[1] <== 100; - and[31][i] = AND(); - and[31][i].a <== states[i][9]; - and[31][i].b <== eq[37][i].out; - states[i+1][10] <== and[31][i].out; - state_changed[i].in[9] <== states[i+1][10]; - eq[38][i] = IsEqual(); - eq[38][i].in[0] <== in[i]; - eq[38][i].in[1] <== 107; - and[32][i] = AND(); - and[32][i].a <== states[i][10]; - and[32][i].b <== eq[38][i].out; - states[i+1][11] <== and[32][i].out; - state_changed[i].in[10] <== states[i+1][11]; - eq[39][i] = IsEqual(); - eq[39][i].in[0] <== in[i]; - eq[39][i].in[1] <== 105; - and[33][i] = AND(); - and[33][i].a <== states[i][11]; - and[33][i].b <== eq[39][i].out; - states[i+1][12] <== and[33][i].out; - state_changed[i].in[11] <== states[i+1][12]; - eq[40][i] = IsEqual(); - eq[40][i].in[0] <== in[i]; - eq[40][i].in[1] <== 109; - and[34][i] = AND(); - and[34][i].a <== states[i][12]; - and[34][i].b <== eq[40][i].out; - states[i+1][13] <== and[34][i].out; - state_changed[i].in[12] <== states[i+1][13]; - eq[41][i] = IsEqual(); - eq[41][i].in[0] <== in[i]; - eq[41][i].in[1] <== 45; - and[35][i] = AND(); - and[35][i].a <== states[i][13]; - and[35][i].b <== eq[41][i].out; - states[i+1][14] <== and[35][i].out; - state_changed[i].in[13] <== states[i+1][14]; - eq[42][i] = IsEqual(); - eq[42][i].in[0] <== in[i]; - eq[42][i].in[1] <== 115; - and[36][i] = AND(); - and[36][i].a <== states[i][14]; - and[36][i].b <== eq[42][i].out; - states[i+1][15] <== and[36][i].out; - state_changed[i].in[14] <== states[i+1][15]; - eq[43][i] = IsEqual(); - eq[43][i].in[0] <== in[i]; - eq[43][i].in[1] <== 105; + eq[34][i].in[1] <== 101; and[37][i] = AND(); - and[37][i].a <== states[i][15]; - and[37][i].b <== eq[43][i].out; - states[i+1][16] <== and[37][i].out; - state_changed[i].in[15] <== states[i+1][16]; - eq[44][i] = IsEqual(); - eq[44][i].in[0] <== in[i]; - eq[44][i].in[1] <== 103; - and[38][i] = AND(); - and[38][i].a <== states[i][16]; - and[38][i].b <== eq[44][i].out; - states[i+1][17] <== and[38][i].out; - state_changed[i].in[16] <== states[i+1][17]; - eq[45][i] = IsEqual(); - eq[45][i].in[0] <== in[i]; - eq[45][i].in[1] <== 110; - and[39][i] = AND(); - and[39][i].a <== states[i][17]; - and[39][i].b <== eq[45][i].out; - states[i+1][18] <== and[39][i].out; - state_changed[i].in[17] <== states[i+1][18]; - eq[46][i] = IsEqual(); - eq[46][i].in[0] <== in[i]; - eq[46][i].in[1] <== 97; - and[40][i] = AND(); - and[40][i].a <== states[i][18]; - and[40][i].b <== eq[46][i].out; - states[i+1][19] <== and[40][i].out; - state_changed[i].in[18] <== states[i+1][19]; - eq[47][i] = IsEqual(); - eq[47][i].in[0] <== in[i]; - eq[47][i].in[1] <== 116; - and[41][i] = AND(); - and[41][i].a <== states[i][19]; - and[41][i].b <== eq[47][i].out; - states[i+1][20] <== and[41][i].out; - state_changed[i].in[19] <== states[i+1][20]; - eq[48][i] = IsEqual(); - eq[48][i].in[0] <== in[i]; - eq[48][i].in[1] <== 117; - and[42][i] = AND(); - and[42][i].a <== states[i][20]; - and[42][i].b <== eq[48][i].out; - states[i+1][21] <== and[42][i].out; - state_changed[i].in[20] <== states[i+1][21]; - eq[49][i] = IsEqual(); - eq[49][i].in[0] <== in[i]; - eq[49][i].in[1] <== 114; - and[43][i] = AND(); - and[43][i].a <== states[i][21]; - and[43][i].b <== eq[49][i].out; - states[i+1][22] <== and[43][i].out; - state_changed[i].in[21] <== states[i+1][22]; - eq[50][i] = IsEqual(); - eq[50][i].in[0] <== in[i]; - eq[50][i].in[1] <== 101; - and[44][i] = AND(); - and[44][i].a <== states[i][22]; - and[44][i].b <== eq[50][i].out; - states[i+1][23] <== and[44][i].out; + and[37][i].a <== states[i][22]; + and[37][i].b <== eq[34][i].out; + states[i+1][23] <== and[37][i].out; state_changed[i].in[22] <== states[i+1][23]; - eq[51][i] = IsEqual(); - eq[51][i].in[0] <== in[i]; - eq[51][i].in[1] <== 58; - and[45][i] = AND(); - and[45][i].a <== states[i][23]; - and[45][i].b <== eq[51][i].out; - states[i+1][24] <== and[45][i].out; + and[38][i] = AND(); + and[38][i].a <== states[i][23]; + and[38][i].b <== eq[6][i].out; + states[i+1][24] <== and[38][i].out; state_changed[i].in[23] <== states[i+1][24]; - eq[52][i] = IsEqual(); - eq[52][i].in[0] <== in[i]; - eq[52][i].in[1] <== 116; - and[46][i] = AND(); - and[46][i].a <== states[i][6]; - and[46][i].b <== eq[52][i].out; - states[i+1][25] <== and[46][i].out; + and[39][i] = AND(); + and[39][i].a <== states[i][6]; + and[39][i].b <== eq[32][i].out; + states[i+1][25] <== and[39][i].out; state_changed[i].in[24] <== states[i+1][25]; - eq[53][i] = IsEqual(); - eq[53][i].in[0] <== in[i]; - eq[53][i].in[1] <== 61; - and[47][i] = AND(); - and[47][i].a <== states[i][25]; - and[47][i].b <== eq[53][i].out; - states[i+1][26] <== and[47][i].out; + and[40][i] = AND(); + and[40][i].a <== states[i][25]; + and[40][i].b <== eq[19][i].out; + states[i+1][26] <== and[40][i].out; state_changed[i].in[25] <== states[i+1][26]; states[i+1][0] <== 1 - state_changed[i].out; } diff --git a/packages/circom/package.json b/packages/circom/package.json index 2234b07..5ee3cbf 100644 --- a/packages/circom/package.json +++ b/packages/circom/package.json @@ -1,6 +1,6 @@ { "name": "@zk-email/zk-regex-circom", - "version": "1.1.1", + "version": "1.2.0", "license": "MIT", "description": "regex verification circuits in circom for common regexes, generated with the compiler in [zk-regex](https://github.com/zkemail/zk-regex/tree/main).", "contributors": [ diff --git a/packages/circom/tests/circuits/negate1_regex.circom b/packages/circom/tests/circuits/negate1_regex.circom index 2c7d4c2..126aa8a 100644 --- a/packages/circom/tests/circuits/negate1_regex.circom +++ b/packages/circom/tests/circuits/negate1_regex.circom @@ -14,8 +14,8 @@ template Negate1Regex(msg_bytes) { } component eq[3][num_bytes]; - component lt[12][num_bytes]; - component and[11][num_bytes]; + component lt[6][num_bytes]; + component and[8][num_bytes]; component multi_or[3][num_bytes]; signal states[num_bytes+1][5]; component state_changed[num_bytes]; @@ -61,68 +61,41 @@ template Negate1Regex(msg_bytes) { multi_or[0][i].in[1] <== and[1][i].out; multi_or[0][i].in[2] <== and[2][i].out; and[3][i].b <== multi_or[0][i].out; - lt[6][i] = LessEqThan(8); - lt[6][i].in[0] <== 0; - lt[6][i].in[1] <== in[i]; - lt[7][i] = LessEqThan(8); - lt[7][i].in[0] <== in[i]; - lt[7][i].in[1] <== 45; and[4][i] = AND(); - and[4][i].a <== lt[6][i].out; - and[4][i].b <== lt[7][i].out; - lt[8][i] = LessEqThan(8); - lt[8][i].in[0] <== 47; - lt[8][i].in[1] <== in[i]; - lt[9][i] = LessEqThan(8); - lt[9][i].in[0] <== in[i]; - lt[9][i].in[1] <== 96; - and[5][i] = AND(); - and[5][i].a <== lt[8][i].out; - and[5][i].b <== lt[9][i].out; - lt[10][i] = LessEqThan(8); - lt[10][i].in[0] <== 123; - lt[10][i].in[1] <== in[i]; - lt[11][i] = LessEqThan(8); - lt[11][i].in[0] <== in[i]; - lt[11][i].in[1] <== 254; - and[6][i] = AND(); - and[6][i].a <== lt[10][i].out; - and[6][i].b <== lt[11][i].out; - and[7][i] = AND(); - and[7][i].a <== states[i][3]; + and[4][i].a <== states[i][3]; multi_or[1][i] = MultiOR(3); - multi_or[1][i].in[0] <== and[4][i].out; - multi_or[1][i].in[1] <== and[5][i].out; - multi_or[1][i].in[2] <== and[6][i].out; - and[7][i].b <== multi_or[1][i].out; + multi_or[1][i].in[0] <== and[0][i].out; + multi_or[1][i].in[1] <== and[1][i].out; + multi_or[1][i].in[2] <== and[2][i].out; + and[4][i].b <== multi_or[1][i].out; multi_or[2][i] = MultiOR(2); multi_or[2][i].in[0] <== and[3][i].out; - multi_or[2][i].in[1] <== and[7][i].out; + multi_or[2][i].in[1] <== and[4][i].out; states[i+1][1] <== multi_or[2][i].out; state_changed[i].in[0] <== states[i+1][1]; eq[0][i] = IsEqual(); eq[0][i].in[0] <== in[i]; eq[0][i].in[1] <== 97; - and[8][i] = AND(); - and[8][i].a <== states[i][0]; - and[8][i].b <== eq[0][i].out; - states[i+1][2] <== and[8][i].out; + and[5][i] = AND(); + and[5][i].a <== states[i][0]; + and[5][i].b <== eq[0][i].out; + states[i+1][2] <== and[5][i].out; state_changed[i].in[1] <== states[i+1][2]; eq[1][i] = IsEqual(); eq[1][i].in[0] <== in[i]; eq[1][i].in[1] <== 58; - and[9][i] = AND(); - and[9][i].a <== states[i][2]; - and[9][i].b <== eq[1][i].out; - states[i+1][3] <== and[9][i].out; + and[6][i] = AND(); + and[6][i].a <== states[i][2]; + and[6][i].b <== eq[1][i].out; + states[i+1][3] <== and[6][i].out; state_changed[i].in[2] <== states[i+1][3]; eq[2][i] = IsEqual(); eq[2][i].in[0] <== in[i]; eq[2][i].in[1] <== 46; - and[10][i] = AND(); - and[10][i].a <== states[i][1]; - and[10][i].b <== eq[2][i].out; - states[i+1][4] <== and[10][i].out; + and[7][i] = AND(); + and[7][i].a <== states[i][1]; + and[7][i].b <== eq[2][i].out; + states[i+1][4] <== and[7][i].out; state_changed[i].in[3] <== states[i+1][4]; states[i+1][0] <== 1 - state_changed[i].out; } diff --git a/packages/circom/tests/circuits/simple_regex.circom b/packages/circom/tests/circuits/simple_regex.circom index 40a90de..839df47 100644 --- a/packages/circom/tests/circuits/simple_regex.circom +++ b/packages/circom/tests/circuits/simple_regex.circom @@ -13,7 +13,7 @@ template SimpleRegex(msg_bytes) { in[i+1] <== msg[i]; } - component eq[14][num_bytes]; + component eq[8][num_bytes]; component and[11][num_bytes]; component multi_or[5][num_bytes]; signal states[num_bytes+1][10]; @@ -70,68 +70,50 @@ template SimpleRegex(msg_bytes) { and[4][i] = AND(); and[4][i].a <== states[i][4]; and[4][i].b <== eq[5][i].out; - eq[6][i] = IsEqual(); - eq[6][i].in[0] <== in[i]; - eq[6][i].in[1] <== 50; and[5][i] = AND(); and[5][i].a <== states[i][8]; - and[5][i].b <== eq[6][i].out; + and[5][i].b <== eq[5][i].out; multi_or[1][i] = MultiOR(2); multi_or[1][i].in[0] <== and[4][i].out; multi_or[1][i].in[1] <== and[5][i].out; states[i+1][5] <== multi_or[1][i].out; state_changed[i].in[4] <== states[i+1][5]; - eq[7][i] = IsEqual(); - eq[7][i].in[0] <== in[i]; - eq[7][i].in[1] <== 61; and[6][i] = AND(); and[6][i].a <== states[i][5]; - and[6][i].b <== eq[7][i].out; + and[6][i].b <== eq[1][i].out; states[i+1][6] <== and[6][i].out; state_changed[i].in[5] <== states[i+1][6]; - eq[8][i] = IsEqual(); - eq[8][i].in[0] <== in[i]; - eq[8][i].in[1] <== 98; - eq[9][i] = IsEqual(); - eq[9][i].in[0] <== in[i]; - eq[9][i].in[1] <== 99; + eq[6][i] = IsEqual(); + eq[6][i].in[0] <== in[i]; + eq[6][i].in[1] <== 99; and[7][i] = AND(); and[7][i].a <== states[i][6]; multi_or[2][i] = MultiOR(2); - multi_or[2][i].in[0] <== eq[8][i].out; - multi_or[2][i].in[1] <== eq[9][i].out; + multi_or[2][i].in[0] <== eq[3][i].out; + multi_or[2][i].in[1] <== eq[6][i].out; and[7][i].b <== multi_or[2][i].out; - eq[10][i] = IsEqual(); - eq[10][i].in[0] <== in[i]; - eq[10][i].in[1] <== 98; - eq[11][i] = IsEqual(); - eq[11][i].in[0] <== in[i]; - eq[11][i].in[1] <== 99; and[8][i] = AND(); and[8][i].a <== states[i][7]; multi_or[3][i] = MultiOR(2); - multi_or[3][i].in[0] <== eq[10][i].out; - multi_or[3][i].in[1] <== eq[11][i].out; + multi_or[3][i].in[0] <== eq[3][i].out; + multi_or[3][i].in[1] <== eq[6][i].out; and[8][i].b <== multi_or[3][i].out; multi_or[4][i] = MultiOR(2); multi_or[4][i].in[0] <== and[7][i].out; multi_or[4][i].in[1] <== and[8][i].out; states[i+1][7] <== multi_or[4][i].out; state_changed[i].in[6] <== states[i+1][7]; - eq[12][i] = IsEqual(); - eq[12][i].in[0] <== in[i]; - eq[12][i].in[1] <== 32; and[9][i] = AND(); and[9][i].a <== states[i][7]; - and[9][i].b <== eq[12][i].out; + and[9][i].b <== eq[4][i].out; states[i+1][8] <== and[9][i].out; state_changed[i].in[7] <== states[i+1][8]; - eq[13][i] = IsEqual(); - eq[13][i].in[0] <== in[i]; - eq[13][i].in[1] <== 100; + eq[7][i] = IsEqual(); + eq[7][i].in[0] <== in[i]; + eq[7][i].in[1] <== 100; and[10][i] = AND(); and[10][i].a <== states[i][8]; - and[10][i].b <== eq[13][i].out; + and[10][i].b <== eq[7][i].out; states[i+1][9] <== and[10][i].out; state_changed[i].in[8] <== states[i+1][9]; states[i+1][0] <== 1 - state_changed[i].out; diff --git a/packages/compiler/Cargo.toml b/packages/compiler/Cargo.toml index b6c0242..3aa40ca 100644 --- a/packages/compiler/Cargo.toml +++ b/packages/compiler/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zk-regex-compiler" -version = "1.0.5" +version = "1.0.6" authors = [ "Javier Su ", "Kata Choi ", diff --git a/packages/compiler/package.json b/packages/compiler/package.json index edc9a2e..20405c9 100644 --- a/packages/compiler/package.json +++ b/packages/compiler/package.json @@ -1,6 +1,6 @@ { "name": "@zk-email/zk-regex-compiler", - "version": "1.0.5", + "version": "1.0.6", "description": "a compiler to generate a regex verification circuit in circom from a user-defined regex. Please check [zk-regex](https://github.com/zkemail/zk-regex/tree/main) for the detail.", "main": "index.node", "contributors": [ diff --git a/packages/compiler/src/gen_circom.js b/packages/compiler/src/gen_circom.js index 2991f48..ffa817d 100644 --- a/packages/compiler/src/gen_circom.js +++ b/packages/compiler/src/gen_circom.js @@ -57,6 +57,13 @@ function genCircomAllstr(graph_json, template_name) { let and_i = 0; let multi_or_i = 0; + const range_checks = new Array(256); + for (let i = 0; i < 256; i++) { + range_checks[i] = new Array(256); + } + const eq_checks = new Array(256); + + let lines = []; lines.push("\tfor (var i = 0; i < num_bytes; i++) {"); @@ -152,29 +159,43 @@ function genCircomAllstr(graph_json, template_name) { // } for (let min_max of min_maxes) { - lines.push(`\t\tlt[${lt_i}][i] = LessEqThan(8);`); - lines.push(`\t\tlt[${lt_i}][i].in[0] <== ${min_max[0]};`); - lines.push(`\t\tlt[${lt_i}][i].in[1] <== in[i];`); + const min = min_max[0]; + const max = min_max[1]; + if (range_checks[min][max] === undefined) { + lines.push(`\t\tlt[${lt_i}][i] = LessEqThan(8);`); + lines.push(`\t\tlt[${lt_i}][i].in[0] <== ${min};`); + lines.push(`\t\tlt[${lt_i}][i].in[1] <== in[i];`); + + lines.push(`\t\tlt[${lt_i + 1}][i] = LessEqThan(8);`); + lines.push(`\t\tlt[${lt_i + 1}][i].in[0] <== in[i];`); + lines.push(`\t\tlt[${lt_i + 1}][i].in[1] <== ${max};`); - lines.push(`\t\tlt[${lt_i + 1}][i] = LessEqThan(8);`); - lines.push(`\t\tlt[${lt_i + 1}][i].in[0] <== in[i];`); - lines.push(`\t\tlt[${lt_i + 1}][i].in[1] <== ${min_max[1]};`); + lines.push(`\t\tand[${and_i}][i] = AND();`); + lines.push(`\t\tand[${and_i}][i].a <== lt[${lt_i}][i].out;`); + lines.push(`\t\tand[${and_i}][i].b <== lt[${lt_i + 1}][i].out;`); - lines.push(`\t\tand[${and_i}][i] = AND();`); - lines.push(`\t\tand[${and_i}][i].a <== lt[${lt_i}][i].out;`); - lines.push(`\t\tand[${and_i}][i].b <== lt[${lt_i + 1}][i].out;`); + eq_outputs.push(['and', and_i]); + range_checks[min][max] = [lt_i, and_i]; + lt_i += 2 + and_i += 1 + } else { + let [_, and_i] = range_checks[min][max]; + eq_outputs.push(['and', and_i]); + } - eq_outputs.push(['and', and_i]); - lt_i += 2 - and_i += 1 } for (let code of vals) { - lines.push(`\t\teq[${eq_i}][i] = IsEqual();`); - lines.push(`\t\teq[${eq_i}][i].in[0] <== in[i];`); - lines.push(`\t\teq[${eq_i}][i].in[1] <== ${code};`); - eq_outputs.push(['eq', eq_i]); - eq_i += 1 + if (eq_checks[code] === undefined) { + lines.push(`\t\teq[${eq_i}][i] = IsEqual();`); + lines.push(`\t\teq[${eq_i}][i].in[0] <== in[i];`); + lines.push(`\t\teq[${eq_i}][i].in[1] <== ${code};`); + eq_outputs.push(['eq', eq_i]); + eq_checks[code] = eq_i; + eq_i += 1 + } else { + eq_outputs.push(['eq', eq_checks[code]]); + } } lines.push(`\t\tand[${and_i}][i] = AND();`);