Skip to content

Commit

Permalink
Tests fixed #335
Browse files Browse the repository at this point in the history
  • Loading branch information
ETatuzova committed Apr 10, 2024
1 parent 573fb8c commit a1d7370
Show file tree
Hide file tree
Showing 14 changed files with 222 additions and 334 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@ namespace nil {
using var = typename plonk_ed25519_range<BlueprintFieldType>::var;

std::size_t row = start_row_index;
bp.add_copy_constraint({var(component.W(0), static_cast<int>(row), false), instance_input.input[0]});
bp.add_copy_constraint({var(component.W(1), static_cast<int>(row), false), instance_input.input[1]});
bp.add_copy_constraint({var(component.W(2), static_cast<int>(row), false), instance_input.input[2]});
bp.add_copy_constraint({var(component.W(3), static_cast<int>(row), false), instance_input.input[3]});
if(var(component.W(0), static_cast<int>(row), false) != instance_input.input[0]) bp.add_copy_constraint({var(component.W(0), static_cast<int>(row), false), instance_input.input[0]});
if(var(component.W(1), static_cast<int>(row), false) != instance_input.input[1]) bp.add_copy_constraint({var(component.W(1), static_cast<int>(row), false), instance_input.input[1]});
if(var(component.W(2), static_cast<int>(row), false) != instance_input.input[2]) bp.add_copy_constraint({var(component.W(2), static_cast<int>(row), false), instance_input.input[2]});
if(var(component.W(3), static_cast<int>(row), false) != instance_input.input[3]) bp.add_copy_constraint({var(component.W(3), static_cast<int>(row), false), instance_input.input[3]});
}

template<typename BlueprintFieldType>
Expand Down
21 changes: 13 additions & 8 deletions include/nil/blueprint/components/algebra/fields/plonk/sqrt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,11 @@ namespace nil {
var output;

result_type(const sqrt &component, std::size_t component_start_row) {
output = var(component.W(0), component_start_row + 3 +
exp_component::get_rows_amount(15));
output = var(
component.W(0),
component_start_row + 3 + exp_component::get_rows_amount(15),
false
);
}

std::vector<std::reference_wrapper<var>> all_vars() {
Expand Down Expand Up @@ -205,11 +208,13 @@ namespace nil {
// check if y \in QR(q)
auto exp_instance =
// qr_check = 1 if y \in QR(q), -1 if y \in QNR(q), 0 if y = 0
exp_component({component.W(0), component.W(1), component.W(2), component.W(3),
component.W(4), component.W(5), component.W(6), component.W(7),
component.W(8), component.W(9), component.W(10), component.W(11),
component.W(12), component.W(13), component.W(14)}, {component.C(0)},
{});
exp_component({
component.W(0), component.W(1), component.W(2), component.W(3),
component.W(4), component.W(5), component.W(6), component.W(7),
component.W(8), component.W(9), component.W(10), component.W(11),
component.W(12), component.W(13), component.W(14)}, {component.C(0)},
{}
);
var qr_check = generate_circuit(exp_instance, bp, assignment, {instance_input.y, exp}, row).output;
row += exp_instance.rows_amount;

Expand Down Expand Up @@ -270,7 +275,7 @@ namespace nil {
template<typename BlueprintFieldType>
typename plonk_sqrt<BlueprintFieldType>::result_type
generate_assignments(
const plonk_sqrt<BlueprintFieldType> &component,\
const plonk_sqrt<BlueprintFieldType> &component,
assignment<crypto3::zk::snark::plonk_constraint_system<BlueprintFieldType>>
&assignment,
const typename plonk_sqrt<BlueprintFieldType>::input_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ namespace nil {
// Proceed with care
using var = typename plonk_poseidon<BlueprintFieldType, FieldType>::var;
for (std::size_t i = 0; i < 3; i++) {
bp.add_copy_constraint({var(component.W(i), start_row_index), instance_input.input_state[i]});
bp.add_copy_constraint({var(component.W(i), start_row_index, false), instance_input.input_state[i]});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ namespace nil {
// Proceed with care
using var = typename plonk_flexible_poseidon<BlueprintFieldType>::var;
for (std::size_t i = 0; i < 3; i++) {
bp.add_copy_constraint({var(component.W(i), start_row_index), instance_input.input_state[i]});
bp.add_copy_constraint({var(component.W(i), start_row_index, false), instance_input.input_state[i]});
}
}

Expand Down
Loading

0 comments on commit a1d7370

Please sign in to comment.