Skip to content

Commit

Permalink
slight mockups modification
Browse files Browse the repository at this point in the history
  • Loading branch information
CblPOK-git committed Jan 31, 2024
1 parent 51fd5f8 commit 0afc570
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
40 changes: 31 additions & 9 deletions include/nil/blueprint/component_mockups/comparison.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,8 @@ namespace nil {

struct result_type {
var flag;

result_type(const comparison &component, std::size_t start_row_index) {
std::size_t outuput_w = component.needs_bonus_row ? 0 : 3;
flag = var(component.W(outuput_w), start_row_index + component.rows_amount - 1, false);
}
result_type(const comparison &component, std::size_t start_row_index, bool skip) {
flag = var(component.W(0), start_row_index, false);
}

Expand Down Expand Up @@ -311,9 +308,8 @@ namespace nil {
integral_type x = integral_type(var_value(assignment, instance_input.x).data);
integral_type y = integral_type(var_value(assignment, instance_input.y).data);


assignment.witness(component.W(0), row) = assignment.witness(component.W(1), row)
= assignment.witness(component.W(2), row) = 0;
assignment.witness(component.W(1), row) = x;
assignment.witness(component.W(2), row) = y;

bool output;
switch (component.mode) {
Expand Down Expand Up @@ -347,12 +343,38 @@ namespace nil {
const typename plonk_comparison<BlueprintFieldType, ArithmetizationParams>::input_type
&instance_input,
const std::uint32_t start_row_index) {
std::size_t row = start_row_index;

using component_type = plonk_comparison<BlueprintFieldType, ArithmetizationParams>;
return typename component_type::result_type(component, start_row_index);
}
using value_type = typename BlueprintFieldType::value_type;
using integral_type = typename BlueprintFieldType::integral_type;

integral_type x = integral_type(var_value(assignment, instance_input.x).data);
integral_type y = integral_type(var_value(assignment, instance_input.y).data);

assignment.witness(component.W(1), row) = x;
assignment.witness(component.W(2), row) = y;

bool output;
switch (component.mode) {
case comparison_mode::LESS_THAN:
output = (x < y);
break;
case comparison_mode::LESS_EQUAL:
output = (x <= y);
break;
case comparison_mode::GREATER_THAN:
output = (x > y);
break;
case comparison_mode::GREATER_EQUAL:
output = (x >= y);
break;
}

assignment.witness(component.W(0), row) = output;

return typename component_type::result_type(component, start_row_index);
}

} // namespace components
} // namespace blueprint
Expand Down
2 changes: 2 additions & 0 deletions include/nil/blueprint/component_mockups/h2c.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ namespace nil {
using component_type = plonk_h2c<BlueprintFieldType, ArithmetizationParams, FieldType>;

assignment.witness(component.W(0), start_row_index) = 1;
assignment.witness(component.W(1), start_row_index) = 1;
assignment.witness(component.W(2), start_row_index) = var_value(assignment, instance_input.input);

return typename plonk_h2c<BlueprintFieldType, ArithmetizationParams, FieldType>::result_type(
component, start_row_index);
Expand Down
1 change: 1 addition & 0 deletions include/nil/blueprint/handle_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ namespace nil {
"is_in_g2",
"native_bls12_381_pairing",
"hash to curve",
"comparison",
};


Expand Down

0 comments on commit 0afc570

Please sign in to comment.