Skip to content

Commit

Permalink
Merge pull request #68 from zkemail/feat/fix-email-addr-regex
Browse files Browse the repository at this point in the history
Fixing email address and domain regexes.
  • Loading branch information
Bisht13 authored Sep 4, 2024
2 parents 3b62631 + f71b30b commit c7c1845
Show file tree
Hide file tree
Showing 24 changed files with 615 additions and 263 deletions.
2 changes: 1 addition & 1 deletion packages/apis/src/decomposed_defs/body_hash.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"parts": [
{
"is_public": false,
"regex_def": "((\r\n)|^)dkim-signature:"
"regex_def": "(\r\n|^)dkim-signature:"
},
{
"is_public": false,
Expand Down
4 changes: 2 additions & 2 deletions packages/apis/src/decomposed_defs/email_addr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"parts": [
{
"is_public": true,
"regex_def": "[A-Za-z0-9!#$%&'*+=?^_`{|}~.]+@[A-Za-z0-9.-]+"
"regex_def": "[A-Za-z0-9!#$%&'*+=?\\-\\^_`{|}~./@]+@[A-Za-z0-9.\\-]+"
}
]
}
}
4 changes: 2 additions & 2 deletions packages/apis/src/decomposed_defs/email_addr_with_name.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
},
{
"is_public": true,
"regex_def": "[a-zA-Z0-9!#$%&'*+-/=?^_`{\\|}~\\.]+@[a-zA-Z0-9_\\.-]+"
"regex_def": "[A-Za-z0-9!#$%&'*+=?\\-\\^_`{|}~./@]+@[a-zA-Z0-9.\\-]+"
},
{
"is_public": false,
"regex_def": ">"
}
]
}
}
10 changes: 3 additions & 7 deletions packages/apis/src/decomposed_defs/email_domain.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@
"parts": [
{
"is_public": false,
"regex_def": "[A-Za-z0-9!#$%&'*+-/=?^_`{\\|}~\\.]+"
},
{
"is_public": false,
"regex_def": "@"
"regex_def": "[A-Za-z0-9!#$%&'*+=?\\-\\^_`{|}~./]+@"
},
{
"is_public": true,
"regex_def": "[A-Za-z0-9\\.-]+"
"regex_def": "[A-Za-z0-9.\\-@]+"
}
]
}
}
6 changes: 3 additions & 3 deletions packages/apis/src/decomposed_defs/from_addr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
"parts": [
{
"is_public": false,
"regex_def": "((\r\n)|^)from:"
"regex_def": "(\r\n|^)from:"
},
{
"is_public": false,
"regex_def": "([^\r\n]+<)?"
},
{
"is_public": true,
"regex_def": "[A-Za-z0-9!#$%&'\\*\\+-/=\\?^_`{\\|}~\\.]+@[A-Za-z0-9\\.-]+"
"regex_def": "[A-Za-z0-9!#$%&'*+=?\\-\\^_`{|}~./@]+@[A-Za-z0-9.\\-]+"
},
{
"is_public": false,
"regex_def": ">?\r\n"
}
]
}
}
30 changes: 15 additions & 15 deletions packages/apis/src/decomposed_defs/from_all.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"parts": [
{
"is_public": false,
"regex_def": "((\r\n)|^)from:"
},
{
"is_public": true,
"regex_def": "[^\r\n]+"
},
{
"is_public": false,
"regex_def": "\r\n"
}
]
}
"parts": [
{
"is_public": false,
"regex_def": "(\r\n|^)from:"
},
{
"is_public": true,
"regex_def": "[^\r\n]+"
},
{
"is_public": false,
"regex_def": "\r\n"
}
]
}
2 changes: 1 addition & 1 deletion packages/apis/src/decomposed_defs/message_id.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"parts": [
{
"is_public": false,
"regex_def": "((\r\n)|^)message-id:"
"regex_def": "(\r\n|^)message-id:"
},
{
"is_public": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/apis/src/decomposed_defs/subject_all.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"parts": [
{
"is_public": false,
"regex_def": "((\r\n)|^)subject:"
"regex_def": "(\r\n|^)subject:"
},
{
"is_public": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/apis/src/decomposed_defs/timestamp.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"parts": [
{
"is_public": false,
"regex_def": "((\r\n)|^)dkim-signature:"
"regex_def": "(\r\n|^)dkim-signature:"
},
{
"is_public": false,
Expand Down
6 changes: 3 additions & 3 deletions packages/apis/src/decomposed_defs/to_addr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
"parts": [
{
"is_public": false,
"regex_def": "((\r\n)|^)to:"
"regex_def": "(\r\n|^)to:"
},
{
"is_public": false,
"regex_def": "([^\r\n]+<)?"
},
{
"is_public": true,
"regex_def": "[a-zA-Z0-9!#$%&'\\*\\+-/=\\?^_`{\\|}~\\.]+@[a-zA-Z0-9_\\.-]+"
"regex_def": "[A-Za-z0-9!#$%&'*+=?\\-\\^_`{|}~./@]+@[a-zA-Z0-9.\\-]+"
},
{
"is_public": false,
"regex_def": ">?\r\n"
}
]
}
}
30 changes: 15 additions & 15 deletions packages/apis/src/decomposed_defs/to_all.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"parts": [
{
"is_public": false,
"regex_def": "((\r\n)|^)to:"
},
{
"is_public": true,
"regex_def": "[^\r\n]+"
},
{
"is_public": false,
"regex_def": "\r\n"
}
]
}
"parts": [
{
"is_public": false,
"regex_def": "(\r\n|^)to:"
},
{
"is_public": true,
"regex_def": "[^\r\n]+"
},
{
"is_public": false,
"regex_def": "\r\n"
}
]
}
4 changes: 3 additions & 1 deletion packages/circom/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

Circom circuits for regex verification in [zk-regex](https://github.com/zkemail/zk-regex/tree/main).
This package contains circom circuits and decomposed regex definitions for common regexes in `./circuits/common` folder.


## Note
Our `email_domain_regex.circom` circuit cannot capture an email address that contains "@" in the name part before the domain part, e.g., "[email protected]@dummy.com", due to limitation of our circuit construction. For example, when "[email protected]@dummy.com" is given, that circuit outputs not "dummy.com" but "[email protected]" as an exposed substring for the domain. However, an adversary cannot exploit this feature to expose a fake domain since the true domain at the end will also be revealed along with it.
4 changes: 2 additions & 2 deletions packages/circom/circuits/common/email_addr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"parts": [
{
"is_public": true,
"regex_def": "[A-Za-z0-9!#$%&'*+=?\\^_`{|}~.]+@[A-Za-z0-9.-]+"
"regex_def": "[A-Za-z0-9!#$%&'*+=?\\-\\^_`{|}~./@]+@[A-Za-z0-9.\\-]+"
}
]
}
}
Loading

0 comments on commit c7c1845

Please sign in to comment.