-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathfrom_addr_regex.circom
31 lines (24 loc) · 1.01 KB
/
from_addr_regex.circom
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
pragma circom 2.1.5;
include "@zk-email/zk-regex-circom/circuits/regex_helpers.circom";
include "@zk-email/zk-regex-circom/circuits/common/from_all_regex.circom";
include "@zk-email/zk-regex-circom/circuits/common/email_addr_regex.circom";
include "@zk-email/zk-regex-circom/circuits/common/email_addr_with_name_regex.circom";
template FromAddrRegex(msg_bytes) {
signal input msg[msg_bytes];
signal output out;
signal output reveal0[msg_bytes];
signal fromOut;
signal fromReveal[msg_bytes];
(fromOut, fromReveal) <== FromAllRegex(msg_bytes)(msg);
fromOut === 1;
signal emailNameOut;
signal emailNameReveal[msg_bytes];
(emailNameOut, emailNameReveal) <== EmailAddrWithNameRegex(msg_bytes)(fromReveal);
signal emailAddrOut;
signal emailAddrReveal[msg_bytes];
(emailAddrOut, emailAddrReveal) <== EmailAddrRegex(msg_bytes)(fromReveal);
out <== MultiOR(2)([emailNameOut, emailAddrOut]);
for(var i=0; i<msg_bytes; i++) {
reveal0[i] <== emailNameOut * (emailNameReveal[i] - emailAddrReveal[i]) + emailAddrReveal[i];
}
}