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

Simplified second-Spartan-sum-check (via simpler uniform R1CS product-vector MLE) #347

Open
arasuarun opened this issue May 7, 2024 · 0 comments
Labels
optimization Performance improvement

Comments

@arasuarun
Copy link
Collaborator

arasuarun commented May 7, 2024

Making a note of a new optimization for Spartan applied to Jolt's R1CS recently suggested by Justin. It would involve simple changes to the A, B, C mle evaluations and the inner (second) sumcheck for the prover, and mle evaluation for the verifier.

Context: the three constraint matrices A, B, C are all in block-diagonal form as there are ~60 constraints and ~80 variables of z per RISC-V cycle. A boolean vector representing a row in this big matrix can be split into two components as $r = r_{small} \parallel r_{big}$ where $r_{small}$ denotes the constraint (from the small matrix) and $r_{big}$ denotes the step counter. A column can be split $y = y_{small} \parallel y_{big}$ where $y_{small}$ denotes the variable (from the small matrix) and $y_{big}$ is again the step counter. Currently, the uniformity of the R1CS is exploited as follows. Let $NC$ be the number of columns in the big matrix.

$(A * z)[r] = \sum\limits_{j_{small} \parallel j_{big} \in \{ 0,1 \} ^{\log(NC)}} A_{small}(r_{small}, j_{small}) * eq(r_{big}, j_{big}) * z(j)$,

and similarly for $(Bz)[r]$ and $(Cz)[r]$.

To prepare to apply sum-check to compute (a random linear combination of) the above three sums, the prover first evaluates the mles of A, B and C at all points of the form $(r, y)$ where $y$ ranges over $\{0, 1\} ^{\log(NC)}$, as: $A(r, y) = \sum\limits_{j} A_{small}(r_{small}, y_{small}) * eq(r_{big}, y_{big})$. Once these values are all computed, the prover is ready to call the second sumcheck through the function prove_spartan_quadratic.

It turns out there is an even simpler way to express $(A * z)$. There's no reason to sum over $j_{big}$ at all. We can simple write:

$(A * z)][r] = \sum\limits_{j_{small}} A_{small}(r_{small}, j_{small}) * z(j_{small} \parallel r_{big})$.

This means that the second sumcheck can just iterate over the variables in y_small which is a constant independent of the program length. And to run the second sum-check, the prover just needs to evaluate the mle of A, B, C at each point $y_{small} \parallel r_{big}$ as $A(r, y_{small} \parallel r_{big}) = \sum\limits_{j_{small}} A_{small}(r_{small}, y_{small})$.

@sragss sragss changed the title Simplified uniform R1CS mle equation Simplified uniform R1CS MLE May 7, 2024
@GUJustin GUJustin changed the title Simplified uniform R1CS MLE Simplified second-Spartan-sum-check (via simpler uniform R1CS product-vector MLE) May 7, 2024
@moodlezoup moodlezoup added the optimization Performance improvement label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
optimization Performance improvement
Projects
None yet
Development

No branches or pull requests

2 participants