Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Note: this is added upon the original Noir support @olehmisar built.
Extraction of 1 or more substrings can be requested in both settings (raw, decomposed):
-s <SUBSTRS_JSON_PATH>
that contains the state transitions that should be revealedNote that the number of substrings that have to be extracted is not necessarily known beforehand. For example regex
(substr=(a|b)+ )+
where the substring to be extracted is(a|b)
, should extract 2 substrings forsubstr=a substr=b
and 1 substring forsubstr=b
.The information of where substrings should be extracted within the regex is added to
substrings
in theRegexAndDFA
. In the case of raw onlysubstring_ranges
is filled so this is what this implementation uses.How it works
The adjustments when
gen_substrs = true
are:regex_match
becomes a Vector of BoundedVec. We don't know the substring length beforehand, but it is bounded by N. And we don't know how many substrings are returnedIf the bool is false, nothing changes.
Note: For the raw setting the boolean was by default set to true, I changed it to false, just like in the decomposed setting. Asked in the TG group if this is ok (open question).
Testing
Decomposed
Create a file called
substring_test.json
containing:Run
Raw
This is the example from the README.md; create
./simple_regex_substrs.json
containing:Run
For example, the corresponding Noir code should return for input
1=b 2=bbcb 2=c 2=bb d
the following 4 substrings:b
,bbcb
,c
,bb
, andd
.Note that the second substring is marked by 2 transitions [6,7] and [7,7], which is needed for the circom impl. However, in Noir we only need to know the substring is in state 7, so this is the information that is taken from
substring_ranges
.Problem*
Resolves
Summary*
Additional Context
PR Checklist*
cargo fmt
on default settings.