Skip to content
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: moving wit comms and witness and comm labels from instance to oink #5199

Merged
merged 2 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,13 @@ template <class Flavor> class ProverInstance_ {
using FF = typename Flavor::FF;
using ProverPolynomials = typename Flavor::ProverPolynomials;
using Polynomial = typename Flavor::Polynomial;
using WitnessCommitments = typename Flavor::WitnessCommitments;
using CommitmentLabels = typename Flavor::CommitmentLabels;
using RelationSeparator = typename Flavor::RelationSeparator;

using Trace = ExecutionTrace_<Flavor>;

public:
std::shared_ptr<ProvingKey> proving_key;
ProverPolynomials prover_polynomials;
WitnessCommitments witness_commitments;
CommitmentLabels commitment_labels;

std::array<Polynomial, 4> sorted_polynomials;

Expand Down
20 changes: 5 additions & 15 deletions barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,13 @@ template <IsUltraFlavor Flavor> void OinkProver<Flavor>::execute_preamble_round(
*/
template <IsUltraFlavor Flavor> void OinkProver<Flavor>::execute_wire_commitments_round()
{
auto& witness_commitments = instance->witness_commitments;

// 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& commitment_labels = instance->commitment_labels;
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]);
Expand Down Expand Up @@ -72,16 +69,14 @@ template <IsUltraFlavor Flavor> void OinkProver<Flavor>::execute_wire_commitment
*/
template <IsUltraFlavor Flavor> void OinkProver<Flavor>::execute_sorted_list_accumulator_round()
{
auto& witness_commitments = instance->witness_commitments;
const auto& commitment_labels = instance->commitment_labels;

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);
witness_commitments.sorted_accum = commitment_key->commit(instance->proving_key->sorted_accum);
witness_commitments.w_4 = commitment_key->commit(instance->proving_key->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);
Expand All @@ -93,16 +88,13 @@ template <IsUltraFlavor Flavor> void OinkProver<Flavor>::execute_sorted_list_acc
*/
template <IsUltraFlavor Flavor> void OinkProver<Flavor>::execute_log_derivative_inverse_round()
{
auto& witness_commitments = instance->witness_commitments;
const auto& commitment_labels = instance->commitment_labels;

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);
witness_commitments.lookup_inverses = commitment_key->commit(instance->proving_key->lookup_inverses);
transcript->send_to_verifier(domain_separator + commitment_labels.lookup_inverses,
witness_commitments.lookup_inverses);
}
Expand All @@ -114,14 +106,12 @@ template <IsUltraFlavor Flavor> void OinkProver<Flavor>::execute_log_derivative_
*/
template <IsUltraFlavor Flavor> void OinkProver<Flavor>::execute_grand_product_computation_round()
{
auto& witness_commitments = instance->witness_commitments;
const auto& commitment_labels = instance->commitment_labels;

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);
witness_commitments.z_perm = commitment_key->commit(instance->proving_key->z_perm);
witness_commitments.z_lookup = commitment_key->commit(instance->proving_key->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);
Expand Down
2 changes: 2 additions & 0 deletions barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ template <IsUltraFlavor Flavor> class OinkProver {
std::shared_ptr<Transcript> transcript;
std::shared_ptr<CommitmentKey> commitment_key;
std::string domain_separator;
typename Flavor::WitnessCommitments witness_commitments;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

witness_commitments acts as storage in the prover, and isn't used outside of it

typename Flavor::CommitmentLabels commitment_labels;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commitment_labels is a static class of strings


OinkProver(const std::shared_ptr<ProverInstance_<Flavor>>& inst,
const std::shared_ptr<typename Flavor::CommitmentKey>& commitment_key,
Expand Down
Loading