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

chore: removing hack commitment from eccvm #8825

Merged
merged 4 commits into from
Sep 26, 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
8 changes: 0 additions & 8 deletions barretenberg/cpp/src/barretenberg/eccvm/eccvm_flavor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -937,13 +937,11 @@ class ECCVMFlavor {
std::array<FF, NUM_ALL_ENTITIES> sumcheck_evaluations;
std::vector<Commitment> zm_cq_comms;
Commitment zm_cq_comm;
Commitment translation_hack_comm;
FF translation_eval_op;
FF translation_eval_px;
FF translation_eval_py;
FF translation_eval_z1;
FF translation_eval_z2;
FF hack_eval;
Commitment shplonk_q_comm;
uint32_t ipa_poly_degree;
std::vector<Commitment> ipa_l_comms;
Expand Down Expand Up @@ -1151,8 +1149,6 @@ class ECCVMFlavor {
}
zm_cq_comm = NativeTranscript::template deserialize_from_buffer<Commitment>(proof_data, num_frs_read);

translation_hack_comm = NativeTranscript::template deserialize_from_buffer<Commitment>(
NativeTranscript::proof_data, num_frs_read);
translation_eval_op =
NativeTranscript::template deserialize_from_buffer<FF>(NativeTranscript::proof_data, num_frs_read);
translation_eval_px =
Expand All @@ -1163,8 +1159,6 @@ class ECCVMFlavor {
NativeTranscript::template deserialize_from_buffer<FF>(NativeTranscript::proof_data, num_frs_read);
translation_eval_z2 =
NativeTranscript::template deserialize_from_buffer<FF>(NativeTranscript::proof_data, num_frs_read);
hack_eval =
NativeTranscript::template deserialize_from_buffer<FF>(NativeTranscript::proof_data, num_frs_read);

shplonk_q_comm = NativeTranscript::template deserialize_from_buffer<Commitment>(proof_data, num_frs_read);

Expand Down Expand Up @@ -1297,13 +1291,11 @@ class ECCVMFlavor {
}
NativeTranscript::template serialize_to_buffer(zm_cq_comm, NativeTranscript::proof_data);

NativeTranscript::template serialize_to_buffer(translation_hack_comm, NativeTranscript::proof_data);
NativeTranscript::template serialize_to_buffer(translation_eval_op, NativeTranscript::proof_data);
NativeTranscript::template serialize_to_buffer(translation_eval_px, NativeTranscript::proof_data);
NativeTranscript::template serialize_to_buffer(translation_eval_py, NativeTranscript::proof_data);
NativeTranscript::template serialize_to_buffer(translation_eval_z1, NativeTranscript::proof_data);
NativeTranscript::template serialize_to_buffer(translation_eval_z2, NativeTranscript::proof_data);
NativeTranscript::template serialize_to_buffer(hack_eval, NativeTranscript::proof_data);

NativeTranscript::template serialize_to_buffer(shplonk_q_comm, NativeTranscript::proof_data);

Expand Down
30 changes: 10 additions & 20 deletions barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,6 @@ void ECCVMProver::execute_pcs_rounds()
commitment_key,
transcript);

// Batch open the transcript polynomials as univariates for Translator consistency check. Since IPA cannot
// currently handle polynomials for which the latter half of the coefficients are 0, we hackily
// batch the constant polynomial 1 in with the 5 transcript polynomials.
// TODO(https://github.com/AztecProtocol/barretenberg/issues/768): fix IPA to avoid the need for the hack polynomial
Polynomial hack(key->circuit_size);
for (size_t idx = 0; idx < key->circuit_size; idx++) {
hack.at(idx) = 1;
}
transcript->send_to_verifier("Translation:hack_commitment", commitment_key->commit(hack));

// Get the challenge at which we evaluate all transcript polynomials as univariates
evaluation_challenge_x = transcript->template get_challenge<FF>("Translation:evaluation_challenge_x");

Expand All @@ -156,20 +146,20 @@ void ECCVMProver::execute_pcs_rounds()
transcript->send_to_verifier("Translation:z1", translation_evaluations.z1);
transcript->send_to_verifier("Translation:z2", translation_evaluations.z2);

FF hack_evaluation = hack.evaluate(evaluation_challenge_x);
transcript->send_to_verifier("Translation:hack_evaluation", hack_evaluation);

// Get another challenge for batching the univariates and evaluations
FF ipa_batching_challenge = transcript->template get_challenge<FF>("Translation:ipa_batching_challenge");

// Collect the polynomials and evaluations to be batched
RefArray univariate_polynomials{ key->polynomials.transcript_op, key->polynomials.transcript_Px,
key->polynomials.transcript_Py, key->polynomials.transcript_z1,
key->polynomials.transcript_z2, hack };
std::array<FF, univariate_polynomials.size()> univariate_evaluations{
translation_evaluations.op, translation_evaluations.Px, translation_evaluations.Py,
translation_evaluations.z1, translation_evaluations.z2, hack_evaluation
};
RefArray univariate_polynomials{ key->polynomials.transcript_op,
key->polynomials.transcript_Px,
key->polynomials.transcript_Py,
key->polynomials.transcript_z1,
key->polynomials.transcript_z2 };
std::array<FF, univariate_polynomials.size()> univariate_evaluations{ translation_evaluations.op,
translation_evaluations.Px,
translation_evaluations.Py,
translation_evaluations.z1,
translation_evaluations.z2 };

// Construct the batched polynomial and batched evaluation to produce the batched opening claim
Polynomial batched_univariate{ key->circuit_size };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ class ECCVMTranscriptTests : public ::testing::Test {
manifest_expected.add_challenge(round, "ZM:x", "ZM:z");

round++;
manifest_expected.add_entry(round, "Translation:hack_commitment", frs_per_G);
manifest_expected.add_challenge(round, "Translation:evaluation_challenge_x");

round++;
Expand All @@ -171,7 +170,6 @@ class ECCVMTranscriptTests : public ::testing::Test {
manifest_expected.add_entry(round, "Translation:Py", frs_per_Fr);
manifest_expected.add_entry(round, "Translation:z1", frs_per_Fr);
manifest_expected.add_entry(round, "Translation:z2", frs_per_Fr);
manifest_expected.add_entry(round, "Translation:hack_evaluation", frs_per_Fr);
manifest_expected.add_challenge(round, "Translation:ipa_batching_challenge");

round++;
Expand Down
28 changes: 13 additions & 15 deletions barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,35 +69,33 @@ bool ECCVMVerifier::verify_proof(const HonkProof& proof)
multivariate_challenge,
key->pcs_verification_key->get_g1_identity(),
transcript);

// Execute transcript consistency univariate opening round
auto hack_commitment = transcript->template receive_from_prover<Commitment>("Translation:hack_commitment");

FF evaluation_challenge_x = transcript->template get_challenge<FF>("Translation:evaluation_challenge_x");
const FF evaluation_challenge_x = transcript->template get_challenge<FF>("Translation:evaluation_challenge_x");

// Construct arrays of commitments and evaluations to be batched, the evaluations being received from the prover
const size_t NUM_UNIVARIATES = 6;
std::array<Commitment, NUM_UNIVARIATES> transcript_commitments = {
commitments.transcript_op, commitments.transcript_Px, commitments.transcript_Py,
commitments.transcript_z1, commitments.transcript_z2, hack_commitment
};
const size_t NUM_UNIVARIATES = 5;
std::array<Commitment, NUM_UNIVARIATES> transcript_commitments = { commitments.transcript_op,
commitments.transcript_Px,
commitments.transcript_Py,
commitments.transcript_z1,
commitments.transcript_z2 };
std::array<FF, NUM_UNIVARIATES> transcript_evaluations = {
transcript->template receive_from_prover<FF>("Translation:op"),
transcript->template receive_from_prover<FF>("Translation:Px"),
transcript->template receive_from_prover<FF>("Translation:Py"),
transcript->template receive_from_prover<FF>("Translation:z1"),
transcript->template receive_from_prover<FF>("Translation:z2"),
transcript->template receive_from_prover<FF>("Translation:hack_evaluation")
transcript->template receive_from_prover<FF>("Translation:z2")
};

// Get the batching challenge for commitments and evaluations
FF ipa_batching_challenge = transcript->template get_challenge<FF>("Translation:ipa_batching_challenge");
const FF ipa_batching_challenge = transcript->template get_challenge<FF>("Translation:ipa_batching_challenge");

// Compute the batched commitment and batched evaluation for the univariate opening claim
auto batched_commitment = transcript_commitments[0];
auto batched_transcript_eval = transcript_evaluations[0];
auto batching_scalar = ipa_batching_challenge;
for (size_t idx = 1; idx < transcript_commitments.size(); ++idx) {
Commitment batched_commitment = transcript_commitments[0];
FF batched_transcript_eval = transcript_evaluations[0];
FF batching_scalar = ipa_batching_challenge;
for (size_t idx = 1; idx < NUM_UNIVARIATES; ++idx) {
batched_commitment = batched_commitment + transcript_commitments[idx] * batching_scalar;
batched_transcript_eval += batching_scalar * transcript_evaluations[idx];
batching_scalar *= ipa_batching_challenge;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ template <typename Flavor> void ECCVMRecursiveVerifier_<Flavor>::verify_proof(co
}

// Get challenge for sorted list batching and wire four memory records
auto [beta, gamma] = transcript->template get_challenges<FF>("beta", "gamma");
const auto [beta, gamma] = transcript->template get_challenges<FF>("beta", "gamma");

auto beta_sqr = beta * beta;

Expand All @@ -63,7 +63,7 @@ template <typename Flavor> void ECCVMRecursiveVerifier_<Flavor>::verify_proof(co
// sumcheck is dependent on circuit size.
const size_t log_circuit_size = numeric::get_msb(static_cast<uint32_t>(circuit_size.get_value()));
auto sumcheck = SumcheckVerifier<Flavor>(log_circuit_size, transcript, FF(0));
FF alpha = transcript->template get_challenge<FF>("Sumcheck:alpha");
const FF alpha = transcript->template get_challenge<FF>("Sumcheck:alpha");
std::vector<FF> gate_challenges(static_cast<size_t>(numeric::get_msb(key->circuit_size)));
for (size_t idx = 0; idx < gate_challenges.size(); idx++) {
gate_challenges[idx] = transcript->template get_challenge<FF>("Sumcheck:gate_challenge_" + std::to_string(idx));
Expand All @@ -80,25 +80,24 @@ template <typename Flavor> void ECCVMRecursiveVerifier_<Flavor>::verify_proof(co
multivariate_challenge,
key->pcs_verification_key->get_g1_identity(),
transcript);
auto hack_commitment = transcript->template receive_from_prover<Commitment>("Translation:hack_commitment");

FF evaluation_challenge_x = transcript->template get_challenge<FF>("Translation:evaluation_challenge_x");
const FF evaluation_challenge_x = transcript->template get_challenge<FF>("Translation:evaluation_challenge_x");

// Construct the vector of commitments (needs to be vector for the batch_mul) and array of evaluations to be batched
std::vector<Commitment> transcript_commitments = { commitments.transcript_op, commitments.transcript_Px,
commitments.transcript_Py, commitments.transcript_z1,
commitments.transcript_z2, hack_commitment };
std::vector<Commitment> transcript_commitments = { commitments.transcript_op,
commitments.transcript_Px,
commitments.transcript_Py,
commitments.transcript_z1,
commitments.transcript_z2 };

std::vector<FF> transcript_evaluations = { transcript->template receive_from_prover<FF>("Translation:op"),
transcript->template receive_from_prover<FF>("Translation:Px"),
transcript->template receive_from_prover<FF>("Translation:Py"),
transcript->template receive_from_prover<FF>("Translation:z1"),
transcript->template receive_from_prover<FF>("Translation:z2"),
transcript->template receive_from_prover<FF>(
"Translation:hack_evaluation") };
transcript->template receive_from_prover<FF>("Translation:z2") };

// Get the batching challenge for commitments and evaluations
FF ipa_batching_challenge = transcript->template get_challenge<FF>("Translation:ipa_batching_challenge");
const FF ipa_batching_challenge = transcript->template get_challenge<FF>("Translation:ipa_batching_challenge");

// Compute the batched commitment and batched evaluation for the univariate opening claim
auto batched_transcript_eval = transcript_evaluations[0];
Expand All @@ -110,7 +109,7 @@ template <typename Flavor> void ECCVMRecursiveVerifier_<Flavor>::verify_proof(co
batching_challenges.emplace_back(batching_scalar);
batching_scalar *= ipa_batching_challenge;
}
auto batched_commitment = Commitment::batch_mul(transcript_commitments, batching_challenges);
const Commitment batched_commitment = Commitment::batch_mul(transcript_commitments, batching_challenges);

// Construct and verify the combined opening claim
OpeningClaim<Curve> batched_univariate_claim = { { evaluation_challenge_x, batched_transcript_eval },
Expand Down
Loading