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

implement polyval #79

Merged
merged 16 commits into from
Sep 20, 2024
Merged

implement polyval #79

merged 16 commits into from
Sep 20, 2024

Conversation

thor314
Copy link
Contributor

@thor314 thor314 commented Sep 19, 2024

implemented polyval to test ghash bug, rendered obsolete by waylon's recent PR, fixing ghash.

Also fixes a bug in polyval mul alg.

Copy link
Contributor

@devloper devloper left a comment

Choose a reason for hiding this comment

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

Quick review LGTM! Given that main is not passing atm, I think we should go ahead and merge this polyval. This uses dramatically less constraints than the approach currently taken by ghash, so I think it's worth combining the two into one more efficient template.

// }

// component MULX;
// MULX = polyval_GFMULX();
Copy link
Contributor

Choose a reason for hiding this comment

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

This approach on the surface seems dramatically more efficient than the one currently used in Waylon's PR, because it only does this GFMULX once at the end.

Would be good to put our heads together and find a potentially combined approach of these code paths that is less constraint consumptive.

@@ -0,0 +1,11 @@
pragma circom 2.1.9;
include "polyval_gfmul.circom";
Copy link
Contributor

Choose a reason for hiding this comment

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

delete file, one will be merged with the other PR

@@ -22,6 +23,43 @@ template ParseLEBytes64() {
out <-- temp;
}

// parse BE bits as bytes and log them. Assumes that the number of bytes logged is a multiple of 8.
template ParseAndLogBitsAsBytes(N_BYTES){
Copy link
Contributor

Choose a reason for hiding this comment

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

nice!

out <-- ReverseByteHalves[1].out;

// component Logger3 = ParseAndLogBitsAsBytes(16);
Copy link
Contributor

Choose a reason for hiding this comment

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

remove

@@ -36,6 +36,13 @@ template MUL() {
h[1] <== a[1];
y[0] <== b[0];
y[1] <== b[1];
// component Loggers[4];
Copy link
Contributor

Choose a reason for hiding this comment

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

remove

@@ -82,52 +89,65 @@ template MUL() {
BMUL64_z[i+3].y <== h_r[i];
zh[i] <== BMUL64_z[i+3].out;
}
// component Loggers_z[3];
Copy link
Contributor

Choose a reason for hiding this comment

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

remove

Xors_v[1].b <== __zh[2];
v[2] <== Xors_v[1].out;
v[3] <== __zh[1];

// component Loggers_v[4];
Copy link
Contributor

Choose a reason for hiding this comment

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

remove

@@ -161,6 +181,10 @@ template MUL() {
XorMultiples_L[0].inputs <== [v[1], LS_v[0].out, LS_v[1].out, LS_v[2].out];
_v1 <== XorMultiples_L[0].out;

// component Loggers_v2[4];
Copy link
Contributor

Choose a reason for hiding this comment

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

remove

@0xJepsen 0xJepsen self-requested a review September 20, 2024 17:38
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.

lgtm

@thor314 thor314 merged commit 7ad6b0c into main Sep 20, 2024
2 checks passed
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.

3 participants