Skip to content

Commit

Permalink
feat(avm): avm recursive verifier cpp (#8162)
Browse files Browse the repository at this point in the history
Resolves #7790
Resolves #7816 
The current version does not enable checks related to public inputs.
This will be handled as part of #7817
  • Loading branch information
jeanmon authored Aug 29, 2024
1 parent 273b452 commit 6a5587c
Show file tree
Hide file tree
Showing 29 changed files with 668 additions and 333 deletions.
5 changes: 4 additions & 1 deletion barretenberg/cpp/src/barretenberg/flavor/flavor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,12 @@ class ECCVMFlavor;
class UltraKeccakFlavor;
class MegaFlavor;
class TranslatorFlavor;
class AvmFlavor;
template <typename BuilderType> class UltraRecursiveFlavor_;
template <typename BuilderType> class MegaRecursiveFlavor_;
template <typename BuilderType> class TranslatorRecursiveFlavor_;
template <typename BuilderType> class ECCVMRecursiveFlavor_;
template <typename BuilderType> class AvmRecursiveFlavor_;
} // namespace bb

// Forward declare plonk flavors
Expand Down Expand Up @@ -437,7 +439,8 @@ MegaRecursiveFlavor_<CircuitSimulatorBN254>,
TranslatorRecursiveFlavor_<UltraCircuitBuilder>,
TranslatorRecursiveFlavor_<MegaCircuitBuilder>,
TranslatorRecursiveFlavor_<CircuitSimulatorBN254>,
ECCVMRecursiveFlavor_<UltraCircuitBuilder>>;
ECCVMRecursiveFlavor_<UltraCircuitBuilder>,
AvmRecursiveFlavor_<UltraCircuitBuilder>>;

template <typename T> concept IsECCVMRecursiveFlavor = IsAnyOf<T, ECCVMRecursiveFlavor_<UltraCircuitBuilder>>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ template <typename BuilderType> class ECCVMRecursiveFlavor_ {
// define the containers for storing the contributions from each relation in Sumcheck
using TupleOfArraysOfValues = decltype(create_tuple_of_arrays_of_values<Relations>());

public:
/**
* @brief A field element for each entity of the flavor. These entities represent the prover polynomials
* evaluated at one point.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ ECCVMRecursiveVerifier_<Flavor>::ECCVMRecursiveVerifier_(
/**
* @brief This function verifies an ECCVM Honk proof for given program settings up to sumcheck.
*/
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1007): Finish this
template <typename Flavor> void ECCVMRecursiveVerifier_<Flavor>::verify_proof(const HonkProof& proof)
{
using Curve = typename Flavor::Curve;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ template <typename Flavor> class ECCVMRecursiveVerifier_ {
void verify_proof(const HonkProof& proof);

std::shared_ptr<VerificationKey> key;
std::map<std::string, Commitment> commitments;

Builder* builder;
std::shared_ptr<Transcript> transcript;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ template <typename Flavor> class DeciderRecursiveVerifier_ {

PairingPoints verify_proof(const HonkProof& proof);

std::map<std::string, Commitment> commitments;
std::shared_ptr<VerifierCommitmentKey> pcs_verification_key;
Builder* builder;
std::shared_ptr<Instance> accumulator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ template <typename Flavor> class UltraRecursiveVerifier_ {
aggregation_state<typename Flavor::Curve> agg_obj);

std::shared_ptr<VerificationKey> key;
std::map<std::string, Commitment> commitments;
std::shared_ptr<VerifierCommitmentKey> pcs_verification_key;
Builder* builder;
std::shared_ptr<Transcript> transcript;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ template <typename BuilderType> class TranslatorRecursiveFlavor_ {
// random polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation
// length = 3
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH = MAX_PARTIAL_RELATION_LENGTH + 1;
static constexpr size_t BATCHED_RELATION_TOTAL_LENGTH = MAX_TOTAL_RELATION_LENGTH + 1;
static constexpr size_t NUM_RELATIONS = std::tuple_size_v<Relations>;

// define the containers for storing the contributions from each relation in Sumcheck
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ std::array<typename Flavor::GroupElement, 2> TranslatorRecursiveVerifier_<Flavor
sumcheck.verify(relation_parameters, alpha, gate_challenges);

// Execute ZeroMorph rounds followed by the univariate PCS. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a
// complete description ofthe unrolled protocol.
// complete description of the unrolled protocol.

auto opening_claim = ZeroMorph::verify(circuit_size,
commitments.get_unshifted_without_concatenated(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ template <typename Flavor> class TranslatorRecursiveVerifier_ {
BF batching_challenge_v = 0;

std::shared_ptr<VerificationKey> key;
std::map<std::string, Commitment> commitments;
std::shared_ptr<Transcript> transcript;
std::shared_ptr<VerifierCommitmentKey> pcs_verification_key; // can remove maybe hopefully
Builder* builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ class MegaFlavor {
// random polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation
// length = 3
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH = MAX_PARTIAL_RELATION_LENGTH + 1;
static constexpr size_t BATCHED_RELATION_TOTAL_LENGTH = MAX_TOTAL_RELATION_LENGTH + 1;
static constexpr size_t NUM_RELATIONS = std::tuple_size_v<Relations>;
// The total number of witnesses including shifts and derived entities.
static constexpr size_t NUM_ALL_WITNESS_ENTITIES = 23;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ template <typename BuilderType> class MegaRecursiveFlavor_ {
// random polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation
// length = 3
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH = MAX_PARTIAL_RELATION_LENGTH + 1;
static constexpr size_t BATCHED_RELATION_TOTAL_LENGTH = MAX_TOTAL_RELATION_LENGTH + 1;
static constexpr size_t NUM_RELATIONS = std::tuple_size_v<Relations>;

// For instances of this flavour, used in folding, we need a unique sumcheck batching challenge for each
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ class UltraFlavor {
// random polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation
// length = 3
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH = MAX_PARTIAL_RELATION_LENGTH + 1;
static constexpr size_t BATCHED_RELATION_TOTAL_LENGTH = MAX_TOTAL_RELATION_LENGTH + 1;
static constexpr size_t NUM_RELATIONS = std::tuple_size_v<Relations>;

template <size_t NUM_INSTANCES>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class UltraKeccakFlavor {
// random polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation
// length = 3
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH = MAX_PARTIAL_RELATION_LENGTH + 1;
static constexpr size_t BATCHED_RELATION_TOTAL_LENGTH = MAX_TOTAL_RELATION_LENGTH + 1;
static constexpr size_t NUM_RELATIONS = std::tuple_size_v<Relations>;

template <size_t NUM_INSTANCES>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ template <typename BuilderType> class UltraRecursiveFlavor_ {
// random polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation
// length = 3
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH = MAX_PARTIAL_RELATION_LENGTH + 1;
static constexpr size_t BATCHED_RELATION_TOTAL_LENGTH = MAX_TOTAL_RELATION_LENGTH + 1;
static constexpr size_t NUM_RELATIONS = std::tuple_size<Relations>::value;

// For instances of this flavour, used in folding, we need a unique sumcheck batching challenges for each
Expand All @@ -93,7 +92,6 @@ template <typename BuilderType> class UltraRecursiveFlavor_ {
// define the container for storing the univariate contribution from each relation in Sumcheck
using TupleOfArraysOfValues = decltype(create_tuple_of_arrays_of_values<Relations>());

public:
/**
* @brief The verification key is responsible for storing the commitments to the precomputed (non-witnessk)
* polynomials used by the verifier.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ class TranslatorFlavor {
// random polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation
// length = 3
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH = MAX_PARTIAL_RELATION_LENGTH + 1;
static constexpr size_t BATCHED_RELATION_TOTAL_LENGTH = MAX_TOTAL_RELATION_LENGTH + 1;
static constexpr size_t NUM_RELATIONS = std::tuple_size_v<Relations>;

// define the containers for storing the contributions from each relation in Sumcheck
Expand Down
2 changes: 1 addition & 1 deletion barretenberg/cpp/src/barretenberg/vm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
if(NOT DISABLE_AZTEC_VM)
barretenberg_module(vm sumcheck)
barretenberg_module(vm sumcheck stdlib_honk_verifier)
endif()
20 changes: 0 additions & 20 deletions barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2427,26 +2427,6 @@ AvmFlavor::CommitmentLabels::CommitmentLabels()
Base::incl_mem_tag_err_counts = "INCL_MEM_TAG_ERR_COUNTS";
};

AvmFlavor::VerifierCommitments::VerifierCommitments(const std::shared_ptr<VerificationKey>& verification_key)
{
byte_lookup_sel_bin = verification_key->byte_lookup_sel_bin;
byte_lookup_table_byte_lengths = verification_key->byte_lookup_table_byte_lengths;
byte_lookup_table_in_tags = verification_key->byte_lookup_table_in_tags;
byte_lookup_table_input_a = verification_key->byte_lookup_table_input_a;
byte_lookup_table_input_b = verification_key->byte_lookup_table_input_b;
byte_lookup_table_op_id = verification_key->byte_lookup_table_op_id;
byte_lookup_table_output = verification_key->byte_lookup_table_output;
gas_base_da_gas_fixed_table = verification_key->gas_base_da_gas_fixed_table;
gas_base_l2_gas_fixed_table = verification_key->gas_base_l2_gas_fixed_table;
gas_dyn_da_gas_fixed_table = verification_key->gas_dyn_da_gas_fixed_table;
gas_dyn_l2_gas_fixed_table = verification_key->gas_dyn_l2_gas_fixed_table;
gas_sel_gas_cost = verification_key->gas_sel_gas_cost;
main_clk = verification_key->main_clk;
main_sel_first = verification_key->main_sel_first;
main_zeroes = verification_key->main_zeroes;
powers_power_of_2 = verification_key->powers_power_of_2;
}

void AvmFlavor::Transcript::deserialize_full_transcript()
{
size_t num_frs_read = 0;
Expand Down
Loading

1 comment on commit 6a5587c

@AztecBot
Copy link
Collaborator

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'C++ Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.05.

Benchmark suite Current: 6a5587c Previous: cc12558 Ratio
nativeClientIVCBench/Full/6 14637.833551 ms/iter 13746.385995999986 ms/iter 1.06

This comment was automatically generated by workflow using github-action-benchmark.

CC: @ludamad @codygunton

Please sign in to comment.