From cca8c1827e38cd43f55a619030e7edbd11219f00 Mon Sep 17 00:00:00 2001 From: Aleksandr Cherenkov Date: Thu, 28 Mar 2024 20:06:46 +0000 Subject: [PATCH 1/2] add uninitialized plonk variable type --- .../crypto3/zk/snark/arithmetization/plonk/variable.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/nil/crypto3/zk/snark/arithmetization/plonk/variable.hpp b/include/nil/crypto3/zk/snark/arithmetization/plonk/variable.hpp index db1bb9d7..e8b0f469 100644 --- a/include/nil/crypto3/zk/snark/arithmetization/plonk/variable.hpp +++ b/include/nil/crypto3/zk/snark/arithmetization/plonk/variable.hpp @@ -69,7 +69,7 @@ namespace nil { using assignment_type = AssignmentType; enum column_type : std::uint8_t { - witness, public_input, constant, selector + witness, public_input, constant, selector, uninitialized }; /** @@ -80,7 +80,7 @@ namespace nil { bool relative; column_type type; - constexpr plonk_variable() : index(0), rotation(0), relative(false), type(column_type::witness) {}; + constexpr plonk_variable() : index(0), rotation(0), relative(false), type(column_type::uninitialized) {}; constexpr plonk_variable(const std::size_t index, std::int32_t rotation, @@ -176,7 +176,8 @@ namespace nil { {plonk_variable::column_type::witness, "w"}, {plonk_variable::column_type::public_input, "pub"}, {plonk_variable::column_type::constant, "c"}, - {plonk_variable::column_type::selector, "sel"} + {plonk_variable::column_type::selector, "sel"}, + {plonk_variable::column_type::uninitialized,"NaN"} }; os << type_map[var.type] << "_" << var.index; if (!var.relative) { From 603bd435d7e17300f4ce6e3cf559fe05bea555dc Mon Sep 17 00:00:00 2001 From: Aleksandr Cherenkov Date: Tue, 2 Apr 2024 12:23:02 +0000 Subject: [PATCH 2/2] add check for ivalid var type --- .../nil/crypto3/zk/snark/arithmetization/plonk/constraint.hpp | 4 ++++ .../zk/snark/arithmetization/plonk/table_description.hpp | 4 ++++ .../zk/snark/systems/plonk/placeholder/gates_argument.hpp | 4 ++++ .../zk/snark/systems/plonk/placeholder/lookup_argument.hpp | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/include/nil/crypto3/zk/snark/arithmetization/plonk/constraint.hpp b/include/nil/crypto3/zk/snark/arithmetization/plonk/constraint.hpp index 5fba556e..2fab964d 100644 --- a/include/nil/crypto3/zk/snark/arithmetization/plonk/constraint.hpp +++ b/include/nil/crypto3/zk/snark/arithmetization/plonk/constraint.hpp @@ -131,6 +131,8 @@ namespace nil { case VariableType::column_type::selector: assignment = assignments.selector(var.index); break; + default: + BOOST_ASSERT_MSG(false, "Invalid column type"); } if (var.rotation != 0) { @@ -169,6 +171,8 @@ namespace nil { case VariableType::column_type::selector: assignment = assignments.selector(var.index); break; + default: + BOOST_ASSERT_MSG(false, "Invalid column type"); } if (var.rotation != 0) { diff --git a/include/nil/crypto3/zk/snark/arithmetization/plonk/table_description.hpp b/include/nil/crypto3/zk/snark/arithmetization/plonk/table_description.hpp index fa4ea3e1..03be3bee 100644 --- a/include/nil/crypto3/zk/snark/arithmetization/plonk/table_description.hpp +++ b/include/nil/crypto3/zk/snark/arithmetization/plonk/table_description.hpp @@ -74,6 +74,10 @@ namespace nil { return witness_columns + public_input_columns + a.index; case plonk_variable::column_type::selector: return witness_columns + public_input_columns + constant_columns + a.index; + default: + std::cerr << "Invalid column type"; + std::abort(); + break; } /* unreachable*/ return std::numeric_limits::max(); diff --git a/include/nil/crypto3/zk/snark/systems/plonk/placeholder/gates_argument.hpp b/include/nil/crypto3/zk/snark/systems/plonk/placeholder/gates_argument.hpp index cb46911d..61721917 100644 --- a/include/nil/crypto3/zk/snark/systems/plonk/placeholder/gates_argument.hpp +++ b/include/nil/crypto3/zk/snark/systems/plonk/placeholder/gates_argument.hpp @@ -107,6 +107,10 @@ namespace nil { case polynomial_dfs_variable_type::column_type::selector: assignment = assignments.selector(var.index); break; + default: + std::cerr << "Invalid column type"; + std::abort(); + break; } if (var.rotation != 0) { diff --git a/include/nil/crypto3/zk/snark/systems/plonk/placeholder/lookup_argument.hpp b/include/nil/crypto3/zk/snark/systems/plonk/placeholder/lookup_argument.hpp index dc1acca6..da28dfed 100644 --- a/include/nil/crypto3/zk/snark/systems/plonk/placeholder/lookup_argument.hpp +++ b/include/nil/crypto3/zk/snark/systems/plonk/placeholder/lookup_argument.hpp @@ -462,6 +462,10 @@ namespace nil { case DfsVariableType::column_type::selector: assignment = assignments.selector(var.index); break; + default: + std::cerr << "Invalid column type"; + std::abort(); + break; } if (var.rotation != 0) {