-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: Add Regex Support For Email Verifier #1
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you add any unit tests?
let (is_public, dfa) = part; | ||
let fwd = dense::DFA::from_bytes(&dfa.fwd).unwrap().0; | ||
let rev = dense::DFA::from_bytes(&dfa.bwd).unwrap().0; | ||
|
||
let re = Regex::builder().build_from_dfas(fwd, rev); | ||
let matches: Vec<Match> = re.find_iter(email_body).collect(); | ||
|
||
if !matches.is_empty() { | ||
regex_verified = true; | ||
if *is_public { | ||
let substring = email_body[matches[0].start()..matches[0].end()].to_string(); | ||
regex_matches.push(substring); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shreyas-londhe
Could you explain why these processes are enough to verify the regex?
Specifically, what are roles of fwd
and rev
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a bug in the regex matching which I'm fixing, and will reflect in #2.
Specifically, what are roles of
fwd
andrev
here?
fwd
and rev
are the DFAs serialized out of the circuit and are fed to the circuit as bytes. In the circuit we just deserialize it and construct the Regex which is the most efficient for matching ops.
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct PublicKey { | ||
pub key: Vec<u8>, | ||
pub key_type: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the role of key_type
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key_type
is a string which determines whether the public key is a RSA public key or ED25519 public key.
- Function where the key is used: https://github.com/risc0-labs/dkim/blob/3213315e41f426c307b8feb8fb329330a47e326c/src/lib.rs#L356
- How the key type is determined: https://github.com/zkemail/r0-zkEmail/blob/feat/regex/host/src/utils.rs#L85-L93
This is a comment for future PR. |
@SoraSuegami I understand your concern and yes I have thought of this. The reason you don't see a library implementation of the core code is because the current ZkVM implementations have different crates supported for precompiles and hence it becomes difficult to manage the dependencies properly. Once the ZkVM implementations become a bit stable, I'm planning to do an abstraction where we just write the rust and different ZkVM implementations are built automatically. Something like this - https://github.com/MatteoMer/any-zkvm |
This PR adds regex matching for email body and headers.