Skip to content

Commit

Permalink
fix build and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ledwards2225 committed Jun 21, 2024
1 parent cd2da7a commit c36266c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ std::array<typename Flavor::Polynomial, 4> construct_sorted_list_polynomials(typ
#endif

for (const auto& entry : lookup_gates) {
const auto components = entry.to_sorted_list_components(table.use_twin_keys);
const auto components = entry.to_table_components(table.use_twin_keys);
sorted_polynomials[0][s_index] = components[0];
sorted_polynomials[1][s_index] = components[1];
sorted_polynomials[2][s_index] = components[2];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,12 @@ void construct_lookup_read_counts(typename Flavor::Polynomial& read_counts,
for (auto& table : circuit.lookup_tables) {
table.initialize_index_map();

for (auto& entry : table.lookup_gates) {
// convert lookup entry to an array of three field elements, one for each of the 3 columns
// WORKTODO change name of this method
auto data = entry.to_sorted_list_components(table.use_twin_keys);
for (auto& gate_data : table.lookup_gates) {
// convert lookup gate data to an array of three field elements, one for each of the 3 columns
auto table_entry = gate_data.to_table_components(table.use_twin_keys);

// find the index of the entry in the table
auto index_in_table = table.index_map[data];
auto index_in_table = table.index_map[table_entry];

// increment the read count at the corresponding index in the full polynomial
size_t index_in_poly = table_offset + index_in_table;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,9 @@ template <typename Flavor> class ProtoGalaxyTests : public testing::Test {
auto [prover_accumulator, verifier_accumulator] = fold_and_verify(get<0>(instances), get<1>(instances));

// Expect failure in manual target sum check and decider
bool expected_result check_accumulator_target_sum_manual(prover_accumulator, false);
decide_and_verify(prover_accumulator, verifier_accumulator, false);
bool expected_result = false;
check_accumulator_target_sum_manual(prover_accumulator, expected_result);
decide_and_verify(prover_accumulator, verifier_accumulator, expected_result);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ template <typename FF_> class LogDerivLookupRelationImpl {
LENGTH // log derivative lookup argument sub-relation
};

// WORKTODO: shouldnt first one be 2? code doesnt compile that way
// WORKTODO: shouldnt first one be 2? Why do tests pass with 1? (Note: if setting to 2, both need to be 2 due to
// structure of relation algebra)
static constexpr std::array<size_t, 2> TOTAL_LENGTH_ADJUSTMENTS{
1, // inverse construction sub-relation
1 // log derivative lookup argument sub-relation
Expand Down Expand Up @@ -144,10 +145,10 @@ template <typename FF_> class LogDerivLookupRelationImpl {
*
* where write_term = table_col_1 + \gamma + table_col_2 * \eta_1 + table_col_3 * \eta_2 + table_index * \eta_3
* and read_term = derived_table_entry_1 + \gamma + derived_table_entry_2 * \eta_1 + derived_table_entry_3 * \eta_2
* + table_index * \eta_3, with derived_table_entry_i = w_i - col_step_size\cdot w_i_shift. (The table entries must
* be 'derived' from wire values in this way since the stored witnesses are actually successive accumulators, the
* differences of which are equal to entries in a table. This is an efficiency trick to avoid using additional gates
* to reconstruct full size values from the limbs contained in tables).
* + table_index * \eta_3, with derived_table_entry_i = w_i - col_step_size_i\cdot w_i_shift. (The table entries
* must be 'derived' from wire values in this way since the stored witnesses are actually successive accumulators,
* the differences of which are equal to entries in a table. This is an efficiency trick to avoid using additional
* gates to reconstruct full size values from the limbs contained in tables).
*
* In practice this identity is expressed in terms of polynomials by defining a polynomial of inverses I_i =
* \frac{1}{read_term_i\cdot write_term_i} then rewriting the above identity as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ struct MultiTable {
// std::array<bb::fr, 2> value{ bb::fr(0), bb::fr(0) };
// bool operator<(const KeyEntry& other) const { return key < other.key; }

// std::array<bb::fr, 3> to_sorted_list_components(const bool use_two_keys) const
// std::array<bb::fr, 3> to_table_components(const bool use_two_keys) const
// {
// return {
// key[0],
Expand Down Expand Up @@ -248,7 +248,7 @@ struct MultiTable {
// return (key.from_montgomery_form() < other.key.from_montgomery_form());
// }

// std::array<bb::fr, 3> to_sorted_list_components() const { return { key, values[0], values[0] }; }
// std::array<bb::fr, 3> to_table_components() const { return { key, values[0], values[0] }; }
// }

// BasicTableId id;
Expand Down Expand Up @@ -349,7 +349,8 @@ struct BasicTable {
return key[0] < other.key[0] || ((key[0] == other.key[0]) && key[1] < other.key[1]);
}

std::array<bb::fr, 3> to_sorted_list_components(const bool use_two_keys) const
// Express the key-value pair as the entries of a 3-column row in a table
std::array<bb::fr, 3> to_table_components(const bool use_two_keys) const
{
return {
bb::fr(key[0]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,6 @@ class UltraCircuitBuilder_ : public CircuitBuilderBase<typename Arithmetization_
*/
size_t get_total_circuit_size() const
{
// WORKTODO: update everywhere that uses the old s_accum size
auto minimum_circuit_size = get_tables_size() + get_lookups_size();
auto num_filled_gates = get_num_gates() + this->public_inputs.size();
return std::max(minimum_circuit_size, num_filled_gates) + NUM_RESERVED_GATES;
Expand Down

0 comments on commit c36266c

Please sign in to comment.