Skip to content

Commit 72f2039

Browse files
committed
Added to_addr test as hardcoded project. This one also consists of combining multiple regex match parts.
1 parent f3ecf3b commit 72f2039

File tree

9 files changed

+4162
-0
lines changed

9 files changed

+4162
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[package]
2+
name = "to_addr"
3+
type = "bin"
4+
authors = [""]
5+
compiler_version = ">=0.34.0"
6+
7+
[dependencies]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# to_addr test
2+
3+
This test for the circom code uses a circuit that includes 3 templates. The 3 templates have been generated with decomposed regex information (see `/decomposed`):
4+
- "to_all"
5+
- "email_addr_with_name"
6+
- "email_addr"
7+
8+
They are combined as follows: "to_all" extracts a substring `s`. Then `s` is used as the input for both "email_addr_with_name" and "email_addr".
9+
10+
- "email_addr_with_name" matches an email address between `<>`
11+
- "email_addr" only matches the email address
12+
13+
If "email_addr_with_name" found an email address, that one is returned. Otherwise the email address found with "email_addr" is returned. If nothing was found, the match fails.
14+
15+
## Recreate templates
16+
17+
```
18+
zk-regex decomposed -d decomposed/to_all.json --noir-file-path src/to_all.nr -g true
19+
20+
zk-regex decomposed -d decomposed/email_addr_with_name.json --noir-file-path src/email_addr_with_name.nr -g true
21+
22+
zk-regex decomposed -d decomposed/email_addr.json --noir-file-path src/email_addr.nr -g true
23+
```
24+
25+
Note that `email_addr_with_name.nr` and `email_addr.nr` have to be adjusted to return a bool instead of fail the assertion if they don't match the regex. Otherwise we can't execute both functions and see which one returns a substring.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"parts": [
3+
{
4+
"is_public": true,
5+
"regex_def": "[A-Za-z0-9!#$%&'*+=?\\-\\^_`{|}~./@]+@[A-Za-z0-9.\\-]+"
6+
}
7+
]
8+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"parts": [
3+
{
4+
"is_public": false,
5+
"regex_def": "[^\r\n]+<"
6+
},
7+
{
8+
"is_public": true,
9+
"regex_def": "[A-Za-z0-9!#$%&'*+=?\\-\\^_`{|}~./@]+@[a-zA-Z0-9.\\-]+"
10+
},
11+
{
12+
"is_public": false,
13+
"regex_def": ">"
14+
}
15+
]
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"parts": [
3+
{
4+
"is_public": false,
5+
"regex_def": "(\r\n|^)to:"
6+
},
7+
{
8+
"is_public": true,
9+
"regex_def": "[^\r\n]+"
10+
},
11+
{
12+
"is_public": false,
13+
"regex_def": "\r\n"
14+
}
15+
]
16+
}

0 commit comments

Comments
 (0)