Skip to content

Commit

Permalink
Lookup argument updated for work with tables placed in witness columns
Browse files Browse the repository at this point in the history
  • Loading branch information
ETatuzova committed Jul 12, 2024
1 parent 6945e28 commit c26270f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ namespace nil {
prepare_lookup_input();
auto& lookup_input = *lookup_input_ptr;


// 3. Lookup_input and lookup_value are ready
// Now sort them!
// Reduce value and input:
Expand All @@ -184,6 +185,7 @@ namespace nil {
for( std::size_t i = 0; i < lookup_input.size(); i++ ){
reduced_input.push_back(reduce_dfs_polynomial_domain(lookup_input[i], basic_domain->m));
}

// Sort
auto sorted = sort_polynomials(reduced_input, reduced_value, basic_domain->m,
preprocessed_data.common_data.desc.usable_rows_amount);
Expand Down Expand Up @@ -419,7 +421,22 @@ namespace nil {
math::polynomial_dfs<typename FieldType::value_type> v = (typename FieldType::value_type(t_id + 1)) * lookup_tag;
theta_acc = theta;
for (std::size_t i = 0; i < l_table.columns_number; i++) {
v += theta_acc * lookup_tag * plonk_columns.constant(l_table.lookup_options[o_id][i].index);
math::polynomial_dfs<typename FieldType::value_type> c;
switch( l_table.lookup_options[o_id][i].type ){
case DfsVariableType::column_type::witness:
c = plonk_columns.witness(l_table.lookup_options[o_id][i].index);
break;
case DfsVariableType::column_type::public_input:
c = plonk_columns.public_input(l_table.lookup_options[o_id][i].index);
break;
case DfsVariableType::column_type::constant:
c = plonk_columns.constant(l_table.lookup_options[o_id][i].index);
break;
case DfsVariableType::column_type::selector:
c = plonk_columns.selector(l_table.lookup_options[o_id][i].index);
break;
}
v += theta_acc * lookup_tag * c;
theta_acc *= theta;
}
v *= mask_assignment;
Expand Down Expand Up @@ -709,8 +726,8 @@ namespace nil {
theta_acc = theta;
BOOST_ASSERT(table.lookup_options[o_id].size() == table.columns_number);
for( std::size_t i = 0; i < table.lookup_options[o_id].size(); i++){
auto key1 = std::tuple(table.lookup_options[o_id][i].index, 0, plonk_variable<typename FieldType::value_type>::column_type::constant);
auto shifted_key1 = std::tuple(table.lookup_options[o_id][i].index, 1, plonk_variable<typename FieldType::value_type>::column_type::constant);
auto key1 = std::tuple(table.lookup_options[o_id][i].index, 0, table.lookup_options[o_id][i].type);
auto shifted_key1 = std::tuple(table.lookup_options[o_id][i].index, 1, table.lookup_options[o_id][i].type);
v += theta_acc * evaluations[key1] * selector_value;
shifted_v += theta_acc * evaluations[shifted_key1]* shifted_selector_value;
theta_acc *= theta;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ namespace nil {
const plonk_constraint_system<FieldType> &constraint_system,
const plonk_table_description<FieldType> &table_description
) {
using var = plonk_variable<typename FieldType::value_type>;
std::vector<std::set<int>> result(table_description.table_width());

for (auto & s : result) {
Expand Down Expand Up @@ -402,11 +403,10 @@ namespace nil {
].insert(1);
for( const auto &option:table.lookup_options){
for( const auto &column:option){
result[
table_description.witness_columns +
table_description.public_input_columns +
column.index
].insert(1);
if( column.type == var::column_type::witness ) result[column.index].insert(1);
if( column.type == var::column_type::public_input ) result[ table_description.witness_columns + column.index].insert(1);
if( column.type == var::column_type::constant ) result[ table_description.witness_columns + table_description.public_input_columns + column.index ].insert(1);
if( column.type == var::column_type::selector ) result[ table_description.witness_columns + table_description.public_input_columns + table_description.constant_columns + column.index].insert(1);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ namespace nil {

// 8. Run evaluation proofs
_proof.eval_proof.challenge = transcript.template challenge<FieldType>();

generate_evaluation_points();

{
Expand Down Expand Up @@ -283,7 +282,7 @@ namespace nil {
}

typename placeholder_lookup_argument_prover<FieldType, commitment_scheme_type, ParamsType>::prover_lookup_result
lookup_argument() {
lookup_argument() {
PROFILE_PLACEHOLDER_SCOPE("lookup_argument_time");

typename placeholder_lookup_argument_prover<
Expand Down

0 comments on commit c26270f

Please sign in to comment.