-
Notifications
You must be signed in to change notification settings - Fork 292
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
refactor: the origins of the oink #5067
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c8f96bb
the origins of the oink
lucasxia01 11471d0
put into ultra_prover and be consistent between the two
lucasxia01 99039d0
Merge remote-tracking branch 'origin/master' into lx/prover-sharing-t…
lucasxia01 2a834fa
forgot to commit?
lucasxia01 1277531
split oink into separate rounds, deleted witness_comms and comm_label…
lucasxia01 3994cd6
Merge branch 'master' into lx/prover-sharing-take-2
lucasxia01 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
91 changes: 12 additions & 79 deletions
91
barretenberg/cpp/src/barretenberg/protogalaxy/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
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
119 changes: 119 additions & 0 deletions
119
barretenberg/cpp/src/barretenberg/ultra_honk/oink_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 |
---|---|---|
@@ -0,0 +1,119 @@ | ||
#include "barretenberg/ultra_honk/oink_prover.hpp" | ||
|
||
namespace bb { | ||
|
||
/** | ||
* @brief Add circuit size, public input size, and public inputs to transcript | ||
* | ||
*/ | ||
template <IsUltraFlavor Flavor> void OinkProver<Flavor>::execute_preamble_round() | ||
{ | ||
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(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->proving_key->pub_inputs_offset)); | ||
|
||
for (size_t i = 0; i < instance->proving_key->public_inputs.size(); ++i) { | ||
auto public_input_i = instance->proving_key->public_inputs[i]; | ||
transcript->send_to_verifier(domain_separator + "public_input_" + std::to_string(i), public_input_i); | ||
} | ||
} | ||
|
||
/** | ||
* @brief Commit to the wire polynomials (part of the witness), with the exception of the fourth wire, which is | ||
* only commited to after adding memory records. In the Goblin Flavor, we also commit to the ECC OP wires and the | ||
* DataBus columns. | ||
*/ | ||
template <IsUltraFlavor Flavor> void OinkProver<Flavor>::execute_wire_commitments_round() | ||
{ | ||
// Commit to the first three wire polynomials of the instance | ||
// We only commit to the fourth wire polynomial after adding memory recordss | ||
witness_commitments.w_l = commitment_key->commit(instance->proving_key->w_l); | ||
witness_commitments.w_r = commitment_key->commit(instance->proving_key->w_r); | ||
witness_commitments.w_o = commitment_key->commit(instance->proving_key->w_o); | ||
|
||
auto wire_comms = witness_commitments.get_wires(); | ||
auto wire_labels = commitment_labels.get_wires(); | ||
for (size_t idx = 0; idx < 3; ++idx) { | ||
transcript->send_to_verifier(domain_separator + wire_labels[idx], wire_comms[idx]); | ||
} | ||
|
||
if constexpr (IsGoblinFlavor<Flavor>) { | ||
// Commit to Goblin ECC op wires | ||
witness_commitments.ecc_op_wire_1 = commitment_key->commit(instance->proving_key->ecc_op_wire_1); | ||
witness_commitments.ecc_op_wire_2 = commitment_key->commit(instance->proving_key->ecc_op_wire_2); | ||
witness_commitments.ecc_op_wire_3 = commitment_key->commit(instance->proving_key->ecc_op_wire_3); | ||
witness_commitments.ecc_op_wire_4 = commitment_key->commit(instance->proving_key->ecc_op_wire_4); | ||
|
||
auto op_wire_comms = witness_commitments.get_ecc_op_wires(); | ||
auto labels = commitment_labels.get_ecc_op_wires(); | ||
for (size_t idx = 0; idx < Flavor::NUM_WIRES; ++idx) { | ||
transcript->send_to_verifier(domain_separator + labels[idx], op_wire_comms[idx]); | ||
} | ||
// Commit to DataBus columns | ||
witness_commitments.calldata = commitment_key->commit(instance->proving_key->calldata); | ||
witness_commitments.calldata_read_counts = commitment_key->commit(instance->proving_key->calldata_read_counts); | ||
transcript->send_to_verifier(domain_separator + commitment_labels.calldata, witness_commitments.calldata); | ||
transcript->send_to_verifier(domain_separator + commitment_labels.calldata_read_counts, | ||
witness_commitments.calldata_read_counts); | ||
} | ||
} | ||
|
||
/** | ||
* @brief Compute sorted witness-table accumulator and commit to the resulting polynomials. | ||
* | ||
*/ | ||
template <IsUltraFlavor Flavor> void OinkProver<Flavor>::execute_sorted_list_accumulator_round() | ||
{ | ||
auto eta = transcript->template get_challenge<FF>(domain_separator + "eta"); | ||
instance->compute_sorted_accumulator_polynomials(eta); | ||
|
||
// Commit to the sorted witness-table accumulator and the finalized (i.e. with memory records) fourth wire | ||
// polynomial | ||
witness_commitments.sorted_accum = commitment_key->commit(instance->prover_polynomials.sorted_accum); | ||
witness_commitments.w_4 = commitment_key->commit(instance->prover_polynomials.w_4); | ||
|
||
transcript->send_to_verifier(domain_separator + commitment_labels.sorted_accum, witness_commitments.sorted_accum); | ||
transcript->send_to_verifier(domain_separator + commitment_labels.w_4, witness_commitments.w_4); | ||
} | ||
|
||
/** | ||
* @brief Compute log derivative inverse polynomial and its commitment, if required | ||
* | ||
*/ | ||
template <IsUltraFlavor Flavor> void OinkProver<Flavor>::execute_log_derivative_inverse_round() | ||
{ | ||
auto [beta, gamma] = transcript->template get_challenges<FF>(domain_separator + "beta", domain_separator + "gamma"); | ||
instance->relation_parameters.beta = beta; | ||
instance->relation_parameters.gamma = gamma; | ||
if constexpr (IsGoblinFlavor<Flavor>) { | ||
// Compute and commit to the logderivative inverse used in DataBus | ||
instance->compute_logderivative_inverse(beta, gamma); | ||
witness_commitments.lookup_inverses = commitment_key->commit(instance->prover_polynomials.lookup_inverses); | ||
transcript->send_to_verifier(domain_separator + commitment_labels.lookup_inverses, | ||
witness_commitments.lookup_inverses); | ||
} | ||
} | ||
|
||
/** | ||
* @brief Compute permutation and lookup grand product polynomials and their commitments | ||
* | ||
*/ | ||
template <IsUltraFlavor Flavor> void OinkProver<Flavor>::execute_grand_product_computation_round() | ||
{ | ||
instance->compute_grand_product_polynomials(instance->relation_parameters.beta, | ||
instance->relation_parameters.gamma); | ||
|
||
witness_commitments.z_perm = commitment_key->commit(instance->prover_polynomials.z_perm); | ||
witness_commitments.z_lookup = commitment_key->commit(instance->prover_polynomials.z_lookup); | ||
|
||
transcript->send_to_verifier(domain_separator + commitment_labels.z_perm, witness_commitments.z_perm); | ||
transcript->send_to_verifier(domain_separator + commitment_labels.z_lookup, witness_commitments.z_lookup); | ||
} | ||
|
||
template class OinkProver<UltraFlavor>; | ||
template class OinkProver<GoblinUltraFlavor>; | ||
|
||
} // namespace bb |
52 changes: 52 additions & 0 deletions
52
barretenberg/cpp/src/barretenberg/ultra_honk/oink_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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#pragma once | ||
#include <utility> | ||
|
||
#include "barretenberg/flavor/goblin_ultra.hpp" | ||
#include "barretenberg/flavor/ultra.hpp" | ||
#include "barretenberg/sumcheck/instance/prover_instance.hpp" | ||
#include "barretenberg/transcript/transcript.hpp" | ||
|
||
namespace bb { | ||
|
||
/** | ||
* @brief Class for all the presumcheck rounds, which are shared between the folding prover and ultra prover. | ||
* @details This class contains execute_preamble_round(), execute_wire_commitments_round(), | ||
* execute_sorted_list_accumulator_round(), execute_log_derivative_inverse_round(), and | ||
* execute_grand_product_computation_round(). | ||
* | ||
* @tparam Flavor | ||
*/ | ||
template <IsUltraFlavor Flavor> class OinkProver { | ||
using CommitmentKey = typename Flavor::CommitmentKey; | ||
using Instance = ProverInstance_<Flavor>; | ||
using Transcript = typename Flavor::Transcript; | ||
using FF = typename Flavor::FF; | ||
|
||
public: | ||
OinkProver(const std::shared_ptr<ProverInstance_<Flavor>>& inst, | ||
const std::shared_ptr<typename Flavor::CommitmentKey>& commitment_key, | ||
const std::shared_ptr<typename Flavor::Transcript>& transcript, | ||
std::string domain_separator = "") | ||
: instance(inst) | ||
, transcript(transcript) | ||
, commitment_key(commitment_key) | ||
, domain_separator(std::move(domain_separator)) | ||
, commitment_labels() | ||
{ | ||
instance->initialize_prover_polynomials(); | ||
} | ||
|
||
void execute_preamble_round(); | ||
void execute_wire_commitments_round(); | ||
void execute_sorted_list_accumulator_round(); | ||
void execute_log_derivative_inverse_round(); | ||
void execute_grand_product_computation_round(); | ||
|
||
std::shared_ptr<Instance> instance; | ||
std::shared_ptr<Transcript> transcript; | ||
std::shared_ptr<CommitmentKey> commitment_key; | ||
std::string domain_separator; | ||
typename Flavor::WitnessCommitments witness_commitments; | ||
typename Flavor::CommitmentLabels commitment_labels; | ||
}; | ||
} // namespace bb |
Oops, something went wrong.
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.
reordering to keep consistent with oink prover