-
Notifications
You must be signed in to change notification settings - Fork 27
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
Proposal to improve the regex circuit #26
Comments
Looks good, we can discuss more tomorrow! We have code for start and end position (along with matched text) in email.circom, perhaps it can be moved here, outputs chosen can be toggled via template parameter). Tests and restrurcturing would be awesome -- would love to hear what else you think could use some restructuring. Feel free to convert to JS! That wilk also help for in browser regex circuit generation if we ever decide to make that client side only. |
My current thoughts are more for the ease of circuit usage, trying to make it align with how the regex is being used in conventional programming languages. Based on my understanding of the code, to use regex circuit, the client has to calculate the position index of the matches text and provide it as an input signal for the regex circuit to locate and process the matched text. With the restructure, I hope to make the regex circuit easier by only providing message input and the Keep in mind, it might not be necessary to have the counted array as illustrated above. It is more for a intermediate purpose.
I have done the JS conversion on my side and will refine the commands for regex compilation. |
Sounds great! I've added you to https://github.com/zk-email-verify/zk-regex/invitations. |
Thanks for the arrangement. @Divide-By-0 I think now
Meanwhile, I think it would be necessary to benchmark the Please feel free to let me know if any other items are also reasonable to be included in this batch of work. |
In the latest commit, the If you get a chance, please help check to see if the code is optimal. |
This is probably related to #27.
Rational
The regex circuit seems playing a key role in the content verification in zk email. I believe it is unique in the
circuit market
at this stage and would provide great value to the circom community if the regex circuit compilation can be encapsulated as a standalone circuit library.To make the regex circuits usable for wider audience, there would be some changes needed as outlined in the following.
Features
Restructure counting for the matches
For example, assuming there are more than one match in the input message signal, then the output reveal signal would be like
[0,0,0,0,1,1,1,1,0,2,2,2,2,0,0,0,3,3,3,0]
.The sample reveal signal serves for two purposes.
nth
matches.With these two embedded information, the reveal array signal can be further processed to provide additional data points as outline in the next feature for different verification needs.
Additional data points
Given an input parameter for the
nth
match, it should output the following signalsFor example, given the input is
2
and the original message is[a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t]
, the output signal values would beImplementation
It is likely to consider together with Streamline compilation for new regexes #27. My current thought is to refactor the regex circuit compiler to include the
counting restructure
outlined in the feature above, and create a helper circuit for the features outlined inadditional data points
.For the regex circom compilation Streamline compilation for new regexes #27, it currently uses a python script. If there is no particular reason for the preference over python language, I think it might be helpful to convert the script to JS as it is consistent with the parts of project for easier maintenance and testing.
Test coverage. The tests, similar to how the
0xparc-ecdsa
does, would be very helpful for the development process. With the tests in place, the concerns can be isolated and imrove the efficiency of circuit compilation for testing. Overall, this would help improve the development process cycle in practice.The text was updated successfully, but these errors were encountered: