Skip to content

Commit

Permalink
Use variable comparison operator in plonk copy constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
x-mass committed Apr 29, 2024
1 parent b3ee42c commit 292b70f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,44 +60,12 @@ namespace nil {
){
BOOST_ASSERT(_first.relative == false);
BOOST_ASSERT(_second.relative == false);
if(_first.type == _second.type){
if(_first.index < _second.index){
first = plonk_variable<typename FieldType::value_type>(_first);
second = plonk_variable<typename FieldType::value_type>(_second);
} else if (_first.index > _second.index){
first = plonk_variable<typename FieldType::value_type>(_second);
second = plonk_variable<typename FieldType::value_type>(_first);
} else if (_first.rotation < _second.rotation){
first = plonk_variable<typename FieldType::value_type>(_first);
second = plonk_variable<typename FieldType::value_type>(_second);
} else if (_first.rotation > _second.rotation){
first = plonk_variable<typename FieldType::value_type>(_second);
second = plonk_variable<typename FieldType::value_type>(_first);
} else {
BOOST_ASSERT_MSG(false, "Copy constraint with equal variables");
}
return;
}
if( _first.type == plonk_variable<typename FieldType::value_type>::column_type::witness){
first = plonk_variable<typename FieldType::value_type>(_first);
second = plonk_variable<typename FieldType::value_type>(_second);
} else if (
_first.type == plonk_variable<typename FieldType::value_type>::column_type::public_input &&
_second.type != plonk_variable<typename FieldType::value_type>::column_type::witness
){
first = plonk_variable<typename FieldType::value_type>(_first);
second = plonk_variable<typename FieldType::value_type>(_second);
} else if(
_first.type == plonk_variable<typename FieldType::value_type>::column_type::constant &&
_second.type == plonk_variable<typename FieldType::value_type>::column_type::selector
){
first = plonk_variable<typename FieldType::value_type>(_first);
second = plonk_variable<typename FieldType::value_type>(_second);
} else {
first = plonk_variable<typename FieldType::value_type>(_second);
second = plonk_variable<typename FieldType::value_type>(_first);
first = _first;
second = _second;

if (_first > _second) {
std::swap(first, second);
}
return;
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ namespace nil {
return this->type < other.type;
return this->relative < other.relative;
}

bool operator>(const plonk_variable &other) const {
return *this != other && !(*this < other);
}
};

template<typename AssignmentType, typename LeftType,
Expand Down

0 comments on commit 292b70f

Please sign in to comment.