-
Notifications
You must be signed in to change notification settings - Fork 94
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
Cg/move to shared #294
Merged
Merged
Cg/move to shared #294
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4cf73ab
Move circuit constructors to shared.
codygunton d2c7be7
Move helper lib and perm helper.
codygunton 77656c2
Move tmp composers and helpers for plonk.
codygunton a251141
Fix namespace and red herring comment.
codygunton 08d3509
Remove pointless namespace declaration.
codygunton 019f3d1
Fix more namespaces.
codygunton 966a186
Split flavor
codygunton e84d33c
Rename tests to avoid ambiguity.
codygunton 4f07a75
Remove redundant macro defs.
codygunton 0ffca09
Fix comment formatting.
codygunton 18c6def
StandardArithmetization is not shared with plonk.
codygunton 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
2 changes: 1 addition & 1 deletion
2
cpp/src/barretenberg/honk/composer/composer_helper/standard_honk_composer_helper.cpp
This file contains 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 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
4 changes: 2 additions & 2 deletions
4
cpp/src/barretenberg/honk/composer/standard_honk_composer.hpp
This file contains 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
2 changes: 1 addition & 1 deletion
2
cpp/src/barretenberg/honk/composer/standard_honk_composer.test.cpp
This file contains 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 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,188 @@ | ||
#pragma once | ||
#include <array> | ||
#include <string> | ||
#include "barretenberg/common/log.hpp" | ||
#include "barretenberg/transcript/manifest.hpp" | ||
|
||
// TODO(Cody): "bonk" is short for "both plonk and honk". Just need a short and non-vague temporary name. | ||
namespace bonk { | ||
struct StandardArithmetization { | ||
/** | ||
* @brief All of the multivariate polynomials used by the Standard Honk Prover. | ||
* @details The polynomials are broken into three categories: precomputed, witness, and shifted. | ||
* This separation must be maintained to allow for programmatic access, but the ordering of the | ||
* polynomials can be permuted within each category if necessary. Polynomials can also be added | ||
* or removed (assuming consistency with the prover algorithm) but the constants describing the | ||
* number of poynomials in each category must be manually updated. | ||
* | ||
*/ | ||
enum POLYNOMIAL { | ||
/* --- PRECOMPUTED POLYNOMIALS --- */ | ||
Q_C, | ||
Q_L, | ||
Q_R, | ||
Q_O, | ||
Q_M, | ||
SIGMA_1, | ||
SIGMA_2, | ||
SIGMA_3, | ||
ID_1, | ||
ID_2, | ||
ID_3, | ||
LAGRANGE_FIRST, | ||
LAGRANGE_LAST, // = LAGRANGE_N-1 whithout ZK, but can be less | ||
/* --- WITNESS POLYNOMIALS --- */ | ||
W_L, | ||
W_R, | ||
W_O, | ||
Z_PERM, | ||
/* --- SHIFTED POLYNOMIALS --- */ | ||
Z_PERM_SHIFT, | ||
/* --- --- */ | ||
COUNT // for programmatic determination of NUM_POLYNOMIALS | ||
}; | ||
|
||
static constexpr size_t NUM_POLYNOMIALS = POLYNOMIAL::COUNT; | ||
static constexpr size_t NUM_SHIFTED_POLYNOMIALS = 1; | ||
static constexpr size_t NUM_PRECOMPUTED_POLYNOMIALS = 13; | ||
static constexpr size_t NUM_UNSHIFTED_POLYNOMIALS = NUM_POLYNOMIALS - NUM_SHIFTED_POLYNOMIALS; | ||
|
||
// *** WARNING: The order of this array must be manually updated to match POLYNOMIAL enum *** | ||
// TODO(luke): This is a temporary measure to associate the above enum with sting tags. Its only needed because | ||
// the | ||
// polynomials/commitments in the prover/verifier are stored in maps. This storage could be converted to simple | ||
// arrays at which point these string tags can be removed. | ||
inline static const std::array<std::string, 18> ENUM_TO_COMM = { | ||
"Q_C", "Q_1", "Q_2", "Q_3", "Q_M", "SIGMA_1", | ||
"SIGMA_2", "SIGMA_3", "ID_1", "ID_2", "ID_3", "LAGRANGE_FIRST", | ||
"LAGRANGE_LAST", "W_1", "W_2", "W_3", "Z_PERM", "Z_PERM_SHIFT" | ||
}; | ||
}; | ||
} // namespace bonk | ||
|
||
namespace honk { | ||
struct StandardHonk { | ||
public: | ||
using Arithmetization = bonk::StandardArithmetization; | ||
using MULTIVARIATE = Arithmetization::POLYNOMIAL; | ||
// // TODO(Cody): Where to specify? is this polynomial manifest size? | ||
// static constexpr size_t STANDARD_HONK_MANIFEST_SIZE = 16; | ||
// TODO(Cody): Maybe relation should be supplied and this should be computed as is done in sumcheck? | ||
// Then honk::StandardHonk (or whatever we rename it) would become an alias for a Honk flavor with a | ||
// certain set of parameters, including the relations? | ||
static constexpr size_t MAX_RELATION_LENGTH = 5; | ||
|
||
// TODO(Cody): should extract this from the parameter pack. Maybe that should be done here? | ||
|
||
// num_sumcheck_rounds = 1 if using quotient polynomials, otherwise = number of sumcheck rounds | ||
static transcript::Manifest create_manifest(const size_t num_public_inputs, const size_t num_sumcheck_rounds = 1) | ||
{ | ||
constexpr size_t g1_size = 64; | ||
constexpr size_t fr_size = 32; | ||
const size_t public_input_size = fr_size * num_public_inputs; | ||
// clang-format off | ||
/* A RoundManifest describes data that will be put in or extracted from a transcript. | ||
Here we have (1 + 7 + num_sumcheck_rounds)-many RoundManifests. */ | ||
std::vector<transcript::Manifest::RoundManifest> manifest_rounds; | ||
|
||
// Round 0 | ||
manifest_rounds.emplace_back(transcript::Manifest::RoundManifest( | ||
{ | ||
{ .name = "circuit_size", .num_bytes = 4, .derived_by_verifier = true }, | ||
{ .name = "public_input_size", .num_bytes = 4, .derived_by_verifier = true } | ||
}, | ||
/* challenge_name = */ "init", | ||
/* num_challenges_in = */ 1)); | ||
|
||
// Round 1 | ||
manifest_rounds.emplace_back(transcript::Manifest::RoundManifest( | ||
{ /* this is a noop */ }, | ||
/* challenge_name = */ "eta", | ||
/* num_challenges_in = */ 0)); | ||
|
||
// Round 2 | ||
manifest_rounds.emplace_back(transcript::Manifest::RoundManifest( | ||
{ | ||
{ .name = "public_inputs", .num_bytes = public_input_size, .derived_by_verifier = false }, | ||
{ .name = "W_1", .num_bytes = g1_size, .derived_by_verifier = false }, | ||
{ .name = "W_2", .num_bytes = g1_size, .derived_by_verifier = false }, | ||
{ .name = "W_3", .num_bytes = g1_size, .derived_by_verifier = false }, | ||
}, | ||
/* challenge_name = */ "beta", | ||
/* num_challenges_in = */ 2) // also produce "gamma" | ||
); | ||
|
||
// Round 3 | ||
manifest_rounds.emplace_back(transcript::Manifest::RoundManifest( | ||
{ { .name = "Z_PERM", .num_bytes = g1_size, .derived_by_verifier = false } }, | ||
/* challenge_name = */ "alpha", | ||
/* num_challenges_in = */ 2) | ||
); | ||
|
||
// Rounds 4, ... 4 + num_sumcheck_rounds-1 | ||
for (size_t i = 0; i < num_sumcheck_rounds; i++) { | ||
auto label = std::to_string(i); | ||
manifest_rounds.emplace_back( | ||
transcript::Manifest::RoundManifest( | ||
{ | ||
{ .name = "univariate_" + label, .num_bytes = fr_size * honk::StandardHonk::MAX_RELATION_LENGTH, .derived_by_verifier = false } | ||
}, | ||
/* challenge_name = */ "u_" + label, | ||
/* num_challenges_in = */ 1)); | ||
} | ||
|
||
// Round 5 + num_sumcheck_rounds | ||
manifest_rounds.emplace_back(transcript::Manifest::RoundManifest( | ||
{ | ||
{ .name = "multivariate_evaluations", .num_bytes = fr_size * bonk::StandardArithmetization::NUM_POLYNOMIALS, .derived_by_verifier = false, .challenge_map_index = 0 }, | ||
}, | ||
/* challenge_name = */ "rho", | ||
/* num_challenges_in = */ 1)); /* TODO(Cody): magic number! Where should this be specified? */ | ||
|
||
// Rounds 6 + num_sumcheck_rounds, ... , 6 + 2 * num_sumcheck_rounds - 1 | ||
std::vector<transcript::Manifest::ManifestEntry> fold_commitment_entries; | ||
for (size_t i = 1; i < num_sumcheck_rounds; i++) { | ||
fold_commitment_entries.emplace_back(transcript::Manifest::ManifestEntry( | ||
{ .name = "FOLD_" + std::to_string(i), .num_bytes = g1_size, .derived_by_verifier = false })); | ||
}; | ||
manifest_rounds.emplace_back(transcript::Manifest::RoundManifest( | ||
fold_commitment_entries, | ||
/* challenge_name = */ "r", | ||
/* num_challenges_in */ 1)); | ||
|
||
// Rounds 6 + 2 * num_sumcheck_rounds, ..., 6 + 3 * num_sumcheck_rounds | ||
std::vector<transcript::Manifest::ManifestEntry> gemini_evaluation_entries; | ||
for (size_t i = 0; i < num_sumcheck_rounds; i++) { | ||
gemini_evaluation_entries.emplace_back(transcript::Manifest::ManifestEntry( | ||
{ .name = "a_" + std::to_string(i), .num_bytes = fr_size, .derived_by_verifier = false })); | ||
}; | ||
manifest_rounds.emplace_back(transcript::Manifest::RoundManifest( | ||
gemini_evaluation_entries, | ||
/* challenge_name = */ "nu", | ||
/* num_challenges_in */ 1)); | ||
|
||
// Round 7 + 3 * num_sumcheck_rounds | ||
manifest_rounds.emplace_back( | ||
transcript::Manifest::RoundManifest( | ||
{ | ||
{ .name = "Q", .num_bytes = g1_size, .derived_by_verifier = false } | ||
}, | ||
/* challenge_name = */ "z", | ||
/* num_challenges_in */ 1)); | ||
|
||
// Round 8 + 3 * num_sumcheck_rounds | ||
manifest_rounds.emplace_back( | ||
transcript::Manifest::RoundManifest( | ||
{ | ||
{ .name = "W", .num_bytes = g1_size, .derived_by_verifier = false } | ||
}, | ||
/* challenge_name = */ "separator", | ||
/* num_challenges_in */ 1)); | ||
|
||
// clang-format on | ||
|
||
auto output = transcript::Manifest(manifest_rounds); | ||
return output; | ||
} | ||
}; | ||
} // namespace honk |
This file contains 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,30 @@ | ||
#include "flavor.hpp" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
namespace test_flavor { | ||
|
||
// // TODO(Cody) This seems like a good idea, but I'm not sure why. | ||
// TEST(Flavor, StandardArithmetization){ | ||
// EXPECT_EQ(StandardArithmetization::MULTIVARIATE::W_L, 0); | ||
// EXPECT_EQ(StandardArithmetization::MULTIVARIATE::W_R, 1); | ||
// EXPECT_EQ(StandardArithmetization::MULTIVARIATE::W_O, 2); | ||
// EXPECT_EQ(StandardArithmetization::MULTIVARIATE::Z_PERM, 3); | ||
// EXPECT_EQ(StandardArithmetization::MULTIVARIATE::Z_PERM_SHIFT, 4); | ||
// EXPECT_EQ(StandardArithmetization::MULTIVARIATE::Q_M, 5); | ||
// EXPECT_EQ(StandardArithmetization::MULTIVARIATE::Q_L, 6); | ||
// EXPECT_EQ(StandardArithmetization::MULTIVARIATE::Q_R, 7); | ||
// EXPECT_EQ(StandardArithmetization::MULTIVARIATE::Q_O, 8); | ||
// EXPECT_EQ(StandardArithmetization::MULTIVARIATE::Q_C, 9); | ||
// EXPECT_EQ(StandardArithmetization::MULTIVARIATE::SIGMA_1, 10); | ||
// EXPECT_EQ(StandardArithmetization::MULTIVARIATE::SIGMA_2, 11); | ||
// EXPECT_EQ(StandardArithmetization::MULTIVARIATE::SIGMA_3, 12); | ||
// EXPECT_EQ(StandardArithmetization::MULTIVARIATE::ID_1, 13); | ||
// EXPECT_EQ(StandardArithmetization::MULTIVARIATE::ID_2, 14); | ||
// EXPECT_EQ(StandardArithmetization::MULTIVARIATE::ID_3, 15); | ||
// EXPECT_EQ(StandardArithmetization::MULTIVARIATE::LAGRANGE_FIRST, 16); | ||
// EXPECT_EQ(StandardArithmetization::MULTIVARIATE::COUNT, 17); | ||
|
||
// } | ||
|
||
} // namespace test_flavor |
This file contains 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 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 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 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 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 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 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 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
2 changes: 1 addition & 1 deletion
2
cpp/src/barretenberg/honk/sumcheck/relations/grand_product_initialization_relation.hpp
This file contains 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 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 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.
Formatting hook changed this for an unknown reason, so I reformatted to something clear that the formatter would accept.