Skip to content

Commit

Permalink
Disable default constructor of plonk variable
Browse files Browse the repository at this point in the history
  • Loading branch information
akokoshn committed May 2, 2024
1 parent a5e1759 commit 9172da9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,17 @@ namespace nil {

template<typename FieldType>
struct plonk_copy_constraint {
plonk_copy_constraint() = default;
plonk_copy_constraint(const plonk_copy_constraint<FieldType> &other){
initialize(other.first, other.second);
plonk_copy_constraint() = delete;
plonk_copy_constraint(const plonk_copy_constraint<FieldType> &other): first(other.first), second(other.second) {
initialize(first, second);
}
plonk_copy_constraint(
const plonk_variable<typename FieldType::value_type> &_first,
const plonk_variable<typename FieldType::value_type> &_second
){
): first(_first), second(_second) {
initialize(_first, _second);
}

plonk_variable<typename FieldType::value_type> first;
plonk_variable<typename FieldType::value_type> second;
bool operator==(const plonk_copy_constraint<FieldType> &other){
Expand All @@ -67,6 +68,12 @@ namespace nil {
std::swap(first, second);
}
}

void swap() {
const auto tmp = first;
first = second;
second = tmp;
}
};

template <typename FieldType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ namespace nil {
return witness_columns + public_input_columns + a.index;
case plonk_variable<typename FieldType::value_type>::column_type::selector:
return witness_columns + public_input_columns + constant_columns + a.index;
case plonk_variable<typename FieldType::value_type>::column_type::uninitialized:
std::cerr << "trying to access uninitialized var!";
std::abort();
break;
}
/* unreachable*/
return std::numeric_limits<size_t>::max();
Expand Down
11 changes: 7 additions & 4 deletions include/nil/crypto3/zk/snark/arithmetization/plonk/variable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace nil {
using assignment_type = AssignmentType;

enum column_type : std::uint8_t {
witness, public_input, constant, selector, uninitialized
witness, public_input, constant, selector
};

/**
Expand All @@ -80,7 +80,11 @@ namespace nil {
bool relative;
column_type type;

constexpr plonk_variable() : index(0), rotation(0), relative(false), type(column_type::uninitialized) {};
constexpr plonk_variable() = delete;

constexpr plonk_variable(const plonk_variable &other) :
index(other.index),
rotation(other.rotation), relative(other.relative), type(other.type) {};

constexpr plonk_variable(const std::size_t index,
std::int32_t rotation,
Expand Down Expand Up @@ -176,8 +180,7 @@ namespace nil {
{plonk_variable<AssignmentType>::column_type::witness, "w"},
{plonk_variable<AssignmentType>::column_type::public_input, "pub"},
{plonk_variable<AssignmentType>::column_type::constant, "c"},
{plonk_variable<AssignmentType>::column_type::selector, "sel"},
{plonk_variable<AssignmentType>::column_type::uninitialized,"NaN"}
{plonk_variable<AssignmentType>::column_type::selector, "sel"}
};
os << type_map[var.type] << "_" << var.index;
if (!var.relative) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,6 @@ namespace nil {
case polynomial_dfs_variable_type::column_type::selector:
assignment = assignments.selector(var.index);
break;
case polynomial_dfs_variable_type::column_type::uninitialized:
std::cerr << "trying to access uninitialized var!";
std::abort();
break;
}

if (var.rotation != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,10 +462,6 @@ namespace nil {
case DfsVariableType::column_type::selector:
assignment = assignments.selector(var.index);
break;
case DfsVariableType::column_type::uninitialized:
std::cerr << "trying to access uninitialized var!";
std::abort();
break;
}

if (var.rotation != 0) {
Expand Down

0 comments on commit 9172da9

Please sign in to comment.