Skip to content

Commit

Permalink
fix(avm): update codegen (#7178)
Browse files Browse the repository at this point in the history
Please read [contributing guidelines](CONTRIBUTING.md) and remove this
line.
  • Loading branch information
IlyasRidhuan authored Jun 25, 2024
1 parent 4c1997f commit 1d29708
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 25 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 @@ -963,9 +963,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
27 changes: 13 additions & 14 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 Expand Up @@ -271,7 +271,6 @@ fn includes_cpp(name: &str) -> String {
#include \"barretenberg/honk/proof_system/permutation_library.hpp\"
#include \"barretenberg/plonk_honk_shared/library/grand_product_library.hpp\"
#include \"barretenberg/polynomials/polynomial.hpp\"
#include \"barretenberg/relations/lookup_relation.hpp\"
#include \"barretenberg/relations/permutation_relation.hpp\"
#include \"barretenberg/sumcheck/sumcheck.hpp\"
"
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 1d29708

Please sign in to comment.