Skip to content

Commit

Permalink
Assignment table deserialization algorithm temporary added to transpi…
Browse files Browse the repository at this point in the history
…ler.
  • Loading branch information
nkaskov committed Jul 26, 2023
1 parent 2403aef commit 72247a7
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions include/nil/blueprint/transpiler/table_profiling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,71 @@ namespace nil {
out << std::endl;
}
}

template<typename BlueprintFieldType, typename ArithmetizationParams, typename ColumnType>
std::tuple<std::size_t, std::size_t,
nil::crypto3::zk::snark::plonk_table<BlueprintFieldType, ArithmetizationParams, ColumnType>>
load_assignment_table(std::istream &istr) {
using PrivateTableType =
nil::crypto3::zk::snark::plonk_private_table<BlueprintFieldType, ArithmetizationParams, ColumnType>;
using PublicTableType =
nil::crypto3::zk::snark::plonk_public_table<BlueprintFieldType, ArithmetizationParams, ColumnType>;
using AssignmentTableType =
nil::crypto3::zk::snark::plonk_table<BlueprintFieldType, ArithmetizationParams, ColumnType>;
std::size_t usable_rows;
std::size_t rows_amount;

typename PrivateTableType::witnesses_container_type witness;
typename PublicTableType::public_input_container_type public_input;
typename PublicTableType::constant_container_type constant;
typename PublicTableType::selector_container_type selector;

istr >> usable_rows;
istr >> rows_amount;

for (size_t i = 0; i < witness.size(); i++) { // witnesses.size() == ArithmetizationParams.WitnessColumns
ColumnType column;
typename BlueprintFieldType::integral_type num;
for (size_t j = 0; j < rows_amount; j++) {
istr >> num;
column.push_back(typename BlueprintFieldType::value_type(num));
}
witness[i] = column;
}

for (size_t i = 0; i < public_input.size(); i++) { // witnesses.size() == ArithmetizationParams.WitnessColumns
ColumnType column;
typename BlueprintFieldType::integral_type num;
for (size_t j = 0; j < rows_amount; j++) {
istr >> num;
column.push_back(typename BlueprintFieldType::value_type(num));
}
public_input[i] = column;
}

for (size_t i = 0; i < constant.size(); i++) { // witnesses.size() == ArithmetizationParams.WitnessColumns
ColumnType column;
typename BlueprintFieldType::integral_type num;
for (size_t j = 0; j < rows_amount; j++) {
istr >> num;
column.push_back(typename BlueprintFieldType::value_type(num));
}
constant[i] = column;
}
for (size_t i = 0; i < selector.size(); i++) { // witnesses.size() == ArithmetizationParams.WitnessColumns
ColumnType column;
typename BlueprintFieldType::integral_type num;
for (size_t j = 0; j < rows_amount; j++) {
istr >> num;
column.push_back(typename BlueprintFieldType::value_type(num));
}
selector[i] = column;
}
return std::make_tuple(
usable_rows, rows_amount,
AssignmentTableType(PrivateTableType(witness), PublicTableType(public_input, constant, selector)));
}

} // namespace blueprint
} // namespace nil

Expand Down

0 comments on commit 72247a7

Please sign in to comment.