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

remove var usage in lock header #29

Merged
merged 5 commits into from
Nov 4, 2024
Merged

remove var usage in lock header #29

merged 5 commits into from
Nov 4, 2024

Conversation

lonerapier
Copy link
Collaborator

@lonerapier lonerapier commented Nov 4, 2024

closes #30

reduces r1cs file size for http_lock_header circuit from 1.93G to 43MB by removing var usage in FirstStringMatch template.

Note: this doesn't happen with all vars, as can be noted here, only happening for iterating var accessed again in a separate signal/var.

@@ -101,13 +103,13 @@ template FirstStringMatch(dataLen, maxKeyLen) {
stringMatch[idx] = IsEqualArray(maxKeyLen);
stringMatch[idx].in[0] <== key;
for (var key_idx = 0 ; key_idx < maxKeyLen ; key_idx++) {
isFirstMatchAndInsideBound[idx * maxKeyLen + key_idx] <== (1 - matched) * (1 - isKeyOutOfBounds[key_idx]);
isFirstMatchAndInsideBound[idx * maxKeyLen + key_idx] <== (1 - isMatched[idx]) * (1 - isKeyOutOfBounds[key_idx]);
Copy link
Collaborator Author

@lonerapier lonerapier Nov 4, 2024

Choose a reason for hiding this comment

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

@0xJepsen circom doesn't like updating a signal using an already updating var

Copy link
Contributor

Choose a reason for hiding this comment

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

Very strange

Copy link
Contributor

@0xJepsen 0xJepsen left a comment

Choose a reason for hiding this comment

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

This is so counter intuitive but honestly amazing that it works and reduces size by so much.

@0xJepsen 0xJepsen changed the base branch from feat/circuits-build to main November 4, 2024 13:36
@0xJepsen
Copy link
Contributor

0xJepsen commented Nov 4, 2024

Okay i don't want to merge this without running CI and rebuilding the right artifacts. But i do think we should build artifacts with these new perf gains asap.

@0xJepsen
Copy link
Contributor

0xJepsen commented Nov 4, 2024

LFG, we spin green to win

@0xJepsen 0xJepsen merged commit 5dd231b into main Nov 4, 2024
3 checks passed
@lonerapier lonerapier deleted the fix/http-r1cs-size branch November 7, 2024 06:32
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.

circuits: extra large r1cs file sizes
2 participants