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: http locking circuit codegen #76

Merged
merged 14 commits into from
Sep 9, 2024
Merged

Conversation

Autoparallel
Copy link
Contributor

@Autoparallel Autoparallel commented Sep 4, 2024

In This PR

We got the following done:

  • Added extra functionality for parsing and locking/verifying the start line of an HTTP request/response.
  • Added codegen functionality for an HTTP request
    • This could easily be modified to handle HTTP responses as well. I just did a bit of a dirty here.
  • Tests that the codegen works, see circuits/test/http/codegen.test.ts.

Hence, at this point we should have these accomplished (not just due to this PR by any means):


This should honestly be cleaned up and made a bit better, but this is an MVP for now before I head out of town for a bit! Feel free to make any changes as needed on top of this base functionality :)

Copy link
Collaborator

@lonerapier lonerapier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

absolute charizard fire!!!
one step closer.

@Autoparallel while making this PR:
image

circuits/http/interpreter.circom Outdated Show resolved Hide resolved

// TODO: change r
headerNameValueMatch[data_idx] <== HeaderFieldNameValueMatch(DATA_BYTES, headerNameLen, headerValueLen)(data, header, value, 100, data_idx);
hasMatched += headerNameValueMatch[data_idx];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is underconstrained. I believe we need to make it hasMatched[DATA_BYTES] and then add with previous value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it actually though? @devloper made a similar comment about an accumulator var being underconstrained, but I think it isn't. If you try to assign hasMatched to something non-quadratic, then it throws an error actually.

If it is underconstrained i must know why!!! need to learn!!!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a change to address this, but still want to know why.

Also the change didn't change the number of constraints I believe

include "circomlib/circuits/gates.circom";
include "@zk-email/circuits/utils/array.circom";

template LockStartLine(DATA_BYTES, beginningLen, middleLen, finalLen) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

umm, why not run IsEqualArray 3 times, first from 0..beginningLen, beginningLen+1..beginningLen+1+middleLen, and so on?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this template will be useful when we can parse multiple spaces between each value in start line, but current parser doesn't.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could do what you suggested!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to avoid using the buggy getSubArray template

@Autoparallel Autoparallel merged commit 12a6651 into main Sep 9, 2024
1 check passed
@Autoparallel Autoparallel deleted the feat/http-circuit-codegen branch September 9, 2024 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants