Skip to content
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
11 changes: 0 additions & 11 deletions barretenberg/cpp/src/barretenberg/eccvm/eccvm_flavor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ class ECCVMFlavor {

// TODO(https://github.com/AztecProtocol/barretenberg/issues/989): refine access specifiers in flavors, this is
// public as it is also used in the recursive flavor but the two could possibly me unified eventually
public:
/**
* @brief A base class labelling precomputed entities and (ordered) subsets of interest.
* @details Used to build the proving key and verification key.
Expand Down Expand Up @@ -353,16 +352,7 @@ class ECCVMFlavor {
public WitnessEntities<DataType>,
public ShiftedEntities<DataType> {
public:
// Initialize members
AllEntities()
: PrecomputedEntities<DataType>{}
, WitnessEntities<DataType>{}
, ShiftedEntities<DataType>{}
{}
// get_wires is inherited

DEFINE_COMPOUND_GET_ALL(PrecomputedEntities<DataType>, WitnessEntities<DataType>, ShiftedEntities<DataType>)
// Gemini-specific getters.
auto get_unshifted()
{
return concatenate(PrecomputedEntities<DataType>::get_all(), WitnessEntities<DataType>::get_all());
Expand All @@ -372,7 +362,6 @@ class ECCVMFlavor {
auto get_precomputed() { return PrecomputedEntities<DataType>::get_all(); };
};

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 @@ -159,9 +159,9 @@ class MegaFlavor {
}
auto get_selectors() { return concatenate(get_non_gate_selectors(), get_gate_selectors()); }

auto get_sigma_polynomials() { return RefArray{ sigma_1, sigma_2, sigma_3, sigma_4 }; };
auto get_id_polynomials() { return RefArray{ id_1, id_2, id_3, id_4 }; };
auto get_table_polynomials() { return RefArray{ table_1, table_2, table_3, table_4 }; };
auto get_sigmas() { return RefArray{ sigma_1, sigma_2, sigma_3, sigma_4 }; };
auto get_ids() { return RefArray{ id_1, id_2, id_3, id_4 }; };
auto get_tables() { return RefArray{ table_1, table_2, table_3, table_4 }; };
};

// Mega needs to expose more public classes than most flavors due to MegaRecursive reuse, but these
Expand Down Expand Up @@ -297,20 +297,12 @@ class MegaFlavor {
public:
DEFINE_COMPOUND_GET_ALL(PrecomputedEntities<DataType>, WitnessEntities<DataType>, ShiftedEntities<DataType>)

auto get_wires() { return WitnessEntities<DataType>::get_wires(); };
auto get_non_gate_selectors() { return PrecomputedEntities<DataType>::get_non_gate_selectors(); }
auto get_gate_selectors() { return PrecomputedEntities<DataType>::get_gate_selectors(); }
auto get_selectors() { return PrecomputedEntities<DataType>::get_selectors(); }
auto get_sigmas() { return PrecomputedEntities<DataType>::get_sigma_polynomials(); };
auto get_ids() { return PrecomputedEntities<DataType>::get_id_polynomials(); };
auto get_tables() { return PrecomputedEntities<DataType>::get_table_polynomials(); };
auto get_unshifted()
{
return concatenate(PrecomputedEntities<DataType>::get_all(), WitnessEntities<DataType>::get_all());
};
auto get_precomputed() { return PrecomputedEntities<DataType>::get_all(); }
auto get_witness() { return WitnessEntities<DataType>::get_all(); };
auto get_to_be_shifted() { return WitnessEntities<DataType>::get_to_be_shifted(); };
auto get_shifted() { return ShiftedEntities<DataType>::get_all(); };
};

Expand Down Expand Up @@ -369,10 +361,10 @@ class MegaFlavor {
[[nodiscard]] AllValues get_row_for_permutation_arg(size_t row_idx)
{
AllValues result;
for (auto [result_field, polynomial] : zip_view(result.get_sigma_polynomials(), get_sigma_polynomials())) {
for (auto [result_field, polynomial] : zip_view(result.get_sigmas(), get_sigmas())) {
result_field = polynomial[row_idx];
}
for (auto [result_field, polynomial] : zip_view(result.get_id_polynomials(), get_id_polynomials())) {
for (auto [result_field, polynomial] : zip_view(result.get_ids(), get_ids())) {
result_field = polynomial[row_idx];
}
for (auto [result_field, polynomial] : zip_view(result.get_wires(), get_wires())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ class UltraFlavor {
}
auto get_selectors() { return concatenate(get_non_gate_selectors(), get_gate_selectors()); }

auto get_sigma_polynomials() { return RefArray{ sigma_1, sigma_2, sigma_3, sigma_4 }; };
auto get_id_polynomials() { return RefArray{ id_1, id_2, id_3, id_4 }; };
auto get_table_polynomials() { return RefArray{ table_1, table_2, table_3, table_4 }; };
auto get_sigmas() { return RefArray{ sigma_1, sigma_2, sigma_3, sigma_4 }; };
auto get_ids() { return RefArray{ id_1, id_2, id_3, id_4 }; };
auto get_tables() { return RefArray{ table_1, table_2, table_3, table_4 }; };
};

/**
Expand Down Expand Up @@ -231,20 +231,12 @@ class UltraFlavor {
public:
DEFINE_COMPOUND_GET_ALL(PrecomputedEntities<DataType>, WitnessEntities<DataType>, ShiftedEntities<DataType>)

auto get_wires() { return WitnessEntities<DataType>::get_wires(); };
auto get_non_gate_selectors() { return PrecomputedEntities<DataType>::get_non_gate_selectors(); }
auto get_gate_selectors() { return PrecomputedEntities<DataType>::get_gate_selectors(); }
auto get_selectors() { return PrecomputedEntities<DataType>::get_selectors(); }
auto get_sigmas() { return PrecomputedEntities<DataType>::get_sigma_polynomials(); };
auto get_ids() { return PrecomputedEntities<DataType>::get_id_polynomials(); };
auto get_tables() { return PrecomputedEntities<DataType>::get_table_polynomials(); };
auto get_unshifted()
{
return concatenate(PrecomputedEntities<DataType>::get_all(), WitnessEntities<DataType>::get_all());
};
auto get_precomputed() { return PrecomputedEntities<DataType>::get_all(); }
auto get_witness() { return WitnessEntities<DataType>::get_all(); };
auto get_to_be_shifted() { return WitnessEntities<DataType>::get_to_be_shifted(); };
};

/**
Expand Down Expand Up @@ -302,10 +294,10 @@ class UltraFlavor {
[[nodiscard]] AllValues get_row_for_permutation_arg(size_t row_idx)
{
AllValues result;
for (auto [result_field, polynomial] : zip_view(result.get_sigma_polynomials(), get_sigma_polynomials())) {
for (auto [result_field, polynomial] : zip_view(result.get_sigmas(), get_sigmas())) {
result_field = polynomial[row_idx];
}
for (auto [result_field, polynomial] : zip_view(result.get_id_polynomials(), get_id_polynomials())) {
for (auto [result_field, polynomial] : zip_view(result.get_ids(), get_ids())) {
result_field = polynomial[row_idx];
}
for (auto [result_field, polynomial] : zip_view(result.get_wires(), get_wires())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ TEST_F(TranslatorRelationCorrectnessTests, ZeroKnowledgePermutation)

// Populate the first 4 ordered polynomials with the random values from the interleaved polynomials
for (size_t i = 0; i < 4; i++) {
auto& ordered = prover_polynomials.get_ordered_constraints()[i];
auto& ordered = prover_polynomials.get_ordered_range_constraints()[i];
auto& interleaved = prover_polynomials.get_interleaved()[i];
for (size_t j = real_circuit_size; j < full_circuit_size; j++) {
ordered.at(j) = interleaved.at(j);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class TranslatorFlavor {

// Indicates that this flavor runs with ZK Sumcheck.
static constexpr bool HasZK = true;

// A minicircuit of such size allows for 10 rounds of folding (i.e. 20 circuits).
// Lowest possible size for the translator circuit (this sets the mini_circuit_size)
static constexpr size_t MINIMUM_MINI_CIRCUIT_SIZE = 2048;
Expand Down Expand Up @@ -291,23 +292,29 @@ class TranslatorFlavor {
DerivedWitnessEntities<DataType>,
InterleavedRangeConstraints<DataType>)

// Used when populating wire polynomials directly from circuit data
/**
* @brief Entities constructed from circuit data.
*
*/
auto get_wires()
{
return concatenate(WireNonshiftedEntities<DataType>::get_all(),
WireToBeShiftedEntities<DataType>::get_all());
};

// Used when computing commitments to wires + ordered range constraints during proof construction
/**
* @brief Witness Entities to which the prover commits and do not require challenges (i.e. not derived).
*/
auto get_wires_and_ordered_range_constraints()
{
return concatenate(WireNonshiftedEntities<DataType>::get_all(),
WireToBeShiftedEntities<DataType>::get_all(),
OrderedRangeConstraints<DataType>::get_all());
};

// everything but InterleavedRangeConstraints (used for Shplemini input since interleaved handled separately)
// TODO(https://github.com/AztecProtocol/barretenberg/issues/810)
/**
* @brief Witness Entities on which Shplemini operates in the default manner.
*/
auto get_unshifted_without_interleaved()
{
return concatenate(WireNonshiftedEntities<DataType>::get_all(),
Expand All @@ -324,6 +331,7 @@ class TranslatorFlavor {
DerivedWitnessEntities<DataType>::get_all(),
InterleavedRangeConstraints<DataType>::get_all());
}

auto get_to_be_shifted()
{
return concatenate(WireToBeShiftedEntities<DataType>::get_all(),
Expand All @@ -332,16 +340,13 @@ class TranslatorFlavor {
};

/**
* @brief Get the polynomials that need to be constructed from other polynomials by interleaving
*
* @return auto
* @brief Get the entities constructed by interleaving.
*/
auto get_interleaved() { return InterleavedRangeConstraints<DataType>::get_all(); }

/**
* @brief Get the entities interleaved for the permutation relation
* @brief Get the entities interleaved for the permutation relation.
*
* @return std::vector<auto>
*/
std::vector<RefVector<DataType>> get_groups_to_be_interleaved()
{
Expand Down Expand Up @@ -516,10 +521,9 @@ class TranslatorFlavor {
z_perm_shift) // column 85
};

public:
/**
* @brief A base class labelling all entities (for instance, all of the polynomials used by the prover during
* sumcheck) in this Honk variant along with particular subsets of interest
* sumcheck) in this Honk variant along with particular subsets of interest.
* @details Used to build containers for: the prover's polynomial during sumcheck; the sumcheck's folded
* polynomials; the univariates consturcted during during sumcheck; the evaluations produced by sumcheck.
*
Expand All @@ -534,48 +538,29 @@ class TranslatorFlavor {

auto get_precomputed() const { return PrecomputedEntities<DataType>::get_all(); };

/**
* @brief Get entities interleaved for the permutation relation
*
*/
std::vector<RefVector<DataType>> get_groups_to_be_interleaved()
{
return WitnessEntities<DataType>::get_groups_to_be_interleaved();
}
/**
* @brief Getter for entities constructed by interleaving
*/
auto get_interleaved() { return InterleavedRangeConstraints<DataType>::get_all(); };

/**
* @brief Get the polynomials from the grand product denominator
*
* @return auto
* @brief Getter for the ordered entities used in computing the denominator of the grand product in the
* permutation relation.
*/
auto get_ordered_constraints()
{
return RefArray{ this->ordered_range_constraints_0,
this->ordered_range_constraints_1,
this->ordered_range_constraints_2,
this->ordered_range_constraints_3,
this->ordered_range_constraints_4 };
};
auto get_ordered_range_constraints() { return OrderedRangeConstraints<DataType>::get_all(); };

auto get_unshifted()
{
return concatenate(PrecomputedEntities<DataType>::get_all(), WitnessEntities<DataType>::get_unshifted());
}
// TODO(https://github.com/AztecProtocol/barretenberg/issues/810)

auto get_unshifted_without_interleaved()
{
return concatenate(PrecomputedEntities<DataType>::get_all(),
WitnessEntities<DataType>::get_unshifted_without_interleaved());
}
// get_to_be_shifted is inherited

auto get_shifted() { return ShiftedEntities<DataType>::get_all(); };
auto get_wires_and_ordered_range_constraints()
{
return WitnessEntities<DataType>::get_wires_and_ordered_range_constraints();
};

friend std::ostream& operator<<(std::ostream& os, const AllEntities& a)
{
Expand Down Expand Up @@ -612,7 +597,7 @@ class TranslatorFlavor {
ProverPolynomials(size_t mini_circuit_size)
{
size_t circuit_size = mini_circuit_size * INTERLEAVING_GROUP_SIZE;
for (auto& ordered_range_constraint : get_ordered_constraints()) {
for (auto& ordered_range_constraint : get_ordered_range_constraints()) {
ordered_range_constraint = Polynomial{ /*size*/ circuit_size - 1,
/*largest possible index*/ circuit_size,
1 };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ void TranslatorProver::execute_wire_and_sorted_constraints_commitments_round()
}

// The ordered range constraints are of full circuit size.
for (const auto& [ordered_range_constraint, label] : zip_view(
key->proving_key->polynomials.get_ordered_constraints(), commitment_labels.get_ordered_constraints())) {
for (const auto& [ordered_range_constraint, label] :
zip_view(key->proving_key->polynomials.get_ordered_range_constraints(),
commitment_labels.get_ordered_range_constraints())) {
commit_to_witness_polynomial(ordered_range_constraint, label);
}
}
Expand Down