From c9a89c3a5dd9d42896fb44a814cc971f74c069d8 Mon Sep 17 00:00:00 2001 From: SoraSuegami Date: Mon, 26 Aug 2024 23:44:05 +0900 Subject: [PATCH] Update dependency versions and circuits. --- packages/apis/Cargo.toml | 4 +- .../common/email_addr_with_name_regex.circom | 716 +++++++++--------- .../circuits/common/from_all_regex.circom | 532 ++++++------- .../circuits/common/subject_all_regex.circom | 532 ++++++------- .../circuits/common/to_all_regex.circom | 532 ++++++------- .../circom/tests/circuits/caret5_regex.circom | 384 +++++----- .../circom/tests/circuits/dot1_regex.circom | 410 +++++----- .../circom/tests/circuits/dot2_regex.circom | 404 +++++----- .../international_chars_decomposed.circom | 100 +-- .../invitation_code_with_prefix_regex.circom | 46 +- .../tests/circuits/negate1_regex.circom | 484 ++++++------ .../tests/circuits/negate2_regex.circom | 316 ++++---- .../circom/tests/circuits/plus4_regex.circom | 38 +- packages/compiler/Cargo.toml | 10 +- 14 files changed, 2254 insertions(+), 2254 deletions(-) diff --git a/packages/apis/Cargo.toml b/packages/apis/Cargo.toml index e2e724d..9dcb11c 100644 --- a/packages/apis/Cargo.toml +++ b/packages/apis/Cargo.toml @@ -19,8 +19,8 @@ crate-type = ["rlib", "cdylib"] [dependencies] # zk-regex-compiler = { path = "../compiler", default-features = false } serde = { version = "1.0.159", features = ["derive"] } -fancy-regex = "0.11.0" -itertools = "0.10.3" +fancy-regex = "0.13.0" +itertools = "0.13.0" thiserror = "1.0.40" serde_json = "1.0.95" wasm-bindgen = "0.2" 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 0ac23ef..ff8a8c1 100644 --- a/packages/circom/circuits/common/email_addr_with_name_regex.circom +++ b/packages/circom/circuits/common/email_addr_with_name_regex.circom @@ -32,487 +32,487 @@ template EmailAddrWithNameRegex(msg_bytes) { state_changed[i] = MultiOR(13); states[i][0] <== 1; lt[0][i] = LessEqThan(8); - lt[0][i].in[0] <== 194; + lt[0][i].in[0] <== 14; lt[0][i].in[1] <== in[i]; lt[1][i] = LessEqThan(8); lt[1][i].in[0] <== in[i]; - lt[1][i].in[1] <== 223; + lt[1][i].in[1] <== 127; and[0][i] = AND(); and[0][i].a <== lt[0][i].out; and[0][i].b <== lt[1][i].out; - and[1][i] = AND(); - and[1][i].a <== states[i][0]; - and[1][i].b <== and[0][i].out; - lt[2][i] = LessEqThan(8); - lt[2][i].in[0] <== 160; - lt[2][i].in[1] <== in[i]; - lt[3][i] = LessEqThan(8); - lt[3][i].in[0] <== in[i]; - lt[3][i].in[1] <== 191; - and[2][i] = AND(); - and[2][i].a <== lt[2][i].out; - and[2][i].b <== lt[3][i].out; - and[3][i] = AND(); - and[3][i].a <== states[i][2]; - and[3][i].b <== and[2][i].out; - lt[4][i] = LessEqThan(8); - lt[4][i].in[0] <== 128; - lt[4][i].in[1] <== in[i]; - lt[5][i] = LessEqThan(8); - lt[5][i].in[0] <== in[i]; - lt[5][i].in[1] <== 191; - 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][3]; - and[5][i].b <== and[4][i].out; - lt[6][i] = LessEqThan(8); - lt[6][i].in[0] <== 128; - lt[6][i].in[1] <== in[i]; - lt[7][i] = LessEqThan(8); - lt[7][i].in[0] <== in[i]; - lt[7][i].in[1] <== 159; - 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][4]; - and[7][i].b <== and[6][i].out; - and[8][i] = AND(); - and[8][i].a <== states[i][8]; - and[8][i].b <== and[0][i].out; - and[9][i] = AND(); - and[9][i].a <== states[i][9]; - and[9][i].b <== and[0][i].out; - multi_or[0][i] = MultiOR(5); - multi_or[0][i].in[0] <== and[3][i].out; - multi_or[0][i].in[1] <== and[5][i].out; - multi_or[0][i].in[2] <== and[7][i].out; - multi_or[0][i].in[3] <== and[8][i].out; - multi_or[0][i].in[4] <== and[9][i].out; - states_tmp[i+1][1] <== multi_or[0][i].out; eq[0][i] = IsEqual(); eq[0][i].in[0] <== in[i]; - eq[0][i].in[1] <== 224; - and[10][i] = AND(); - and[10][i].a <== states[i][0]; - and[10][i].b <== eq[0][i].out; - and[11][i] = AND(); - and[11][i].a <== states[i][8]; - and[11][i].b <== eq[0][i].out; - and[12][i] = AND(); - and[12][i].a <== states[i][9]; - and[12][i].b <== eq[0][i].out; - multi_or[1][i] = MultiOR(2); - multi_or[1][i].in[0] <== and[11][i].out; - multi_or[1][i].in[1] <== and[12][i].out; - states_tmp[i+1][2] <== multi_or[1][i].out; + eq[0][i].in[1] <== 1; eq[1][i] = IsEqual(); eq[1][i].in[0] <== in[i]; - eq[1][i].in[1] <== 225; + eq[1][i].in[1] <== 2; eq[2][i] = IsEqual(); eq[2][i].in[0] <== in[i]; - eq[2][i].in[1] <== 226; + eq[2][i].in[1] <== 3; eq[3][i] = IsEqual(); eq[3][i].in[0] <== in[i]; - eq[3][i].in[1] <== 227; + eq[3][i].in[1] <== 4; eq[4][i] = IsEqual(); eq[4][i].in[0] <== in[i]; - eq[4][i].in[1] <== 228; + eq[4][i].in[1] <== 5; eq[5][i] = IsEqual(); eq[5][i].in[0] <== in[i]; - eq[5][i].in[1] <== 229; + eq[5][i].in[1] <== 6; eq[6][i] = IsEqual(); eq[6][i].in[0] <== in[i]; - eq[6][i].in[1] <== 230; + eq[6][i].in[1] <== 7; eq[7][i] = IsEqual(); eq[7][i].in[0] <== in[i]; - eq[7][i].in[1] <== 231; + eq[7][i].in[1] <== 8; eq[8][i] = IsEqual(); eq[8][i].in[0] <== in[i]; - eq[8][i].in[1] <== 232; + eq[8][i].in[1] <== 9; eq[9][i] = IsEqual(); eq[9][i].in[0] <== in[i]; - eq[9][i].in[1] <== 233; + eq[9][i].in[1] <== 11; eq[10][i] = IsEqual(); eq[10][i].in[0] <== in[i]; - eq[10][i].in[1] <== 234; + eq[10][i].in[1] <== 12; + and[1][i] = AND(); + and[1][i].a <== states[i][0]; + multi_or[0][i] = MultiOR(12); + multi_or[0][i].in[0] <== and[0][i].out; + multi_or[0][i].in[1] <== eq[0][i].out; + multi_or[0][i].in[2] <== eq[1][i].out; + multi_or[0][i].in[3] <== eq[2][i].out; + multi_or[0][i].in[4] <== eq[3][i].out; + multi_or[0][i].in[5] <== eq[4][i].out; + multi_or[0][i].in[6] <== eq[5][i].out; + multi_or[0][i].in[7] <== eq[6][i].out; + multi_or[0][i].in[8] <== eq[7][i].out; + multi_or[0][i].in[9] <== eq[8][i].out; + multi_or[0][i].in[10] <== eq[9][i].out; + multi_or[0][i].in[11] <== eq[10][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] <== 59; + and[2][i] = AND(); + and[2][i].a <== lt[2][i].out; + and[2][i].b <== lt[3][i].out; + lt[4][i] = LessEqThan(8); + lt[4][i].in[0] <== 61; + lt[4][i].in[1] <== in[i]; + lt[5][i] = LessEqThan(8); + lt[5][i].in[0] <== in[i]; + lt[5][i].in[1] <== 127; + and[3][i] = AND(); + and[3][i].a <== lt[4][i].out; + and[3][i].b <== lt[5][i].out; + and[4][i] = AND(); + and[4][i].a <== states[i][1]; + multi_or[1][i] = MultiOR(13); + multi_or[1][i].in[0] <== and[2][i].out; + multi_or[1][i].in[1] <== and[3][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; + and[4][i].b <== multi_or[1][i].out; + lt[6][i] = LessEqThan(8); + lt[6][i].in[0] <== 128; + lt[6][i].in[1] <== in[i]; + lt[7][i] = LessEqThan(8); + lt[7][i].in[0] <== in[i]; + lt[7][i].in[1] <== 191; + and[5][i] = AND(); + and[5][i].a <== lt[6][i].out; + and[5][i].b <== lt[7][i].out; + and[6][i] = AND(); + and[6][i].a <== states[i][2]; + and[6][i].b <== and[5][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] <== 32; + and[7][i] = AND(); + and[7][i].a <== lt[8][i].out; + and[7][i].b <== lt[9][i].out; eq[11][i] = IsEqual(); eq[11][i].in[0] <== in[i]; - eq[11][i].in[1] <== 235; + eq[11][i].in[1] <== 34; eq[12][i] = IsEqual(); eq[12][i].in[0] <== in[i]; - eq[12][i].in[1] <== 236; + eq[12][i].in[1] <== 40; eq[13][i] = IsEqual(); eq[13][i].in[0] <== in[i]; - eq[13][i].in[1] <== 238; + eq[13][i].in[1] <== 41; eq[14][i] = IsEqual(); eq[14][i].in[0] <== in[i]; - eq[14][i].in[1] <== 239; - and[13][i] = AND(); - and[13][i].a <== states[i][0]; - multi_or[2][i] = MultiOR(14); - multi_or[2][i].in[0] <== eq[1][i].out; - multi_or[2][i].in[1] <== eq[2][i].out; - multi_or[2][i].in[2] <== eq[3][i].out; - multi_or[2][i].in[3] <== eq[4][i].out; - multi_or[2][i].in[4] <== eq[5][i].out; - multi_or[2][i].in[5] <== eq[6][i].out; - multi_or[2][i].in[6] <== eq[7][i].out; - multi_or[2][i].in[7] <== eq[8][i].out; - multi_or[2][i].in[8] <== eq[9][i].out; - multi_or[2][i].in[9] <== eq[10][i].out; - multi_or[2][i].in[10] <== eq[11][i].out; - multi_or[2][i].in[11] <== eq[12][i].out; - multi_or[2][i].in[12] <== eq[13][i].out; - multi_or[2][i].in[13] <== eq[14][i].out; - and[13][i].b <== multi_or[2][i].out; - lt[8][i] = LessEqThan(8); - lt[8][i].in[0] <== 144; - lt[8][i].in[1] <== in[i]; - lt[9][i] = LessEqThan(8); - lt[9][i].in[0] <== in[i]; - lt[9][i].in[1] <== 191; - and[14][i] = AND(); - and[14][i].a <== lt[8][i].out; - and[14][i].b <== lt[9][i].out; - and[15][i] = AND(); - and[15][i].a <== states[i][5]; - and[15][i].b <== and[14][i].out; - and[16][i] = AND(); - and[16][i].a <== states[i][6]; - and[16][i].b <== and[4][i].out; + eq[14][i].in[1] <== 58; eq[15][i] = IsEqual(); eq[15][i].in[0] <== in[i]; - eq[15][i].in[1] <== 128; + eq[15][i].in[1] <== 59; eq[16][i] = IsEqual(); eq[16][i].in[0] <== in[i]; - eq[16][i].in[1] <== 129; + eq[16][i].in[1] <== 62; eq[17][i] = IsEqual(); eq[17][i].in[0] <== in[i]; - eq[17][i].in[1] <== 130; + eq[17][i].in[1] <== 64; eq[18][i] = IsEqual(); eq[18][i].in[0] <== in[i]; - eq[18][i].in[1] <== 131; + eq[18][i].in[1] <== 91; eq[19][i] = IsEqual(); eq[19][i].in[0] <== in[i]; - eq[19][i].in[1] <== 132; + eq[19][i].in[1] <== 92; eq[20][i] = IsEqual(); eq[20][i].in[0] <== in[i]; - eq[20][i].in[1] <== 133; + eq[20][i].in[1] <== 93; eq[21][i] = IsEqual(); eq[21][i].in[0] <== in[i]; - eq[21][i].in[1] <== 134; + eq[21][i].in[1] <== 127; + and[8][i] = AND(); + and[8][i].a <== states[i][9]; + multi_or[2][i] = MultiOR(23); + multi_or[2][i].in[0] <== and[7][i].out; + multi_or[2][i].in[1] <== eq[0][i].out; + multi_or[2][i].in[2] <== eq[1][i].out; + multi_or[2][i].in[3] <== eq[2][i].out; + multi_or[2][i].in[4] <== eq[3][i].out; + multi_or[2][i].in[5] <== eq[4][i].out; + multi_or[2][i].in[6] <== eq[5][i].out; + multi_or[2][i].in[7] <== eq[6][i].out; + multi_or[2][i].in[8] <== eq[7][i].out; + multi_or[2][i].in[9] <== eq[8][i].out; + multi_or[2][i].in[10] <== eq[9][i].out; + multi_or[2][i].in[11] <== eq[10][i].out; + multi_or[2][i].in[12] <== eq[11][i].out; + multi_or[2][i].in[13] <== eq[12][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; + and[8][i].b <== multi_or[2][i].out; + multi_or[3][i] = MultiOR(3); + multi_or[3][i].in[0] <== and[4][i].out; + multi_or[3][i].in[1] <== and[6][i].out; + multi_or[3][i].in[2] <== and[8][i].out; + states_tmp[i+1][1] <== multi_or[3][i].out; + lt[10][i] = LessEqThan(8); + lt[10][i].in[0] <== 194; + lt[10][i].in[1] <== in[i]; + lt[11][i] = LessEqThan(8); + lt[11][i].in[0] <== in[i]; + lt[11][i].in[1] <== 223; + 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][0]; + and[10][i].b <== and[9][i].out; + and[11][i] = AND(); + and[11][i].a <== states[i][1]; + and[11][i].b <== and[9][i].out; + lt[12][i] = LessEqThan(8); + lt[12][i].in[0] <== 160; + lt[12][i].in[1] <== in[i]; + lt[13][i] = LessEqThan(8); + lt[13][i].in[0] <== in[i]; + lt[13][i].in[1] <== 191; + and[12][i] = AND(); + and[12][i].a <== lt[12][i].out; + and[12][i].b <== lt[13][i].out; + and[13][i] = AND(); + and[13][i].a <== states[i][3]; + and[13][i].b <== and[12][i].out; + and[14][i] = AND(); + and[14][i].a <== states[i][4]; + and[14][i].b <== and[5][i].out; + lt[14][i] = LessEqThan(8); + lt[14][i].in[0] <== 128; + lt[14][i].in[1] <== in[i]; + lt[15][i] = LessEqThan(8); + lt[15][i].in[0] <== in[i]; + lt[15][i].in[1] <== 159; + and[15][i] = AND(); + and[15][i].a <== lt[14][i].out; + and[15][i].b <== lt[15][i].out; + and[16][i] = AND(); + and[16][i].a <== states[i][5]; + and[16][i].b <== and[15][i].out; + and[17][i] = AND(); + and[17][i].a <== states[i][9]; + and[17][i].b <== and[9][i].out; + multi_or[4][i] = MultiOR(5); + multi_or[4][i].in[0] <== and[11][i].out; + multi_or[4][i].in[1] <== and[13][i].out; + multi_or[4][i].in[2] <== and[14][i].out; + multi_or[4][i].in[3] <== and[16][i].out; + multi_or[4][i].in[4] <== and[17][i].out; + states_tmp[i+1][2] <== multi_or[4][i].out; eq[22][i] = IsEqual(); eq[22][i].in[0] <== in[i]; - eq[22][i].in[1] <== 135; + eq[22][i].in[1] <== 224; + and[18][i] = AND(); + and[18][i].a <== states[i][0]; + and[18][i].b <== eq[22][i].out; + and[19][i] = AND(); + and[19][i].a <== states[i][1]; + and[19][i].b <== eq[22][i].out; + and[20][i] = AND(); + and[20][i].a <== states[i][9]; + and[20][i].b <== eq[22][i].out; + multi_or[5][i] = MultiOR(2); + multi_or[5][i].in[0] <== and[19][i].out; + multi_or[5][i].in[1] <== and[20][i].out; + states_tmp[i+1][3] <== multi_or[5][i].out; eq[23][i] = IsEqual(); eq[23][i].in[0] <== in[i]; - eq[23][i].in[1] <== 136; + eq[23][i].in[1] <== 225; eq[24][i] = IsEqual(); eq[24][i].in[0] <== in[i]; - eq[24][i].in[1] <== 137; + eq[24][i].in[1] <== 226; eq[25][i] = IsEqual(); eq[25][i].in[0] <== in[i]; - eq[25][i].in[1] <== 138; + eq[25][i].in[1] <== 227; eq[26][i] = IsEqual(); eq[26][i].in[0] <== in[i]; - eq[26][i].in[1] <== 139; + eq[26][i].in[1] <== 228; eq[27][i] = IsEqual(); eq[27][i].in[0] <== in[i]; - eq[27][i].in[1] <== 140; + eq[27][i].in[1] <== 229; eq[28][i] = IsEqual(); eq[28][i].in[0] <== in[i]; - eq[28][i].in[1] <== 141; + eq[28][i].in[1] <== 230; eq[29][i] = IsEqual(); eq[29][i].in[0] <== in[i]; - eq[29][i].in[1] <== 142; + eq[29][i].in[1] <== 231; eq[30][i] = IsEqual(); eq[30][i].in[0] <== in[i]; - eq[30][i].in[1] <== 143; - and[17][i] = AND(); - and[17][i].a <== states[i][7]; - multi_or[3][i] = MultiOR(16); - multi_or[3][i].in[0] <== eq[15][i].out; - multi_or[3][i].in[1] <== eq[16][i].out; - multi_or[3][i].in[2] <== eq[17][i].out; - multi_or[3][i].in[3] <== eq[18][i].out; - multi_or[3][i].in[4] <== eq[19][i].out; - multi_or[3][i].in[5] <== eq[20][i].out; - multi_or[3][i].in[6] <== eq[21][i].out; - multi_or[3][i].in[7] <== eq[22][i].out; - multi_or[3][i].in[8] <== eq[23][i].out; - multi_or[3][i].in[9] <== eq[24][i].out; - multi_or[3][i].in[10] <== eq[25][i].out; - multi_or[3][i].in[11] <== eq[26][i].out; - multi_or[3][i].in[12] <== eq[27][i].out; - multi_or[3][i].in[13] <== eq[28][i].out; - multi_or[3][i].in[14] <== eq[29][i].out; - multi_or[3][i].in[15] <== eq[30][i].out; - and[17][i].b <== multi_or[3][i].out; - and[18][i] = AND(); - and[18][i].a <== states[i][8]; - and[18][i].b <== multi_or[2][i].out; - and[19][i] = AND(); - and[19][i].a <== states[i][9]; - and[19][i].b <== multi_or[2][i].out; - multi_or[4][i] = MultiOR(5); - multi_or[4][i].in[0] <== and[15][i].out; - multi_or[4][i].in[1] <== and[16][i].out; - multi_or[4][i].in[2] <== and[17][i].out; - multi_or[4][i].in[3] <== and[18][i].out; - multi_or[4][i].in[4] <== and[19][i].out; - states_tmp[i+1][3] <== multi_or[4][i].out; + eq[30][i].in[1] <== 232; eq[31][i] = IsEqual(); eq[31][i].in[0] <== in[i]; - eq[31][i].in[1] <== 237; - and[20][i] = AND(); - and[20][i].a <== states[i][0]; - and[20][i].b <== eq[31][i].out; - and[21][i] = AND(); - and[21][i].a <== states[i][8]; - and[21][i].b <== eq[31][i].out; - and[22][i] = AND(); - and[22][i].a <== states[i][9]; - and[22][i].b <== eq[31][i].out; - multi_or[5][i] = MultiOR(2); - multi_or[5][i].in[0] <== and[21][i].out; - multi_or[5][i].in[1] <== and[22][i].out; - states_tmp[i+1][4] <== multi_or[5][i].out; + eq[31][i].in[1] <== 233; eq[32][i] = IsEqual(); eq[32][i].in[0] <== in[i]; - eq[32][i].in[1] <== 240; - and[23][i] = AND(); - and[23][i].a <== states[i][0]; - and[23][i].b <== eq[32][i].out; - and[24][i] = AND(); - and[24][i].a <== states[i][8]; - and[24][i].b <== eq[32][i].out; - and[25][i] = AND(); - and[25][i].a <== states[i][9]; - and[25][i].b <== eq[32][i].out; - multi_or[6][i] = MultiOR(2); - multi_or[6][i].in[0] <== and[24][i].out; - multi_or[6][i].in[1] <== and[25][i].out; - states_tmp[i+1][5] <== multi_or[6][i].out; + eq[32][i].in[1] <== 234; eq[33][i] = IsEqual(); eq[33][i].in[0] <== in[i]; - eq[33][i].in[1] <== 241; + eq[33][i].in[1] <== 235; eq[34][i] = IsEqual(); eq[34][i].in[0] <== in[i]; - eq[34][i].in[1] <== 242; + eq[34][i].in[1] <== 236; eq[35][i] = IsEqual(); eq[35][i].in[0] <== in[i]; - eq[35][i].in[1] <== 243; - and[26][i] = AND(); - and[26][i].a <== states[i][0]; - multi_or[7][i] = MultiOR(3); - multi_or[7][i].in[0] <== eq[33][i].out; - multi_or[7][i].in[1] <== eq[34][i].out; - multi_or[7][i].in[2] <== eq[35][i].out; - and[26][i].b <== multi_or[7][i].out; - and[27][i] = AND(); - and[27][i].a <== states[i][8]; - and[27][i].b <== multi_or[7][i].out; - and[28][i] = AND(); - and[28][i].a <== states[i][9]; - and[28][i].b <== multi_or[7][i].out; - multi_or[8][i] = MultiOR(2); - multi_or[8][i].in[0] <== and[27][i].out; - multi_or[8][i].in[1] <== and[28][i].out; - states_tmp[i+1][6] <== multi_or[8][i].out; + eq[35][i].in[1] <== 238; eq[36][i] = IsEqual(); eq[36][i].in[0] <== in[i]; - eq[36][i].in[1] <== 244; - and[29][i] = AND(); - and[29][i].a <== states[i][0]; - and[29][i].b <== eq[36][i].out; - and[30][i] = AND(); - and[30][i].a <== states[i][8]; - and[30][i].b <== eq[36][i].out; - and[31][i] = AND(); - and[31][i].a <== states[i][9]; - and[31][i].b <== eq[36][i].out; - multi_or[9][i] = MultiOR(2); - multi_or[9][i].in[0] <== and[30][i].out; - multi_or[9][i].in[1] <== and[31][i].out; - states_tmp[i+1][7] <== multi_or[9][i].out; - lt[10][i] = LessEqThan(8); - lt[10][i].in[0] <== 14; - lt[10][i].in[1] <== in[i]; - lt[11][i] = LessEqThan(8); - lt[11][i].in[0] <== in[i]; - lt[11][i].in[1] <== 127; - and[32][i] = AND(); - and[32][i].a <== lt[10][i].out; - and[32][i].b <== lt[11][i].out; + eq[36][i].in[1] <== 239; + and[21][i] = AND(); + and[21][i].a <== states[i][0]; + multi_or[6][i] = MultiOR(14); + multi_or[6][i].in[0] <== eq[23][i].out; + multi_or[6][i].in[1] <== eq[24][i].out; + multi_or[6][i].in[2] <== eq[25][i].out; + multi_or[6][i].in[3] <== eq[26][i].out; + multi_or[6][i].in[4] <== eq[27][i].out; + multi_or[6][i].in[5] <== eq[28][i].out; + multi_or[6][i].in[6] <== eq[29][i].out; + multi_or[6][i].in[7] <== eq[30][i].out; + multi_or[6][i].in[8] <== eq[31][i].out; + multi_or[6][i].in[9] <== eq[32][i].out; + multi_or[6][i].in[10] <== eq[33][i].out; + multi_or[6][i].in[11] <== eq[34][i].out; + multi_or[6][i].in[12] <== eq[35][i].out; + multi_or[6][i].in[13] <== eq[36][i].out; + and[21][i].b <== multi_or[6][i].out; + and[22][i] = AND(); + and[22][i].a <== states[i][1]; + and[22][i].b <== multi_or[6][i].out; + lt[16][i] = LessEqThan(8); + lt[16][i].in[0] <== 144; + lt[16][i].in[1] <== in[i]; + lt[17][i] = LessEqThan(8); + lt[17][i].in[0] <== in[i]; + lt[17][i].in[1] <== 191; + and[23][i] = AND(); + and[23][i].a <== lt[16][i].out; + and[23][i].b <== lt[17][i].out; + and[24][i] = AND(); + and[24][i].a <== states[i][6]; + and[24][i].b <== and[23][i].out; + and[25][i] = AND(); + and[25][i].a <== states[i][7]; + and[25][i].b <== and[5][i].out; eq[37][i] = IsEqual(); eq[37][i].in[0] <== in[i]; - eq[37][i].in[1] <== 1; + eq[37][i].in[1] <== 128; eq[38][i] = IsEqual(); eq[38][i].in[0] <== in[i]; - eq[38][i].in[1] <== 2; + eq[38][i].in[1] <== 129; eq[39][i] = IsEqual(); eq[39][i].in[0] <== in[i]; - eq[39][i].in[1] <== 3; + eq[39][i].in[1] <== 130; eq[40][i] = IsEqual(); eq[40][i].in[0] <== in[i]; - eq[40][i].in[1] <== 4; + eq[40][i].in[1] <== 131; eq[41][i] = IsEqual(); eq[41][i].in[0] <== in[i]; - eq[41][i].in[1] <== 5; + eq[41][i].in[1] <== 132; eq[42][i] = IsEqual(); eq[42][i].in[0] <== in[i]; - eq[42][i].in[1] <== 6; + eq[42][i].in[1] <== 133; eq[43][i] = IsEqual(); eq[43][i].in[0] <== in[i]; - eq[43][i].in[1] <== 7; + eq[43][i].in[1] <== 134; eq[44][i] = IsEqual(); eq[44][i].in[0] <== in[i]; - eq[44][i].in[1] <== 8; + eq[44][i].in[1] <== 135; eq[45][i] = IsEqual(); eq[45][i].in[0] <== in[i]; - eq[45][i].in[1] <== 9; + eq[45][i].in[1] <== 136; eq[46][i] = IsEqual(); eq[46][i].in[0] <== in[i]; - eq[46][i].in[1] <== 11; + eq[46][i].in[1] <== 137; eq[47][i] = IsEqual(); eq[47][i].in[0] <== in[i]; - eq[47][i].in[1] <== 12; - and[33][i] = AND(); - and[33][i].a <== states[i][0]; - multi_or[10][i] = MultiOR(12); - multi_or[10][i].in[0] <== and[32][i].out; - multi_or[10][i].in[1] <== eq[37][i].out; - multi_or[10][i].in[2] <== eq[38][i].out; - multi_or[10][i].in[3] <== eq[39][i].out; - multi_or[10][i].in[4] <== eq[40][i].out; - multi_or[10][i].in[5] <== eq[41][i].out; - multi_or[10][i].in[6] <== eq[42][i].out; - multi_or[10][i].in[7] <== eq[43][i].out; - multi_or[10][i].in[8] <== eq[44][i].out; - multi_or[10][i].in[9] <== eq[45][i].out; - multi_or[10][i].in[10] <== eq[46][i].out; - multi_or[10][i].in[11] <== eq[47][i].out; - and[33][i].b <== multi_or[10][i].out; - and[34][i] = AND(); - and[34][i].a <== states[i][1]; - and[34][i].b <== and[4][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] <== 59; - and[35][i] = AND(); - and[35][i].a <== lt[12][i].out; - and[35][i].b <== lt[13][i].out; - lt[14][i] = LessEqThan(8); - lt[14][i].in[0] <== 61; - lt[14][i].in[1] <== in[i]; - lt[15][i] = LessEqThan(8); - lt[15][i].in[0] <== in[i]; - lt[15][i].in[1] <== 127; - and[36][i] = AND(); - and[36][i].a <== lt[14][i].out; - and[36][i].b <== lt[15][i].out; - and[37][i] = AND(); - and[37][i].a <== states[i][8]; - multi_or[11][i] = MultiOR(13); - multi_or[11][i].in[0] <== and[35][i].out; - multi_or[11][i].in[1] <== and[36][i].out; - multi_or[11][i].in[2] <== eq[37][i].out; - multi_or[11][i].in[3] <== eq[38][i].out; - multi_or[11][i].in[4] <== eq[39][i].out; - multi_or[11][i].in[5] <== eq[40][i].out; - multi_or[11][i].in[6] <== eq[41][i].out; - multi_or[11][i].in[7] <== eq[42][i].out; - multi_or[11][i].in[8] <== eq[43][i].out; - multi_or[11][i].in[9] <== eq[44][i].out; - multi_or[11][i].in[10] <== eq[45][i].out; - multi_or[11][i].in[11] <== eq[46][i].out; - multi_or[11][i].in[12] <== eq[47][i].out; - and[37][i].b <== multi_or[11][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] <== 32; - and[38][i] = AND(); - and[38][i].a <== lt[16][i].out; - and[38][i].b <== lt[17][i].out; + eq[47][i].in[1] <== 138; eq[48][i] = IsEqual(); eq[48][i].in[0] <== in[i]; - eq[48][i].in[1] <== 34; + eq[48][i].in[1] <== 139; eq[49][i] = IsEqual(); eq[49][i].in[0] <== in[i]; - eq[49][i].in[1] <== 40; + eq[49][i].in[1] <== 140; eq[50][i] = IsEqual(); eq[50][i].in[0] <== in[i]; - eq[50][i].in[1] <== 41; + eq[50][i].in[1] <== 141; eq[51][i] = IsEqual(); eq[51][i].in[0] <== in[i]; - eq[51][i].in[1] <== 58; + eq[51][i].in[1] <== 142; eq[52][i] = IsEqual(); eq[52][i].in[0] <== in[i]; - eq[52][i].in[1] <== 59; + eq[52][i].in[1] <== 143; + and[26][i] = AND(); + and[26][i].a <== states[i][8]; + multi_or[7][i] = MultiOR(16); + multi_or[7][i].in[0] <== eq[37][i].out; + multi_or[7][i].in[1] <== eq[38][i].out; + multi_or[7][i].in[2] <== eq[39][i].out; + multi_or[7][i].in[3] <== eq[40][i].out; + multi_or[7][i].in[4] <== eq[41][i].out; + multi_or[7][i].in[5] <== eq[42][i].out; + multi_or[7][i].in[6] <== eq[43][i].out; + multi_or[7][i].in[7] <== eq[44][i].out; + multi_or[7][i].in[8] <== eq[45][i].out; + multi_or[7][i].in[9] <== eq[46][i].out; + multi_or[7][i].in[10] <== eq[47][i].out; + multi_or[7][i].in[11] <== eq[48][i].out; + multi_or[7][i].in[12] <== eq[49][i].out; + multi_or[7][i].in[13] <== eq[50][i].out; + multi_or[7][i].in[14] <== eq[51][i].out; + multi_or[7][i].in[15] <== eq[52][i].out; + and[26][i].b <== multi_or[7][i].out; + and[27][i] = AND(); + and[27][i].a <== states[i][9]; + and[27][i].b <== multi_or[6][i].out; + multi_or[8][i] = MultiOR(5); + multi_or[8][i].in[0] <== and[22][i].out; + multi_or[8][i].in[1] <== and[24][i].out; + multi_or[8][i].in[2] <== and[25][i].out; + multi_or[8][i].in[3] <== and[26][i].out; + multi_or[8][i].in[4] <== and[27][i].out; + states_tmp[i+1][4] <== multi_or[8][i].out; eq[53][i] = IsEqual(); eq[53][i].in[0] <== in[i]; - eq[53][i].in[1] <== 62; + eq[53][i].in[1] <== 237; + and[28][i] = AND(); + and[28][i].a <== states[i][0]; + and[28][i].b <== eq[53][i].out; + and[29][i] = AND(); + and[29][i].a <== states[i][1]; + and[29][i].b <== eq[53][i].out; + and[30][i] = AND(); + and[30][i].a <== states[i][9]; + and[30][i].b <== eq[53][i].out; + multi_or[9][i] = MultiOR(2); + multi_or[9][i].in[0] <== and[29][i].out; + multi_or[9][i].in[1] <== and[30][i].out; + states_tmp[i+1][5] <== multi_or[9][i].out; eq[54][i] = IsEqual(); eq[54][i].in[0] <== in[i]; - eq[54][i].in[1] <== 64; + eq[54][i].in[1] <== 240; + and[31][i] = AND(); + and[31][i].a <== states[i][0]; + and[31][i].b <== eq[54][i].out; + and[32][i] = AND(); + and[32][i].a <== states[i][1]; + and[32][i].b <== eq[54][i].out; + and[33][i] = AND(); + and[33][i].a <== states[i][9]; + and[33][i].b <== eq[54][i].out; + multi_or[10][i] = MultiOR(2); + multi_or[10][i].in[0] <== and[32][i].out; + multi_or[10][i].in[1] <== and[33][i].out; + states_tmp[i+1][6] <== multi_or[10][i].out; eq[55][i] = IsEqual(); eq[55][i].in[0] <== in[i]; - eq[55][i].in[1] <== 91; + eq[55][i].in[1] <== 241; eq[56][i] = IsEqual(); eq[56][i].in[0] <== in[i]; - eq[56][i].in[1] <== 92; + eq[56][i].in[1] <== 242; eq[57][i] = IsEqual(); eq[57][i].in[0] <== in[i]; - eq[57][i].in[1] <== 93; + eq[57][i].in[1] <== 243; + and[34][i] = AND(); + and[34][i].a <== states[i][0]; + multi_or[11][i] = MultiOR(3); + multi_or[11][i].in[0] <== eq[55][i].out; + multi_or[11][i].in[1] <== eq[56][i].out; + multi_or[11][i].in[2] <== eq[57][i].out; + and[34][i].b <== multi_or[11][i].out; + and[35][i] = AND(); + and[35][i].a <== states[i][1]; + and[35][i].b <== multi_or[11][i].out; + and[36][i] = AND(); + and[36][i].a <== states[i][9]; + and[36][i].b <== multi_or[11][i].out; + multi_or[12][i] = MultiOR(2); + multi_or[12][i].in[0] <== and[35][i].out; + multi_or[12][i].in[1] <== and[36][i].out; + states_tmp[i+1][7] <== multi_or[12][i].out; eq[58][i] = IsEqual(); eq[58][i].in[0] <== in[i]; - eq[58][i].in[1] <== 127; + eq[58][i].in[1] <== 244; + and[37][i] = AND(); + and[37][i].a <== states[i][0]; + and[37][i].b <== eq[58][i].out; + and[38][i] = AND(); + and[38][i].a <== states[i][1]; + and[38][i].b <== eq[58][i].out; and[39][i] = AND(); and[39][i].a <== states[i][9]; - multi_or[12][i] = MultiOR(23); - multi_or[12][i].in[0] <== and[38][i].out; - multi_or[12][i].in[1] <== eq[37][i].out; - multi_or[12][i].in[2] <== eq[38][i].out; - multi_or[12][i].in[3] <== eq[39][i].out; - multi_or[12][i].in[4] <== eq[40][i].out; - multi_or[12][i].in[5] <== eq[41][i].out; - multi_or[12][i].in[6] <== eq[42][i].out; - multi_or[12][i].in[7] <== eq[43][i].out; - multi_or[12][i].in[8] <== eq[44][i].out; - multi_or[12][i].in[9] <== eq[45][i].out; - multi_or[12][i].in[10] <== eq[46][i].out; - multi_or[12][i].in[11] <== eq[47][i].out; - multi_or[12][i].in[12] <== eq[48][i].out; - multi_or[12][i].in[13] <== eq[49][i].out; - multi_or[12][i].in[14] <== eq[50][i].out; - multi_or[12][i].in[15] <== eq[51][i].out; - multi_or[12][i].in[16] <== eq[52][i].out; - multi_or[12][i].in[17] <== eq[53][i].out; - multi_or[12][i].in[18] <== eq[54][i].out; - multi_or[12][i].in[19] <== eq[55][i].out; - multi_or[12][i].in[20] <== eq[56][i].out; - multi_or[12][i].in[21] <== eq[57][i].out; - multi_or[12][i].in[22] <== eq[58][i].out; - and[39][i].b <== multi_or[12][i].out; - multi_or[13][i] = MultiOR(3); - multi_or[13][i].in[0] <== and[34][i].out; - multi_or[13][i].in[1] <== and[37][i].out; - multi_or[13][i].in[2] <== and[39][i].out; + and[39][i].b <== eq[58][i].out; + multi_or[13][i] = MultiOR(2); + multi_or[13][i].in[0] <== and[38][i].out; + multi_or[13][i].in[1] <== and[39][i].out; states_tmp[i+1][8] <== multi_or[13][i].out; eq[59][i] = IsEqual(); eq[59][i].in[0] <== in[i]; eq[59][i].in[1] <== 60; and[40][i] = AND(); - and[40][i].a <== states[i][8]; + and[40][i].a <== states[i][1]; and[40][i].b <== eq[59][i].out; and[41][i] = AND(); and[41][i].a <== states[i][9]; @@ -650,7 +650,7 @@ template EmailAddrWithNameRegex(msg_bytes) { states[i+1][10] <== multi_or[16][i].out; and[46][i] = AND(); and[46][i].a <== states[i][10]; - and[46][i].b <== eq[54][i].out; + and[46][i].b <== eq[17][i].out; states[i+1][11] <== and[46][i].out; lt[22][i] = LessEqThan(8); lt[22][i].in[0] <== 97; @@ -692,17 +692,17 @@ template EmailAddrWithNameRegex(msg_bytes) { states[i+1][12] <== multi_or[18][i].out; and[50][i] = AND(); and[50][i].a <== states[i][12]; - and[50][i].b <== eq[53][i].out; + and[50][i].b <== eq[16][i].out; states[i+1][13] <== and[50][i].out; from_zero_enabled[i] <== MultiNOR(13)([states_tmp[i+1][1], states_tmp[i+1][2], states_tmp[i+1][3], states_tmp[i+1][4], states_tmp[i+1][5], states_tmp[i+1][6], states_tmp[i+1][7], states_tmp[i+1][8], states[i+1][9], states[i+1][10], states[i+1][11], states[i+1][12], states[i+1][13]]); states[i+1][1] <== MultiOR(2)([states_tmp[i+1][1], from_zero_enabled[i] * and[1][i].out]); states[i+1][2] <== MultiOR(2)([states_tmp[i+1][2], from_zero_enabled[i] * and[10][i].out]); - states[i+1][3] <== MultiOR(2)([states_tmp[i+1][3], from_zero_enabled[i] * and[13][i].out]); - states[i+1][4] <== MultiOR(2)([states_tmp[i+1][4], from_zero_enabled[i] * and[20][i].out]); - states[i+1][5] <== MultiOR(2)([states_tmp[i+1][5], from_zero_enabled[i] * and[23][i].out]); - states[i+1][6] <== MultiOR(2)([states_tmp[i+1][6], from_zero_enabled[i] * and[26][i].out]); - states[i+1][7] <== MultiOR(2)([states_tmp[i+1][7], from_zero_enabled[i] * and[29][i].out]); - states[i+1][8] <== MultiOR(2)([states_tmp[i+1][8], from_zero_enabled[i] * and[33][i].out]); + states[i+1][3] <== MultiOR(2)([states_tmp[i+1][3], from_zero_enabled[i] * and[18][i].out]); + states[i+1][4] <== MultiOR(2)([states_tmp[i+1][4], from_zero_enabled[i] * and[21][i].out]); + states[i+1][5] <== MultiOR(2)([states_tmp[i+1][5], from_zero_enabled[i] * and[28][i].out]); + states[i+1][6] <== MultiOR(2)([states_tmp[i+1][6], from_zero_enabled[i] * and[31][i].out]); + states[i+1][7] <== MultiOR(2)([states_tmp[i+1][7], from_zero_enabled[i] * and[34][i].out]); + states[i+1][8] <== MultiOR(2)([states_tmp[i+1][8], from_zero_enabled[i] * and[37][i].out]); state_changed[i].in[0] <== states[i+1][1]; state_changed[i].in[1] <== states[i+1][2]; state_changed[i].in[2] <== states[i+1][3]; diff --git a/packages/circom/circuits/common/from_all_regex.circom b/packages/circom/circuits/common/from_all_regex.circom index bdafa99..0326ca7 100644 --- a/packages/circom/circuits/common/from_all_regex.circom +++ b/packages/circom/circuits/common/from_all_regex.circom @@ -87,362 +87,362 @@ template FromAllRegex(msg_bytes) { and[7][i].b <== eq[7][i].out; states[i+1][7] <== and[7][i].out; lt[0][i] = LessEqThan(8); - lt[0][i].in[0] <== 194; + lt[0][i].in[0] <== 14; lt[0][i].in[1] <== in[i]; lt[1][i] = LessEqThan(8); lt[1][i].in[0] <== in[i]; - lt[1][i].in[1] <== 223; + lt[1][i].in[1] <== 127; and[8][i] = AND(); and[8][i].a <== lt[0][i].out; and[8][i].b <== lt[1][i].out; - and[9][i] = AND(); - and[9][i].a <== states[i][7]; - and[9][i].b <== and[8][i].out; - lt[2][i] = LessEqThan(8); - lt[2][i].in[0] <== 160; - lt[2][i].in[1] <== in[i]; - lt[3][i] = LessEqThan(8); - lt[3][i].in[0] <== in[i]; - lt[3][i].in[1] <== 191; - and[10][i] = AND(); - and[10][i].a <== lt[2][i].out; - and[10][i].b <== lt[3][i].out; - and[11][i] = AND(); - and[11][i].a <== states[i][9]; - and[11][i].b <== and[10][i].out; - lt[4][i] = LessEqThan(8); - lt[4][i].in[0] <== 128; - lt[4][i].in[1] <== in[i]; - lt[5][i] = LessEqThan(8); - lt[5][i].in[0] <== in[i]; - lt[5][i].in[1] <== 191; - and[12][i] = AND(); - and[12][i].a <== lt[4][i].out; - and[12][i].b <== lt[5][i].out; - and[13][i] = AND(); - and[13][i].a <== states[i][10]; - and[13][i].b <== and[12][i].out; - lt[6][i] = LessEqThan(8); - lt[6][i].in[0] <== 128; - lt[6][i].in[1] <== in[i]; - lt[7][i] = LessEqThan(8); - lt[7][i].in[0] <== in[i]; - lt[7][i].in[1] <== 159; - and[14][i] = AND(); - and[14][i].a <== lt[6][i].out; - and[14][i].b <== lt[7][i].out; - and[15][i] = AND(); - and[15][i].a <== states[i][11]; - and[15][i].b <== and[14][i].out; - and[16][i] = AND(); - and[16][i].a <== states[i][15]; - and[16][i].b <== and[8][i].out; - multi_or[0][i] = MultiOR(5); - multi_or[0][i].in[0] <== and[9][i].out; - multi_or[0][i].in[1] <== and[11][i].out; - multi_or[0][i].in[2] <== and[13][i].out; - multi_or[0][i].in[3] <== and[15][i].out; - multi_or[0][i].in[4] <== and[16][i].out; - states[i+1][8] <== multi_or[0][i].out; eq[8][i] = IsEqual(); eq[8][i].in[0] <== in[i]; - eq[8][i].in[1] <== 224; - and[17][i] = AND(); - and[17][i].a <== states[i][7]; - and[17][i].b <== eq[8][i].out; - and[18][i] = AND(); - and[18][i].a <== states[i][15]; - and[18][i].b <== eq[8][i].out; - multi_or[1][i] = MultiOR(2); - multi_or[1][i].in[0] <== and[17][i].out; - multi_or[1][i].in[1] <== and[18][i].out; - states[i+1][9] <== multi_or[1][i].out; + eq[8][i].in[1] <== 1; eq[9][i] = IsEqual(); eq[9][i].in[0] <== in[i]; - eq[9][i].in[1] <== 225; + eq[9][i].in[1] <== 2; eq[10][i] = IsEqual(); eq[10][i].in[0] <== in[i]; - eq[10][i].in[1] <== 226; + eq[10][i].in[1] <== 3; eq[11][i] = IsEqual(); eq[11][i].in[0] <== in[i]; - eq[11][i].in[1] <== 227; + eq[11][i].in[1] <== 4; eq[12][i] = IsEqual(); eq[12][i].in[0] <== in[i]; - eq[12][i].in[1] <== 228; + eq[12][i].in[1] <== 5; eq[13][i] = IsEqual(); eq[13][i].in[0] <== in[i]; - eq[13][i].in[1] <== 229; + eq[13][i].in[1] <== 6; eq[14][i] = IsEqual(); eq[14][i].in[0] <== in[i]; - eq[14][i].in[1] <== 230; + eq[14][i].in[1] <== 7; eq[15][i] = IsEqual(); eq[15][i].in[0] <== in[i]; - eq[15][i].in[1] <== 231; + eq[15][i].in[1] <== 8; eq[16][i] = IsEqual(); eq[16][i].in[0] <== in[i]; - eq[16][i].in[1] <== 232; + eq[16][i].in[1] <== 9; eq[17][i] = IsEqual(); eq[17][i].in[0] <== in[i]; - eq[17][i].in[1] <== 233; + eq[17][i].in[1] <== 11; eq[18][i] = IsEqual(); eq[18][i].in[0] <== in[i]; - eq[18][i].in[1] <== 234; + eq[18][i].in[1] <== 12; + and[9][i] = AND(); + and[9][i].a <== states[i][7]; + multi_or[0][i] = MultiOR(12); + multi_or[0][i].in[0] <== and[8][i].out; + multi_or[0][i].in[1] <== eq[8][i].out; + multi_or[0][i].in[2] <== eq[9][i].out; + multi_or[0][i].in[3] <== eq[10][i].out; + multi_or[0][i].in[4] <== eq[11][i].out; + multi_or[0][i].in[5] <== eq[12][i].out; + multi_or[0][i].in[6] <== eq[13][i].out; + multi_or[0][i].in[7] <== eq[14][i].out; + multi_or[0][i].in[8] <== eq[15][i].out; + multi_or[0][i].in[9] <== eq[16][i].out; + multi_or[0][i].in[10] <== eq[17][i].out; + multi_or[0][i].in[11] <== eq[18][i].out; + and[9][i].b <== multi_or[0][i].out; + and[10][i] = AND(); + and[10][i].a <== states[i][8]; + and[10][i].b <== multi_or[0][i].out; + lt[2][i] = LessEqThan(8); + lt[2][i].in[0] <== 128; + lt[2][i].in[1] <== in[i]; + lt[3][i] = LessEqThan(8); + lt[3][i].in[0] <== in[i]; + lt[3][i].in[1] <== 191; + and[11][i] = AND(); + and[11][i].a <== lt[2][i].out; + and[11][i].b <== lt[3][i].out; + and[12][i] = AND(); + and[12][i].a <== states[i][9]; + and[12][i].b <== and[11][i].out; + multi_or[1][i] = MultiOR(3); + multi_or[1][i].in[0] <== and[9][i].out; + multi_or[1][i].in[1] <== and[10][i].out; + multi_or[1][i].in[2] <== and[12][i].out; + states[i+1][8] <== multi_or[1][i].out; + lt[4][i] = LessEqThan(8); + lt[4][i].in[0] <== 194; + lt[4][i].in[1] <== in[i]; + lt[5][i] = LessEqThan(8); + lt[5][i].in[0] <== in[i]; + lt[5][i].in[1] <== 223; + and[13][i] = AND(); + and[13][i].a <== lt[4][i].out; + and[13][i].b <== lt[5][i].out; + and[14][i] = AND(); + and[14][i].a <== states[i][7]; + and[14][i].b <== and[13][i].out; + and[15][i] = AND(); + and[15][i].a <== states[i][8]; + and[15][i].b <== and[13][i].out; + lt[6][i] = LessEqThan(8); + lt[6][i].in[0] <== 160; + lt[6][i].in[1] <== in[i]; + lt[7][i] = LessEqThan(8); + lt[7][i].in[0] <== in[i]; + lt[7][i].in[1] <== 191; + and[16][i] = AND(); + and[16][i].a <== lt[6][i].out; + and[16][i].b <== lt[7][i].out; + and[17][i] = AND(); + and[17][i].a <== states[i][10]; + and[17][i].b <== and[16][i].out; + and[18][i] = AND(); + and[18][i].a <== states[i][11]; + and[18][i].b <== and[11][i].out; + lt[8][i] = LessEqThan(8); + lt[8][i].in[0] <== 128; + lt[8][i].in[1] <== in[i]; + lt[9][i] = LessEqThan(8); + lt[9][i].in[0] <== in[i]; + lt[9][i].in[1] <== 159; + and[19][i] = AND(); + and[19][i].a <== lt[8][i].out; + and[19][i].b <== lt[9][i].out; + and[20][i] = AND(); + and[20][i].a <== states[i][12]; + and[20][i].b <== and[19][i].out; + multi_or[2][i] = MultiOR(5); + multi_or[2][i].in[0] <== and[14][i].out; + multi_or[2][i].in[1] <== and[15][i].out; + multi_or[2][i].in[2] <== and[17][i].out; + multi_or[2][i].in[3] <== and[18][i].out; + multi_or[2][i].in[4] <== and[20][i].out; + states[i+1][9] <== multi_or[2][i].out; eq[19][i] = IsEqual(); eq[19][i].in[0] <== in[i]; - eq[19][i].in[1] <== 235; + eq[19][i].in[1] <== 224; + and[21][i] = AND(); + and[21][i].a <== states[i][7]; + and[21][i].b <== eq[19][i].out; + and[22][i] = AND(); + and[22][i].a <== states[i][8]; + and[22][i].b <== eq[19][i].out; + multi_or[3][i] = MultiOR(2); + multi_or[3][i].in[0] <== and[21][i].out; + multi_or[3][i].in[1] <== and[22][i].out; + states[i+1][10] <== multi_or[3][i].out; eq[20][i] = IsEqual(); eq[20][i].in[0] <== in[i]; - eq[20][i].in[1] <== 236; + eq[20][i].in[1] <== 225; eq[21][i] = IsEqual(); eq[21][i].in[0] <== in[i]; - eq[21][i].in[1] <== 238; + eq[21][i].in[1] <== 226; eq[22][i] = IsEqual(); eq[22][i].in[0] <== in[i]; - eq[22][i].in[1] <== 239; - and[19][i] = AND(); - and[19][i].a <== states[i][7]; - multi_or[2][i] = MultiOR(14); - multi_or[2][i].in[0] <== eq[9][i].out; - multi_or[2][i].in[1] <== eq[10][i].out; - multi_or[2][i].in[2] <== eq[11][i].out; - multi_or[2][i].in[3] <== eq[12][i].out; - multi_or[2][i].in[4] <== eq[13][i].out; - multi_or[2][i].in[5] <== eq[14][i].out; - multi_or[2][i].in[6] <== eq[15][i].out; - multi_or[2][i].in[7] <== eq[16][i].out; - multi_or[2][i].in[8] <== eq[17][i].out; - multi_or[2][i].in[9] <== eq[18][i].out; - multi_or[2][i].in[10] <== eq[19][i].out; - multi_or[2][i].in[11] <== eq[20][i].out; - multi_or[2][i].in[12] <== eq[21][i].out; - multi_or[2][i].in[13] <== eq[22][i].out; - and[19][i].b <== multi_or[2][i].out; - lt[8][i] = LessEqThan(8); - lt[8][i].in[0] <== 144; - lt[8][i].in[1] <== in[i]; - lt[9][i] = LessEqThan(8); - lt[9][i].in[0] <== in[i]; - lt[9][i].in[1] <== 191; - and[20][i] = AND(); - and[20][i].a <== lt[8][i].out; - and[20][i].b <== lt[9][i].out; - and[21][i] = AND(); - and[21][i].a <== states[i][12]; - and[21][i].b <== and[20][i].out; - and[22][i] = AND(); - and[22][i].a <== states[i][13]; - and[22][i].b <== and[12][i].out; + eq[22][i].in[1] <== 227; eq[23][i] = IsEqual(); eq[23][i].in[0] <== in[i]; - eq[23][i].in[1] <== 128; + eq[23][i].in[1] <== 228; eq[24][i] = IsEqual(); eq[24][i].in[0] <== in[i]; - eq[24][i].in[1] <== 129; + eq[24][i].in[1] <== 229; eq[25][i] = IsEqual(); eq[25][i].in[0] <== in[i]; - eq[25][i].in[1] <== 130; + eq[25][i].in[1] <== 230; eq[26][i] = IsEqual(); eq[26][i].in[0] <== in[i]; - eq[26][i].in[1] <== 131; + eq[26][i].in[1] <== 231; eq[27][i] = IsEqual(); eq[27][i].in[0] <== in[i]; - eq[27][i].in[1] <== 132; + eq[27][i].in[1] <== 232; eq[28][i] = IsEqual(); eq[28][i].in[0] <== in[i]; - eq[28][i].in[1] <== 133; + eq[28][i].in[1] <== 233; eq[29][i] = IsEqual(); eq[29][i].in[0] <== in[i]; - eq[29][i].in[1] <== 134; + eq[29][i].in[1] <== 234; eq[30][i] = IsEqual(); eq[30][i].in[0] <== in[i]; - eq[30][i].in[1] <== 135; + eq[30][i].in[1] <== 235; eq[31][i] = IsEqual(); eq[31][i].in[0] <== in[i]; - eq[31][i].in[1] <== 136; + eq[31][i].in[1] <== 236; eq[32][i] = IsEqual(); eq[32][i].in[0] <== in[i]; - eq[32][i].in[1] <== 137; + eq[32][i].in[1] <== 238; eq[33][i] = IsEqual(); eq[33][i].in[0] <== in[i]; - eq[33][i].in[1] <== 138; + eq[33][i].in[1] <== 239; + and[23][i] = AND(); + and[23][i].a <== states[i][7]; + multi_or[4][i] = MultiOR(14); + multi_or[4][i].in[0] <== eq[20][i].out; + multi_or[4][i].in[1] <== eq[21][i].out; + multi_or[4][i].in[2] <== eq[22][i].out; + multi_or[4][i].in[3] <== eq[23][i].out; + multi_or[4][i].in[4] <== eq[24][i].out; + multi_or[4][i].in[5] <== eq[25][i].out; + multi_or[4][i].in[6] <== eq[26][i].out; + multi_or[4][i].in[7] <== eq[27][i].out; + multi_or[4][i].in[8] <== eq[28][i].out; + multi_or[4][i].in[9] <== eq[29][i].out; + multi_or[4][i].in[10] <== eq[30][i].out; + multi_or[4][i].in[11] <== eq[31][i].out; + multi_or[4][i].in[12] <== eq[32][i].out; + multi_or[4][i].in[13] <== eq[33][i].out; + and[23][i].b <== multi_or[4][i].out; + and[24][i] = AND(); + and[24][i].a <== states[i][8]; + and[24][i].b <== multi_or[4][i].out; + lt[10][i] = LessEqThan(8); + lt[10][i].in[0] <== 144; + lt[10][i].in[1] <== in[i]; + lt[11][i] = LessEqThan(8); + lt[11][i].in[0] <== in[i]; + lt[11][i].in[1] <== 191; + and[25][i] = AND(); + and[25][i].a <== lt[10][i].out; + and[25][i].b <== lt[11][i].out; + and[26][i] = AND(); + and[26][i].a <== states[i][13]; + and[26][i].b <== and[25][i].out; + and[27][i] = AND(); + and[27][i].a <== states[i][14]; + and[27][i].b <== and[11][i].out; eq[34][i] = IsEqual(); eq[34][i].in[0] <== in[i]; - eq[34][i].in[1] <== 139; + eq[34][i].in[1] <== 128; eq[35][i] = IsEqual(); eq[35][i].in[0] <== in[i]; - eq[35][i].in[1] <== 140; + eq[35][i].in[1] <== 129; eq[36][i] = IsEqual(); eq[36][i].in[0] <== in[i]; - eq[36][i].in[1] <== 141; + eq[36][i].in[1] <== 130; eq[37][i] = IsEqual(); eq[37][i].in[0] <== in[i]; - eq[37][i].in[1] <== 142; + eq[37][i].in[1] <== 131; eq[38][i] = IsEqual(); eq[38][i].in[0] <== in[i]; - eq[38][i].in[1] <== 143; - and[23][i] = AND(); - and[23][i].a <== states[i][14]; - multi_or[3][i] = MultiOR(16); - multi_or[3][i].in[0] <== eq[23][i].out; - multi_or[3][i].in[1] <== eq[24][i].out; - multi_or[3][i].in[2] <== eq[25][i].out; - multi_or[3][i].in[3] <== eq[26][i].out; - multi_or[3][i].in[4] <== eq[27][i].out; - multi_or[3][i].in[5] <== eq[28][i].out; - multi_or[3][i].in[6] <== eq[29][i].out; - multi_or[3][i].in[7] <== eq[30][i].out; - multi_or[3][i].in[8] <== eq[31][i].out; - multi_or[3][i].in[9] <== eq[32][i].out; - multi_or[3][i].in[10] <== eq[33][i].out; - multi_or[3][i].in[11] <== eq[34][i].out; - multi_or[3][i].in[12] <== eq[35][i].out; - multi_or[3][i].in[13] <== eq[36][i].out; - multi_or[3][i].in[14] <== eq[37][i].out; - multi_or[3][i].in[15] <== eq[38][i].out; - and[23][i].b <== multi_or[3][i].out; - and[24][i] = AND(); - and[24][i].a <== states[i][15]; - and[24][i].b <== multi_or[2][i].out; - multi_or[4][i] = MultiOR(5); - multi_or[4][i].in[0] <== and[19][i].out; - multi_or[4][i].in[1] <== and[21][i].out; - multi_or[4][i].in[2] <== and[22][i].out; - multi_or[4][i].in[3] <== and[23][i].out; - multi_or[4][i].in[4] <== and[24][i].out; - states[i+1][10] <== multi_or[4][i].out; + eq[38][i].in[1] <== 132; eq[39][i] = IsEqual(); eq[39][i].in[0] <== in[i]; - eq[39][i].in[1] <== 237; - and[25][i] = AND(); - and[25][i].a <== states[i][7]; - and[25][i].b <== eq[39][i].out; - and[26][i] = AND(); - and[26][i].a <== states[i][15]; - and[26][i].b <== eq[39][i].out; - multi_or[5][i] = MultiOR(2); - multi_or[5][i].in[0] <== and[25][i].out; - multi_or[5][i].in[1] <== and[26][i].out; - states[i+1][11] <== multi_or[5][i].out; + eq[39][i].in[1] <== 133; eq[40][i] = IsEqual(); eq[40][i].in[0] <== in[i]; - eq[40][i].in[1] <== 240; - and[27][i] = AND(); - and[27][i].a <== states[i][7]; - and[27][i].b <== eq[40][i].out; - and[28][i] = AND(); - and[28][i].a <== states[i][15]; - and[28][i].b <== eq[40][i].out; - multi_or[6][i] = MultiOR(2); - multi_or[6][i].in[0] <== and[27][i].out; - multi_or[6][i].in[1] <== and[28][i].out; - states[i+1][12] <== multi_or[6][i].out; + eq[40][i].in[1] <== 134; eq[41][i] = IsEqual(); eq[41][i].in[0] <== in[i]; - eq[41][i].in[1] <== 241; + eq[41][i].in[1] <== 135; eq[42][i] = IsEqual(); eq[42][i].in[0] <== in[i]; - eq[42][i].in[1] <== 242; + eq[42][i].in[1] <== 136; eq[43][i] = IsEqual(); eq[43][i].in[0] <== in[i]; - eq[43][i].in[1] <== 243; - and[29][i] = AND(); - and[29][i].a <== states[i][7]; - multi_or[7][i] = MultiOR(3); - multi_or[7][i].in[0] <== eq[41][i].out; - multi_or[7][i].in[1] <== eq[42][i].out; - multi_or[7][i].in[2] <== eq[43][i].out; - and[29][i].b <== multi_or[7][i].out; - and[30][i] = AND(); - and[30][i].a <== states[i][15]; - and[30][i].b <== multi_or[7][i].out; - multi_or[8][i] = MultiOR(2); - multi_or[8][i].in[0] <== and[29][i].out; - multi_or[8][i].in[1] <== and[30][i].out; - states[i+1][13] <== multi_or[8][i].out; + eq[43][i].in[1] <== 137; eq[44][i] = IsEqual(); eq[44][i].in[0] <== in[i]; - eq[44][i].in[1] <== 244; - and[31][i] = AND(); - and[31][i].a <== states[i][7]; - and[31][i].b <== eq[44][i].out; - and[32][i] = AND(); - and[32][i].a <== states[i][15]; - and[32][i].b <== eq[44][i].out; - multi_or[9][i] = MultiOR(2); - multi_or[9][i].in[0] <== and[31][i].out; - multi_or[9][i].in[1] <== and[32][i].out; - states[i+1][14] <== multi_or[9][i].out; - lt[10][i] = LessEqThan(8); - lt[10][i].in[0] <== 14; - lt[10][i].in[1] <== in[i]; - lt[11][i] = LessEqThan(8); - lt[11][i].in[0] <== in[i]; - lt[11][i].in[1] <== 127; - and[33][i] = AND(); - and[33][i].a <== lt[10][i].out; - and[33][i].b <== lt[11][i].out; + eq[44][i].in[1] <== 138; eq[45][i] = IsEqual(); eq[45][i].in[0] <== in[i]; - eq[45][i].in[1] <== 1; + eq[45][i].in[1] <== 139; eq[46][i] = IsEqual(); eq[46][i].in[0] <== in[i]; - eq[46][i].in[1] <== 2; + eq[46][i].in[1] <== 140; eq[47][i] = IsEqual(); eq[47][i].in[0] <== in[i]; - eq[47][i].in[1] <== 3; + eq[47][i].in[1] <== 141; eq[48][i] = IsEqual(); eq[48][i].in[0] <== in[i]; - eq[48][i].in[1] <== 4; + eq[48][i].in[1] <== 142; eq[49][i] = IsEqual(); eq[49][i].in[0] <== in[i]; - eq[49][i].in[1] <== 5; + eq[49][i].in[1] <== 143; + and[28][i] = AND(); + and[28][i].a <== states[i][15]; + multi_or[5][i] = MultiOR(16); + multi_or[5][i].in[0] <== eq[34][i].out; + multi_or[5][i].in[1] <== eq[35][i].out; + multi_or[5][i].in[2] <== eq[36][i].out; + multi_or[5][i].in[3] <== eq[37][i].out; + multi_or[5][i].in[4] <== eq[38][i].out; + multi_or[5][i].in[5] <== eq[39][i].out; + multi_or[5][i].in[6] <== eq[40][i].out; + multi_or[5][i].in[7] <== eq[41][i].out; + multi_or[5][i].in[8] <== eq[42][i].out; + multi_or[5][i].in[9] <== eq[43][i].out; + multi_or[5][i].in[10] <== eq[44][i].out; + multi_or[5][i].in[11] <== eq[45][i].out; + multi_or[5][i].in[12] <== eq[46][i].out; + multi_or[5][i].in[13] <== eq[47][i].out; + multi_or[5][i].in[14] <== eq[48][i].out; + multi_or[5][i].in[15] <== eq[49][i].out; + and[28][i].b <== multi_or[5][i].out; + multi_or[6][i] = MultiOR(5); + multi_or[6][i].in[0] <== and[23][i].out; + multi_or[6][i].in[1] <== and[24][i].out; + multi_or[6][i].in[2] <== and[26][i].out; + multi_or[6][i].in[3] <== and[27][i].out; + multi_or[6][i].in[4] <== and[28][i].out; + states[i+1][11] <== multi_or[6][i].out; eq[50][i] = IsEqual(); eq[50][i].in[0] <== in[i]; - eq[50][i].in[1] <== 6; + eq[50][i].in[1] <== 237; + and[29][i] = AND(); + and[29][i].a <== states[i][7]; + and[29][i].b <== eq[50][i].out; + and[30][i] = AND(); + and[30][i].a <== states[i][8]; + and[30][i].b <== eq[50][i].out; + multi_or[7][i] = MultiOR(2); + multi_or[7][i].in[0] <== and[29][i].out; + multi_or[7][i].in[1] <== and[30][i].out; + states[i+1][12] <== multi_or[7][i].out; eq[51][i] = IsEqual(); eq[51][i].in[0] <== in[i]; - eq[51][i].in[1] <== 7; + eq[51][i].in[1] <== 240; + and[31][i] = AND(); + and[31][i].a <== states[i][7]; + and[31][i].b <== eq[51][i].out; + and[32][i] = AND(); + and[32][i].a <== states[i][8]; + and[32][i].b <== eq[51][i].out; + multi_or[8][i] = MultiOR(2); + multi_or[8][i].in[0] <== and[31][i].out; + multi_or[8][i].in[1] <== and[32][i].out; + states[i+1][13] <== multi_or[8][i].out; eq[52][i] = IsEqual(); eq[52][i].in[0] <== in[i]; - eq[52][i].in[1] <== 8; + eq[52][i].in[1] <== 241; eq[53][i] = IsEqual(); eq[53][i].in[0] <== in[i]; - eq[53][i].in[1] <== 9; + eq[53][i].in[1] <== 242; eq[54][i] = IsEqual(); eq[54][i].in[0] <== in[i]; - eq[54][i].in[1] <== 11; - eq[55][i] = IsEqual(); - eq[55][i].in[0] <== in[i]; - eq[55][i].in[1] <== 12; + eq[54][i].in[1] <== 243; + and[33][i] = AND(); + and[33][i].a <== states[i][7]; + multi_or[9][i] = MultiOR(3); + multi_or[9][i].in[0] <== eq[52][i].out; + multi_or[9][i].in[1] <== eq[53][i].out; + multi_or[9][i].in[2] <== eq[54][i].out; + and[33][i].b <== multi_or[9][i].out; and[34][i] = AND(); - and[34][i].a <== states[i][7]; - multi_or[10][i] = MultiOR(12); + and[34][i].a <== states[i][8]; + and[34][i].b <== multi_or[9][i].out; + multi_or[10][i] = MultiOR(2); multi_or[10][i].in[0] <== and[33][i].out; - multi_or[10][i].in[1] <== eq[45][i].out; - multi_or[10][i].in[2] <== eq[46][i].out; - multi_or[10][i].in[3] <== eq[47][i].out; - multi_or[10][i].in[4] <== eq[48][i].out; - multi_or[10][i].in[5] <== eq[49][i].out; - multi_or[10][i].in[6] <== eq[50][i].out; - multi_or[10][i].in[7] <== eq[51][i].out; - multi_or[10][i].in[8] <== eq[52][i].out; - multi_or[10][i].in[9] <== eq[53][i].out; - multi_or[10][i].in[10] <== eq[54][i].out; - multi_or[10][i].in[11] <== eq[55][i].out; - and[34][i].b <== multi_or[10][i].out; + multi_or[10][i].in[1] <== and[34][i].out; + states[i+1][14] <== multi_or[10][i].out; + eq[55][i] = IsEqual(); + eq[55][i].in[0] <== in[i]; + eq[55][i].in[1] <== 244; and[35][i] = AND(); - and[35][i].a <== states[i][8]; - and[35][i].b <== and[12][i].out; + and[35][i].a <== states[i][7]; + and[35][i].b <== eq[55][i].out; and[36][i] = AND(); - and[36][i].a <== states[i][15]; - and[36][i].b <== multi_or[10][i].out; - multi_or[11][i] = MultiOR(3); - multi_or[11][i].in[0] <== and[34][i].out; - multi_or[11][i].in[1] <== and[35][i].out; - multi_or[11][i].in[2] <== and[36][i].out; + and[36][i].a <== states[i][8]; + and[36][i].b <== eq[55][i].out; + multi_or[11][i] = MultiOR(2); + multi_or[11][i].in[0] <== and[35][i].out; + multi_or[11][i].in[1] <== and[36][i].out; states[i+1][15] <== multi_or[11][i].out; and[37][i] = AND(); - and[37][i].a <== states[i][15]; + and[37][i].a <== states[i][8]; and[37][i].b <== eq[0][i].out; states[i+1][16] <== and[37][i].out; and[38][i] = AND(); @@ -483,13 +483,13 @@ template FromAllRegex(msg_bytes) { is_consecutive[msg_bytes-1-i][1] <== state_changed[msg_bytes-i].out * is_consecutive[msg_bytes-1-i][0]; is_consecutive[msg_bytes-1-i][2] <== ORAnd()([(1 - from_zero_enabled[msg_bytes-i+1]), states[num_bytes-i][17], is_consecutive[msg_bytes-1-i][1]]); } - // substrings calculated: [{(7, 8), (7, 9), (7, 10), (7, 11), (7, 12), (7, 13), (7, 14), (7, 15), (8, 15), (9, 8), (10, 8), (11, 8), (12, 10), (13, 10), (14, 10), (15, 8), (15, 9), (15, 10), (15, 11), (15, 12), (15, 13), (15, 14), (15, 15)}] + // substrings calculated: [{(7, 8), (7, 9), (7, 10), (7, 11), (7, 12), (7, 13), (7, 14), (7, 15), (8, 8), (8, 9), (8, 10), (8, 11), (8, 12), (8, 13), (8, 14), (8, 15), (9, 8), (10, 9), (11, 9), (12, 9), (13, 11), (14, 11), (15, 11)}] signal prev_states0[23][msg_bytes]; signal is_substr0[msg_bytes]; signal is_reveal0[msg_bytes]; signal output reveal0[msg_bytes]; for (var i = 0; i < msg_bytes; i++) { - // the 0-th substring transitions: [(7, 8), (7, 9), (7, 10), (7, 11), (7, 12), (7, 13), (7, 14), (7, 15), (8, 15), (9, 8), (10, 8), (11, 8), (12, 10), (13, 10), (14, 10), (15, 8), (15, 9), (15, 10), (15, 11), (15, 12), (15, 13), (15, 14), (15, 15)] + // the 0-th substring transitions: [(7, 8), (7, 9), (7, 10), (7, 11), (7, 12), (7, 13), (7, 14), (7, 15), (8, 8), (8, 9), (8, 10), (8, 11), (8, 12), (8, 13), (8, 14), (8, 15), (9, 8), (10, 9), (11, 9), (12, 9), (13, 11), (14, 11), (15, 11)] prev_states0[0][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][7]; prev_states0[1][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][7]; prev_states0[2][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][7]; @@ -499,21 +499,21 @@ template FromAllRegex(msg_bytes) { prev_states0[6][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][7]; prev_states0[7][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][7]; prev_states0[8][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][8]; - prev_states0[9][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][9]; - prev_states0[10][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][10]; - prev_states0[11][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][11]; - prev_states0[12][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][12]; - prev_states0[13][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][13]; - prev_states0[14][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][14]; - prev_states0[15][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][15]; - prev_states0[16][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][15]; - prev_states0[17][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][15]; - prev_states0[18][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][15]; - prev_states0[19][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][15]; - prev_states0[20][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][15]; - prev_states0[21][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][15]; + prev_states0[9][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][8]; + prev_states0[10][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][8]; + prev_states0[11][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][8]; + prev_states0[12][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][8]; + prev_states0[13][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][8]; + prev_states0[14][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][8]; + prev_states0[15][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][8]; + prev_states0[16][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][9]; + prev_states0[17][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][10]; + prev_states0[18][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][11]; + prev_states0[19][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][12]; + prev_states0[20][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][13]; + prev_states0[21][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][14]; prev_states0[22][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][15]; - is_substr0[i] <== MultiOR(23)([prev_states0[0][i] * states[i+2][8], prev_states0[1][i] * states[i+2][9], prev_states0[2][i] * states[i+2][10], prev_states0[3][i] * states[i+2][11], prev_states0[4][i] * states[i+2][12], prev_states0[5][i] * states[i+2][13], prev_states0[6][i] * states[i+2][14], prev_states0[7][i] * states[i+2][15], prev_states0[8][i] * states[i+2][15], prev_states0[9][i] * states[i+2][8], prev_states0[10][i] * states[i+2][8], prev_states0[11][i] * states[i+2][8], prev_states0[12][i] * states[i+2][10], prev_states0[13][i] * states[i+2][10], prev_states0[14][i] * states[i+2][10], prev_states0[15][i] * states[i+2][8], prev_states0[16][i] * states[i+2][9], prev_states0[17][i] * states[i+2][10], prev_states0[18][i] * states[i+2][11], prev_states0[19][i] * states[i+2][12], prev_states0[20][i] * states[i+2][13], prev_states0[21][i] * states[i+2][14], prev_states0[22][i] * states[i+2][15]]); + is_substr0[i] <== MultiOR(23)([prev_states0[0][i] * states[i+2][8], prev_states0[1][i] * states[i+2][9], prev_states0[2][i] * states[i+2][10], prev_states0[3][i] * states[i+2][11], prev_states0[4][i] * states[i+2][12], prev_states0[5][i] * states[i+2][13], prev_states0[6][i] * states[i+2][14], prev_states0[7][i] * states[i+2][15], prev_states0[8][i] * states[i+2][8], prev_states0[9][i] * states[i+2][9], prev_states0[10][i] * states[i+2][10], prev_states0[11][i] * states[i+2][11], prev_states0[12][i] * states[i+2][12], prev_states0[13][i] * states[i+2][13], prev_states0[14][i] * states[i+2][14], prev_states0[15][i] * states[i+2][15], prev_states0[16][i] * states[i+2][8], prev_states0[17][i] * states[i+2][9], prev_states0[18][i] * states[i+2][9], prev_states0[19][i] * states[i+2][9], prev_states0[20][i] * states[i+2][11], prev_states0[21][i] * states[i+2][11], prev_states0[22][i] * states[i+2][11]]); is_reveal0[i] <== MultiAND(3)([out, is_substr0[i], is_consecutive[i][2]]); reveal0[i] <== in[i+1] * is_reveal0[i]; } diff --git a/packages/circom/circuits/common/subject_all_regex.circom b/packages/circom/circuits/common/subject_all_regex.circom index e3d5b41..e66edcc 100644 --- a/packages/circom/circuits/common/subject_all_regex.circom +++ b/packages/circom/circuits/common/subject_all_regex.circom @@ -108,362 +108,362 @@ template SubjectAllRegex(msg_bytes) { and[10][i].b <== eq[10][i].out; states[i+1][10] <== and[10][i].out; lt[0][i] = LessEqThan(8); - lt[0][i].in[0] <== 194; + lt[0][i].in[0] <== 14; lt[0][i].in[1] <== in[i]; lt[1][i] = LessEqThan(8); lt[1][i].in[0] <== in[i]; - lt[1][i].in[1] <== 223; + lt[1][i].in[1] <== 127; and[11][i] = AND(); and[11][i].a <== lt[0][i].out; and[11][i].b <== lt[1][i].out; - and[12][i] = AND(); - and[12][i].a <== states[i][10]; - and[12][i].b <== and[11][i].out; - lt[2][i] = LessEqThan(8); - lt[2][i].in[0] <== 160; - lt[2][i].in[1] <== in[i]; - lt[3][i] = LessEqThan(8); - lt[3][i].in[0] <== in[i]; - lt[3][i].in[1] <== 191; - and[13][i] = AND(); - and[13][i].a <== lt[2][i].out; - and[13][i].b <== lt[3][i].out; - and[14][i] = AND(); - and[14][i].a <== states[i][12]; - and[14][i].b <== and[13][i].out; - lt[4][i] = LessEqThan(8); - lt[4][i].in[0] <== 128; - lt[4][i].in[1] <== in[i]; - lt[5][i] = LessEqThan(8); - lt[5][i].in[0] <== in[i]; - lt[5][i].in[1] <== 191; - and[15][i] = AND(); - and[15][i].a <== lt[4][i].out; - and[15][i].b <== lt[5][i].out; - and[16][i] = AND(); - and[16][i].a <== states[i][13]; - and[16][i].b <== and[15][i].out; - lt[6][i] = LessEqThan(8); - lt[6][i].in[0] <== 128; - lt[6][i].in[1] <== in[i]; - lt[7][i] = LessEqThan(8); - lt[7][i].in[0] <== in[i]; - lt[7][i].in[1] <== 159; - and[17][i] = AND(); - and[17][i].a <== lt[6][i].out; - and[17][i].b <== lt[7][i].out; - and[18][i] = AND(); - and[18][i].a <== states[i][14]; - and[18][i].b <== and[17][i].out; - and[19][i] = AND(); - and[19][i].a <== states[i][18]; - and[19][i].b <== and[11][i].out; - multi_or[0][i] = MultiOR(5); - multi_or[0][i].in[0] <== and[12][i].out; - multi_or[0][i].in[1] <== and[14][i].out; - multi_or[0][i].in[2] <== and[16][i].out; - multi_or[0][i].in[3] <== and[18][i].out; - multi_or[0][i].in[4] <== and[19][i].out; - states[i+1][11] <== multi_or[0][i].out; eq[11][i] = IsEqual(); eq[11][i].in[0] <== in[i]; - eq[11][i].in[1] <== 224; - and[20][i] = AND(); - and[20][i].a <== states[i][10]; - and[20][i].b <== eq[11][i].out; - and[21][i] = AND(); - and[21][i].a <== states[i][18]; - and[21][i].b <== eq[11][i].out; - multi_or[1][i] = MultiOR(2); - multi_or[1][i].in[0] <== and[20][i].out; - multi_or[1][i].in[1] <== and[21][i].out; - states[i+1][12] <== multi_or[1][i].out; + eq[11][i].in[1] <== 1; eq[12][i] = IsEqual(); eq[12][i].in[0] <== in[i]; - eq[12][i].in[1] <== 225; + eq[12][i].in[1] <== 2; eq[13][i] = IsEqual(); eq[13][i].in[0] <== in[i]; - eq[13][i].in[1] <== 226; + eq[13][i].in[1] <== 3; eq[14][i] = IsEqual(); eq[14][i].in[0] <== in[i]; - eq[14][i].in[1] <== 227; + eq[14][i].in[1] <== 4; eq[15][i] = IsEqual(); eq[15][i].in[0] <== in[i]; - eq[15][i].in[1] <== 228; + eq[15][i].in[1] <== 5; eq[16][i] = IsEqual(); eq[16][i].in[0] <== in[i]; - eq[16][i].in[1] <== 229; + eq[16][i].in[1] <== 6; eq[17][i] = IsEqual(); eq[17][i].in[0] <== in[i]; - eq[17][i].in[1] <== 230; + eq[17][i].in[1] <== 7; eq[18][i] = IsEqual(); eq[18][i].in[0] <== in[i]; - eq[18][i].in[1] <== 231; + eq[18][i].in[1] <== 8; eq[19][i] = IsEqual(); eq[19][i].in[0] <== in[i]; - eq[19][i].in[1] <== 232; + eq[19][i].in[1] <== 9; eq[20][i] = IsEqual(); eq[20][i].in[0] <== in[i]; - eq[20][i].in[1] <== 233; + eq[20][i].in[1] <== 11; eq[21][i] = IsEqual(); eq[21][i].in[0] <== in[i]; - eq[21][i].in[1] <== 234; + eq[21][i].in[1] <== 12; + and[12][i] = AND(); + and[12][i].a <== states[i][10]; + multi_or[0][i] = MultiOR(12); + multi_or[0][i].in[0] <== and[11][i].out; + multi_or[0][i].in[1] <== eq[11][i].out; + multi_or[0][i].in[2] <== eq[12][i].out; + multi_or[0][i].in[3] <== eq[13][i].out; + multi_or[0][i].in[4] <== eq[14][i].out; + multi_or[0][i].in[5] <== eq[15][i].out; + multi_or[0][i].in[6] <== eq[16][i].out; + multi_or[0][i].in[7] <== eq[17][i].out; + multi_or[0][i].in[8] <== eq[18][i].out; + multi_or[0][i].in[9] <== eq[19][i].out; + multi_or[0][i].in[10] <== eq[20][i].out; + multi_or[0][i].in[11] <== eq[21][i].out; + and[12][i].b <== multi_or[0][i].out; + and[13][i] = AND(); + and[13][i].a <== states[i][11]; + and[13][i].b <== multi_or[0][i].out; + lt[2][i] = LessEqThan(8); + lt[2][i].in[0] <== 128; + lt[2][i].in[1] <== in[i]; + lt[3][i] = LessEqThan(8); + lt[3][i].in[0] <== in[i]; + lt[3][i].in[1] <== 191; + and[14][i] = AND(); + and[14][i].a <== lt[2][i].out; + and[14][i].b <== lt[3][i].out; + and[15][i] = AND(); + and[15][i].a <== states[i][12]; + and[15][i].b <== and[14][i].out; + multi_or[1][i] = MultiOR(3); + multi_or[1][i].in[0] <== and[12][i].out; + multi_or[1][i].in[1] <== and[13][i].out; + multi_or[1][i].in[2] <== and[15][i].out; + states[i+1][11] <== multi_or[1][i].out; + lt[4][i] = LessEqThan(8); + lt[4][i].in[0] <== 194; + lt[4][i].in[1] <== in[i]; + lt[5][i] = LessEqThan(8); + lt[5][i].in[0] <== in[i]; + lt[5][i].in[1] <== 223; + and[16][i] = AND(); + and[16][i].a <== lt[4][i].out; + and[16][i].b <== lt[5][i].out; + and[17][i] = AND(); + and[17][i].a <== states[i][10]; + and[17][i].b <== and[16][i].out; + and[18][i] = AND(); + and[18][i].a <== states[i][11]; + and[18][i].b <== and[16][i].out; + lt[6][i] = LessEqThan(8); + lt[6][i].in[0] <== 160; + lt[6][i].in[1] <== in[i]; + lt[7][i] = LessEqThan(8); + lt[7][i].in[0] <== in[i]; + lt[7][i].in[1] <== 191; + and[19][i] = AND(); + and[19][i].a <== lt[6][i].out; + and[19][i].b <== lt[7][i].out; + and[20][i] = AND(); + and[20][i].a <== states[i][13]; + and[20][i].b <== and[19][i].out; + and[21][i] = AND(); + and[21][i].a <== states[i][14]; + and[21][i].b <== and[14][i].out; + lt[8][i] = LessEqThan(8); + lt[8][i].in[0] <== 128; + lt[8][i].in[1] <== in[i]; + lt[9][i] = LessEqThan(8); + lt[9][i].in[0] <== in[i]; + lt[9][i].in[1] <== 159; + and[22][i] = AND(); + and[22][i].a <== lt[8][i].out; + and[22][i].b <== lt[9][i].out; + and[23][i] = AND(); + and[23][i].a <== states[i][15]; + and[23][i].b <== and[22][i].out; + multi_or[2][i] = MultiOR(5); + multi_or[2][i].in[0] <== and[17][i].out; + multi_or[2][i].in[1] <== and[18][i].out; + multi_or[2][i].in[2] <== and[20][i].out; + multi_or[2][i].in[3] <== and[21][i].out; + multi_or[2][i].in[4] <== and[23][i].out; + states[i+1][12] <== multi_or[2][i].out; eq[22][i] = IsEqual(); eq[22][i].in[0] <== in[i]; - eq[22][i].in[1] <== 235; + eq[22][i].in[1] <== 224; + and[24][i] = AND(); + and[24][i].a <== states[i][10]; + and[24][i].b <== eq[22][i].out; + and[25][i] = AND(); + and[25][i].a <== states[i][11]; + and[25][i].b <== eq[22][i].out; + multi_or[3][i] = MultiOR(2); + multi_or[3][i].in[0] <== and[24][i].out; + multi_or[3][i].in[1] <== and[25][i].out; + states[i+1][13] <== multi_or[3][i].out; eq[23][i] = IsEqual(); eq[23][i].in[0] <== in[i]; - eq[23][i].in[1] <== 236; + eq[23][i].in[1] <== 225; eq[24][i] = IsEqual(); eq[24][i].in[0] <== in[i]; - eq[24][i].in[1] <== 238; + eq[24][i].in[1] <== 226; eq[25][i] = IsEqual(); eq[25][i].in[0] <== in[i]; - eq[25][i].in[1] <== 239; - and[22][i] = AND(); - and[22][i].a <== states[i][10]; - multi_or[2][i] = MultiOR(14); - multi_or[2][i].in[0] <== eq[12][i].out; - multi_or[2][i].in[1] <== eq[13][i].out; - multi_or[2][i].in[2] <== eq[14][i].out; - multi_or[2][i].in[3] <== eq[15][i].out; - multi_or[2][i].in[4] <== eq[16][i].out; - multi_or[2][i].in[5] <== eq[17][i].out; - multi_or[2][i].in[6] <== eq[18][i].out; - multi_or[2][i].in[7] <== eq[19][i].out; - multi_or[2][i].in[8] <== eq[20][i].out; - multi_or[2][i].in[9] <== eq[21][i].out; - multi_or[2][i].in[10] <== eq[22][i].out; - multi_or[2][i].in[11] <== eq[23][i].out; - multi_or[2][i].in[12] <== eq[24][i].out; - multi_or[2][i].in[13] <== eq[25][i].out; - and[22][i].b <== multi_or[2][i].out; - lt[8][i] = LessEqThan(8); - lt[8][i].in[0] <== 144; - lt[8][i].in[1] <== in[i]; - lt[9][i] = LessEqThan(8); - lt[9][i].in[0] <== in[i]; - lt[9][i].in[1] <== 191; - and[23][i] = AND(); - and[23][i].a <== lt[8][i].out; - and[23][i].b <== lt[9][i].out; - and[24][i] = AND(); - and[24][i].a <== states[i][15]; - and[24][i].b <== and[23][i].out; - and[25][i] = AND(); - and[25][i].a <== states[i][16]; - and[25][i].b <== and[15][i].out; + eq[25][i].in[1] <== 227; eq[26][i] = IsEqual(); eq[26][i].in[0] <== in[i]; - eq[26][i].in[1] <== 128; + eq[26][i].in[1] <== 228; eq[27][i] = IsEqual(); eq[27][i].in[0] <== in[i]; - eq[27][i].in[1] <== 129; + eq[27][i].in[1] <== 229; eq[28][i] = IsEqual(); eq[28][i].in[0] <== in[i]; - eq[28][i].in[1] <== 130; + eq[28][i].in[1] <== 230; eq[29][i] = IsEqual(); eq[29][i].in[0] <== in[i]; - eq[29][i].in[1] <== 131; + eq[29][i].in[1] <== 231; eq[30][i] = IsEqual(); eq[30][i].in[0] <== in[i]; - eq[30][i].in[1] <== 132; + eq[30][i].in[1] <== 232; eq[31][i] = IsEqual(); eq[31][i].in[0] <== in[i]; - eq[31][i].in[1] <== 133; + eq[31][i].in[1] <== 233; eq[32][i] = IsEqual(); eq[32][i].in[0] <== in[i]; - eq[32][i].in[1] <== 134; + eq[32][i].in[1] <== 234; eq[33][i] = IsEqual(); eq[33][i].in[0] <== in[i]; - eq[33][i].in[1] <== 135; + eq[33][i].in[1] <== 235; eq[34][i] = IsEqual(); eq[34][i].in[0] <== in[i]; - eq[34][i].in[1] <== 136; + eq[34][i].in[1] <== 236; eq[35][i] = IsEqual(); eq[35][i].in[0] <== in[i]; - eq[35][i].in[1] <== 137; + eq[35][i].in[1] <== 238; eq[36][i] = IsEqual(); eq[36][i].in[0] <== in[i]; - eq[36][i].in[1] <== 138; + eq[36][i].in[1] <== 239; + and[26][i] = AND(); + and[26][i].a <== states[i][10]; + multi_or[4][i] = MultiOR(14); + multi_or[4][i].in[0] <== eq[23][i].out; + multi_or[4][i].in[1] <== eq[24][i].out; + multi_or[4][i].in[2] <== eq[25][i].out; + multi_or[4][i].in[3] <== eq[26][i].out; + multi_or[4][i].in[4] <== eq[27][i].out; + multi_or[4][i].in[5] <== eq[28][i].out; + multi_or[4][i].in[6] <== eq[29][i].out; + multi_or[4][i].in[7] <== eq[30][i].out; + multi_or[4][i].in[8] <== eq[31][i].out; + multi_or[4][i].in[9] <== eq[32][i].out; + multi_or[4][i].in[10] <== eq[33][i].out; + multi_or[4][i].in[11] <== eq[34][i].out; + multi_or[4][i].in[12] <== eq[35][i].out; + multi_or[4][i].in[13] <== eq[36][i].out; + and[26][i].b <== multi_or[4][i].out; + and[27][i] = AND(); + and[27][i].a <== states[i][11]; + and[27][i].b <== multi_or[4][i].out; + lt[10][i] = LessEqThan(8); + lt[10][i].in[0] <== 144; + lt[10][i].in[1] <== in[i]; + lt[11][i] = LessEqThan(8); + lt[11][i].in[0] <== in[i]; + lt[11][i].in[1] <== 191; + and[28][i] = AND(); + and[28][i].a <== lt[10][i].out; + and[28][i].b <== lt[11][i].out; + and[29][i] = AND(); + and[29][i].a <== states[i][16]; + and[29][i].b <== and[28][i].out; + and[30][i] = AND(); + and[30][i].a <== states[i][17]; + and[30][i].b <== and[14][i].out; eq[37][i] = IsEqual(); eq[37][i].in[0] <== in[i]; - eq[37][i].in[1] <== 139; + eq[37][i].in[1] <== 128; eq[38][i] = IsEqual(); eq[38][i].in[0] <== in[i]; - eq[38][i].in[1] <== 140; + eq[38][i].in[1] <== 129; eq[39][i] = IsEqual(); eq[39][i].in[0] <== in[i]; - eq[39][i].in[1] <== 141; + eq[39][i].in[1] <== 130; eq[40][i] = IsEqual(); eq[40][i].in[0] <== in[i]; - eq[40][i].in[1] <== 142; + eq[40][i].in[1] <== 131; eq[41][i] = IsEqual(); eq[41][i].in[0] <== in[i]; - eq[41][i].in[1] <== 143; - and[26][i] = AND(); - and[26][i].a <== states[i][17]; - multi_or[3][i] = MultiOR(16); - multi_or[3][i].in[0] <== eq[26][i].out; - multi_or[3][i].in[1] <== eq[27][i].out; - multi_or[3][i].in[2] <== eq[28][i].out; - multi_or[3][i].in[3] <== eq[29][i].out; - multi_or[3][i].in[4] <== eq[30][i].out; - multi_or[3][i].in[5] <== eq[31][i].out; - multi_or[3][i].in[6] <== eq[32][i].out; - multi_or[3][i].in[7] <== eq[33][i].out; - multi_or[3][i].in[8] <== eq[34][i].out; - multi_or[3][i].in[9] <== eq[35][i].out; - multi_or[3][i].in[10] <== eq[36][i].out; - multi_or[3][i].in[11] <== eq[37][i].out; - multi_or[3][i].in[12] <== eq[38][i].out; - multi_or[3][i].in[13] <== eq[39][i].out; - multi_or[3][i].in[14] <== eq[40][i].out; - multi_or[3][i].in[15] <== eq[41][i].out; - and[26][i].b <== multi_or[3][i].out; - and[27][i] = AND(); - and[27][i].a <== states[i][18]; - and[27][i].b <== multi_or[2][i].out; - multi_or[4][i] = MultiOR(5); - multi_or[4][i].in[0] <== and[22][i].out; - multi_or[4][i].in[1] <== and[24][i].out; - multi_or[4][i].in[2] <== and[25][i].out; - multi_or[4][i].in[3] <== and[26][i].out; - multi_or[4][i].in[4] <== and[27][i].out; - states[i+1][13] <== multi_or[4][i].out; + eq[41][i].in[1] <== 132; eq[42][i] = IsEqual(); eq[42][i].in[0] <== in[i]; - eq[42][i].in[1] <== 237; - and[28][i] = AND(); - and[28][i].a <== states[i][10]; - and[28][i].b <== eq[42][i].out; - and[29][i] = AND(); - and[29][i].a <== states[i][18]; - and[29][i].b <== eq[42][i].out; - multi_or[5][i] = MultiOR(2); - multi_or[5][i].in[0] <== and[28][i].out; - multi_or[5][i].in[1] <== and[29][i].out; - states[i+1][14] <== multi_or[5][i].out; + eq[42][i].in[1] <== 133; eq[43][i] = IsEqual(); eq[43][i].in[0] <== in[i]; - eq[43][i].in[1] <== 240; - and[30][i] = AND(); - and[30][i].a <== states[i][10]; - and[30][i].b <== eq[43][i].out; - and[31][i] = AND(); - and[31][i].a <== states[i][18]; - and[31][i].b <== eq[43][i].out; - multi_or[6][i] = MultiOR(2); - multi_or[6][i].in[0] <== and[30][i].out; - multi_or[6][i].in[1] <== and[31][i].out; - states[i+1][15] <== multi_or[6][i].out; + eq[43][i].in[1] <== 134; eq[44][i] = IsEqual(); eq[44][i].in[0] <== in[i]; - eq[44][i].in[1] <== 241; + eq[44][i].in[1] <== 135; eq[45][i] = IsEqual(); eq[45][i].in[0] <== in[i]; - eq[45][i].in[1] <== 242; + eq[45][i].in[1] <== 136; eq[46][i] = IsEqual(); eq[46][i].in[0] <== in[i]; - eq[46][i].in[1] <== 243; - and[32][i] = AND(); - and[32][i].a <== states[i][10]; - multi_or[7][i] = MultiOR(3); - multi_or[7][i].in[0] <== eq[44][i].out; - multi_or[7][i].in[1] <== eq[45][i].out; - multi_or[7][i].in[2] <== eq[46][i].out; - and[32][i].b <== multi_or[7][i].out; - and[33][i] = AND(); - and[33][i].a <== states[i][18]; - and[33][i].b <== multi_or[7][i].out; - multi_or[8][i] = MultiOR(2); - multi_or[8][i].in[0] <== and[32][i].out; - multi_or[8][i].in[1] <== and[33][i].out; - states[i+1][16] <== multi_or[8][i].out; + eq[46][i].in[1] <== 137; eq[47][i] = IsEqual(); eq[47][i].in[0] <== in[i]; - eq[47][i].in[1] <== 244; - and[34][i] = AND(); - and[34][i].a <== states[i][10]; - and[34][i].b <== eq[47][i].out; - and[35][i] = AND(); - and[35][i].a <== states[i][18]; - and[35][i].b <== eq[47][i].out; - multi_or[9][i] = MultiOR(2); - multi_or[9][i].in[0] <== and[34][i].out; - multi_or[9][i].in[1] <== and[35][i].out; - states[i+1][17] <== multi_or[9][i].out; - lt[10][i] = LessEqThan(8); - lt[10][i].in[0] <== 14; - lt[10][i].in[1] <== in[i]; - lt[11][i] = LessEqThan(8); - lt[11][i].in[0] <== in[i]; - lt[11][i].in[1] <== 127; - and[36][i] = AND(); - and[36][i].a <== lt[10][i].out; - and[36][i].b <== lt[11][i].out; + eq[47][i].in[1] <== 138; eq[48][i] = IsEqual(); eq[48][i].in[0] <== in[i]; - eq[48][i].in[1] <== 1; + eq[48][i].in[1] <== 139; eq[49][i] = IsEqual(); eq[49][i].in[0] <== in[i]; - eq[49][i].in[1] <== 2; + eq[49][i].in[1] <== 140; eq[50][i] = IsEqual(); eq[50][i].in[0] <== in[i]; - eq[50][i].in[1] <== 3; + eq[50][i].in[1] <== 141; eq[51][i] = IsEqual(); eq[51][i].in[0] <== in[i]; - eq[51][i].in[1] <== 4; + eq[51][i].in[1] <== 142; eq[52][i] = IsEqual(); eq[52][i].in[0] <== in[i]; - eq[52][i].in[1] <== 5; + eq[52][i].in[1] <== 143; + and[31][i] = AND(); + and[31][i].a <== states[i][18]; + multi_or[5][i] = MultiOR(16); + multi_or[5][i].in[0] <== eq[37][i].out; + multi_or[5][i].in[1] <== eq[38][i].out; + multi_or[5][i].in[2] <== eq[39][i].out; + multi_or[5][i].in[3] <== eq[40][i].out; + multi_or[5][i].in[4] <== eq[41][i].out; + multi_or[5][i].in[5] <== eq[42][i].out; + multi_or[5][i].in[6] <== eq[43][i].out; + multi_or[5][i].in[7] <== eq[44][i].out; + multi_or[5][i].in[8] <== eq[45][i].out; + multi_or[5][i].in[9] <== eq[46][i].out; + multi_or[5][i].in[10] <== eq[47][i].out; + multi_or[5][i].in[11] <== eq[48][i].out; + multi_or[5][i].in[12] <== eq[49][i].out; + multi_or[5][i].in[13] <== eq[50][i].out; + multi_or[5][i].in[14] <== eq[51][i].out; + multi_or[5][i].in[15] <== eq[52][i].out; + and[31][i].b <== multi_or[5][i].out; + multi_or[6][i] = MultiOR(5); + multi_or[6][i].in[0] <== and[26][i].out; + multi_or[6][i].in[1] <== and[27][i].out; + multi_or[6][i].in[2] <== and[29][i].out; + multi_or[6][i].in[3] <== and[30][i].out; + multi_or[6][i].in[4] <== and[31][i].out; + states[i+1][14] <== multi_or[6][i].out; eq[53][i] = IsEqual(); eq[53][i].in[0] <== in[i]; - eq[53][i].in[1] <== 6; + eq[53][i].in[1] <== 237; + and[32][i] = AND(); + and[32][i].a <== states[i][10]; + and[32][i].b <== eq[53][i].out; + and[33][i] = AND(); + and[33][i].a <== states[i][11]; + and[33][i].b <== eq[53][i].out; + multi_or[7][i] = MultiOR(2); + multi_or[7][i].in[0] <== and[32][i].out; + multi_or[7][i].in[1] <== and[33][i].out; + states[i+1][15] <== multi_or[7][i].out; eq[54][i] = IsEqual(); eq[54][i].in[0] <== in[i]; - eq[54][i].in[1] <== 7; + eq[54][i].in[1] <== 240; + and[34][i] = AND(); + and[34][i].a <== states[i][10]; + and[34][i].b <== eq[54][i].out; + and[35][i] = AND(); + and[35][i].a <== states[i][11]; + and[35][i].b <== eq[54][i].out; + multi_or[8][i] = MultiOR(2); + multi_or[8][i].in[0] <== and[34][i].out; + multi_or[8][i].in[1] <== and[35][i].out; + states[i+1][16] <== multi_or[8][i].out; eq[55][i] = IsEqual(); eq[55][i].in[0] <== in[i]; - eq[55][i].in[1] <== 8; + eq[55][i].in[1] <== 241; eq[56][i] = IsEqual(); eq[56][i].in[0] <== in[i]; - eq[56][i].in[1] <== 9; + eq[56][i].in[1] <== 242; eq[57][i] = IsEqual(); eq[57][i].in[0] <== in[i]; - eq[57][i].in[1] <== 11; - eq[58][i] = IsEqual(); - eq[58][i].in[0] <== in[i]; - eq[58][i].in[1] <== 12; + eq[57][i].in[1] <== 243; + and[36][i] = AND(); + and[36][i].a <== states[i][10]; + multi_or[9][i] = MultiOR(3); + multi_or[9][i].in[0] <== eq[55][i].out; + multi_or[9][i].in[1] <== eq[56][i].out; + multi_or[9][i].in[2] <== eq[57][i].out; + and[36][i].b <== multi_or[9][i].out; and[37][i] = AND(); - and[37][i].a <== states[i][10]; - multi_or[10][i] = MultiOR(12); + and[37][i].a <== states[i][11]; + and[37][i].b <== multi_or[9][i].out; + multi_or[10][i] = MultiOR(2); multi_or[10][i].in[0] <== and[36][i].out; - multi_or[10][i].in[1] <== eq[48][i].out; - multi_or[10][i].in[2] <== eq[49][i].out; - multi_or[10][i].in[3] <== eq[50][i].out; - multi_or[10][i].in[4] <== eq[51][i].out; - multi_or[10][i].in[5] <== eq[52][i].out; - multi_or[10][i].in[6] <== eq[53][i].out; - multi_or[10][i].in[7] <== eq[54][i].out; - multi_or[10][i].in[8] <== eq[55][i].out; - multi_or[10][i].in[9] <== eq[56][i].out; - multi_or[10][i].in[10] <== eq[57][i].out; - multi_or[10][i].in[11] <== eq[58][i].out; - and[37][i].b <== multi_or[10][i].out; + multi_or[10][i].in[1] <== and[37][i].out; + states[i+1][17] <== multi_or[10][i].out; + eq[58][i] = IsEqual(); + eq[58][i].in[0] <== in[i]; + eq[58][i].in[1] <== 244; and[38][i] = AND(); - and[38][i].a <== states[i][11]; - and[38][i].b <== and[15][i].out; + and[38][i].a <== states[i][10]; + and[38][i].b <== eq[58][i].out; and[39][i] = AND(); - and[39][i].a <== states[i][18]; - and[39][i].b <== multi_or[10][i].out; - multi_or[11][i] = MultiOR(3); - multi_or[11][i].in[0] <== and[37][i].out; - multi_or[11][i].in[1] <== and[38][i].out; - multi_or[11][i].in[2] <== and[39][i].out; + and[39][i].a <== states[i][11]; + and[39][i].b <== eq[58][i].out; + multi_or[11][i] = MultiOR(2); + multi_or[11][i].in[0] <== and[38][i].out; + multi_or[11][i].in[1] <== and[39][i].out; states[i+1][18] <== multi_or[11][i].out; and[40][i] = AND(); - and[40][i].a <== states[i][18]; + and[40][i].a <== states[i][11]; and[40][i].b <== eq[0][i].out; states[i+1][19] <== and[40][i].out; and[41][i] = AND(); @@ -507,13 +507,13 @@ template SubjectAllRegex(msg_bytes) { is_consecutive[msg_bytes-1-i][1] <== state_changed[msg_bytes-i].out * is_consecutive[msg_bytes-1-i][0]; is_consecutive[msg_bytes-1-i][2] <== ORAnd()([(1 - from_zero_enabled[msg_bytes-i+1]), states[num_bytes-i][20], is_consecutive[msg_bytes-1-i][1]]); } - // substrings calculated: [{(10, 11), (10, 12), (10, 13), (10, 14), (10, 15), (10, 16), (10, 17), (10, 18), (11, 18), (12, 11), (13, 11), (14, 11), (15, 13), (16, 13), (17, 13), (18, 11), (18, 12), (18, 13), (18, 14), (18, 15), (18, 16), (18, 17), (18, 18)}] + // substrings calculated: [{(10, 11), (10, 12), (10, 13), (10, 14), (10, 15), (10, 16), (10, 17), (10, 18), (11, 11), (11, 12), (11, 13), (11, 14), (11, 15), (11, 16), (11, 17), (11, 18), (12, 11), (13, 12), (14, 12), (15, 12), (16, 14), (17, 14), (18, 14)}] signal prev_states0[23][msg_bytes]; signal is_substr0[msg_bytes]; signal is_reveal0[msg_bytes]; signal output reveal0[msg_bytes]; for (var i = 0; i < msg_bytes; i++) { - // the 0-th substring transitions: [(10, 11), (10, 12), (10, 13), (10, 14), (10, 15), (10, 16), (10, 17), (10, 18), (11, 18), (12, 11), (13, 11), (14, 11), (15, 13), (16, 13), (17, 13), (18, 11), (18, 12), (18, 13), (18, 14), (18, 15), (18, 16), (18, 17), (18, 18)] + // the 0-th substring transitions: [(10, 11), (10, 12), (10, 13), (10, 14), (10, 15), (10, 16), (10, 17), (10, 18), (11, 11), (11, 12), (11, 13), (11, 14), (11, 15), (11, 16), (11, 17), (11, 18), (12, 11), (13, 12), (14, 12), (15, 12), (16, 14), (17, 14), (18, 14)] prev_states0[0][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][10]; prev_states0[1][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][10]; prev_states0[2][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][10]; @@ -523,21 +523,21 @@ template SubjectAllRegex(msg_bytes) { prev_states0[6][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][10]; prev_states0[7][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][10]; prev_states0[8][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][11]; - prev_states0[9][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][12]; - prev_states0[10][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][13]; - prev_states0[11][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][14]; - prev_states0[12][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][15]; - prev_states0[13][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][16]; - prev_states0[14][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][17]; - prev_states0[15][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][18]; - prev_states0[16][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][18]; - prev_states0[17][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][18]; - prev_states0[18][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][18]; - prev_states0[19][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][18]; - prev_states0[20][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][18]; - prev_states0[21][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][18]; + prev_states0[9][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][11]; + prev_states0[10][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][11]; + prev_states0[11][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][11]; + prev_states0[12][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][11]; + prev_states0[13][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][11]; + prev_states0[14][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][11]; + prev_states0[15][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][11]; + prev_states0[16][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][12]; + prev_states0[17][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][13]; + prev_states0[18][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][14]; + prev_states0[19][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][15]; + prev_states0[20][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][16]; + prev_states0[21][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][17]; prev_states0[22][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][18]; - is_substr0[i] <== MultiOR(23)([prev_states0[0][i] * states[i+2][11], prev_states0[1][i] * states[i+2][12], prev_states0[2][i] * states[i+2][13], prev_states0[3][i] * states[i+2][14], prev_states0[4][i] * states[i+2][15], prev_states0[5][i] * states[i+2][16], prev_states0[6][i] * states[i+2][17], prev_states0[7][i] * states[i+2][18], prev_states0[8][i] * states[i+2][18], prev_states0[9][i] * states[i+2][11], prev_states0[10][i] * states[i+2][11], prev_states0[11][i] * states[i+2][11], prev_states0[12][i] * states[i+2][13], prev_states0[13][i] * states[i+2][13], prev_states0[14][i] * states[i+2][13], prev_states0[15][i] * states[i+2][11], prev_states0[16][i] * states[i+2][12], prev_states0[17][i] * states[i+2][13], prev_states0[18][i] * states[i+2][14], prev_states0[19][i] * states[i+2][15], prev_states0[20][i] * states[i+2][16], prev_states0[21][i] * states[i+2][17], prev_states0[22][i] * states[i+2][18]]); + is_substr0[i] <== MultiOR(23)([prev_states0[0][i] * states[i+2][11], prev_states0[1][i] * states[i+2][12], prev_states0[2][i] * states[i+2][13], prev_states0[3][i] * states[i+2][14], prev_states0[4][i] * states[i+2][15], prev_states0[5][i] * states[i+2][16], prev_states0[6][i] * states[i+2][17], prev_states0[7][i] * states[i+2][18], prev_states0[8][i] * states[i+2][11], prev_states0[9][i] * states[i+2][12], prev_states0[10][i] * states[i+2][13], prev_states0[11][i] * states[i+2][14], prev_states0[12][i] * states[i+2][15], prev_states0[13][i] * states[i+2][16], prev_states0[14][i] * states[i+2][17], prev_states0[15][i] * states[i+2][18], prev_states0[16][i] * states[i+2][11], prev_states0[17][i] * states[i+2][12], prev_states0[18][i] * states[i+2][12], prev_states0[19][i] * states[i+2][12], prev_states0[20][i] * states[i+2][14], prev_states0[21][i] * states[i+2][14], prev_states0[22][i] * states[i+2][14]]); is_reveal0[i] <== MultiAND(3)([out, is_substr0[i], is_consecutive[i][2]]); reveal0[i] <== in[i+1] * is_reveal0[i]; } diff --git a/packages/circom/circuits/common/to_all_regex.circom b/packages/circom/circuits/common/to_all_regex.circom index 456b6dc..2dbbca8 100644 --- a/packages/circom/circuits/common/to_all_regex.circom +++ b/packages/circom/circuits/common/to_all_regex.circom @@ -73,362 +73,362 @@ template ToAllRegex(msg_bytes) { and[5][i].b <== eq[5][i].out; states[i+1][5] <== and[5][i].out; lt[0][i] = LessEqThan(8); - lt[0][i].in[0] <== 194; + lt[0][i].in[0] <== 14; lt[0][i].in[1] <== in[i]; lt[1][i] = LessEqThan(8); lt[1][i].in[0] <== in[i]; - lt[1][i].in[1] <== 223; + lt[1][i].in[1] <== 127; and[6][i] = AND(); and[6][i].a <== lt[0][i].out; and[6][i].b <== lt[1][i].out; - and[7][i] = AND(); - and[7][i].a <== states[i][5]; - and[7][i].b <== and[6][i].out; - lt[2][i] = LessEqThan(8); - lt[2][i].in[0] <== 160; - lt[2][i].in[1] <== in[i]; - lt[3][i] = LessEqThan(8); - lt[3][i].in[0] <== in[i]; - lt[3][i].in[1] <== 191; - and[8][i] = AND(); - and[8][i].a <== lt[2][i].out; - and[8][i].b <== lt[3][i].out; - and[9][i] = AND(); - and[9][i].a <== states[i][7]; - and[9][i].b <== and[8][i].out; - lt[4][i] = LessEqThan(8); - lt[4][i].in[0] <== 128; - lt[4][i].in[1] <== in[i]; - lt[5][i] = LessEqThan(8); - lt[5][i].in[0] <== in[i]; - lt[5][i].in[1] <== 191; - and[10][i] = AND(); - and[10][i].a <== lt[4][i].out; - and[10][i].b <== lt[5][i].out; - and[11][i] = AND(); - and[11][i].a <== states[i][8]; - and[11][i].b <== and[10][i].out; - lt[6][i] = LessEqThan(8); - lt[6][i].in[0] <== 128; - lt[6][i].in[1] <== in[i]; - lt[7][i] = LessEqThan(8); - lt[7][i].in[0] <== in[i]; - lt[7][i].in[1] <== 159; - and[12][i] = AND(); - and[12][i].a <== lt[6][i].out; - and[12][i].b <== lt[7][i].out; - and[13][i] = AND(); - and[13][i].a <== states[i][9]; - and[13][i].b <== and[12][i].out; - and[14][i] = AND(); - and[14][i].a <== states[i][13]; - and[14][i].b <== and[6][i].out; - multi_or[0][i] = MultiOR(5); - multi_or[0][i].in[0] <== and[7][i].out; - multi_or[0][i].in[1] <== and[9][i].out; - multi_or[0][i].in[2] <== and[11][i].out; - multi_or[0][i].in[3] <== and[13][i].out; - multi_or[0][i].in[4] <== and[14][i].out; - states[i+1][6] <== multi_or[0][i].out; eq[6][i] = IsEqual(); eq[6][i].in[0] <== in[i]; - eq[6][i].in[1] <== 224; - and[15][i] = AND(); - and[15][i].a <== states[i][5]; - and[15][i].b <== eq[6][i].out; - and[16][i] = AND(); - and[16][i].a <== states[i][13]; - and[16][i].b <== eq[6][i].out; - multi_or[1][i] = MultiOR(2); - multi_or[1][i].in[0] <== and[15][i].out; - multi_or[1][i].in[1] <== and[16][i].out; - states[i+1][7] <== multi_or[1][i].out; + eq[6][i].in[1] <== 1; eq[7][i] = IsEqual(); eq[7][i].in[0] <== in[i]; - eq[7][i].in[1] <== 225; + eq[7][i].in[1] <== 2; eq[8][i] = IsEqual(); eq[8][i].in[0] <== in[i]; - eq[8][i].in[1] <== 226; + eq[8][i].in[1] <== 3; eq[9][i] = IsEqual(); eq[9][i].in[0] <== in[i]; - eq[9][i].in[1] <== 227; + eq[9][i].in[1] <== 4; eq[10][i] = IsEqual(); eq[10][i].in[0] <== in[i]; - eq[10][i].in[1] <== 228; + eq[10][i].in[1] <== 5; eq[11][i] = IsEqual(); eq[11][i].in[0] <== in[i]; - eq[11][i].in[1] <== 229; + eq[11][i].in[1] <== 6; eq[12][i] = IsEqual(); eq[12][i].in[0] <== in[i]; - eq[12][i].in[1] <== 230; + eq[12][i].in[1] <== 7; eq[13][i] = IsEqual(); eq[13][i].in[0] <== in[i]; - eq[13][i].in[1] <== 231; + eq[13][i].in[1] <== 8; eq[14][i] = IsEqual(); eq[14][i].in[0] <== in[i]; - eq[14][i].in[1] <== 232; + eq[14][i].in[1] <== 9; eq[15][i] = IsEqual(); eq[15][i].in[0] <== in[i]; - eq[15][i].in[1] <== 233; + eq[15][i].in[1] <== 11; eq[16][i] = IsEqual(); eq[16][i].in[0] <== in[i]; - eq[16][i].in[1] <== 234; + eq[16][i].in[1] <== 12; + and[7][i] = AND(); + and[7][i].a <== states[i][5]; + multi_or[0][i] = MultiOR(12); + multi_or[0][i].in[0] <== and[6][i].out; + multi_or[0][i].in[1] <== eq[6][i].out; + multi_or[0][i].in[2] <== eq[7][i].out; + multi_or[0][i].in[3] <== eq[8][i].out; + multi_or[0][i].in[4] <== eq[9][i].out; + multi_or[0][i].in[5] <== eq[10][i].out; + multi_or[0][i].in[6] <== eq[11][i].out; + multi_or[0][i].in[7] <== eq[12][i].out; + multi_or[0][i].in[8] <== eq[13][i].out; + multi_or[0][i].in[9] <== eq[14][i].out; + multi_or[0][i].in[10] <== eq[15][i].out; + multi_or[0][i].in[11] <== eq[16][i].out; + and[7][i].b <== multi_or[0][i].out; + and[8][i] = AND(); + and[8][i].a <== states[i][6]; + and[8][i].b <== multi_or[0][i].out; + lt[2][i] = LessEqThan(8); + lt[2][i].in[0] <== 128; + lt[2][i].in[1] <== in[i]; + lt[3][i] = LessEqThan(8); + lt[3][i].in[0] <== in[i]; + lt[3][i].in[1] <== 191; + and[9][i] = AND(); + and[9][i].a <== lt[2][i].out; + and[9][i].b <== lt[3][i].out; + and[10][i] = AND(); + and[10][i].a <== states[i][7]; + and[10][i].b <== and[9][i].out; + multi_or[1][i] = MultiOR(3); + multi_or[1][i].in[0] <== and[7][i].out; + multi_or[1][i].in[1] <== and[8][i].out; + multi_or[1][i].in[2] <== and[10][i].out; + states[i+1][6] <== multi_or[1][i].out; + lt[4][i] = LessEqThan(8); + lt[4][i].in[0] <== 194; + lt[4][i].in[1] <== in[i]; + lt[5][i] = LessEqThan(8); + lt[5][i].in[0] <== in[i]; + lt[5][i].in[1] <== 223; + and[11][i] = AND(); + and[11][i].a <== lt[4][i].out; + and[11][i].b <== lt[5][i].out; + and[12][i] = AND(); + and[12][i].a <== states[i][5]; + and[12][i].b <== and[11][i].out; + and[13][i] = AND(); + and[13][i].a <== states[i][6]; + and[13][i].b <== and[11][i].out; + lt[6][i] = LessEqThan(8); + lt[6][i].in[0] <== 160; + lt[6][i].in[1] <== in[i]; + lt[7][i] = LessEqThan(8); + lt[7][i].in[0] <== in[i]; + lt[7][i].in[1] <== 191; + and[14][i] = AND(); + and[14][i].a <== lt[6][i].out; + and[14][i].b <== lt[7][i].out; + and[15][i] = AND(); + and[15][i].a <== states[i][8]; + and[15][i].b <== and[14][i].out; + and[16][i] = AND(); + and[16][i].a <== states[i][9]; + and[16][i].b <== and[9][i].out; + lt[8][i] = LessEqThan(8); + lt[8][i].in[0] <== 128; + lt[8][i].in[1] <== in[i]; + lt[9][i] = LessEqThan(8); + lt[9][i].in[0] <== in[i]; + lt[9][i].in[1] <== 159; + and[17][i] = AND(); + and[17][i].a <== lt[8][i].out; + and[17][i].b <== lt[9][i].out; + and[18][i] = AND(); + and[18][i].a <== states[i][10]; + and[18][i].b <== and[17][i].out; + multi_or[2][i] = MultiOR(5); + multi_or[2][i].in[0] <== and[12][i].out; + multi_or[2][i].in[1] <== and[13][i].out; + multi_or[2][i].in[2] <== and[15][i].out; + multi_or[2][i].in[3] <== and[16][i].out; + multi_or[2][i].in[4] <== and[18][i].out; + states[i+1][7] <== multi_or[2][i].out; eq[17][i] = IsEqual(); eq[17][i].in[0] <== in[i]; - eq[17][i].in[1] <== 235; + eq[17][i].in[1] <== 224; + and[19][i] = AND(); + and[19][i].a <== states[i][5]; + and[19][i].b <== eq[17][i].out; + and[20][i] = AND(); + and[20][i].a <== states[i][6]; + and[20][i].b <== eq[17][i].out; + multi_or[3][i] = MultiOR(2); + multi_or[3][i].in[0] <== and[19][i].out; + multi_or[3][i].in[1] <== and[20][i].out; + states[i+1][8] <== multi_or[3][i].out; eq[18][i] = IsEqual(); eq[18][i].in[0] <== in[i]; - eq[18][i].in[1] <== 236; + eq[18][i].in[1] <== 225; eq[19][i] = IsEqual(); eq[19][i].in[0] <== in[i]; - eq[19][i].in[1] <== 238; + eq[19][i].in[1] <== 226; eq[20][i] = IsEqual(); eq[20][i].in[0] <== in[i]; - eq[20][i].in[1] <== 239; - and[17][i] = AND(); - and[17][i].a <== states[i][5]; - multi_or[2][i] = MultiOR(14); - multi_or[2][i].in[0] <== eq[7][i].out; - multi_or[2][i].in[1] <== eq[8][i].out; - multi_or[2][i].in[2] <== eq[9][i].out; - multi_or[2][i].in[3] <== eq[10][i].out; - multi_or[2][i].in[4] <== eq[11][i].out; - multi_or[2][i].in[5] <== eq[12][i].out; - multi_or[2][i].in[6] <== eq[13][i].out; - multi_or[2][i].in[7] <== eq[14][i].out; - multi_or[2][i].in[8] <== eq[15][i].out; - multi_or[2][i].in[9] <== eq[16][i].out; - multi_or[2][i].in[10] <== eq[17][i].out; - multi_or[2][i].in[11] <== eq[18][i].out; - multi_or[2][i].in[12] <== eq[19][i].out; - multi_or[2][i].in[13] <== eq[20][i].out; - and[17][i].b <== multi_or[2][i].out; - lt[8][i] = LessEqThan(8); - lt[8][i].in[0] <== 144; - lt[8][i].in[1] <== in[i]; - lt[9][i] = LessEqThan(8); - lt[9][i].in[0] <== in[i]; - lt[9][i].in[1] <== 191; - and[18][i] = AND(); - and[18][i].a <== lt[8][i].out; - and[18][i].b <== lt[9][i].out; - and[19][i] = AND(); - and[19][i].a <== states[i][10]; - and[19][i].b <== and[18][i].out; - and[20][i] = AND(); - and[20][i].a <== states[i][11]; - and[20][i].b <== and[10][i].out; + eq[20][i].in[1] <== 227; eq[21][i] = IsEqual(); eq[21][i].in[0] <== in[i]; - eq[21][i].in[1] <== 128; + eq[21][i].in[1] <== 228; eq[22][i] = IsEqual(); eq[22][i].in[0] <== in[i]; - eq[22][i].in[1] <== 129; + eq[22][i].in[1] <== 229; eq[23][i] = IsEqual(); eq[23][i].in[0] <== in[i]; - eq[23][i].in[1] <== 130; + eq[23][i].in[1] <== 230; eq[24][i] = IsEqual(); eq[24][i].in[0] <== in[i]; - eq[24][i].in[1] <== 131; + eq[24][i].in[1] <== 231; eq[25][i] = IsEqual(); eq[25][i].in[0] <== in[i]; - eq[25][i].in[1] <== 132; + eq[25][i].in[1] <== 232; eq[26][i] = IsEqual(); eq[26][i].in[0] <== in[i]; - eq[26][i].in[1] <== 133; + eq[26][i].in[1] <== 233; eq[27][i] = IsEqual(); eq[27][i].in[0] <== in[i]; - eq[27][i].in[1] <== 134; + eq[27][i].in[1] <== 234; eq[28][i] = IsEqual(); eq[28][i].in[0] <== in[i]; - eq[28][i].in[1] <== 135; + eq[28][i].in[1] <== 235; eq[29][i] = IsEqual(); eq[29][i].in[0] <== in[i]; - eq[29][i].in[1] <== 136; + eq[29][i].in[1] <== 236; eq[30][i] = IsEqual(); eq[30][i].in[0] <== in[i]; - eq[30][i].in[1] <== 137; + eq[30][i].in[1] <== 238; eq[31][i] = IsEqual(); eq[31][i].in[0] <== in[i]; - eq[31][i].in[1] <== 138; + eq[31][i].in[1] <== 239; + and[21][i] = AND(); + and[21][i].a <== states[i][5]; + multi_or[4][i] = MultiOR(14); + multi_or[4][i].in[0] <== eq[18][i].out; + multi_or[4][i].in[1] <== eq[19][i].out; + multi_or[4][i].in[2] <== eq[20][i].out; + multi_or[4][i].in[3] <== eq[21][i].out; + multi_or[4][i].in[4] <== eq[22][i].out; + multi_or[4][i].in[5] <== eq[23][i].out; + multi_or[4][i].in[6] <== eq[24][i].out; + multi_or[4][i].in[7] <== eq[25][i].out; + multi_or[4][i].in[8] <== eq[26][i].out; + multi_or[4][i].in[9] <== eq[27][i].out; + multi_or[4][i].in[10] <== eq[28][i].out; + multi_or[4][i].in[11] <== eq[29][i].out; + multi_or[4][i].in[12] <== eq[30][i].out; + multi_or[4][i].in[13] <== eq[31][i].out; + and[21][i].b <== multi_or[4][i].out; + and[22][i] = AND(); + and[22][i].a <== states[i][6]; + and[22][i].b <== multi_or[4][i].out; + lt[10][i] = LessEqThan(8); + lt[10][i].in[0] <== 144; + lt[10][i].in[1] <== in[i]; + lt[11][i] = LessEqThan(8); + lt[11][i].in[0] <== in[i]; + lt[11][i].in[1] <== 191; + and[23][i] = AND(); + and[23][i].a <== lt[10][i].out; + and[23][i].b <== lt[11][i].out; + and[24][i] = AND(); + and[24][i].a <== states[i][11]; + and[24][i].b <== and[23][i].out; + and[25][i] = AND(); + and[25][i].a <== states[i][12]; + and[25][i].b <== and[9][i].out; eq[32][i] = IsEqual(); eq[32][i].in[0] <== in[i]; - eq[32][i].in[1] <== 139; + eq[32][i].in[1] <== 128; eq[33][i] = IsEqual(); eq[33][i].in[0] <== in[i]; - eq[33][i].in[1] <== 140; + eq[33][i].in[1] <== 129; eq[34][i] = IsEqual(); eq[34][i].in[0] <== in[i]; - eq[34][i].in[1] <== 141; + eq[34][i].in[1] <== 130; eq[35][i] = IsEqual(); eq[35][i].in[0] <== in[i]; - eq[35][i].in[1] <== 142; + eq[35][i].in[1] <== 131; eq[36][i] = IsEqual(); eq[36][i].in[0] <== in[i]; - eq[36][i].in[1] <== 143; - and[21][i] = AND(); - and[21][i].a <== states[i][12]; - multi_or[3][i] = MultiOR(16); - multi_or[3][i].in[0] <== eq[21][i].out; - multi_or[3][i].in[1] <== eq[22][i].out; - multi_or[3][i].in[2] <== eq[23][i].out; - multi_or[3][i].in[3] <== eq[24][i].out; - multi_or[3][i].in[4] <== eq[25][i].out; - multi_or[3][i].in[5] <== eq[26][i].out; - multi_or[3][i].in[6] <== eq[27][i].out; - multi_or[3][i].in[7] <== eq[28][i].out; - multi_or[3][i].in[8] <== eq[29][i].out; - multi_or[3][i].in[9] <== eq[30][i].out; - multi_or[3][i].in[10] <== eq[31][i].out; - multi_or[3][i].in[11] <== eq[32][i].out; - multi_or[3][i].in[12] <== eq[33][i].out; - multi_or[3][i].in[13] <== eq[34][i].out; - multi_or[3][i].in[14] <== eq[35][i].out; - multi_or[3][i].in[15] <== eq[36][i].out; - and[21][i].b <== multi_or[3][i].out; - and[22][i] = AND(); - and[22][i].a <== states[i][13]; - and[22][i].b <== multi_or[2][i].out; - multi_or[4][i] = MultiOR(5); - multi_or[4][i].in[0] <== and[17][i].out; - multi_or[4][i].in[1] <== and[19][i].out; - multi_or[4][i].in[2] <== and[20][i].out; - multi_or[4][i].in[3] <== and[21][i].out; - multi_or[4][i].in[4] <== and[22][i].out; - states[i+1][8] <== multi_or[4][i].out; + eq[36][i].in[1] <== 132; eq[37][i] = IsEqual(); eq[37][i].in[0] <== in[i]; - eq[37][i].in[1] <== 237; - and[23][i] = AND(); - and[23][i].a <== states[i][5]; - and[23][i].b <== eq[37][i].out; - and[24][i] = AND(); - and[24][i].a <== states[i][13]; - and[24][i].b <== eq[37][i].out; - multi_or[5][i] = MultiOR(2); - multi_or[5][i].in[0] <== and[23][i].out; - multi_or[5][i].in[1] <== and[24][i].out; - states[i+1][9] <== multi_or[5][i].out; + eq[37][i].in[1] <== 133; eq[38][i] = IsEqual(); eq[38][i].in[0] <== in[i]; - eq[38][i].in[1] <== 240; - and[25][i] = AND(); - and[25][i].a <== states[i][5]; - and[25][i].b <== eq[38][i].out; - and[26][i] = AND(); - and[26][i].a <== states[i][13]; - and[26][i].b <== eq[38][i].out; - multi_or[6][i] = MultiOR(2); - multi_or[6][i].in[0] <== and[25][i].out; - multi_or[6][i].in[1] <== and[26][i].out; - states[i+1][10] <== multi_or[6][i].out; + eq[38][i].in[1] <== 134; eq[39][i] = IsEqual(); eq[39][i].in[0] <== in[i]; - eq[39][i].in[1] <== 241; + eq[39][i].in[1] <== 135; eq[40][i] = IsEqual(); eq[40][i].in[0] <== in[i]; - eq[40][i].in[1] <== 242; + eq[40][i].in[1] <== 136; eq[41][i] = IsEqual(); eq[41][i].in[0] <== in[i]; - eq[41][i].in[1] <== 243; - and[27][i] = AND(); - and[27][i].a <== states[i][5]; - multi_or[7][i] = MultiOR(3); - multi_or[7][i].in[0] <== eq[39][i].out; - multi_or[7][i].in[1] <== eq[40][i].out; - multi_or[7][i].in[2] <== eq[41][i].out; - and[27][i].b <== multi_or[7][i].out; - and[28][i] = AND(); - and[28][i].a <== states[i][13]; - and[28][i].b <== multi_or[7][i].out; - multi_or[8][i] = MultiOR(2); - multi_or[8][i].in[0] <== and[27][i].out; - multi_or[8][i].in[1] <== and[28][i].out; - states[i+1][11] <== multi_or[8][i].out; + eq[41][i].in[1] <== 137; eq[42][i] = IsEqual(); eq[42][i].in[0] <== in[i]; - eq[42][i].in[1] <== 244; - and[29][i] = AND(); - and[29][i].a <== states[i][5]; - and[29][i].b <== eq[42][i].out; - and[30][i] = AND(); - and[30][i].a <== states[i][13]; - and[30][i].b <== eq[42][i].out; - multi_or[9][i] = MultiOR(2); - multi_or[9][i].in[0] <== and[29][i].out; - multi_or[9][i].in[1] <== and[30][i].out; - states[i+1][12] <== multi_or[9][i].out; - lt[10][i] = LessEqThan(8); - lt[10][i].in[0] <== 14; - lt[10][i].in[1] <== in[i]; - lt[11][i] = LessEqThan(8); - lt[11][i].in[0] <== in[i]; - lt[11][i].in[1] <== 127; - and[31][i] = AND(); - and[31][i].a <== lt[10][i].out; - and[31][i].b <== lt[11][i].out; + eq[42][i].in[1] <== 138; eq[43][i] = IsEqual(); eq[43][i].in[0] <== in[i]; - eq[43][i].in[1] <== 1; + eq[43][i].in[1] <== 139; eq[44][i] = IsEqual(); eq[44][i].in[0] <== in[i]; - eq[44][i].in[1] <== 2; + eq[44][i].in[1] <== 140; eq[45][i] = IsEqual(); eq[45][i].in[0] <== in[i]; - eq[45][i].in[1] <== 3; + eq[45][i].in[1] <== 141; eq[46][i] = IsEqual(); eq[46][i].in[0] <== in[i]; - eq[46][i].in[1] <== 4; + eq[46][i].in[1] <== 142; eq[47][i] = IsEqual(); eq[47][i].in[0] <== in[i]; - eq[47][i].in[1] <== 5; + eq[47][i].in[1] <== 143; + and[26][i] = AND(); + and[26][i].a <== states[i][13]; + multi_or[5][i] = MultiOR(16); + multi_or[5][i].in[0] <== eq[32][i].out; + multi_or[5][i].in[1] <== eq[33][i].out; + multi_or[5][i].in[2] <== eq[34][i].out; + multi_or[5][i].in[3] <== eq[35][i].out; + multi_or[5][i].in[4] <== eq[36][i].out; + multi_or[5][i].in[5] <== eq[37][i].out; + multi_or[5][i].in[6] <== eq[38][i].out; + multi_or[5][i].in[7] <== eq[39][i].out; + multi_or[5][i].in[8] <== eq[40][i].out; + multi_or[5][i].in[9] <== eq[41][i].out; + multi_or[5][i].in[10] <== eq[42][i].out; + multi_or[5][i].in[11] <== eq[43][i].out; + multi_or[5][i].in[12] <== eq[44][i].out; + multi_or[5][i].in[13] <== eq[45][i].out; + multi_or[5][i].in[14] <== eq[46][i].out; + multi_or[5][i].in[15] <== eq[47][i].out; + and[26][i].b <== multi_or[5][i].out; + multi_or[6][i] = MultiOR(5); + multi_or[6][i].in[0] <== and[21][i].out; + multi_or[6][i].in[1] <== and[22][i].out; + multi_or[6][i].in[2] <== and[24][i].out; + multi_or[6][i].in[3] <== and[25][i].out; + multi_or[6][i].in[4] <== and[26][i].out; + states[i+1][9] <== multi_or[6][i].out; eq[48][i] = IsEqual(); eq[48][i].in[0] <== in[i]; - eq[48][i].in[1] <== 6; + eq[48][i].in[1] <== 237; + and[27][i] = AND(); + and[27][i].a <== states[i][5]; + and[27][i].b <== eq[48][i].out; + and[28][i] = AND(); + and[28][i].a <== states[i][6]; + and[28][i].b <== eq[48][i].out; + multi_or[7][i] = MultiOR(2); + multi_or[7][i].in[0] <== and[27][i].out; + multi_or[7][i].in[1] <== and[28][i].out; + states[i+1][10] <== multi_or[7][i].out; eq[49][i] = IsEqual(); eq[49][i].in[0] <== in[i]; - eq[49][i].in[1] <== 7; + eq[49][i].in[1] <== 240; + and[29][i] = AND(); + and[29][i].a <== states[i][5]; + and[29][i].b <== eq[49][i].out; + and[30][i] = AND(); + and[30][i].a <== states[i][6]; + and[30][i].b <== eq[49][i].out; + multi_or[8][i] = MultiOR(2); + multi_or[8][i].in[0] <== and[29][i].out; + multi_or[8][i].in[1] <== and[30][i].out; + states[i+1][11] <== multi_or[8][i].out; eq[50][i] = IsEqual(); eq[50][i].in[0] <== in[i]; - eq[50][i].in[1] <== 8; + eq[50][i].in[1] <== 241; eq[51][i] = IsEqual(); eq[51][i].in[0] <== in[i]; - eq[51][i].in[1] <== 9; + eq[51][i].in[1] <== 242; eq[52][i] = IsEqual(); eq[52][i].in[0] <== in[i]; - eq[52][i].in[1] <== 11; - eq[53][i] = IsEqual(); - eq[53][i].in[0] <== in[i]; - eq[53][i].in[1] <== 12; + eq[52][i].in[1] <== 243; + and[31][i] = AND(); + and[31][i].a <== states[i][5]; + multi_or[9][i] = MultiOR(3); + multi_or[9][i].in[0] <== eq[50][i].out; + multi_or[9][i].in[1] <== eq[51][i].out; + multi_or[9][i].in[2] <== eq[52][i].out; + and[31][i].b <== multi_or[9][i].out; and[32][i] = AND(); - and[32][i].a <== states[i][5]; - multi_or[10][i] = MultiOR(12); + and[32][i].a <== states[i][6]; + and[32][i].b <== multi_or[9][i].out; + multi_or[10][i] = MultiOR(2); multi_or[10][i].in[0] <== and[31][i].out; - multi_or[10][i].in[1] <== eq[43][i].out; - multi_or[10][i].in[2] <== eq[44][i].out; - multi_or[10][i].in[3] <== eq[45][i].out; - multi_or[10][i].in[4] <== eq[46][i].out; - multi_or[10][i].in[5] <== eq[47][i].out; - multi_or[10][i].in[6] <== eq[48][i].out; - multi_or[10][i].in[7] <== eq[49][i].out; - multi_or[10][i].in[8] <== eq[50][i].out; - multi_or[10][i].in[9] <== eq[51][i].out; - multi_or[10][i].in[10] <== eq[52][i].out; - multi_or[10][i].in[11] <== eq[53][i].out; - and[32][i].b <== multi_or[10][i].out; + multi_or[10][i].in[1] <== and[32][i].out; + states[i+1][12] <== multi_or[10][i].out; + eq[53][i] = IsEqual(); + eq[53][i].in[0] <== in[i]; + eq[53][i].in[1] <== 244; and[33][i] = AND(); - and[33][i].a <== states[i][6]; - and[33][i].b <== and[10][i].out; + and[33][i].a <== states[i][5]; + and[33][i].b <== eq[53][i].out; and[34][i] = AND(); - and[34][i].a <== states[i][13]; - and[34][i].b <== multi_or[10][i].out; - multi_or[11][i] = MultiOR(3); - multi_or[11][i].in[0] <== and[32][i].out; - multi_or[11][i].in[1] <== and[33][i].out; - multi_or[11][i].in[2] <== and[34][i].out; + and[34][i].a <== states[i][6]; + and[34][i].b <== eq[53][i].out; + multi_or[11][i] = MultiOR(2); + multi_or[11][i].in[0] <== and[33][i].out; + multi_or[11][i].in[1] <== and[34][i].out; states[i+1][13] <== multi_or[11][i].out; and[35][i] = AND(); - and[35][i].a <== states[i][13]; + and[35][i].a <== states[i][6]; and[35][i].b <== eq[0][i].out; states[i+1][14] <== and[35][i].out; and[36][i] = AND(); @@ -467,13 +467,13 @@ template ToAllRegex(msg_bytes) { is_consecutive[msg_bytes-1-i][1] <== state_changed[msg_bytes-i].out * is_consecutive[msg_bytes-1-i][0]; is_consecutive[msg_bytes-1-i][2] <== ORAnd()([(1 - from_zero_enabled[msg_bytes-i+1]), states[num_bytes-i][15], is_consecutive[msg_bytes-1-i][1]]); } - // substrings calculated: [{(5, 6), (5, 7), (5, 8), (5, 9), (5, 10), (5, 11), (5, 12), (5, 13), (6, 13), (7, 6), (8, 6), (9, 6), (10, 8), (11, 8), (12, 8), (13, 6), (13, 7), (13, 8), (13, 9), (13, 10), (13, 11), (13, 12), (13, 13)}] + // substrings calculated: [{(5, 6), (5, 7), (5, 8), (5, 9), (5, 10), (5, 11), (5, 12), (5, 13), (6, 6), (6, 7), (6, 8), (6, 9), (6, 10), (6, 11), (6, 12), (6, 13), (7, 6), (8, 7), (9, 7), (10, 7), (11, 9), (12, 9), (13, 9)}] signal prev_states0[23][msg_bytes]; signal is_substr0[msg_bytes]; signal is_reveal0[msg_bytes]; signal output reveal0[msg_bytes]; for (var i = 0; i < msg_bytes; i++) { - // the 0-th substring transitions: [(5, 6), (5, 7), (5, 8), (5, 9), (5, 10), (5, 11), (5, 12), (5, 13), (6, 13), (7, 6), (8, 6), (9, 6), (10, 8), (11, 8), (12, 8), (13, 6), (13, 7), (13, 8), (13, 9), (13, 10), (13, 11), (13, 12), (13, 13)] + // the 0-th substring transitions: [(5, 6), (5, 7), (5, 8), (5, 9), (5, 10), (5, 11), (5, 12), (5, 13), (6, 6), (6, 7), (6, 8), (6, 9), (6, 10), (6, 11), (6, 12), (6, 13), (7, 6), (8, 7), (9, 7), (10, 7), (11, 9), (12, 9), (13, 9)] prev_states0[0][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][5]; prev_states0[1][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][5]; prev_states0[2][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][5]; @@ -483,21 +483,21 @@ template ToAllRegex(msg_bytes) { prev_states0[6][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][5]; prev_states0[7][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][5]; prev_states0[8][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][6]; - prev_states0[9][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][7]; - prev_states0[10][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][8]; - prev_states0[11][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][9]; - prev_states0[12][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][10]; - prev_states0[13][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][11]; - prev_states0[14][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][12]; - prev_states0[15][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][13]; - prev_states0[16][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][13]; - prev_states0[17][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][13]; - prev_states0[18][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][13]; - prev_states0[19][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][13]; - prev_states0[20][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][13]; - prev_states0[21][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][13]; + prev_states0[9][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][6]; + prev_states0[10][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][6]; + prev_states0[11][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][6]; + prev_states0[12][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][6]; + prev_states0[13][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][6]; + prev_states0[14][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][6]; + prev_states0[15][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][6]; + prev_states0[16][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][7]; + prev_states0[17][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][8]; + prev_states0[18][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][9]; + prev_states0[19][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][10]; + prev_states0[20][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][11]; + prev_states0[21][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][12]; prev_states0[22][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][13]; - is_substr0[i] <== MultiOR(23)([prev_states0[0][i] * states[i+2][6], prev_states0[1][i] * states[i+2][7], prev_states0[2][i] * states[i+2][8], prev_states0[3][i] * states[i+2][9], prev_states0[4][i] * states[i+2][10], prev_states0[5][i] * states[i+2][11], prev_states0[6][i] * states[i+2][12], prev_states0[7][i] * states[i+2][13], prev_states0[8][i] * states[i+2][13], prev_states0[9][i] * states[i+2][6], prev_states0[10][i] * states[i+2][6], prev_states0[11][i] * states[i+2][6], prev_states0[12][i] * states[i+2][8], prev_states0[13][i] * states[i+2][8], prev_states0[14][i] * states[i+2][8], prev_states0[15][i] * states[i+2][6], prev_states0[16][i] * states[i+2][7], prev_states0[17][i] * states[i+2][8], prev_states0[18][i] * states[i+2][9], prev_states0[19][i] * states[i+2][10], prev_states0[20][i] * states[i+2][11], prev_states0[21][i] * states[i+2][12], prev_states0[22][i] * states[i+2][13]]); + is_substr0[i] <== MultiOR(23)([prev_states0[0][i] * states[i+2][6], prev_states0[1][i] * states[i+2][7], prev_states0[2][i] * states[i+2][8], prev_states0[3][i] * states[i+2][9], prev_states0[4][i] * states[i+2][10], prev_states0[5][i] * states[i+2][11], prev_states0[6][i] * states[i+2][12], prev_states0[7][i] * states[i+2][13], prev_states0[8][i] * states[i+2][6], prev_states0[9][i] * states[i+2][7], prev_states0[10][i] * states[i+2][8], prev_states0[11][i] * states[i+2][9], prev_states0[12][i] * states[i+2][10], prev_states0[13][i] * states[i+2][11], prev_states0[14][i] * states[i+2][12], prev_states0[15][i] * states[i+2][13], prev_states0[16][i] * states[i+2][6], prev_states0[17][i] * states[i+2][7], prev_states0[18][i] * states[i+2][7], prev_states0[19][i] * states[i+2][7], prev_states0[20][i] * states[i+2][9], prev_states0[21][i] * states[i+2][9], prev_states0[22][i] * states[i+2][9]]); is_reveal0[i] <== MultiAND(3)([out, is_substr0[i], is_consecutive[i][2]]); reveal0[i] <== in[i+1] * is_reveal0[i]; } diff --git a/packages/circom/tests/circuits/caret5_regex.circom b/packages/circom/tests/circuits/caret5_regex.circom index 6bcbda4..2c189b3 100644 --- a/packages/circom/tests/circuits/caret5_regex.circom +++ b/packages/circom/tests/circuits/caret5_regex.circom @@ -52,29 +52,32 @@ template Caret5Regex(msg_bytes) { and[1][i].b <== eq[2][i].out; states[i+1][2] <== and[1][i].out; lt[0][i] = LessEqThan(8); - lt[0][i].in[0] <== 194; + lt[0][i].in[0] <== 1; lt[0][i].in[1] <== in[i]; lt[1][i] = LessEqThan(8); lt[1][i].in[0] <== in[i]; - lt[1][i].in[1] <== 223; + lt[1][i].in[1] <== 96; and[2][i] = AND(); and[2][i].a <== lt[0][i].out; and[2][i].b <== lt[1][i].out; - and[3][i] = AND(); - and[3][i].a <== states[i][2]; - and[3][i].b <== and[2][i].out; lt[2][i] = LessEqThan(8); - lt[2][i].in[0] <== 160; + lt[2][i].in[0] <== 100; lt[2][i].in[1] <== in[i]; lt[3][i] = LessEqThan(8); lt[3][i].in[0] <== in[i]; - lt[3][i].in[1] <== 191; + lt[3][i].in[1] <== 127; + and[3][i] = AND(); + and[3][i].a <== lt[2][i].out; + and[3][i].b <== lt[3][i].out; and[4][i] = AND(); - and[4][i].a <== lt[2][i].out; - and[4][i].b <== lt[3][i].out; + and[4][i].a <== states[i][2]; + multi_or[1][i] = MultiOR(2); + multi_or[1][i].in[0] <== and[2][i].out; + multi_or[1][i].in[1] <== and[3][i].out; + and[4][i].b <== multi_or[1][i].out; and[5][i] = AND(); - and[5][i].a <== states[i][4]; - and[5][i].b <== and[4][i].out; + and[5][i].a <== states[i][3]; + and[5][i].b <== multi_or[1][i].out; lt[4][i] = LessEqThan(8); lt[4][i].in[0] <== 128; lt[4][i].in[1] <== in[i]; @@ -85,43 +88,75 @@ template Caret5Regex(msg_bytes) { and[6][i].a <== lt[4][i].out; and[6][i].b <== lt[5][i].out; and[7][i] = AND(); - and[7][i].a <== states[i][5]; + and[7][i].a <== states[i][4]; and[7][i].b <== and[6][i].out; + multi_or[2][i] = MultiOR(3); + multi_or[2][i].in[0] <== and[4][i].out; + multi_or[2][i].in[1] <== and[5][i].out; + multi_or[2][i].in[2] <== and[7][i].out; + states[i+1][3] <== multi_or[2][i].out; lt[6][i] = LessEqThan(8); - lt[6][i].in[0] <== 128; + lt[6][i].in[0] <== 194; lt[6][i].in[1] <== in[i]; lt[7][i] = LessEqThan(8); lt[7][i].in[0] <== in[i]; - lt[7][i].in[1] <== 159; + lt[7][i].in[1] <== 223; and[8][i] = AND(); and[8][i].a <== lt[6][i].out; and[8][i].b <== lt[7][i].out; and[9][i] = AND(); - and[9][i].a <== states[i][6]; + and[9][i].a <== states[i][2]; and[9][i].b <== and[8][i].out; and[10][i] = AND(); - and[10][i].a <== states[i][10]; - and[10][i].b <== and[2][i].out; - multi_or[1][i] = MultiOR(5); - multi_or[1][i].in[0] <== and[3][i].out; - multi_or[1][i].in[1] <== and[5][i].out; - multi_or[1][i].in[2] <== and[7][i].out; - multi_or[1][i].in[3] <== and[9][i].out; - multi_or[1][i].in[4] <== and[10][i].out; - states[i+1][3] <== multi_or[1][i].out; + and[10][i].a <== states[i][3]; + and[10][i].b <== and[8][i].out; + lt[8][i] = LessEqThan(8); + lt[8][i].in[0] <== 160; + lt[8][i].in[1] <== in[i]; + lt[9][i] = LessEqThan(8); + lt[9][i].in[0] <== in[i]; + lt[9][i].in[1] <== 191; + and[11][i] = AND(); + and[11][i].a <== lt[8][i].out; + and[11][i].b <== lt[9][i].out; + and[12][i] = AND(); + and[12][i].a <== states[i][5]; + and[12][i].b <== and[11][i].out; + and[13][i] = AND(); + and[13][i].a <== states[i][6]; + and[13][i].b <== and[6][i].out; + lt[10][i] = LessEqThan(8); + lt[10][i].in[0] <== 128; + lt[10][i].in[1] <== in[i]; + lt[11][i] = LessEqThan(8); + lt[11][i].in[0] <== in[i]; + lt[11][i].in[1] <== 159; + and[14][i] = AND(); + and[14][i].a <== lt[10][i].out; + and[14][i].b <== lt[11][i].out; + and[15][i] = AND(); + and[15][i].a <== states[i][7]; + and[15][i].b <== and[14][i].out; + multi_or[3][i] = MultiOR(5); + 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] <== and[12][i].out; + multi_or[3][i].in[3] <== and[13][i].out; + multi_or[3][i].in[4] <== and[15][i].out; + states[i+1][4] <== multi_or[3][i].out; eq[3][i] = IsEqual(); eq[3][i].in[0] <== in[i]; eq[3][i].in[1] <== 224; - and[11][i] = AND(); - and[11][i].a <== states[i][2]; - and[11][i].b <== eq[3][i].out; - and[12][i] = AND(); - and[12][i].a <== states[i][10]; - and[12][i].b <== eq[3][i].out; - multi_or[2][i] = MultiOR(2); - multi_or[2][i].in[0] <== and[11][i].out; - multi_or[2][i].in[1] <== and[12][i].out; - states[i+1][4] <== multi_or[2][i].out; + and[16][i] = AND(); + and[16][i].a <== states[i][2]; + and[16][i].b <== eq[3][i].out; + and[17][i] = AND(); + and[17][i].a <== states[i][3]; + and[17][i].b <== eq[3][i].out; + multi_or[4][i] = MultiOR(2); + multi_or[4][i].in[0] <== and[16][i].out; + multi_or[4][i].in[1] <== and[17][i].out; + states[i+1][5] <== multi_or[4][i].out; eq[4][i] = IsEqual(); eq[4][i].in[0] <== in[i]; eq[4][i].in[1] <== 225; @@ -164,39 +199,42 @@ template Caret5Regex(msg_bytes) { eq[17][i] = IsEqual(); eq[17][i].in[0] <== in[i]; eq[17][i].in[1] <== 239; - and[13][i] = AND(); - and[13][i].a <== states[i][2]; - multi_or[3][i] = MultiOR(14); - multi_or[3][i].in[0] <== eq[4][i].out; - multi_or[3][i].in[1] <== eq[5][i].out; - multi_or[3][i].in[2] <== eq[6][i].out; - multi_or[3][i].in[3] <== eq[7][i].out; - multi_or[3][i].in[4] <== eq[8][i].out; - multi_or[3][i].in[5] <== eq[9][i].out; - multi_or[3][i].in[6] <== eq[10][i].out; - multi_or[3][i].in[7] <== eq[11][i].out; - multi_or[3][i].in[8] <== eq[12][i].out; - multi_or[3][i].in[9] <== eq[13][i].out; - multi_or[3][i].in[10] <== eq[14][i].out; - multi_or[3][i].in[11] <== eq[15][i].out; - multi_or[3][i].in[12] <== eq[16][i].out; - multi_or[3][i].in[13] <== eq[17][i].out; - and[13][i].b <== multi_or[3][i].out; - lt[8][i] = LessEqThan(8); - lt[8][i].in[0] <== 144; - lt[8][i].in[1] <== in[i]; - lt[9][i] = LessEqThan(8); - lt[9][i].in[0] <== in[i]; - lt[9][i].in[1] <== 191; - and[14][i] = AND(); - and[14][i].a <== lt[8][i].out; - and[14][i].b <== lt[9][i].out; - and[15][i] = AND(); - and[15][i].a <== states[i][7]; - and[15][i].b <== and[14][i].out; - and[16][i] = AND(); - and[16][i].a <== states[i][8]; - and[16][i].b <== and[6][i].out; + and[18][i] = AND(); + and[18][i].a <== states[i][2]; + multi_or[5][i] = MultiOR(14); + multi_or[5][i].in[0] <== eq[4][i].out; + multi_or[5][i].in[1] <== eq[5][i].out; + multi_or[5][i].in[2] <== eq[6][i].out; + multi_or[5][i].in[3] <== eq[7][i].out; + multi_or[5][i].in[4] <== eq[8][i].out; + multi_or[5][i].in[5] <== eq[9][i].out; + multi_or[5][i].in[6] <== eq[10][i].out; + multi_or[5][i].in[7] <== eq[11][i].out; + multi_or[5][i].in[8] <== eq[12][i].out; + multi_or[5][i].in[9] <== eq[13][i].out; + multi_or[5][i].in[10] <== eq[14][i].out; + multi_or[5][i].in[11] <== eq[15][i].out; + multi_or[5][i].in[12] <== eq[16][i].out; + multi_or[5][i].in[13] <== eq[17][i].out; + and[18][i].b <== multi_or[5][i].out; + and[19][i] = AND(); + and[19][i].a <== states[i][3]; + and[19][i].b <== multi_or[5][i].out; + lt[12][i] = LessEqThan(8); + lt[12][i].in[0] <== 144; + lt[12][i].in[1] <== in[i]; + lt[13][i] = LessEqThan(8); + lt[13][i].in[0] <== in[i]; + lt[13][i].in[1] <== 191; + and[20][i] = AND(); + and[20][i].a <== lt[12][i].out; + and[20][i].b <== lt[13][i].out; + and[21][i] = AND(); + and[21][i].a <== states[i][8]; + and[21][i].b <== and[20][i].out; + and[22][i] = AND(); + and[22][i].a <== states[i][9]; + and[22][i].b <== and[6][i].out; eq[18][i] = IsEqual(); eq[18][i].in[0] <== in[i]; eq[18][i].in[1] <== 128; @@ -245,62 +283,59 @@ template Caret5Regex(msg_bytes) { eq[33][i] = IsEqual(); eq[33][i].in[0] <== in[i]; eq[33][i].in[1] <== 143; - and[17][i] = AND(); - and[17][i].a <== states[i][9]; - multi_or[4][i] = MultiOR(16); - multi_or[4][i].in[0] <== eq[18][i].out; - multi_or[4][i].in[1] <== eq[19][i].out; - multi_or[4][i].in[2] <== eq[20][i].out; - multi_or[4][i].in[3] <== eq[21][i].out; - multi_or[4][i].in[4] <== eq[22][i].out; - multi_or[4][i].in[5] <== eq[23][i].out; - multi_or[4][i].in[6] <== eq[24][i].out; - multi_or[4][i].in[7] <== eq[25][i].out; - multi_or[4][i].in[8] <== eq[26][i].out; - multi_or[4][i].in[9] <== eq[27][i].out; - multi_or[4][i].in[10] <== eq[28][i].out; - multi_or[4][i].in[11] <== eq[29][i].out; - multi_or[4][i].in[12] <== eq[30][i].out; - multi_or[4][i].in[13] <== eq[31][i].out; - multi_or[4][i].in[14] <== eq[32][i].out; - multi_or[4][i].in[15] <== eq[33][i].out; - and[17][i].b <== multi_or[4][i].out; - and[18][i] = AND(); - and[18][i].a <== states[i][10]; - and[18][i].b <== multi_or[3][i].out; - multi_or[5][i] = MultiOR(5); - multi_or[5][i].in[0] <== and[13][i].out; - multi_or[5][i].in[1] <== and[15][i].out; - multi_or[5][i].in[2] <== and[16][i].out; - multi_or[5][i].in[3] <== and[17][i].out; - multi_or[5][i].in[4] <== and[18][i].out; - states[i+1][5] <== multi_or[5][i].out; + and[23][i] = AND(); + and[23][i].a <== states[i][10]; + multi_or[6][i] = MultiOR(16); + multi_or[6][i].in[0] <== eq[18][i].out; + multi_or[6][i].in[1] <== eq[19][i].out; + multi_or[6][i].in[2] <== eq[20][i].out; + multi_or[6][i].in[3] <== eq[21][i].out; + multi_or[6][i].in[4] <== eq[22][i].out; + multi_or[6][i].in[5] <== eq[23][i].out; + multi_or[6][i].in[6] <== eq[24][i].out; + multi_or[6][i].in[7] <== eq[25][i].out; + multi_or[6][i].in[8] <== eq[26][i].out; + multi_or[6][i].in[9] <== eq[27][i].out; + multi_or[6][i].in[10] <== eq[28][i].out; + multi_or[6][i].in[11] <== eq[29][i].out; + multi_or[6][i].in[12] <== eq[30][i].out; + multi_or[6][i].in[13] <== eq[31][i].out; + multi_or[6][i].in[14] <== eq[32][i].out; + multi_or[6][i].in[15] <== eq[33][i].out; + and[23][i].b <== multi_or[6][i].out; + multi_or[7][i] = MultiOR(5); + multi_or[7][i].in[0] <== and[18][i].out; + multi_or[7][i].in[1] <== and[19][i].out; + multi_or[7][i].in[2] <== and[21][i].out; + multi_or[7][i].in[3] <== and[22][i].out; + multi_or[7][i].in[4] <== and[23][i].out; + states[i+1][6] <== multi_or[7][i].out; eq[34][i] = IsEqual(); eq[34][i].in[0] <== in[i]; eq[34][i].in[1] <== 237; - and[19][i] = AND(); - and[19][i].a <== states[i][2]; - and[19][i].b <== eq[34][i].out; - and[20][i] = AND(); - and[20][i].a <== states[i][10]; - and[20][i].b <== eq[34][i].out; - 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; - states[i+1][6] <== multi_or[6][i].out; + and[24][i] = AND(); + and[24][i].a <== states[i][2]; + and[24][i].b <== eq[34][i].out; + and[25][i] = AND(); + and[25][i].a <== states[i][3]; + and[25][i].b <== eq[34][i].out; + multi_or[8][i] = MultiOR(2); + multi_or[8][i].in[0] <== and[24][i].out; + multi_or[8][i].in[1] <== and[25][i].out; + states[i+1][7] <== multi_or[8][i].out; eq[35][i] = IsEqual(); eq[35][i].in[0] <== in[i]; eq[35][i].in[1] <== 240; - and[21][i] = AND(); - and[21][i].a <== states[i][2]; - and[21][i].b <== eq[35][i].out; - and[22][i] = AND(); - and[22][i].a <== states[i][10]; - and[22][i].b <== eq[35][i].out; - multi_or[7][i] = MultiOR(2); - multi_or[7][i].in[0] <== and[21][i].out; - multi_or[7][i].in[1] <== and[22][i].out; - states[i+1][7] <== multi_or[7][i].out; + and[26][i] = AND(); + and[26][i].a <== states[i][2]; + and[26][i].b <== eq[35][i].out; + and[27][i] = AND(); + and[27][i].a <== states[i][3]; + and[27][i].b <== eq[35][i].out; + multi_or[9][i] = MultiOR(2); + multi_or[9][i].in[0] <== and[26][i].out; + multi_or[9][i].in[1] <== and[27][i].out; + states[i+1][8] <== multi_or[9][i].out; eq[36][i] = IsEqual(); eq[36][i].in[0] <== in[i]; eq[36][i].in[1] <== 241; @@ -310,67 +345,32 @@ template Caret5Regex(msg_bytes) { eq[38][i] = IsEqual(); eq[38][i].in[0] <== in[i]; eq[38][i].in[1] <== 243; - and[23][i] = AND(); - and[23][i].a <== states[i][2]; - multi_or[8][i] = MultiOR(3); - multi_or[8][i].in[0] <== eq[36][i].out; - multi_or[8][i].in[1] <== eq[37][i].out; - multi_or[8][i].in[2] <== eq[38][i].out; - and[23][i].b <== multi_or[8][i].out; - and[24][i] = AND(); - and[24][i].a <== states[i][10]; - and[24][i].b <== multi_or[8][i].out; - multi_or[9][i] = MultiOR(2); - multi_or[9][i].in[0] <== and[23][i].out; - multi_or[9][i].in[1] <== and[24][i].out; - states[i+1][8] <== multi_or[9][i].out; - eq[39][i] = IsEqual(); - eq[39][i].in[0] <== in[i]; - eq[39][i].in[1] <== 244; - and[25][i] = AND(); - and[25][i].a <== states[i][2]; - and[25][i].b <== eq[39][i].out; - and[26][i] = AND(); - and[26][i].a <== states[i][10]; - and[26][i].b <== eq[39][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[26][i].out; - states[i+1][9] <== multi_or[10][i].out; - lt[10][i] = LessEqThan(8); - lt[10][i].in[0] <== 1; - lt[10][i].in[1] <== in[i]; - lt[11][i] = LessEqThan(8); - lt[11][i].in[0] <== in[i]; - lt[11][i].in[1] <== 96; - and[27][i] = AND(); - and[27][i].a <== lt[10][i].out; - and[27][i].b <== lt[11][i].out; - lt[12][i] = LessEqThan(8); - lt[12][i].in[0] <== 100; - lt[12][i].in[1] <== in[i]; - lt[13][i] = LessEqThan(8); - lt[13][i].in[0] <== in[i]; - lt[13][i].in[1] <== 127; and[28][i] = AND(); - and[28][i].a <== lt[12][i].out; - and[28][i].b <== lt[13][i].out; + and[28][i].a <== states[i][2]; + multi_or[10][i] = MultiOR(3); + multi_or[10][i].in[0] <== eq[36][i].out; + multi_or[10][i].in[1] <== eq[37][i].out; + multi_or[10][i].in[2] <== eq[38][i].out; + and[28][i].b <== multi_or[10][i].out; and[29][i] = AND(); - and[29][i].a <== states[i][2]; + and[29][i].a <== states[i][3]; + and[29][i].b <== multi_or[10][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; - and[29][i].b <== multi_or[11][i].out; + multi_or[11][i].in[0] <== and[28][i].out; + multi_or[11][i].in[1] <== and[29][i].out; + states[i+1][9] <== multi_or[11][i].out; + eq[39][i] = IsEqual(); + eq[39][i].in[0] <== in[i]; + eq[39][i].in[1] <== 244; and[30][i] = AND(); - and[30][i].a <== states[i][3]; - and[30][i].b <== and[6][i].out; + and[30][i].a <== states[i][2]; + and[30][i].b <== eq[39][i].out; and[31][i] = AND(); - and[31][i].a <== states[i][10]; - and[31][i].b <== multi_or[11][i].out; - multi_or[12][i] = MultiOR(3); - multi_or[12][i].in[0] <== and[29][i].out; - multi_or[12][i].in[1] <== and[30][i].out; - multi_or[12][i].in[2] <== and[31][i].out; + and[31][i].a <== states[i][3]; + and[31][i].b <== eq[39][i].out; + multi_or[12][i] = MultiOR(2); + multi_or[12][i].in[0] <== and[30][i].out; + multi_or[12][i].in[1] <== and[31][i].out; states[i+1][10] <== multi_or[12][i].out; from_zero_enabled[i] <== MultiNOR(10)([states_tmp[i+1][1], states[i+1][2], states[i+1][3], states[i+1][4], states[i+1][5], states[i+1][6], states[i+1][7], states[i+1][8], states[i+1][9], states[i+1][10]]); states[i+1][1] <== MultiOR(2)([states_tmp[i+1][1], from_zero_enabled[i] * and[0][i].out]); @@ -388,23 +388,23 @@ template Caret5Regex(msg_bytes) { component is_accepted = MultiOR(num_bytes+1); for (var i = 0; i <= num_bytes; i++) { - is_accepted.in[i] <== states[i][10]; + is_accepted.in[i] <== states[i][3]; } out <== is_accepted.out; signal is_consecutive[msg_bytes+1][3]; is_consecutive[msg_bytes][2] <== 0; for (var i = 0; i < msg_bytes; i++) { - is_consecutive[msg_bytes-1-i][0] <== states[num_bytes-i][10] * (1 - is_consecutive[msg_bytes-i][2]) + is_consecutive[msg_bytes-i][2]; + is_consecutive[msg_bytes-1-i][0] <== states[num_bytes-i][3] * (1 - is_consecutive[msg_bytes-i][2]) + is_consecutive[msg_bytes-i][2]; is_consecutive[msg_bytes-1-i][1] <== state_changed[msg_bytes-i].out * is_consecutive[msg_bytes-1-i][0]; - is_consecutive[msg_bytes-1-i][2] <== ORAnd()([(1 - from_zero_enabled[msg_bytes-i+1]), states[num_bytes-i][10], is_consecutive[msg_bytes-1-i][1]]); + is_consecutive[msg_bytes-1-i][2] <== ORAnd()([(1 - from_zero_enabled[msg_bytes-i+1]), states[num_bytes-i][3], is_consecutive[msg_bytes-1-i][1]]); } - // substrings calculated: [{(2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (3, 10), (4, 3), (5, 3), (6, 3), (7, 5), (8, 5), (9, 5), (10, 3), (10, 4), (10, 5), (10, 6), (10, 7), (10, 8), (10, 9), (10, 10)}] + // substrings calculated: [{(2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (4, 3), (5, 4), (6, 4), (7, 4), (8, 6), (9, 6), (10, 6)}] signal prev_states0[23][msg_bytes]; signal is_substr0[msg_bytes]; signal is_reveal0[msg_bytes]; signal output reveal0[msg_bytes]; for (var i = 0; i < msg_bytes; i++) { - // the 0-th substring transitions: [(2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (3, 10), (4, 3), (5, 3), (6, 3), (7, 5), (8, 5), (9, 5), (10, 3), (10, 4), (10, 5), (10, 6), (10, 7), (10, 8), (10, 9), (10, 10)] + // the 0-th substring transitions: [(2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (4, 3), (5, 4), (6, 4), (7, 4), (8, 6), (9, 6), (10, 6)] prev_states0[0][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][2]; prev_states0[1][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][2]; prev_states0[2][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][2]; @@ -414,21 +414,21 @@ template Caret5Regex(msg_bytes) { prev_states0[6][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][2]; prev_states0[7][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][2]; prev_states0[8][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][3]; - prev_states0[9][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][4]; - prev_states0[10][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][5]; - prev_states0[11][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][6]; - prev_states0[12][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][7]; - prev_states0[13][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][8]; - prev_states0[14][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][9]; - prev_states0[15][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][10]; - prev_states0[16][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][10]; - prev_states0[17][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][10]; - prev_states0[18][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][10]; - prev_states0[19][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][10]; - prev_states0[20][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][10]; - prev_states0[21][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][10]; + prev_states0[9][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][3]; + prev_states0[10][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][3]; + prev_states0[11][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][3]; + prev_states0[12][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][3]; + prev_states0[13][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][3]; + prev_states0[14][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][3]; + prev_states0[15][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][3]; + prev_states0[16][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][4]; + prev_states0[17][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][5]; + prev_states0[18][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][6]; + prev_states0[19][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][7]; + prev_states0[20][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][8]; + prev_states0[21][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][9]; prev_states0[22][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][10]; - is_substr0[i] <== MultiOR(23)([prev_states0[0][i] * states[i+2][3], prev_states0[1][i] * states[i+2][4], prev_states0[2][i] * states[i+2][5], prev_states0[3][i] * states[i+2][6], prev_states0[4][i] * states[i+2][7], prev_states0[5][i] * states[i+2][8], prev_states0[6][i] * states[i+2][9], prev_states0[7][i] * states[i+2][10], prev_states0[8][i] * states[i+2][10], prev_states0[9][i] * states[i+2][3], prev_states0[10][i] * states[i+2][3], prev_states0[11][i] * states[i+2][3], prev_states0[12][i] * states[i+2][5], prev_states0[13][i] * states[i+2][5], prev_states0[14][i] * states[i+2][5], prev_states0[15][i] * states[i+2][3], prev_states0[16][i] * states[i+2][4], prev_states0[17][i] * states[i+2][5], prev_states0[18][i] * states[i+2][6], prev_states0[19][i] * states[i+2][7], prev_states0[20][i] * states[i+2][8], prev_states0[21][i] * states[i+2][9], prev_states0[22][i] * states[i+2][10]]); + is_substr0[i] <== MultiOR(23)([prev_states0[0][i] * states[i+2][3], prev_states0[1][i] * states[i+2][4], prev_states0[2][i] * states[i+2][5], prev_states0[3][i] * states[i+2][6], prev_states0[4][i] * states[i+2][7], prev_states0[5][i] * states[i+2][8], prev_states0[6][i] * states[i+2][9], prev_states0[7][i] * states[i+2][10], prev_states0[8][i] * states[i+2][3], prev_states0[9][i] * states[i+2][4], prev_states0[10][i] * states[i+2][5], prev_states0[11][i] * states[i+2][6], prev_states0[12][i] * states[i+2][7], prev_states0[13][i] * states[i+2][8], prev_states0[14][i] * states[i+2][9], prev_states0[15][i] * states[i+2][10], prev_states0[16][i] * states[i+2][3], prev_states0[17][i] * states[i+2][4], prev_states0[18][i] * states[i+2][4], prev_states0[19][i] * states[i+2][4], prev_states0[20][i] * states[i+2][6], prev_states0[21][i] * states[i+2][6], prev_states0[22][i] * states[i+2][6]]); is_reveal0[i] <== MultiAND(3)([out, is_substr0[i], is_consecutive[i][2]]); reveal0[i] <== in[i+1] * is_reveal0[i]; } diff --git a/packages/circom/tests/circuits/dot1_regex.circom b/packages/circom/tests/circuits/dot1_regex.circom index 774b9a0..80f137f 100644 --- a/packages/circom/tests/circuits/dot1_regex.circom +++ b/packages/circom/tests/circuits/dot1_regex.circom @@ -32,19 +32,57 @@ template Dot1Regex(msg_bytes) { state_changed[i] = MultiOR(8); states[i][0] <== 1; lt[0][i] = LessEqThan(8); - lt[0][i].in[0] <== 194; + lt[0][i].in[0] <== 11; lt[0][i].in[1] <== in[i]; lt[1][i] = LessEqThan(8); lt[1][i].in[0] <== in[i]; - lt[1][i].in[1] <== 223; + lt[1][i].in[1] <== 127; and[0][i] = AND(); and[0][i].a <== lt[0][i].out; and[0][i].b <== lt[1][i].out; + eq[0][i] = IsEqual(); + eq[0][i].in[0] <== in[i]; + eq[0][i].in[1] <== 1; + eq[1][i] = IsEqual(); + eq[1][i].in[0] <== in[i]; + eq[1][i].in[1] <== 2; + eq[2][i] = IsEqual(); + eq[2][i].in[0] <== in[i]; + eq[2][i].in[1] <== 3; + eq[3][i] = IsEqual(); + eq[3][i].in[0] <== in[i]; + eq[3][i].in[1] <== 4; + eq[4][i] = IsEqual(); + eq[4][i].in[0] <== in[i]; + eq[4][i].in[1] <== 5; + eq[5][i] = IsEqual(); + eq[5][i].in[0] <== in[i]; + eq[5][i].in[1] <== 6; + eq[6][i] = IsEqual(); + eq[6][i].in[0] <== in[i]; + eq[6][i].in[1] <== 7; + eq[7][i] = IsEqual(); + eq[7][i].in[0] <== in[i]; + eq[7][i].in[1] <== 8; + eq[8][i] = IsEqual(); + eq[8][i].in[0] <== in[i]; + eq[8][i].in[1] <== 9; and[1][i] = AND(); and[1][i].a <== states[i][0]; - and[1][i].b <== and[0][i].out; + multi_or[0][i] = MultiOR(10); + multi_or[0][i].in[0] <== and[0][i].out; + multi_or[0][i].in[1] <== eq[0][i].out; + multi_or[0][i].in[2] <== eq[1][i].out; + multi_or[0][i].in[3] <== eq[2][i].out; + multi_or[0][i].in[4] <== eq[3][i].out; + multi_or[0][i].in[5] <== eq[4][i].out; + multi_or[0][i].in[6] <== eq[5][i].out; + multi_or[0][i].in[7] <== eq[6][i].out; + multi_or[0][i].in[8] <== eq[7][i].out; + multi_or[0][i].in[9] <== eq[8][i].out; + and[1][i].b <== multi_or[0][i].out; lt[2][i] = LessEqThan(8); - lt[2][i].in[0] <== 160; + lt[2][i].in[0] <== 128; lt[2][i].in[1] <== in[i]; lt[3][i] = LessEqThan(8); lt[3][i].in[0] <== in[i]; @@ -55,291 +93,253 @@ template Dot1Regex(msg_bytes) { and[3][i] = AND(); and[3][i].a <== states[i][2]; and[3][i].b <== and[2][i].out; + states_tmp[i+1][1] <== and[3][i].out; lt[4][i] = LessEqThan(8); - lt[4][i].in[0] <== 128; + lt[4][i].in[0] <== 194; lt[4][i].in[1] <== in[i]; lt[5][i] = LessEqThan(8); lt[5][i].in[0] <== in[i]; - lt[5][i].in[1] <== 191; + lt[5][i].in[1] <== 223; 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][3]; + and[5][i].a <== states[i][0]; and[5][i].b <== and[4][i].out; lt[6][i] = LessEqThan(8); - lt[6][i].in[0] <== 128; + lt[6][i].in[0] <== 160; lt[6][i].in[1] <== in[i]; lt[7][i] = LessEqThan(8); lt[7][i].in[0] <== in[i]; - lt[7][i].in[1] <== 159; + lt[7][i].in[1] <== 191; 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][4]; + and[7][i].a <== states[i][3]; and[7][i].b <== and[6][i].out; - multi_or[0][i] = MultiOR(3); - multi_or[0][i].in[0] <== and[3][i].out; - multi_or[0][i].in[1] <== and[5][i].out; - multi_or[0][i].in[2] <== and[7][i].out; - states_tmp[i+1][1] <== multi_or[0][i].out; - eq[0][i] = IsEqual(); - eq[0][i].in[0] <== in[i]; - eq[0][i].in[1] <== 224; and[8][i] = AND(); - and[8][i].a <== states[i][0]; - and[8][i].b <== eq[0][i].out; - states_tmp[i+1][2] <== 0; - eq[1][i] = IsEqual(); - eq[1][i].in[0] <== in[i]; - eq[1][i].in[1] <== 225; - eq[2][i] = IsEqual(); - eq[2][i].in[0] <== in[i]; - eq[2][i].in[1] <== 226; - eq[3][i] = IsEqual(); - eq[3][i].in[0] <== in[i]; - eq[3][i].in[1] <== 227; - eq[4][i] = IsEqual(); - eq[4][i].in[0] <== in[i]; - eq[4][i].in[1] <== 228; - eq[5][i] = IsEqual(); - eq[5][i].in[0] <== in[i]; - eq[5][i].in[1] <== 229; - eq[6][i] = IsEqual(); - eq[6][i].in[0] <== in[i]; - eq[6][i].in[1] <== 230; - eq[7][i] = IsEqual(); - eq[7][i].in[0] <== in[i]; - eq[7][i].in[1] <== 231; - eq[8][i] = IsEqual(); - eq[8][i].in[0] <== in[i]; - eq[8][i].in[1] <== 232; + and[8][i].a <== states[i][4]; + and[8][i].b <== and[2][i].out; + lt[8][i] = LessEqThan(8); + lt[8][i].in[0] <== 128; + lt[8][i].in[1] <== in[i]; + lt[9][i] = LessEqThan(8); + lt[9][i].in[0] <== in[i]; + lt[9][i].in[1] <== 159; + 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][5]; + and[10][i].b <== and[9][i].out; + multi_or[1][i] = MultiOR(3); + multi_or[1][i].in[0] <== and[7][i].out; + multi_or[1][i].in[1] <== and[8][i].out; + multi_or[1][i].in[2] <== and[10][i].out; + states_tmp[i+1][2] <== multi_or[1][i].out; eq[9][i] = IsEqual(); eq[9][i].in[0] <== in[i]; - eq[9][i].in[1] <== 233; + eq[9][i].in[1] <== 224; + and[11][i] = AND(); + and[11][i].a <== states[i][0]; + and[11][i].b <== eq[9][i].out; + states_tmp[i+1][3] <== 0; eq[10][i] = IsEqual(); eq[10][i].in[0] <== in[i]; - eq[10][i].in[1] <== 234; + eq[10][i].in[1] <== 225; eq[11][i] = IsEqual(); eq[11][i].in[0] <== in[i]; - eq[11][i].in[1] <== 235; + eq[11][i].in[1] <== 226; eq[12][i] = IsEqual(); eq[12][i].in[0] <== in[i]; - eq[12][i].in[1] <== 236; + eq[12][i].in[1] <== 227; eq[13][i] = IsEqual(); eq[13][i].in[0] <== in[i]; - eq[13][i].in[1] <== 238; + eq[13][i].in[1] <== 228; eq[14][i] = IsEqual(); eq[14][i].in[0] <== in[i]; - eq[14][i].in[1] <== 239; - and[9][i] = AND(); - and[9][i].a <== states[i][0]; - multi_or[1][i] = MultiOR(14); - multi_or[1][i].in[0] <== eq[1][i].out; - multi_or[1][i].in[1] <== eq[2][i].out; - multi_or[1][i].in[2] <== eq[3][i].out; - multi_or[1][i].in[3] <== eq[4][i].out; - multi_or[1][i].in[4] <== eq[5][i].out; - multi_or[1][i].in[5] <== eq[6][i].out; - multi_or[1][i].in[6] <== eq[7][i].out; - multi_or[1][i].in[7] <== eq[8][i].out; - multi_or[1][i].in[8] <== eq[9][i].out; - multi_or[1][i].in[9] <== eq[10][i].out; - multi_or[1][i].in[10] <== eq[11][i].out; - multi_or[1][i].in[11] <== eq[12][i].out; - multi_or[1][i].in[12] <== eq[13][i].out; - multi_or[1][i].in[13] <== eq[14][i].out; - and[9][i].b <== multi_or[1][i].out; - lt[8][i] = LessEqThan(8); - lt[8][i].in[0] <== 144; - lt[8][i].in[1] <== in[i]; - lt[9][i] = LessEqThan(8); - lt[9][i].in[0] <== in[i]; - lt[9][i].in[1] <== 191; - and[10][i] = AND(); - and[10][i].a <== lt[8][i].out; - and[10][i].b <== lt[9][i].out; - and[11][i] = AND(); - and[11][i].a <== states[i][5]; - and[11][i].b <== and[10][i].out; - and[12][i] = AND(); - and[12][i].a <== states[i][6]; - and[12][i].b <== and[4][i].out; + eq[14][i].in[1] <== 229; eq[15][i] = IsEqual(); eq[15][i].in[0] <== in[i]; - eq[15][i].in[1] <== 128; + eq[15][i].in[1] <== 230; eq[16][i] = IsEqual(); eq[16][i].in[0] <== in[i]; - eq[16][i].in[1] <== 129; + eq[16][i].in[1] <== 231; eq[17][i] = IsEqual(); eq[17][i].in[0] <== in[i]; - eq[17][i].in[1] <== 130; + eq[17][i].in[1] <== 232; eq[18][i] = IsEqual(); eq[18][i].in[0] <== in[i]; - eq[18][i].in[1] <== 131; + eq[18][i].in[1] <== 233; eq[19][i] = IsEqual(); eq[19][i].in[0] <== in[i]; - eq[19][i].in[1] <== 132; + eq[19][i].in[1] <== 234; eq[20][i] = IsEqual(); eq[20][i].in[0] <== in[i]; - eq[20][i].in[1] <== 133; + eq[20][i].in[1] <== 235; eq[21][i] = IsEqual(); eq[21][i].in[0] <== in[i]; - eq[21][i].in[1] <== 134; + eq[21][i].in[1] <== 236; eq[22][i] = IsEqual(); eq[22][i].in[0] <== in[i]; - eq[22][i].in[1] <== 135; + eq[22][i].in[1] <== 238; eq[23][i] = IsEqual(); eq[23][i].in[0] <== in[i]; - eq[23][i].in[1] <== 136; + eq[23][i].in[1] <== 239; + and[12][i] = AND(); + and[12][i].a <== states[i][0]; + multi_or[2][i] = MultiOR(14); + multi_or[2][i].in[0] <== eq[10][i].out; + multi_or[2][i].in[1] <== eq[11][i].out; + multi_or[2][i].in[2] <== eq[12][i].out; + multi_or[2][i].in[3] <== eq[13][i].out; + multi_or[2][i].in[4] <== eq[14][i].out; + multi_or[2][i].in[5] <== eq[15][i].out; + multi_or[2][i].in[6] <== eq[16][i].out; + multi_or[2][i].in[7] <== eq[17][i].out; + multi_or[2][i].in[8] <== eq[18][i].out; + multi_or[2][i].in[9] <== eq[19][i].out; + multi_or[2][i].in[10] <== eq[20][i].out; + multi_or[2][i].in[11] <== eq[21][i].out; + multi_or[2][i].in[12] <== eq[22][i].out; + multi_or[2][i].in[13] <== eq[23][i].out; + and[12][i].b <== multi_or[2][i].out; + lt[10][i] = LessEqThan(8); + lt[10][i].in[0] <== 144; + lt[10][i].in[1] <== in[i]; + lt[11][i] = LessEqThan(8); + lt[11][i].in[0] <== in[i]; + lt[11][i].in[1] <== 191; + and[13][i] = AND(); + and[13][i].a <== lt[10][i].out; + and[13][i].b <== lt[11][i].out; + and[14][i] = AND(); + and[14][i].a <== states[i][6]; + and[14][i].b <== and[13][i].out; + and[15][i] = AND(); + and[15][i].a <== states[i][7]; + and[15][i].b <== and[2][i].out; eq[24][i] = IsEqual(); eq[24][i].in[0] <== in[i]; - eq[24][i].in[1] <== 137; + eq[24][i].in[1] <== 128; eq[25][i] = IsEqual(); eq[25][i].in[0] <== in[i]; - eq[25][i].in[1] <== 138; + eq[25][i].in[1] <== 129; eq[26][i] = IsEqual(); eq[26][i].in[0] <== in[i]; - eq[26][i].in[1] <== 139; + eq[26][i].in[1] <== 130; eq[27][i] = IsEqual(); eq[27][i].in[0] <== in[i]; - eq[27][i].in[1] <== 140; + eq[27][i].in[1] <== 131; eq[28][i] = IsEqual(); eq[28][i].in[0] <== in[i]; - eq[28][i].in[1] <== 141; + eq[28][i].in[1] <== 132; eq[29][i] = IsEqual(); eq[29][i].in[0] <== in[i]; - eq[29][i].in[1] <== 142; + eq[29][i].in[1] <== 133; eq[30][i] = IsEqual(); eq[30][i].in[0] <== in[i]; - eq[30][i].in[1] <== 143; - and[13][i] = AND(); - and[13][i].a <== states[i][7]; - multi_or[2][i] = MultiOR(16); - multi_or[2][i].in[0] <== eq[15][i].out; - multi_or[2][i].in[1] <== eq[16][i].out; - multi_or[2][i].in[2] <== eq[17][i].out; - multi_or[2][i].in[3] <== eq[18][i].out; - multi_or[2][i].in[4] <== eq[19][i].out; - multi_or[2][i].in[5] <== eq[20][i].out; - multi_or[2][i].in[6] <== eq[21][i].out; - multi_or[2][i].in[7] <== eq[22][i].out; - multi_or[2][i].in[8] <== eq[23][i].out; - multi_or[2][i].in[9] <== eq[24][i].out; - multi_or[2][i].in[10] <== eq[25][i].out; - multi_or[2][i].in[11] <== eq[26][i].out; - multi_or[2][i].in[12] <== eq[27][i].out; - multi_or[2][i].in[13] <== eq[28][i].out; - multi_or[2][i].in[14] <== eq[29][i].out; - multi_or[2][i].in[15] <== eq[30][i].out; - and[13][i].b <== multi_or[2][i].out; - 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[2] <== and[13][i].out; - states_tmp[i+1][3] <== multi_or[3][i].out; + eq[30][i].in[1] <== 134; eq[31][i] = IsEqual(); eq[31][i].in[0] <== in[i]; - eq[31][i].in[1] <== 237; - and[14][i] = AND(); - and[14][i].a <== states[i][0]; - and[14][i].b <== eq[31][i].out; - states_tmp[i+1][4] <== 0; + eq[31][i].in[1] <== 135; eq[32][i] = IsEqual(); eq[32][i].in[0] <== in[i]; - eq[32][i].in[1] <== 240; - and[15][i] = AND(); - and[15][i].a <== states[i][0]; - and[15][i].b <== eq[32][i].out; - states_tmp[i+1][5] <== 0; + eq[32][i].in[1] <== 136; eq[33][i] = IsEqual(); eq[33][i].in[0] <== in[i]; - eq[33][i].in[1] <== 241; + eq[33][i].in[1] <== 137; eq[34][i] = IsEqual(); eq[34][i].in[0] <== in[i]; - eq[34][i].in[1] <== 242; + eq[34][i].in[1] <== 138; eq[35][i] = IsEqual(); eq[35][i].in[0] <== in[i]; - eq[35][i].in[1] <== 243; - and[16][i] = AND(); - and[16][i].a <== states[i][0]; - multi_or[4][i] = MultiOR(3); - multi_or[4][i].in[0] <== eq[33][i].out; - multi_or[4][i].in[1] <== eq[34][i].out; - multi_or[4][i].in[2] <== eq[35][i].out; - and[16][i].b <== multi_or[4][i].out; - states_tmp[i+1][6] <== 0; + eq[35][i].in[1] <== 139; eq[36][i] = IsEqual(); eq[36][i].in[0] <== in[i]; - eq[36][i].in[1] <== 244; - and[17][i] = AND(); - and[17][i].a <== states[i][0]; - and[17][i].b <== eq[36][i].out; - states_tmp[i+1][7] <== 0; - lt[10][i] = LessEqThan(8); - lt[10][i].in[0] <== 11; - lt[10][i].in[1] <== in[i]; - lt[11][i] = LessEqThan(8); - lt[11][i].in[0] <== in[i]; - lt[11][i].in[1] <== 127; - and[18][i] = AND(); - and[18][i].a <== lt[10][i].out; - and[18][i].b <== lt[11][i].out; + eq[36][i].in[1] <== 140; eq[37][i] = IsEqual(); eq[37][i].in[0] <== in[i]; - eq[37][i].in[1] <== 1; + eq[37][i].in[1] <== 141; eq[38][i] = IsEqual(); eq[38][i].in[0] <== in[i]; - eq[38][i].in[1] <== 2; + eq[38][i].in[1] <== 142; eq[39][i] = IsEqual(); eq[39][i].in[0] <== in[i]; - eq[39][i].in[1] <== 3; + eq[39][i].in[1] <== 143; + and[16][i] = AND(); + and[16][i].a <== states[i][8]; + multi_or[3][i] = MultiOR(16); + multi_or[3][i].in[0] <== eq[24][i].out; + multi_or[3][i].in[1] <== eq[25][i].out; + multi_or[3][i].in[2] <== eq[26][i].out; + multi_or[3][i].in[3] <== eq[27][i].out; + multi_or[3][i].in[4] <== eq[28][i].out; + multi_or[3][i].in[5] <== eq[29][i].out; + multi_or[3][i].in[6] <== eq[30][i].out; + multi_or[3][i].in[7] <== eq[31][i].out; + multi_or[3][i].in[8] <== eq[32][i].out; + multi_or[3][i].in[9] <== eq[33][i].out; + multi_or[3][i].in[10] <== eq[34][i].out; + multi_or[3][i].in[11] <== eq[35][i].out; + multi_or[3][i].in[12] <== eq[36][i].out; + multi_or[3][i].in[13] <== eq[37][i].out; + multi_or[3][i].in[14] <== eq[38][i].out; + multi_or[3][i].in[15] <== eq[39][i].out; + and[16][i].b <== multi_or[3][i].out; + multi_or[4][i] = MultiOR(3); + 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] <== and[16][i].out; + states_tmp[i+1][4] <== multi_or[4][i].out; eq[40][i] = IsEqual(); eq[40][i].in[0] <== in[i]; - eq[40][i].in[1] <== 4; + eq[40][i].in[1] <== 237; + and[17][i] = AND(); + and[17][i].a <== states[i][0]; + and[17][i].b <== eq[40][i].out; + states_tmp[i+1][5] <== 0; eq[41][i] = IsEqual(); eq[41][i].in[0] <== in[i]; - eq[41][i].in[1] <== 5; + eq[41][i].in[1] <== 240; + and[18][i] = AND(); + and[18][i].a <== states[i][0]; + and[18][i].b <== eq[41][i].out; + states_tmp[i+1][6] <== 0; eq[42][i] = IsEqual(); eq[42][i].in[0] <== in[i]; - eq[42][i].in[1] <== 6; + eq[42][i].in[1] <== 241; eq[43][i] = IsEqual(); eq[43][i].in[0] <== in[i]; - eq[43][i].in[1] <== 7; + eq[43][i].in[1] <== 242; eq[44][i] = IsEqual(); eq[44][i].in[0] <== in[i]; - eq[44][i].in[1] <== 8; - eq[45][i] = IsEqual(); - eq[45][i].in[0] <== in[i]; - eq[45][i].in[1] <== 9; + eq[44][i].in[1] <== 243; and[19][i] = AND(); and[19][i].a <== states[i][0]; - multi_or[5][i] = MultiOR(10); - multi_or[5][i].in[0] <== and[18][i].out; - multi_or[5][i].in[1] <== eq[37][i].out; - multi_or[5][i].in[2] <== eq[38][i].out; - multi_or[5][i].in[3] <== eq[39][i].out; - multi_or[5][i].in[4] <== eq[40][i].out; - multi_or[5][i].in[5] <== eq[41][i].out; - multi_or[5][i].in[6] <== eq[42][i].out; - multi_or[5][i].in[7] <== eq[43][i].out; - multi_or[5][i].in[8] <== eq[44][i].out; - multi_or[5][i].in[9] <== eq[45][i].out; + multi_or[5][i] = MultiOR(3); + multi_or[5][i].in[0] <== eq[42][i].out; + multi_or[5][i].in[1] <== eq[43][i].out; + multi_or[5][i].in[2] <== eq[44][i].out; and[19][i].b <== multi_or[5][i].out; + states_tmp[i+1][7] <== 0; + eq[45][i] = IsEqual(); + eq[45][i].in[0] <== in[i]; + eq[45][i].in[1] <== 244; and[20][i] = AND(); - and[20][i].a <== states[i][1]; - and[20][i].b <== and[4][i].out; - states_tmp[i+1][8] <== and[20][i].out; + and[20][i].a <== states[i][0]; + and[20][i].b <== eq[45][i].out; + states_tmp[i+1][8] <== 0; from_zero_enabled[i] <== MultiNOR(8)([states_tmp[i+1][1], states_tmp[i+1][2], states_tmp[i+1][3], states_tmp[i+1][4], states_tmp[i+1][5], states_tmp[i+1][6], states_tmp[i+1][7], states_tmp[i+1][8]]); states[i+1][1] <== MultiOR(2)([states_tmp[i+1][1], from_zero_enabled[i] * and[1][i].out]); - states[i+1][2] <== MultiOR(2)([states_tmp[i+1][2], from_zero_enabled[i] * and[8][i].out]); - states[i+1][3] <== MultiOR(2)([states_tmp[i+1][3], from_zero_enabled[i] * and[9][i].out]); - states[i+1][4] <== MultiOR(2)([states_tmp[i+1][4], from_zero_enabled[i] * and[14][i].out]); - states[i+1][5] <== MultiOR(2)([states_tmp[i+1][5], from_zero_enabled[i] * and[15][i].out]); - states[i+1][6] <== MultiOR(2)([states_tmp[i+1][6], from_zero_enabled[i] * and[16][i].out]); - states[i+1][7] <== MultiOR(2)([states_tmp[i+1][7], from_zero_enabled[i] * and[17][i].out]); - states[i+1][8] <== MultiOR(2)([states_tmp[i+1][8], from_zero_enabled[i] * and[19][i].out]); + states[i+1][2] <== MultiOR(2)([states_tmp[i+1][2], from_zero_enabled[i] * and[5][i].out]); + states[i+1][3] <== MultiOR(2)([states_tmp[i+1][3], from_zero_enabled[i] * and[11][i].out]); + states[i+1][4] <== MultiOR(2)([states_tmp[i+1][4], from_zero_enabled[i] * and[12][i].out]); + states[i+1][5] <== MultiOR(2)([states_tmp[i+1][5], from_zero_enabled[i] * and[17][i].out]); + states[i+1][6] <== MultiOR(2)([states_tmp[i+1][6], from_zero_enabled[i] * and[18][i].out]); + states[i+1][7] <== MultiOR(2)([states_tmp[i+1][7], from_zero_enabled[i] * and[19][i].out]); + states[i+1][8] <== MultiOR(2)([states_tmp[i+1][8], from_zero_enabled[i] * and[20][i].out]); state_changed[i].in[0] <== states[i+1][1]; state_changed[i].in[1] <== states[i+1][2]; state_changed[i].in[2] <== states[i+1][3]; @@ -352,23 +352,23 @@ template Dot1Regex(msg_bytes) { component is_accepted = MultiOR(num_bytes+1); for (var i = 0; i <= num_bytes; i++) { - is_accepted.in[i] <== states[i][8]; + is_accepted.in[i] <== states[i][1]; } out <== is_accepted.out; signal is_consecutive[msg_bytes+1][3]; is_consecutive[msg_bytes][2] <== 0; for (var i = 0; i < msg_bytes; i++) { - is_consecutive[msg_bytes-1-i][0] <== states[num_bytes-i][8] * (1 - is_consecutive[msg_bytes-i][2]) + is_consecutive[msg_bytes-i][2]; + is_consecutive[msg_bytes-1-i][0] <== states[num_bytes-i][1] * (1 - is_consecutive[msg_bytes-i][2]) + is_consecutive[msg_bytes-i][2]; is_consecutive[msg_bytes-1-i][1] <== state_changed[msg_bytes-i].out * is_consecutive[msg_bytes-1-i][0]; - is_consecutive[msg_bytes-1-i][2] <== ORAnd()([(1 - from_zero_enabled[msg_bytes-i+1]), states[num_bytes-i][8], is_consecutive[msg_bytes-1-i][1]]); + is_consecutive[msg_bytes-1-i][2] <== ORAnd()([(1 - from_zero_enabled[msg_bytes-i+1]), states[num_bytes-i][1], is_consecutive[msg_bytes-1-i][1]]); } - // substrings calculated: [{(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (1, 8), (2, 1), (3, 1), (4, 1), (5, 3), (6, 3), (7, 3)}] + // substrings calculated: [{(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (2, 1), (3, 2), (4, 2), (5, 2), (6, 4), (7, 4), (8, 4)}] signal prev_states0[15][msg_bytes]; signal is_substr0[msg_bytes]; signal is_reveal0[msg_bytes]; signal output reveal0[msg_bytes]; for (var i = 0; i < msg_bytes; i++) { - // the 0-th substring transitions: [(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (1, 8), (2, 1), (3, 1), (4, 1), (5, 3), (6, 3), (7, 3)] + // the 0-th substring transitions: [(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (2, 1), (3, 2), (4, 2), (5, 2), (6, 4), (7, 4), (8, 4)] prev_states0[0][i] <== from_zero_enabled[i+1] * states[i+1][0]; prev_states0[1][i] <== from_zero_enabled[i+1] * states[i+1][0]; prev_states0[2][i] <== from_zero_enabled[i+1] * states[i+1][0]; @@ -377,14 +377,14 @@ template Dot1Regex(msg_bytes) { prev_states0[5][i] <== from_zero_enabled[i+1] * states[i+1][0]; prev_states0[6][i] <== from_zero_enabled[i+1] * states[i+1][0]; prev_states0[7][i] <== from_zero_enabled[i+1] * states[i+1][0]; - prev_states0[8][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][1]; - prev_states0[9][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][2]; - prev_states0[10][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][3]; - prev_states0[11][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][4]; - prev_states0[12][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][5]; - prev_states0[13][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][6]; - prev_states0[14][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][7]; - is_substr0[i] <== MultiOR(15)([prev_states0[0][i] * states[i+2][1], prev_states0[1][i] * states[i+2][2], prev_states0[2][i] * states[i+2][3], prev_states0[3][i] * states[i+2][4], prev_states0[4][i] * states[i+2][5], prev_states0[5][i] * states[i+2][6], prev_states0[6][i] * states[i+2][7], prev_states0[7][i] * states[i+2][8], prev_states0[8][i] * states[i+2][8], prev_states0[9][i] * states[i+2][1], prev_states0[10][i] * states[i+2][1], prev_states0[11][i] * states[i+2][1], prev_states0[12][i] * states[i+2][3], prev_states0[13][i] * states[i+2][3], prev_states0[14][i] * states[i+2][3]]); + prev_states0[8][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][2]; + prev_states0[9][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][3]; + prev_states0[10][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][4]; + prev_states0[11][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][5]; + prev_states0[12][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][6]; + prev_states0[13][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][7]; + prev_states0[14][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][8]; + is_substr0[i] <== MultiOR(15)([prev_states0[0][i] * states[i+2][1], prev_states0[1][i] * states[i+2][2], prev_states0[2][i] * states[i+2][3], prev_states0[3][i] * states[i+2][4], prev_states0[4][i] * states[i+2][5], prev_states0[5][i] * states[i+2][6], prev_states0[6][i] * states[i+2][7], prev_states0[7][i] * states[i+2][8], prev_states0[8][i] * states[i+2][1], prev_states0[9][i] * states[i+2][2], prev_states0[10][i] * states[i+2][2], prev_states0[11][i] * states[i+2][2], prev_states0[12][i] * states[i+2][4], prev_states0[13][i] * states[i+2][4], prev_states0[14][i] * states[i+2][4]]); is_reveal0[i] <== MultiAND(3)([out, is_substr0[i], is_consecutive[i][2]]); reveal0[i] <== in[i+1] * is_reveal0[i]; } diff --git a/packages/circom/tests/circuits/dot2_regex.circom b/packages/circom/tests/circuits/dot2_regex.circom index 855b946..366ac40 100644 --- a/packages/circom/tests/circuits/dot2_regex.circom +++ b/packages/circom/tests/circuits/dot2_regex.circom @@ -39,19 +39,57 @@ template Dot2Regex(msg_bytes) { and[0][i].b <== eq[0][i].out; states_tmp[i+1][1] <== 0; lt[0][i] = LessEqThan(8); - lt[0][i].in[0] <== 194; + lt[0][i].in[0] <== 11; lt[0][i].in[1] <== in[i]; lt[1][i] = LessEqThan(8); lt[1][i].in[0] <== in[i]; - lt[1][i].in[1] <== 223; + lt[1][i].in[1] <== 127; and[1][i] = AND(); and[1][i].a <== lt[0][i].out; and[1][i].b <== lt[1][i].out; + eq[1][i] = IsEqual(); + eq[1][i].in[0] <== in[i]; + eq[1][i].in[1] <== 1; + eq[2][i] = IsEqual(); + eq[2][i].in[0] <== in[i]; + eq[2][i].in[1] <== 2; + eq[3][i] = IsEqual(); + eq[3][i].in[0] <== in[i]; + eq[3][i].in[1] <== 3; + eq[4][i] = IsEqual(); + eq[4][i].in[0] <== in[i]; + eq[4][i].in[1] <== 4; + eq[5][i] = IsEqual(); + eq[5][i].in[0] <== in[i]; + eq[5][i].in[1] <== 5; + eq[6][i] = IsEqual(); + eq[6][i].in[0] <== in[i]; + eq[6][i].in[1] <== 6; + eq[7][i] = IsEqual(); + eq[7][i].in[0] <== in[i]; + eq[7][i].in[1] <== 7; + eq[8][i] = IsEqual(); + eq[8][i].in[0] <== in[i]; + eq[8][i].in[1] <== 8; + eq[9][i] = IsEqual(); + eq[9][i].in[0] <== in[i]; + eq[9][i].in[1] <== 9; and[2][i] = AND(); and[2][i].a <== states[i][1]; - and[2][i].b <== and[1][i].out; + multi_or[0][i] = MultiOR(10); + multi_or[0][i].in[0] <== and[1][i].out; + multi_or[0][i].in[1] <== eq[1][i].out; + multi_or[0][i].in[2] <== eq[2][i].out; + multi_or[0][i].in[3] <== eq[3][i].out; + multi_or[0][i].in[4] <== eq[4][i].out; + multi_or[0][i].in[5] <== eq[5][i].out; + multi_or[0][i].in[6] <== eq[6][i].out; + multi_or[0][i].in[7] <== eq[7][i].out; + multi_or[0][i].in[8] <== eq[8][i].out; + multi_or[0][i].in[9] <== eq[9][i].out; + and[2][i].b <== multi_or[0][i].out; lt[2][i] = LessEqThan(8); - lt[2][i].in[0] <== 160; + lt[2][i].in[0] <== 128; lt[2][i].in[1] <== in[i]; lt[3][i] = LessEqThan(8); lt[3][i].in[0] <== in[i]; @@ -62,292 +100,254 @@ template Dot2Regex(msg_bytes) { and[4][i] = AND(); and[4][i].a <== states[i][3]; and[4][i].b <== and[3][i].out; + multi_or[1][i] = MultiOR(2); + multi_or[1][i].in[0] <== and[2][i].out; + multi_or[1][i].in[1] <== and[4][i].out; + states[i+1][2] <== multi_or[1][i].out; lt[4][i] = LessEqThan(8); - lt[4][i].in[0] <== 128; + lt[4][i].in[0] <== 194; lt[4][i].in[1] <== in[i]; lt[5][i] = LessEqThan(8); lt[5][i].in[0] <== in[i]; - lt[5][i].in[1] <== 191; + lt[5][i].in[1] <== 223; and[5][i] = AND(); and[5][i].a <== lt[4][i].out; and[5][i].b <== lt[5][i].out; and[6][i] = AND(); - and[6][i].a <== states[i][4]; + and[6][i].a <== states[i][1]; and[6][i].b <== and[5][i].out; lt[6][i] = LessEqThan(8); - lt[6][i].in[0] <== 128; + lt[6][i].in[0] <== 160; lt[6][i].in[1] <== in[i]; lt[7][i] = LessEqThan(8); lt[7][i].in[0] <== in[i]; - lt[7][i].in[1] <== 159; + lt[7][i].in[1] <== 191; and[7][i] = AND(); 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][5]; + and[8][i].a <== states[i][4]; and[8][i].b <== and[7][i].out; - multi_or[0][i] = MultiOR(4); - multi_or[0][i].in[0] <== and[2][i].out; - multi_or[0][i].in[1] <== and[4][i].out; - multi_or[0][i].in[2] <== and[6][i].out; - multi_or[0][i].in[3] <== and[8][i].out; - states[i+1][2] <== multi_or[0][i].out; - eq[1][i] = IsEqual(); - eq[1][i].in[0] <== in[i]; - eq[1][i].in[1] <== 224; and[9][i] = AND(); - and[9][i].a <== states[i][1]; - and[9][i].b <== eq[1][i].out; - states[i+1][3] <== and[9][i].out; - eq[2][i] = IsEqual(); - eq[2][i].in[0] <== in[i]; - eq[2][i].in[1] <== 225; - eq[3][i] = IsEqual(); - eq[3][i].in[0] <== in[i]; - eq[3][i].in[1] <== 226; - eq[4][i] = IsEqual(); - eq[4][i].in[0] <== in[i]; - eq[4][i].in[1] <== 227; - eq[5][i] = IsEqual(); - eq[5][i].in[0] <== in[i]; - eq[5][i].in[1] <== 228; - eq[6][i] = IsEqual(); - eq[6][i].in[0] <== in[i]; - eq[6][i].in[1] <== 229; - eq[7][i] = IsEqual(); - eq[7][i].in[0] <== in[i]; - eq[7][i].in[1] <== 230; - eq[8][i] = IsEqual(); - eq[8][i].in[0] <== in[i]; - eq[8][i].in[1] <== 231; - eq[9][i] = IsEqual(); - eq[9][i].in[0] <== in[i]; - eq[9][i].in[1] <== 232; + and[9][i].a <== states[i][5]; + and[9][i].b <== and[3][i].out; + lt[8][i] = LessEqThan(8); + lt[8][i].in[0] <== 128; + lt[8][i].in[1] <== in[i]; + lt[9][i] = LessEqThan(8); + lt[9][i].in[0] <== in[i]; + lt[9][i].in[1] <== 159; + and[10][i] = AND(); + and[10][i].a <== lt[8][i].out; + and[10][i].b <== lt[9][i].out; + and[11][i] = AND(); + and[11][i].a <== states[i][6]; + and[11][i].b <== and[10][i].out; + multi_or[2][i] = MultiOR(4); + multi_or[2][i].in[0] <== and[6][i].out; + multi_or[2][i].in[1] <== and[8][i].out; + multi_or[2][i].in[2] <== and[9][i].out; + multi_or[2][i].in[3] <== and[11][i].out; + states[i+1][3] <== multi_or[2][i].out; eq[10][i] = IsEqual(); eq[10][i].in[0] <== in[i]; - eq[10][i].in[1] <== 233; + eq[10][i].in[1] <== 224; + and[12][i] = AND(); + and[12][i].a <== states[i][1]; + and[12][i].b <== eq[10][i].out; + states[i+1][4] <== and[12][i].out; eq[11][i] = IsEqual(); eq[11][i].in[0] <== in[i]; - eq[11][i].in[1] <== 234; + eq[11][i].in[1] <== 225; eq[12][i] = IsEqual(); eq[12][i].in[0] <== in[i]; - eq[12][i].in[1] <== 235; + eq[12][i].in[1] <== 226; eq[13][i] = IsEqual(); eq[13][i].in[0] <== in[i]; - eq[13][i].in[1] <== 236; + eq[13][i].in[1] <== 227; eq[14][i] = IsEqual(); eq[14][i].in[0] <== in[i]; - eq[14][i].in[1] <== 238; + eq[14][i].in[1] <== 228; eq[15][i] = IsEqual(); eq[15][i].in[0] <== in[i]; - eq[15][i].in[1] <== 239; - and[10][i] = AND(); - and[10][i].a <== states[i][1]; - multi_or[1][i] = MultiOR(14); - multi_or[1][i].in[0] <== eq[2][i].out; - multi_or[1][i].in[1] <== eq[3][i].out; - multi_or[1][i].in[2] <== eq[4][i].out; - multi_or[1][i].in[3] <== eq[5][i].out; - multi_or[1][i].in[4] <== eq[6][i].out; - multi_or[1][i].in[5] <== eq[7][i].out; - multi_or[1][i].in[6] <== eq[8][i].out; - multi_or[1][i].in[7] <== eq[9][i].out; - multi_or[1][i].in[8] <== eq[10][i].out; - multi_or[1][i].in[9] <== eq[11][i].out; - multi_or[1][i].in[10] <== eq[12][i].out; - multi_or[1][i].in[11] <== eq[13][i].out; - multi_or[1][i].in[12] <== eq[14][i].out; - multi_or[1][i].in[13] <== eq[15][i].out; - and[10][i].b <== multi_or[1][i].out; - lt[8][i] = LessEqThan(8); - lt[8][i].in[0] <== 144; - lt[8][i].in[1] <== in[i]; - lt[9][i] = LessEqThan(8); - lt[9][i].in[0] <== in[i]; - lt[9][i].in[1] <== 191; - and[11][i] = AND(); - and[11][i].a <== lt[8][i].out; - and[11][i].b <== lt[9][i].out; - and[12][i] = AND(); - and[12][i].a <== states[i][6]; - and[12][i].b <== and[11][i].out; - and[13][i] = AND(); - and[13][i].a <== states[i][7]; - and[13][i].b <== and[5][i].out; + eq[15][i].in[1] <== 229; eq[16][i] = IsEqual(); eq[16][i].in[0] <== in[i]; - eq[16][i].in[1] <== 128; + eq[16][i].in[1] <== 230; eq[17][i] = IsEqual(); eq[17][i].in[0] <== in[i]; - eq[17][i].in[1] <== 129; + eq[17][i].in[1] <== 231; eq[18][i] = IsEqual(); eq[18][i].in[0] <== in[i]; - eq[18][i].in[1] <== 130; + eq[18][i].in[1] <== 232; eq[19][i] = IsEqual(); eq[19][i].in[0] <== in[i]; - eq[19][i].in[1] <== 131; + eq[19][i].in[1] <== 233; eq[20][i] = IsEqual(); eq[20][i].in[0] <== in[i]; - eq[20][i].in[1] <== 132; + eq[20][i].in[1] <== 234; eq[21][i] = IsEqual(); eq[21][i].in[0] <== in[i]; - eq[21][i].in[1] <== 133; + eq[21][i].in[1] <== 235; eq[22][i] = IsEqual(); eq[22][i].in[0] <== in[i]; - eq[22][i].in[1] <== 134; + eq[22][i].in[1] <== 236; eq[23][i] = IsEqual(); eq[23][i].in[0] <== in[i]; - eq[23][i].in[1] <== 135; + eq[23][i].in[1] <== 238; eq[24][i] = IsEqual(); eq[24][i].in[0] <== in[i]; - eq[24][i].in[1] <== 136; + eq[24][i].in[1] <== 239; + and[13][i] = AND(); + and[13][i].a <== states[i][1]; + multi_or[3][i] = MultiOR(14); + multi_or[3][i].in[0] <== eq[11][i].out; + multi_or[3][i].in[1] <== eq[12][i].out; + multi_or[3][i].in[2] <== eq[13][i].out; + multi_or[3][i].in[3] <== eq[14][i].out; + multi_or[3][i].in[4] <== eq[15][i].out; + multi_or[3][i].in[5] <== eq[16][i].out; + multi_or[3][i].in[6] <== eq[17][i].out; + multi_or[3][i].in[7] <== eq[18][i].out; + multi_or[3][i].in[8] <== eq[19][i].out; + multi_or[3][i].in[9] <== eq[20][i].out; + multi_or[3][i].in[10] <== eq[21][i].out; + multi_or[3][i].in[11] <== eq[22][i].out; + multi_or[3][i].in[12] <== eq[23][i].out; + multi_or[3][i].in[13] <== eq[24][i].out; + and[13][i].b <== multi_or[3][i].out; + lt[10][i] = LessEqThan(8); + lt[10][i].in[0] <== 144; + lt[10][i].in[1] <== in[i]; + lt[11][i] = LessEqThan(8); + lt[11][i].in[0] <== in[i]; + lt[11][i].in[1] <== 191; + and[14][i] = AND(); + and[14][i].a <== lt[10][i].out; + and[14][i].b <== lt[11][i].out; + and[15][i] = AND(); + and[15][i].a <== states[i][7]; + and[15][i].b <== and[14][i].out; + and[16][i] = AND(); + and[16][i].a <== states[i][8]; + and[16][i].b <== and[3][i].out; eq[25][i] = IsEqual(); eq[25][i].in[0] <== in[i]; - eq[25][i].in[1] <== 137; + eq[25][i].in[1] <== 128; eq[26][i] = IsEqual(); eq[26][i].in[0] <== in[i]; - eq[26][i].in[1] <== 138; + eq[26][i].in[1] <== 129; eq[27][i] = IsEqual(); eq[27][i].in[0] <== in[i]; - eq[27][i].in[1] <== 139; + eq[27][i].in[1] <== 130; eq[28][i] = IsEqual(); eq[28][i].in[0] <== in[i]; - eq[28][i].in[1] <== 140; + eq[28][i].in[1] <== 131; eq[29][i] = IsEqual(); eq[29][i].in[0] <== in[i]; - eq[29][i].in[1] <== 141; + eq[29][i].in[1] <== 132; eq[30][i] = IsEqual(); eq[30][i].in[0] <== in[i]; - eq[30][i].in[1] <== 142; + eq[30][i].in[1] <== 133; eq[31][i] = IsEqual(); eq[31][i].in[0] <== in[i]; - eq[31][i].in[1] <== 143; - and[14][i] = AND(); - and[14][i].a <== states[i][8]; - multi_or[2][i] = MultiOR(16); - multi_or[2][i].in[0] <== eq[16][i].out; - multi_or[2][i].in[1] <== eq[17][i].out; - multi_or[2][i].in[2] <== eq[18][i].out; - multi_or[2][i].in[3] <== eq[19][i].out; - multi_or[2][i].in[4] <== eq[20][i].out; - multi_or[2][i].in[5] <== eq[21][i].out; - multi_or[2][i].in[6] <== eq[22][i].out; - multi_or[2][i].in[7] <== eq[23][i].out; - multi_or[2][i].in[8] <== eq[24][i].out; - multi_or[2][i].in[9] <== eq[25][i].out; - multi_or[2][i].in[10] <== eq[26][i].out; - multi_or[2][i].in[11] <== eq[27][i].out; - multi_or[2][i].in[12] <== eq[28][i].out; - multi_or[2][i].in[13] <== eq[29][i].out; - multi_or[2][i].in[14] <== eq[30][i].out; - multi_or[2][i].in[15] <== eq[31][i].out; - and[14][i].b <== multi_or[2][i].out; - multi_or[3][i] = MultiOR(4); - multi_or[3][i].in[0] <== and[10][i].out; - multi_or[3][i].in[1] <== and[12][i].out; - multi_or[3][i].in[2] <== and[13][i].out; - multi_or[3][i].in[3] <== and[14][i].out; - states[i+1][4] <== multi_or[3][i].out; + eq[31][i].in[1] <== 134; eq[32][i] = IsEqual(); eq[32][i].in[0] <== in[i]; - eq[32][i].in[1] <== 237; - and[15][i] = AND(); - and[15][i].a <== states[i][1]; - and[15][i].b <== eq[32][i].out; - states[i+1][5] <== and[15][i].out; + eq[32][i].in[1] <== 135; eq[33][i] = IsEqual(); eq[33][i].in[0] <== in[i]; - eq[33][i].in[1] <== 240; - and[16][i] = AND(); - and[16][i].a <== states[i][1]; - and[16][i].b <== eq[33][i].out; - states[i+1][6] <== and[16][i].out; + eq[33][i].in[1] <== 136; eq[34][i] = IsEqual(); eq[34][i].in[0] <== in[i]; - eq[34][i].in[1] <== 241; + eq[34][i].in[1] <== 137; eq[35][i] = IsEqual(); eq[35][i].in[0] <== in[i]; - eq[35][i].in[1] <== 242; + eq[35][i].in[1] <== 138; eq[36][i] = IsEqual(); eq[36][i].in[0] <== in[i]; - eq[36][i].in[1] <== 243; - and[17][i] = AND(); - and[17][i].a <== states[i][1]; - multi_or[4][i] = MultiOR(3); - multi_or[4][i].in[0] <== eq[34][i].out; - multi_or[4][i].in[1] <== eq[35][i].out; - multi_or[4][i].in[2] <== eq[36][i].out; - and[17][i].b <== multi_or[4][i].out; - states[i+1][7] <== and[17][i].out; + eq[36][i].in[1] <== 139; eq[37][i] = IsEqual(); eq[37][i].in[0] <== in[i]; - eq[37][i].in[1] <== 244; - and[18][i] = AND(); - and[18][i].a <== states[i][1]; - and[18][i].b <== eq[37][i].out; - states[i+1][8] <== and[18][i].out; - lt[10][i] = LessEqThan(8); - lt[10][i].in[0] <== 11; - lt[10][i].in[1] <== in[i]; - lt[11][i] = LessEqThan(8); - lt[11][i].in[0] <== in[i]; - lt[11][i].in[1] <== 127; - and[19][i] = AND(); - and[19][i].a <== lt[10][i].out; - and[19][i].b <== lt[11][i].out; + eq[37][i].in[1] <== 140; eq[38][i] = IsEqual(); eq[38][i].in[0] <== in[i]; - eq[38][i].in[1] <== 1; + eq[38][i].in[1] <== 141; eq[39][i] = IsEqual(); eq[39][i].in[0] <== in[i]; - eq[39][i].in[1] <== 2; + eq[39][i].in[1] <== 142; eq[40][i] = IsEqual(); eq[40][i].in[0] <== in[i]; - eq[40][i].in[1] <== 3; + eq[40][i].in[1] <== 143; + and[17][i] = AND(); + and[17][i].a <== states[i][9]; + multi_or[4][i] = MultiOR(16); + multi_or[4][i].in[0] <== eq[25][i].out; + multi_or[4][i].in[1] <== eq[26][i].out; + multi_or[4][i].in[2] <== eq[27][i].out; + multi_or[4][i].in[3] <== eq[28][i].out; + multi_or[4][i].in[4] <== eq[29][i].out; + multi_or[4][i].in[5] <== eq[30][i].out; + multi_or[4][i].in[6] <== eq[31][i].out; + multi_or[4][i].in[7] <== eq[32][i].out; + multi_or[4][i].in[8] <== eq[33][i].out; + multi_or[4][i].in[9] <== eq[34][i].out; + multi_or[4][i].in[10] <== eq[35][i].out; + multi_or[4][i].in[11] <== eq[36][i].out; + multi_or[4][i].in[12] <== eq[37][i].out; + multi_or[4][i].in[13] <== eq[38][i].out; + multi_or[4][i].in[14] <== eq[39][i].out; + multi_or[4][i].in[15] <== eq[40][i].out; + and[17][i].b <== multi_or[4][i].out; + multi_or[5][i] = MultiOR(4); + multi_or[5][i].in[0] <== and[13][i].out; + multi_or[5][i].in[1] <== and[15][i].out; + multi_or[5][i].in[2] <== and[16][i].out; + multi_or[5][i].in[3] <== and[17][i].out; + states[i+1][5] <== multi_or[5][i].out; eq[41][i] = IsEqual(); eq[41][i].in[0] <== in[i]; - eq[41][i].in[1] <== 4; + eq[41][i].in[1] <== 237; + and[18][i] = AND(); + and[18][i].a <== states[i][1]; + and[18][i].b <== eq[41][i].out; + states[i+1][6] <== and[18][i].out; eq[42][i] = IsEqual(); eq[42][i].in[0] <== in[i]; - eq[42][i].in[1] <== 5; + eq[42][i].in[1] <== 240; + and[19][i] = AND(); + and[19][i].a <== states[i][1]; + and[19][i].b <== eq[42][i].out; + states[i+1][7] <== and[19][i].out; eq[43][i] = IsEqual(); eq[43][i].in[0] <== in[i]; - eq[43][i].in[1] <== 6; + eq[43][i].in[1] <== 241; eq[44][i] = IsEqual(); eq[44][i].in[0] <== in[i]; - eq[44][i].in[1] <== 7; + eq[44][i].in[1] <== 242; eq[45][i] = IsEqual(); eq[45][i].in[0] <== in[i]; - eq[45][i].in[1] <== 8; - eq[46][i] = IsEqual(); - eq[46][i].in[0] <== in[i]; - eq[46][i].in[1] <== 9; + eq[45][i].in[1] <== 243; and[20][i] = AND(); and[20][i].a <== states[i][1]; - multi_or[5][i] = MultiOR(10); - multi_or[5][i].in[0] <== and[19][i].out; - multi_or[5][i].in[1] <== eq[38][i].out; - multi_or[5][i].in[2] <== eq[39][i].out; - multi_or[5][i].in[3] <== eq[40][i].out; - multi_or[5][i].in[4] <== eq[41][i].out; - multi_or[5][i].in[5] <== eq[42][i].out; - multi_or[5][i].in[6] <== eq[43][i].out; - multi_or[5][i].in[7] <== eq[44][i].out; - multi_or[5][i].in[8] <== eq[45][i].out; - multi_or[5][i].in[9] <== eq[46][i].out; - and[20][i].b <== multi_or[5][i].out; + multi_or[6][i] = MultiOR(3); + multi_or[6][i].in[0] <== eq[43][i].out; + multi_or[6][i].in[1] <== eq[44][i].out; + multi_or[6][i].in[2] <== eq[45][i].out; + and[20][i].b <== multi_or[6][i].out; + states[i+1][8] <== and[20][i].out; + eq[46][i] = IsEqual(); + eq[46][i].in[0] <== in[i]; + eq[46][i].in[1] <== 244; and[21][i] = AND(); - and[21][i].a <== states[i][2]; - and[21][i].b <== and[5][i].out; - multi_or[6][i] = MultiOR(2); - multi_or[6][i].in[0] <== and[20][i].out; - multi_or[6][i].in[1] <== and[21][i].out; - states[i+1][9] <== multi_or[6][i].out; + and[21][i].a <== states[i][1]; + and[21][i].b <== eq[46][i].out; + states[i+1][9] <== and[21][i].out; eq[47][i] = IsEqual(); eq[47][i].in[0] <== in[i]; eq[47][i].in[1] <== 98; and[22][i] = AND(); - and[22][i].a <== states[i][9]; + and[22][i].a <== states[i][2]; and[22][i].b <== eq[47][i].out; states[i+1][10] <== and[22][i].out; from_zero_enabled[i] <== MultiNOR(10)([states_tmp[i+1][1], states[i+1][2], states[i+1][3], states[i+1][4], states[i+1][5], states[i+1][6], states[i+1][7], states[i+1][8], states[i+1][9], states[i+1][10]]); @@ -376,13 +376,13 @@ template Dot2Regex(msg_bytes) { is_consecutive[msg_bytes-1-i][1] <== state_changed[msg_bytes-i].out * is_consecutive[msg_bytes-1-i][0]; is_consecutive[msg_bytes-1-i][2] <== ORAnd()([(1 - from_zero_enabled[msg_bytes-i+1]), states[num_bytes-i][10], is_consecutive[msg_bytes-1-i][1]]); } - // substrings calculated: [{(1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (2, 9), (3, 2), (4, 2), (5, 2), (6, 4), (7, 4), (8, 4)}] + // substrings calculated: [{(1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (3, 2), (4, 3), (5, 3), (6, 3), (7, 5), (8, 5), (9, 5)}] signal prev_states0[15][msg_bytes]; signal is_substr0[msg_bytes]; signal is_reveal0[msg_bytes]; signal output reveal0[msg_bytes]; for (var i = 0; i < msg_bytes; i++) { - // the 0-th substring transitions: [(1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (2, 9), (3, 2), (4, 2), (5, 2), (6, 4), (7, 4), (8, 4)] + // the 0-th substring transitions: [(1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (3, 2), (4, 3), (5, 3), (6, 3), (7, 5), (8, 5), (9, 5)] prev_states0[0][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][1]; prev_states0[1][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][1]; prev_states0[2][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][1]; @@ -391,14 +391,14 @@ template Dot2Regex(msg_bytes) { prev_states0[5][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][1]; prev_states0[6][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][1]; prev_states0[7][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][1]; - prev_states0[8][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][2]; - prev_states0[9][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][3]; - prev_states0[10][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][4]; - prev_states0[11][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][5]; - prev_states0[12][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][6]; - prev_states0[13][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][7]; - prev_states0[14][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][8]; - is_substr0[i] <== MultiOR(15)([prev_states0[0][i] * states[i+2][2], prev_states0[1][i] * states[i+2][3], prev_states0[2][i] * states[i+2][4], prev_states0[3][i] * states[i+2][5], prev_states0[4][i] * states[i+2][6], prev_states0[5][i] * states[i+2][7], prev_states0[6][i] * states[i+2][8], prev_states0[7][i] * states[i+2][9], prev_states0[8][i] * states[i+2][9], prev_states0[9][i] * states[i+2][2], prev_states0[10][i] * states[i+2][2], prev_states0[11][i] * states[i+2][2], prev_states0[12][i] * states[i+2][4], prev_states0[13][i] * states[i+2][4], prev_states0[14][i] * states[i+2][4]]); + prev_states0[8][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][3]; + prev_states0[9][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][4]; + prev_states0[10][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][5]; + prev_states0[11][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][6]; + prev_states0[12][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][7]; + prev_states0[13][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][8]; + prev_states0[14][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][9]; + is_substr0[i] <== MultiOR(15)([prev_states0[0][i] * states[i+2][2], prev_states0[1][i] * states[i+2][3], prev_states0[2][i] * states[i+2][4], prev_states0[3][i] * states[i+2][5], prev_states0[4][i] * states[i+2][6], prev_states0[5][i] * states[i+2][7], prev_states0[6][i] * states[i+2][8], prev_states0[7][i] * states[i+2][9], prev_states0[8][i] * states[i+2][2], prev_states0[9][i] * states[i+2][3], prev_states0[10][i] * states[i+2][3], prev_states0[11][i] * states[i+2][3], prev_states0[12][i] * states[i+2][5], prev_states0[13][i] * states[i+2][5], prev_states0[14][i] * states[i+2][5]]); is_reveal0[i] <== MultiAND(3)([out, is_substr0[i], is_consecutive[i][2]]); reveal0[i] <== in[i+1] * is_reveal0[i]; } diff --git a/packages/circom/tests/circuits/international_chars_decomposed.circom b/packages/circom/tests/circuits/international_chars_decomposed.circom index a663ca8..95e53db 100644 --- a/packages/circom/tests/circuits/international_chars_decomposed.circom +++ b/packages/circom/tests/circuits/international_chars_decomposed.circom @@ -133,46 +133,46 @@ template InternationalCharsDecomposed(msg_bytes) { states[i+1][16] <== and[15][i].out; eq[12][i] = IsEqual(); eq[12][i].in[0] <== in[i]; - eq[12][i].in[1] <== 195; + eq[12][i].in[1] <== 194; + and[16][i] = AND(); + and[16][i].a <== states[i][16]; + and[16][i].b <== eq[12][i].out; + and[17][i] = AND(); + and[17][i].a <== states[i][19]; + and[17][i].b <== eq[12][i].out; + multi_or[0][i] = MultiOR(2); + multi_or[0][i].in[0] <== and[16][i].out; + multi_or[0][i].in[1] <== and[17][i].out; + states[i+1][17] <== multi_or[0][i].out; eq[13][i] = IsEqual(); eq[13][i].in[0] <== in[i]; - eq[13][i].in[1] <== 196; + eq[13][i].in[1] <== 195; eq[14][i] = IsEqual(); eq[14][i].in[0] <== in[i]; - eq[14][i].in[1] <== 197; + eq[14][i].in[1] <== 196; eq[15][i] = IsEqual(); eq[15][i].in[0] <== in[i]; - eq[15][i].in[1] <== 198; - and[16][i] = AND(); - and[16][i].a <== states[i][16]; - multi_or[0][i] = MultiOR(4); - multi_or[0][i].in[0] <== eq[12][i].out; - multi_or[0][i].in[1] <== eq[13][i].out; - multi_or[0][i].in[2] <== eq[14][i].out; - multi_or[0][i].in[3] <== eq[15][i].out; - and[16][i].b <== multi_or[0][i].out; - and[17][i] = AND(); - and[17][i].a <== states[i][19]; - and[17][i].b <== multi_or[0][i].out; - multi_or[1][i] = MultiOR(2); - multi_or[1][i].in[0] <== and[16][i].out; - multi_or[1][i].in[1] <== and[17][i].out; - states[i+1][17] <== multi_or[1][i].out; + eq[15][i].in[1] <== 197; eq[16][i] = IsEqual(); eq[16][i].in[0] <== in[i]; - eq[16][i].in[1] <== 194; + eq[16][i].in[1] <== 198; and[18][i] = AND(); and[18][i].a <== states[i][16]; - and[18][i].b <== eq[16][i].out; + multi_or[1][i] = MultiOR(4); + multi_or[1][i].in[0] <== eq[13][i].out; + multi_or[1][i].in[1] <== eq[14][i].out; + multi_or[1][i].in[2] <== eq[15][i].out; + multi_or[1][i].in[3] <== eq[16][i].out; + and[18][i].b <== multi_or[1][i].out; and[19][i] = AND(); and[19][i].a <== states[i][19]; - and[19][i].b <== eq[16][i].out; + and[19][i].b <== multi_or[1][i].out; multi_or[2][i] = MultiOR(2); multi_or[2][i].in[0] <== and[18][i].out; multi_or[2][i].in[1] <== and[19][i].out; states[i+1][18] <== multi_or[2][i].out; lt[0][i] = LessEqThan(8); - lt[0][i].in[0] <== 128; + lt[0][i].in[0] <== 161; lt[0][i].in[1] <== in[i]; lt[1][i] = LessEqThan(8); lt[1][i].in[0] <== in[i]; @@ -184,7 +184,7 @@ template InternationalCharsDecomposed(msg_bytes) { and[21][i].a <== states[i][17]; and[21][i].b <== and[20][i].out; lt[2][i] = LessEqThan(8); - lt[2][i].in[0] <== 161; + lt[2][i].in[0] <== 128; lt[2][i].in[1] <== in[i]; lt[3][i] = LessEqThan(8); lt[3][i].in[0] <== in[i]; @@ -241,39 +241,36 @@ template InternationalCharsDecomposed(msg_bytes) { states[i+1][26] <== and[30][i].out; eq[21][i] = IsEqual(); eq[21][i].in[0] <== in[i]; - eq[21][i].in[1] <== 206; - eq[22][i] = IsEqual(); - eq[22][i].in[0] <== in[i]; - eq[22][i].in[1] <== 207; + eq[21][i].in[1] <== 205; and[31][i] = AND(); and[31][i].a <== states[i][26]; - multi_or[4][i] = MultiOR(2); - multi_or[4][i].in[0] <== eq[21][i].out; - multi_or[4][i].in[1] <== eq[22][i].out; - and[31][i].b <== multi_or[4][i].out; + and[31][i].b <== eq[21][i].out; and[32][i] = AND(); and[32][i].a <== states[i][29]; - and[32][i].b <== multi_or[4][i].out; - multi_or[5][i] = MultiOR(2); - multi_or[5][i].in[0] <== and[31][i].out; - multi_or[5][i].in[1] <== and[32][i].out; - states[i+1][27] <== multi_or[5][i].out; + and[32][i].b <== eq[21][i].out; + multi_or[4][i] = MultiOR(2); + multi_or[4][i].in[0] <== and[31][i].out; + multi_or[4][i].in[1] <== and[32][i].out; + states[i+1][27] <== multi_or[4][i].out; + eq[22][i] = IsEqual(); + eq[22][i].in[0] <== in[i]; + eq[22][i].in[1] <== 206; eq[23][i] = IsEqual(); eq[23][i].in[0] <== in[i]; - eq[23][i].in[1] <== 205; + eq[23][i].in[1] <== 207; and[33][i] = AND(); and[33][i].a <== states[i][26]; - and[33][i].b <== eq[23][i].out; + multi_or[5][i] = MultiOR(2); + multi_or[5][i].in[0] <== eq[22][i].out; + multi_or[5][i].in[1] <== eq[23][i].out; + and[33][i].b <== multi_or[5][i].out; and[34][i] = AND(); and[34][i].a <== states[i][29]; - and[34][i].b <== eq[23][i].out; + and[34][i].b <== multi_or[5][i].out; multi_or[6][i] = MultiOR(2); multi_or[6][i].in[0] <== and[33][i].out; multi_or[6][i].in[1] <== and[34][i].out; states[i+1][28] <== multi_or[6][i].out; - and[35][i] = AND(); - and[35][i].a <== states[i][27]; - and[35][i].b <== and[20][i].out; eq[24][i] = IsEqual(); eq[24][i].in[0] <== in[i]; eq[24][i].in[1] <== 176; @@ -322,8 +319,8 @@ template InternationalCharsDecomposed(msg_bytes) { eq[39][i] = IsEqual(); eq[39][i].in[0] <== in[i]; eq[39][i].in[1] <== 191; - and[36][i] = AND(); - and[36][i].a <== states[i][28]; + and[35][i] = AND(); + and[35][i].a <== states[i][27]; multi_or[7][i] = MultiOR(16); multi_or[7][i].in[0] <== eq[24][i].out; multi_or[7][i].in[1] <== eq[25][i].out; @@ -341,7 +338,10 @@ template InternationalCharsDecomposed(msg_bytes) { multi_or[7][i].in[13] <== eq[37][i].out; multi_or[7][i].in[14] <== eq[38][i].out; multi_or[7][i].in[15] <== eq[39][i].out; - and[36][i].b <== multi_or[7][i].out; + and[35][i].b <== multi_or[7][i].out; + and[36][i] = AND(); + and[36][i].a <== states[i][28]; + and[36][i].b <== and[22][i].out; multi_or[8][i] = MultiOR(2); multi_or[8][i].in[0] <== and[35][i].out; multi_or[8][i].in[1] <== and[36][i].out; @@ -427,7 +427,7 @@ template InternationalCharsDecomposed(msg_bytes) { states[i+1][40] <== multi_or[10][i].out; and[49][i] = AND(); and[49][i].a <== states[i][40]; - and[49][i].b <== and[20][i].out; + and[49][i].b <== and[22][i].out; states[i+1][41] <== and[49][i].out; and[50][i] = AND(); and[50][i].a <== states[i][41]; @@ -496,7 +496,7 @@ template InternationalCharsDecomposed(msg_bytes) { states[i+1][50] <== multi_or[12][i].out; and[60][i] = AND(); and[60][i].a <== states[i][50]; - and[60][i].b <== and[20][i].out; + and[60][i].b <== and[22][i].out; states[i+1][51] <== and[60][i].out; and[61][i] = AND(); and[61][i].a <== states[i][51]; @@ -583,7 +583,7 @@ template InternationalCharsDecomposed(msg_bytes) { states[i+1][65] <== and[75][i].out; and[76][i] = AND(); and[76][i].a <== states[i][65]; - and[76][i].b <== and[20][i].out; + and[76][i].b <== and[22][i].out; states[i+1][66] <== and[76][i].out; and[77][i] = AND(); and[77][i].a <== states[i][66]; @@ -717,7 +717,7 @@ template InternationalCharsDecomposed(msg_bytes) { and[101][i].b <== and[100][i].out; and[102][i] = AND(); and[102][i].a <== states[i][88]; - and[102][i].b <== and[20][i].out; + and[102][i].b <== and[22][i].out; multi_or[17][i] = MultiOR(2); multi_or[17][i].in[0] <== and[101][i].out; multi_or[17][i].in[1] <== and[102][i].out; diff --git a/packages/circom/tests/circuits/invitation_code_with_prefix_regex.circom b/packages/circom/tests/circuits/invitation_code_with_prefix_regex.circom index 979a9a5..8c31790 100644 --- a/packages/circom/tests/circuits/invitation_code_with_prefix_regex.circom +++ b/packages/circom/tests/circuits/invitation_code_with_prefix_regex.circom @@ -32,32 +32,32 @@ template InvitationCodeWithPrefixRegex(msg_bytes) { states[i][0] <== 1; eq[0][i] = IsEqual(); eq[0][i].in[0] <== in[i]; - eq[0][i].in[1] <== 67; - eq[1][i] = IsEqual(); - eq[1][i].in[0] <== in[i]; - eq[1][i].in[1] <== 99; + eq[0][i].in[1] <== 32; and[0][i] = AND(); and[0][i].a <== states[i][0]; - multi_or[0][i] = MultiOR(2); - multi_or[0][i].in[0] <== eq[0][i].out; - multi_or[0][i].in[1] <== eq[1][i].out; - and[0][i].b <== multi_or[0][i].out; - and[1][i] = AND(); - and[1][i].a <== states[i][2]; - and[1][i].b <== multi_or[0][i].out; - states_tmp[i+1][1] <== and[1][i].out; + and[0][i].b <== eq[0][i].out; + states_tmp[i+1][1] <== 0; + eq[1][i] = IsEqual(); + eq[1][i].in[0] <== in[i]; + eq[1][i].in[1] <== 67; eq[2][i] = IsEqual(); eq[2][i].in[0] <== in[i]; - eq[2][i].in[1] <== 32; + eq[2][i].in[1] <== 99; + and[1][i] = AND(); + and[1][i].a <== states[i][0]; + multi_or[0][i] = MultiOR(2); + multi_or[0][i].in[0] <== eq[1][i].out; + multi_or[0][i].in[1] <== eq[2][i].out; + and[1][i].b <== multi_or[0][i].out; and[2][i] = AND(); - and[2][i].a <== states[i][0]; - and[2][i].b <== eq[2][i].out; - states_tmp[i+1][2] <== 0; + and[2][i].a <== states[i][1]; + and[2][i].b <== multi_or[0][i].out; + states_tmp[i+1][2] <== and[2][i].out; eq[3][i] = IsEqual(); eq[3][i].in[0] <== in[i]; eq[3][i].in[1] <== 111; and[3][i] = AND(); - and[3][i].a <== states[i][1]; + and[3][i].a <== states[i][2]; and[3][i].b <== eq[3][i].out; states[i+1][3] <== and[3][i].out; eq[4][i] = IsEqual(); @@ -76,7 +76,7 @@ template InvitationCodeWithPrefixRegex(msg_bytes) { states[i+1][5] <== and[5][i].out; and[6][i] = AND(); and[6][i].a <== states[i][5]; - and[6][i].b <== eq[2][i].out; + and[6][i].b <== eq[0][i].out; states[i+1][6] <== and[6][i].out; eq[6][i] = IsEqual(); eq[6][i].in[0] <== in[i]; @@ -132,7 +132,7 @@ template InvitationCodeWithPrefixRegex(msg_bytes) { multi_or[1][i].in[9] <== eq[15][i].out; multi_or[1][i].in[10] <== eq[16][i].out; multi_or[1][i].in[11] <== eq[17][i].out; - multi_or[1][i].in[12] <== eq[1][i].out; + multi_or[1][i].in[12] <== eq[2][i].out; multi_or[1][i].in[13] <== eq[4][i].out; multi_or[1][i].in[14] <== eq[5][i].out; multi_or[1][i].in[15] <== eq[18][i].out; @@ -150,7 +150,7 @@ template InvitationCodeWithPrefixRegex(msg_bytes) { states[i+1][7] <== multi_or[2][i].out; from_zero_enabled[i] <== MultiNOR(7)([states_tmp[i+1][1], states_tmp[i+1][2], states[i+1][3], states[i+1][4], states[i+1][5], states[i+1][6], states[i+1][7]]); states[i+1][1] <== MultiOR(2)([states_tmp[i+1][1], from_zero_enabled[i] * and[0][i].out]); - states[i+1][2] <== MultiOR(2)([states_tmp[i+1][2], from_zero_enabled[i] * and[2][i].out]); + states[i+1][2] <== MultiOR(2)([states_tmp[i+1][2], from_zero_enabled[i] * and[1][i].out]); state_changed[i].in[0] <== states[i+1][1]; state_changed[i].in[1] <== states[i+1][2]; state_changed[i].in[2] <== states[i+1][3]; @@ -172,13 +172,13 @@ template InvitationCodeWithPrefixRegex(msg_bytes) { is_consecutive[msg_bytes-1-i][1] <== state_changed[msg_bytes-i].out * is_consecutive[msg_bytes-1-i][0]; is_consecutive[msg_bytes-1-i][2] <== ORAnd()([(1 - from_zero_enabled[msg_bytes-i+1]), states[num_bytes-i][7], is_consecutive[msg_bytes-1-i][1]]); } - // substrings calculated: [{(0, 1), (0, 2), (1, 3), (2, 1), (3, 4), (4, 5), (5, 6), (5, 7), (6, 7), (7, 7)}] + // substrings calculated: [{(0, 1), (0, 2), (1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (5, 7), (6, 7), (7, 7)}] signal prev_states0[10][msg_bytes]; signal is_substr0[msg_bytes]; signal is_reveal0[msg_bytes]; signal output reveal0[msg_bytes]; for (var i = 0; i < msg_bytes; i++) { - // the 0-th substring transitions: [(0, 1), (0, 2), (1, 3), (2, 1), (3, 4), (4, 5), (5, 6), (5, 7), (6, 7), (7, 7)] + // the 0-th substring transitions: [(0, 1), (0, 2), (1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (5, 7), (6, 7), (7, 7)] prev_states0[0][i] <== from_zero_enabled[i+1] * states[i+1][0]; prev_states0[1][i] <== from_zero_enabled[i+1] * states[i+1][0]; prev_states0[2][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][1]; @@ -189,7 +189,7 @@ template InvitationCodeWithPrefixRegex(msg_bytes) { prev_states0[7][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][5]; prev_states0[8][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][6]; prev_states0[9][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][7]; - is_substr0[i] <== MultiOR(10)([prev_states0[0][i] * states[i+2][1], prev_states0[1][i] * states[i+2][2], prev_states0[2][i] * states[i+2][3], prev_states0[3][i] * states[i+2][1], prev_states0[4][i] * states[i+2][4], prev_states0[5][i] * states[i+2][5], prev_states0[6][i] * states[i+2][6], prev_states0[7][i] * states[i+2][7], prev_states0[8][i] * states[i+2][7], prev_states0[9][i] * states[i+2][7]]); + is_substr0[i] <== MultiOR(10)([prev_states0[0][i] * states[i+2][1], prev_states0[1][i] * states[i+2][2], prev_states0[2][i] * states[i+2][2], prev_states0[3][i] * states[i+2][3], prev_states0[4][i] * states[i+2][4], prev_states0[5][i] * states[i+2][5], prev_states0[6][i] * states[i+2][6], prev_states0[7][i] * states[i+2][7], prev_states0[8][i] * states[i+2][7], prev_states0[9][i] * states[i+2][7]]); is_reveal0[i] <== MultiAND(3)([out, is_substr0[i], is_consecutive[i][2]]); reveal0[i] <== in[i+1] * is_reveal0[i]; } diff --git a/packages/circom/tests/circuits/negate1_regex.circom b/packages/circom/tests/circuits/negate1_regex.circom index e54b21f..e5c7572 100644 --- a/packages/circom/tests/circuits/negate1_regex.circom +++ b/packages/circom/tests/circuits/negate1_regex.circom @@ -46,29 +46,52 @@ template Negate1Regex(msg_bytes) { and[1][i].b <== eq[1][i].out; states[i+1][2] <== and[1][i].out; lt[0][i] = LessEqThan(8); - lt[0][i].in[0] <== 194; + lt[0][i].in[0] <== 1; lt[0][i].in[1] <== in[i]; lt[1][i] = LessEqThan(8); lt[1][i].in[0] <== in[i]; - lt[1][i].in[1] <== 223; + lt[1][i].in[1] <== 45; and[2][i] = AND(); and[2][i].a <== lt[0][i].out; and[2][i].b <== lt[1][i].out; - and[3][i] = AND(); - and[3][i].a <== states[i][2]; - and[3][i].b <== and[2][i].out; lt[2][i] = LessEqThan(8); - lt[2][i].in[0] <== 160; + lt[2][i].in[0] <== 47; lt[2][i].in[1] <== in[i]; lt[3][i] = LessEqThan(8); lt[3][i].in[0] <== in[i]; - lt[3][i].in[1] <== 191; + lt[3][i].in[1] <== 96; + and[3][i] = AND(); + and[3][i].a <== lt[2][i].out; + and[3][i].b <== lt[3][i].out; + eq[2][i] = IsEqual(); + eq[2][i].in[0] <== in[i]; + eq[2][i].in[1] <== 123; + eq[3][i] = IsEqual(); + eq[3][i].in[0] <== in[i]; + eq[3][i].in[1] <== 124; + eq[4][i] = IsEqual(); + eq[4][i].in[0] <== in[i]; + eq[4][i].in[1] <== 125; + eq[5][i] = IsEqual(); + eq[5][i].in[0] <== in[i]; + eq[5][i].in[1] <== 126; + eq[6][i] = IsEqual(); + eq[6][i].in[0] <== in[i]; + eq[6][i].in[1] <== 127; and[4][i] = AND(); - and[4][i].a <== lt[2][i].out; - and[4][i].b <== lt[3][i].out; + and[4][i].a <== states[i][2]; + multi_or[0][i] = MultiOR(7); + multi_or[0][i].in[0] <== and[2][i].out; + multi_or[0][i].in[1] <== and[3][i].out; + multi_or[0][i].in[2] <== eq[2][i].out; + multi_or[0][i].in[3] <== eq[3][i].out; + multi_or[0][i].in[4] <== eq[4][i].out; + multi_or[0][i].in[5] <== eq[5][i].out; + multi_or[0][i].in[6] <== eq[6][i].out; + and[4][i].b <== multi_or[0][i].out; and[5][i] = AND(); - and[5][i].a <== states[i][4]; - and[5][i].b <== and[4][i].out; + and[5][i].a <== states[i][3]; + and[5][i].b <== multi_or[0][i].out; lt[4][i] = LessEqThan(8); lt[4][i].in[0] <== 128; lt[4][i].in[1] <== in[i]; @@ -79,318 +102,295 @@ template Negate1Regex(msg_bytes) { and[6][i].a <== lt[4][i].out; and[6][i].b <== lt[5][i].out; and[7][i] = AND(); - and[7][i].a <== states[i][5]; + and[7][i].a <== states[i][4]; and[7][i].b <== and[6][i].out; + 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[7][i].out; + states[i+1][3] <== multi_or[1][i].out; lt[6][i] = LessEqThan(8); - lt[6][i].in[0] <== 128; + lt[6][i].in[0] <== 194; lt[6][i].in[1] <== in[i]; lt[7][i] = LessEqThan(8); lt[7][i].in[0] <== in[i]; - lt[7][i].in[1] <== 159; + lt[7][i].in[1] <== 223; and[8][i] = AND(); and[8][i].a <== lt[6][i].out; and[8][i].b <== lt[7][i].out; and[9][i] = AND(); - and[9][i].a <== states[i][6]; + and[9][i].a <== states[i][2]; and[9][i].b <== and[8][i].out; and[10][i] = AND(); - and[10][i].a <== states[i][10]; - and[10][i].b <== and[2][i].out; - multi_or[0][i] = MultiOR(5); - multi_or[0][i].in[0] <== and[3][i].out; - multi_or[0][i].in[1] <== and[5][i].out; - multi_or[0][i].in[2] <== and[7][i].out; - multi_or[0][i].in[3] <== and[9][i].out; - multi_or[0][i].in[4] <== and[10][i].out; - states[i+1][3] <== multi_or[0][i].out; - eq[2][i] = IsEqual(); - eq[2][i].in[0] <== in[i]; - eq[2][i].in[1] <== 224; + and[10][i].a <== states[i][3]; + and[10][i].b <== and[8][i].out; + lt[8][i] = LessEqThan(8); + lt[8][i].in[0] <== 160; + lt[8][i].in[1] <== in[i]; + lt[9][i] = LessEqThan(8); + lt[9][i].in[0] <== in[i]; + lt[9][i].in[1] <== 191; and[11][i] = AND(); - and[11][i].a <== states[i][2]; - and[11][i].b <== eq[2][i].out; + and[11][i].a <== lt[8][i].out; + and[11][i].b <== lt[9][i].out; and[12][i] = AND(); - and[12][i].a <== states[i][10]; - and[12][i].b <== eq[2][i].out; - multi_or[1][i] = MultiOR(2); - multi_or[1][i].in[0] <== and[11][i].out; - multi_or[1][i].in[1] <== and[12][i].out; - states[i+1][4] <== multi_or[1][i].out; - eq[3][i] = IsEqual(); - eq[3][i].in[0] <== in[i]; - eq[3][i].in[1] <== 225; - eq[4][i] = IsEqual(); - eq[4][i].in[0] <== in[i]; - eq[4][i].in[1] <== 226; - eq[5][i] = IsEqual(); - eq[5][i].in[0] <== in[i]; - eq[5][i].in[1] <== 227; - eq[6][i] = IsEqual(); - eq[6][i].in[0] <== in[i]; - eq[6][i].in[1] <== 228; + and[12][i].a <== states[i][5]; + and[12][i].b <== and[11][i].out; + and[13][i] = AND(); + and[13][i].a <== states[i][6]; + and[13][i].b <== and[6][i].out; + lt[10][i] = LessEqThan(8); + lt[10][i].in[0] <== 128; + lt[10][i].in[1] <== in[i]; + lt[11][i] = LessEqThan(8); + lt[11][i].in[0] <== in[i]; + lt[11][i].in[1] <== 159; + and[14][i] = AND(); + and[14][i].a <== lt[10][i].out; + and[14][i].b <== lt[11][i].out; + and[15][i] = AND(); + and[15][i].a <== states[i][7]; + and[15][i].b <== and[14][i].out; + multi_or[2][i] = MultiOR(5); + multi_or[2][i].in[0] <== and[9][i].out; + multi_or[2][i].in[1] <== and[10][i].out; + multi_or[2][i].in[2] <== and[12][i].out; + multi_or[2][i].in[3] <== and[13][i].out; + multi_or[2][i].in[4] <== and[15][i].out; + states[i+1][4] <== multi_or[2][i].out; eq[7][i] = IsEqual(); eq[7][i].in[0] <== in[i]; - eq[7][i].in[1] <== 229; + eq[7][i].in[1] <== 224; + and[16][i] = AND(); + and[16][i].a <== states[i][2]; + and[16][i].b <== eq[7][i].out; + and[17][i] = AND(); + and[17][i].a <== states[i][3]; + and[17][i].b <== eq[7][i].out; + multi_or[3][i] = MultiOR(2); + multi_or[3][i].in[0] <== and[16][i].out; + multi_or[3][i].in[1] <== and[17][i].out; + states[i+1][5] <== multi_or[3][i].out; eq[8][i] = IsEqual(); eq[8][i].in[0] <== in[i]; - eq[8][i].in[1] <== 230; + eq[8][i].in[1] <== 225; eq[9][i] = IsEqual(); eq[9][i].in[0] <== in[i]; - eq[9][i].in[1] <== 231; + eq[9][i].in[1] <== 226; eq[10][i] = IsEqual(); eq[10][i].in[0] <== in[i]; - eq[10][i].in[1] <== 232; + eq[10][i].in[1] <== 227; eq[11][i] = IsEqual(); eq[11][i].in[0] <== in[i]; - eq[11][i].in[1] <== 233; + eq[11][i].in[1] <== 228; eq[12][i] = IsEqual(); eq[12][i].in[0] <== in[i]; - eq[12][i].in[1] <== 234; + eq[12][i].in[1] <== 229; eq[13][i] = IsEqual(); eq[13][i].in[0] <== in[i]; - eq[13][i].in[1] <== 235; + eq[13][i].in[1] <== 230; eq[14][i] = IsEqual(); eq[14][i].in[0] <== in[i]; - eq[14][i].in[1] <== 236; + eq[14][i].in[1] <== 231; eq[15][i] = IsEqual(); eq[15][i].in[0] <== in[i]; - eq[15][i].in[1] <== 238; + eq[15][i].in[1] <== 232; eq[16][i] = IsEqual(); eq[16][i].in[0] <== in[i]; - eq[16][i].in[1] <== 239; - and[13][i] = AND(); - and[13][i].a <== states[i][2]; - multi_or[2][i] = MultiOR(14); - multi_or[2][i].in[0] <== eq[3][i].out; - multi_or[2][i].in[1] <== eq[4][i].out; - multi_or[2][i].in[2] <== eq[5][i].out; - multi_or[2][i].in[3] <== eq[6][i].out; - multi_or[2][i].in[4] <== eq[7][i].out; - multi_or[2][i].in[5] <== eq[8][i].out; - multi_or[2][i].in[6] <== eq[9][i].out; - multi_or[2][i].in[7] <== eq[10][i].out; - multi_or[2][i].in[8] <== eq[11][i].out; - multi_or[2][i].in[9] <== eq[12][i].out; - multi_or[2][i].in[10] <== eq[13][i].out; - multi_or[2][i].in[11] <== eq[14][i].out; - multi_or[2][i].in[12] <== eq[15][i].out; - multi_or[2][i].in[13] <== eq[16][i].out; - and[13][i].b <== multi_or[2][i].out; - lt[8][i] = LessEqThan(8); - lt[8][i].in[0] <== 144; - lt[8][i].in[1] <== in[i]; - lt[9][i] = LessEqThan(8); - lt[9][i].in[0] <== in[i]; - lt[9][i].in[1] <== 191; - and[14][i] = AND(); - and[14][i].a <== lt[8][i].out; - and[14][i].b <== lt[9][i].out; - and[15][i] = AND(); - and[15][i].a <== states[i][7]; - and[15][i].b <== and[14][i].out; - and[16][i] = AND(); - and[16][i].a <== states[i][8]; - and[16][i].b <== and[6][i].out; + eq[16][i].in[1] <== 233; eq[17][i] = IsEqual(); eq[17][i].in[0] <== in[i]; - eq[17][i].in[1] <== 128; + eq[17][i].in[1] <== 234; eq[18][i] = IsEqual(); eq[18][i].in[0] <== in[i]; - eq[18][i].in[1] <== 129; + eq[18][i].in[1] <== 235; eq[19][i] = IsEqual(); eq[19][i].in[0] <== in[i]; - eq[19][i].in[1] <== 130; + eq[19][i].in[1] <== 236; eq[20][i] = IsEqual(); eq[20][i].in[0] <== in[i]; - eq[20][i].in[1] <== 131; + eq[20][i].in[1] <== 238; eq[21][i] = IsEqual(); eq[21][i].in[0] <== in[i]; - eq[21][i].in[1] <== 132; + eq[21][i].in[1] <== 239; + and[18][i] = AND(); + and[18][i].a <== states[i][2]; + multi_or[4][i] = MultiOR(14); + multi_or[4][i].in[0] <== eq[8][i].out; + multi_or[4][i].in[1] <== eq[9][i].out; + multi_or[4][i].in[2] <== eq[10][i].out; + multi_or[4][i].in[3] <== eq[11][i].out; + multi_or[4][i].in[4] <== eq[12][i].out; + multi_or[4][i].in[5] <== eq[13][i].out; + multi_or[4][i].in[6] <== eq[14][i].out; + multi_or[4][i].in[7] <== eq[15][i].out; + multi_or[4][i].in[8] <== eq[16][i].out; + multi_or[4][i].in[9] <== eq[17][i].out; + multi_or[4][i].in[10] <== eq[18][i].out; + multi_or[4][i].in[11] <== eq[19][i].out; + multi_or[4][i].in[12] <== eq[20][i].out; + multi_or[4][i].in[13] <== eq[21][i].out; + and[18][i].b <== multi_or[4][i].out; + and[19][i] = AND(); + and[19][i].a <== states[i][3]; + and[19][i].b <== multi_or[4][i].out; + lt[12][i] = LessEqThan(8); + lt[12][i].in[0] <== 144; + lt[12][i].in[1] <== in[i]; + lt[13][i] = LessEqThan(8); + lt[13][i].in[0] <== in[i]; + lt[13][i].in[1] <== 191; + and[20][i] = AND(); + and[20][i].a <== lt[12][i].out; + and[20][i].b <== lt[13][i].out; + and[21][i] = AND(); + and[21][i].a <== states[i][8]; + and[21][i].b <== and[20][i].out; + and[22][i] = AND(); + and[22][i].a <== states[i][9]; + and[22][i].b <== and[6][i].out; eq[22][i] = IsEqual(); eq[22][i].in[0] <== in[i]; - eq[22][i].in[1] <== 133; + eq[22][i].in[1] <== 128; eq[23][i] = IsEqual(); eq[23][i].in[0] <== in[i]; - eq[23][i].in[1] <== 134; + eq[23][i].in[1] <== 129; eq[24][i] = IsEqual(); eq[24][i].in[0] <== in[i]; - eq[24][i].in[1] <== 135; + eq[24][i].in[1] <== 130; eq[25][i] = IsEqual(); eq[25][i].in[0] <== in[i]; - eq[25][i].in[1] <== 136; + eq[25][i].in[1] <== 131; eq[26][i] = IsEqual(); eq[26][i].in[0] <== in[i]; - eq[26][i].in[1] <== 137; + eq[26][i].in[1] <== 132; eq[27][i] = IsEqual(); eq[27][i].in[0] <== in[i]; - eq[27][i].in[1] <== 138; + eq[27][i].in[1] <== 133; eq[28][i] = IsEqual(); eq[28][i].in[0] <== in[i]; - eq[28][i].in[1] <== 139; + eq[28][i].in[1] <== 134; eq[29][i] = IsEqual(); eq[29][i].in[0] <== in[i]; - eq[29][i].in[1] <== 140; + eq[29][i].in[1] <== 135; eq[30][i] = IsEqual(); eq[30][i].in[0] <== in[i]; - eq[30][i].in[1] <== 141; + eq[30][i].in[1] <== 136; eq[31][i] = IsEqual(); eq[31][i].in[0] <== in[i]; - eq[31][i].in[1] <== 142; + eq[31][i].in[1] <== 137; eq[32][i] = IsEqual(); eq[32][i].in[0] <== in[i]; - eq[32][i].in[1] <== 143; - and[17][i] = AND(); - and[17][i].a <== states[i][9]; - multi_or[3][i] = MultiOR(16); - multi_or[3][i].in[0] <== eq[17][i].out; - multi_or[3][i].in[1] <== eq[18][i].out; - multi_or[3][i].in[2] <== eq[19][i].out; - multi_or[3][i].in[3] <== eq[20][i].out; - multi_or[3][i].in[4] <== eq[21][i].out; - multi_or[3][i].in[5] <== eq[22][i].out; - multi_or[3][i].in[6] <== eq[23][i].out; - multi_or[3][i].in[7] <== eq[24][i].out; - multi_or[3][i].in[8] <== eq[25][i].out; - multi_or[3][i].in[9] <== eq[26][i].out; - multi_or[3][i].in[10] <== eq[27][i].out; - multi_or[3][i].in[11] <== eq[28][i].out; - multi_or[3][i].in[12] <== eq[29][i].out; - multi_or[3][i].in[13] <== eq[30][i].out; - multi_or[3][i].in[14] <== eq[31][i].out; - multi_or[3][i].in[15] <== eq[32][i].out; - and[17][i].b <== multi_or[3][i].out; - and[18][i] = AND(); - and[18][i].a <== states[i][10]; - and[18][i].b <== multi_or[2][i].out; - multi_or[4][i] = MultiOR(5); - multi_or[4][i].in[0] <== and[13][i].out; - multi_or[4][i].in[1] <== and[15][i].out; - multi_or[4][i].in[2] <== and[16][i].out; - multi_or[4][i].in[3] <== and[17][i].out; - multi_or[4][i].in[4] <== and[18][i].out; - states[i+1][5] <== multi_or[4][i].out; + eq[32][i].in[1] <== 138; eq[33][i] = IsEqual(); eq[33][i].in[0] <== in[i]; - eq[33][i].in[1] <== 237; - and[19][i] = AND(); - and[19][i].a <== states[i][2]; - and[19][i].b <== eq[33][i].out; - and[20][i] = AND(); - and[20][i].a <== states[i][10]; - and[20][i].b <== eq[33][i].out; - multi_or[5][i] = MultiOR(2); - multi_or[5][i].in[0] <== and[19][i].out; - multi_or[5][i].in[1] <== and[20][i].out; - states[i+1][6] <== multi_or[5][i].out; + eq[33][i].in[1] <== 139; eq[34][i] = IsEqual(); eq[34][i].in[0] <== in[i]; - eq[34][i].in[1] <== 240; - and[21][i] = AND(); - and[21][i].a <== states[i][2]; - and[21][i].b <== eq[34][i].out; - and[22][i] = AND(); - and[22][i].a <== states[i][10]; - and[22][i].b <== eq[34][i].out; - multi_or[6][i] = MultiOR(2); - multi_or[6][i].in[0] <== and[21][i].out; - multi_or[6][i].in[1] <== and[22][i].out; - states[i+1][7] <== multi_or[6][i].out; + eq[34][i].in[1] <== 140; eq[35][i] = IsEqual(); eq[35][i].in[0] <== in[i]; - eq[35][i].in[1] <== 241; + eq[35][i].in[1] <== 141; eq[36][i] = IsEqual(); eq[36][i].in[0] <== in[i]; - eq[36][i].in[1] <== 242; + eq[36][i].in[1] <== 142; eq[37][i] = IsEqual(); eq[37][i].in[0] <== in[i]; - eq[37][i].in[1] <== 243; + eq[37][i].in[1] <== 143; and[23][i] = AND(); - and[23][i].a <== states[i][2]; - multi_or[7][i] = MultiOR(3); - multi_or[7][i].in[0] <== eq[35][i].out; - multi_or[7][i].in[1] <== eq[36][i].out; - multi_or[7][i].in[2] <== eq[37][i].out; - and[23][i].b <== multi_or[7][i].out; - and[24][i] = AND(); - and[24][i].a <== states[i][10]; - and[24][i].b <== multi_or[7][i].out; - multi_or[8][i] = MultiOR(2); - multi_or[8][i].in[0] <== and[23][i].out; - multi_or[8][i].in[1] <== and[24][i].out; - states[i+1][8] <== multi_or[8][i].out; + and[23][i].a <== states[i][10]; + multi_or[5][i] = MultiOR(16); + multi_or[5][i].in[0] <== eq[22][i].out; + multi_or[5][i].in[1] <== eq[23][i].out; + multi_or[5][i].in[2] <== eq[24][i].out; + multi_or[5][i].in[3] <== eq[25][i].out; + multi_or[5][i].in[4] <== eq[26][i].out; + multi_or[5][i].in[5] <== eq[27][i].out; + multi_or[5][i].in[6] <== eq[28][i].out; + multi_or[5][i].in[7] <== eq[29][i].out; + multi_or[5][i].in[8] <== eq[30][i].out; + multi_or[5][i].in[9] <== eq[31][i].out; + multi_or[5][i].in[10] <== eq[32][i].out; + multi_or[5][i].in[11] <== eq[33][i].out; + multi_or[5][i].in[12] <== eq[34][i].out; + multi_or[5][i].in[13] <== eq[35][i].out; + multi_or[5][i].in[14] <== eq[36][i].out; + multi_or[5][i].in[15] <== eq[37][i].out; + and[23][i].b <== multi_or[5][i].out; + multi_or[6][i] = MultiOR(5); + multi_or[6][i].in[0] <== and[18][i].out; + multi_or[6][i].in[1] <== and[19][i].out; + multi_or[6][i].in[2] <== and[21][i].out; + multi_or[6][i].in[3] <== and[22][i].out; + multi_or[6][i].in[4] <== and[23][i].out; + states[i+1][6] <== multi_or[6][i].out; eq[38][i] = IsEqual(); eq[38][i].in[0] <== in[i]; - eq[38][i].in[1] <== 244; + eq[38][i].in[1] <== 237; + and[24][i] = AND(); + and[24][i].a <== states[i][2]; + and[24][i].b <== eq[38][i].out; and[25][i] = AND(); - and[25][i].a <== states[i][2]; + and[25][i].a <== states[i][3]; and[25][i].b <== eq[38][i].out; - and[26][i] = AND(); - and[26][i].a <== states[i][10]; - and[26][i].b <== eq[38][i].out; - multi_or[9][i] = MultiOR(2); - multi_or[9][i].in[0] <== and[25][i].out; - multi_or[9][i].in[1] <== and[26][i].out; - states[i+1][9] <== multi_or[9][i].out; - lt[10][i] = LessEqThan(8); - lt[10][i].in[0] <== 1; - lt[10][i].in[1] <== in[i]; - lt[11][i] = LessEqThan(8); - lt[11][i].in[0] <== in[i]; - lt[11][i].in[1] <== 45; - and[27][i] = AND(); - and[27][i].a <== lt[10][i].out; - and[27][i].b <== lt[11][i].out; - lt[12][i] = LessEqThan(8); - lt[12][i].in[0] <== 47; - lt[12][i].in[1] <== in[i]; - lt[13][i] = LessEqThan(8); - lt[13][i].in[0] <== in[i]; - lt[13][i].in[1] <== 96; - and[28][i] = AND(); - and[28][i].a <== lt[12][i].out; - and[28][i].b <== lt[13][i].out; + multi_or[7][i] = MultiOR(2); + multi_or[7][i].in[0] <== and[24][i].out; + multi_or[7][i].in[1] <== and[25][i].out; + states[i+1][7] <== multi_or[7][i].out; eq[39][i] = IsEqual(); eq[39][i].in[0] <== in[i]; - eq[39][i].in[1] <== 123; + eq[39][i].in[1] <== 240; + and[26][i] = AND(); + and[26][i].a <== states[i][2]; + and[26][i].b <== eq[39][i].out; + and[27][i] = AND(); + and[27][i].a <== states[i][3]; + and[27][i].b <== eq[39][i].out; + multi_or[8][i] = MultiOR(2); + multi_or[8][i].in[0] <== and[26][i].out; + multi_or[8][i].in[1] <== and[27][i].out; + states[i+1][8] <== multi_or[8][i].out; eq[40][i] = IsEqual(); eq[40][i].in[0] <== in[i]; - eq[40][i].in[1] <== 124; + eq[40][i].in[1] <== 241; eq[41][i] = IsEqual(); eq[41][i].in[0] <== in[i]; - eq[41][i].in[1] <== 125; + eq[41][i].in[1] <== 242; eq[42][i] = IsEqual(); eq[42][i].in[0] <== in[i]; - eq[42][i].in[1] <== 126; + eq[42][i].in[1] <== 243; + and[28][i] = AND(); + and[28][i].a <== states[i][2]; + multi_or[9][i] = MultiOR(3); + multi_or[9][i].in[0] <== eq[40][i].out; + multi_or[9][i].in[1] <== eq[41][i].out; + multi_or[9][i].in[2] <== eq[42][i].out; + and[28][i].b <== multi_or[9][i].out; + and[29][i] = AND(); + and[29][i].a <== states[i][3]; + and[29][i].b <== multi_or[9][i].out; + multi_or[10][i] = MultiOR(2); + multi_or[10][i].in[0] <== and[28][i].out; + multi_or[10][i].in[1] <== and[29][i].out; + states[i+1][9] <== multi_or[10][i].out; eq[43][i] = IsEqual(); eq[43][i].in[0] <== in[i]; - eq[43][i].in[1] <== 127; - and[29][i] = AND(); - and[29][i].a <== states[i][2]; - multi_or[10][i] = MultiOR(7); - multi_or[10][i].in[0] <== and[27][i].out; - multi_or[10][i].in[1] <== and[28][i].out; - multi_or[10][i].in[2] <== eq[39][i].out; - multi_or[10][i].in[3] <== eq[40][i].out; - multi_or[10][i].in[4] <== eq[41][i].out; - multi_or[10][i].in[5] <== eq[42][i].out; - multi_or[10][i].in[6] <== eq[43][i].out; - and[29][i].b <== multi_or[10][i].out; + eq[43][i].in[1] <== 244; and[30][i] = AND(); - and[30][i].a <== states[i][3]; - and[30][i].b <== and[6][i].out; + and[30][i].a <== states[i][2]; + and[30][i].b <== eq[43][i].out; and[31][i] = AND(); - and[31][i].a <== states[i][10]; - and[31][i].b <== multi_or[10][i].out; - multi_or[11][i] = MultiOR(3); - multi_or[11][i].in[0] <== and[29][i].out; - multi_or[11][i].in[1] <== and[30][i].out; - multi_or[11][i].in[2] <== and[31][i].out; + and[31][i].a <== states[i][3]; + and[31][i].b <== eq[43][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; states[i+1][10] <== multi_or[11][i].out; eq[44][i] = IsEqual(); eq[44][i].in[0] <== in[i]; eq[44][i].in[1] <== 46; and[32][i] = AND(); - and[32][i].a <== states[i][10]; + and[32][i].a <== states[i][3]; and[32][i].b <== eq[44][i].out; states[i+1][11] <== and[32][i].out; from_zero_enabled[i] <== MultiNOR(11)([states_tmp[i+1][1], states[i+1][2], states[i+1][3], states[i+1][4], states[i+1][5], states[i+1][6], states[i+1][7], states[i+1][8], states[i+1][9], states[i+1][10], states[i+1][11]]); @@ -420,13 +420,13 @@ template Negate1Regex(msg_bytes) { is_consecutive[msg_bytes-1-i][1] <== state_changed[msg_bytes-i].out * is_consecutive[msg_bytes-1-i][0]; is_consecutive[msg_bytes-1-i][2] <== ORAnd()([(1 - from_zero_enabled[msg_bytes-i+1]), states[num_bytes-i][11], is_consecutive[msg_bytes-1-i][1]]); } - // substrings calculated: [{(2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (3, 10), (4, 3), (5, 3), (6, 3), (7, 5), (8, 5), (9, 5), (10, 3), (10, 4), (10, 5), (10, 6), (10, 7), (10, 8), (10, 9), (10, 10)}] + // substrings calculated: [{(2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (4, 3), (5, 4), (6, 4), (7, 4), (8, 6), (9, 6), (10, 6)}] signal prev_states0[23][msg_bytes]; signal is_substr0[msg_bytes]; signal is_reveal0[msg_bytes]; signal output reveal0[msg_bytes]; for (var i = 0; i < msg_bytes; i++) { - // the 0-th substring transitions: [(2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (3, 10), (4, 3), (5, 3), (6, 3), (7, 5), (8, 5), (9, 5), (10, 3), (10, 4), (10, 5), (10, 6), (10, 7), (10, 8), (10, 9), (10, 10)] + // the 0-th substring transitions: [(2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (4, 3), (5, 4), (6, 4), (7, 4), (8, 6), (9, 6), (10, 6)] prev_states0[0][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][2]; prev_states0[1][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][2]; prev_states0[2][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][2]; @@ -436,21 +436,21 @@ template Negate1Regex(msg_bytes) { prev_states0[6][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][2]; prev_states0[7][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][2]; prev_states0[8][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][3]; - prev_states0[9][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][4]; - prev_states0[10][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][5]; - prev_states0[11][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][6]; - prev_states0[12][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][7]; - prev_states0[13][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][8]; - prev_states0[14][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][9]; - prev_states0[15][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][10]; - prev_states0[16][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][10]; - prev_states0[17][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][10]; - prev_states0[18][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][10]; - prev_states0[19][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][10]; - prev_states0[20][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][10]; - prev_states0[21][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][10]; + prev_states0[9][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][3]; + prev_states0[10][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][3]; + prev_states0[11][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][3]; + prev_states0[12][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][3]; + prev_states0[13][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][3]; + prev_states0[14][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][3]; + prev_states0[15][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][3]; + prev_states0[16][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][4]; + prev_states0[17][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][5]; + prev_states0[18][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][6]; + prev_states0[19][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][7]; + prev_states0[20][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][8]; + prev_states0[21][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][9]; prev_states0[22][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][10]; - is_substr0[i] <== MultiOR(23)([prev_states0[0][i] * states[i+2][3], prev_states0[1][i] * states[i+2][4], prev_states0[2][i] * states[i+2][5], prev_states0[3][i] * states[i+2][6], prev_states0[4][i] * states[i+2][7], prev_states0[5][i] * states[i+2][8], prev_states0[6][i] * states[i+2][9], prev_states0[7][i] * states[i+2][10], prev_states0[8][i] * states[i+2][10], prev_states0[9][i] * states[i+2][3], prev_states0[10][i] * states[i+2][3], prev_states0[11][i] * states[i+2][3], prev_states0[12][i] * states[i+2][5], prev_states0[13][i] * states[i+2][5], prev_states0[14][i] * states[i+2][5], prev_states0[15][i] * states[i+2][3], prev_states0[16][i] * states[i+2][4], prev_states0[17][i] * states[i+2][5], prev_states0[18][i] * states[i+2][6], prev_states0[19][i] * states[i+2][7], prev_states0[20][i] * states[i+2][8], prev_states0[21][i] * states[i+2][9], prev_states0[22][i] * states[i+2][10]]); + is_substr0[i] <== MultiOR(23)([prev_states0[0][i] * states[i+2][3], prev_states0[1][i] * states[i+2][4], prev_states0[2][i] * states[i+2][5], prev_states0[3][i] * states[i+2][6], prev_states0[4][i] * states[i+2][7], prev_states0[5][i] * states[i+2][8], prev_states0[6][i] * states[i+2][9], prev_states0[7][i] * states[i+2][10], prev_states0[8][i] * states[i+2][3], prev_states0[9][i] * states[i+2][4], prev_states0[10][i] * states[i+2][5], prev_states0[11][i] * states[i+2][6], prev_states0[12][i] * states[i+2][7], prev_states0[13][i] * states[i+2][8], prev_states0[14][i] * states[i+2][9], prev_states0[15][i] * states[i+2][10], prev_states0[16][i] * states[i+2][3], prev_states0[17][i] * states[i+2][4], prev_states0[18][i] * states[i+2][4], prev_states0[19][i] * states[i+2][4], prev_states0[20][i] * states[i+2][6], prev_states0[21][i] * states[i+2][6], prev_states0[22][i] * states[i+2][6]]); is_reveal0[i] <== MultiAND(3)([out, is_substr0[i], is_consecutive[i][2]]); reveal0[i] <== in[i+1] * is_reveal0[i]; } diff --git a/packages/circom/tests/circuits/negate2_regex.circom b/packages/circom/tests/circuits/negate2_regex.circom index ecfefec..1ed57f6 100644 --- a/packages/circom/tests/circuits/negate2_regex.circom +++ b/packages/circom/tests/circuits/negate2_regex.circom @@ -32,65 +32,93 @@ template Negate2Regex(msg_bytes) { state_changed[i] = MultiOR(8); states[i][0] <== 1; lt[0][i] = LessEqThan(8); - lt[0][i].in[0] <== 194; + lt[0][i].in[0] <== 1; lt[0][i].in[1] <== in[i]; lt[1][i] = LessEqThan(8); lt[1][i].in[0] <== in[i]; - lt[1][i].in[1] <== 223; + lt[1][i].in[1] <== 96; and[0][i] = AND(); and[0][i].a <== lt[0][i].out; and[0][i].b <== lt[1][i].out; - and[1][i] = AND(); - and[1][i].a <== states[i][0]; - and[1][i].b <== and[0][i].out; lt[2][i] = LessEqThan(8); - lt[2][i].in[0] <== 160; + lt[2][i].in[0] <== 99; lt[2][i].in[1] <== in[i]; lt[3][i] = LessEqThan(8); lt[3][i].in[0] <== in[i]; - lt[3][i].in[1] <== 191; + lt[3][i].in[1] <== 127; + and[1][i] = AND(); + and[1][i].a <== lt[2][i].out; + and[1][i].b <== lt[3][i].out; and[2][i] = AND(); - and[2][i].a <== lt[2][i].out; - and[2][i].b <== lt[3][i].out; - and[3][i] = AND(); - and[3][i].a <== states[i][2]; - and[3][i].b <== and[2][i].out; + and[2][i].a <== states[i][0]; + multi_or[0][i] = MultiOR(2); + multi_or[0][i].in[0] <== and[0][i].out; + multi_or[0][i].in[1] <== and[1][i].out; + and[2][i].b <== multi_or[0][i].out; lt[4][i] = LessEqThan(8); lt[4][i].in[0] <== 128; lt[4][i].in[1] <== in[i]; lt[5][i] = LessEqThan(8); lt[5][i].in[0] <== in[i]; lt[5][i].in[1] <== 191; + and[3][i] = AND(); + and[3][i].a <== lt[4][i].out; + and[3][i].b <== lt[5][i].out; 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][3]; - and[5][i].b <== and[4][i].out; + and[4][i].a <== states[i][2]; + and[4][i].b <== and[3][i].out; + states_tmp[i+1][1] <== and[4][i].out; lt[6][i] = LessEqThan(8); - lt[6][i].in[0] <== 128; + lt[6][i].in[0] <== 194; lt[6][i].in[1] <== in[i]; lt[7][i] = LessEqThan(8); lt[7][i].in[0] <== in[i]; - lt[7][i].in[1] <== 159; + lt[7][i].in[1] <== 223; + and[5][i] = AND(); + and[5][i].a <== lt[6][i].out; + and[5][i].b <== lt[7][i].out; and[6][i] = AND(); - and[6][i].a <== lt[6][i].out; - and[6][i].b <== lt[7][i].out; + and[6][i].a <== states[i][0]; + and[6][i].b <== and[5][i].out; + lt[8][i] = LessEqThan(8); + lt[8][i].in[0] <== 160; + lt[8][i].in[1] <== in[i]; + lt[9][i] = LessEqThan(8); + lt[9][i].in[0] <== in[i]; + lt[9][i].in[1] <== 191; and[7][i] = AND(); - and[7][i].a <== states[i][4]; - and[7][i].b <== and[6][i].out; - multi_or[0][i] = MultiOR(3); - multi_or[0][i].in[0] <== and[3][i].out; - multi_or[0][i].in[1] <== and[5][i].out; - multi_or[0][i].in[2] <== and[7][i].out; - states_tmp[i+1][1] <== multi_or[0][i].out; + and[7][i].a <== lt[8][i].out; + and[7][i].b <== lt[9][i].out; + and[8][i] = AND(); + and[8][i].a <== states[i][3]; + and[8][i].b <== and[7][i].out; + and[9][i] = AND(); + and[9][i].a <== states[i][4]; + and[9][i].b <== and[3][i].out; + lt[10][i] = LessEqThan(8); + lt[10][i].in[0] <== 128; + lt[10][i].in[1] <== in[i]; + lt[11][i] = LessEqThan(8); + lt[11][i].in[0] <== in[i]; + lt[11][i].in[1] <== 159; + and[10][i] = AND(); + and[10][i].a <== lt[10][i].out; + and[10][i].b <== lt[11][i].out; + and[11][i] = AND(); + and[11][i].a <== states[i][5]; + and[11][i].b <== and[10][i].out; + multi_or[1][i] = MultiOR(3); + multi_or[1][i].in[0] <== and[8][i].out; + multi_or[1][i].in[1] <== and[9][i].out; + multi_or[1][i].in[2] <== and[11][i].out; + states_tmp[i+1][2] <== multi_or[1][i].out; eq[0][i] = IsEqual(); eq[0][i].in[0] <== in[i]; eq[0][i].in[1] <== 224; - and[8][i] = AND(); - and[8][i].a <== states[i][0]; - and[8][i].b <== eq[0][i].out; - states_tmp[i+1][2] <== 0; + and[12][i] = AND(); + and[12][i].a <== states[i][0]; + and[12][i].b <== eq[0][i].out; + states_tmp[i+1][3] <== 0; eq[1][i] = IsEqual(); eq[1][i].in[0] <== in[i]; eq[1][i].in[1] <== 225; @@ -133,39 +161,39 @@ template Negate2Regex(msg_bytes) { eq[14][i] = IsEqual(); eq[14][i].in[0] <== in[i]; eq[14][i].in[1] <== 239; - and[9][i] = AND(); - and[9][i].a <== states[i][0]; - multi_or[1][i] = MultiOR(14); - multi_or[1][i].in[0] <== eq[1][i].out; - multi_or[1][i].in[1] <== eq[2][i].out; - multi_or[1][i].in[2] <== eq[3][i].out; - multi_or[1][i].in[3] <== eq[4][i].out; - multi_or[1][i].in[4] <== eq[5][i].out; - multi_or[1][i].in[5] <== eq[6][i].out; - multi_or[1][i].in[6] <== eq[7][i].out; - multi_or[1][i].in[7] <== eq[8][i].out; - multi_or[1][i].in[8] <== eq[9][i].out; - multi_or[1][i].in[9] <== eq[10][i].out; - multi_or[1][i].in[10] <== eq[11][i].out; - multi_or[1][i].in[11] <== eq[12][i].out; - multi_or[1][i].in[12] <== eq[13][i].out; - multi_or[1][i].in[13] <== eq[14][i].out; - and[9][i].b <== multi_or[1][i].out; - lt[8][i] = LessEqThan(8); - lt[8][i].in[0] <== 144; - lt[8][i].in[1] <== in[i]; - lt[9][i] = LessEqThan(8); - lt[9][i].in[0] <== in[i]; - lt[9][i].in[1] <== 191; - and[10][i] = AND(); - and[10][i].a <== lt[8][i].out; - and[10][i].b <== lt[9][i].out; - and[11][i] = AND(); - and[11][i].a <== states[i][5]; - and[11][i].b <== and[10][i].out; - and[12][i] = AND(); - and[12][i].a <== states[i][6]; - and[12][i].b <== and[4][i].out; + and[13][i] = AND(); + and[13][i].a <== states[i][0]; + multi_or[2][i] = MultiOR(14); + multi_or[2][i].in[0] <== eq[1][i].out; + multi_or[2][i].in[1] <== eq[2][i].out; + multi_or[2][i].in[2] <== eq[3][i].out; + multi_or[2][i].in[3] <== eq[4][i].out; + multi_or[2][i].in[4] <== eq[5][i].out; + multi_or[2][i].in[5] <== eq[6][i].out; + multi_or[2][i].in[6] <== eq[7][i].out; + multi_or[2][i].in[7] <== eq[8][i].out; + multi_or[2][i].in[8] <== eq[9][i].out; + multi_or[2][i].in[9] <== eq[10][i].out; + multi_or[2][i].in[10] <== eq[11][i].out; + multi_or[2][i].in[11] <== eq[12][i].out; + multi_or[2][i].in[12] <== eq[13][i].out; + multi_or[2][i].in[13] <== eq[14][i].out; + and[13][i].b <== multi_or[2][i].out; + lt[12][i] = LessEqThan(8); + lt[12][i].in[0] <== 144; + lt[12][i].in[1] <== in[i]; + lt[13][i] = LessEqThan(8); + lt[13][i].in[0] <== in[i]; + lt[13][i].in[1] <== 191; + and[14][i] = AND(); + and[14][i].a <== lt[12][i].out; + and[14][i].b <== lt[13][i].out; + and[15][i] = AND(); + and[15][i].a <== states[i][6]; + and[15][i].b <== and[14][i].out; + and[16][i] = AND(); + and[16][i].a <== states[i][7]; + and[16][i].b <== and[3][i].out; eq[15][i] = IsEqual(); eq[15][i].in[0] <== in[i]; eq[15][i].in[1] <== 128; @@ -214,45 +242,45 @@ template Negate2Regex(msg_bytes) { eq[30][i] = IsEqual(); eq[30][i].in[0] <== in[i]; eq[30][i].in[1] <== 143; - and[13][i] = AND(); - and[13][i].a <== states[i][7]; - multi_or[2][i] = MultiOR(16); - multi_or[2][i].in[0] <== eq[15][i].out; - multi_or[2][i].in[1] <== eq[16][i].out; - multi_or[2][i].in[2] <== eq[17][i].out; - multi_or[2][i].in[3] <== eq[18][i].out; - multi_or[2][i].in[4] <== eq[19][i].out; - multi_or[2][i].in[5] <== eq[20][i].out; - multi_or[2][i].in[6] <== eq[21][i].out; - multi_or[2][i].in[7] <== eq[22][i].out; - multi_or[2][i].in[8] <== eq[23][i].out; - multi_or[2][i].in[9] <== eq[24][i].out; - multi_or[2][i].in[10] <== eq[25][i].out; - multi_or[2][i].in[11] <== eq[26][i].out; - multi_or[2][i].in[12] <== eq[27][i].out; - multi_or[2][i].in[13] <== eq[28][i].out; - multi_or[2][i].in[14] <== eq[29][i].out; - multi_or[2][i].in[15] <== eq[30][i].out; - and[13][i].b <== multi_or[2][i].out; - 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[2] <== and[13][i].out; - states_tmp[i+1][3] <== multi_or[3][i].out; + and[17][i] = AND(); + and[17][i].a <== states[i][8]; + multi_or[3][i] = MultiOR(16); + multi_or[3][i].in[0] <== eq[15][i].out; + multi_or[3][i].in[1] <== eq[16][i].out; + multi_or[3][i].in[2] <== eq[17][i].out; + multi_or[3][i].in[3] <== eq[18][i].out; + multi_or[3][i].in[4] <== eq[19][i].out; + multi_or[3][i].in[5] <== eq[20][i].out; + multi_or[3][i].in[6] <== eq[21][i].out; + multi_or[3][i].in[7] <== eq[22][i].out; + multi_or[3][i].in[8] <== eq[23][i].out; + multi_or[3][i].in[9] <== eq[24][i].out; + multi_or[3][i].in[10] <== eq[25][i].out; + multi_or[3][i].in[11] <== eq[26][i].out; + multi_or[3][i].in[12] <== eq[27][i].out; + multi_or[3][i].in[13] <== eq[28][i].out; + multi_or[3][i].in[14] <== eq[29][i].out; + multi_or[3][i].in[15] <== eq[30][i].out; + and[17][i].b <== multi_or[3][i].out; + multi_or[4][i] = MultiOR(3); + multi_or[4][i].in[0] <== and[15][i].out; + multi_or[4][i].in[1] <== and[16][i].out; + multi_or[4][i].in[2] <== and[17][i].out; + states_tmp[i+1][4] <== multi_or[4][i].out; eq[31][i] = IsEqual(); eq[31][i].in[0] <== in[i]; eq[31][i].in[1] <== 237; - and[14][i] = AND(); - and[14][i].a <== states[i][0]; - and[14][i].b <== eq[31][i].out; - states_tmp[i+1][4] <== 0; + and[18][i] = AND(); + and[18][i].a <== states[i][0]; + and[18][i].b <== eq[31][i].out; + states_tmp[i+1][5] <== 0; eq[32][i] = IsEqual(); eq[32][i].in[0] <== in[i]; eq[32][i].in[1] <== 240; - and[15][i] = AND(); - and[15][i].a <== states[i][0]; - and[15][i].b <== eq[32][i].out; - states_tmp[i+1][5] <== 0; + and[19][i] = AND(); + and[19][i].a <== states[i][0]; + and[19][i].b <== eq[32][i].out; + states_tmp[i+1][6] <== 0; eq[33][i] = IsEqual(); eq[33][i].in[0] <== in[i]; eq[33][i].in[1] <== 241; @@ -262,58 +290,30 @@ template Negate2Regex(msg_bytes) { eq[35][i] = IsEqual(); eq[35][i].in[0] <== in[i]; eq[35][i].in[1] <== 243; - and[16][i] = AND(); - and[16][i].a <== states[i][0]; - multi_or[4][i] = MultiOR(3); - multi_or[4][i].in[0] <== eq[33][i].out; - multi_or[4][i].in[1] <== eq[34][i].out; - multi_or[4][i].in[2] <== eq[35][i].out; - and[16][i].b <== multi_or[4][i].out; - states_tmp[i+1][6] <== 0; - eq[36][i] = IsEqual(); - eq[36][i].in[0] <== in[i]; - eq[36][i].in[1] <== 244; - and[17][i] = AND(); - and[17][i].a <== states[i][0]; - and[17][i].b <== eq[36][i].out; - states_tmp[i+1][7] <== 0; - lt[10][i] = LessEqThan(8); - lt[10][i].in[0] <== 1; - lt[10][i].in[1] <== in[i]; - lt[11][i] = LessEqThan(8); - lt[11][i].in[0] <== in[i]; - lt[11][i].in[1] <== 96; - and[18][i] = AND(); - and[18][i].a <== lt[10][i].out; - and[18][i].b <== lt[11][i].out; - lt[12][i] = LessEqThan(8); - lt[12][i].in[0] <== 99; - lt[12][i].in[1] <== in[i]; - lt[13][i] = LessEqThan(8); - lt[13][i].in[0] <== in[i]; - lt[13][i].in[1] <== 127; - and[19][i] = AND(); - and[19][i].a <== lt[12][i].out; - and[19][i].b <== lt[13][i].out; and[20][i] = AND(); and[20][i].a <== states[i][0]; - multi_or[5][i] = MultiOR(2); - multi_or[5][i].in[0] <== and[18][i].out; - multi_or[5][i].in[1] <== and[19][i].out; + multi_or[5][i] = MultiOR(3); + multi_or[5][i].in[0] <== eq[33][i].out; + multi_or[5][i].in[1] <== eq[34][i].out; + multi_or[5][i].in[2] <== eq[35][i].out; and[20][i].b <== multi_or[5][i].out; + states_tmp[i+1][7] <== 0; + eq[36][i] = IsEqual(); + eq[36][i].in[0] <== in[i]; + eq[36][i].in[1] <== 244; and[21][i] = AND(); - and[21][i].a <== states[i][1]; - and[21][i].b <== and[4][i].out; - states_tmp[i+1][8] <== and[21][i].out; + and[21][i].a <== states[i][0]; + and[21][i].b <== eq[36][i].out; + states_tmp[i+1][8] <== 0; from_zero_enabled[i] <== MultiNOR(8)([states_tmp[i+1][1], states_tmp[i+1][2], states_tmp[i+1][3], states_tmp[i+1][4], states_tmp[i+1][5], states_tmp[i+1][6], states_tmp[i+1][7], states_tmp[i+1][8]]); - states[i+1][1] <== MultiOR(2)([states_tmp[i+1][1], from_zero_enabled[i] * and[1][i].out]); - states[i+1][2] <== MultiOR(2)([states_tmp[i+1][2], from_zero_enabled[i] * and[8][i].out]); - states[i+1][3] <== MultiOR(2)([states_tmp[i+1][3], from_zero_enabled[i] * and[9][i].out]); - states[i+1][4] <== MultiOR(2)([states_tmp[i+1][4], from_zero_enabled[i] * and[14][i].out]); - states[i+1][5] <== MultiOR(2)([states_tmp[i+1][5], from_zero_enabled[i] * and[15][i].out]); - states[i+1][6] <== MultiOR(2)([states_tmp[i+1][6], from_zero_enabled[i] * and[16][i].out]); - states[i+1][7] <== MultiOR(2)([states_tmp[i+1][7], from_zero_enabled[i] * and[17][i].out]); - states[i+1][8] <== MultiOR(2)([states_tmp[i+1][8], from_zero_enabled[i] * and[20][i].out]); + states[i+1][1] <== MultiOR(2)([states_tmp[i+1][1], from_zero_enabled[i] * and[2][i].out]); + states[i+1][2] <== MultiOR(2)([states_tmp[i+1][2], from_zero_enabled[i] * and[6][i].out]); + states[i+1][3] <== MultiOR(2)([states_tmp[i+1][3], from_zero_enabled[i] * and[12][i].out]); + states[i+1][4] <== MultiOR(2)([states_tmp[i+1][4], from_zero_enabled[i] * and[13][i].out]); + states[i+1][5] <== MultiOR(2)([states_tmp[i+1][5], from_zero_enabled[i] * and[18][i].out]); + states[i+1][6] <== MultiOR(2)([states_tmp[i+1][6], from_zero_enabled[i] * and[19][i].out]); + states[i+1][7] <== MultiOR(2)([states_tmp[i+1][7], from_zero_enabled[i] * and[20][i].out]); + states[i+1][8] <== MultiOR(2)([states_tmp[i+1][8], from_zero_enabled[i] * and[21][i].out]); state_changed[i].in[0] <== states[i+1][1]; state_changed[i].in[1] <== states[i+1][2]; state_changed[i].in[2] <== states[i+1][3]; @@ -326,23 +326,23 @@ template Negate2Regex(msg_bytes) { component is_accepted = MultiOR(num_bytes+1); for (var i = 0; i <= num_bytes; i++) { - is_accepted.in[i] <== states[i][8]; + is_accepted.in[i] <== states[i][1]; } out <== is_accepted.out; signal is_consecutive[msg_bytes+1][3]; is_consecutive[msg_bytes][2] <== 0; for (var i = 0; i < msg_bytes; i++) { - is_consecutive[msg_bytes-1-i][0] <== states[num_bytes-i][8] * (1 - is_consecutive[msg_bytes-i][2]) + is_consecutive[msg_bytes-i][2]; + is_consecutive[msg_bytes-1-i][0] <== states[num_bytes-i][1] * (1 - is_consecutive[msg_bytes-i][2]) + is_consecutive[msg_bytes-i][2]; is_consecutive[msg_bytes-1-i][1] <== state_changed[msg_bytes-i].out * is_consecutive[msg_bytes-1-i][0]; - is_consecutive[msg_bytes-1-i][2] <== ORAnd()([(1 - from_zero_enabled[msg_bytes-i+1]), states[num_bytes-i][8], is_consecutive[msg_bytes-1-i][1]]); + is_consecutive[msg_bytes-1-i][2] <== ORAnd()([(1 - from_zero_enabled[msg_bytes-i+1]), states[num_bytes-i][1], is_consecutive[msg_bytes-1-i][1]]); } - // substrings calculated: [{(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (1, 8), (2, 1), (3, 1), (4, 1), (5, 3), (6, 3), (7, 3)}] + // substrings calculated: [{(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (2, 1), (3, 2), (4, 2), (5, 2), (6, 4), (7, 4), (8, 4)}] signal prev_states0[15][msg_bytes]; signal is_substr0[msg_bytes]; signal is_reveal0[msg_bytes]; signal output reveal0[msg_bytes]; for (var i = 0; i < msg_bytes; i++) { - // the 0-th substring transitions: [(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (1, 8), (2, 1), (3, 1), (4, 1), (5, 3), (6, 3), (7, 3)] + // the 0-th substring transitions: [(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (2, 1), (3, 2), (4, 2), (5, 2), (6, 4), (7, 4), (8, 4)] prev_states0[0][i] <== from_zero_enabled[i+1] * states[i+1][0]; prev_states0[1][i] <== from_zero_enabled[i+1] * states[i+1][0]; prev_states0[2][i] <== from_zero_enabled[i+1] * states[i+1][0]; @@ -351,14 +351,14 @@ template Negate2Regex(msg_bytes) { prev_states0[5][i] <== from_zero_enabled[i+1] * states[i+1][0]; prev_states0[6][i] <== from_zero_enabled[i+1] * states[i+1][0]; prev_states0[7][i] <== from_zero_enabled[i+1] * states[i+1][0]; - prev_states0[8][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][1]; - prev_states0[9][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][2]; - prev_states0[10][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][3]; - prev_states0[11][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][4]; - prev_states0[12][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][5]; - prev_states0[13][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][6]; - prev_states0[14][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][7]; - is_substr0[i] <== MultiOR(15)([prev_states0[0][i] * states[i+2][1], prev_states0[1][i] * states[i+2][2], prev_states0[2][i] * states[i+2][3], prev_states0[3][i] * states[i+2][4], prev_states0[4][i] * states[i+2][5], prev_states0[5][i] * states[i+2][6], prev_states0[6][i] * states[i+2][7], prev_states0[7][i] * states[i+2][8], prev_states0[8][i] * states[i+2][8], prev_states0[9][i] * states[i+2][1], prev_states0[10][i] * states[i+2][1], prev_states0[11][i] * states[i+2][1], prev_states0[12][i] * states[i+2][3], prev_states0[13][i] * states[i+2][3], prev_states0[14][i] * states[i+2][3]]); + prev_states0[8][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][2]; + prev_states0[9][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][3]; + prev_states0[10][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][4]; + prev_states0[11][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][5]; + prev_states0[12][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][6]; + prev_states0[13][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][7]; + prev_states0[14][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][8]; + is_substr0[i] <== MultiOR(15)([prev_states0[0][i] * states[i+2][1], prev_states0[1][i] * states[i+2][2], prev_states0[2][i] * states[i+2][3], prev_states0[3][i] * states[i+2][4], prev_states0[4][i] * states[i+2][5], prev_states0[5][i] * states[i+2][6], prev_states0[6][i] * states[i+2][7], prev_states0[7][i] * states[i+2][8], prev_states0[8][i] * states[i+2][1], prev_states0[9][i] * states[i+2][2], prev_states0[10][i] * states[i+2][2], prev_states0[11][i] * states[i+2][2], prev_states0[12][i] * states[i+2][4], prev_states0[13][i] * states[i+2][4], prev_states0[14][i] * states[i+2][4]]); is_reveal0[i] <== MultiAND(3)([out, is_substr0[i], is_consecutive[i][2]]); reveal0[i] <== in[i+1] * is_reveal0[i]; } diff --git a/packages/circom/tests/circuits/plus4_regex.circom b/packages/circom/tests/circuits/plus4_regex.circom index b8ec65e..38ee5c4 100644 --- a/packages/circom/tests/circuits/plus4_regex.circom +++ b/packages/circom/tests/circuits/plus4_regex.circom @@ -32,52 +32,52 @@ template Plus4Regex(msg_bytes) { states[i][0] <== 1; eq[0][i] = IsEqual(); eq[0][i].in[0] <== in[i]; - eq[0][i].in[1] <== 51; + eq[0][i].in[1] <== 49; and[0][i] = AND(); and[0][i].a <== states[i][0]; and[0][i].b <== eq[0][i].out; and[1][i] = AND(); - and[1][i].a <== states[i][4]; + and[1][i].a <== states[i][3]; and[1][i].b <== eq[0][i].out; states_tmp[i+1][1] <== and[1][i].out; eq[1][i] = IsEqual(); eq[1][i].in[0] <== in[i]; - eq[1][i].in[1] <== 49; + eq[1][i].in[1] <== 51; and[2][i] = AND(); and[2][i].a <== states[i][0]; and[2][i].b <== eq[1][i].out; and[3][i] = AND(); - and[3][i].a <== states[i][4]; + and[3][i].a <== states[i][3]; and[3][i].b <== eq[1][i].out; states_tmp[i+1][2] <== and[3][i].out; eq[2][i] = IsEqual(); eq[2][i].in[0] <== in[i]; - eq[2][i].in[1] <== 52; + eq[2][i].in[1] <== 50; and[4][i] = AND(); and[4][i].a <== states[i][1]; and[4][i].b <== eq[2][i].out; - states[i+1][3] <== and[4][i].out; eq[3][i] = IsEqual(); eq[3][i].in[0] <== in[i]; - eq[3][i].in[1] <== 50; + eq[3][i].in[1] <== 53; and[5][i] = AND(); - and[5][i].a <== states[i][2]; + and[5][i].a <== states[i][4]; and[5][i].b <== eq[3][i].out; + multi_or[0][i] = MultiOR(2); + multi_or[0][i].in[0] <== and[4][i].out; + multi_or[0][i].in[1] <== and[5][i].out; + states[i+1][3] <== multi_or[0][i].out; eq[4][i] = IsEqual(); eq[4][i].in[0] <== in[i]; - eq[4][i].in[1] <== 53; + eq[4][i].in[1] <== 52; and[6][i] = AND(); - and[6][i].a <== states[i][3]; + and[6][i].a <== states[i][2]; and[6][i].b <== eq[4][i].out; - multi_or[0][i] = MultiOR(2); - multi_or[0][i].in[0] <== and[5][i].out; - multi_or[0][i].in[1] <== and[6][i].out; - states[i+1][4] <== multi_or[0][i].out; + states[i+1][4] <== and[6][i].out; eq[5][i] = IsEqual(); eq[5][i].in[0] <== in[i]; eq[5][i].in[1] <== 98; and[7][i] = AND(); - and[7][i].a <== states[i][4]; + and[7][i].a <== states[i][3]; and[7][i].b <== eq[5][i].out; states[i+1][5] <== and[7][i].out; from_zero_enabled[i] <== MultiNOR(5)([states_tmp[i+1][1], states_tmp[i+1][2], states[i+1][3], states[i+1][4], states[i+1][5]]); @@ -102,21 +102,21 @@ template Plus4Regex(msg_bytes) { is_consecutive[msg_bytes-1-i][1] <== state_changed[msg_bytes-i].out * is_consecutive[msg_bytes-1-i][0]; is_consecutive[msg_bytes-1-i][2] <== ORAnd()([(1 - from_zero_enabled[msg_bytes-i+1]), states[num_bytes-i][5], is_consecutive[msg_bytes-1-i][1]]); } - // substrings calculated: [{(0, 1), (0, 2), (1, 3), (2, 4), (3, 4), (4, 1), (4, 2)}] + // substrings calculated: [{(0, 1), (0, 2), (1, 3), (2, 4), (3, 1), (3, 2), (4, 3)}] signal prev_states0[7][msg_bytes]; signal is_substr0[msg_bytes]; signal is_reveal0[msg_bytes]; signal output reveal0[msg_bytes]; for (var i = 0; i < msg_bytes; i++) { - // the 0-th substring transitions: [(0, 1), (0, 2), (1, 3), (2, 4), (3, 4), (4, 1), (4, 2)] + // the 0-th substring transitions: [(0, 1), (0, 2), (1, 3), (2, 4), (3, 1), (3, 2), (4, 3)] prev_states0[0][i] <== from_zero_enabled[i+1] * states[i+1][0]; prev_states0[1][i] <== from_zero_enabled[i+1] * states[i+1][0]; prev_states0[2][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][1]; prev_states0[3][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][2]; prev_states0[4][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][3]; - prev_states0[5][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][4]; + prev_states0[5][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][3]; prev_states0[6][i] <== (1 - from_zero_enabled[i+1]) * states[i+1][4]; - is_substr0[i] <== MultiOR(7)([prev_states0[0][i] * states[i+2][1], prev_states0[1][i] * states[i+2][2], prev_states0[2][i] * states[i+2][3], prev_states0[3][i] * states[i+2][4], prev_states0[4][i] * states[i+2][4], prev_states0[5][i] * states[i+2][1], prev_states0[6][i] * states[i+2][2]]); + is_substr0[i] <== MultiOR(7)([prev_states0[0][i] * states[i+2][1], prev_states0[1][i] * states[i+2][2], prev_states0[2][i] * states[i+2][3], prev_states0[3][i] * states[i+2][4], prev_states0[4][i] * states[i+2][1], prev_states0[5][i] * states[i+2][2], prev_states0[6][i] * states[i+2][3]]); is_reveal0[i] <== MultiAND(3)([out, is_substr0[i], is_consecutive[i][2]]); reveal0[i] <== in[i+1] * is_reveal0[i]; } diff --git a/packages/compiler/Cargo.toml b/packages/compiler/Cargo.toml index 0a2d520..a541de3 100644 --- a/packages/compiler/Cargo.toml +++ b/packages/compiler/Cargo.toml @@ -22,17 +22,17 @@ crate-type = ["rlib", "cdylib"] [dependencies] tabbycat = { version = "0.1", features = ["attributes"], optional = true } -fancy-regex = "0.11.0" +fancy-regex = "=0.13.0" petgraph = "0.6.3" graph-cycles = "0.1.0" thiserror = "1.0.40" serde_json = "1.0.95" serde = { version = "1.0.159", features = ["derive"] } -itertools = "0.10.3" +itertools = "0.13.0" clap = { version = "=4.2.1", features = ["derive"] } -ahash = "=0.8.6" -regex-automata = "0.4.5" -regex = "1.10.3" +ahash = "=0.8.11" +regex-automata = "=0.4.7" +regex = "=1.10.6" getrandom = { version = "0.2", features = ["js"] } wasm-bindgen = "0.2" serde-wasm-bindgen = "0.6.5"