From 6056063411f09c2ba39ab46a30a7b78a48840c5d Mon Sep 17 00:00:00 2001 From: CblPOK-git Date: Thu, 5 Oct 2023 16:00:56 +0000 Subject: [PATCH] replace naive eq and ne handling with components --- .../nil/blueprint/comparison/comparison.hpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/include/nil/blueprint/comparison/comparison.hpp b/include/nil/blueprint/comparison/comparison.hpp index e67e5028..f9a4c822 100644 --- a/include/nil/blueprint/comparison/comparison.hpp +++ b/include/nil/blueprint/comparison/comparison.hpp @@ -31,7 +31,7 @@ #include -#include +#include #include #include @@ -52,20 +52,21 @@ namespace nil { std::uint32_t start_row, std::size_t &public_input_idx) { + using eq_component_type = components::equality_flag< + crypto3::zk::snark::plonk_constraint_system, BlueprintFieldType>; + // TODO(maksenov): replace naive handling with the component switch (p) { case llvm::CmpInst::ICMP_EQ: { - bool res = (var_value(assignment, x) == var_value(assignment, y)); - assignment.public_input(0, public_input_idx) = res; - using var = crypto3::zk::snark::plonk_variable; - return var(0, public_input_idx++, false, var::column_type::public_input); + eq_component_type component_instance = eq_component_type({0, 1, 2, 3, 4}, {0}, {0}, false); + components::generate_circuit(component_instance, bp, assignment, {x, y}, start_row); + return components::generate_assignments(component_instance, assignment, {x, y}, start_row).output; break; } case llvm::CmpInst::ICMP_NE:{ - bool res = (var_value(assignment, x) != var_value(assignment, y)); - assignment.public_input(0, public_input_idx) = res; - using var = crypto3::zk::snark::plonk_variable; - return var(0, public_input_idx++, false, var::column_type::public_input); + eq_component_type component_instance = eq_component_type({0, 1, 2, 3, 4}, {0}, {0}, true); + components::generate_circuit(component_instance, bp, assignment, {x, y}, start_row); + return components::generate_assignments(component_instance, assignment, {x, y}, start_row).output; break; } case llvm::CmpInst::ICMP_SGE: