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

feat(avm): avm recursive verifier cpp #8162

Merged
merged 21 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7409b1f
7790: Port cpp changes
jeanmon Aug 7, 2024
2b4a8a7
7790: port codegen part
jeanmon Aug 7, 2024
5947d16
7790: Fix compilation issues
jeanmon Aug 7, 2024
9a19ae6
7790: WIP - debugging assertion in from_witness()
jeanmon Aug 14, 2024
0e7382f
7790: Fix for zeromorph verification issue
jeanmon Aug 16, 2024
3cfc1c4
7790: fix issues after rebase to master
jeanmon Aug 22, 2024
79dc2bf
7790: Clean up header files
jeanmon Aug 23, 2024
b803a26
7790: cosmetic cleanups and assert circuit size
jeanmon Aug 23, 2024
d503611
7790: Enable Zeromorph in AVM recursive verifier (just compilation)
jeanmon Aug 23, 2024
c08f5d7
7790: refactor - move pcs_verification_key to verification_key
jeanmon Aug 23, 2024
8e6adf6
7790: Make Zeromorph verification work in AVM recursive verifier
jeanmon Aug 26, 2024
6fba30c
7790: recursive verifier returns pairing pooints + other improvements
jeanmon Aug 27, 2024
4ba25b2
7790: Cleaning up recursive flavor
jeanmon Aug 28, 2024
e180d60
7790: Remove BATCHED_RELATION_TOTAL_LENGTH constant in all flavors
jeanmon Aug 28, 2024
31d29e3
7790: additional clean ups
jeanmon Aug 28, 2024
ad67582
7790: Keep certain classes in flavor.hpp private
jeanmon Aug 29, 2024
68e3dde
7790: some review feedback is addressed
jeanmon Aug 29, 2024
f2021ec
7790: remove _recursive.hpp generated files
jeanmon Aug 29, 2024
4bc2381
7790: remove code-gen related to recursive files
jeanmon Aug 29, 2024
33c16ad
7790: some other review comments are addressed
jeanmon Aug 29, 2024
84412e7
7790: resolve conflict after rebase on master
jeanmon Aug 29, 2024
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
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
Loading