-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6987762
commit 8a7c7da
Showing
9 changed files
with
114 additions
and
28 deletions.
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
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
5 changes: 5 additions & 0 deletions
5
circuits/cpp/barretenberg/cpp/src/barretenberg/honk/instance/verifier_instance.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
1 change: 1 addition & 0 deletions
1
circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/folding_result.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
15 changes: 11 additions & 4 deletions
15
circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/protogalaxy_prover.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 |
---|---|---|
@@ -1,23 +1,30 @@ | ||
#pragma once | ||
#include "barretenberg/honk/flavor/goblin_ultra.hpp" | ||
#include "barretenberg/honk/flavor/ultra.hpp" | ||
#include "barretenberg/honk/flavor/ultra_grumpkin.hpp" | ||
#include "barretenberg/honk/instance/instance.hpp" | ||
#include "barretenberg/honk/proof_system/folding_result.hpp" | ||
#include "barretenberg/proof_system/flavor/flavor.hpp" | ||
#include "barretenberg/proof_system/folding_result.hpp" | ||
namespace proof_system::honk { | ||
template <UltraFlavor Flavor> class ProtoGalaxyProver_ { | ||
public: | ||
using FF = typename Flavor::FF; | ||
using Instance = Instance_<Flavor>; | ||
using ProverPolynomials = typename Flavor::ProverPolynomials; | ||
|
||
std::vector<Instance&> instances; | ||
std::vector<std::shared_ptr<Instance>> instances; | ||
|
||
ProverTranscript<FF> transcript; | ||
|
||
explicit ProtoGalaxyProver_(std::vector<Instance&>); | ||
explicit ProtoGalaxyProver_(std::vector<std::shared_ptr<Instance>>); | ||
|
||
void prepare_for_folding(); | ||
|
||
// TODO: implement this function | ||
ProverFoldingResult<Flavor> fold_instances(); | ||
}; | ||
|
||
extern template class ProtoGalaxyProver_<honk::flavor::Ultra>; | ||
extern template class ProtoGalaxyProver_<honk::flavor::UltraGrumpkin>; | ||
extern template class ProtoGalaxyProver_<honk::flavor::GoblinUltra>; | ||
// the folding prover returns the new prover polynomials and the new public inputs(does the verifier do anything) | ||
} // namespace proof_system::honk |
43 changes: 41 additions & 2 deletions
43
circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/protogalaxy_verifier.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,9 +1,48 @@ | ||
#include "protogalaxy_verifier.hpp" | ||
#include "barretenberg/honk/utils/grand_product_delta.hpp" | ||
namespace proof_system::honk { | ||
template <UltraFlavor Flavor> | ||
ProtoGalaxyVerifier_<Flavor>::ProtoGalaxyVerifier_(std::vector<VerificationKey> vks, std::vector<uint8_t> proof_data) | ||
ProtoGalaxyVerifier_<Flavor>::ProtoGalaxyVerifier_(std::vector<std::shared_ptr<VerificationKey>> vks) | ||
{ | ||
uint32_t idx = 0; | ||
for (const auto& vk : vks) { | ||
VerifierInstance inst; | ||
inst.verification_key = std::move(vk); | ||
inst.index = idx; | ||
verifier_instances.emplace_back(inst); | ||
idx++; | ||
} | ||
} | ||
|
||
template <UltraFlavor Flavor> | ||
VerifierFoldingResult<Flavor> ProtoGalaxyVerifier_<Flavor>::fold_public_parameters(std::vector<uint8_t> fold_data) | ||
{ | ||
transcript = VerifierTranscript<FF>{ proof_data }; | ||
transcript = VerifierTranscript<FF>{ fold_data }; | ||
for (auto& inst : verifier_instances) { | ||
auto idx = std::to_string(inst.index); | ||
inst.circuit_size = transcript.template receive_from_prover<uint32_t>(idx + "_circuit_size"); | ||
inst.public_input_size = transcript.template receive_from_prover<uint32_t>(idx + "_public_input_size"); | ||
inst.pub_inputs_offset = transcript.template receive_from_prover<uint32_t>(idx + "_pub_inputs_offset"); | ||
|
||
for (size_t i = 0; i < inst.public_input_size; ++i) { | ||
auto public_input_i = | ||
transcript.template receive_from_prover<FF>(idx + "public_input_" + std::to_string(i)); | ||
inst.public_inputs.emplace_back(public_input_i); | ||
} | ||
auto eta = transcript.get_challenge(idx + "_eta"); | ||
auto [beta, gamma] = transcript.get_challenges(idx + "_beta", idx + "_gamma"); | ||
const FF public_input_delta = compute_public_input_delta<Flavor>( | ||
inst.public_inputs, beta, gamma, inst.circuit_size, inst.pub_inputs_offset); | ||
const FF lookup_grand_product_delta = compute_lookup_grand_product_delta<FF>(beta, gamma, inst.circuit_size); | ||
inst.relation_parameters = | ||
RelationParameters<FF>{ eta, beta, gamma, public_input_delta, lookup_grand_product_delta }; | ||
verifier_instances.emplace_back(inst); | ||
} | ||
VerifierFoldingResult<Flavor> res; | ||
return res; | ||
} | ||
|
||
template class ProtoGalaxyVerifier_<honk::flavor::Ultra>; | ||
template class ProtoGalaxyVerifier_<honk::flavor::UltraGrumpkin>; | ||
template class ProtoGalaxyVerifier_<honk::flavor::GoblinUltra>; | ||
} // namespace proof_system::honk |
16 changes: 13 additions & 3 deletions
16
circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/protogalaxy_verifier.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 |
---|---|---|
@@ -1,16 +1,26 @@ | ||
#pragma once | ||
#include "barretenberg/honk/flavor/goblin_ultra.hpp" | ||
#include "barretenberg/honk/flavor/ultra.hpp" | ||
#include "barretenberg/honk/flavor/ultra_grumpkin.hpp" | ||
#include "barretenberg/honk/instance/verifier_instance.hpp" | ||
#include "barretenberg/honk/proof_system/folding_result.hpp" | ||
#include "barretenberg/honk/transcript/transcript.hpp" | ||
#include "barretenberg/proof_system/flavor/flavor.hpp" | ||
#include "barretenberg/proof_system/folding_result.hpp" | ||
|
||
namespace proof_system::honk { | ||
template <UltraFlavor Flavor> class ProtoGalaxyVerifier_ { | ||
public: | ||
using FF = typename Flavor::FF; | ||
using VerificationKey = typename Flavor::VerificationKey; | ||
using VerifierInstance = VerifierInstance_<Flavor>; | ||
std::vector<VerifierInstance> verifier_instances; | ||
VerifierTranscript<FF> transcript; | ||
|
||
explicit ProtoGalaxyVerifier_(std::vector<VerificationKey> vks); | ||
VerifierFoldingResult<Flavor> fold_public_parameters(); | ||
explicit ProtoGalaxyVerifier_(std::vector<std::shared_ptr<VerificationKey>> vks); | ||
VerifierFoldingResult<Flavor> fold_public_parameters(std::vector<uint8_t> fold_data); | ||
}; | ||
|
||
extern template class ProtoGalaxyVerifier_<honk::flavor::Ultra>; | ||
extern template class ProtoGalaxyVerifier_<honk::flavor::UltraGrumpkin>; | ||
extern template class ProtoGalaxyVerifier_<honk::flavor::GoblinUltra>; | ||
} // namespace proof_system::honk |