Skip to content
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

Caret anchor (ˆ) support for Noir #1

Closed
wants to merge 3 commits into from

Conversation

ewynx
Copy link

@ewynx ewynx commented Sep 19, 2024

Description

Note: proposed change here is an addition of a single line, the rest is the original Noir support @olehmisar built.

^ causes the DFA to contain an extra state beforehand that has a transition for 255, which marks the start of the input byte array. In the regex_match function the input is then prefixed with 255 to execute the check. This implementation follows the one of circom. As checked in the TG group, this assumes 255 won't appear in the rest of the input byte string as valid ASCII.

If the regex doesn't start with a "ˆ" this doesn't do anything because then the mapping is to 0.

Note that ^ is only taken into consideration in the decomposed mode.

Example test input for ˆ[0-9]{2}/[0-9]{2}/[0-9]{4}:

{
  "parts": [
      {
          "is_public": false,
          "regex_def": "^"
      },
      {
          "is_public": true,
          "regex_def": "[0-9]{2}/[0-9]{2}/[0-9]{4}"
      }
  ]
}

With cargo run --bin zk-regex decomposed -d <filepath>.json --noir-file-path caret_anchor_test.nr

Problem*

Resolves

Summary*

Additional Context

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

olehmisar and others added 3 commits September 19, 2024 14:13
…r caret anchor (ˆ) works.

Note that ^ is only taken into consideration in the decomposed mode.
@ewynx
Copy link
Author

ewynx commented Oct 2, 2024

#8 contains this feature, closing this PR.

@ewynx ewynx closed this Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants