Skip to content

Commit

Permalink
fix(avm): update codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyasRidhuan committed Jun 25, 2024
1 parent 9aabc32 commit d4c488c
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ template <typename FF_> class gasImpl {
{
Avm_DECLARE_VIEWS(0);

auto tmp = (gas_sel_gas_cost - gas_sel_gas_cost);
auto tmp = ((gas_sel_gas_cost - gas_sel_gas_cost) - FF(0));
tmp *= scaling_factor;
std::get<0>(evals) += tmp;
}
// Contribution 1
{
Avm_DECLARE_VIEWS(1);

auto tmp = (gas_l2_gas_fixed_table - gas_l2_gas_fixed_table);
auto tmp = ((gas_l2_gas_fixed_table - gas_l2_gas_fixed_table) - FF(0));
tmp *= scaling_factor;
std::get<1>(evals) += tmp;
}
// Contribution 2
{
Avm_DECLARE_VIEWS(2);

auto tmp = (gas_da_gas_fixed_table - gas_da_gas_fixed_table);
auto tmp = ((gas_da_gas_fixed_table - gas_da_gas_fixed_table) - FF(0));
tmp *= scaling_factor;
std::get<2>(evals) += tmp;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ template <typename FF_> class powersImpl {
{
Avm_DECLARE_VIEWS(0);

auto tmp = (powers_power_of_2 - powers_power_of_2);
auto tmp = ((powers_power_of_2 - powers_power_of_2) - FF(0));
tmp *= scaling_factor;
std::get<0>(evals) += tmp;
}
Expand Down
3 changes: 0 additions & 3 deletions barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -964,9 +964,6 @@ void AvmProver::execute_relation_check_rounds()
* */
void AvmProver::execute_pcs_rounds()
{
using Curve = typename Flavor::Curve;
using ZeroMorph = ZeroMorphProver_<Curve>;

auto prover_opening_claim = ZeroMorph::prove(prover_polynomials.get_unshifted(),
prover_polynomials.get_to_be_shifted(),
sumcheck_output.claimed_evaluations.get_unshifted(),
Expand Down
2 changes: 2 additions & 0 deletions barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class AvmProver {
using Flavor = AvmFlavor;
using FF = Flavor::FF;
using PCS = Flavor::PCS;
using Curve = Flavor::Curve;
using ZeroMorph = ZeroMorphProver_<Curve>;
using PCSCommitmentKey = Flavor::CommitmentKey;
using ProvingKey = Flavor::ProvingKey;
using Polynomial = Flavor::Polynomial;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ bool AvmVerifier::verify_proof(const HonkProof& proof, const std::vector<std::ve
using FF = Flavor::FF;
using Commitment = Flavor::Commitment;
// using PCS = Flavor::PCS;
// using ZeroMorph = ZeroMorphVerifier_<PCS>;
// using Curve = Flavor::Curve;
// using ZeroMorph = ZeroMorphVerifier_<Curve>;
using VerifierCommitments = Flavor::VerifierCommitments;
using CommitmentLabels = Flavor::CommitmentLabels;

Expand Down Expand Up @@ -739,13 +740,15 @@ bool AvmVerifier::verify_proof(const HonkProof& proof, const std::vector<std::ve
// Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description of the
// unrolled protocol.
// NOTE: temporarily disabled - facing integration issues
// auto pairing_points = ZeroMorph::verify(commitments.get_unshifted(),
// auto opening_claim = ZeroMorph::verify(commitments.get_unshifted(),
// commitments.get_to_be_shifted(),
// claimed_evaluations.get_unshifted(),
// claimed_evaluations.get_shifted(),
// multivariate_challenge,
// pcs_verification_key->get_g1_identity(),
// transcript);

// auto pairing_points = PCS::reduce_verify(opening_claim, transcript);
// auto verified = pcs_verification_key->pairing_check(pairing_points[0], pairing_points[1]);
// return sumcheck_verified.value() && verified;
return sumcheck_verified.value();
Expand Down
26 changes: 13 additions & 13 deletions bb-pilcom/bb-pil-backend/src/prover_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ impl ProverBuilder for BBFiles {
using Flavor = {name}Flavor;
using FF = Flavor::FF;
using PCS = Flavor::PCS;
using Curve = Flavor::Curve;
using ZeroMorph = ZeroMorphProver_<Curve>;
using PCSCommitmentKey = Flavor::CommitmentKey;
using ProvingKey = Flavor::ProvingKey;
using Polynomial = Flavor::Polynomial;
Expand All @@ -39,7 +41,7 @@ impl ProverBuilder for BBFiles {
void execute_wire_commitments_round();
void execute_log_derivative_inverse_round();
void execute_relation_check_rounds();
void execute_zeromorph_rounds();
void execute_pcs_rounds();
HonkProof export_proof();
HonkProof construct_proof();
Expand All @@ -64,8 +66,6 @@ impl ProverBuilder for BBFiles {
std::shared_ptr<PCSCommitmentKey> commitment_key;
using ZeroMorph = ZeroMorphProver_<PCS>;
private:
HonkProof proof;
}};
Expand Down Expand Up @@ -190,16 +190,16 @@ impl ProverBuilder for BBFiles {
* @details See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description of the unrolled protocol.
*
* */
void {name}Prover::execute_zeromorph_rounds()
void {name}Prover::execute_pcs_rounds()
{{
ZeroMorph::prove(prover_polynomials.get_unshifted(),
prover_polynomials.get_to_be_shifted(),
sumcheck_output.claimed_evaluations.get_unshifted(),
sumcheck_output.claimed_evaluations.get_shifted(),
sumcheck_output.challenge,
commitment_key,
transcript);
auto prover_opening_claim = ZeroMorph::prove(prover_polynomials.get_unshifted(),
prover_polynomials.get_to_be_shifted(),
sumcheck_output.claimed_evaluations.get_unshifted(),
sumcheck_output.claimed_evaluations.get_shifted(),
sumcheck_output.challenge,
commitment_key,
transcript);
PCS::compute_opening_proof(commitment_key, prover_opening_claim, transcript);
}}
Expand All @@ -226,7 +226,7 @@ impl ProverBuilder for BBFiles {
// Fiat-Shamir: rho, y, x, z
// Execute Zeromorph multilinear PCS
execute_zeromorph_rounds();
execute_pcs_rounds();
return export_proof();
}}
Expand Down
7 changes: 5 additions & 2 deletions bb-pilcom/bb-pil-backend/src/verifier_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ impl VerifierBuilder for BBFiles {
using FF = Flavor::FF;
using Commitment = Flavor::Commitment;
// using PCS = Flavor::PCS;
// using ZeroMorph = ZeroMorphVerifier_<PCS>;
// using Curve = Flavor::Curve;
// using ZeroMorph = ZeroMorphVerifier_<Curve>;
using VerifierCommitments = Flavor::VerifierCommitments;
using CommitmentLabels = Flavor::CommitmentLabels;
Expand Down Expand Up @@ -182,13 +183,15 @@ impl VerifierBuilder for BBFiles {
// Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description of the
// unrolled protocol.
// NOTE: temporarily disabled - facing integration issues
// auto pairing_points = ZeroMorph::verify(commitments.get_unshifted(),
// auto opening_claim = ZeroMorph::verify(commitments.get_unshifted(),
// commitments.get_to_be_shifted(),
// claimed_evaluations.get_unshifted(),
// claimed_evaluations.get_shifted(),
// multivariate_challenge,
// pcs_verification_key->get_g1_identity(),
// transcript);
// auto pairing_points = PCS::reduce_verify(opening_claim, transcript);
// auto verified = pcs_verification_key->pairing_check(pairing_points[0], pairing_points[1]);
// return sumcheck_verified.value() && verified;
return sumcheck_verified.value();
Expand Down

0 comments on commit d4c488c

Please sign in to comment.