From 0800c9dfbc5c8b00d45130c317849413b603906d Mon Sep 17 00:00:00 2001 From: Alexander Evgin Date: Thu, 15 Feb 2024 21:00:46 +0000 Subject: [PATCH] Refactor generation mode class This is done to avoid ugly constructions when checking generation mode. --- include/nil/blueprint/assigner.hpp | 84 ++++++----- .../extract_constructor_parameters.hpp | 2 +- include/nil/blueprint/handle_component.hpp | 134 +++++++++++++++--- .../blueprint/integers/bit_de_composition.hpp | 2 +- .../recursive_prover/fri_array_swap.hpp | 2 +- .../blueprint/recursive_prover/fri_cosets.hpp | 2 +- 6 files changed, 158 insertions(+), 68 deletions(-) diff --git a/include/nil/blueprint/assigner.hpp b/include/nil/blueprint/assigner.hpp index 6e88be09..d4ca083f 100644 --- a/include/nil/blueprint/assigner.hpp +++ b/include/nil/blueprint/assigner.hpp @@ -268,7 +268,7 @@ namespace nil { } void handle_ptr_cmp(const llvm::ICmpInst *inst, stack_frame &frame) { - if (std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS)) { + if (gen_mode.has_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)); @@ -419,7 +419,7 @@ namespace nil { switch (id) { case llvm::Intrinsic::assigner_malloc: { - if (std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS)) { + if (gen_mode.has_assignments()) { size_t bytes = resolve_number(frame, inst->getOperand(0)); frame.scalars[inst] = put_into_assignment(memory.malloc(bytes)); } else { @@ -533,13 +533,13 @@ namespace nil { 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(gen_mode & generation_mode::ASSIGNMENTS)) { + if (gen_mode.has_assignments()) { std::cout << var_value(assignments[currProverIdx], frame.scalars[input]).data << std::endl; } return true; } case llvm::Intrinsic::memcpy: { - if (std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS)) { + if (gen_mode.has_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); @@ -549,7 +549,7 @@ namespace nil { return true; } case llvm::Intrinsic::memset: { - if (std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS)) { + if (gen_mode.has_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()); @@ -600,7 +600,7 @@ namespace nil { llvm::CmpInst::ICMP_EQ, logical_statement, zero_var, bitness, circuits[currProverIdx], assignments[currProverIdx], statistics, param).output; - if (validity_check && std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS)) { + if (validity_check && gen_mode.has_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"); @@ -688,7 +688,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(gen_mode & generation_mode::ASSIGNMENTS)) { + if (gen_mode.has_assignments()) { auto &cell = memory[ptr]; frame.scalars[dest] = put_into_assignment(var_value(assignments[currProverIdx], cell.v)); } else { @@ -696,7 +696,7 @@ namespace nil { } } else { std::vector res; - if (std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS)) { + if (gen_mode.has_assignments()) { for (size_t i = 0; i < num_cells; ++i) { res.push_back(put_into_assignment(var_value(assignments[currProverIdx], memory[ptr + i].v))); } @@ -784,7 +784,7 @@ namespace nil { } void handle_ptrtoint(const llvm::Value *inst, llvm::Value *operand, stack_frame &frame) { - if (std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS)) { + if (gen_mode.has_assignments()) { ptr_type ptr = resolve_number(frame, operand); size_t offset = memory.ptrtoint(ptr); log.debug(boost::format("PtrToInt %1% %2%") % ptr % offset); @@ -879,7 +879,7 @@ namespace nil { handle_ptrtoint(expr, expr->getOperand(0), frame); break; case llvm::Instruction::GetElementPtr: { - if (std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS)) { + if (gen_mode.has_assignments()) { std::vector gep_indices; for (unsigned i = 2; i < expr->getNumOperands(); ++i) { int gep_index = resolve_number(frame, expr->getOperand(i)); @@ -1188,7 +1188,7 @@ namespace nil { return inst->getNextNonDebugInstruction(); } case llvm::Instruction::Select: { - if (std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS)) { + if (gen_mode.has_assignments()) { var condition = variables[inst->getOperand(0)]; llvm::Value *true_val = inst->getOperand(1); llvm::Value *false_val = inst->getOperand(2); @@ -1204,7 +1204,7 @@ namespace nil { return inst->getNextNonDebugInstruction(); } case llvm::Instruction::And: { - if (std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS)) { + if (gen_mode.has_assignments()) { const var &lhs = variables[inst->getOperand(0)]; const var &rhs = variables[inst->getOperand(1)]; @@ -1224,7 +1224,7 @@ namespace nil { return inst->getNextNonDebugInstruction(); } case llvm::Instruction::Or: { - if (std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS)) { + if (gen_mode.has_assignments()) { const var &lhs = variables[inst->getOperand(0)]; const var &rhs = variables[inst->getOperand(1)]; @@ -1244,7 +1244,7 @@ namespace nil { return inst->getNextNonDebugInstruction(); } case llvm::Instruction::Xor: { - if (std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS)) { + if (gen_mode.has_assignments()) { const var &lhs = variables[inst->getOperand(0)]; const var &rhs = variables[inst->getOperand(1)]; @@ -1281,19 +1281,19 @@ namespace nil { UNREACHABLE("Can't to process loop"); } const auto stack_size = call_stack.size(); - if (std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS)) { + if (gen_mode.has_assignments()) { bool cond_val = (var_value(assignments[currProverIdx], cond) != 0); const AssignerState assigner_state(*this); curr_branch.push_back(branch_desc(false, stack_size)); curr_branch.push_back(branch_desc(true, stack_size)); if (!cond_val) { - gen_mode = std::uint8_t(gen_mode & (generation_mode::ASSIGNMENTS | generation_mode::FALSE_ASSIGNMENTS)) ? - (gen_mode & generation_mode::CIRCUIT) | generation_mode::FALSE_ASSIGNMENTS : - gen_mode & generation_mode::CIRCUIT; + gen_mode = (gen_mode.has_assignments() && gen_mode.has_false_assignments()) ? + (gen_mode & generation_mode::circuit()) | generation_mode::false_assignments() : + gen_mode & generation_mode::circuit(); } - log.debug(boost::format("start handle true branch: %1% %2%") % curr_branch.size() % (std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS) == 0)); + log.debug(boost::format("start handle true branch: %1% %2%") % curr_branch.size() % !gen_mode.has_assignments()); 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()); @@ -1307,12 +1307,12 @@ namespace nil { curr_branch.pop_back(); if (cond_val) { - gen_mode = std::uint8_t(gen_mode & (generation_mode::ASSIGNMENTS | generation_mode::FALSE_ASSIGNMENTS)) ? - (gen_mode & generation_mode::CIRCUIT) | generation_mode::FALSE_ASSIGNMENTS : - gen_mode & generation_mode::CIRCUIT; + gen_mode = (gen_mode.has_assignments() && gen_mode.has_false_assignments()) ? + (gen_mode & generation_mode::circuit()) | generation_mode::false_assignments() : + gen_mode & generation_mode::circuit(); } - log.debug(boost::format("start handle false branch: %1% %2%") % curr_branch.size() % (std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS) == 0)); + log.debug(boost::format("start handle false branch: %1% %2%") % curr_branch.size() % !gen_mode.has_assignments()); 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()); @@ -1336,7 +1336,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(gen_mode & generation_mode::ASSIGNMENTS) == 0)); + log.debug(boost::format("start handle true branch: %1% %2%") % curr_branch.size() % !gen_mode.has_assignments()); 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()); @@ -1349,7 +1349,7 @@ namespace nil { restore_state(assigner_state); curr_branch.pop_back(); - log.debug(boost::format("start handle false branch: %1% %2%") % curr_branch.size() % (std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS) == 0)); + log.debug(boost::format("start handle false branch: %1% %2%") % curr_branch.size() % (gen_mode.has_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()); @@ -1398,7 +1398,7 @@ namespace nil { auto switch_inst = llvm::cast(inst); llvm::Value *cond = switch_inst->getCondition(); ASSERT(cond->getType()->isIntegerTy()); - if (std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS)) { + if (gen_mode.has_assignments()) { unsigned bit_width = llvm::cast(cond->getType())->getBitWidth(); ASSERT(bit_width <= 64); auto cond_var = var_value(assignments[currProverIdx], frame.scalars[cond]); @@ -1407,11 +1407,9 @@ namespace nil { (int64_t) static_cast(cond_var.data)); for (auto Case : switch_inst->cases()) { if (Case.getCaseValue()->getValue().eq(cond_val)) { - gen_mode = - std::uint8_t(gen_mode & - (generation_mode::ASSIGNMENTS | generation_mode::FALSE_ASSIGNMENTS)) ? - (gen_mode & generation_mode::CIRCUIT) | generation_mode::FALSE_ASSIGNMENTS : - gen_mode & generation_mode::CIRCUIT; + gen_mode = (gen_mode.has_assignments() && gen_mode.has_false_assignments()) ? + (gen_mode & generation_mode::circuit()) | generation_mode::false_assignments() : + gen_mode & generation_mode::circuit(); } const AssignerState assigner_state(*this); curr_branch.push_back(branch_desc(false, call_stack.size())); @@ -1449,7 +1447,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(gen_mode & generation_mode::ASSIGNMENTS)) { + if (gen_mode.has_assignments()) { int index = resolve_number(frame, index_value); variables[inst] = frame.vectors[vec][index]; } else { @@ -1472,7 +1470,7 @@ namespace nil { } case llvm::Instruction::GetElementPtr: { auto *gep = llvm::cast(inst); - if (std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS)) { + if (gen_mode.has_assignments()) { std::vector gep_indices; for (unsigned i = 1; i < gep->getNumIndices(); ++i) { int gep_index = resolve_number(frame, gep->getOperand(i + 1)); @@ -1497,7 +1495,7 @@ namespace nil { case llvm::Instruction::Load: { auto *load_inst = llvm::cast(inst); ptr_type ptr = 0; - if (std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS)) { + if (gen_mode.has_assignments()) { ptr = resolve_number(frame, load_inst->getPointerOperand()); } log.debug(boost::format("Load: %1%") % ptr); @@ -1505,7 +1503,7 @@ namespace nil { return inst->getNextNonDebugInstruction(); } case llvm::Instruction::Store: { - if (std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS)) { + if (gen_mode.has_assignments()) { auto *store_inst = llvm::cast(inst); ptr_type ptr = resolve_number(frame, store_inst->getPointerOperand()); log.debug(boost::format("Store: %1%") % ptr); @@ -1518,7 +1516,7 @@ namespace nil { } case llvm::Instruction::InsertValue: { auto *insert_inst = llvm::cast(inst); - if (std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS)) { + if (gen_mode.has_assignments()) { ptr_type ptr = resolve_number(frame, insert_inst->getAggregateOperand()); // TODO(maksenov): handle offset properly ptr += layout_resolver @@ -1532,7 +1530,7 @@ namespace nil { } case llvm::Instruction::ExtractValue: { auto *extract_inst = llvm::cast(inst); - if (std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS)) { + if (gen_mode.has_assignments()) { ptr_type ptr = resolve_number(frame, extract_inst->getAggregateOperand()); // TODO(maksenov): handle offset properly ptr += layout_resolver @@ -1553,7 +1551,7 @@ namespace nil { return inst->getNextNonDebugInstruction(); } case llvm::Instruction::IndirectBr: { - if (std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS) == 0) { + if (!gen_mode.has_assignments()) { UNREACHABLE("IndirectBr is not supported without generating assignment table"); return inst->getNextNonDebugInstruction(); } @@ -1568,7 +1566,7 @@ namespace nil { return inst->getNextNonDebugInstruction(); } case llvm::Instruction::IntToPtr: { - if (std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS)) { + if (gen_mode.has_assignments()) { std::ostringstream oss; size_t offset = resolve_number(frame, inst->getOperand(0)); oss << var_value(assignments[currProverIdx], frame.scalars[inst->getOperand(0)]).data; @@ -1609,7 +1607,7 @@ namespace nil { if(print_output_format == hex) { std::cout << std::hex; } - if (inst->getNumOperands() != 0 && std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS)) { + if (inst->getNumOperands() != 0 && gen_mode.has_assignments()) { llvm::Value *ret_val = inst->getOperand(0); if (ret_val->getType()->isPointerTy()) { // TODO(maksenov): support printing complex results @@ -1682,7 +1680,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(gen_mode & generation_mode::ASSIGNMENTS)) { + if (gen_mode.has_assignments()) { ptr_type ret_ptr = resolve_number(extracted_frame, ret_val); ptr_type allocated_copy = memory.add_cells( layout_resolver->get_type_layout(ret_type)); @@ -1756,7 +1754,7 @@ namespace nil { auto &function = *entry_point_it; auto input_reader = InputReader>( - base_frame, memory, assignments[currProverIdx], *layout_resolver, (std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS) != 0)); + base_frame, memory, assignments[currProverIdx], *layout_resolver, gen_mode.has_assignments()); 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(); @@ -1802,7 +1800,7 @@ namespace nil { while (true) { next_inst = handle_instruction(next_inst); if (finished) { - if (std::uint8_t(gen_mode & generation_mode::SIZE_ESTIMATION)) { + if (gen_mode.has_size_estimation()) { std::cout << "\nallocated_rows: " << assignments[currProverIdx].allocated_rows() << "\n"; statistics.print(); } diff --git a/include/nil/blueprint/extract_constructor_parameters.hpp b/include/nil/blueprint/extract_constructor_parameters.hpp index ac486098..ba3941ae 100644 --- a/include/nil/blueprint/extract_constructor_parameters.hpp +++ b/include/nil/blueprint/extract_constructor_parameters.hpp @@ -80,7 +80,7 @@ namespace nil { &assignment, generation_mode gen_mode ) { std::vector res = {}; - if (std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS)) { + if (gen_mode.has_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/handle_component.hpp b/include/nil/blueprint/handle_component.hpp index dc9dc139..65349a2d 100644 --- a/include/nil/blueprint/handle_component.hpp +++ b/include/nil/blueprint/handle_component.hpp @@ -73,24 +73,116 @@ namespace nil { namespace blueprint { + /** + * @brief Assigner generation mode, defining which output types will be produced. + * + * A number of flags may be set: + * + * - CIRCUIT - generate circuit; + * - ASSIGNMENTS - generate assignment table; + * - FALSE_ASSIGNMENTS; + * - SIZE_ESTIMATION - print circuit stats (generate nothing). + * + * Binary AND and OR can be applied to modes: + * `mode_a | mode_b`, `mode_a & mode_b`. + **/ + class generation_mode { + private: + enum modes : uint8_t { + NONE = 0, + CIRCUIT = 1 << 0, + ASSIGNMENTS = 1 << 1, + FALSE_ASSIGNMENTS = 1 << 2, + SIZE_ESTIMATION = 1 << 3 + }; - enum class generation_mode : uint8_t { - NONE = 0, - CIRCUIT = 1 << 0, - ASSIGNMENTS = 1 << 1, - FALSE_ASSIGNMENTS = 1 << 2, - SIZE_ESTIMATION = 1 << 3 - }; + public: + constexpr generation_mode() : mode_(NONE) { + } - constexpr enum generation_mode operator |( const enum generation_mode self, const enum generation_mode val ) - { - return (enum generation_mode)(uint8_t(self) | uint8_t(val)); - } + constexpr generation_mode(uint8_t mode) : mode_(mode) { + } - constexpr enum generation_mode operator &( const enum generation_mode self, const enum generation_mode val ) - { - return (enum generation_mode)(uint8_t(self) & uint8_t(val)); - } + constexpr generation_mode(const generation_mode& other) : mode_(other.mode_) { + } + + /// @brief "Do nothing" mode. + constexpr static generation_mode none() { + return generation_mode(NONE); + } + + /// @brief Generate circuit. + constexpr static generation_mode circuit() { + return generation_mode(CIRCUIT); + } + + /// @brief Generate assignment table. + constexpr static generation_mode assignments() { + return generation_mode(ASSIGNMENTS); + } + + constexpr static generation_mode false_assignments() { + return generation_mode(FALSE_ASSIGNMENTS); + } + + /// @brief Print circuit statistics (generate nothing). + constexpr static generation_mode size_estimation() { + return generation_mode(SIZE_ESTIMATION); + } + + constexpr bool operator==(generation_mode other) const { + return mode_ == other.mode_; + } + + constexpr bool operator!=(generation_mode other) const { + return mode_ != other.mode_; + } + + constexpr generation_mode operator|(const generation_mode other) const { + return generation_mode(mode_ | other.mode_); + } + + constexpr generation_mode operator&(const generation_mode other) const { + return generation_mode(mode_ & other.mode_); + } + + generation_mode& operator=(const generation_mode& other) { + mode_ = other.mode_; + return *this; + } + + generation_mode& operator|=(const generation_mode& other) { + mode_ |= other.mode_; + return *this; + } + + generation_mode& operator&=(const generation_mode& other) { + mode_ &= other.mode_; + return *this; + } + + /// @brief Whether generate circuit or not in this mode. + constexpr bool has_circuit() const { + return mode_ & CIRCUIT; + } + + /// @brief Whether generate assignment table or not in this mode. + constexpr bool has_assignments() const { + return mode_ & ASSIGNMENTS; + } + + constexpr bool has_false_assignments() const { + return mode_ & FALSE_ASSIGNMENTS; + } + + /// @brief Whether print circuit statistics or not in this mode. + constexpr bool has_size_estimation() const { + return mode_ & SIZE_ESTIMATION; + } + + private: + uint8_t mode_; + }; struct common_component_parameters { std::uint32_t start_row; @@ -113,7 +205,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_mode & generation_mode::ASSIGNMENTS)) { + if (gen_mode.has_assignments()) { new_v = save_shared_var(assignment, v); } else { const auto& shared_idx = assignment.shared_column_size(0); @@ -212,7 +304,7 @@ namespace nil { BOOST_LOG_TRIVIAL(debug) << "Using component \"" << component_instance.component_name << "\""; - if (std::uint8_t(param.gen_mode & generation_mode::SIZE_ESTIMATION)) { + if (param.gen_mode.has_size_estimation()) { statistics.add_record( component_instance.component_name, component_instance.rows_amount, @@ -230,11 +322,11 @@ namespace nil { // generate circuit in any case for fill selectors generate_circuit(component_instance, bp, assignment, instance_input, param.start_row); - if (std::uint8_t(param.gen_mode & generation_mode::ASSIGNMENTS)) { + if (param.gen_mode.has_assignments()) { return generate_assignments(component_instance, assignment, instance_input, param.start_row, param.target_prover_idx); } else { - if (std::uint8_t(param.gen_mode & generation_mode::FALSE_ASSIGNMENTS)) { + if (param.gen_mode.has_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++) { @@ -295,7 +387,7 @@ namespace nil { std::vector output = component_result.all_vars(); //touch result variables - if (std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS) == 0) { + if (!gen_mode.has_assignments()) { const auto result_vars = component_result.all_vars(); for (const auto &v : result_vars) { if (v.type == var::column_type::witness) { @@ -324,7 +416,7 @@ namespace nil { using var = crypto3::zk::snark::plonk_variable; //touch result variables - if (std::uint8_t(gen_mode & generation_mode::ASSIGNMENTS) == 0) { + if (!gen_mode.has_assignments()) { for (const auto &v : result) { if (v.type == var::column_type::witness) { assignment.witness(v.index, v.rotation) = BlueprintFieldType::value_type::zero(); diff --git a/include/nil/blueprint/integers/bit_de_composition.hpp b/include/nil/blueprint/integers/bit_de_composition.hpp index 10307e9e..50af7dd6 100644 --- a/include/nil/blueprint/integers/bit_de_composition.hpp +++ b/include/nil/blueprint/integers/bit_de_composition.hpp @@ -66,7 +66,7 @@ namespace nil { auto result = get_component_result (bp, assignment, statistics, param, instance_input, BitsAmount, Mode).output; - if (std::uint8_t(param.gen_mode & generation_mode::ASSIGNMENTS)) { + if (param.gen_mode.has_assignments()) { ptr_type result_ptr = static_cast( typename BlueprintFieldType::integral_type(var_value(assignment, variables[result_value]).data)); for (var v : result) { diff --git a/include/nil/blueprint/recursive_prover/fri_array_swap.hpp b/include/nil/blueprint/recursive_prover/fri_array_swap.hpp index 10765259..97f688d6 100644 --- a/include/nil/blueprint/recursive_prover/fri_array_swap.hpp +++ b/include/nil/blueprint/recursive_prover/fri_array_swap.hpp @@ -74,7 +74,7 @@ namespace nil { std::vector res = get_component_result (bp, assignment, statistics, param, instance_input, array_size / 2).output; - if (std::uint8_t(param.gen_mode & generation_mode::ASSIGNMENTS)) { + if (param.gen_mode.has_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 ecf65f09..a96ce732 100644 --- a/include/nil/blueprint/recursive_prover/fri_cosets.hpp +++ b/include/nil/blueprint/recursive_prover/fri_cosets.hpp @@ -67,7 +67,7 @@ namespace nil { const auto& result = get_component_result (bp, assignment, statistics, param, instance_input, res_length, omega).output; - if (std::uint8_t(param.gen_mode & generation_mode::ASSIGNMENTS)) { + if (param.gen_mode.has_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++) {