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

feat: NIVC circuits #97

Open
Tracked by #96
Autoparallel opened this issue Oct 19, 2024 · 0 comments
Open
Tracked by #96

feat: NIVC circuits #97

Autoparallel opened this issue Oct 19, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request http json

Comments

@Autoparallel
Copy link
Contributor

Idea

To be able to string together multiple circuits in NIVC, we can make slightly different versions of our templates we have now to do this. Roughly, we will have:

HTTP:

  1. http_parse_and_lock_start_line.circom: Sets the complete parser state for an HTTP request/response and additionally goes ahead to assert values in the start line are correct (locking).
  2. http_lock_header.circom: Uses the parser state from the previous circuit. Asserts headers are properly contained in the HTTP request/response. Can be ran multiple times as needed.
  3. http_body_mask.circom: Uses the parser state from the previous circuit(s). Applies a mask to the HTTP request/response data so that only the body of a response (or, I suppose, request) remains nonzero.

JSON:

  1. json_parse.circom: Reads in the data from the http_body_mask and, assuming this body data is JSON, sets the parser state of the JSON parser using this.
  2. json_object_mask.circom: Given a sub-object of a JSON, e.g.,:
{
     "items": {
         "helmet": "Look at My Head",
         "sword": "Look at My Sword!",
         "etc": ["stick", "stone", { "potions": [100, 200] } ]
      }
}

we can mask out an object such as that contained in the key "items". Upon applying the template with the input of `"items" as the key (and its length), we will mask out the JSON to be all zeros aside from:

     "items": {
         "helmet": "Look at My Head",
         "sword": "Look at My Sword!",
         "etc": ["stick", "stone", { "potions": [100, 200] } ]
      }

We could apply this again to "etc" to get out all zeros except:

["stick", "stone", { "potions": [100, 200] } ]

Throughout this, the parser state for each byte of the JSON is passed through (it may need to parse for the whole HTTP size).
3. json_array_index_mask.circom: Now if we have an array we are looking at, we want to be able to mask just a specific index of that array. For instance, we may want to mask index 2 so that we get out:

{ "potions": [100,200] }

Parser state is carried forward.
4. json_final_extract.circom: We now want to get out our intended object, so we can run whatever we may need to get to a final primitive value (such as the 200 in potions), and with that being all that's left, we can run this circuit with the parser data and return an signal output out that is the final value that is nonzero left in all the data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request http json
Projects
None yet
Development

No branches or pull requests

2 participants