-
Notifications
You must be signed in to change notification settings - Fork 598
feat: sumcheck with disabled rows #10068
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
Merged
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
e056407
created row disabling poly
iakovenkos b53cf64
some comments
iakovenkos c2efe17
disabled rows 1-3, adjusted tests
iakovenkos ac34911
a bit of clean-up
iakovenkos e449422
switched to last rows
iakovenkos 533f154
Merge branch 'master' into si/sumcheck-with-disabled-rows
iakovenkos 6d7c988
mostly dysfunctional
iakovenkos f116bd1
bug fixed
iakovenkos ad6ab32
tests fixed for MegaZKFlavor
iakovenkos 60c8fb4
eccvm circuit size adjusted
iakovenkos ca25839
ultra fixed
iakovenkos 9dc41a8
Merge branch 'master' into si/sumcheck-with-disabled-rows
iakovenkos 254e622
build fixed
iakovenkos 7cca8e0
Merge branch 'master' into si/sumcheck-with-disabled-rows
iakovenkos e4c2398
debugging independent vk hash
iakovenkos 106949e
Merge branch 'si/sumcheck-with-disabled-rows' of github.com:AztecProt…
iakovenkos c930acd
clean-up + typed databus tests
iakovenkos 5c5e2bd
Merge branch 'master' into si/sumcheck-with-disabled-rows
iakovenkos f408141
4 rows disabled + clean-up
iakovenkos 241cfb6
LookupReadCounts fix
iakovenkos f352204
Merge branch 'master' into si/sumcheck-with-disabled-rows
iakovenkos 2c729f6
eccvm fixed
iakovenkos 4543602
removed print statements
iakovenkos 6676030
docs upd
iakovenkos 7ecca7b
Merge branch 'si/sumcheck-with-disabled-rows' of github.com:AztecProt…
iakovenkos 3abc971
Merge branch 'master' into si/sumcheck-with-disabled-rows
iakovenkos c96f1a0
removed print statements
iakovenkos 377169d
small fixes
iakovenkos 8d53049
Merge branch 'master' into si/sumcheck-with-disabled-rows
iakovenkos 0ea2ddd
-empty line
iakovenkos d8f5f59
clean-up
iakovenkos b651bfa
Merge branch 'master' into si/sumcheck-with-disabled-rows
iakovenkos 1dfbd6c
removed print
iakovenkos f2f4da0
resolved comments
iakovenkos 02b3696
Merge branch 'master' into si/sumcheck-with-disabled-rows
iakovenkos b290c54
removed redundant print
iakovenkos 354e5f2
Merge branch 'master' into si/sumcheck-with-disabled-rows
iakovenkos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
179 changes: 179 additions & 0 deletions
179
barretenberg/cpp/src/barretenberg/polynomials/row_disabling_polynomial.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,179 @@ | ||
| #pragma once | ||
| #include "barretenberg/common/compiler_hints.hpp" | ||
| #include "barretenberg/common/op_count.hpp" | ||
| #include "barretenberg/common/thread.hpp" | ||
| #include "barretenberg/stdlib/primitives/bool/bool.hpp" | ||
|
|
||
| #include <cstddef> | ||
| #include <vector> | ||
| namespace bb { | ||
| /** | ||
| * @struct RowDisablingPolynomial | ||
| * @brief Polynomial for Sumcheck with disabled Rows | ||
| * | ||
| * \f$ n = 2^d \f$ circuit size | ||
| * \f$ L_i \f$ multilinear Lagrange in \f$ d \f$ variables, \f$ i = 0,\ldots, n-1 \f$. | ||
| * | ||
| * Assume we are given a "valid" execution trace at rows \f$ 0,\ldots, n-5 \f$, i.e., | ||
| * \f[ | ||
| * \sum_{\mathbb{H} \setminus \{n-1, n-2, n-3, n-4\}} H = 0. | ||
| * \f] | ||
| * | ||
| * We want to pad the witness polynomials with random field elements in rows \f$ n-1, n-2, n-3 \f$. | ||
| * Since the commitment to the shift must coincide with the commitment to its unshifted counterpart, | ||
| * we have to reserve \f$ 4 \f$ rows at the end to be able to. | ||
| * To achieve this, we multiply the Honk relation \f$ H \f$ by the polynomial | ||
| * \f[ | ||
| * 1 - L = 1 - L_{n-1} - L_{n-2} - L_{n-3} - L_{n-4}. | ||
| * \f] | ||
| * that vanishes at the last \f$ 4 \f$ rows and is equal to \f$ 1 \f$ everywhere else on the hypercube. | ||
| * | ||
| * We consider the sumcheck protocol for the modified relation | ||
| * \f[ | ||
| * \sum_{\mathbb{H}} (1 - L) H = \sum_{\mathbb{H}} H - \sum_{\mathbb{H}} L \cdot H. | ||
| * \f] | ||
| * | ||
| * Note that the target sum remains \f$ 0 \f$ because the contributions from the last rows are multiplied by \f$ 0 \f$. | ||
| * | ||
| * Recall: | ||
| * - \f$ n-1 = 2^d - 1 = (1,1, \ldots, 1) \f$ | ||
| * - \f$ n-2 = (0,1,\ldots,1) \f$ | ||
| * - \f$ n-3 = (1,0,\ldots,1) \f$ | ||
| * - \f$ n-4 = (0,0,\ldots,1) \f$ | ||
| * | ||
| * ### Round 0: | ||
| * \f[ | ||
| * \begin{aligned} | ||
| * S' &= | ||
| * S_{H,0} - \Big(L_{n-1}(X, 1, \ldots, 1) + L_{n-2}(X, 1,\ldots,1)\Big) H(X,1,\ldots, 1) \\ | ||
| * &\quad - \Big(L_{n-3}(X, 0,1,\ldots,1) + L_{n-4}(X,0,1,\ldots,1)\Big) H(X,0,1,\ldots,1) | ||
| * \end{aligned} | ||
| * \f] | ||
| * | ||
| * We do not modify the algorithm computing \f$ S_{H,0} \f$. Simply add a method that computes the contribution from the | ||
| * edges \f$ (0,1,\ldots,1) \f$ and \f$ (1,\ldots,1) \in \mathbb{H}^{d-1} \f$. | ||
| * | ||
| * First, compute the coefficients in the Lagrange basis of the factor coming from the Lagranges: | ||
| * \f[ | ||
| * \begin{aligned} | ||
| * L_{n-1}(X,\vec{1}) + L_{n-2}(X,\vec{1}) &= X + (1 - X) = 1 \\ | ||
| * L_{n-3}(X,0,1,\ldots,1) + L_{n-4}(X,0,1,\ldots,1) &= 1 | ||
| * \end{aligned} | ||
| * \f] | ||
| * | ||
| * \f[ | ||
| * S'_0 = S_{H,0} - H(X,1,\ldots,1) - H(X,0,1,\ldots,1) | ||
| * \f] | ||
| * | ||
| * ### Round 1: | ||
| * \f[ | ||
| * \begin{aligned} | ||
| * L_{n-1}(u_0,X,\vec{1}) + L_{n-2}(u_0,X,\vec{1}) &= | ||
| * u_0 X + (1 - u_0) X = X \\ | ||
| * L_{n-3}(u_0,X,\vec{1}) + L_{n-4}(u_0,X,\vec{1}) &= | ||
| * u_0 (1 - X) + (1 - u_0)(1 - X) = (1 - X) | ||
| * \end{aligned} | ||
| * \f] | ||
| * | ||
| * \f[ | ||
| * S'_1 = S_{H,1} - H(X,1,\ldots,1) | ||
| * \f] | ||
| * | ||
| * ### Round 2: | ||
| * \f[ | ||
| * S'_2 = S_{H,2} - X \cdot H(u_0,u_1,X,1,\ldots,1) | ||
| * \f] | ||
| * | ||
| * ### Rounds i > 1: | ||
| * We can compute the restricted sumcheck univariates \f$ S' \f$ in each round as follows: | ||
| * \f[ | ||
| * \begin{aligned} | ||
| * S' = S_{H,i} - | ||
| * \Big(L_{n-1}(u_0, \ldots, u_{i-1}, X, 1, \ldots, 1) + L_{n-2}(u_0, \ldots, u_{i-1}, X, 1,\ldots,1) \\ | ||
| * + L_{n-3}(u_0, \ldots, u_{i-1}, X, 1,\ldots,1) + L_{n-4}(u_0, \ldots, u_{i-1}, X, 1,\ldots,1)\Big) \\ | ||
| * \times H(u_0, \ldots, u_{i-1}, X, 1,\ldots,1) | ||
| * \end{aligned} | ||
| * \f] | ||
| * | ||
| * Compute the factor coming from the Lagranges: | ||
| * \f[ | ||
| * \begin{aligned} | ||
| * &\left(u_0 \cdots u_{i-1} + (1 - u_0) u_1 \cdots u_{i-1} + u_0 (1 - u_1) u_2 \cdots u_{i-1} + (1 - u_0)(1 - u_1) u_2 | ||
| * \cdots u_{i-1}\right) X \\ | ||
| * &= \left(u_0 u_1 + (1 - u_0) u_1 + u_0 (1 - u_1) + (1 - u_0)(1 - u_1)\right) u_2 \cdots u_{i-1} X \\ | ||
| * &= 0 \cdot (1 - X) + 1 \cdot u_2 \cdots u_{i-1} \cdot X | ||
| * \end{aligned} | ||
| * \f] | ||
| * | ||
| * This way, we get: | ||
| * \f[ | ||
| * S_{H,i}(X) = S_{H,i} - u_2 \cdots u_{i-1} \cdot X \cdot H(u_0, \ldots, u_{i-1}, X, 1, \ldots, 1). | ||
| * \f] | ||
| * | ||
| * ## The algorithm: | ||
| * | ||
| * Let \f$ D \f$ be the max partial degree of \f$ H \f$. | ||
| * | ||
| * 1. Compute \f$ S_{H,i} \f$ without any modifications as a polynomial of degree \f$ D \f$. Extend it to degree \f$ D + | ||
| * 1 \f$, because it is the max partial degree of \f$ L \cdot H \f$. | ||
| * | ||
| * 2. If \f$ i = 0 \f$, compute \f$ H(X,1,1,\ldots,1) + H(X,0,1,\ldots,1) \f$ as a univariate of degree \f$ D \f$, else | ||
| * compute \f$ H(u_0, \ldots, u_{i-1}, X, 1, \ldots, 1) \f$ as a univariate of degree \f$ D \f$. Extend to degree \f$ D | ||
| * + 1 \f$. | ||
| * | ||
| * 3. Compute the extension of \f$ L^{(i)} = L(u_0, \ldots, u_{i-1}, X, 1, \ldots, 1) \f$ to the degree \f$ D + 1 \f$ | ||
| * polynomial. | ||
| * | ||
| * 4. Compute the coefficients of the product \f$ L^{(i)} \cdot H^{(i)} \f$. | ||
| * | ||
| * 5. Compute the coefficients of \f$ S_{H,i} - L^{(i)} \cdot H^{(i)} \f$ (degree \f$ D + 1 \f$ univariate). | ||
| * | ||
| * The verifier needs to evaluate \f$ 1 - L(u_0, \ldots, u_{d-1}) \f$, which is equal to \f$ 0 \f$ if \f$ d < 2 \f$, and | ||
| * is equal to \f$ 1- u_2 \cdots u_{d-1} \f$ otherwise. | ||
| */ | ||
|
|
||
| template <typename FF> struct RowDisablingPolynomial { | ||
| // initialized as a constant linear polynomial = 1 | ||
| FF eval_at_0{ 1 }; | ||
| FF eval_at_1{ 1 }; | ||
|
|
||
| RowDisablingPolynomial() = default; | ||
| /** | ||
| * @brief Compute the evaluations of L^{(i)} at 0 and 1. | ||
| * | ||
| * @details In every round, the contribution from the Honk relation computed at | ||
| * disabled rows has to be mutiplied by \f$ L^{(i)} \f$, which is a linear combination of Lagrange polynomials | ||
| * defined above. | ||
| * | ||
| * @param round_challenge Sumcheck round challenge | ||
| * @param round_idx Sumcheck round index | ||
| */ | ||
| void update_evaluations(FF round_challenge, size_t round_idx) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add function docs please for this and below |
||
| { | ||
| if (round_idx == 1) { | ||
| eval_at_0 = FF{ 0 }; | ||
| } | ||
| if (round_idx >= 2) { | ||
| eval_at_1 *= round_challenge; | ||
| } | ||
| } | ||
| /** | ||
| * @brief Compute the evaluation of \f$ 1 - L \f$ at the sumcheck challenge | ||
| * | ||
| * @param multivariate_challenge | ||
| * @param log_circuit_size | ||
| * @return FF | ||
| */ | ||
| static FF evaluate_at_challenge(std::vector<FF> multivariate_challenge, const size_t log_circuit_size) | ||
| { | ||
| FF evaluation_at_multivariate_challenge{ 1 }; | ||
|
|
||
| for (size_t idx = 2; idx < log_circuit_size; idx++) { | ||
| evaluation_at_multivariate_challenge *= multivariate_challenge[idx]; | ||
| } | ||
|
|
||
| return FF{ 1 } - evaluation_at_multivariate_challenge; | ||
| } | ||
| }; | ||
|
|
||
| } // namespace bb | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's like that someone modifying the
table_offsetis not going to be exactly aware of this additional MASKING_OFFSET and all the places it has to be modified so I wonder if subtractions can be unified a bit.