Skip to content

Commit

Permalink
add comments for regex and substrings
Browse files Browse the repository at this point in the history
  • Loading branch information
Divide-By-0 authored and bert0RM committed Dec 13, 2023
1 parent 1febda8 commit ee5c94e
Show file tree
Hide file tree
Showing 14 changed files with 523 additions and 409 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"packages/*"
],
"contributors": [
"Javier Su <javier.su.weijie@gmail.com>",
"Kata Choi <kata.choi@gmail.com>",
"Sora Suegami <suegamisora@gmail.com>",
"Yush G <aayushg@mit.edu>"
"Yush G <aayushg@mit.edu>",
"Javier Su <javier.su.weijie@gmail.com>",
"Kata Choi <kata.choi@gmail.com>"
],
"scripts": {
"install": "yarn workspaces -pt run install",
Expand Down
2 changes: 2 additions & 0 deletions packages/circom/circuits/common/email_addr_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pragma circom 2.1.5;

include "@zk-email/zk-regex-circom/circuits/regex_helpers.circom";

// regex: (a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|0|1|2|3|4|5|6|7|8|9|!|#|$|%|&|'|\*|\+|-|/|=|\?|^|_|`|{|\||}|~|\.)+@(a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|0|1|2|3|4|5|6|7|8|9|\.|-)+
template EmailAddrRegex(msg_bytes) {
signal input msg[msg_bytes];
signal output out;
Expand Down Expand Up @@ -248,6 +249,7 @@ template EmailAddrRegex(msg_bytes) {
is_consecutive[msg_bytes-1-i][0] <== states[num_bytes-i][3] * (1 - is_consecutive[msg_bytes-i][1]) + is_consecutive[msg_bytes-i][1];
is_consecutive[msg_bytes-1-i][1] <== state_changed[msg_bytes-i].out * is_consecutive[msg_bytes-1-i][0];
}
// substrings calculated: [{(1, 2), (1, 1), (0, 1), (3, 3), (2, 3)}]
signal is_substr0[msg_bytes][6];
signal is_reveal0[msg_bytes];
signal output reveal0[msg_bytes];
Expand Down
2 changes: 2 additions & 0 deletions packages/circom/circuits/common/email_domain_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pragma circom 2.1.5;

include "@zk-email/zk-regex-circom/circuits/regex_helpers.circom";

// regex: (a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|0|1|2|3|4|5|6|7|8|9|!|#|$|%|&|'|\*|\+|-|/|=|\?|^|_|`|{|\||}|~|\.)+@(a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|0|1|2|3|4|5|6|7|8|9|\.|-)+
template EmailDomainRegex(msg_bytes) {
signal input msg[msg_bytes];
signal output out;
Expand Down Expand Up @@ -248,6 +249,7 @@ template EmailDomainRegex(msg_bytes) {
is_consecutive[msg_bytes-1-i][0] <== states[num_bytes-i][3] * (1 - is_consecutive[msg_bytes-i][1]) + is_consecutive[msg_bytes-i][1];
is_consecutive[msg_bytes-1-i][1] <== state_changed[msg_bytes-i].out * is_consecutive[msg_bytes-1-i][0];
}
// substrings calculated: [{(3, 3), (2, 3)}]
signal is_substr0[msg_bytes][3];
signal is_reveal0[msg_bytes];
signal output reveal0[msg_bytes];
Expand Down
2 changes: 2 additions & 0 deletions packages/circom/circuits/common/message_id_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pragma circom 2.1.5;

include "@zk-email/zk-regex-circom/circuits/regex_helpers.circom";

// regex: ((\n)|^)message-id:<(=|@|\.|\+|_|-|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|0|1|2|3|4|5|6|7|8|9)+>\n
template MessageIdRegex(msg_bytes) {
signal input msg[msg_bytes];
signal output out;
Expand Down Expand Up @@ -270,6 +271,7 @@ template MessageIdRegex(msg_bytes) {
is_consecutive[msg_bytes-1-i][0] <== states[num_bytes-i][7] * (1 - is_consecutive[msg_bytes-i][1]) + is_consecutive[msg_bytes-i][1];
is_consecutive[msg_bytes-1-i][1] <== state_changed[msg_bytes-i].out * is_consecutive[msg_bytes-1-i][0];
}
// substrings calculated: [{(17, 18), (1, 4), (1, 1), (18, 1)}]
signal is_substr0[msg_bytes][5];
signal is_reveal0[msg_bytes];
signal output reveal0[msg_bytes];
Expand Down
2 changes: 2 additions & 0 deletions packages/circom/tests/circuits/simple_regex.circom
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pragma circom 2.1.5;

include "@zk-email/zk-regex-circom/circuits/regex_helpers.circom";

// regex: 1=(a|b) (2=(b|c)+ )+d
template SimpleRegex(msg_bytes) {
signal input msg[msg_bytes];
signal output out;
Expand Down Expand Up @@ -128,6 +129,7 @@ template SimpleRegex(msg_bytes) {
is_consecutive[msg_bytes-1-i][0] <== states[num_bytes-i][9] * (1 - is_consecutive[msg_bytes-i][1]) + is_consecutive[msg_bytes-i][1];
is_consecutive[msg_bytes-1-i][1] <== state_changed[msg_bytes-i].out * is_consecutive[msg_bytes-1-i][0];
}
// substrings calculated: [{(2, 3)}, {(6, 7), (7, 7)}, {(8, 9)}]
signal is_substr0[msg_bytes][2];
signal is_reveal0[msg_bytes];
signal output reveal0[msg_bytes];
Expand Down
Loading

0 comments on commit ee5c94e

Please sign in to comment.