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

fix(avm): update codegen #7178

Merged
merged 1 commit into from
Jun 25, 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 @@ -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));
jeanmon marked this conversation as resolved.
Show resolved Hide resolved
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
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;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are moved to the header file

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
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;
IlyasRidhuan marked this conversation as resolved.
Show resolved Hide resolved
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;
IlyasRidhuan marked this conversation as resolved.
Show resolved Hide resolved
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(),
IlyasRidhuan marked this conversation as resolved.
Show resolved Hide resolved
// 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
Loading