diff --git a/bin/assigner/src/main.cpp b/bin/assigner/src/main.cpp index 39f30de1..79ebafd3 100644 --- a/bin/assigner/src/main.cpp +++ b/bin/assigner/src/main.cpp @@ -72,7 +72,9 @@ void print_hex_byteblob(std::ostream &os, TIter iter_begin, TIter iter_end, bool } template -void print_circuit(const circuit_proxy &circuit_proxy, std::ostream &out = std::cout) { +void print_circuit(const circuit_proxy &circuit_proxy, + const assignment_proxy &table_proxy, + bool rename_required, std::ostream &out = std::cout) { using TTypeBase = nil::marshalling::field_type; using plonk_constraint_system = nil::marshalling::types::bundle< TTypeBase, std::tuple< @@ -83,6 +85,8 @@ void print_circuit(const circuit_proxy &circuit_proxy, std: nil::crypto3::marshalling::types::plonk_lookup_tables< TTypeBase, typename ConstraintSystemType::lookup_tables_type::value_type > // lookup tables > >; + using AssignmentTableType = assignment_proxy; + using variable_type = crypto3::zk::snark::plonk_variable; const auto gates = circuit_proxy.gates(); const std::set& used_gates_idx = circuit_proxy.get_used_gates(); @@ -97,6 +101,29 @@ void print_circuit(const circuit_proxy &circuit_proxy, std: for (const auto &it : used_copy_constraints_idx) { used_copy_constraints.push_back(copy_constraints[it]); } + if (rename_required) { + const auto used_rows = table_proxy.get_used_rows(); + std::uint32_t local_row = 0; + for (const auto &row : used_rows) { + for (auto &constraint : used_copy_constraints) { + const auto first_var = constraint.first; + const auto second_var = constraint.second; + if ((first_var.type == variable_type::column_type::witness || + first_var.type == variable_type::column_type::constant) && + first_var.rotation == row) { + constraint.first = variable_type(first_var.index, local_row, first_var.relative, + first_var.type); + } + if ((second_var.type == variable_type::column_type::witness || + second_var.type == variable_type::column_type::constant) && + second_var.rotation == row) { + constraint.second = variable_type(second_var.index, local_row, + second_var.relative, second_var.type); + } + } + local_row++; + } + } const auto lookup_gates = circuit_proxy.lookup_gates(); typename ConstraintSystemType::lookup_gates_container_type used_lookup_gates; @@ -279,10 +306,10 @@ void print_assignment_table(const assignment_proxy &table_p fill_vector_value (table_values, table_proxy, print_column_kind::SELECTOR, selector_size, usable_rows_amount, padding); } else if (print_kind == print_table_kind::SHARED) { - fill_vector_value - (table_values, table_proxy, print_column_kind::SHARED, shared_size, usable_rows_amount, padding); fill_vector_value (table_values, table_proxy, print_column_kind::PUBLIC_INPUT, public_input_size, usable_rows_amount, padding); + fill_vector_value + (table_values, table_proxy, print_column_kind::SHARED, shared_size, usable_rows_amount, padding); } else { const auto rows = table_proxy.get_used_rows(); for( std::size_t i = 0; i < AssignmentTableType::arithmetization_params::witness_columns; i++ ){ @@ -442,7 +469,8 @@ int curve_dependent_main(std::string bytecode_file_name, } } - for (const auto& it : parser_instance.circuits) { + auto assignment_it = parser_instance.assignments.begin(); + for (auto& it : parser_instance.circuits) { std::ofstream ocircuit; std::string file_name = parser_instance.circuits.size() > 1 ? circuit_file_name + std::to_string(it.get_id()) : circuit_file_name; @@ -451,8 +479,11 @@ int curve_dependent_main(std::string bytecode_file_name, std::cout << "Something wrong with output " << file_name << std::endl; return 1; } - print_circuit(it, ocircuit); + ASSERT_MSG(assignment_it != parser_instance.assignments.end(), "Not found assignment for circuit"); + print_circuit + (it, *assignment_it, (parser_instance.assignments.size() > 1), ocircuit); ocircuit.close(); + assignment_it++; } if (check_validity){