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: ultra honk arith from ultra #3274

Merged
merged 7 commits into from
Nov 10, 2023
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
188 changes: 113 additions & 75 deletions barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ class GoblinUltra {
// The number of multivariate polynomials on which a sumcheck prover sumcheck operates (including shifts). We often
// need containers of this size to hold related data, so we choose a name more agnostic than `NUM_POLYNOMIALS`.
// Note: this number does not include the individual sorted list polynomials.
static constexpr size_t NUM_ALL_ENTITIES = 48; // 43 (UH) + 4 op wires + 1 op wire "selector"
// NUM = 43 (UH) + 4 op wires + 1 op wire "selector" + 3 (calldata + calldata_read_counts + q_busread)
static constexpr size_t NUM_ALL_ENTITIES = 51;
// The number of polynomials precomputed to describe a circuit and to aid a prover in constructing a satisfying
// assignment of witnesses. We again choose a neutral name.
static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 26; // 25 (UH) + 1 op wire "selector"
static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 27; // 25 (UH) + 1 op wire "selector" + q_busread
// The total number of witness entities not including shifts.
static constexpr size_t NUM_WITNESS_ENTITIES = 15; // 11 (UH) + 4 op wires
static constexpr size_t NUM_WITNESS_ENTITIES = 17; // 11 (UH) + 4 op wires + (calldata + calldata_read_counts)

using GrandProductRelations =
std::tuple<proof_system::UltraPermutationRelation<FF>, proof_system::LookupRelation<FF>>;
Expand Down Expand Up @@ -89,27 +90,28 @@ class GoblinUltra {
DataType& q_elliptic = std::get<8>(this->_data);
DataType& q_aux = std::get<9>(this->_data);
DataType& q_lookup = std::get<10>(this->_data);
DataType& sigma_1 = std::get<11>(this->_data);
DataType& sigma_2 = std::get<12>(this->_data);
DataType& sigma_3 = std::get<13>(this->_data);
DataType& sigma_4 = std::get<14>(this->_data);
DataType& id_1 = std::get<15>(this->_data);
DataType& id_2 = std::get<16>(this->_data);
DataType& id_3 = std::get<17>(this->_data);
DataType& id_4 = std::get<18>(this->_data);
DataType& table_1 = std::get<19>(this->_data);
DataType& table_2 = std::get<20>(this->_data);
DataType& table_3 = std::get<21>(this->_data);
DataType& table_4 = std::get<22>(this->_data);
DataType& lagrange_first = std::get<23>(this->_data);
DataType& lagrange_last = std::get<24>(this->_data);
DataType& lagrange_ecc_op = std::get<25>(this->_data); // indicator poly for ecc op gates
DataType& q_busread = std::get<11>(this->_data);
DataType& sigma_1 = std::get<12>(this->_data);
DataType& sigma_2 = std::get<13>(this->_data);
DataType& sigma_3 = std::get<14>(this->_data);
DataType& sigma_4 = std::get<15>(this->_data);
DataType& id_1 = std::get<16>(this->_data);
DataType& id_2 = std::get<17>(this->_data);
DataType& id_3 = std::get<18>(this->_data);
DataType& id_4 = std::get<19>(this->_data);
DataType& table_1 = std::get<20>(this->_data);
DataType& table_2 = std::get<21>(this->_data);
DataType& table_3 = std::get<22>(this->_data);
DataType& table_4 = std::get<23>(this->_data);
DataType& lagrange_first = std::get<24>(this->_data);
DataType& lagrange_last = std::get<25>(this->_data);
DataType& lagrange_ecc_op = std::get<26>(this->_data); // indicator poly for ecc op gates

static constexpr CircuitType CIRCUIT_TYPE = CircuitBuilder::CIRCUIT_TYPE;

std::vector<HandleType> get_selectors() override
{
return { q_m, q_c, q_l, q_r, q_o, q_4, q_arith, q_sort, q_elliptic, q_aux, q_lookup };
return { q_m, q_c, q_l, q_r, q_o, q_4, q_arith, q_sort, q_elliptic, q_aux, q_lookup, q_busread };
};
std::vector<HandleType> get_sigma_polynomials() override { return { sigma_1, sigma_2, sigma_3, sigma_4 }; };
std::vector<HandleType> get_id_polynomials() override { return { id_1, id_2, id_3, id_4 }; };
Expand Down Expand Up @@ -139,6 +141,8 @@ class GoblinUltra {
DataType& ecc_op_wire_2 = std::get<12>(this->_data);
DataType& ecc_op_wire_3 = std::get<13>(this->_data);
DataType& ecc_op_wire_4 = std::get<14>(this->_data);
DataType& calldata = std::get<15>(this->_data);
DataType& calldata_read_counts = std::get<16>(this->_data);

std::vector<HandleType> get_wires() override { return { w_l, w_r, w_o, w_4 }; };
std::vector<HandleType> get_ecc_op_wires()
Expand Down Expand Up @@ -172,43 +176,46 @@ class GoblinUltra {
DataType& q_elliptic = std::get<8>(this->_data);
DataType& q_aux = std::get<9>(this->_data);
DataType& q_lookup = std::get<10>(this->_data);
DataType& sigma_1 = std::get<11>(this->_data);
DataType& sigma_2 = std::get<12>(this->_data);
DataType& sigma_3 = std::get<13>(this->_data);
DataType& sigma_4 = std::get<14>(this->_data);
DataType& id_1 = std::get<15>(this->_data);
DataType& id_2 = std::get<16>(this->_data);
DataType& id_3 = std::get<17>(this->_data);
DataType& id_4 = std::get<18>(this->_data);
DataType& table_1 = std::get<19>(this->_data);
DataType& table_2 = std::get<20>(this->_data);
DataType& table_3 = std::get<21>(this->_data);
DataType& table_4 = std::get<22>(this->_data);
DataType& lagrange_first = std::get<23>(this->_data);
DataType& lagrange_last = std::get<24>(this->_data);
DataType& lagrange_ecc_op = std::get<25>(this->_data);
DataType& w_l = std::get<26>(this->_data);
DataType& w_r = std::get<27>(this->_data);
DataType& w_o = std::get<28>(this->_data);
DataType& w_4 = std::get<29>(this->_data);
DataType& sorted_accum = std::get<30>(this->_data);
DataType& z_perm = std::get<31>(this->_data);
DataType& z_lookup = std::get<32>(this->_data);
DataType& ecc_op_wire_1 = std::get<33>(this->_data);
DataType& ecc_op_wire_2 = std::get<34>(this->_data);
DataType& ecc_op_wire_3 = std::get<35>(this->_data);
DataType& ecc_op_wire_4 = std::get<36>(this->_data);
DataType& table_1_shift = std::get<37>(this->_data);
DataType& table_2_shift = std::get<38>(this->_data);
DataType& table_3_shift = std::get<39>(this->_data);
DataType& table_4_shift = std::get<40>(this->_data);
DataType& w_l_shift = std::get<41>(this->_data);
DataType& w_r_shift = std::get<42>(this->_data);
DataType& w_o_shift = std::get<43>(this->_data);
DataType& w_4_shift = std::get<44>(this->_data);
DataType& sorted_accum_shift = std::get<45>(this->_data);
DataType& z_perm_shift = std::get<46>(this->_data);
DataType& z_lookup_shift = std::get<47>(this->_data);
DataType& q_busread = std::get<11>(this->_data);
DataType& sigma_1 = std::get<12>(this->_data);
DataType& sigma_2 = std::get<13>(this->_data);
DataType& sigma_3 = std::get<14>(this->_data);
DataType& sigma_4 = std::get<15>(this->_data);
DataType& id_1 = std::get<16>(this->_data);
DataType& id_2 = std::get<17>(this->_data);
DataType& id_3 = std::get<18>(this->_data);
DataType& id_4 = std::get<19>(this->_data);
DataType& table_1 = std::get<20>(this->_data);
DataType& table_2 = std::get<21>(this->_data);
DataType& table_3 = std::get<22>(this->_data);
DataType& table_4 = std::get<23>(this->_data);
DataType& lagrange_first = std::get<24>(this->_data);
DataType& lagrange_last = std::get<25>(this->_data);
DataType& lagrange_ecc_op = std::get<26>(this->_data);
DataType& w_l = std::get<27>(this->_data);
DataType& w_r = std::get<28>(this->_data);
DataType& w_o = std::get<29>(this->_data);
DataType& w_4 = std::get<30>(this->_data);
DataType& sorted_accum = std::get<31>(this->_data);
DataType& z_perm = std::get<32>(this->_data);
DataType& z_lookup = std::get<33>(this->_data);
DataType& ecc_op_wire_1 = std::get<34>(this->_data);
DataType& ecc_op_wire_2 = std::get<35>(this->_data);
DataType& ecc_op_wire_3 = std::get<36>(this->_data);
DataType& ecc_op_wire_4 = std::get<37>(this->_data);
DataType& calldata = std::get<38>(this->_data);
DataType& calldata_read_counts = std::get<39>(this->_data);
DataType& table_1_shift = std::get<40>(this->_data);
DataType& table_2_shift = std::get<41>(this->_data);
DataType& table_3_shift = std::get<42>(this->_data);
DataType& table_4_shift = std::get<43>(this->_data);
DataType& w_l_shift = std::get<44>(this->_data);
DataType& w_r_shift = std::get<45>(this->_data);
DataType& w_o_shift = std::get<46>(this->_data);
DataType& w_4_shift = std::get<47>(this->_data);
DataType& sorted_accum_shift = std::get<48>(this->_data);
DataType& z_perm_shift = std::get<49>(this->_data);
DataType& z_lookup_shift = std::get<50>(this->_data);

std::vector<HandleType> get_wires() override { return { w_l, w_r, w_o, w_4 }; };
std::vector<HandleType> get_ecc_op_wires()
Expand All @@ -218,25 +225,46 @@ class GoblinUltra {
// Gemini-specific getters.
std::vector<HandleType> get_unshifted() override
{
return { q_c, q_l,
q_r, q_o,
q_4, q_m,
q_arith, q_sort,
q_elliptic, q_aux,
q_lookup, sigma_1,
sigma_2, sigma_3,
sigma_4, id_1,
id_2, id_3,
id_4, table_1,
table_2, table_3,
table_4, lagrange_first,
lagrange_last, lagrange_ecc_op,
w_l, w_r,
w_o, w_4,
sorted_accum, z_perm,
z_lookup, ecc_op_wire_1,
ecc_op_wire_2, ecc_op_wire_3,
ecc_op_wire_4 };
return { q_c,
q_l,
q_r,
q_o,
q_4,
q_m,
q_arith,
q_sort,
q_elliptic,
q_aux,
q_lookup,
q_busread,
sigma_1,
sigma_2,
sigma_3,
sigma_4,
id_1,
id_2,
id_3,
id_4,
table_1,
table_2,
table_3,
table_4,
lagrange_first,
lagrange_last,
lagrange_ecc_op,
w_l,
w_r,
w_o,
w_4,
sorted_accum,
z_perm,
z_lookup,
ecc_op_wire_1,
ecc_op_wire_2,
ecc_op_wire_3,
ecc_op_wire_4,
calldata,
calldata_read_counts };
};
std::vector<HandleType> get_to_be_shifted() override
{
Expand Down Expand Up @@ -384,6 +412,8 @@ class GoblinUltra {
ecc_op_wire_2 = "ECC_OP_WIRE_2";
ecc_op_wire_3 = "ECC_OP_WIRE_3";
ecc_op_wire_4 = "ECC_OP_WIRE_4";
calldata = "CALLDATA";
calldata_read_counts = "CALLDATA_READ_COUNTS";

// The ones beginning with "__" are only used for debugging
q_c = "__Q_C";
Expand All @@ -397,6 +427,7 @@ class GoblinUltra {
q_elliptic = "__Q_ELLIPTIC";
q_aux = "__Q_AUX";
q_lookup = "__Q_LOOKUP";
q_busread = "__Q_BUSREAD";
sigma_1 = "__SIGMA_1";
sigma_2 = "__SIGMA_2";
sigma_3 = "__SIGMA_3";
Expand Down Expand Up @@ -432,6 +463,7 @@ class GoblinUltra {
q_elliptic = verification_key->q_elliptic;
q_aux = verification_key->q_aux;
q_lookup = verification_key->q_lookup;
q_busread = verification_key->q_busread;
sigma_1 = verification_key->sigma_1;
sigma_2 = verification_key->sigma_2;
sigma_3 = verification_key->sigma_3;
Expand Down Expand Up @@ -473,6 +505,8 @@ class GoblinUltra {
Commitment ecc_op_wire_2_comm;
Commitment ecc_op_wire_3_comm;
Commitment ecc_op_wire_4_comm;
Commitment calldata_comm;
Commitment calldata_read_counts_comm;
Commitment sorted_accum_comm;
Commitment w_4_comm;
Commitment z_perm_comm;
Expand Down Expand Up @@ -507,6 +541,8 @@ class GoblinUltra {
ecc_op_wire_2_comm = deserialize_from_buffer<Commitment>(proof_data, num_bytes_read);
ecc_op_wire_3_comm = deserialize_from_buffer<Commitment>(proof_data, num_bytes_read);
ecc_op_wire_4_comm = deserialize_from_buffer<Commitment>(proof_data, num_bytes_read);
calldata_comm = deserialize_from_buffer<Commitment>(proof_data, num_bytes_read);
calldata_read_counts_comm = deserialize_from_buffer<Commitment>(proof_data, num_bytes_read);
sorted_accum_comm = deserialize_from_buffer<Commitment>(proof_data, num_bytes_read);
w_4_comm = deserialize_from_buffer<Commitment>(proof_data, num_bytes_read);
z_perm_comm = deserialize_from_buffer<Commitment>(proof_data, num_bytes_read);
Expand Down Expand Up @@ -543,6 +579,8 @@ class GoblinUltra {
serialize_to_buffer(ecc_op_wire_2_comm, proof_data);
serialize_to_buffer(ecc_op_wire_3_comm, proof_data);
serialize_to_buffer(ecc_op_wire_4_comm, proof_data);
serialize_to_buffer(calldata_comm, proof_data);
serialize_to_buffer(calldata_read_counts_comm, proof_data);
serialize_to_buffer(sorted_accum_comm, proof_data);
serialize_to_buffer(w_4_comm, proof_data);
serialize_to_buffer(z_perm_comm, proof_data);
Expand Down
Loading