-
Notifications
You must be signed in to change notification settings - Fork 614
feat: zk sumcheck #7517
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
feat: zk sumcheck #7517
Changes from 21 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
36523c1
added changes to flavors, relation_types.hpp and flavor.hpp
iakovenkos 4692e4c
Expanded docs and added UltraFlavorWithZK
iakovenkos da478a6
fix: added NUM_ALL_WITNESSES to AvmFlavor
iakovenkos ffdf418
feat: added zk sumcheck, need to expand the docs
iakovenkos 573f13c
docs: updated sumcheck_outline.md and inline docs
iakovenkos be77077
Merge branch 'master' into adjust-flavors-and-relation-types-to-zk-su…
iakovenkos ec0bfc7
fixed tests and gcc build issues
iakovenkos 0fbf781
resolved comments
iakovenkos 051a966
Merge branch 'adjust-flavors-and-relation-types-to-zk-sumcheck' of gi…
iakovenkos afa284e
refactor: added get_shifted_witnesses and AllWitnessEntities
iakovenkos 74cf2e7
Merge remote-tracking branch 'origin/master' into adjust-flavors-and-…
iakovenkos 2487f75
Merge branch 'adjust-flavors-and-relation-types-to-zk-sumcheck' into …
iakovenkos 63bd81b
wip: fixing build issues
iakovenkos d449355
refactor: AllEntities and ShiftedEntities in Mega and Ultra
iakovenkos c5fab2b
Merge branch 'adjust-flavors-and-relation-types-to-zk-sumcheck' into …
iakovenkos 4dbae08
fixed issues
iakovenkos eaeca2d
Merge branch 'adjust-flavors-and-relation-types-to-zk-sumcheck' into …
iakovenkos 14fb4e1
wip: resolving comments
iakovenkos c2bf3f6
docs fix
iakovenkos 0c07e19
fixed gcc added libra evals to sumcheck output
iakovenkos 2002fe3
Merge branch 'adjust-flavors-and-relation-types-to-zk-sumcheck' into …
iakovenkos 1dd93cc
comments resolved branch updated
iakovenkos 94c95f3
comments resolved
iakovenkos e75c4f9
Merge branch 'master' into si/zk-sumcheck-and-sumcheck-tests
iakovenkos 70d04c9
Merge branch 'master' into si/zk-sumcheck-and-sumcheck-tests
iakovenkos 332eab9
simplified HasZK concept
iakovenkos f6916b9
Merge branch 'master' into si/zk-sumcheck-and-sumcheck-tests
iakovenkos c62a745
Merge branch 'master' into si/zk-sumcheck-and-sumcheck-tests
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,7 +48,7 @@ | |
| * @note It would be ideal to codify more structure in these base class template and to have it imposed on the actual | ||
| * flavors, but our inheritance model is complicated as it is, and we saw no reasonable way to fix this. | ||
| * | ||
| * @note One asymmetry to note is in the use of the term "key". It is worthwhile to distinguish betwen prover/verifier | ||
| * @note One asymmetry to note is in the use of the term "key". It is worthwhile to distinguish between prover/verifier | ||
| * circuit data, and "keys" that consist of such data augmented with witness data (whether, raw, blinded, or polynomial | ||
| * commitments). Currently the proving key contains witness data, while the verification key does not. | ||
| * TODO(Cody): It would be nice to resolve this but it's not essential. | ||
|
|
@@ -292,6 +292,27 @@ template <typename Tuple, std::size_t Index = 0> static constexpr size_t compute | |
| return subrelations_in_relation + compute_number_of_subrelations<Tuple, Index + 1>(); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @brief Takes a Tuple of objects in the Relation class and recursively computes the maximum among partial | ||
| * subrelation lengths incremented by corresponding subrelation witness degrees over all | ||
| * subrelations of given relations. This method is required to compute the size of | ||
| * Round Univariates in ZK Sumcheck. | ||
| * @tparam Tuple | ||
| * @tparam Index | ||
| * @return constexpr size_t | ||
| */ | ||
| template <typename Tuple, std::size_t Index = 0> static constexpr size_t compute_max_total_zk_relation_length() | ||
| { | ||
| if constexpr (Index >= std::tuple_size<Tuple>::value) { | ||
| return 0; // Return 0 when reach end of the tuple | ||
| } else { | ||
| constexpr size_t current_zk_length = std::tuple_element<Index, Tuple>::type::ZK_TOTAL_RELATION_LENGTH; | ||
| constexpr size_t next_zk_length = compute_max_total_zk_relation_length<Tuple, Index + 1>(); | ||
| return (current_zk_length > next_zk_length) ? current_zk_length : next_zk_length; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @brief Recursive utility function to construct a container for the subrelation accumulators of Protogalaxy folding. | ||
| * @details The size of the outer tuple is equal to the number of relations. Each relation contributes an inner tuple of | ||
|
|
@@ -334,6 +355,26 @@ template <typename Tuple, std::size_t Index = 0> static constexpr auto create_su | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * @brief Recursive utility function to construct a container for the subrelation accumulators of ZK Sumcheck prover. | ||
| * @details The size of the outer tuple is equal to the number of relations. Each relation contributes an inner tuple of | ||
| * univariates whose size is equal to the number of subrelations of the relation. The length of a univariate in an inner | ||
| * tuple is determined by the corresponding zk subrelation length, i.e. by the subrelation partial length corrected by | ||
| * the corresponding witness degree. | ||
| */ | ||
| template <typename Tuple, std::size_t Index = 0> | ||
| static constexpr auto create_zk_sumcheck_tuple_of_tuples_of_univariates() | ||
| { | ||
| if constexpr (Index >= std::tuple_size<Tuple>::value) { | ||
| return std::tuple<>{}; // Return empty when reach end of the tuple | ||
| } else { | ||
| using UnivariateTuple = | ||
| typename std::tuple_element_t<Index, Tuple>::ZKSumcheckTupleOfUnivariatesOverSubrelations; | ||
| return std::tuple_cat(std::tuple<UnivariateTuple>{}, | ||
| create_zk_sumcheck_tuple_of_tuples_of_univariates<Tuple, Index + 1>()); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @brief Recursive utility function to construct tuple of arrays | ||
| * @details Container for storing value of each identity in each relation. Each Relation contributes an array of | ||
|
|
@@ -354,6 +395,7 @@ template <typename Tuple, std::size_t Index = 0> static constexpr auto create_tu | |
| // Forward declare honk flavors | ||
| namespace bb { | ||
| class UltraFlavor; | ||
| class UltraFlavorWithZK; | ||
| class ECCVMFlavor; | ||
| class UltraKeccakFlavor; | ||
| class MegaFlavor; | ||
|
|
@@ -387,13 +429,13 @@ template <typename T> | |
| concept IsUltraPlonkFlavor = IsAnyOf<T, plonk::flavor::Ultra, UltraKeccakFlavor>; | ||
|
|
||
| template <typename T> | ||
| concept IsUltraPlonkOrHonk = IsAnyOf<T, plonk::flavor::Ultra, UltraFlavor, UltraKeccakFlavor, MegaFlavor>; | ||
| concept IsUltraPlonkOrHonk = IsAnyOf<T, plonk::flavor::Ultra, UltraFlavor, UltraKeccakFlavor, UltraFlavorWithZK, MegaFlavor>; | ||
|
|
||
| template <typename T> | ||
| concept IsHonkFlavor = IsAnyOf<T, UltraFlavor, UltraKeccakFlavor, MegaFlavor>; | ||
| concept IsHonkFlavor = IsAnyOf<T, UltraFlavor, UltraKeccakFlavor, UltraFlavorWithZK, MegaFlavor>; | ||
|
|
||
| template <typename T> | ||
| concept IsUltraFlavor = IsAnyOf<T, UltraFlavor, UltraKeccakFlavor, MegaFlavor>; | ||
| concept IsUltraFlavor = IsAnyOf<T, UltraFlavor, UltraKeccakFlavor, UltraFlavorWithZK, MegaFlavor>; | ||
|
|
||
| template <typename T> | ||
| concept IsGoblinFlavor = IsAnyOf<T, MegaFlavor, | ||
|
|
@@ -420,12 +462,19 @@ template <typename T> concept IsGrumpkinFlavor = IsAnyOf<T, ECCVMFlavor>; | |
| template <typename T> concept IsFoldingFlavor = IsAnyOf<T, UltraFlavor, | ||
| // Note(md): must be here to use oink prover | ||
| UltraKeccakFlavor, | ||
| UltraFlavorWithZK, | ||
| MegaFlavor, | ||
| UltraRecursiveFlavor_<UltraCircuitBuilder>, | ||
| UltraRecursiveFlavor_<MegaCircuitBuilder>, | ||
| UltraRecursiveFlavor_<CircuitSimulatorBN254>, | ||
| MegaRecursiveFlavor_<UltraCircuitBuilder>, | ||
| MegaRecursiveFlavor_<MegaCircuitBuilder>, MegaRecursiveFlavor_<CircuitSimulatorBN254>>; | ||
| template <typename T> | ||
|
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. why do you need this concept to be so complicated? |
||
| concept FlavorHasZK = requires { | ||
| { | ||
| T::HasZK | ||
| } -> std::convertible_to<bool>; | ||
| } && T::HasZK; | ||
|
|
||
| template <typename Container, typename Element> | ||
| inline std::string flavor_get_label(Container&& container, const Element& element) { | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.