-
Notifications
You must be signed in to change notification settings - Fork 310
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
feat: update to protogalaxy interfaces #2498
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cf18c69
more wip
maramihali 2d0bd07
linker errrors :(
maramihali 99504a5
it links and builds <3
maramihali 77e2e7f
Merge branch 'master' into mm/pg-interfaces-update
maramihali 93cdec5
Merge branch 'master' into mm/pg-interfaces-update
maramihali 02a11a7
make gcc happy
maramihali a70d67c
Merge branch 'master' into mm/pg-interfaces-update
maramihali 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 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
48 changes: 48 additions & 0 deletions
48
barretenberg/cpp/src/barretenberg/honk/instance/instances.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#pragma once | ||
#include "barretenberg/honk/instance/prover_instance.hpp" | ||
#include "barretenberg/honk/instance/verifier_instance.hpp" | ||
namespace proof_system::honk { | ||
|
||
template <typename Flavor_, size_t NUM_> struct ProverInstances_ { | ||
using Flavor = Flavor_; | ||
using Instance = ProverInstance_<Flavor>; | ||
using ArrayType = std::array<std::shared_ptr<Instance>, NUM_>; | ||
|
||
public: | ||
static constexpr size_t NUM = NUM_; | ||
ArrayType _data; | ||
Instance const& operator[](size_t idx) const { return _data[idx]; } | ||
typename ArrayType::iterator begin() { return _data.begin(); }; | ||
typename ArrayType::iterator end() { return _data.end(); }; | ||
ProverInstances_(std::vector<std::shared_ptr<Instance>> data) | ||
{ | ||
ASSERT(data.size() == NUM); | ||
for (size_t idx = 0; idx < data.size(); idx++) { | ||
_data[idx] = std::move(data[idx]); | ||
} | ||
}; | ||
}; | ||
|
||
template <typename Flavor_, size_t NUM_> struct VerifierInstances_ { | ||
using Flavor = Flavor_; | ||
using VerificationKey = typename Flavor::VerificationKey; | ||
using Instance = VerifierInstance_<Flavor>; | ||
using ArrayType = std::array<Instance, NUM_>; | ||
|
||
public: | ||
static constexpr size_t NUM = NUM_; | ||
ArrayType _data; | ||
Instance const& operator[](size_t idx) const { return _data[idx]; } | ||
typename ArrayType::iterator begin() { return _data.begin(); }; | ||
typename ArrayType::iterator end() { return _data.end(); }; | ||
VerifierInstances_(std::vector<std::shared_ptr<VerificationKey>> vks) | ||
{ | ||
ASSERT(vks.size() == NUM); | ||
for (size_t idx = 0; idx < vks.size(); idx++) { | ||
Instance inst; | ||
inst.verification_key = std::move(vks[idx]); | ||
_data[idx] = inst; | ||
} | ||
}; | ||
}; | ||
} // namespace proof_system::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
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
36 changes: 17 additions & 19 deletions
36
barretenberg/cpp/src/barretenberg/honk/proof_system/protogalaxy_prover.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,52 @@ | ||
#include "protogalaxy_prover.hpp" | ||
#include "barretenberg/proof_system/flavor/flavor.hpp" | ||
namespace proof_system::honk { | ||
template <class Flavor> | ||
ProtoGalaxyProver_<Flavor>::ProtoGalaxyProver_(std::vector<std::shared_ptr<Instance>> insts) | ||
: instances(insts) | ||
{} | ||
|
||
/** | ||
* @brief Prior to folding we need to add all the public inputs to the transcript, labelled by their corresponding | ||
* instance index, compute all the instance's polynomials and record the relation parameters involved in computing these | ||
* polynomials in the transcript. | ||
* | ||
*/ | ||
template <class Flavor> void ProtoGalaxyProver_<Flavor>::prepare_for_folding() | ||
template <class ProverInstances> void ProtoGalaxyProver_<ProverInstances>::prepare_for_folding() | ||
{ | ||
for (const auto& instance : instances) { | ||
// this doesnt work in the current format | ||
auto idx = 0; | ||
for (auto it = instances.begin(); it != instances.end(); it++, idx++) { | ||
auto instance = *it; | ||
instance->initialise_prover_polynomials(); | ||
|
||
const auto instance_index = std::to_string(instance->index); | ||
auto domain_separator = std::to_string(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. we still need to domain separate information coming from different instances but now the index is not part of |
||
const auto circuit_size = static_cast<uint32_t>(instance->proving_key->circuit_size); | ||
const auto num_public_inputs = static_cast<uint32_t>(instance->proving_key->num_public_inputs); | ||
|
||
transcript.send_to_verifier(instance_index + "_circuit_size", circuit_size); | ||
transcript.send_to_verifier(instance_index + "_public_input_size", num_public_inputs); | ||
transcript.send_to_verifier(instance_index + "_pub_inputs_offset", | ||
transcript.send_to_verifier(domain_separator + "_circuit_size", circuit_size); | ||
transcript.send_to_verifier(domain_separator + "_public_input_size", num_public_inputs); | ||
transcript.send_to_verifier(domain_separator + "_pub_inputs_offset", | ||
static_cast<uint32_t>(instance->pub_inputs_offset)); | ||
|
||
for (size_t i = 0; i < instance->proving_key->num_public_inputs; ++i) { | ||
auto public_input_i = instance->public_inputs[i]; | ||
transcript.send_to_verifier(instance_index + "_public_input_" + std::to_string(i), public_input_i); | ||
transcript.send_to_verifier(domain_separator + "_public_input_" + std::to_string(i), public_input_i); | ||
} | ||
|
||
auto [eta, beta, gamma] = | ||
transcript.get_challenges(instance_index + "_eta", instance_index + "_beta", instance_index + "_gamma"); | ||
auto [eta, beta, gamma] = transcript.get_challenges( | ||
domain_separator + "_eta", domain_separator + "_beta", domain_separator + "_gamma"); | ||
instance->compute_sorted_accumulator_polynomials(eta); | ||
instance->compute_grand_product_polynomials(beta, gamma); | ||
} | ||
} | ||
|
||
// TODO(#689): implement this function | ||
template <class Flavor> ProverFoldingResult<Flavor> ProtoGalaxyProver_<Flavor>::fold_instances() | ||
template <class ProverInstances> | ||
ProverFoldingResult<typename ProverInstances::Flavor> ProtoGalaxyProver_<ProverInstances>::fold_instances() | ||
{ | ||
prepare_for_folding(); | ||
ProverFoldingResult<Flavor> res; | ||
res.folding_data = transcript.proof_data; | ||
return res; | ||
} | ||
|
||
template class ProtoGalaxyProver_<honk::flavor::Ultra>; | ||
template class ProtoGalaxyProver_<honk::flavor::UltraGrumpkin>; | ||
template class ProtoGalaxyProver_<honk::flavor::GoblinUltra>; | ||
|
||
template class ProtoGalaxyProver_<ProverInstances_<honk::flavor::Ultra, 2>>; | ||
template class ProtoGalaxyProver_<ProverInstances_<honk::flavor::UltraGrumpkin, 2>>; | ||
template class ProtoGalaxyProver_<ProverInstances_<honk::flavor::GoblinUltra, 2>>; | ||
} // namespace proof_system::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
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
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.
After fighting linker and compile errors having the create folding prover and verifier functions in the header and specify the numbers of instances to be folded in the composer (see above) seemed like the most reasonable thing to do. Very open to ways to improve this if there are any.