From 4031373861cd297394d7b196914b401fe7328a49 Mon Sep 17 00:00:00 2001 From: Aleksandr Cherenkov Date: Thu, 1 Feb 2024 18:11:51 +0000 Subject: [PATCH 1/2] fold genFlag into component_creation_parameters_struct --- include/nil/blueprint/boolean/logic_ops.hpp | 4 +- .../nil/blueprint/comparison/comparison.hpp | 6 +- .../component_creation_parameters.hpp | 62 ++++++ include/nil/blueprint/curves/addition.hpp | 18 +- .../nil/blueprint/curves/multiplication.hpp | 18 +- include/nil/blueprint/curves/subtraction.hpp | 2 +- .../extract_constructor_parameters.hpp | 4 +- include/nil/blueprint/fields/addition.hpp | 26 +-- include/nil/blueprint/fields/division.hpp | 18 +- .../nil/blueprint/fields/multiplication.hpp | 26 +-- include/nil/blueprint/fields/subtraction.hpp | 26 +-- include/nil/blueprint/handle_component.hpp | 51 ++--- include/nil/blueprint/hashes/sha2_256.hpp | 4 +- include/nil/blueprint/hashes/sha2_512.hpp | 10 +- include/nil/blueprint/integers/addition.hpp | 6 +- .../blueprint/integers/bit_de_composition.hpp | 22 +-- include/nil/blueprint/integers/bit_shift.hpp | 10 +- include/nil/blueprint/integers/division.hpp | 2 +- .../blueprint/integers/division_remainder.hpp | 12 +- .../nil/blueprint/integers/multiplication.hpp | 6 +- .../nil/blueprint/integers/subtraction.hpp | 6 +- include/nil/blueprint/parser.hpp | 183 +++++++++--------- .../recursive_prover/fri_array_swap.hpp | 8 +- .../blueprint/recursive_prover/fri_cosets.hpp | 10 +- .../recursive_prover/fri_lin_inter.hpp | 4 +- .../recursive_prover/gate_arg_verifier.hpp | 14 +- .../recursive_prover/lookup_arg_verifier.hpp | 6 +- .../permutation_arg_verifier.hpp | 16 +- 28 files changed, 314 insertions(+), 266 deletions(-) create mode 100644 include/nil/blueprint/component_creation_parameters.hpp diff --git a/include/nil/blueprint/boolean/logic_ops.hpp b/include/nil/blueprint/boolean/logic_ops.hpp index d7a3300e..7b607c7f 100644 --- a/include/nil/blueprint/boolean/logic_ops.hpp +++ b/include/nil/blueprint/boolean/logic_ops.hpp @@ -42,7 +42,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using arithmetization_type = crypto3::zk::snark::plonk_constraint_system; using component_type = components::logic_and; @@ -52,7 +52,7 @@ namespace nil { instance_input.input[1] = y; return get_component_result - (bp, assignment, start_row, target_prover_idx, gen_flag, instance_input).output; + (bp, assignment, start_row, target_prover_idx, comp_gen_params, instance_input).output; } } // namespace blueprint diff --git a/include/nil/blueprint/comparison/comparison.hpp b/include/nil/blueprint/comparison/comparison.hpp index 4dfb166f..d702bb8d 100644 --- a/include/nil/blueprint/comparison/comparison.hpp +++ b/include/nil/blueprint/comparison/comparison.hpp @@ -44,7 +44,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using eq_component_type = components::equality_flag< crypto3::zk::snark::plonk_constraint_system, BlueprintFieldType>; @@ -54,12 +54,12 @@ namespace nil { switch (p) { case llvm::CmpInst::ICMP_EQ: { return get_component_result - (bp, assignment, start_row, target_prover_idx, instance_input, gen_flag, false); + (bp, assignment, start_row, target_prover_idx, instance_input, comp_gen_params, false); break; } case llvm::CmpInst::ICMP_NE:{ return get_component_result - (bp, assignment, start_row, target_prover_idx, instance_input, gen_flag, true); + (bp, assignment, start_row, target_prover_idx, instance_input, comp_gen_params, true); break; } default: diff --git a/include/nil/blueprint/component_creation_parameters.hpp b/include/nil/blueprint/component_creation_parameters.hpp new file mode 100644 index 00000000..6299a43a --- /dev/null +++ b/include/nil/blueprint/component_creation_parameters.hpp @@ -0,0 +1,62 @@ +//---------------------------------------------------------------------------// +// Copyright (c) 2022 Mikhail Komarov +// Copyright (c) 2022 Nikita Kaskov +// +// MIT License +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +//---------------------------------------------------------------------------// + +#ifndef CRYPTO3_BLUEPRINT_COMPONENT_CREATION_PARAMETERS_HPP +#define CRYPTO3_BLUEPRINT_COMPONENT_CREATION_PARAMETERS_HPP + +namespace nil { + namespace blueprint { + + enum class generate_flag : uint8_t { + NONE = 0, + CIRCUIT = 1 << 0, + ASSIGNMENTS = 1 << 1, + FALSE_ASSIGNMENTS = 1 << 2 + }; + + constexpr enum generate_flag operator |( const enum generate_flag self, const enum generate_flag val ) + { + return (enum generate_flag)(uint8_t(self) | uint8_t(val)); + } + constexpr enum generate_flag operator &( const enum generate_flag self, const enum generate_flag val ) + { + return (enum generate_flag)(uint8_t(self) & uint8_t(val)); + } + + + struct component_creation_parameters_struct { + generate_flag genFlag; + component_creation_parameters_struct(generate_flag input) { + genFlag = input; + } + component_creation_parameters_struct() { + genFlag = ((generate_flag)((uint8_t)generate_flag::ASSIGNMENTS | (uint8_t)generate_flag::CIRCUIT)); + } + }; + + } // namespace blueprint +} // namespace nil + +#endif // CRYPTO3_BLUEPRINT_COMPONENT_CREATION_PARAMETERS_HPP diff --git a/include/nil/blueprint/curves/addition.hpp b/include/nil/blueprint/curves/addition.hpp index 3a9e475f..68a7f094 100644 --- a/include/nil/blueprint/curves/addition.hpp +++ b/include/nil/blueprint/curves/addition.hpp @@ -52,7 +52,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; @@ -70,7 +70,7 @@ namespace nil { typename component_type::input_type addition_input = {{P.X, P.Y}, {Q.X, Q.Y}}; return get_component_result - (bp, assignment, start_row, target_prover_idx, addition_input, gen_flag); + (bp, assignment, start_row, target_prover_idx, addition_input, comp_gen_params); } template @@ -85,7 +85,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; @@ -127,7 +127,7 @@ namespace nil { typename component_type::input_type addition_input = {{P.X, P.Y}, {Q.X, Q.Y}}; return get_component_result - (bp, assignment, start_row, target_prover_idx, addition_input, gen_flag); + (bp, assignment, start_row, target_prover_idx, addition_input, comp_gen_params); } } // namespace detail @@ -138,7 +138,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using non_native_policy_type = basic_non_native_policy; @@ -168,9 +168,9 @@ namespace nil { using component_type = components::unified_addition; typename component_type::result_type res = detail::handle_native_curve_unified_addition_component( - operand0, operand1, frame.vectors, bp, assignment, start_row, target_prover_idx, gen_flag); + operand0, operand1, frame.vectors, bp, assignment, start_row, target_prover_idx, comp_gen_params); std::vector> res_vector = {res.X, res.Y}; - handle_component_result(assignment, inst, frame, res, gen_flag); + handle_component_result(assignment, inst, frame, res, comp_gen_params); } else { UNREACHABLE("non-native pallas is undefined"); } @@ -209,8 +209,8 @@ namespace nil { operating_curve_type, basic_non_native_policy>; typename component_type::result_type res = detail::handle_non_native_curve_addition_component( - operand0, operand1, frame.vectors, bp, assignment, start_row, target_prover_idx, gen_flag); - handle_component_result(assignment, inst, frame, res, gen_flag); + operand0, operand1, frame.vectors, bp, assignment, start_row, target_prover_idx, comp_gen_params); + handle_component_result(assignment, inst, frame, res, comp_gen_params); } } diff --git a/include/nil/blueprint/curves/multiplication.hpp b/include/nil/blueprint/curves/multiplication.hpp index a033e487..4fde213e 100644 --- a/include/nil/blueprint/curves/multiplication.hpp +++ b/include/nil/blueprint/curves/multiplication.hpp @@ -52,7 +52,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; @@ -71,7 +71,7 @@ namespace nil { typename component_type::input_type addition_input = {{T.X, T.Y}, b[0], b[1]}; return get_component_result - (bp, assignment, start_row, target_prover_idx, addition_input, gen_flag); + (bp, assignment, start_row, target_prover_idx, addition_input, comp_gen_params); } template @@ -88,7 +88,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; @@ -119,7 +119,7 @@ namespace nil { typename component_type::input_type addition_input = {{T.X, T.Y}, b}; return get_component_result - (bp, assignment, start_row, target_prover_idx, addition_input, gen_flag, + (bp, assignment, start_row, target_prover_idx, addition_input, comp_gen_params, 253, nil::blueprint::components::bit_shift_mode::RIGHT); } @@ -132,7 +132,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using non_native_policy_type = basic_non_native_policy; @@ -185,9 +185,9 @@ namespace nil { ArithmetizationType, operating_curve_type>; typename component_type::result_type res = detail::handle_native_curve_non_native_scalar_multiplication_component( - operand_curve, operand_field, frame.vectors, bp, assignment, start_row, target_prover_idx, gen_flag); + operand_curve, operand_field, frame.vectors, bp, assignment, start_row, target_prover_idx, comp_gen_params); std::vector> res_vector = {res.X, res.Y}; - handle_component_result(assignment, inst, frame, res, gen_flag); + handle_component_result(assignment, inst, frame, res, comp_gen_params); } else { UNREACHABLE("non-native pallas multiplication is not implemented"); } @@ -227,9 +227,9 @@ namespace nil { assignment, start_row, target_prover_idx, - gen_flag); + comp_gen_params); - handle_component_result(assignment, inst, frame, res, gen_flag); + handle_component_result(assignment, inst, frame, res, comp_gen_params); } } diff --git a/include/nil/blueprint/curves/subtraction.hpp b/include/nil/blueprint/curves/subtraction.hpp index be1116a6..4f576415 100644 --- a/include/nil/blueprint/curves/subtraction.hpp +++ b/include/nil/blueprint/curves/subtraction.hpp @@ -56,7 +56,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using non_native_policy_type = basic_non_native_policy; diff --git a/include/nil/blueprint/extract_constructor_parameters.hpp b/include/nil/blueprint/extract_constructor_parameters.hpp index 453cfb2e..6f871d22 100644 --- a/include/nil/blueprint/extract_constructor_parameters.hpp +++ b/include/nil/blueprint/extract_constructor_parameters.hpp @@ -77,10 +77,10 @@ namespace nil { typename std::map> &variables, program_memory> &memory, assignment_proxy> - &assignment, generate_flag gen_flag + &assignment, component_creation_parameters_struct comp_gen_params ) { std::vector res = {}; - if (std::uint8_t(gen_flag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(comp_gen_params.genFlag & generate_flag::ASSIGNMENTS)) { ptr_type input_ptr = static_cast( typename BlueprintFieldType::integral_type(var_value(assignment, variables[input_value]).data)); for (std::size_t i = 0; i < input_length; i++) { diff --git a/include/nil/blueprint/fields/addition.hpp b/include/nil/blueprint/fields/addition.hpp index 49141bef..e9f9d6a1 100644 --- a/include/nil/blueprint/fields/addition.hpp +++ b/include/nil/blueprint/fields/addition.hpp @@ -52,7 +52,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; @@ -65,7 +65,7 @@ namespace nil { typename component_type::input_type instance_input({x, y}); return get_component_result - (bp, assignment, start_row, target_prover_idx, instance_input, gen_flag); + (bp, assignment, start_row, target_prover_idx, instance_input, comp_gen_params); } template @@ -78,7 +78,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; using non_native_policy_type = basic_non_native_policy; @@ -102,7 +102,7 @@ namespace nil { typename component_type::input_type instance_input({x, y}); return get_component_result - (bp, assignment, start_row, target_prover_idx, instance_input, gen_flag); + (bp, assignment, start_row, target_prover_idx, instance_input, comp_gen_params); } } // namespace detail @@ -114,7 +114,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using non_native_policy_type = basic_non_native_policy; using native_component_type = components::addition< @@ -138,9 +138,9 @@ namespace nil { if (std::is_same::value) { const auto res = detail::handle_native_field_addition_component( - operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, gen_flag); + operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, comp_gen_params); handle_component_result - (assignment, inst, frame, res, gen_flag); + (assignment, inst, frame, res, comp_gen_params); } else { UNREACHABLE("bls12-381 non-native field addition is not implemented yet"); } @@ -158,9 +158,9 @@ namespace nil { if (std::is_same::value) { const auto res = detail::handle_native_field_addition_component( - operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, gen_flag); + operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, comp_gen_params); handle_component_result - (assignment, inst, frame, res, gen_flag); + (assignment, inst, frame, res, comp_gen_params); } else { UNREACHABLE("non-native pallas field addition is implemented yet"); } @@ -181,16 +181,16 @@ namespace nil { if (std::is_same::value) { const auto res = detail::handle_native_field_addition_component( - operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, gen_flag); + operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, comp_gen_params); handle_component_result - (assignment, inst, frame, res, gen_flag); + (assignment, inst, frame, res, comp_gen_params); } else { const auto& component_result = detail::handle_non_native_field_addition_component< BlueprintFieldType, ArithmetizationParams, operating_field_type>( - operand0, operand1, frame.vectors, bp, assignment, start_row, target_prover_idx, gen_flag); + operand0, operand1, frame.vectors, bp, assignment, start_row, target_prover_idx, comp_gen_params); handle_component_result - (assignment, inst, frame, component_result, gen_flag); + (assignment, inst, frame, component_result, comp_gen_params); } } else { diff --git a/include/nil/blueprint/fields/division.hpp b/include/nil/blueprint/fields/division.hpp index d2ed8473..3b7d2da5 100644 --- a/include/nil/blueprint/fields/division.hpp +++ b/include/nil/blueprint/fields/division.hpp @@ -52,7 +52,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; @@ -65,7 +65,7 @@ namespace nil { typename component_type::input_type instance_input({x, y}); return get_component_result - (bp, assignment, start_row, target_prover_idx, instance_input, gen_flag); + (bp, assignment, start_row, target_prover_idx, instance_input, comp_gen_params); } } // namespace detail @@ -77,7 +77,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using non_native_policy_type = basic_non_native_policy; using component_type = components::division< @@ -100,8 +100,8 @@ namespace nil { if (std::is_same::value) { const auto res = detail::handle_native_field_division_component( - operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, gen_flag); - handle_component_result(assignment, inst, frame, res, gen_flag); + operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, comp_gen_params); + handle_component_result(assignment, inst, frame, res, comp_gen_params); } else { UNREACHABLE("Non-native bls12-381 is undefined yet"); } @@ -114,8 +114,8 @@ namespace nil { if (std::is_same::value) { const auto res = detail::handle_native_field_division_component( - operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, gen_flag); - handle_component_result(assignment, inst, frame, res, gen_flag); + operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, comp_gen_params); + handle_component_result(assignment, inst, frame, res, comp_gen_params); } else { UNREACHABLE("Non-native pallas is undefined yet"); } @@ -128,8 +128,8 @@ namespace nil { if (std::is_same::value) { const auto res = detail::handle_native_field_division_component( - operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, gen_flag); - handle_component_result(assignment, inst, frame, res, gen_flag); + operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, comp_gen_params); + handle_component_result(assignment, inst, frame, res, comp_gen_params); } else { UNREACHABLE("Non-native ed25519 division is not implemented yet"); } diff --git a/include/nil/blueprint/fields/multiplication.hpp b/include/nil/blueprint/fields/multiplication.hpp index efdd135d..c4f39b44 100644 --- a/include/nil/blueprint/fields/multiplication.hpp +++ b/include/nil/blueprint/fields/multiplication.hpp @@ -52,7 +52,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; @@ -65,7 +65,7 @@ namespace nil { typename component_type::input_type instance_input({x, y}); return get_component_result - (bp, assignment, start_row, target_prover_idx, instance_input, gen_flag); + (bp, assignment, start_row, target_prover_idx, instance_input, comp_gen_params); } template @@ -78,7 +78,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; using non_native_policy_type = basic_non_native_policy; @@ -102,7 +102,7 @@ namespace nil { typename component_type::input_type instance_input({x, y}); return get_component_result - (bp, assignment, start_row, target_prover_idx, instance_input, gen_flag); + (bp, assignment, start_row, target_prover_idx, instance_input, comp_gen_params); } } // namespace detail @@ -114,7 +114,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using non_native_policy_type = basic_non_native_policy; using native_component_type = components::multiplication< @@ -138,9 +138,9 @@ namespace nil { if (std::is_same::value) { const auto res = detail::handle_native_field_multiplication_component( - operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, gen_flag); + operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, comp_gen_params); handle_component_result - (assignment, inst, frame, res, gen_flag); + (assignment, inst, frame, res, comp_gen_params); } else { UNREACHABLE("non-native bls12-381 base field mul not implemented yet"); } @@ -158,9 +158,9 @@ namespace nil { if (std::is_same::value) { const auto res = detail::handle_native_field_multiplication_component( - operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, gen_flag); + operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, comp_gen_params); handle_component_result - (assignment, inst, frame, res, gen_flag); + (assignment, inst, frame, res, comp_gen_params); } else { UNREACHABLE("non-native pallas base field mul not implemented yet"); } @@ -181,16 +181,16 @@ namespace nil { if (std::is_same::value) { const auto res = detail::handle_native_field_multiplication_component( - operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, gen_flag); + operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, comp_gen_params); handle_component_result - (assignment, inst, frame, res, gen_flag); + (assignment, inst, frame, res, comp_gen_params); } else { const auto& component_result = detail::handle_non_native_field_multiplication_component< BlueprintFieldType, ArithmetizationParams, operating_field_type>( - operand0, operand1, frame.vectors, bp, assignment, start_row, target_prover_idx, gen_flag); + operand0, operand1, frame.vectors, bp, assignment, start_row, target_prover_idx, comp_gen_params); handle_component_result - (assignment, inst, frame, component_result, gen_flag); + (assignment, inst, frame, component_result, comp_gen_params); } } else { diff --git a/include/nil/blueprint/fields/subtraction.hpp b/include/nil/blueprint/fields/subtraction.hpp index 0eed959c..aa4b6dff 100644 --- a/include/nil/blueprint/fields/subtraction.hpp +++ b/include/nil/blueprint/fields/subtraction.hpp @@ -52,7 +52,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; @@ -65,7 +65,7 @@ namespace nil { typename component_type::input_type instance_input({x, y}); return get_component_result - (bp, assignment, start_row, target_prover_idx, instance_input, gen_flag); + (bp, assignment, start_row, target_prover_idx, instance_input, comp_gen_params); } template @@ -78,7 +78,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; using non_native_policy_type = basic_non_native_policy; @@ -102,7 +102,7 @@ namespace nil { typename component_type::input_type instance_input({x, y}); return get_component_result - (bp, assignment, start_row, target_prover_idx, instance_input, gen_flag); + (bp, assignment, start_row, target_prover_idx, instance_input, comp_gen_params); } } // namespace detail @@ -114,7 +114,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using non_native_policy_type = basic_non_native_policy; using native_component_type = components::subtraction< @@ -138,8 +138,8 @@ namespace nil { if (std::is_same::value) { const auto res = detail::handle_native_field_subtraction_component( - operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, gen_flag); - handle_component_result(assignment, inst, frame, res, gen_flag); + operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, comp_gen_params); + handle_component_result(assignment, inst, frame, res, comp_gen_params); } else { UNREACHABLE("not implemented yet"); } @@ -157,8 +157,8 @@ namespace nil { if (std::is_same::value) { const auto res = detail::handle_native_field_subtraction_component( - operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, gen_flag); - handle_component_result(assignment, inst, frame, res, gen_flag); + operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, comp_gen_params); + handle_component_result(assignment, inst, frame, res, comp_gen_params); } else { UNREACHABLE("non_native_policy is not implemented yet"); } @@ -179,15 +179,15 @@ namespace nil { if (std::is_same::value) { const auto res = detail::handle_native_field_subtraction_component( - operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, gen_flag); - handle_component_result(assignment, inst, frame, res, gen_flag); + operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, comp_gen_params); + handle_component_result(assignment, inst, frame, res, comp_gen_params); } else { const auto& component_result = detail::handle_non_native_field_subtraction_component< BlueprintFieldType, ArithmetizationParams, operating_field_type>( - operand0, operand1, frame.vectors, bp, assignment, start_row, target_prover_idx, gen_flag); + operand0, operand1, frame.vectors, bp, assignment, start_row, target_prover_idx, comp_gen_params); handle_component_result - (assignment, inst, frame, component_result, gen_flag); + (assignment, inst, frame, component_result, comp_gen_params); } } else { diff --git a/include/nil/blueprint/handle_component.hpp b/include/nil/blueprint/handle_component.hpp index af3142af..b61f8d43 100644 --- a/include/nil/blueprint/handle_component.hpp +++ b/include/nil/blueprint/handle_component.hpp @@ -62,32 +62,17 @@ #include #include +#include + namespace nil { namespace blueprint { - enum class generate_flag : uint8_t { - NONE = 0, - CIRCUIT = 1 << 0, - ASSIGNMENTS = 1 << 1, - FALSE_ASSIGNMENTS = 1 << 2 - }; - - constexpr enum generate_flag operator |( const enum generate_flag self, const enum generate_flag val ) - { - return (enum generate_flag)(uint8_t(self) | uint8_t(val)); - } - - constexpr enum generate_flag operator &( const enum generate_flag self, const enum generate_flag val ) - { - return (enum generate_flag)(uint8_t(self) & uint8_t(val)); - } - template void handle_component_input( assignment_proxy> &assignment, - typename ComponentType::input_type& instance_input, generate_flag gen_flag) { + typename ComponentType::input_type& instance_input, component_creation_parameters_struct comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; @@ -98,7 +83,7 @@ namespace nil { bool found = (used_rows.find(v.get().rotation) != used_rows.end()); if (!found && (v.get().type == var::column_type::witness || v.get().type == var::column_type::constant)) { var new_v; - if (std::uint8_t(gen_flag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(comp_gen_params.genFlag & generate_flag::ASSIGNMENTS)) { new_v = save_shared_var(assignment, v); } else { const auto& shared_idx = assignment.shared_column_size(0); @@ -120,7 +105,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag, + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params, typename components::logic_and< crypto3::zk::snark::plonk_constraint_system>::input_type& instance_input) { @@ -138,11 +123,11 @@ namespace nil { } }; - handle_component_input(assignment, instance_input, gen_flag); + handle_component_input(assignment, instance_input, comp_gen_params); components::generate_circuit(component_instance, bp, assignment, instance_input, start_row); - if (std::uint8_t(gen_flag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(comp_gen_params.genFlag & generate_flag::ASSIGNMENTS)) { return components::generate_assignments(component_instance, assignment, instance_input, start_row); } else { @@ -223,7 +208,7 @@ namespace nil { &assignment, std::uint32_t start_row, std::uint32_t target_prover_idx, typename ComponentType::input_type& instance_input, - generate_flag gen_flag, + component_creation_parameters_struct comp_gen_params, Args... args) { const auto p = detail::PolicyManager::get_parameters(detail::ManifestReader::get_witness(0, args...)); @@ -231,7 +216,7 @@ namespace nil { ComponentType component_instance(p.witness, detail::ManifestReader::get_constants(), detail::ManifestReader::get_public_inputs(), args...); - handle_component_input(assignment, instance_input, gen_flag); + handle_component_input(assignment, instance_input, comp_gen_params); // copy constraints before execute component const auto num_copy_constraints = bp.copy_constraints().size(); @@ -239,11 +224,11 @@ namespace nil { // generate circuit in any case for fill selectors generate_circuit(component_instance, bp, assignment, instance_input, start_row); - if (std::uint8_t(gen_flag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(comp_gen_params.genFlag & generate_flag::ASSIGNMENTS)) { return generate_assignments(component_instance, assignment, instance_input, start_row, target_prover_idx); } else { - if (std::uint8_t(gen_flag & generate_flag::FALSE_ASSIGNMENTS)) { + if (std::uint8_t(comp_gen_params.genFlag & generate_flag::FALSE_ASSIGNMENTS)) { const auto rows_amount = ComponentType::get_rows_amount(p.witness.size(), 0, args...); // disable selector for (std::uint32_t i = 0; i < rows_amount; i++) { @@ -297,14 +282,14 @@ namespace nil { &assignment, const llvm::Instruction *inst, stack_frame> &frame, - const typename ComponentType::result_type& component_result, generate_flag gen_flag) { + const typename ComponentType::result_type& component_result, component_creation_parameters_struct comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; std::vector output = component_result.all_vars(); //touch result variables - if (std::uint8_t(gen_flag & generate_flag::ASSIGNMENTS) == 0) { + if (std::uint8_t(comp_gen_params.genFlag & generate_flag::ASSIGNMENTS) == 0) { const auto result_vars = component_result.all_vars(); for (const auto &v : result_vars) { if (v.type == var::column_type::witness) { @@ -328,12 +313,12 @@ namespace nil { const llvm::Instruction *inst, stack_frame> &frame, const std::vector>& result, - generate_flag gen_flag) { + component_creation_parameters_struct comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; //touch result variables - if (std::uint8_t(gen_flag & generate_flag::ASSIGNMENTS) == 0) { + if (std::uint8_t(comp_gen_params.genFlag & generate_flag::ASSIGNMENTS) == 0) { for (const auto &v : result) { if (v.type == var::column_type::witness) { assignment.witness(v.index, v.rotation) = BlueprintFieldType::value_type::zero(); @@ -354,16 +339,16 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag, + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params, typename ComponentType::input_type& instance_input, const llvm::Instruction *inst, stack_frame> &frame, Args... args) { const auto component_result = get_component_result - (bp, assignment, start_row, target_prover_idx, instance_input, gen_flag, args...); + (bp, assignment, start_row, target_prover_idx, instance_input, comp_gen_params, args...); - handle_component_result(assignment, inst, frame, component_result, gen_flag); + handle_component_result(assignment, inst, frame, component_result, comp_gen_params); } } // namespace blueprint diff --git a/include/nil/blueprint/hashes/sha2_256.hpp b/include/nil/blueprint/hashes/sha2_256.hpp index 8875c99a..cdadd2ef 100644 --- a/include/nil/blueprint/hashes/sha2_256.hpp +++ b/include/nil/blueprint/hashes/sha2_256.hpp @@ -47,7 +47,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; using component_type = components::sha256< @@ -66,7 +66,7 @@ namespace nil { typename component_type::input_type instance_input = {input_block_vars}; handle_component - (bp, assignment, start_row, target_prover_idx, gen_flag, instance_input, inst, frame); + (bp, assignment, start_row, target_prover_idx, comp_gen_params, instance_input, inst, frame); } } // namespace blueprint } // namespace nil diff --git a/include/nil/blueprint/hashes/sha2_512.hpp b/include/nil/blueprint/hashes/sha2_512.hpp index 13833bb4..5a518504 100644 --- a/include/nil/blueprint/hashes/sha2_512.hpp +++ b/include/nil/blueprint/hashes/sha2_512.hpp @@ -47,7 +47,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; using sha2_512_component_type = components::sha512< @@ -74,10 +74,10 @@ namespace nil { typename sha2_512_component_type::result_type sha2_512_component_result = get_component_result - (bp, assignment, start_row, target_prover_idx, sha2_512_instance_input, gen_flag); + (bp, assignment, start_row, target_prover_idx, sha2_512_instance_input, comp_gen_params); handle_component_result - (assignment, inst, frame, sha2_512_component_result, gen_flag); + (assignment, inst, frame, sha2_512_component_result, comp_gen_params); using reduction_component_type = components::reduction< crypto3::zk::snark::plonk_constraint_system, BlueprintFieldType, @@ -89,10 +89,10 @@ namespace nil { typename reduction_component_type::result_type reduction_component_result = get_component_result - (bp, assignment, start_row, target_prover_idx, reduction_instance_input, gen_flag); + (bp, assignment, start_row, target_prover_idx, reduction_instance_input, comp_gen_params); handle_component_result - (assignment, inst, frame, reduction_component_result, gen_flag); + (assignment, inst, frame, reduction_component_result, comp_gen_params); } } // namespace blueprint } // namespace nil diff --git a/include/nil/blueprint/integers/addition.hpp b/include/nil/blueprint/integers/addition.hpp index f359fcca..6fbccd65 100644 --- a/include/nil/blueprint/integers/addition.hpp +++ b/include/nil/blueprint/integers/addition.hpp @@ -48,7 +48,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using non_native_policy_type = basic_non_native_policy; @@ -56,13 +56,13 @@ namespace nil { llvm::Value *operand1 = inst->getOperand(1); const auto res = detail::handle_native_field_addition_component( - operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, gen_flag); + operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, comp_gen_params); using component_type = components::addition< crypto3::zk::snark::plonk_constraint_system, BlueprintFieldType, basic_non_native_policy>; - handle_component_result(assignment, inst, frame, res, gen_flag); + handle_component_result(assignment, inst, frame, res, comp_gen_params); } } // namespace blueprint diff --git a/include/nil/blueprint/integers/bit_de_composition.hpp b/include/nil/blueprint/integers/bit_de_composition.hpp index 4ceafa5c..eec66407 100644 --- a/include/nil/blueprint/integers/bit_de_composition.hpp +++ b/include/nil/blueprint/integers/bit_de_composition.hpp @@ -50,7 +50,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; var component_input = variables[input]; @@ -63,9 +63,9 @@ namespace nil { typename component_type::input_type instance_input({component_input}); auto result = get_component_result - (bp, assignment, start_row, target_prover_idx, instance_input, gen_flag, BitsAmount, Mode).output; + (bp, assignment, start_row, target_prover_idx, instance_input, comp_gen_params, BitsAmount, Mode).output; - if (std::uint8_t(gen_flag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(comp_gen_params.genFlag & generate_flag::ASSIGNMENTS)) { ptr_type result_ptr = static_cast( typename BlueprintFieldType::integral_type(var_value(assignment, variables[result_value]).data)); for (var v : result) { @@ -88,7 +88,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; @@ -102,11 +102,11 @@ namespace nil { std::size_t bitness_from_intrinsic = extract_constant_size_t_value(bitness_value); std::vector component_input = extract_intrinsic_input_vector( - input_value, bitness_from_intrinsic, variables, memory, assignment, gen_flag); + input_value, bitness_from_intrinsic, variables, memory, assignment, comp_gen_params); typename component_type::input_type instance_input({component_input}); return get_component_result - (bp, assignment, start_row, target_prover_idx, instance_input, gen_flag, bitness_from_intrinsic, true, Mode); + (bp, assignment, start_row, target_prover_idx, instance_input, comp_gen_params, bitness_from_intrinsic, true, Mode); } } // namespace detail @@ -118,7 +118,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { llvm::Value *result_value = inst->getOperand(0); llvm::Value *bitness_value = inst->getOperand(1); @@ -134,7 +134,7 @@ namespace nil { detail::handle_native_field_decomposition_component( bitness_from_intrinsic, result_value, input, is_msb, frame.vectors, - frame.scalars, memory, bp, assignment, start_row, target_prover_idx, gen_flag); + frame.scalars, memory, bp, assignment, start_row, target_prover_idx, comp_gen_params); } template @@ -145,7 +145,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using non_native_policy_type = basic_non_native_policy; using component_type = nil::blueprint::components::bit_composition< @@ -157,9 +157,9 @@ namespace nil { const auto res = detail::handle_native_field_bit_composition_component( result_value, bitness_value, operand_sig_bit, frame.vectors, - frame.scalars, memory, bp, assignment, start_row, target_prover_idx, gen_flag); + frame.scalars, memory, bp, assignment, start_row, target_prover_idx, comp_gen_params); - handle_component_result(assignment, inst, frame, res, gen_flag); + handle_component_result(assignment, inst, frame, res, comp_gen_params); } } // namespace blueprint diff --git a/include/nil/blueprint/integers/bit_shift.hpp b/include/nil/blueprint/integers/bit_shift.hpp index 147d80d5..56e15b93 100644 --- a/include/nil/blueprint/integers/bit_shift.hpp +++ b/include/nil/blueprint/integers/bit_shift.hpp @@ -47,7 +47,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag, + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params, typename nil::blueprint::components::bit_shift_mode left_or_right) { using var = crypto3::zk::snark::plonk_variable; @@ -67,7 +67,7 @@ namespace nil { using nil::blueprint::components::bit_shift_mode; return get_component_result - (bp, assignment, start_row, target_prover_idx, instance_input, gen_flag, Bitness, Shift, left_or_right); + (bp, assignment, start_row, target_prover_idx, instance_input, comp_gen_params, Bitness, Shift, left_or_right); } } // namespace detail @@ -78,7 +78,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag, + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params, typename nil::blueprint::components::bit_shift_mode left_or_right) { using component_type = nil::blueprint::components::bit_shift_constant< @@ -92,8 +92,8 @@ namespace nil { std::size_t bitness = inst->getOperand(0)->getType()->getPrimitiveSizeInBits(); const auto res = detail::handle_native_field_bit_shift_constant_component( - bitness, operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, gen_flag, left_or_right); - handle_component_result(assignment, inst, frame, res, gen_flag); + bitness, operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, comp_gen_params, left_or_right); + handle_component_result(assignment, inst, frame, res, comp_gen_params); } } // namespace blueprint diff --git a/include/nil/blueprint/integers/division.hpp b/include/nil/blueprint/integers/division.hpp index d1df606e..eaa7d02b 100644 --- a/include/nil/blueprint/integers/division.hpp +++ b/include/nil/blueprint/integers/division.hpp @@ -49,7 +49,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using non_native_policy_type = basic_non_native_policy; diff --git a/include/nil/blueprint/integers/division_remainder.hpp b/include/nil/blueprint/integers/division_remainder.hpp index 4be16d46..88960a97 100644 --- a/include/nil/blueprint/integers/division_remainder.hpp +++ b/include/nil/blueprint/integers/division_remainder.hpp @@ -48,7 +48,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; using component_type = components::division_remainder< @@ -59,7 +59,7 @@ namespace nil { typename component_type::input_type instance_input({x, y}); return get_component_result - (bp, assignment, start_row, target_prover_idx, instance_input, gen_flag, Bitness, true); + (bp, assignment, start_row, target_prover_idx, instance_input, comp_gen_params, Bitness, true); } } // namespace detail @@ -72,7 +72,7 @@ namespace nil { &assignment, std::uint32_t start_row, std::uint32_t target_prover_idx, - generate_flag gen_flag, + component_creation_parameters_struct comp_gen_params, bool is_division) { using non_native_policy_type = basic_non_native_policy; @@ -87,14 +87,14 @@ namespace nil { crypto3::zk::snark::plonk_variable res; if (is_division) { res = detail::handle_native_field_division_remainder_component( - bitness, operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, gen_flag).quotient; + bitness, operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, comp_gen_params).quotient; } else { res = detail::handle_native_field_division_remainder_component( - bitness, operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, gen_flag).remainder; + bitness, operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, comp_gen_params).remainder; } handle_result - (assignment, inst, frame, {res}, gen_flag); + (assignment, inst, frame, {res}, comp_gen_params); } } // namespace blueprint diff --git a/include/nil/blueprint/integers/multiplication.hpp b/include/nil/blueprint/integers/multiplication.hpp index eb6d694a..d294f70a 100644 --- a/include/nil/blueprint/integers/multiplication.hpp +++ b/include/nil/blueprint/integers/multiplication.hpp @@ -49,7 +49,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using non_native_policy_type = basic_non_native_policy; using component_type = components::multiplication< @@ -61,8 +61,8 @@ namespace nil { const auto res = detail::handle_native_field_multiplication_component( - operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, gen_flag); - handle_component_result(assignment, inst, frame, res, gen_flag); + operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, comp_gen_params); + handle_component_result(assignment, inst, frame, res, comp_gen_params); } } // namespace blueprint diff --git a/include/nil/blueprint/integers/subtraction.hpp b/include/nil/blueprint/integers/subtraction.hpp index 5007ecee..be511742 100644 --- a/include/nil/blueprint/integers/subtraction.hpp +++ b/include/nil/blueprint/integers/subtraction.hpp @@ -49,7 +49,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using non_native_policy_type = basic_non_native_policy; using component_type = components::subtraction< @@ -61,8 +61,8 @@ namespace nil { const auto res = detail::handle_native_field_subtraction_component( - operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, gen_flag); - handle_component_result(assignment, inst, frame, res, gen_flag); + operand0, operand1, frame.scalars, bp, assignment, start_row, target_prover_idx, comp_gen_params); + handle_component_result(assignment, inst, frame, res, comp_gen_params); } } // namespace blueprint diff --git a/include/nil/blueprint/parser.hpp b/include/nil/blueprint/parser.hpp index 9f87cb5b..27559cd2 100644 --- a/include/nil/blueprint/parser.hpp +++ b/include/nil/blueprint/parser.hpp @@ -52,6 +52,7 @@ #include "llvm/IR/Intrinsics.h" #include "llvm/IR/GetElementPtrTypeIterator.h" +#include #include #include #include @@ -119,7 +120,7 @@ namespace nil { log(log_level), print_output_format(output_print_format), validity_check(check_validity), - genFlag(gen_flag) + component_creation_parameters(gen_flag) { detail::PolicyManager::set_policy(kind); @@ -145,13 +146,13 @@ namespace nil { predecessor = p.predecessor; currProverIdx = p.currProverIdx; cpp_values = p.cpp_values; - genFlag = p.genFlag; + component_creation_parameters = p.component_creation_parameters; finished = p.finished; } const llvm::BasicBlock *predecessor; std::uint32_t currProverIdx; std::vector cpp_values; - generate_flag genFlag; + component_creation_parameters_struct component_creation_parameters; bool finished; }; @@ -203,12 +204,12 @@ namespace nil { const auto start_row = assignments[currProverIdx].allocated_rows(); const auto v = handle_comparison_component( p, lhs, rhs, bitness, - circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag); + circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters); handle_component_result - (assignments[currProverIdx], inst, frame, v, genFlag); + (assignments[currProverIdx], inst, frame, v, component_creation_parameters); } else { bool res = false; - if (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { switch (p) { case llvm::CmpInst::ICMP_SGE: case llvm::CmpInst::ICMP_UGE: { @@ -264,12 +265,12 @@ namespace nil { const auto start_row = assignments[currProverIdx].allocated_rows(); auto v = handle_comparison_component( inst->getPredicate(), lhs[i], rhs[i], bitness, - circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag); + circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters); res.emplace_back(v.output); } handle_result - (assignments[currProverIdx], inst, frame, res, genFlag); + (assignments[currProverIdx], inst, frame, res, component_creation_parameters); } void handle_curve_cmp(const llvm::ICmpInst *inst, stack_frame &frame) { @@ -290,7 +291,7 @@ namespace nil { for (size_t i = 0; i < lhs.size(); ++i) { auto v = handle_comparison_component( inst->getPredicate(), lhs[i], rhs[i], 0, - circuits[currProverIdx], assignments[currProverIdx], assignments[currProverIdx].allocated_rows(), targetProverIdx, genFlag); + circuits[currProverIdx], assignments[currProverIdx], assignments[currProverIdx].allocated_rows(), targetProverIdx, component_creation_parameters); res.emplace_back(v.output); } @@ -301,14 +302,14 @@ namespace nil { for (size_t i = 1; i < lhs.size(); ++i) { are_curves_equal = handle_logic_and( are_curves_equal, res[i], circuits[currProverIdx], assignments[currProverIdx], - assignments[currProverIdx].allocated_rows(), targetProverIdx, genFlag); + assignments[currProverIdx].allocated_rows(), targetProverIdx, component_creation_parameters); } handle_result - (assignments[currProverIdx], inst, frame, {are_curves_equal}, genFlag); + (assignments[currProverIdx], inst, frame, {are_curves_equal}, component_creation_parameters); } void handle_ptr_cmp(const llvm::ICmpInst *inst, stack_frame &frame) { - if (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { ptr_type lhs = resolve_number(frame, inst->getOperand(0)); ASSERT(frame.scalars.find(inst->getOperand(1)) != frame.scalars.end()); ptr_type rhs = resolve_number(frame, inst->getOperand(1)); @@ -457,7 +458,7 @@ namespace nil { switch (id) { case llvm::Intrinsic::assigner_malloc: { - if (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { size_t bytes = resolve_number(frame, inst->getOperand(0)); frame.scalars[inst] = put_into_assignment(stack_memory.malloc(bytes)); } else { @@ -483,7 +484,7 @@ namespace nil { typename component_type::input_type instance_input = {input_state_var}; handle_component - (circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag, instance_input, inst, frame); + (circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters, instance_input, inst, frame); return true; } else { @@ -495,12 +496,12 @@ namespace nil { circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, - genFlag); + component_creation_parameters); return true; } case llvm::Intrinsic::assigner_sha2_512: { if constexpr (std::is_same::value) { - handle_sha2_512_component(inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag); + handle_sha2_512_component(inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters); return true; } else { @@ -515,7 +516,7 @@ namespace nil { ASSERT(frame.vectors[inst->getOperand(0)].size() == 2); ASSERT(frame.vectors[inst->getOperand(1)].size() == 4); - if (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { typename crypto3::algebra::curves::bls12<381>::template g1_type<>::value_type g1 = { var_value(assignments[currProverIdx], frame.vectors[inst->getOperand(0)][0]), var_value(assignments[currProverIdx], frame.vectors[inst->getOperand(0)][1]), @@ -553,7 +554,7 @@ namespace nil { put_into_assignment(gt.data[1].data[2].data[1])}; handle_result(assignments[currProverIdx], - inst, frame, res, genFlag); + inst, frame, res, component_creation_parameters); } else { std::vector res = {put_into_assignment(0), put_into_assignment(0), @@ -569,7 +570,7 @@ namespace nil { put_into_assignment(0)}; handle_result(assignments[currProverIdx], - inst, frame, res, genFlag); + inst, frame, res, component_creation_parameters); } return true; } @@ -586,7 +587,7 @@ namespace nil { frame.scalars[inst->getOperand(0)]}; handle_result(assignments[currProverIdx], - inst, frame, res, genFlag); + inst, frame, res, component_creation_parameters); return true; } else { @@ -599,7 +600,7 @@ namespace nil { std::cerr << "warning: __builtin_assigner_is_in_g1_check is an experimental feature, may be not stable\n"; handle_result(assignments[currProverIdx], - inst, frame, {zero_var}, genFlag); + inst, frame, {zero_var}, component_creation_parameters); return true; } else { @@ -612,7 +613,7 @@ namespace nil { std::cerr << "warning: __builtin_assigner_is_in_g2_check is an experimental feature, may be not stable\n"; handle_result(assignments[currProverIdx], - inst, frame, {zero_var}, genFlag); + inst, frame, {zero_var}, component_creation_parameters); return true; } else { @@ -624,7 +625,7 @@ namespace nil { std::cerr << "warning: __builtin_assigner_gt_multiplication is an experimental feature, may be not stable\n"; - if (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { std::vector vars_1 = frame.vectors[inst->getOperand(0)]; ASSERT(vars_1.size() == 12); std::vector A = {}; @@ -662,7 +663,7 @@ namespace nil { put_into_assignment(e.data[1].data[2].data[1])}; handle_result(assignments[currProverIdx], - inst, frame, res, genFlag); + inst, frame, res, component_creation_parameters); } else { std::vector res = {put_into_assignment(0), put_into_assignment(0), @@ -678,7 +679,7 @@ namespace nil { put_into_assignment(0)}; handle_result(assignments[currProverIdx], - inst, frame, res, genFlag); + inst, frame, res, component_creation_parameters); } return true; } @@ -689,24 +690,24 @@ namespace nil { case llvm::Intrinsic::assigner_bit_decomposition_field: case llvm::Intrinsic::assigner_bit_decomposition: { ASSERT(check_operands_constantness(inst, {1, 3}, frame)); - handle_integer_bit_decomposition_component(inst, frame, stack_memory, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag); + handle_integer_bit_decomposition_component(inst, frame, stack_memory, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters); return true; } case llvm::Intrinsic::assigner_bit_composition: { ASSERT(check_operands_constantness(inst, {1, 2}, frame)); - handle_integer_bit_composition_component(inst, frame, stack_memory, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag); + handle_integer_bit_composition_component(inst, frame, stack_memory, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters); return true; } case llvm::Intrinsic::assigner_print_native_pallas_field: { llvm::Value *input = inst->getOperand(0); ASSERT(field_arg_num(input->getType()) == 1); - if (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { std::cout << var_value(assignments[currProverIdx], frame.scalars[input]).data << std::endl; } return true; } case llvm::Intrinsic::memcpy: { - if (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { llvm::Value *src_val = inst->getOperand(1); ptr_type dst = resolve_number(frame, inst->getOperand(0)); ptr_type src = resolve_number(frame, src_val); @@ -716,7 +717,7 @@ namespace nil { return true; } case llvm::Intrinsic::memset: { - if (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { ptr_type dst = resolve_number(frame, inst->getOperand(0)); unsigned width = resolve_number(frame, inst->getOperand(2)); ASSERT(frame.scalars.find(inst->getOperand(1)) != frame.scalars.end()); @@ -765,9 +766,9 @@ namespace nil { var comparison_result = handle_comparison_component( llvm::CmpInst::ICMP_EQ, logical_statement, zero_var, bitness, - circuits[currProverIdx], assignments[currProverIdx], assignments[currProverIdx].allocated_rows(), targetProverIdx, genFlag).output; + circuits[currProverIdx], assignments[currProverIdx], assignments[currProverIdx].allocated_rows(), targetProverIdx, component_creation_parameters).output; - if (validity_check && std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (validity_check && std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { bool assigner_exit_check_input = var_value(assignments[currProverIdx], comparison_result) == 0; ASSERT_MSG(assigner_exit_check_input, "assigner_exit_check input is false, verification will fail!\n"); @@ -778,22 +779,22 @@ namespace nil { return true; } case llvm::Intrinsic::assigner_fri_lin_inter: { - handle_fri_lin_inter_component(inst, frame, stack_memory, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag); + handle_fri_lin_inter_component(inst, frame, stack_memory, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters); return true; } case llvm::Intrinsic::assigner_fri_cosets: { ASSERT_MSG(check_operands_constantness(inst, {1, 2}, frame), "result length, omega and total_bits must be constants"); - handle_fri_cosets_component(inst, frame, stack_memory, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag); + handle_fri_cosets_component(inst, frame, stack_memory, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters); return true; } case llvm::Intrinsic::assigner_gate_arg_verifier: { ASSERT_MSG(check_operands_constantness(inst, {1, 2, 4}, frame), "gates_sizes, gates and selectors amount must be constants"); - handle_gate_arg_verifier_component(inst, frame, stack_memory, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag); + handle_gate_arg_verifier_component(inst, frame, stack_memory, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters); return true; } case llvm::Intrinsic::assigner_permutation_arg_verifier: { ASSERT_MSG(check_operands_constantness(inst, {3}, frame), "f, se, sigma size must be constant"); - handle_permutation_arg_verifier_component(inst, frame, stack_memory, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag); + handle_permutation_arg_verifier_component(inst, frame, stack_memory, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters); return true; } case llvm::Intrinsic::assigner_lookup_arg_verifier: { @@ -801,12 +802,12 @@ namespace nil { for (std::size_t i = 0; i < 8; i++) { constants_positions.push_back(i);} for (std::size_t i = 4; i < 13; i++) { constants_positions.push_back(2*i + 1);} ASSERT_MSG(check_operands_constantness(inst, constants_positions, frame), "vectors sizes must be constants"); - handle_lookup_arg_verifier_component(inst, frame, stack_memory, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag); + handle_lookup_arg_verifier_component(inst, frame, stack_memory, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters); return true; } case llvm::Intrinsic::assigner_fri_array_swap: { ASSERT_MSG(check_operands_constantness(inst, {1}, frame), "array size must be constant"); - handle_fri_array_swap_component(inst, frame, stack_memory, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag); + handle_fri_array_swap_component(inst, frame, stack_memory, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters); return true; } @@ -855,7 +856,7 @@ namespace nil { void handle_load(ptr_type ptr, const llvm::Value *dest, stack_frame &frame) { size_t num_cells = layout_resolver->get_cells_num(dest->getType()); if (num_cells == 1) { - if (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { auto &cell = stack_memory[ptr]; frame.scalars[dest] = put_into_assignment(var_value(assignments[currProverIdx], cell.v)); } else { @@ -863,7 +864,7 @@ namespace nil { } } else { std::vector res; - if (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { for (size_t i = 0; i < num_cells; ++i) { res.push_back(put_into_assignment(var_value(assignments[currProverIdx], stack_memory[ptr + i].v))); } @@ -951,7 +952,7 @@ namespace nil { } void handle_ptrtoint(const llvm::Value *inst, llvm::Value *operand, stack_frame &frame) { - if (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { ptr_type ptr = resolve_number(frame, operand); size_t offset = stack_memory.ptrtoint(ptr); log.debug(boost::format("PtrToInt %1% %2%") % ptr % offset); @@ -1046,7 +1047,7 @@ namespace nil { handle_ptrtoint(expr, expr->getOperand(0), frame); break; case llvm::Instruction::GetElementPtr: { - if (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { std::vector gep_indices; for (unsigned i = 2; i < expr->getNumOperands(); ++i) { int gep_index = resolve_number(frame, expr->getOperand(i)); @@ -1094,7 +1095,7 @@ namespace nil { predecessor = parser_state.predecessor; currProverIdx = parser_state.currProverIdx; cpp_values = parser_state.cpp_values; - genFlag = parser_state.genFlag; + component_creation_parameters = parser_state.component_creation_parameters; finished = parser_state.finished; } @@ -1161,17 +1162,17 @@ namespace nil { if (inst->getOperand(0)->getType()->isIntegerTy()) { handle_integer_addition_component( - inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag); + inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters); return inst->getNextNonDebugInstruction(); } if (inst->getOperand(0)->getType()->isFieldTy() && inst->getOperand(1)->getType()->isFieldTy()) { handle_field_addition_component( - inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag); + inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters); return inst->getNextNonDebugInstruction(); } else if (inst->getOperand(0)->getType()->isCurveTy() && inst->getOperand(1)->getType()->isCurveTy()) { handle_curve_addition_component( - inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag); + inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters); return inst->getNextNonDebugInstruction(); } else { UNREACHABLE("curve + scalar is undefined"); @@ -1182,17 +1183,17 @@ namespace nil { case llvm::Instruction::Sub: { if (inst->getOperand(0)->getType()->isIntegerTy()) { handle_integer_subtraction_component( - inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag); + inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters); return inst->getNextNonDebugInstruction(); } if (inst->getOperand(0)->getType()->isFieldTy() && inst->getOperand(1)->getType()->isFieldTy()) { handle_field_subtraction_component( - inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag); + inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters); return inst->getNextNonDebugInstruction(); } else if (inst->getOperand(0)->getType()->isCurveTy() && inst->getOperand(1)->getType()->isCurveTy()) { handle_curve_subtraction_component( - inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag); + inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters); return inst->getNextNonDebugInstruction(); } else { UNREACHABLE("curve - scalar is undefined"); @@ -1204,13 +1205,13 @@ namespace nil { if (inst->getOperand(0)->getType()->isIntegerTy()) { handle_integer_multiplication_component( - inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag); + inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters); return inst->getNextNonDebugInstruction(); } if (inst->getOperand(0)->getType()->isFieldTy() && inst->getOperand(1)->getType()->isFieldTy()) { handle_field_multiplication_component( - inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag); + inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters); return inst->getNextNonDebugInstruction(); } @@ -1224,7 +1225,7 @@ namespace nil { (inst->getOperand(1)->getType()->isCurveTy() && inst->getOperand(0)->getType()->isFieldTy())) { handle_curve_multiplication_component( - inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag); + inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters); return inst->getNextNonDebugInstruction(); } else { UNREACHABLE("cmul opcode is defined only for curveTy * fieldTy"); @@ -1233,12 +1234,12 @@ namespace nil { case llvm::Instruction::UDiv: { if (inst->getOperand(0)->getType()->isIntegerTy() && inst->getOperand(1)->getType()->isIntegerTy()) { handle_integer_division_remainder_component( - inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag, true); + inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters, true); return inst->getNextNonDebugInstruction(); } else if (inst->getOperand(0)->getType()->isFieldTy() && inst->getOperand(1)->getType()->isFieldTy()) { handle_field_division_component( - inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag); + inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters); return inst->getNextNonDebugInstruction(); } else { @@ -1248,7 +1249,7 @@ namespace nil { case llvm::Instruction::URem: { if (inst->getOperand(0)->getType()->isIntegerTy() && inst->getOperand(1)->getType()->isIntegerTy()) { handle_integer_division_remainder_component( - inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag, false); + inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters, false); return inst->getNextNonDebugInstruction(); } else { UNREACHABLE("URem opcode is defined only for integerTy"); @@ -1257,7 +1258,7 @@ namespace nil { case llvm::Instruction::Shl: { if (inst->getOperand(0)->getType()->isIntegerTy() && inst->getOperand(1)->getType()->isIntegerTy()) { handle_integer_bit_shift_constant_component( - inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag, + inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters, nil::blueprint::components::bit_shift_mode::LEFT); return inst->getNextNonDebugInstruction(); } else { @@ -1267,7 +1268,7 @@ namespace nil { case llvm::Instruction::LShr: { if (inst->getOperand(0)->getType()->isIntegerTy() && inst->getOperand(1)->getType()->isIntegerTy()) { handle_integer_bit_shift_constant_component( - inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag, + inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters, nil::blueprint::components::bit_shift_mode::RIGHT); return inst->getNextNonDebugInstruction(); } else { @@ -1278,13 +1279,13 @@ namespace nil { if (inst->getOperand(0)->getType()->isIntegerTy()) { handle_integer_division_component( - inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag); + inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters); return inst->getNextNonDebugInstruction(); } if (inst->getOperand(0)->getType()->isFieldTy() && inst->getOperand(1)->getType()->isFieldTy()) { handle_field_division_component( - inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, genFlag); + inst, frame, circuits[currProverIdx], assignments[currProverIdx], start_row, targetProverIdx, component_creation_parameters); return inst->getNextNonDebugInstruction(); } @@ -1353,7 +1354,7 @@ namespace nil { return inst->getNextNonDebugInstruction(); } case llvm::Instruction::Select: { - if (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { var condition = variables[inst->getOperand(0)]; llvm::Value *true_val = inst->getOperand(1); llvm::Value *false_val = inst->getOperand(2); @@ -1369,7 +1370,7 @@ namespace nil { return inst->getNextNonDebugInstruction(); } case llvm::Instruction::And: { - if (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { const var &lhs = variables[inst->getOperand(0)]; const var &rhs = variables[inst->getOperand(1)]; @@ -1389,7 +1390,7 @@ namespace nil { return inst->getNextNonDebugInstruction(); } case llvm::Instruction::Or: { - if (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { const var &lhs = variables[inst->getOperand(0)]; const var &rhs = variables[inst->getOperand(1)]; @@ -1409,7 +1410,7 @@ namespace nil { return inst->getNextNonDebugInstruction(); } case llvm::Instruction::Xor: { - if (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { const var &lhs = variables[inst->getOperand(0)]; const var &rhs = variables[inst->getOperand(1)]; @@ -1446,19 +1447,19 @@ namespace nil { UNREACHABLE("Can't to process loop"); } const auto stack_size = call_stack.size(); - if (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { bool cond_val = (var_value(assignments[currProverIdx], cond) != 0); const ParserState parser_state(*this); curr_branch.push_back(branch_desc(false, stack_size)); curr_branch.push_back(branch_desc(true, stack_size)); if (!cond_val) { - genFlag = std::uint8_t(genFlag & (generate_flag::ASSIGNMENTS | generate_flag::FALSE_ASSIGNMENTS)) ? - (genFlag & generate_flag::CIRCUIT) | generate_flag::FALSE_ASSIGNMENTS : - genFlag & generate_flag::CIRCUIT; + component_creation_parameters.genFlag = std::uint8_t(component_creation_parameters.genFlag & (generate_flag::ASSIGNMENTS | generate_flag::FALSE_ASSIGNMENTS)) ? + (component_creation_parameters.genFlag & generate_flag::CIRCUIT) | generate_flag::FALSE_ASSIGNMENTS : + component_creation_parameters.genFlag & generate_flag::CIRCUIT; } - log.debug(boost::format("start handle true branch: %1% %2%") % curr_branch.size() % (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS) == 0)); + log.debug(boost::format("start handle true branch: %1% %2%") % curr_branch.size() % (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS) == 0)); const llvm::Instruction* true_next_inst = nullptr; if (!cond_val && true_name == "panic") { log.debug(boost::format("skip handle true branch as false positive panic: %1%") % curr_branch.size()); @@ -1472,12 +1473,12 @@ namespace nil { curr_branch.pop_back(); if (cond_val) { - genFlag = std::uint8_t(genFlag & (generate_flag::ASSIGNMENTS | generate_flag::FALSE_ASSIGNMENTS)) ? - (genFlag & generate_flag::CIRCUIT) | generate_flag::FALSE_ASSIGNMENTS : - genFlag & generate_flag::CIRCUIT; + component_creation_parameters.genFlag = std::uint8_t(component_creation_parameters.genFlag & (generate_flag::ASSIGNMENTS | generate_flag::FALSE_ASSIGNMENTS)) ? + (component_creation_parameters.genFlag & generate_flag::CIRCUIT) | generate_flag::FALSE_ASSIGNMENTS : + component_creation_parameters.genFlag & generate_flag::CIRCUIT; } - log.debug(boost::format("start handle false branch: %1% %2%") % curr_branch.size() % (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS) == 0)); + log.debug(boost::format("start handle false branch: %1% %2%") % curr_branch.size() % (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS) == 0)); auto false_next_inst = true_next_inst; if (cond_val && false_name == "panic") { log.debug(boost::format("skip handle false branch as false positive panic: %1%") % curr_branch.size()); @@ -1501,7 +1502,7 @@ namespace nil { curr_branch.push_back(branch_desc(false, stack_size)); curr_branch.push_back(branch_desc(true, stack_size)); - log.debug(boost::format("start handle true branch: %1% %2%") % curr_branch.size() % (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS) == 0)); + log.debug(boost::format("start handle true branch: %1% %2%") % curr_branch.size() % (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS) == 0)); const llvm::Instruction* true_next_inst = nullptr; if (true_name == "panic") { log.debug(boost::format("skip handle true branch as false positive panic: %1%") % curr_branch.size()); @@ -1514,7 +1515,7 @@ namespace nil { restore_state(parser_state); curr_branch.pop_back(); - log.debug(boost::format("start handle false branch: %1% %2%") % curr_branch.size() % (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS) == 0)); + log.debug(boost::format("start handle false branch: %1% %2%") % curr_branch.size() % (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS) == 0)); auto false_next_inst = true_next_inst; if (false_name == "panic") { log.debug(boost::format("skip handle false branch as false positive panic: %1%") % curr_branch.size()); @@ -1563,7 +1564,7 @@ namespace nil { auto switch_inst = llvm::cast(inst); llvm::Value *cond = switch_inst->getCondition(); ASSERT(cond->getType()->isIntegerTy()); - if (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { unsigned bit_width = llvm::cast(cond->getType())->getBitWidth(); ASSERT(bit_width <= 64); auto cond_var = var_value(assignments[currProverIdx], frame.scalars[cond]); @@ -1572,11 +1573,11 @@ namespace nil { (int64_t) static_cast(cond_var.data)); for (auto Case : switch_inst->cases()) { if (Case.getCaseValue()->getValue().eq(cond_val)) { - genFlag = - std::uint8_t(genFlag & + component_creation_parameters.genFlag = + std::uint8_t(component_creation_parameters.genFlag & (generate_flag::ASSIGNMENTS | generate_flag::FALSE_ASSIGNMENTS)) ? - (genFlag & generate_flag::CIRCUIT) | generate_flag::FALSE_ASSIGNMENTS : - genFlag & generate_flag::CIRCUIT; + (component_creation_parameters.genFlag & generate_flag::CIRCUIT) | generate_flag::FALSE_ASSIGNMENTS : + component_creation_parameters.genFlag & generate_flag::CIRCUIT; } const ParserState parser_state(*this); curr_branch.push_back(branch_desc(false, call_stack.size())); @@ -1614,7 +1615,7 @@ namespace nil { llvm::Value *vec = extract_inst->getOperand(0); llvm::Value *index_value = extract_inst->getOperand(1); if (!llvm::isa(index_value)) { - if (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { int index = resolve_number(frame, index_value); variables[inst] = frame.vectors[vec][index]; } else { @@ -1637,7 +1638,7 @@ namespace nil { } case llvm::Instruction::GetElementPtr: { auto *gep = llvm::cast(inst); - if (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { std::vector gep_indices; for (unsigned i = 1; i < gep->getNumIndices(); ++i) { int gep_index = resolve_number(frame, gep->getOperand(i + 1)); @@ -1662,7 +1663,7 @@ namespace nil { case llvm::Instruction::Load: { auto *load_inst = llvm::cast(inst); ptr_type ptr = 0; - if (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { ptr = resolve_number(frame, load_inst->getPointerOperand()); } log.debug(boost::format("Load: %1%") % ptr); @@ -1670,7 +1671,7 @@ namespace nil { return inst->getNextNonDebugInstruction(); } case llvm::Instruction::Store: { - if (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { auto *store_inst = llvm::cast(inst); ptr_type ptr = resolve_number(frame, store_inst->getPointerOperand()); log.debug(boost::format("Store: %1%") % ptr); @@ -1683,7 +1684,7 @@ namespace nil { } case llvm::Instruction::InsertValue: { auto *insert_inst = llvm::cast(inst); - if (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { ptr_type ptr = resolve_number(frame, insert_inst->getAggregateOperand()); // TODO(maksenov): handle offset properly ptr += layout_resolver @@ -1697,7 +1698,7 @@ namespace nil { } case llvm::Instruction::ExtractValue: { auto *extract_inst = llvm::cast(inst); - if (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { ptr_type ptr = resolve_number(frame, extract_inst->getAggregateOperand()); // TODO(maksenov): handle offset properly ptr += layout_resolver @@ -1718,7 +1719,7 @@ namespace nil { return inst->getNextNonDebugInstruction(); } case llvm::Instruction::IndirectBr: { - if (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS) == 0) { + if (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS) == 0) { UNREACHABLE("IndirectBr is not supported without generating assignment table"); return inst->getNextNonDebugInstruction(); } @@ -1733,7 +1734,7 @@ namespace nil { return inst->getNextNonDebugInstruction(); } case llvm::Instruction::IntToPtr: { - if (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { std::ostringstream oss; size_t offset = resolve_number(frame, inst->getOperand(0)); oss << var_value(assignments[currProverIdx], frame.scalars[inst->getOperand(0)]).data; @@ -1774,7 +1775,7 @@ namespace nil { if(print_output_format == hex) { std::cout << std::hex; } - if (inst->getNumOperands() != 0 && std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (inst->getNumOperands() != 0 && std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { llvm::Value *ret_val = inst->getOperand(0); if (ret_val->getType()->isPointerTy()) { // TODO(maksenov): support printing complex results @@ -1847,7 +1848,7 @@ namespace nil { auto res = extracted_frame.vectors[ret_val]; upper_frame_vectors[extracted_frame.caller] = res; } else if (ret_type->isAggregateType()) { - if (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS)) { ptr_type ret_ptr = resolve_number(extracted_frame, ret_val); ptr_type allocated_copy = stack_memory.add_cells( layout_resolver->get_type_layout(ret_type)); @@ -1912,7 +1913,7 @@ namespace nil { auto &function = *entry_point_it; auto input_reader = InputReader>( - base_frame, stack_memory, assignments[currProverIdx], *layout_resolver, (std::uint8_t(genFlag & generate_flag::ASSIGNMENTS) != 0)); + base_frame, stack_memory, assignments[currProverIdx], *layout_resolver, (std::uint8_t(component_creation_parameters.genFlag & generate_flag::ASSIGNMENTS) != 0)); if (!input_reader.fill_public_input(function, public_input, private_input, log)) { std::cerr << "Public input does not match the circuit signature"; const std::string &error = input_reader.get_error(); @@ -1995,7 +1996,7 @@ namespace nil { std::vector cpp_values; print_format print_output_format = no_print; bool validity_check; - generate_flag genFlag; + component_creation_parameters_struct component_creation_parameters; std::vector curr_branch; }; diff --git a/include/nil/blueprint/recursive_prover/fri_array_swap.hpp b/include/nil/blueprint/recursive_prover/fri_array_swap.hpp index eb384fa0..4f574d0b 100644 --- a/include/nil/blueprint/recursive_prover/fri_array_swap.hpp +++ b/include/nil/blueprint/recursive_prover/fri_array_swap.hpp @@ -45,7 +45,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { llvm::Value *result_value = inst->getOperand(0); llvm::Value *array_size_value = inst->getOperand(1); @@ -58,7 +58,7 @@ namespace nil { std::vector input_array = detail::extract_intrinsic_input_vector( - input_array_value, array_size, frame.scalars, memory, assignment, gen_flag); + input_array_value, array_size, frame.scalars, memory, assignment, comp_gen_params); var input_bool = frame.scalars[input_bool_value]; @@ -71,9 +71,9 @@ namespace nil { }; std::vector res = get_component_result - (bp, assignment, start_row, target_prover_idx, instance_input, gen_flag, array_size / 2).output; + (bp, assignment, start_row, target_prover_idx, instance_input, comp_gen_params, array_size / 2).output; - if (std::uint8_t(gen_flag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(comp_gen_params.genFlag & generate_flag::ASSIGNMENTS)) { ptr_type result_ptr = static_cast(typename BlueprintFieldType::integral_type( var_value(assignment, frame.scalars[result_value]).data)); for (std::size_t i = 0; i < array_size; i++) { diff --git a/include/nil/blueprint/recursive_prover/fri_cosets.hpp b/include/nil/blueprint/recursive_prover/fri_cosets.hpp index 9aacc83b..375332a8 100644 --- a/include/nil/blueprint/recursive_prover/fri_cosets.hpp +++ b/include/nil/blueprint/recursive_prover/fri_cosets.hpp @@ -51,7 +51,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; var component_input = variables[input]; @@ -64,9 +64,9 @@ namespace nil { typename component_type::input_type instance_input({component_input}); const auto& result = get_component_result - (bp, assignment, start_row, target_prover_idx, instance_input, gen_flag, res_length, omega).output; + (bp, assignment, start_row, target_prover_idx, instance_input, comp_gen_params, res_length, omega).output; - if (std::uint8_t(gen_flag & generate_flag::ASSIGNMENTS)) { + if (std::uint8_t(comp_gen_params.genFlag & generate_flag::ASSIGNMENTS)) { ptr_type result_ptr = static_cast( typename BlueprintFieldType::integral_type(var_value(assignment, variables[result_value]).data)); for (std::size_t i = 0; i < result.size(); i++) { @@ -88,7 +88,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { llvm::Value *result_value = inst->getOperand(0); llvm::Value *result_length_value = inst->getOperand(1); @@ -96,7 +96,7 @@ namespace nil { llvm::Value *input = inst->getOperand(3); detail::handle_native_fri_cosets_component( - result_value, result_length_value, omega_value, input, frame.vectors, frame.scalars, memory, bp, assignment, start_row, target_prover_idx, gen_flag); + result_value, result_length_value, omega_value, input, frame.vectors, frame.scalars, memory, bp, assignment, start_row, target_prover_idx, comp_gen_params); } diff --git a/include/nil/blueprint/recursive_prover/fri_lin_inter.hpp b/include/nil/blueprint/recursive_prover/fri_lin_inter.hpp index 7edd1fa8..ef4873d1 100644 --- a/include/nil/blueprint/recursive_prover/fri_lin_inter.hpp +++ b/include/nil/blueprint/recursive_prover/fri_lin_inter.hpp @@ -45,7 +45,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; @@ -59,7 +59,7 @@ namespace nil { typename component_type::input_type instance_input({s, y0, y1, alpha}); handle_component - (bp, assignment, start_row, target_prover_idx, gen_flag, instance_input, inst, frame); + (bp, assignment, start_row, target_prover_idx, comp_gen_params, instance_input, inst, frame); } diff --git a/include/nil/blueprint/recursive_prover/gate_arg_verifier.hpp b/include/nil/blueprint/recursive_prover/gate_arg_verifier.hpp index bbe395bd..162f6079 100644 --- a/include/nil/blueprint/recursive_prover/gate_arg_verifier.hpp +++ b/include/nil/blueprint/recursive_prover/gate_arg_verifier.hpp @@ -53,7 +53,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; var theta = variables[theta_value]; @@ -84,10 +84,10 @@ namespace nil { std::vector selectors = extract_intrinsic_input_vector( - selectors_value, gates_amount, variables, memory, assignment, gen_flag); + selectors_value, gates_amount, variables, memory, assignment, comp_gen_params); std::vector constraints = extract_intrinsic_input_vector( - constraints_value, constraints_amount, variables, memory, assignment, gen_flag); + constraints_value, constraints_amount, variables, memory, assignment, comp_gen_params); using component_type = components::basic_constraints_verifier< crypto3::zk::snark::plonk_constraint_system>; @@ -95,7 +95,7 @@ namespace nil { typename component_type::input_type instance_input = {theta, constraints, selectors}; return get_component_result - (bp, assignment, start_row, target_prover_idx, instance_input, gen_flag, gates_sizes); + (bp, assignment, start_row, target_prover_idx, instance_input, comp_gen_params, gates_sizes); } @@ -109,7 +109,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { llvm::Value *selectors_value = inst->getOperand(0); llvm::Value *gates_sizes_value = inst->getOperand(1); @@ -123,8 +123,8 @@ namespace nil { const auto& res = detail::handle_native_gate_arg_verifier_component( selectors_value, gates_sizes_value, gates_amount_value, constraints_value, constraints_amount_value, theta_value, - frame.scalars, memory, bp, assignment, start_row, target_prover_idx, gen_flag); - handle_component_result(assignment, inst, frame, res, gen_flag); + frame.scalars, memory, bp, assignment, start_row, target_prover_idx, comp_gen_params); + handle_component_result(assignment, inst, frame, res, comp_gen_params); } } // namespace blueprint } // namespace nil diff --git a/include/nil/blueprint/recursive_prover/lookup_arg_verifier.hpp b/include/nil/blueprint/recursive_prover/lookup_arg_verifier.hpp index cd14fcb8..5a2738c0 100644 --- a/include/nil/blueprint/recursive_prover/lookup_arg_verifier.hpp +++ b/include/nil/blueprint/recursive_prover/lookup_arg_verifier.hpp @@ -45,7 +45,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; @@ -72,7 +72,7 @@ namespace nil { for (std::size_t i = 0; i < 9; i++) { size = detail::extract_constant_size_t_value(inst->getOperand(8 + i * 2 + 1)); input_vectors.push_back(detail::extract_intrinsic_input_vector( - inst->getOperand(8 + i * 2), size, frame.scalars, memory, assignment, gen_flag)); + inst->getOperand(8 + i * 2), size, frame.scalars, memory, assignment, comp_gen_params)); } var theta = frame.scalars[inst->getOperand(26)]; @@ -110,7 +110,7 @@ namespace nil { }; handle_component - (bp, assignment, start_row, target_prover_idx, gen_flag, instance_input, inst, frame, + (bp, assignment, start_row, target_prover_idx, comp_gen_params, instance_input, inst, frame, lookup_gate_size, lookup_gate_constraints_sizes, lookup_gate_constraints_lookup_input_sizes, diff --git a/include/nil/blueprint/recursive_prover/permutation_arg_verifier.hpp b/include/nil/blueprint/recursive_prover/permutation_arg_verifier.hpp index 5f77bb93..2e55c49f 100644 --- a/include/nil/blueprint/recursive_prover/permutation_arg_verifier.hpp +++ b/include/nil/blueprint/recursive_prover/permutation_arg_verifier.hpp @@ -58,7 +58,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; var L0 = variables[L0_value]; @@ -72,13 +72,13 @@ namespace nil { std::size_t input_length = extract_constant_size_t_value(input_length_value); std::vector Ssigma = extract_intrinsic_input_vector( - Ssigma_value, input_length, variables, memory, assignment, gen_flag); + Ssigma_value, input_length, variables, memory, assignment, comp_gen_params); std::vector f = extract_intrinsic_input_vector( - f_value, input_length, variables, memory, assignment, gen_flag); + f_value, input_length, variables, memory, assignment, comp_gen_params); std::vector Se = extract_intrinsic_input_vector( - Se_value, input_length, variables, memory, assignment, gen_flag); + Se_value, input_length, variables, memory, assignment, comp_gen_params); using component_type = components::permutation_verifier< @@ -97,7 +97,7 @@ namespace nil { }; return get_component_result - (bp, assignment, start_row, target_prover_idx, instance_input, gen_flag, input_length); + (bp, assignment, start_row, target_prover_idx, instance_input, comp_gen_params, input_length); } @@ -111,7 +111,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, generate_flag gen_flag) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { llvm::Value *f_value = inst->getOperand(0); llvm::Value *Se_value = inst->getOperand(1); @@ -133,9 +133,9 @@ namespace nil { typename component_type::result_type res = detail::handle_native_permutation_arg_verifier_component( f_value, Se_value, Ssigma_value, input_length_value, L0_value, V_value, V_zeta_value, q_last_value, q_pad_value, thetas_value, - frame.vectors, frame.scalars, memory, bp, assignment, start_row, target_prover_idx, gen_flag); + frame.vectors, frame.scalars, memory, bp, assignment, start_row, target_prover_idx, comp_gen_params); - handle_component_result(assignment, inst, frame, res, gen_flag); + handle_component_result(assignment, inst, frame, res, comp_gen_params); } } // namespace blueprint From 92bbe76ea3b6bb12234ba28c05368259d36b3f82 Mon Sep 17 00:00:00 2001 From: Aleksandr Cherenkov Date: Fri, 2 Feb 2024 15:12:25 +0000 Subject: [PATCH 2/2] pass comp_gen_params by reference, not by value --- include/nil/blueprint/boolean/logic_ops.hpp | 2 +- include/nil/blueprint/comparison/comparison.hpp | 2 +- include/nil/blueprint/curves/addition.hpp | 6 +++--- include/nil/blueprint/curves/multiplication.hpp | 6 +++--- include/nil/blueprint/curves/subtraction.hpp | 2 +- .../nil/blueprint/extract_constructor_parameters.hpp | 2 +- include/nil/blueprint/fields/addition.hpp | 6 +++--- include/nil/blueprint/fields/division.hpp | 4 ++-- include/nil/blueprint/fields/multiplication.hpp | 6 +++--- include/nil/blueprint/fields/subtraction.hpp | 6 +++--- include/nil/blueprint/handle_component.hpp | 12 ++++++------ include/nil/blueprint/hashes/sha2_256.hpp | 2 +- include/nil/blueprint/hashes/sha2_512.hpp | 2 +- include/nil/blueprint/integers/addition.hpp | 2 +- .../nil/blueprint/integers/bit_de_composition.hpp | 8 ++++---- include/nil/blueprint/integers/bit_shift.hpp | 4 ++-- include/nil/blueprint/integers/division.hpp | 2 +- .../nil/blueprint/integers/division_remainder.hpp | 4 ++-- include/nil/blueprint/integers/multiplication.hpp | 2 +- include/nil/blueprint/integers/subtraction.hpp | 2 +- .../blueprint/recursive_prover/fri_array_swap.hpp | 2 +- .../nil/blueprint/recursive_prover/fri_cosets.hpp | 4 ++-- .../nil/blueprint/recursive_prover/fri_lin_inter.hpp | 2 +- .../blueprint/recursive_prover/gate_arg_verifier.hpp | 4 ++-- .../recursive_prover/lookup_arg_verifier.hpp | 2 +- .../recursive_prover/permutation_arg_verifier.hpp | 4 ++-- 26 files changed, 50 insertions(+), 50 deletions(-) diff --git a/include/nil/blueprint/boolean/logic_ops.hpp b/include/nil/blueprint/boolean/logic_ops.hpp index 7b607c7f..3a0ae624 100644 --- a/include/nil/blueprint/boolean/logic_ops.hpp +++ b/include/nil/blueprint/boolean/logic_ops.hpp @@ -42,7 +42,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using arithmetization_type = crypto3::zk::snark::plonk_constraint_system; using component_type = components::logic_and; diff --git a/include/nil/blueprint/comparison/comparison.hpp b/include/nil/blueprint/comparison/comparison.hpp index d702bb8d..0c1fa3d0 100644 --- a/include/nil/blueprint/comparison/comparison.hpp +++ b/include/nil/blueprint/comparison/comparison.hpp @@ -44,7 +44,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using eq_component_type = components::equality_flag< crypto3::zk::snark::plonk_constraint_system, BlueprintFieldType>; diff --git a/include/nil/blueprint/curves/addition.hpp b/include/nil/blueprint/curves/addition.hpp index 68a7f094..603fb8f0 100644 --- a/include/nil/blueprint/curves/addition.hpp +++ b/include/nil/blueprint/curves/addition.hpp @@ -52,7 +52,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; @@ -85,7 +85,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; @@ -138,7 +138,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using non_native_policy_type = basic_non_native_policy; diff --git a/include/nil/blueprint/curves/multiplication.hpp b/include/nil/blueprint/curves/multiplication.hpp index 4fde213e..d65fa49e 100644 --- a/include/nil/blueprint/curves/multiplication.hpp +++ b/include/nil/blueprint/curves/multiplication.hpp @@ -52,7 +52,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; @@ -88,7 +88,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; @@ -132,7 +132,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using non_native_policy_type = basic_non_native_policy; diff --git a/include/nil/blueprint/curves/subtraction.hpp b/include/nil/blueprint/curves/subtraction.hpp index 4f576415..433943cd 100644 --- a/include/nil/blueprint/curves/subtraction.hpp +++ b/include/nil/blueprint/curves/subtraction.hpp @@ -56,7 +56,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using non_native_policy_type = basic_non_native_policy; diff --git a/include/nil/blueprint/extract_constructor_parameters.hpp b/include/nil/blueprint/extract_constructor_parameters.hpp index 6f871d22..498064f6 100644 --- a/include/nil/blueprint/extract_constructor_parameters.hpp +++ b/include/nil/blueprint/extract_constructor_parameters.hpp @@ -77,7 +77,7 @@ namespace nil { typename std::map> &variables, program_memory> &memory, assignment_proxy> - &assignment, component_creation_parameters_struct comp_gen_params + &assignment, component_creation_parameters_struct& comp_gen_params ) { std::vector res = {}; if (std::uint8_t(comp_gen_params.genFlag & generate_flag::ASSIGNMENTS)) { diff --git a/include/nil/blueprint/fields/addition.hpp b/include/nil/blueprint/fields/addition.hpp index e9f9d6a1..062a5356 100644 --- a/include/nil/blueprint/fields/addition.hpp +++ b/include/nil/blueprint/fields/addition.hpp @@ -52,7 +52,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; @@ -78,7 +78,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; using non_native_policy_type = basic_non_native_policy; @@ -114,7 +114,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using non_native_policy_type = basic_non_native_policy; using native_component_type = components::addition< diff --git a/include/nil/blueprint/fields/division.hpp b/include/nil/blueprint/fields/division.hpp index 3b7d2da5..6bf92340 100644 --- a/include/nil/blueprint/fields/division.hpp +++ b/include/nil/blueprint/fields/division.hpp @@ -52,7 +52,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; @@ -77,7 +77,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using non_native_policy_type = basic_non_native_policy; using component_type = components::division< diff --git a/include/nil/blueprint/fields/multiplication.hpp b/include/nil/blueprint/fields/multiplication.hpp index c4f39b44..73cf9c02 100644 --- a/include/nil/blueprint/fields/multiplication.hpp +++ b/include/nil/blueprint/fields/multiplication.hpp @@ -52,7 +52,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; @@ -78,7 +78,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; using non_native_policy_type = basic_non_native_policy; @@ -114,7 +114,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using non_native_policy_type = basic_non_native_policy; using native_component_type = components::multiplication< diff --git a/include/nil/blueprint/fields/subtraction.hpp b/include/nil/blueprint/fields/subtraction.hpp index aa4b6dff..34ded46e 100644 --- a/include/nil/blueprint/fields/subtraction.hpp +++ b/include/nil/blueprint/fields/subtraction.hpp @@ -52,7 +52,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; @@ -78,7 +78,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; using non_native_policy_type = basic_non_native_policy; @@ -114,7 +114,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using non_native_policy_type = basic_non_native_policy; using native_component_type = components::subtraction< diff --git a/include/nil/blueprint/handle_component.hpp b/include/nil/blueprint/handle_component.hpp index b61f8d43..1270d472 100644 --- a/include/nil/blueprint/handle_component.hpp +++ b/include/nil/blueprint/handle_component.hpp @@ -72,7 +72,7 @@ namespace nil { void handle_component_input( assignment_proxy> &assignment, - typename ComponentType::input_type& instance_input, component_creation_parameters_struct comp_gen_params) { + typename ComponentType::input_type& instance_input, component_creation_parameters_struct& comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; @@ -105,7 +105,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params, + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params, typename components::logic_and< crypto3::zk::snark::plonk_constraint_system>::input_type& instance_input) { @@ -208,7 +208,7 @@ namespace nil { &assignment, std::uint32_t start_row, std::uint32_t target_prover_idx, typename ComponentType::input_type& instance_input, - component_creation_parameters_struct comp_gen_params, + component_creation_parameters_struct& comp_gen_params, Args... args) { const auto p = detail::PolicyManager::get_parameters(detail::ManifestReader::get_witness(0, args...)); @@ -282,7 +282,7 @@ namespace nil { &assignment, const llvm::Instruction *inst, stack_frame> &frame, - const typename ComponentType::result_type& component_result, component_creation_parameters_struct comp_gen_params) { + const typename ComponentType::result_type& component_result, component_creation_parameters_struct& comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; @@ -313,7 +313,7 @@ namespace nil { const llvm::Instruction *inst, stack_frame> &frame, const std::vector>& result, - component_creation_parameters_struct comp_gen_params) { + component_creation_parameters_struct& comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; @@ -339,7 +339,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params, + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params, typename ComponentType::input_type& instance_input, const llvm::Instruction *inst, stack_frame> &frame, diff --git a/include/nil/blueprint/hashes/sha2_256.hpp b/include/nil/blueprint/hashes/sha2_256.hpp index cdadd2ef..a45c281a 100644 --- a/include/nil/blueprint/hashes/sha2_256.hpp +++ b/include/nil/blueprint/hashes/sha2_256.hpp @@ -47,7 +47,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; using component_type = components::sha256< diff --git a/include/nil/blueprint/hashes/sha2_512.hpp b/include/nil/blueprint/hashes/sha2_512.hpp index 5a518504..95bc2324 100644 --- a/include/nil/blueprint/hashes/sha2_512.hpp +++ b/include/nil/blueprint/hashes/sha2_512.hpp @@ -47,7 +47,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; using sha2_512_component_type = components::sha512< diff --git a/include/nil/blueprint/integers/addition.hpp b/include/nil/blueprint/integers/addition.hpp index 6fbccd65..3a87bda4 100644 --- a/include/nil/blueprint/integers/addition.hpp +++ b/include/nil/blueprint/integers/addition.hpp @@ -48,7 +48,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using non_native_policy_type = basic_non_native_policy; diff --git a/include/nil/blueprint/integers/bit_de_composition.hpp b/include/nil/blueprint/integers/bit_de_composition.hpp index eec66407..db990c63 100644 --- a/include/nil/blueprint/integers/bit_de_composition.hpp +++ b/include/nil/blueprint/integers/bit_de_composition.hpp @@ -50,7 +50,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; var component_input = variables[input]; @@ -88,7 +88,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; @@ -118,7 +118,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { llvm::Value *result_value = inst->getOperand(0); llvm::Value *bitness_value = inst->getOperand(1); @@ -145,7 +145,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using non_native_policy_type = basic_non_native_policy; using component_type = nil::blueprint::components::bit_composition< diff --git a/include/nil/blueprint/integers/bit_shift.hpp b/include/nil/blueprint/integers/bit_shift.hpp index 56e15b93..8b39dc1e 100644 --- a/include/nil/blueprint/integers/bit_shift.hpp +++ b/include/nil/blueprint/integers/bit_shift.hpp @@ -47,7 +47,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params, + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params, typename nil::blueprint::components::bit_shift_mode left_or_right) { using var = crypto3::zk::snark::plonk_variable; @@ -78,7 +78,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params, + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params, typename nil::blueprint::components::bit_shift_mode left_or_right) { using component_type = nil::blueprint::components::bit_shift_constant< diff --git a/include/nil/blueprint/integers/division.hpp b/include/nil/blueprint/integers/division.hpp index eaa7d02b..11765f05 100644 --- a/include/nil/blueprint/integers/division.hpp +++ b/include/nil/blueprint/integers/division.hpp @@ -49,7 +49,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using non_native_policy_type = basic_non_native_policy; diff --git a/include/nil/blueprint/integers/division_remainder.hpp b/include/nil/blueprint/integers/division_remainder.hpp index 88960a97..608da34d 100644 --- a/include/nil/blueprint/integers/division_remainder.hpp +++ b/include/nil/blueprint/integers/division_remainder.hpp @@ -48,7 +48,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; using component_type = components::division_remainder< @@ -72,7 +72,7 @@ namespace nil { &assignment, std::uint32_t start_row, std::uint32_t target_prover_idx, - component_creation_parameters_struct comp_gen_params, + component_creation_parameters_struct& comp_gen_params, bool is_division) { using non_native_policy_type = basic_non_native_policy; diff --git a/include/nil/blueprint/integers/multiplication.hpp b/include/nil/blueprint/integers/multiplication.hpp index d294f70a..b4ebf487 100644 --- a/include/nil/blueprint/integers/multiplication.hpp +++ b/include/nil/blueprint/integers/multiplication.hpp @@ -49,7 +49,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using non_native_policy_type = basic_non_native_policy; using component_type = components::multiplication< diff --git a/include/nil/blueprint/integers/subtraction.hpp b/include/nil/blueprint/integers/subtraction.hpp index be511742..8d741801 100644 --- a/include/nil/blueprint/integers/subtraction.hpp +++ b/include/nil/blueprint/integers/subtraction.hpp @@ -49,7 +49,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using non_native_policy_type = basic_non_native_policy; using component_type = components::subtraction< diff --git a/include/nil/blueprint/recursive_prover/fri_array_swap.hpp b/include/nil/blueprint/recursive_prover/fri_array_swap.hpp index 4f574d0b..c1e635bf 100644 --- a/include/nil/blueprint/recursive_prover/fri_array_swap.hpp +++ b/include/nil/blueprint/recursive_prover/fri_array_swap.hpp @@ -45,7 +45,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { llvm::Value *result_value = inst->getOperand(0); llvm::Value *array_size_value = inst->getOperand(1); diff --git a/include/nil/blueprint/recursive_prover/fri_cosets.hpp b/include/nil/blueprint/recursive_prover/fri_cosets.hpp index 375332a8..91917c11 100644 --- a/include/nil/blueprint/recursive_prover/fri_cosets.hpp +++ b/include/nil/blueprint/recursive_prover/fri_cosets.hpp @@ -51,7 +51,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; var component_input = variables[input]; @@ -88,7 +88,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { llvm::Value *result_value = inst->getOperand(0); llvm::Value *result_length_value = inst->getOperand(1); diff --git a/include/nil/blueprint/recursive_prover/fri_lin_inter.hpp b/include/nil/blueprint/recursive_prover/fri_lin_inter.hpp index ef4873d1..b572962a 100644 --- a/include/nil/blueprint/recursive_prover/fri_lin_inter.hpp +++ b/include/nil/blueprint/recursive_prover/fri_lin_inter.hpp @@ -45,7 +45,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; diff --git a/include/nil/blueprint/recursive_prover/gate_arg_verifier.hpp b/include/nil/blueprint/recursive_prover/gate_arg_verifier.hpp index 162f6079..a7bb27e7 100644 --- a/include/nil/blueprint/recursive_prover/gate_arg_verifier.hpp +++ b/include/nil/blueprint/recursive_prover/gate_arg_verifier.hpp @@ -53,7 +53,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; var theta = variables[theta_value]; @@ -109,7 +109,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { llvm::Value *selectors_value = inst->getOperand(0); llvm::Value *gates_sizes_value = inst->getOperand(1); diff --git a/include/nil/blueprint/recursive_prover/lookup_arg_verifier.hpp b/include/nil/blueprint/recursive_prover/lookup_arg_verifier.hpp index 5a2738c0..b0aa12e5 100644 --- a/include/nil/blueprint/recursive_prover/lookup_arg_verifier.hpp +++ b/include/nil/blueprint/recursive_prover/lookup_arg_verifier.hpp @@ -45,7 +45,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; diff --git a/include/nil/blueprint/recursive_prover/permutation_arg_verifier.hpp b/include/nil/blueprint/recursive_prover/permutation_arg_verifier.hpp index 2e55c49f..c811befb 100644 --- a/include/nil/blueprint/recursive_prover/permutation_arg_verifier.hpp +++ b/include/nil/blueprint/recursive_prover/permutation_arg_verifier.hpp @@ -58,7 +58,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { using var = crypto3::zk::snark::plonk_variable; var L0 = variables[L0_value]; @@ -111,7 +111,7 @@ namespace nil { circuit_proxy> &bp, assignment_proxy> &assignment, - std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct comp_gen_params) { + std::uint32_t start_row, std::uint32_t target_prover_idx, component_creation_parameters_struct& comp_gen_params) { llvm::Value *f_value = inst->getOperand(0); llvm::Value *Se_value = inst->getOperand(1);