Skip to content

Commit

Permalink
Pare down ECCVM flavor
Browse files Browse the repository at this point in the history
  • Loading branch information
codygunton committed Mar 19, 2024
1 parent c8897ca commit 9af7d58
Showing 1 changed file with 25 additions and 47 deletions.
72 changes: 25 additions & 47 deletions barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once
#include "barretenberg/commitment_schemes/commitment_key.hpp"
// #include "barretenberg/commitment_schemes/commitment_key.hpp"
#include "barretenberg/commitment_schemes/ipa/ipa.hpp"
#include "barretenberg/commitment_schemes/kzg/kzg.hpp"
#include "barretenberg/common/std_array.hpp"
#include "barretenberg/ecc/curves/bn254/bn254.hpp"
#include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp"
Expand All @@ -17,24 +16,16 @@
#include "barretenberg/relations/relation_parameters.hpp"
#include "barretenberg/relations/relation_types.hpp"
#include "relation_definitions.hpp"
#include <array>
#include <concepts>
#include <span>
#include <string>
#include <type_traits>
#include <vector>

// NOLINTBEGIN(cppcoreguidelines-avoid-const-or-ref-data-members)

namespace bb {

template <typename CycleGroup_T, typename Curve_T, typename PCS_T> class ECCVMBase {
class ECCVMFlavor {
public:
// forward template params into the ECCVMBase namespace
using CycleGroup = CycleGroup_T;
using Curve = Curve_T;
using CycleGroup = bb::g1;
using Curve = curve::Grumpkin;
using G1 = typename Curve::Group;
using PCS = PCS_T;
using PCS = IPA<Curve>;

using FF = typename G1::subgroup_field;
using Polynomial = bb::Polynomial<FF>;
Expand Down Expand Up @@ -300,7 +291,7 @@ template <typename CycleGroup_T, typename Curve_T, typename PCS_T> class ECCVMBa
return concatenate(PrecomputedEntities<DataType>::get_all(), WitnessEntities<DataType>::get_all());
};

auto get_to_be_shifted() { return ECCVMBase::get_to_be_shifted<DataType>(*this); }
auto get_to_be_shifted() { return ECCVMFlavor::get_to_be_shifted<DataType>(*this); }
auto get_shifted() { return ShiftedEntities<DataType>::get_all(); };
};

Expand All @@ -316,7 +307,7 @@ template <typename CycleGroup_T, typename Curve_T, typename PCS_T> class ECCVMBa
using Base = ProvingKey_<PrecomputedEntities<Polynomial>, WitnessEntities<Polynomial>, CommitmentKey>;
using Base::Base;

auto get_to_be_shifted() { return ECCVMBase::get_to_be_shifted<Polynomial>(*this); }
auto get_to_be_shifted() { return ECCVMFlavor::get_to_be_shifted<Polynomial>(*this); }
// The plookup wires that store plookup read data.
RefArray<Polynomial, 0> get_table_column_wires() { return {}; };
};
Expand Down Expand Up @@ -345,7 +336,6 @@ template <typename CycleGroup_T, typename Curve_T, typename PCS_T> class ECCVMBa
public:
using Base = AllEntities<FF>;
using Base::Base;
AllValues(std::array<FF, NUM_ALL_ENTITIES> _data_in) { this->_data = _data_in; }
};

/**
Expand Down Expand Up @@ -791,24 +781,17 @@ template <typename CycleGroup_T, typename Curve_T, typename PCS_T> class ECCVMBa
}
shplonk_q_comm = NativeTranscript::template deserialize_from_buffer<Commitment>(
NativeTranscript::proof_data, num_frs_read);
if (std::is_same<PCS, KZG<curve::BN254>>::value) {
kzg_w_comm = NativeTranscript::template deserialize_from_buffer<Commitment>(
NativeTranscript::proof_data, num_frs_read);
} else if (std::is_same<PCS, IPA<curve::Grumpkin>>::value) {
ipa_poly_degree = NativeTranscript::template deserialize_from_buffer<uint32_t>(
NativeTranscript::proof_data, num_frs_read);
auto log_poly_degree = static_cast<size_t>(numeric::get_msb(ipa_poly_degree));
for (size_t i = 0; i < log_poly_degree; ++i) {
ipa_l_comms.emplace_back(NativeTranscript::template deserialize_from_buffer<Commitment>(
NativeTranscript::proof_data, num_frs_read));
ipa_r_comms.emplace_back(NativeTranscript::template deserialize_from_buffer<Commitment>(
NativeTranscript::proof_data, num_frs_read));
}
ipa_a_0_eval =
NativeTranscript::template deserialize_from_buffer<FF>(NativeTranscript::proof_data, num_frs_read);
} else {
throw_or_abort("Unsupported PCS");
ipa_poly_degree = NativeTranscript::template deserialize_from_buffer<uint32_t>(NativeTranscript::proof_data,
num_frs_read);
auto log_poly_degree = static_cast<size_t>(numeric::get_msb(ipa_poly_degree));
for (size_t i = 0; i < log_poly_degree; ++i) {
ipa_l_comms.emplace_back(NativeTranscript::template deserialize_from_buffer<Commitment>(
NativeTranscript::proof_data, num_frs_read));
ipa_r_comms.emplace_back(NativeTranscript::template deserialize_from_buffer<Commitment>(
NativeTranscript::proof_data, num_frs_read));
}
ipa_a_0_eval =
NativeTranscript::template deserialize_from_buffer<FF>(NativeTranscript::proof_data, num_frs_read);
}

void serialize_full_transcript()
Expand Down Expand Up @@ -911,25 +894,20 @@ template <typename CycleGroup_T, typename Curve_T, typename PCS_T> class ECCVMBa
NativeTranscript::template serialize_to_buffer(gemini_a_evals[i], NativeTranscript::proof_data);
}
NativeTranscript::template serialize_to_buffer(shplonk_q_comm, NativeTranscript::proof_data);
if (std::is_same<PCS, KZG<curve::BN254>>::value) {
NativeTranscript::template serialize_to_buffer(kzg_w_comm, NativeTranscript::proof_data);
} else if (std::is_same<PCS, IPA<curve::Grumpkin>>::value) {
NativeTranscript::template serialize_to_buffer(ipa_poly_degree, NativeTranscript::proof_data);
auto log_poly_degree = static_cast<size_t>(numeric::get_msb(ipa_poly_degree));
for (size_t i = 0; i < log_poly_degree; ++i) {
NativeTranscript::template serialize_to_buffer(ipa_l_comms[i], NativeTranscript::proof_data);
NativeTranscript::template serialize_to_buffer(ipa_r_comms[i], NativeTranscript::proof_data);
}

NativeTranscript::template serialize_to_buffer(ipa_a_0_eval, NativeTranscript::proof_data);
NativeTranscript::template serialize_to_buffer(ipa_poly_degree, NativeTranscript::proof_data);
auto log_poly_degree = static_cast<size_t>(numeric::get_msb(ipa_poly_degree));
for (size_t i = 0; i < log_poly_degree; ++i) {
NativeTranscript::template serialize_to_buffer(ipa_l_comms[i], NativeTranscript::proof_data);
NativeTranscript::template serialize_to_buffer(ipa_r_comms[i], NativeTranscript::proof_data);
}

NativeTranscript::template serialize_to_buffer(ipa_a_0_eval, NativeTranscript::proof_data);

ASSERT(NativeTranscript::proof_data.size() == old_proof_length);
}
};
};

class ECCVMFlavor : public ECCVMBase<bb::g1, curve::Grumpkin, IPA<curve::Grumpkin>> {};

// NOLINTEND(cppcoreguidelines-avoid-const-or-ref-data-members)

} // namespace bb

0 comments on commit 9af7d58

Please sign in to comment.