From 1ba18823823703d5ebbb01c19aa412a7d75ea770 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Tue, 28 May 2024 16:06:43 +0000 Subject: [PATCH 01/20] feat: add test that state getting opcodes are executed correctly --- .../vm/avm_trace/avm_deserialization.cpp | 2 ++ .../vm/avm_trace/avm_execution.cpp | 33 ++++++++++--------- .../vm/tests/avm_execution.test.cpp | 1 + 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp index e269ff62ff4..8b48dee8ce5 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp @@ -17,6 +17,7 @@ namespace { const std::vector three_operand_format = { OperandType::INDIRECT, OperandType::TAG, OperandType::UINT32, OperandType::UINT32, OperandType::UINT32, }; +const std::vector kernel_input_operand_format = { OperandType::INDIRECT, OperandType::UINT32 }; const std::vector getter_format = { OperandType::INDIRECT, @@ -143,6 +144,7 @@ std::vector Deserialization::parse(std::vector const& byte while (pos < length) { const uint8_t opcode_byte = bytecode.at(pos); + // info("opcode_byte: ", opcode_byte); if (!Bytecode::is_valid(opcode_byte)) { throw_or_abort("Invalid opcode byte: " + to_hex(opcode_byte) + " at position: " + std::to_string(pos)); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp index 733f118beb2..27c6b465c5d 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp @@ -63,6 +63,22 @@ std::tuple Execution::prove(std::vector Execution::gen_trace(std::vector const& instructions, + std::vector const& calldata, + std::vector const& public_inputs) +{ + std::vector returndata{}; + return gen_trace(instructions, returndata, calldata, public_inputs); +} + /** * @brief Convert Public Inputs * @@ -130,22 +146,6 @@ bool Execution::verify(AvmFlavor::VerificationKey vk, HonkProof const& proof) return verifier.verify_proof(proof, public_inputs_vec); } -/** - * @brief Generate the execution trace pertaining to the supplied instructions. - * - * @param instructions A vector of the instructions to be executed. - * @param calldata expressed as a vector of finite field elements. - * @param public_inputs expressed as a vector of finite field elements. - * @return The trace as a vector of Row. - */ -std::vector Execution::gen_trace(std::vector const& instructions, - std::vector const& calldata, - std::vector const& public_inputs) -{ - std::vector returndata{}; - return gen_trace(instructions, returndata, calldata, public_inputs); -} - /** * @brief Generate the execution trace pertaining to the supplied instructions. * @@ -173,6 +173,7 @@ std::vector Execution::gen_trace(std::vector const& instructio std::vector const& calldata, std::vector const& public_inputs_vec) +// TODO: add the entire kernel inputs to this - all of the public inputs for the prover - will the simulator know these? { // TODO(https://github.com/AztecProtocol/aztec-packages/issues/6718): construction of the public input columns // should be done in the kernel - this is stubbed and underconstrained diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp index 2c594094f64..5ff37d653d9 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp @@ -1000,6 +1000,7 @@ TEST_F(AvmExecutionTests, sha256Opcode) validate_trace(std::move(trace)); } + // Positive test with POSEIDON2_PERM. TEST_F(AvmExecutionTests, poseidon2PermutationOpCode) { From f955016485c710837fbb6ccc3b96f0b5b9ad7beb Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Tue, 28 May 2024 16:39:26 +0000 Subject: [PATCH 02/20] sweep --- .../src/barretenberg/vm/avm_trace/avm_deserialization.cpp | 1 - .../cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp | 1 - .../cpp/src/barretenberg/vm/tests/avm_execution.test.cpp | 8 ++++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp index 8b48dee8ce5..f89410351b2 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp @@ -144,7 +144,6 @@ std::vector Deserialization::parse(std::vector const& byte while (pos < length) { const uint8_t opcode_byte = bytecode.at(pos); - // info("opcode_byte: ", opcode_byte); if (!Bytecode::is_valid(opcode_byte)) { throw_or_abort("Invalid opcode byte: " + to_hex(opcode_byte) + " at position: " + std::to_string(pos)); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp index 27c6b465c5d..7efba7db179 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp @@ -173,7 +173,6 @@ std::vector Execution::gen_trace(std::vector const& instructio std::vector const& calldata, std::vector const& public_inputs_vec) -// TODO: add the entire kernel inputs to this - all of the public inputs for the prover - will the simulator know these? { // TODO(https://github.com/AztecProtocol/aztec-packages/issues/6718): construction of the public input columns // should be done in the kernel - this is stubbed and underconstrained diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp index 5ff37d653d9..cbf5303c1da 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp @@ -1536,14 +1536,14 @@ TEST_F(AvmExecutionTests, ExecutorThrowsWithIncorrectNumberOfPublicInputs) "00" // Indirect flag "00000007"; // addr 7 - auto bytecode = hex_to_bytes(bytecode_hex); - auto instructions = Deserialization::parse(bytecode); - std::vector calldata = {}; std::vector returndata = {}; std::vector public_inputs_vec = { 1 }; - EXPECT_THROW_WITH_MESSAGE(Execution::gen_trace(instructions, returndata, calldata, public_inputs_vec), + auto bytecode = hex_to_bytes(bytecode_hex); + auto instructions = Deserialization::parse(bytecode); + + EXPECT_THROW_WITH_MESSAGE(Execution::gen_trace(instructions, calldata, returndata, public_inputs_vec), "Public inputs vector is not of PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH"); } From 6da5d105d65fbe95de5b1c279c4eb51893c48501 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Wed, 29 May 2024 10:09:03 +0000 Subject: [PATCH 03/20] chore: add emit log execution tests --- .../vm/avm_trace/avm_deserialization.cpp | 7 ++ .../vm/avm_trace/avm_execution.cpp | 26 ++++++ .../barretenberg/vm/avm_trace/avm_helper.cpp | 64 +++++++------- .../vm/avm_trace/avm_kernel_trace.cpp | 2 + .../barretenberg/vm/avm_trace/avm_trace.cpp | 42 +++++----- .../vm/tests/avm_execution.test.cpp | 83 +++++++++++++++++++ 6 files changed, 176 insertions(+), 48 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp index f89410351b2..f6569c7720e 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp @@ -54,6 +54,11 @@ const std::unordered_map> OPCODE_WIRE_FORMAT = { OpCode::FEEPERL2GAS, getter_format }, { OpCode::FEEPERDAGAS, getter_format }, { OpCode::TRANSACTIONFEE, getter_format }, + + // TODO: ordering inline with spec + { OpCode::EMITNOTEHASH, getter_format }, // TODO: new format for these + { OpCode::EMITNULLIFIER, getter_format }, // TODO: new format for these + { OpCode::EMITUNENCRYPTEDLOG, getter_format }, // CONTRACTCALLDEPTH, -- not in simulator // Execution Environment - Globals { OpCode::CHAINID, getter_format }, @@ -153,6 +158,7 @@ std::vector Deserialization::parse(std::vector const& byte auto const opcode = static_cast(opcode_byte); std::vector inst_format; + info("opcode byte: ", opcode_byte); if (opcode == OpCode::SET) { // Small hack here because of the structure of SET (where Indirect is the first flag). // Right now pos is pointing to the indirect flag, but we want it to point to the memory tag. @@ -262,6 +268,7 @@ std::vector Deserialization::parse(std::vector const& byte } instructions.emplace_back(opcode, operands); } + info("have all instructions"); return instructions; }; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp index 7efba7db179..426d0ff076a 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp @@ -188,7 +188,9 @@ std::vector Execution::gen_trace(std::vector const& instructio // TODO: We do not yet support the indirect flag. Therefore we do not extract // inst.operands(0) (i.e. the indirect flag) when processiing the instructions. + info("opcode: ", static_cast(inst.op_code)); switch (inst.op_code) { + // Compute // Compute - Arithmetic case OpCode::ADD: @@ -338,6 +340,30 @@ std::vector Execution::gen_trace(std::vector const& instructio case OpCode::TIMESTAMP: trace_builder.op_timestamp(std::get(inst.operands.at(1))); break; + case OpCode::NOTEHASHEXISTS: + trace_builder.op_note_hash_exists(std::get(inst.operands.at(1)), + std::get(inst.operands.at(2))); + break; + case OpCode::EMITNOTEHASH: + trace_builder.op_emit_note_hash(std::get(inst.operands.at(1))); + break; + case OpCode::NULLIFIEREXISTS: + trace_builder.op_nullifier_exists(std::get(inst.operands.at(1)), + std::get(inst.operands.at(2))); + break; + case OpCode::EMITNULLIFIER: + trace_builder.op_emit_nullifier(std::get(inst.operands.at(1))); + break; + case OpCode::L1TOL2MSGEXISTS: + trace_builder.op_l1_to_l2_msg_exists(std::get(inst.operands.at(1)), + std::get(inst.operands.at(2))); + break; + case OpCode::EMITUNENCRYPTEDLOG: + trace_builder.op_emit_unencrypted_log(std::get(inst.operands.at(1))); + break; + case OpCode::SENDL2TOL1MSG: + trace_builder.op_emit_l2_to_l1_msg(std::get(inst.operands.at(1))); + break; // Machine State - Internal Control Flow case OpCode::JUMP: trace_builder.jump(std::get(inst.operands.at(0))); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp index 900ef90f7a9..207d03175e0 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp @@ -43,11 +43,11 @@ void log_avm_trace(std::vector const& trace, size_t beg, size_t end, bool e info("internal_return: ", trace.at(i).avm_main_sel_internal_return); info("internal_return_ptr:", trace.at(i).avm_main_internal_return_ptr); - info("=======ALU TRACE====================================================================="); - info("alu_clk ", trace.at(i).avm_alu_clk); - info("alu_ia ", trace.at(i).avm_alu_ia); - info("alu_ib ", trace.at(i).avm_alu_ib); - info("alu_ic ", trace.at(i).avm_alu_ic); + // info("=======ALU TRACE====================================================================="); + // info("alu_clk ", trace.at(i).avm_alu_clk); + // info("alu_ia ", trace.at(i).avm_alu_ia); + // info("alu_ib ", trace.at(i).avm_alu_ib); + // info("alu_ic ", trace.at(i).avm_alu_ic); info("=======MAIN TRACE===================================================================="); info("clk: ", trace.at(i).avm_main_clk); @@ -60,23 +60,28 @@ void log_avm_trace(std::vector const& trace, size_t beg, size_t end, bool e info("first: ", trace.at(i).avm_main_first); info("last: ", trace.at(i).avm_main_last); - info("=======MEM_OP_A======================================================================"); - info("mem_op_a: ", trace.at(i).avm_main_mem_op_a); - info("mem_idx_a: ", trace.at(i).avm_main_mem_idx_a); - info("rwa: ", trace.at(i).avm_main_rwa); - - info("=======MEM_OP_B======================================================================"); - info("mem_op_b: ", trace.at(i).avm_main_mem_op_b); - info("mem_idx_b: ", trace.at(i).avm_main_mem_idx_b); - info("rwb: ", trace.at(i).avm_main_rwb); - - info("=======MEM_OP_C======================================================================"); - info("mem_op_c: ", trace.at(i).avm_main_mem_op_c); - info("mem_idx_c: ", trace.at(i).avm_main_mem_idx_c); - info("rwc: ", trace.at(i).avm_main_rwc); - info("diff_hi: ", trace.at(i).avm_mem_diff_hi); - info("diff_mid: ", trace.at(i).avm_mem_diff_mid); - info("diff_lo: ", trace.at(i).avm_mem_diff_lo); + // info("=======MEM_OP_A======================================================================"); + // info("mem_op_a: ", trace.at(i).avm_main_mem_op_a); + // info("mem_idx_a: ", trace.at(i).avm_main_mem_idx_a); + // info("rwa: ", trace.at(i).avm_main_rwa); + + // info("=======MEM_OP_B======================================================================"); + // info("mem_op_b: ", trace.at(i).avm_main_mem_op_b); + // info("mem_idx_b: ", trace.at(i).avm_main_mem_idx_b); + // info("rwb: ", trace.at(i).avm_main_rwb); + + // info("=======MEM_OP_C======================================================================"); + // info("mem_op_c: ", trace.at(i).avm_main_mem_op_c); + // info("mem_idx_c: ", trace.at(i).avm_main_mem_idx_c); + // info("rwc: ", trace.at(i).avm_main_rwc); + // info("diff_hi: ", trace.at(i).avm_mem_diff_hi); + // info("diff_mid: ", trace.at(i).avm_mem_diff_mid); + // info("diff_lo: ", trace.at(i).avm_mem_diff_lo); + + info("=======OUT_CONSISTENCY======================================================================"); + info("note_hash_write: ", trace.at(i).avm_kernel_emit_note_hash_write_offset); + info("nullifier_write: ", trace.at(i).avm_kernel_emit_nullifier_write_offset); + info("unencrypted_write: ", trace.at(i).avm_kernel_emit_unencrypted_log_write_offset); info("=======GAS ACCOUNTING================================================================"); info("opcode active: ", trace.at(i).avm_main_gas_cost_active); @@ -87,12 +92,15 @@ void log_avm_trace(std::vector const& trace, size_t beg, size_t end, bool e if (enable_selectors) { info("=======SELECTORS======================================================================"); - info("sel_op_add: ", trace.at(i).avm_main_sel_op_add); - info("sel_op_sub: ", trace.at(i).avm_main_sel_op_sub); - info("sel_op_mul: ", trace.at(i).avm_main_sel_op_mul); - info("sel_op_eq: ", trace.at(i).avm_main_sel_op_eq); - info("sel_op_not: ", trace.at(i).avm_main_sel_op_not); - info("sel_op_sel_alu: ", trace.at(i).avm_main_alu_sel); + info("sel_op_emit_note_hash: ", trace.at(i).avm_main_sel_op_emit_note_hash); + info("sel_op_emit_nullifier: ", trace.at(i).avm_main_sel_op_emit_nullifier); + info("sel_op_emit_unencryped_log: ", trace.at(i).avm_main_sel_op_emit_unencrypted_log); + // info("sel_op_add: ", trace.at(i).avm_main_sel_op_add); + // info("sel_op_sub: ", trace.at(i).avm_main_sel_op_sub); + // info("sel_op_mul: ", trace.at(i).avm_main_sel_op_mul); + // info("sel_op_eq: ", trace.at(i).avm_main_sel_op_eq); + // info("sel_op_not: ", trace.at(i).avm_main_sel_op_not); + // info("sel_op_sel_alu: ", trace.at(i).avm_main_alu_sel); } info("\n"); } diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.cpp index a2af2684653..88b6964183b 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.cpp @@ -39,6 +39,8 @@ void AvmKernelTraceBuilder::perform_kernel_output_lookup(uint32_t write_offset, std::get(public_inputs)[write_offset] = side_effect_counter; std::get(public_inputs)[write_offset] = metadata; + info("output writing side effect counter: ", side_effect_counter); + // Lookup counts kernel_output_selector_counter[write_offset]++; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp index 94dfaa03e5e..26655bdc068 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp @@ -3621,28 +3621,30 @@ std::vector AvmTraceBuilder::finalize(uint32_t min_trace_size, bool range_c if (clk < main_trace_size) { Row& next = main_trace.at(clk + 1); - // Increment the write offset counter for the following row - if (src.op_note_hash_exists) { - next.avm_kernel_note_hash_exist_write_offset = curr.avm_kernel_note_hash_exist_write_offset + 1; - } else if (src.op_emit_note_hash) { - next.avm_kernel_emit_note_hash_write_offset = curr.avm_kernel_emit_note_hash_write_offset + 1; - } else if (src.op_emit_nullifier) { - next.avm_kernel_emit_nullifier_write_offset = curr.avm_kernel_emit_nullifier_write_offset + 1; - } else if (src.op_nullifier_exists) { - next.avm_kernel_nullifier_exists_write_offset = curr.avm_kernel_nullifier_exists_write_offset + 1; - } else if (src.op_l1_to_l2_msg_exists) { - next.avm_kernel_l1_to_l2_msg_exists_write_offset = curr.avm_kernel_l1_to_l2_msg_exists_write_offset + 1; - } else if (src.op_emit_l2_to_l1_msg) { - next.avm_kernel_emit_l2_to_l1_msg_write_offset = curr.avm_kernel_emit_l2_to_l1_msg_write_offset + 1; - } else if (src.op_emit_unencrypted_log) { - next.avm_kernel_emit_unencrypted_log_write_offset = - curr.avm_kernel_emit_unencrypted_log_write_offset + 1; - } else if (src.op_sload) { - next.avm_kernel_sload_write_offset = curr.avm_kernel_sload_write_offset + 1; - } else if (src.op_sstore) { - next.avm_kernel_sstore_write_offset = curr.avm_kernel_sstore_write_offset + 1; + if (src.op_emit_unencrypted_log) { + info("side effect counter when emiting log: ", curr.avm_kernel_side_effect_counter); } + // Increment the write offset counter for the following row + next.avm_kernel_note_hash_exist_write_offset = + curr.avm_kernel_note_hash_exist_write_offset + static_cast(src.op_note_hash_exists); + next.avm_kernel_emit_note_hash_write_offset = + curr.avm_kernel_emit_note_hash_write_offset + static_cast(src.op_emit_note_hash); + next.avm_kernel_emit_nullifier_write_offset = + curr.avm_kernel_emit_nullifier_write_offset + static_cast(src.op_emit_nullifier); + next.avm_kernel_nullifier_exists_write_offset = + curr.avm_kernel_nullifier_exists_write_offset + static_cast(src.op_nullifier_exists); + next.avm_kernel_l1_to_l2_msg_exists_write_offset = + curr.avm_kernel_l1_to_l2_msg_exists_write_offset + static_cast(src.op_l1_to_l2_msg_exists); + next.avm_kernel_emit_l2_to_l1_msg_write_offset = + curr.avm_kernel_emit_l2_to_l1_msg_write_offset + static_cast(src.op_emit_l2_to_l1_msg); + next.avm_kernel_emit_unencrypted_log_write_offset = + curr.avm_kernel_emit_unencrypted_log_write_offset + static_cast(src.op_emit_unencrypted_log); + next.avm_kernel_sload_write_offset = + curr.avm_kernel_sload_write_offset + static_cast(src.op_sload); + next.avm_kernel_sstore_write_offset = + curr.avm_kernel_sstore_write_offset + static_cast(src.op_sstore); + // The side effect counter will increment regardless of the offset value next.avm_kernel_side_effect_counter = curr.avm_kernel_side_effect_counter + 1; } diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp index cbf5303c1da..6d4cd8124fd 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp @@ -4,12 +4,16 @@ #include "barretenberg/common/utils.hpp" #include "barretenberg/vm/avm_trace/avm_common.hpp" #include "barretenberg/vm/avm_trace/avm_deserialization.hpp" +#include "barretenberg/vm/avm_trace/avm_kernel_trace.hpp" #include "barretenberg/vm/avm_trace/avm_opcode.hpp" #include "barretenberg/vm/avm_trace/aztec_constants.hpp" #include #include #include +// TODO: remove +#include "barretenberg/vm/avm_trace/avm_helper.cpp" + namespace tests_avm { using namespace bb; using namespace bb::avm_trace; @@ -1547,6 +1551,85 @@ TEST_F(AvmExecutionTests, ExecutorThrowsWithIncorrectNumberOfPublicInputs) "Public inputs vector is not of PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH"); } +TEST_F(AvmExecutionTests, kernelOutputEmitOpcodes) +{ + // Set values into the first register to emit + std::string bytecode_hex = to_hex(OpCode::SET) + // opcode Set + "00" // Indirect flag + "03" // U32 + "00000001" // value 1 + "00000001" // dst_offset 1 + // Cast set to field + + to_hex(OpCode::CAST) + // opcode CAST + "00" // Indirect flag + "06" // tag field + "00000001" // dst 1 + "00000001" // dst 1 + + to_hex(OpCode::EMITNOTEHASH) + // opcode EMITNOTEHASH + "00" // Indirect flag + "00000001" // src offset 1 + + to_hex(OpCode::EMITNULLIFIER) + // opcode EMITNOTEHASH + "00" // Indirect flag + "00000001" // src offset 1 + + to_hex(OpCode::EMITUNENCRYPTEDLOG) + // opcode EMITNOTEHASH + "00" // Indirect flag + "00000001" // src offset 1 + + to_hex(OpCode::RETURN) + // opcode RETURN + "00" // Indirect flag + "00000000" // ret offset 0 + "00000000"; // ret size 0 + + auto bytecode = hex_to_bytes(bytecode_hex); + auto instructions = Deserialization::parse(bytecode); + + // 2 instructions + ASSERT_THAT(instructions, SizeIs(6)); + + auto trace = Execution::gen_trace(instructions); + + log_avm_trace(trace, 3, 6, true); + + // CHECK EMIT NOTE HASH + // Check output data + side effect counters have been set correctly + auto emit_note_hash_row = + std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_emit_note_hash == 1; }); + EXPECT_EQ(emit_note_hash_row->avm_main_ia, 1); + EXPECT_EQ(emit_note_hash_row->avm_kernel_side_effect_counter, 0); + + // Get the row of the first note hash out + uint32_t emit_note_hash_out_offset = AvmKernelTraceBuilder::START_EMIT_NOTE_HASH_WRITE_OFFSET; + auto emit_note_hash_kernel_out_row = std::ranges::find_if( + trace.begin(), trace.end(), [&](Row r) { return r.avm_main_clk == emit_note_hash_out_offset; }); + EXPECT_EQ(emit_note_hash_kernel_out_row->avm_kernel_kernel_value_out__is_public, 1); + EXPECT_EQ(emit_note_hash_kernel_out_row->avm_kernel_kernel_side_effect_out__is_public, 0); + + // CHECK EMIT NULLIFIER + auto emit_nullifier_row = + std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_emit_nullifier == 1; }); + EXPECT_EQ(emit_nullifier_row->avm_main_ia, 1); + EXPECT_EQ(emit_nullifier_row->avm_kernel_side_effect_counter, 1); + + uint32_t emit_nullifier_out_offset = AvmKernelTraceBuilder::START_EMIT_NULLIFIER_WRITE_OFFSET; + auto emit_nullifier_kernel_out_row = std::ranges::find_if( + trace.begin(), trace.end(), [&](Row r) { return r.avm_main_clk == emit_nullifier_out_offset; }); + EXPECT_EQ(emit_nullifier_kernel_out_row->avm_kernel_kernel_value_out__is_public, 1); + EXPECT_EQ(emit_nullifier_kernel_out_row->avm_kernel_kernel_side_effect_out__is_public, 1); + + // CHECK EMIT UNENCRYPTED LOG + auto emit_log_row = std::ranges::find_if( + trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_emit_unencrypted_log == 1; }); + EXPECT_EQ(emit_log_row->avm_main_ia, 1); + EXPECT_EQ(emit_log_row->avm_kernel_side_effect_counter, 2); + + uint32_t emit_log_out_offset = AvmKernelTraceBuilder::START_EMIT_UNENCRYPTED_LOG_WRITE_OFFSET; + auto emit_log_kernel_out_row = + std::ranges::find_if(trace.begin(), trace.end(), [&](Row r) { return r.avm_main_clk == emit_log_out_offset; }); + EXPECT_EQ(emit_log_kernel_out_row->avm_kernel_kernel_value_out__is_public, 1); + EXPECT_EQ(emit_log_kernel_out_row->avm_kernel_kernel_side_effect_out__is_public, 2); + + validate_trace(std::move(trace)); +} + // Negative test detecting an invalid opcode byte. TEST_F(AvmExecutionTests, invalidOpcode) { From c813a444a2dfee9fd65311676df4f7846e2860cb Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Wed, 29 May 2024 19:12:14 +0000 Subject: [PATCH 04/20] temp --- .../barretenberg/vm/avm_trace/constants.hpp | 18 ++++++++++++++++++ .../vm/tests/avm_execution.test.cpp | 10 ++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/constants.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/constants.hpp index d3ca2ab0a92..1fd2fe0029a 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/constants.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/constants.hpp @@ -33,6 +33,24 @@ inline const uint32_t TRANSACTION_FEE_OFFSET = PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENG inline const uint32_t DA_GAS_LEFT_PCPI_OFFSET = PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH - 3 - GAS_LENGTH; inline const uint32_t L2_GAS_LEFT_PCPI_OFFSET = PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH - 2 - GAS_LENGTH; +// Kernel outputs offsets +inline const uint32_t NULLIFIER_EXISTS_OFFSET = CALL_CONTEXT_LENGTH + 2; +inline const uint32_t NULLIFIER_NON_EXISTS_OFFSET = + NULLIFIER_EXISTS_OFFSET + MAX_NULLIFIER_READ_REQUESTS_PER_CALL * READ_REQUEST_LENGTH; +inline const uint32_t PUBLIC_DATA_UPDATE_OFFSET = + NULLIFIER_NON_EXISTS_OFFSET + MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL * READ_REQUEST_LENGTH; +inline const uint32_t PUBLIC_DATA_READ_OFFSET = + PUBLIC_DATA_UPDATE_OFFSET + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL * CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH; +inline const uint32_t PUBLIC_CALLSTACK_OFFSET = + PUBLIC_DATA_READ_OFFSET + MAX_PUBLIC_DATA_READS_PER_CALL * CONTRACT_STORAGE_READ_LENGTH; +inline const uint32_t NOTE_HASHES_OFFSET = PUBLIC_CALLSTACK_OFFSET + MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL; +inline const uint32_t NULLIFIERS_OFFSET = NOTE_HASHES_OFFSET + MAX_NEW_NOTE_HASHES_PER_CALL * NOTE_HASH_LENGTH; +inline const uint32_t L2_TO_L1_MSGS_OFFSET = NULLIFIERS_OFFSET + MAX_NEW_NULLIFIERS_PER_CALL * NULLIFIER_LENGTH; + +// Two item gap +inline const uint32_t UNENCRYPTED_LOGS_OFFSET = + L2_TO_L1_MSGS_OFFSET + (MAX_NEW_L2_TO_L1_MSGS_PER_CALL * L2_TO_L1_MESSAGE_LENGTH) + 2; + // END INDEXES in the PUBLIC_CIRCUIT_PUBLIC_INPUTS // L2 and Da gas left are the 3rd last and 2nd last items in the context kernel inputs respectively diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp index 6d4cd8124fd..51f1fc3ffd2 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp @@ -1585,9 +1585,15 @@ TEST_F(AvmExecutionTests, kernelOutputEmitOpcodes) // 2 instructions ASSERT_THAT(instructions, SizeIs(6)); - auto trace = Execution::gen_trace(instructions); + std::vector calldata = {}; + std::vector reutrndata = {}; + + // Craft public inputs object - in this case all return values are known to be a fixed value 1 + std::vector public_inputs_vec(PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH); + + size_t public_inputs_emit_note_hash_offset = - log_avm_trace(trace, 3, 6, true); + auto trace = Execution::gen_trace(instructions); // CHECK EMIT NOTE HASH // Check output data + side effect counters have been set correctly From f59cb2e73b89326c68ffc8e28db3a96a55eed52e Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Thu, 30 May 2024 09:38:53 +0000 Subject: [PATCH 05/20] fix: merge --- barretenberg/cpp/pil/avm/avm_kernel.pil | 6 +++--- .../cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp | 2 ++ .../cpp/src/barretenberg/vm/tests/avm_execution.test.cpp | 7 +++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/barretenberg/cpp/pil/avm/avm_kernel.pil b/barretenberg/cpp/pil/avm/avm_kernel.pil index d5b5ef256e5..473c60c85f3 100644 --- a/barretenberg/cpp/pil/avm/avm_kernel.pil +++ b/barretenberg/cpp/pil/avm/avm_kernel.pil @@ -25,16 +25,16 @@ namespace avm_kernel(256); pol commit side_effect_counter; // FIXED INDEXES + pol START_NULLIFIER_EXISTS_OFFSET = 8; + pol START_SLOAD_WRITE_OFFSET = 28; + pol START_SSTORE_WRITE_OFFSET = 32; pol START_NOTE_HASH_EXISTS_WRITE_OFFSET = 0; pol START_EMIT_NOTE_HASH_WRITE_OFFSET = 4; - pol START_NULLIFIER_EXISTS_OFFSET = 8; pol START_EMIT_NULLIFIER_WRITE_OFFSET = 12; pol START_L1_TO_L2_MSG_EXISTS_WRITE_OFFSET = 16; pol START_EMIT_UNENCRYPTED_LOG_WRITE_OFFSET = 20; pol START_EMIT_L2_TO_l1_MSG = 24; - pol START_SLOAD_WRITE_OFFSET = 28; - pol START_SSTORE_WRITE_OFFSET = 32; // TODO(https://github.com/AztecProtocol/aztec-packages/issues/6465): Must constrain write_offset counters to be less than side effect MAX // Current write offsets for each opcode diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp index 426d0ff076a..a1e9f561027 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp @@ -176,7 +176,9 @@ std::vector Execution::gen_trace(std::vector const& instructio { // TODO(https://github.com/AztecProtocol/aztec-packages/issues/6718): construction of the public input columns // should be done in the kernel - this is stubbed and underconstrained + info("before convert public inputs"); VmPublicInputs public_inputs = convert_public_inputs(public_inputs_vec); + info("after convert public inputs"); AvmTraceBuilder trace_builder(public_inputs); // Copied version of pc maintained in trace builder. The value of pc is evolving based diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp index 51f1fc3ffd2..0185588ffb0 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp @@ -885,6 +885,7 @@ TEST_F(AvmExecutionTests, sha256CompressionOpcode) VariantWith(35))))); // Assign a vector that we will mutate internally in gen_trace to store the return values; + std::vector calldata = std::vector(); std::vector returndata = std::vector(); // Test vector output taken from noir black_box_solver // Uint32Array.from([1862536192, 526086805, 2067405084, 593147560, 726610467, 813867028, @@ -892,7 +893,6 @@ TEST_F(AvmExecutionTests, sha256CompressionOpcode) std::vector expected_output = { 1862536192, 526086805, 2067405084, 593147560, 726610467, 813867028, 4091010797ULL, 3974542186ULL }; - std::vector calldata = std::vector(); auto trace = Execution::gen_trace(instructions, returndata, calldata, public_inputs_vec); // Find the first row enabling the Sha256Compression selector @@ -1059,6 +1059,7 @@ TEST_F(AvmExecutionTests, poseidon2PermutationOpCode) // Assign a vector that we will mutate internally in gen_trace to store the return values; std::vector returndata = std::vector(); + std::vector public_inputs_vec(PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH); std::vector expected_output = { FF(std::string("0x2bf1eaf87f7d27e8dc4056e9af975985bccc89077a21891d6c7b6ccce0631f95")), FF(std::string("0x0c01fa1b8d0748becafbe452c0cb0231c38224ea824554c9362518eebdd5701f")), @@ -1591,9 +1592,7 @@ TEST_F(AvmExecutionTests, kernelOutputEmitOpcodes) // Craft public inputs object - in this case all return values are known to be a fixed value 1 std::vector public_inputs_vec(PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH); - size_t public_inputs_emit_note_hash_offset = - - auto trace = Execution::gen_trace(instructions); + auto trace = Execution::gen_trace(instructions); // CHECK EMIT NOTE HASH // Check output data + side effect counters have been set correctly From 33c9c015e6f6ea52faa20ff0949bcb7d49065cd7 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Fri, 31 May 2024 10:04:43 +0000 Subject: [PATCH 06/20] fix: align offsets with real values --- barretenberg/cpp/pil/avm/avm_kernel.pil | 31 +++++--- .../relations/generated/avm/avm_main.hpp | 16 ++-- .../vm/avm_trace/avm_kernel_trace.hpp | 29 +++++--- .../vm/avm_trace/aztec_constants.hpp | 74 +++++++++++-------- .../barretenberg/vm/avm_trace/constants.hpp | 11 ++- .../crates/types/src/constants.nr | 1 + .../circuits.js/src/scripts/constants.in.ts | 3 +- 7 files changed, 98 insertions(+), 67 deletions(-) diff --git a/barretenberg/cpp/pil/avm/avm_kernel.pil b/barretenberg/cpp/pil/avm/avm_kernel.pil index 473c60c85f3..0baf1573f46 100644 --- a/barretenberg/cpp/pil/avm/avm_kernel.pil +++ b/barretenberg/cpp/pil/avm/avm_kernel.pil @@ -25,30 +25,37 @@ namespace avm_kernel(256); pol commit side_effect_counter; // FIXED INDEXES - pol START_NULLIFIER_EXISTS_OFFSET = 8; - pol START_SLOAD_WRITE_OFFSET = 28; - pol START_SSTORE_WRITE_OFFSET = 32; + // Exists checks pol START_NOTE_HASH_EXISTS_WRITE_OFFSET = 0; - pol START_EMIT_NOTE_HASH_WRITE_OFFSET = 4; - pol START_EMIT_NULLIFIER_WRITE_OFFSET = 12; - pol START_L1_TO_L2_MSG_EXISTS_WRITE_OFFSET = 16; - pol START_EMIT_UNENCRYPTED_LOG_WRITE_OFFSET = 20; - pol START_EMIT_L2_TO_l1_MSG = 24; + pol START_NULLIFIER_EXISTS_OFFSET = 32; // START_NOTE_HASH_EXISTS_WRITE_OFFSET + MAX_NOTE_HASH_READ_REQUESTS_PER_CALL TODO: exists and non exists + pol START_L1_TO_L2_MSG_EXISTS_WRITE_OFFSET = 96; // START_NULLIFIER_EXISTS_OFFET + (MAX_NULLIFIER_READ_REQUESTS_PER_CALL + MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL) + + // Public storage requests + pol START_SLOAD_WRITE_OFFSET = 112; // START_L1_TO_L2_MSG_EXISTS_WRITE_OFFSET + MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL + pol START_SSTORE_WRITE_OFFSET = 144; // START_SSTORE_WRITE_OFFSET + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL + + // Emit data + pol START_EMIT_NOTE_HASH_WRITE_OFFSET = 160; // START_SLOAD_WRITE_OFFSET + MAX_PUBLIC_DATA_READS_PER_CALL + pol START_EMIT_NULLIFIER_WRITE_OFFSET = 176; // START_EMIT_NOTE_HASH_WRITE_OFFSET + MAX_NEW_NOTE_HASHES_PER_CALL + pol START_EMIT_L2_TO_l1_MSG = 192; // START_EMIT_NULLIFIER_WRITE_OFFSET + MAX_NEW_NULLIFIERS_PER_CALL + pol START_EMIT_UNENCRYPTED_LOG_WRITE_OFFSET = 194; // START_EMIT_L2_TO_L1_MSG + MAX_NEW_L2_TO_L1_MSGS_PER_CALL // TODO(https://github.com/AztecProtocol/aztec-packages/issues/6465): Must constrain write_offset counters to be less than side effect MAX // Current write offsets for each opcode pol commit note_hash_exist_write_offset; - pol commit emit_note_hash_write_offset; pol commit nullifier_exists_write_offset; - pol commit emit_nullifier_write_offset; pol commit l1_to_l2_msg_exists_write_offset; - pol commit emit_unencrypted_log_write_offset; - pol commit emit_l2_to_l1_msg_write_offset; pol commit sload_write_offset; pol commit sstore_write_offset; + pol commit emit_note_hash_write_offset; + pol commit emit_nullifier_write_offset; + pol commit emit_unencrypted_log_write_offset; + pol commit emit_l2_to_l1_msg_write_offset; + + pol NOT_LAST = (1 - avm_main.last); // Constraints to increase the offsets when the opcodes are found diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_main.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_main.hpp index d28c3db96dc..0744e52c63f 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_main.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_main.hpp @@ -1342,7 +1342,7 @@ template class avm_mainImpl { Avm_DECLARE_VIEWS(114); auto tmp = (avm_main_sel_op_emit_note_hash * - (avm_kernel_kernel_out_offset - (avm_kernel_emit_note_hash_write_offset + FF(4)))); + (avm_kernel_kernel_out_offset - (avm_kernel_emit_note_hash_write_offset + FF(160)))); tmp *= scaling_factor; std::get<114>(evals) += tmp; } @@ -1359,7 +1359,7 @@ template class avm_mainImpl { Avm_DECLARE_VIEWS(116); auto tmp = (avm_main_sel_op_nullifier_exists * - (avm_kernel_kernel_out_offset - (avm_kernel_nullifier_exists_write_offset + FF(8)))); + (avm_kernel_kernel_out_offset - (avm_kernel_nullifier_exists_write_offset + FF(32)))); tmp *= scaling_factor; std::get<116>(evals) += tmp; } @@ -1376,7 +1376,7 @@ template class avm_mainImpl { Avm_DECLARE_VIEWS(118); auto tmp = (avm_main_sel_op_emit_nullifier * - (avm_kernel_kernel_out_offset - (avm_kernel_emit_nullifier_write_offset + FF(12)))); + (avm_kernel_kernel_out_offset - (avm_kernel_emit_nullifier_write_offset + FF(176)))); tmp *= scaling_factor; std::get<118>(evals) += tmp; } @@ -1393,7 +1393,7 @@ template class avm_mainImpl { Avm_DECLARE_VIEWS(120); auto tmp = (avm_main_sel_op_l1_to_l2_msg_exists * - (avm_kernel_kernel_out_offset - (avm_kernel_l1_to_l2_msg_exists_write_offset + FF(16)))); + (avm_kernel_kernel_out_offset - (avm_kernel_l1_to_l2_msg_exists_write_offset + FF(96)))); tmp *= scaling_factor; std::get<120>(evals) += tmp; } @@ -1410,7 +1410,7 @@ template class avm_mainImpl { Avm_DECLARE_VIEWS(122); auto tmp = (avm_main_sel_op_emit_unencrypted_log * - (avm_kernel_kernel_out_offset - (avm_kernel_emit_unencrypted_log_write_offset + FF(20)))); + (avm_kernel_kernel_out_offset - (avm_kernel_emit_unencrypted_log_write_offset + FF(194)))); tmp *= scaling_factor; std::get<122>(evals) += tmp; } @@ -1427,7 +1427,7 @@ template class avm_mainImpl { Avm_DECLARE_VIEWS(124); auto tmp = (avm_main_sel_op_emit_l2_to_l1_msg * - (avm_kernel_kernel_out_offset - (avm_kernel_emit_l2_to_l1_msg_write_offset + FF(24)))); + (avm_kernel_kernel_out_offset - (avm_kernel_emit_l2_to_l1_msg_write_offset + FF(192)))); tmp *= scaling_factor; std::get<124>(evals) += tmp; } @@ -1444,7 +1444,7 @@ template class avm_mainImpl { Avm_DECLARE_VIEWS(126); auto tmp = - (avm_main_sel_op_sload * (avm_kernel_kernel_out_offset - (avm_kernel_sload_write_offset + FF(28)))); + (avm_main_sel_op_sload * (avm_kernel_kernel_out_offset - (avm_kernel_sload_write_offset + FF(112)))); tmp *= scaling_factor; std::get<126>(evals) += tmp; } @@ -1461,7 +1461,7 @@ template class avm_mainImpl { Avm_DECLARE_VIEWS(128); auto tmp = - (avm_main_sel_op_sstore * (avm_kernel_kernel_out_offset - (avm_kernel_sstore_write_offset + FF(32)))); + (avm_main_sel_op_sstore * (avm_kernel_kernel_out_offset - (avm_kernel_sstore_write_offset + FF(144)))); tmp *= scaling_factor; std::get<128>(evals) += tmp; } diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.hpp index a5ec7a31927..dd9d9b9dd96 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.hpp @@ -100,17 +100,26 @@ class AvmKernelTraceBuilder { void op_sload(uint32_t clk, const FF& slot, const FF& value); void op_sstore(uint32_t clk, const FF& slot, const FF& value); - // Temp: these are temporary offsets + // TODO: Move into constants.hpp? static const uint32_t START_NOTE_HASH_EXISTS_WRITE_OFFSET = 0; - static const uint32_t START_EMIT_NOTE_HASH_WRITE_OFFSET = 4; - static const uint32_t START_NULLIFIER_EXISTS_OFFSET = 8; - static const uint32_t START_EMIT_NULLIFIER_WRITE_OFFSET = 12; - static const uint32_t START_L1_TO_L2_MSG_EXISTS_WRITE_OFFSET = 16; - static const uint32_t START_EMIT_UNENCRYPTED_LOG_WRITE_OFFSET = 20; - static const uint32_t START_L2_TO_L1_MSG_WRITE_OFFSET = 24; - - static const uint32_t START_SLOAD_WRITE_OFFSET = 28; - static const uint32_t START_SSTORE_WRITE_OFFSET = 32; + static const uint32_t START_NULLIFIER_EXISTS_OFFSET = + START_NOTE_HASH_EXISTS_WRITE_OFFSET + MAX_NOTE_HASH_READ_REQUESTS_PER_CALL; + static const uint32_t START_L1_TO_L2_MSG_EXISTS_WRITE_OFFSET = + START_NULLIFIER_EXISTS_OFFSET + (2 * MAX_NULLIFIER_READ_REQUESTS_PER_CALL); + + static const uint32_t START_SLOAD_WRITE_OFFSET = + START_L1_TO_L2_MSG_EXISTS_WRITE_OFFSET + MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL; + static const uint32_t START_SSTORE_WRITE_OFFSET = + START_SLOAD_WRITE_OFFSET + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL; + + static const uint32_t START_EMIT_NOTE_HASH_WRITE_OFFSET = + START_SSTORE_WRITE_OFFSET + MAX_PUBLIC_DATA_READS_PER_CALL; + static const uint32_t START_EMIT_NULLIFIER_WRITE_OFFSET = + START_EMIT_NOTE_HASH_WRITE_OFFSET + MAX_NEW_NOTE_HASHES_PER_CALL; + static const uint32_t START_L2_TO_L1_MSG_WRITE_OFFSET = + START_EMIT_NULLIFIER_WRITE_OFFSET + MAX_NEW_NULLIFIERS_PER_CALL; + static const uint32_t START_EMIT_UNENCRYPTED_LOG_WRITE_OFFSET = + START_L2_TO_L1_MSG_WRITE_OFFSET + MAX_NEW_L2_TO_L1_MSGS_PER_CALL; private: std::vector kernel_trace; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/aztec_constants.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/aztec_constants.hpp index c6ea15ba1ea..2f2bfe59682 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/aztec_constants.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/aztec_constants.hpp @@ -1,34 +1,46 @@ // GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants in circuits.js #pragma once -#define MAX_NEW_NOTE_HASHES_PER_CALL 16 -#define MAX_NEW_NULLIFIERS_PER_CALL 16 -#define MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL 16 -#define MAX_NEW_L2_TO_L1_MSGS_PER_CALL 2 -#define MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL 32 -#define MAX_PUBLIC_DATA_READS_PER_CALL 16 -#define MAX_NOTE_HASH_READ_REQUESTS_PER_CALL 32 -#define MAX_NULLIFIER_READ_REQUESTS_PER_CALL 32 -#define MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL 32 -#define MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL 16 -#define MAX_UNENCRYPTED_LOGS_PER_CALL 4 -#define AZTEC_ADDRESS_LENGTH 1 -#define GAS_FEES_LENGTH 2 -#define GAS_LENGTH 2 -#define CALL_CONTEXT_LENGTH 6 -#define CONTENT_COMMITMENT_LENGTH 4 -#define CONTRACT_STORAGE_READ_LENGTH 2 -#define CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH 3 -#define GLOBAL_VARIABLES_LENGTH 8 -#define APPEND_ONLY_TREE_SNAPSHOT_LENGTH 2 -#define L2_TO_L1_MESSAGE_LENGTH 3 -#define PARTIAL_STATE_REFERENCE_LENGTH 6 -#define READ_REQUEST_LENGTH 2 -#define LOG_HASH_LENGTH 3 -#define NOTE_HASH_LENGTH 2 -#define NULLIFIER_LENGTH 3 -#define STATE_REFERENCE_LENGTH 8 -#define TOTAL_FEES_LENGTH 1 -#define HEADER_LENGTH 23 -#define PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH 514 -#define PUBLIC_CONTEXT_INPUTS_LENGTH 41 +const size_t MAX_NEW_NOTE_HASHES_PER_CALL = 16; +const size_t MAX_NEW_NULLIFIERS_PER_CALL = 16; +const size_t MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL = 16; +const size_t MAX_NEW_L2_TO_L1_MSGS_PER_CALL = 2; +const size_t MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL = 32; +const size_t MAX_PUBLIC_DATA_READS_PER_CALL = 16; +const size_t MAX_NOTE_HASH_READ_REQUESTS_PER_CALL = 32; +const size_t MAX_NULLIFIER_READ_REQUESTS_PER_CALL = 32; +const size_t MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL = 32; +const size_t MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL = 16; +const size_t MAX_UNENCRYPTED_LOGS_PER_CALL = 4; +const size_t AZTEC_ADDRESS_LENGTH = 1; +const size_t GAS_FEES_LENGTH = 2; +const size_t GAS_LENGTH = 2; +const size_t CALL_CONTEXT_LENGTH = 6; +const size_t CONTENT_COMMITMENT_LENGTH = 4; +const size_t CONTRACT_STORAGE_READ_LENGTH = 2; +const size_t CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH = 3; +const size_t GLOBAL_VARIABLES_LENGTH = 6 + GAS_FEES_LENGTH; +const size_t APPEND_ONLY_TREE_SNAPSHOT_LENGTH = 2; +const size_t L2_TO_L1_MESSAGE_LENGTH = 3; +const size_t PARTIAL_STATE_REFERENCE_LENGTH = 6; +const size_t READ_REQUEST_LENGTH = 2; +const size_t LOG_HASH_LENGTH = 3; +const size_t NOTE_HASH_LENGTH = 2; +const size_t NULLIFIER_LENGTH = 3; +const size_t STATE_REFERENCE_LENGTH = APPEND_ONLY_TREE_SNAPSHOT_LENGTH + PARTIAL_STATE_REFERENCE_LENGTH; +const size_t TOTAL_FEES_LENGTH = 1; +const size_t HEADER_LENGTH = APPEND_ONLY_TREE_SNAPSHOT_LENGTH + CONTENT_COMMITMENT_LENGTH + STATE_REFERENCE_LENGTH + + GLOBAL_VARIABLES_LENGTH + TOTAL_FEES_LENGTH; +const size_t PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH = + CALL_CONTEXT_LENGTH + /*argsHash + returnsHash*/ 2 + (READ_REQUEST_LENGTH * MAX_NOTE_HASH_READ_REQUESTS_PER_CALL) + + (READ_REQUEST_LENGTH * MAX_NULLIFIER_READ_REQUESTS_PER_CALL) + + (READ_REQUEST_LENGTH * MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL) + + (READ_REQUEST_LENGTH * MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL) + + (CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH * MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL) + + (CONTRACT_STORAGE_READ_LENGTH * MAX_PUBLIC_DATA_READS_PER_CALL) + MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL + + (NOTE_HASH_LENGTH * MAX_NEW_NOTE_HASHES_PER_CALL) + (NULLIFIER_LENGTH * MAX_NEW_NULLIFIERS_PER_CALL) + + (L2_TO_L1_MESSAGE_LENGTH * MAX_NEW_L2_TO_L1_MSGS_PER_CALL) + 2 + (LOG_HASH_LENGTH * MAX_UNENCRYPTED_LOGS_PER_CALL) + + HEADER_LENGTH + GLOBAL_VARIABLES_LENGTH + AZTEC_ADDRESS_LENGTH + /* revert_code */ 1 + 2 * GAS_LENGTH + + /* transaction_fee */ 1; +const size_t PUBLIC_CONTEXT_INPUTS_LENGTH = + CALL_CONTEXT_LENGTH + HEADER_LENGTH + GLOBAL_VARIABLES_LENGTH + GAS_LENGTH + 2; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/constants.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/constants.hpp index 1fd2fe0029a..06ff6677574 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/constants.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/constants.hpp @@ -11,9 +11,10 @@ inline const std::size_t KERNEL_INPUTS_LENGTH = PUBLIC_CONTEXT_INPUTS_LENGTH; inline const std::size_t KERNEL_OUTPUTS_LENGTH = - MAX_NOTE_HASH_READ_REQUESTS_PER_CALL + MAX_NEW_NOTE_HASHES_PER_CALL + MAX_NULLIFIER_READ_REQUESTS_PER_CALL + - MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL + MAX_NEW_NULLIFIERS_PER_CALL + MAX_NEW_L2_TO_L1_MSGS_PER_CALL + - MAX_UNENCRYPTED_LOGS_PER_CALL + MAX_PUBLIC_DATA_READS_PER_CALL + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL; + MAX_NOTE_HASH_READ_REQUESTS_PER_CALL + MAX_NULLIFIER_READ_REQUESTS_PER_CALL + + MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL + MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL + + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL + MAX_PUBLIC_DATA_READS_PER_CALL + MAX_NEW_NOTE_HASHES_PER_CALL + + MAX_NEW_NULLIFIERS_PER_CALL + MAX_NEW_L2_TO_L1_MSGS_PER_CALL + MAX_UNENCRYPTED_LOGS_PER_CALL; // START INDEXES in the PUBLIC_CIRCUIT_PUBLIC_INPUTS // These line up with indexes found in @@ -33,7 +34,9 @@ inline const uint32_t TRANSACTION_FEE_OFFSET = PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENG inline const uint32_t DA_GAS_LEFT_PCPI_OFFSET = PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH - 3 - GAS_LENGTH; inline const uint32_t L2_GAS_LEFT_PCPI_OFFSET = PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH - 2 - GAS_LENGTH; -// Kernel outputs offsets +// Kernel output pil offset (Where update objects are inlined) + +// Kernel outputs public inputs offsets inline const uint32_t NULLIFIER_EXISTS_OFFSET = CALL_CONTEXT_LENGTH + 2; inline const uint32_t NULLIFIER_NON_EXISTS_OFFSET = NULLIFIER_EXISTS_OFFSET + MAX_NULLIFIER_READ_REQUESTS_PER_CALL * READ_REQUEST_LENGTH; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr index dde7d4103e8..8e5a15dc1ab 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr @@ -22,6 +22,7 @@ global ARGS_LENGTH: u64 = 16; // docs:start:constants // "PER CALL" CONSTANTS +// If modifiying, update avm_kernel.pil / avm_constants.pil offset values (our pil does not yet support constant evaluation so values are hardcoded) global MAX_NEW_NOTE_HASHES_PER_CALL: u64 = 16; global MAX_NEW_NULLIFIERS_PER_CALL: u64 = 16; global MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL: u64 = 4; diff --git a/yarn-project/circuits.js/src/scripts/constants.in.ts b/yarn-project/circuits.js/src/scripts/constants.in.ts index be66fcf09e2..11b606b16a8 100644 --- a/yarn-project/circuits.js/src/scripts/constants.in.ts +++ b/yarn-project/circuits.js/src/scripts/constants.in.ts @@ -23,10 +23,9 @@ const CPP_CONSTANTS = [ 'PUBLIC_CONTEXT_INPUTS_LENGTH', 'PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH', 'READ_REQUEST_LENGTH', - 'MAX_NULLIFIER_READ_REQUESTS_PER_CALL', 'MAX_NOTE_HASH_READ_REQUESTS_PER_CALL', + 'MAX_NULLIFIER_READ_REQUESTS_PER_CALL', 'MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL', - 'MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL', 'CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH', 'MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL', 'CONTRACT_STORAGE_READ_LENGTH', From 494f9665f19a410f187e209bc921b1b091c23bf7 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Fri, 31 May 2024 13:02:52 +0000 Subject: [PATCH 07/20] feat: mvp execution hints --- .../barretenberg/vm/avm_trace/avm_common.hpp | 28 +++++++ .../vm/avm_trace/avm_execution.cpp | 5 +- .../vm/avm_trace/avm_execution.hpp | 4 +- .../barretenberg/vm/avm_trace/avm_trace.cpp | 56 +++++++++++-- .../barretenberg/vm/avm_trace/avm_trace.hpp | 9 +- .../vm/tests/avm_execution.test.cpp | 84 +++++++++++++++++++ .../barretenberg/vm/tests/avm_kernel.test.cpp | 83 +++++++++++++----- 7 files changed, 237 insertions(+), 32 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_common.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_common.hpp index af60e21c8c5..6f2f5ab82a9 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_common.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_common.hpp @@ -5,6 +5,7 @@ #include #include +#include namespace bb::avm_trace { @@ -35,4 +36,31 @@ static const size_t NUM_MEM_SPACES = 256; static const uint8_t INTERNAL_CALL_SPACE_ID = 255; static const uint32_t MAX_SIZE_INTERNAL_STACK = 1 << 16; +// TODO: find a more suitable place for these +/** + * Auxiliary hints are required when the executor is unable to work out a witness value + * These hints will be required for any opcodes that will require database information + */ +struct ExecutionHints { + // slot -> value + std::unordered_map storage_values; + + // Note hash value -> exists + std::unordered_map note_hash_exists; + + // Nullifier -> exists + std::unordered_map nullifier_exists; + + // L1 to L2 message exists + std::unordered_map l1_to_l2_msg_exists; + + ExecutionHints() + { + storage_values = std::unordered_map(); + note_hash_exists = std::unordered_map(); + nullifier_exists = std::unordered_map(); + l1_to_l2_msg_exists = std::unordered_map(); + } +}; + } // namespace bb::avm_trace diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp index a1e9f561027..abe1fd01b41 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp @@ -171,7 +171,8 @@ std::vector Execution::gen_trace(std::vector const& instructio std::vector Execution::gen_trace(std::vector const& instructions, std::vector& returndata, std::vector const& calldata, - std::vector const& public_inputs_vec) + std::vector const& public_inputs_vec, + ExecutionHints const& execution_hints) { // TODO(https://github.com/AztecProtocol/aztec-packages/issues/6718): construction of the public input columns @@ -179,7 +180,7 @@ std::vector Execution::gen_trace(std::vector const& instructio info("before convert public inputs"); VmPublicInputs public_inputs = convert_public_inputs(public_inputs_vec); info("after convert public inputs"); - AvmTraceBuilder trace_builder(public_inputs); + AvmTraceBuilder trace_builder(public_inputs, execution_hints); // Copied version of pc maintained in trace builder. The value of pc is evolving based // on opcode logic and therefore is not maintained here. However, the next opcode in the execution diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.hpp index af4919a9b18..db41fb8ec05 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.hpp @@ -23,12 +23,14 @@ class Execution { static std::vector gen_trace(std::vector const& instructions, std::vector& returndata, std::vector const& calldata, - std::vector const& public_inputs); + std::vector const& public_inputs, + ExecutionHints const& execution_hints = {}); static std::vector gen_trace(std::vector const& instructions, std::vector const& calldata = {}); static std::vector gen_trace(std::vector const& instructions, std::vector const& calldata, std::vector const& public_inputs); + static std::tuple prove(std::vector const& bytecode, std::vector const& calldata = {}); static bool verify(AvmFlavor::VerificationKey vk, HonkProof const& proof); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp index 26655bdc068..b4c6c308648 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp @@ -22,9 +22,10 @@ namespace bb::avm_trace { * @brief Constructor of a trace builder of AVM. Only serves to set the capacity of the * underlying traces and initialize gas values. */ -AvmTraceBuilder::AvmTraceBuilder(VmPublicInputs public_inputs) +AvmTraceBuilder::AvmTraceBuilder(VmPublicInputs public_inputs, ExecutionHints execution_hints) // NOTE: we initialise the environment builder here as it requires public inputs : kernel_trace_builder(public_inputs) + , execution_hints(execution_hints) { main_trace.reserve(AVM_TRACE_SIZE); @@ -1332,6 +1333,34 @@ Row AvmTraceBuilder::create_kernel_output_opcode_with_metadata( }; } +// TODO: fix the naming here - we need it to be different as we are writing a hint +Row AvmTraceBuilder::create_sload( + uint32_t clk, uint32_t data_offset, FF const& data_value, FF const& slot_value, uint32_t slot_offset) +{ + // We write the sload into memory, where the sload is an injected value that is mapped to the public inputs + mem_trace_builder.write_into_memory( + call_ptr, clk, IntermRegister::IA, data_offset, data_value, AvmMemoryTag::FF, AvmMemoryTag::FF); + + return Row{ + .avm_main_clk = clk, + .avm_main_ia = data_value, + .avm_main_ib = slot_value, + .avm_main_ind_a = 0, + .avm_main_ind_b = 0, + .avm_main_internal_return_ptr = internal_return_ptr, + .avm_main_mem_idx_a = data_offset, + .avm_main_mem_idx_b = slot_offset, + .avm_main_mem_op_a = 1, + .avm_main_mem_op_b = 1, + .avm_main_pc = pc++, + .avm_main_q_kernel_output_lookup = 1, + .avm_main_r_in_tag = static_cast(AvmMemoryTag::FF), + .avm_main_rwa = 1, + .avm_main_rwb = 0, + .avm_main_w_in_tag = static_cast(AvmMemoryTag::FF), + }; +} + Row AvmTraceBuilder::create_kernel_output_opcode_with_set_metadata_output( uint32_t clk, uint32_t data_offset, AvmMemoryTag data_r_tag, uint32_t metadata_offset, FF write_value) { @@ -1423,8 +1452,7 @@ void AvmTraceBuilder::op_l1_to_l2_msg_exists(uint32_t log_offset, uint32_t dest_ auto const clk = static_cast(main_trace.size()) + 1; // TODO(https://github.com/AztecProtocol/aztec-packages/issues/6481): success or fail must come from hint - it is - // always 1 for now - uint32_t result = 1; + bool result = execution_hints.l1_to_l2_msg_exists.at(log_offset); Row row = create_kernel_output_opcode_with_set_metadata_output(clk, log_offset, AvmMemoryTag::FF, dest_offset, result); kernel_trace_builder.op_l1_to_l2_msg_exists(clk, row.avm_main_ia, result); @@ -1441,7 +1469,7 @@ void AvmTraceBuilder::op_note_hash_exists(uint32_t note_offset, uint32_t dest_of auto const clk = static_cast(main_trace.size()) + 1; // TODO(ISSUE_NUMBER): success or fail must come from hint - it is always 1 for now - uint32_t result = 1; + bool result = execution_hints.note_hash_exists.at(note_offset); Row row = create_kernel_output_opcode_with_set_metadata_output(clk, note_offset, AvmMemoryTag::FF, dest_offset, result); kernel_trace_builder.op_note_hash_exists(clk, row.avm_main_ia, result); @@ -1458,7 +1486,7 @@ void AvmTraceBuilder::op_nullifier_exists(uint32_t note_offset, uint32_t dest_of auto const clk = static_cast(main_trace.size()) + 1; // TODO(ISSUE_NUMBER): success or fail must come from hint - it is always 1 for now - uint32_t result = 1; + bool result = execution_hints.nullifier_exists.at(note_offset); Row row = create_kernel_output_opcode_with_set_metadata_output(clk, note_offset, AvmMemoryTag::FF, dest_offset, result); kernel_trace_builder.op_nullifier_exists(clk, row.avm_main_ia, result); @@ -1470,13 +1498,23 @@ void AvmTraceBuilder::op_nullifier_exists(uint32_t note_offset, uint32_t dest_of main_trace.push_back(row); } -void AvmTraceBuilder::op_sload(uint32_t slot_offset, uint32_t value_offset) +void AvmTraceBuilder::op_sload(uint32_t slot_offset, uint32_t write_offset) { auto const clk = static_cast(main_trace.size()) + 1; - Row row = - create_kernel_output_opcode_with_metadata(clk, value_offset, AvmMemoryTag::FF, slot_offset, AvmMemoryTag::FF); - kernel_trace_builder.op_sload(clk, row.avm_main_ib, row.avm_main_ia); + // Read the slot + AvmMemTraceBuilder::MemRead slot_read = mem_trace_builder.read_and_load_from_memory( + call_ptr, clk, IntermRegister::IB, slot_offset, AvmMemoryTag::FF, AvmMemoryTag::FF); + + // Get the data value from the execution_hints + // TODO: for now the hints are being offset by the offset - this will NOT fly, but i struggled to get the hash + // working for FF + FF value = execution_hints.storage_values.at(write_offset); + // TODO: throw error if the hint does not exist + + Row row = create_sload(clk, write_offset, value, slot_read.val, slot_offset); + kernel_trace_builder.op_sload(clk, row.avm_main_ib, value); + row.avm_main_sel_op_sload = FF(1); // Constrain gas cost diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp index 4f307f705e7..bdbc145f015 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp @@ -27,7 +27,7 @@ using Row = bb::AvmFullRow; class AvmTraceBuilder { public: - AvmTraceBuilder(VmPublicInputs public_inputs = {}); + AvmTraceBuilder(VmPublicInputs public_inputs = {}, ExecutionHints execution_hints = {}); std::vector finalize(uint32_t min_trace_size = 0, bool range_check_required = false); void reset(); @@ -266,6 +266,13 @@ class AvmTraceBuilder { 0; // After a nested call, it should be initialized with MAX_SIZE_INTERNAL_STACK * call_ptr uint8_t call_ptr = 0; + // TODO: more info + // Execution hints aid witness solving for instructions that require auxiliary information to construct + ExecutionHints execution_hints; + + Row create_sload( + uint32_t clk, uint32_t data_offset, FF const& data_value, FF const& slot_value, uint32_t solt_offset); + // TODO(ilyas: #6383): Temporary way to bulk read slices template uint32_t read_slice_to_memory(uint8_t space_id, diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp index 0185588ffb0..c94773625c7 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp @@ -1635,6 +1635,90 @@ TEST_F(AvmExecutionTests, kernelOutputEmitOpcodes) validate_trace(std::move(trace)); } +// SLOAD and SSTORE +TEST_F(AvmExecutionTests, kernelOutputStorageOpcodes) +{ + // Sload from a value that has not previously been written to will require a hint to process + std::string bytecode_hex = to_hex(OpCode::SET) + // opcode Set + "00" // Indirect flag + "03" // U32 + "00000001" // value 1 + "00000001" // dst_offset 1 + // Cast set to field + + to_hex(OpCode::CAST) + // opcode CAST + "00" // Indirect flag + "06" // tag field + "00000001" // dst 1 + "00000001" // dst 1 + + to_hex(OpCode::EMITNOTEHASH) + // opcode EMITNOTEHASH + "00" // Indirect flag + "00000001" // src offset 1 + + to_hex(OpCode::EMITNULLIFIER) + // opcode EMITNOTEHASH + "00" // Indirect flag + "00000001" // src offset 1 + + to_hex(OpCode::EMITUNENCRYPTEDLOG) + // opcode EMITNOTEHASH + "00" // Indirect flag + "00000001" // src offset 1 + + to_hex(OpCode::RETURN) + // opcode RETURN + "00" // Indirect flag + "00000000" // ret offset 0 + "00000000"; // ret size 0 + + auto bytecode = hex_to_bytes(bytecode_hex); + auto instructions = Deserialization::parse(bytecode); + + // 2 instructions + ASSERT_THAT(instructions, SizeIs(6)); + + std::vector calldata = {}; + std::vector reutrndata = {}; + + // Craft public inputs object - in this case all return values are known to be a fixed value 1 + std::vector public_inputs_vec(PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH); + + auto trace = Execution::gen_trace(instructions); + + // CHECK EMIT NOTE HASH + // Check output data + side effect counters have been set correctly + auto emit_note_hash_row = + std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_emit_note_hash == 1; }); + EXPECT_EQ(emit_note_hash_row->avm_main_ia, 1); + EXPECT_EQ(emit_note_hash_row->avm_kernel_side_effect_counter, 0); + + // Get the row of the first note hash out + uint32_t emit_note_hash_out_offset = AvmKernelTraceBuilder::START_EMIT_NOTE_HASH_WRITE_OFFSET; + auto emit_note_hash_kernel_out_row = std::ranges::find_if( + trace.begin(), trace.end(), [&](Row r) { return r.avm_main_clk == emit_note_hash_out_offset; }); + EXPECT_EQ(emit_note_hash_kernel_out_row->avm_kernel_kernel_value_out__is_public, 1); + EXPECT_EQ(emit_note_hash_kernel_out_row->avm_kernel_kernel_side_effect_out__is_public, 0); + + // CHECK EMIT NULLIFIER + auto emit_nullifier_row = + std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_emit_nullifier == 1; }); + EXPECT_EQ(emit_nullifier_row->avm_main_ia, 1); + EXPECT_EQ(emit_nullifier_row->avm_kernel_side_effect_counter, 1); + + uint32_t emit_nullifier_out_offset = AvmKernelTraceBuilder::START_EMIT_NULLIFIER_WRITE_OFFSET; + auto emit_nullifier_kernel_out_row = std::ranges::find_if( + trace.begin(), trace.end(), [&](Row r) { return r.avm_main_clk == emit_nullifier_out_offset; }); + EXPECT_EQ(emit_nullifier_kernel_out_row->avm_kernel_kernel_value_out__is_public, 1); + EXPECT_EQ(emit_nullifier_kernel_out_row->avm_kernel_kernel_side_effect_out__is_public, 1); + + // CHECK EMIT UNENCRYPTED LOG + auto emit_log_row = std::ranges::find_if( + trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_emit_unencrypted_log == 1; }); + EXPECT_EQ(emit_log_row->avm_main_ia, 1); + EXPECT_EQ(emit_log_row->avm_kernel_side_effect_counter, 2); + + uint32_t emit_log_out_offset = AvmKernelTraceBuilder::START_EMIT_UNENCRYPTED_LOG_WRITE_OFFSET; + auto emit_log_kernel_out_row = + std::ranges::find_if(trace.begin(), trace.end(), [&](Row r) { return r.avm_main_clk == emit_log_out_offset; }); + EXPECT_EQ(emit_log_kernel_out_row->avm_kernel_kernel_value_out__is_public, 1); + EXPECT_EQ(emit_log_kernel_out_row->avm_kernel_kernel_side_effect_out__is_public, 2); + + validate_trace(std::move(trace)); +} + // Negative test detecting an invalid opcode byte. TEST_F(AvmExecutionTests, invalidOpcode) { diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp index e60a5857db0..c4ced9afbc4 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp @@ -38,11 +38,11 @@ VmPublicInputs get_public_inputs() // Template helper function to apply boilerplate around the kernel lookup tests template -void test_kernel_lookup(OpcodesFunc apply_opcodes, CheckFunc check_trace) +void test_kernel_lookup(OpcodesFunc apply_opcodes, CheckFunc check_trace, ExecutionHints execution_hints = {}) { VmPublicInputs public_inputs = get_public_inputs(); - AvmTraceBuilder trace_builder(public_inputs); + AvmTraceBuilder trace_builder(public_inputs, execution_hints); // We should return a value of 1 for the sender, as it exists at index 0 apply_opcodes(trace_builder); @@ -78,7 +78,7 @@ void expect_output_table_row(std::vector::const_iterator row, FF selector, FF ia, FF mem_idx_a, - AvmMemoryTag w_in_tag, + AvmMemoryTag r_in_tag, uint32_t side_effect_counter) { // Checks dependent on the opcode @@ -90,7 +90,7 @@ void expect_output_table_row(std::vector::const_iterator row, EXPECT_EQ(row->avm_main_rwa, FF(0)); EXPECT_EQ(row->avm_main_ind_a, FF(0)); EXPECT_EQ(row->avm_main_mem_op_a, FF(1)); - EXPECT_EQ(row->avm_main_r_in_tag, static_cast(w_in_tag)); + EXPECT_EQ(row->avm_main_r_in_tag, static_cast(r_in_tag)); EXPECT_EQ(row->avm_main_q_kernel_output_lookup, FF(1)); EXPECT_EQ(row->avm_kernel_side_effect_counter, FF(side_effect_counter)); @@ -102,10 +102,44 @@ void expect_output_table_row_with_metadata(std::vector::const_iterator row, FF mem_idx_a, FF ib, FF mem_idx_b, - AvmMemoryTag w_in_tag, + AvmMemoryTag r_in_tag, uint32_t side_effect_counter) { - expect_output_table_row(row, selector, ia, mem_idx_a, w_in_tag, side_effect_counter); + expect_output_table_row(row, selector, ia, mem_idx_a, r_in_tag, side_effect_counter); + + EXPECT_EQ(row->avm_main_ib, ib); + EXPECT_EQ(row->avm_main_mem_idx_b, mem_idx_b); + + // Checks that are fixed for kernel inputs + EXPECT_EQ(row->avm_main_rwb, FF(0)); + EXPECT_EQ(row->avm_main_ind_b, FF(0)); + EXPECT_EQ(row->avm_main_mem_op_b, FF(1)); +} + +// TODO: rework - temporary for PoC +void expect_output_table_row_with_metadata_hint(std::vector::const_iterator row, + FF selector, + FF ia, + FF mem_idx_a, + FF ib, + FF mem_idx_b, + AvmMemoryTag r_in_tag, + uint32_t side_effect_counter) +{ + // Checks dependent on the opcode + EXPECT_EQ(row->avm_kernel_kernel_out_offset, selector); + EXPECT_EQ(row->avm_main_ia, ia); + EXPECT_EQ(row->avm_main_mem_idx_a, mem_idx_a); + + // Checks that are fixed for kernel inputs + EXPECT_EQ(row->avm_main_rwa, FF(1)); + EXPECT_EQ(row->avm_main_ind_a, FF(0)); + EXPECT_EQ(row->avm_main_mem_op_a, FF(1)); + EXPECT_EQ(row->avm_main_w_in_tag, static_cast(r_in_tag)); + EXPECT_EQ(row->avm_main_r_in_tag, static_cast(r_in_tag)); + EXPECT_EQ(row->avm_main_q_kernel_output_lookup, FF(1)); + + EXPECT_EQ(row->avm_kernel_side_effect_counter, FF(side_effect_counter)); EXPECT_EQ(row->avm_main_ib, ib); EXPECT_EQ(row->avm_main_mem_idx_b, mem_idx_b); @@ -726,13 +760,16 @@ TEST_F(AvmKernelOutputPositiveTests, kernelSload) { uint32_t value_offset = 42; auto value = 1234; - uint32_t metadata_offset = 420; + uint32_t slot_offset = 420; auto slot = 12345; + // Provide a hint for sload value slot + ExecutionHints execution_hints; + execution_hints.storage_values[value_offset] = value; + auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { - trace_builder.op_set(0, static_cast(value), value_offset, AvmMemoryTag::FF); - trace_builder.op_set(0, static_cast(slot), metadata_offset, AvmMemoryTag::FF); - trace_builder.op_sload(metadata_offset, value_offset); + trace_builder.op_set(0, static_cast(slot), slot_offset, AvmMemoryTag::FF); + trace_builder.op_sload(slot_offset, value_offset); }; auto checks = [=](const std::vector& trace) { std::vector::const_iterator row = @@ -742,22 +779,20 @@ TEST_F(AvmKernelOutputPositiveTests, kernelSload) // Check the outputs of the trace uint32_t output_offset = AvmKernelTraceBuilder::START_SLOAD_WRITE_OFFSET; - expect_output_table_row_with_metadata( + expect_output_table_row_with_metadata_hint( row, /*kernel_in_offset=*/output_offset, /*ia=*/value, // Note the value generated above for public inputs is the same as the index read + 1 /*mem_idx_a=*/value_offset, /*ib=*/slot, - /*mem_idx_b=*/metadata_offset, + /*mem_idx_b=*/slot_offset, /*w_in_tag=*/AvmMemoryTag::FF, - /*side_effect_counter=*/0 - - ); + /*side_effect_counter=*/0); check_kernel_outputs(trace.at(output_offset), value, /*side_effect_counter=*/0, slot); }; - test_kernel_lookup(apply_opcodes, checks); + test_kernel_lookup(apply_opcodes, checks, execution_hints); } TEST_F(AvmKernelOutputPositiveTests, kernelSstore) @@ -803,6 +838,9 @@ TEST_F(AvmKernelOutputPositiveTests, kernelNoteHashExists) uint32_t metadata_offset = 420; auto exists = 1; + ExecutionHints execution_hints = {}; + execution_hints.note_hash_exists[value_offset] = static_cast(exists); + auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_set(0, static_cast(value), value_offset, AvmMemoryTag::FF); trace_builder.op_note_hash_exists(value_offset, metadata_offset); @@ -829,7 +867,7 @@ TEST_F(AvmKernelOutputPositiveTests, kernelNoteHashExists) check_kernel_outputs(trace.at(output_offset), value, /*side_effect_counter=*/0, exists); }; - test_kernel_lookup(apply_opcodes, checks); + test_kernel_lookup(apply_opcodes, checks, execution_hints); } TEST_F(AvmKernelOutputPositiveTests, kernelNullifierExists) @@ -839,6 +877,9 @@ TEST_F(AvmKernelOutputPositiveTests, kernelNullifierExists) uint32_t metadata_offset = 420; auto exists = 1; + ExecutionHints execution_hints = {}; + execution_hints.nullifier_exists[value_offset] = static_cast(exists); + auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_set(0, static_cast(value), value_offset, AvmMemoryTag::FF); trace_builder.op_nullifier_exists(value_offset, metadata_offset); @@ -864,7 +905,7 @@ TEST_F(AvmKernelOutputPositiveTests, kernelNullifierExists) check_kernel_outputs(trace.at(output_offset), value, /*side_effect_counter=*/0, exists); }; - test_kernel_lookup(apply_opcodes, checks); + test_kernel_lookup(apply_opcodes, checks, execution_hints); } TEST_F(AvmKernelOutputPositiveTests, kernelL1ToL2MsgExists) @@ -874,6 +915,10 @@ TEST_F(AvmKernelOutputPositiveTests, kernelL1ToL2MsgExists) uint32_t metadata_offset = 420; auto exists = 1; + // Create an execution hints object with the result of the operation + ExecutionHints execution_hints = {}; + execution_hints.l1_to_l2_msg_exists[value_offset] = static_cast(exists); + auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_set(0, static_cast(value), value_offset, AvmMemoryTag::FF); trace_builder.op_l1_to_l2_msg_exists(value_offset, metadata_offset); @@ -899,7 +944,7 @@ TEST_F(AvmKernelOutputPositiveTests, kernelL1ToL2MsgExists) check_kernel_outputs(trace.at(output_offset), value, /*side_effect_counter=*/0, exists); }; - test_kernel_lookup(apply_opcodes, checks); + test_kernel_lookup(apply_opcodes, checks, execution_hints); } } // namespace tests_avm \ No newline at end of file From fe02298ecbeac41b49ea82cabdabbef0c93f1811 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Fri, 31 May 2024 16:14:45 +0000 Subject: [PATCH 08/20] feat: sload and sstore execution --- barretenberg/cpp/src/barretenberg/bb/main.cpp | 19 ++- .../barretenberg/vm/avm_trace/avm_common.hpp | 37 ++++-- .../vm/avm_trace/avm_deserialization.cpp | 2 + .../vm/avm_trace/avm_execution.cpp | 23 ++-- .../vm/avm_trace/avm_execution.hpp | 7 +- .../barretenberg/vm/avm_trace/avm_trace.cpp | 2 +- .../vm/tests/avm_execution.test.cpp | 108 +++++++++--------- .../barretenberg/vm/tests/avm_kernel.test.cpp | 3 +- 8 files changed, 124 insertions(+), 77 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/bb/main.cpp b/barretenberg/cpp/src/barretenberg/bb/main.cpp index ec7da2a62ea..0742fe3ee60 100644 --- a/barretenberg/cpp/src/barretenberg/bb/main.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/main.cpp @@ -521,6 +521,8 @@ void vk_as_fields(const std::string& vk_path, const std::string& output_path) */ void avm_prove(const std::filesystem::path& bytecode_path, const std::filesystem::path& calldata_path, + const std::filesystem::path& public_inputs_path, + const std::filesystem::path& hints_path, const std::filesystem::path& output_path) { // Get Bytecode @@ -532,11 +534,26 @@ void avm_prove(const std::filesystem::path& bytecode_path, } std::vector const call_data = many_from_buffer(call_data_bytes); + std::vector public_inputs_bytes{}; + if (std::filesystem::exists(public_inputs_path)) { + public_inputs_bytes = read_file(public_inputs_path); + } + std::vector const public_inputs_vec = many_from_buffer(public_inputs_bytes); + + std::vector hints_bytes{}; + if (std::filesystem::exists(hints_path)) { + hints_bytes = read_file(hints_path); + } + + // ExecutionHints const execution_hints = ExecutionHints::from_buffer(hints_bytes); + // ExecutionHints const execution_hints = {}; + // Hardcoded circuit size for now, with enough to support 16-bit range checks init_bn254_crs(1 << 17); // Prove execution and return vk - auto const [verification_key, proof] = avm_trace::Execution::prove(avm_bytecode, call_data); + auto const [verification_key, proof] = + avm_trace::Execution::prove(avm_bytecode, call_data, public_inputs_vec /*, execution_hints*/); // TODO(ilyas): <#4887>: Currently we only need these two parts of the vk, look into pcs_verification key reqs std::vector vk_vector = { verification_key.circuit_size, verification_key.num_public_inputs }; std::vector vk_as_fields = { verification_key.circuit_size, verification_key.num_public_inputs }; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_common.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_common.hpp index 6f2f5ab82a9..338841832fd 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_common.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_common.hpp @@ -12,6 +12,23 @@ namespace bb::avm_trace { using Flavor = bb::AvmFlavor; using FF = Flavor::FF; +} // namespace bb::avm_trace + +// TODO: where is the best place for this to live? +namespace std { +template <> struct hash { + // We define a hash function for the AVM FF type for an unordered_map integration + size_t operator()(const bb::avm_trace::FF& ff) const + { + return ( + std::hash()(ff.data[0]) ^ + std::hash()(ff.data[1] ^ std::hash()(ff.data[2]) ^ std::hash()(ff.data[3]))); + } +}; +} // namespace std + +namespace bb::avm_trace { + // There are 4 public input columns, 1 for context inputs, and 3 for emitting side effects using VmPublicInputs = std::tuple, // Input: Kernel context inputs std::array, // Output: Kernel outputs data @@ -43,24 +60,28 @@ static const uint32_t MAX_SIZE_INTERNAL_STACK = 1 << 16; */ struct ExecutionHints { // slot -> value - std::unordered_map storage_values; + std::unordered_map storage_values; // Note hash value -> exists - std::unordered_map note_hash_exists; + std::unordered_map note_hash_exists; // Nullifier -> exists - std::unordered_map nullifier_exists; + std::unordered_map nullifier_exists; // L1 to L2 message exists - std::unordered_map l1_to_l2_msg_exists; + std::unordered_map l1_to_l2_msg_exists; ExecutionHints() { - storage_values = std::unordered_map(); - note_hash_exists = std::unordered_map(); - nullifier_exists = std::unordered_map(); - l1_to_l2_msg_exists = std::unordered_map(); + storage_values = std::unordered_map(); + note_hash_exists = std::unordered_map(); + nullifier_exists = std::unordered_map(); + l1_to_l2_msg_exists = std::unordered_map(); } + + friend bool operator==(const ExecutionHints&, const ExecutionHints&); + std::vector bincodeSerialize() const; + static ExecutionHints bincodeDeserialize(std::vector); }; } // namespace bb::avm_trace diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp index f6569c7720e..63fa047df43 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp @@ -59,6 +59,8 @@ const std::unordered_map> OPCODE_WIRE_FORMAT = { OpCode::EMITNOTEHASH, getter_format }, // TODO: new format for these { OpCode::EMITNULLIFIER, getter_format }, // TODO: new format for these { OpCode::EMITUNENCRYPTEDLOG, getter_format }, + { OpCode::SLOAD, { OperandType::INDIRECT, OperandType::UINT32, OperandType::UINT32 } }, + { OpCode::SSTORE, { OperandType::INDIRECT, OperandType::UINT32, OperandType::UINT32 } }, // CONTRACTCALLDEPTH, -- not in simulator // Execution Environment - Globals { OpCode::CHAINID, getter_format }, diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp index abe1fd01b41..4fc2df36fae 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp @@ -47,11 +47,15 @@ std::vector Execution::getDefaultPublicInputs() * @return The verifier key and zk proof of the execution. */ std::tuple Execution::prove(std::vector const& bytecode, - std::vector const& calldata) + std::vector const& calldata, + std::vector const& public_inputs_vec, + ExecutionHints const& execution_hints) { + info("silence warning: ", public_inputs_vec[0]); + auto instructions = Deserialization::parse(bytecode); std::vector returndata{}; - auto trace = gen_trace(instructions, returndata, calldata, getDefaultPublicInputs()); + auto trace = gen_trace(instructions, returndata, calldata, getDefaultPublicInputs(), execution_hints); auto circuit_builder = bb::AvmCircuitBuilder(); circuit_builder.set_trace(std::move(trace)); @@ -73,10 +77,11 @@ std::tuple Execution::prove(std::vector Execution::gen_trace(std::vector const& instructions, std::vector const& calldata, - std::vector const& public_inputs) + std::vector const& public_inputs, + ExecutionHints const& execution_hints) { std::vector returndata{}; - return gen_trace(instructions, returndata, calldata, public_inputs); + return gen_trace(instructions, returndata, calldata, public_inputs, execution_hints); } /** @@ -177,9 +182,7 @@ std::vector Execution::gen_trace(std::vector const& instructio { // TODO(https://github.com/AztecProtocol/aztec-packages/issues/6718): construction of the public input columns // should be done in the kernel - this is stubbed and underconstrained - info("before convert public inputs"); VmPublicInputs public_inputs = convert_public_inputs(public_inputs_vec); - info("after convert public inputs"); AvmTraceBuilder trace_builder(public_inputs, execution_hints); // Copied version of pc maintained in trace builder. The value of pc is evolving based @@ -191,9 +194,7 @@ std::vector Execution::gen_trace(std::vector const& instructio // TODO: We do not yet support the indirect flag. Therefore we do not extract // inst.operands(0) (i.e. the indirect flag) when processiing the instructions. - info("opcode: ", static_cast(inst.op_code)); switch (inst.op_code) { - // Compute // Compute - Arithmetic case OpCode::ADD: @@ -357,6 +358,12 @@ std::vector Execution::gen_trace(std::vector const& instructio case OpCode::EMITNULLIFIER: trace_builder.op_emit_nullifier(std::get(inst.operands.at(1))); break; + case OpCode::SLOAD: + trace_builder.op_sload(std::get(inst.operands.at(1)), std::get(inst.operands.at(2))); + break; + case OpCode::SSTORE: + trace_builder.op_sstore(std::get(inst.operands.at(1)), std::get(inst.operands.at(2))); + break; case OpCode::L1TOL2MSGEXISTS: trace_builder.op_l1_to_l2_msg_exists(std::get(inst.operands.at(1)), std::get(inst.operands.at(2))); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.hpp index db41fb8ec05..e8a53ea60cf 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.hpp @@ -29,10 +29,13 @@ class Execution { std::vector const& calldata = {}); static std::vector gen_trace(std::vector const& instructions, std::vector const& calldata, - std::vector const& public_inputs); + std::vector const& public_inputs, + ExecutionHints const& execution_hints); static std::tuple prove(std::vector const& bytecode, - std::vector const& calldata = {}); + std::vector const& calldata = {}, + std::vector const& public_inputs_vec = {}, + ExecutionHints const& execution_hints = {}); static bool verify(AvmFlavor::VerificationKey vk, HonkProof const& proof); }; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp index b4c6c308648..4b1369a598c 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp @@ -1509,7 +1509,7 @@ void AvmTraceBuilder::op_sload(uint32_t slot_offset, uint32_t write_offset) // Get the data value from the execution_hints // TODO: for now the hints are being offset by the offset - this will NOT fly, but i struggled to get the hash // working for FF - FF value = execution_hints.storage_values.at(write_offset); + FF value = execution_hints.storage_values.at(slot_read.val); // TODO: throw error if the hint does not exist Row row = create_sload(clk, write_offset, value, slot_read.val, slot_offset); diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp index c94773625c7..a97ec969cbf 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp @@ -1639,82 +1639,78 @@ TEST_F(AvmExecutionTests, kernelOutputEmitOpcodes) TEST_F(AvmExecutionTests, kernelOutputStorageOpcodes) { // Sload from a value that has not previously been written to will require a hint to process - std::string bytecode_hex = to_hex(OpCode::SET) + // opcode Set + std::string bytecode_hex = to_hex(OpCode::SET) + // opcode SET "00" // Indirect flag "03" // U32 - "00000001" // value 1 + "00000009" // value 9 "00000001" // dst_offset 1 // Cast set to field - + to_hex(OpCode::CAST) + // opcode CAST - "00" // Indirect flag - "06" // tag field - "00000001" // dst 1 - "00000001" // dst 1 - + to_hex(OpCode::EMITNOTEHASH) + // opcode EMITNOTEHASH - "00" // Indirect flag - "00000001" // src offset 1 - + to_hex(OpCode::EMITNULLIFIER) + // opcode EMITNOTEHASH - "00" // Indirect flag - "00000001" // src offset 1 - + to_hex(OpCode::EMITUNENCRYPTEDLOG) + // opcode EMITNOTEHASH - "00" // Indirect flag - "00000001" // src offset 1 - + to_hex(OpCode::RETURN) + // opcode RETURN - "00" // Indirect flag - "00000000" // ret offset 0 - "00000000"; // ret size 0 + + to_hex(OpCode::CAST) + // opcode CAST + "00" // Indirect flag + "06" // tag field + "00000001" // dst 1 + "00000001" // dst 1 + + to_hex(OpCode::SLOAD) + // opcode SLOAD + "00" // Indirect flag + "00000001" // slot offset 1 + "00000002" // write storage value to offset 2 + + to_hex(OpCode::SSTORE) + // opcode SSTORE + "00" // Indirect flag + "00000001" // slot offset 1 + "00000002" // value write offset 2 + + to_hex(OpCode::RETURN) + // opcode RETURN + "00" // Indirect flag + "00000000" // ret offset 0 + "00000000"; // ret size 0 auto bytecode = hex_to_bytes(bytecode_hex); auto instructions = Deserialization::parse(bytecode); // 2 instructions - ASSERT_THAT(instructions, SizeIs(6)); + ASSERT_THAT(instructions, SizeIs(5)); std::vector calldata = {}; - std::vector reutrndata = {}; + std::vector returndata = {}; // Craft public inputs object - in this case all return values are known to be a fixed value 1 std::vector public_inputs_vec(PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH); - auto trace = Execution::gen_trace(instructions); + // Generate Hint for Sload operation + ExecutionHints execution_hints = {}; + execution_hints.storage_values[FF(9)] = FF(42); // Slot 9 = value 42 - // CHECK EMIT NOTE HASH + auto trace = Execution::gen_trace(instructions, returndata, calldata, public_inputs_vec, execution_hints); + + // CHECK SLOAD // Check output data + side effect counters have been set correctly - auto emit_note_hash_row = - std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_emit_note_hash == 1; }); - EXPECT_EQ(emit_note_hash_row->avm_main_ia, 1); - EXPECT_EQ(emit_note_hash_row->avm_kernel_side_effect_counter, 0); + auto sload_row = + std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_sload == 1; }); + EXPECT_EQ(sload_row->avm_main_ia, 42); // Read value + EXPECT_EQ(sload_row->avm_main_ib, 9); // Storage slot + EXPECT_EQ(sload_row->avm_kernel_side_effect_counter, 0); // Get the row of the first note hash out - uint32_t emit_note_hash_out_offset = AvmKernelTraceBuilder::START_EMIT_NOTE_HASH_WRITE_OFFSET; - auto emit_note_hash_kernel_out_row = std::ranges::find_if( - trace.begin(), trace.end(), [&](Row r) { return r.avm_main_clk == emit_note_hash_out_offset; }); - EXPECT_EQ(emit_note_hash_kernel_out_row->avm_kernel_kernel_value_out__is_public, 1); - EXPECT_EQ(emit_note_hash_kernel_out_row->avm_kernel_kernel_side_effect_out__is_public, 0); - - // CHECK EMIT NULLIFIER - auto emit_nullifier_row = - std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_emit_nullifier == 1; }); - EXPECT_EQ(emit_nullifier_row->avm_main_ia, 1); - EXPECT_EQ(emit_nullifier_row->avm_kernel_side_effect_counter, 1); - - uint32_t emit_nullifier_out_offset = AvmKernelTraceBuilder::START_EMIT_NULLIFIER_WRITE_OFFSET; - auto emit_nullifier_kernel_out_row = std::ranges::find_if( - trace.begin(), trace.end(), [&](Row r) { return r.avm_main_clk == emit_nullifier_out_offset; }); - EXPECT_EQ(emit_nullifier_kernel_out_row->avm_kernel_kernel_value_out__is_public, 1); - EXPECT_EQ(emit_nullifier_kernel_out_row->avm_kernel_kernel_side_effect_out__is_public, 1); + uint32_t sload_out_offset = AvmKernelTraceBuilder::START_SLOAD_WRITE_OFFSET; + auto sload_kernel_out_row = + std::ranges::find_if(trace.begin(), trace.end(), [&](Row r) { return r.avm_main_clk == sload_out_offset; }); + EXPECT_EQ(sload_kernel_out_row->avm_kernel_kernel_value_out__is_public, 42); // value + EXPECT_EQ(sload_kernel_out_row->avm_kernel_kernel_side_effect_out__is_public, 0); + EXPECT_EQ(sload_kernel_out_row->avm_kernel_kernel_metadata_out__is_public, 9); // slot + + // CHECK SSTORE + auto sstore_row = + std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_sstore == 1; }); + EXPECT_EQ(sstore_row->avm_main_ia, 42); // Read value + EXPECT_EQ(sstore_row->avm_main_ib, 9); // Storage slot + EXPECT_EQ(sstore_row->avm_kernel_side_effect_counter, 0); - // CHECK EMIT UNENCRYPTED LOG - auto emit_log_row = std::ranges::find_if( - trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_emit_unencrypted_log == 1; }); - EXPECT_EQ(emit_log_row->avm_main_ia, 1); - EXPECT_EQ(emit_log_row->avm_kernel_side_effect_counter, 2); - - uint32_t emit_log_out_offset = AvmKernelTraceBuilder::START_EMIT_UNENCRYPTED_LOG_WRITE_OFFSET; - auto emit_log_kernel_out_row = - std::ranges::find_if(trace.begin(), trace.end(), [&](Row r) { return r.avm_main_clk == emit_log_out_offset; }); - EXPECT_EQ(emit_log_kernel_out_row->avm_kernel_kernel_value_out__is_public, 1); - EXPECT_EQ(emit_log_kernel_out_row->avm_kernel_kernel_side_effect_out__is_public, 2); + // Get the row of the first note hash out + uint32_t sstore_out_offset = AvmKernelTraceBuilder::START_SSTORE_WRITE_OFFSET; + auto sstore_kernel_out_row = + std::ranges::find_if(trace.begin(), trace.end(), [&](Row r) { return r.avm_main_clk == sstore_out_offset; }); + EXPECT_EQ(sstore_kernel_out_row->avm_kernel_kernel_value_out__is_public, 42); // value + EXPECT_EQ(sstore_kernel_out_row->avm_kernel_kernel_side_effect_out__is_public, 1); + EXPECT_EQ(sstore_kernel_out_row->avm_kernel_kernel_metadata_out__is_public, 9); // slot validate_trace(std::move(trace)); } diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp index c4ced9afbc4..5e42333e307 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp @@ -765,7 +765,7 @@ TEST_F(AvmKernelOutputPositiveTests, kernelSload) // Provide a hint for sload value slot ExecutionHints execution_hints; - execution_hints.storage_values[value_offset] = value; + execution_hints.storage_values[FF(slot)] = FF(value); auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_set(0, static_cast(slot), slot_offset, AvmMemoryTag::FF); @@ -779,6 +779,7 @@ TEST_F(AvmKernelOutputPositiveTests, kernelSload) // Check the outputs of the trace uint32_t output_offset = AvmKernelTraceBuilder::START_SLOAD_WRITE_OFFSET; + // TODO: unify this with the existing metadata checking thing - it should not be different expect_output_table_row_with_metadata_hint( row, /*kernel_in_offset=*/output_offset, From 69a0ce00228a5618ce31a376ed363ee2563ab308 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Fri, 31 May 2024 16:15:32 +0000 Subject: [PATCH 09/20] fix: update sstore side effect counter --- .../cpp/src/barretenberg/vm/tests/avm_execution.test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp index a97ec969cbf..b95520cdbd5 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp @@ -1702,7 +1702,7 @@ TEST_F(AvmExecutionTests, kernelOutputStorageOpcodes) std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_sstore == 1; }); EXPECT_EQ(sstore_row->avm_main_ia, 42); // Read value EXPECT_EQ(sstore_row->avm_main_ib, 9); // Storage slot - EXPECT_EQ(sstore_row->avm_kernel_side_effect_counter, 0); + EXPECT_EQ(sstore_row->avm_kernel_side_effect_counter, 1); // Get the row of the first note hash out uint32_t sstore_out_offset = AvmKernelTraceBuilder::START_SSTORE_WRITE_OFFSET; From 18fef35c800400de31d2a17e8c4a1c743c3ea7f0 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Sun, 2 Jun 2024 17:34:27 +0000 Subject: [PATCH 10/20] temp --- .../vm/avm_trace/avm_deserialization.cpp | 3 + .../vm/avm_trace/avm_kernel_trace.cpp | 4 +- .../barretenberg/vm/avm_trace/avm_trace.cpp | 37 ++++---- .../barretenberg/vm/avm_trace/avm_trace.hpp | 7 +- .../vm/tests/avm_execution.test.cpp | 85 +++++++++++++++++++ .../barretenberg/vm/tests/avm_kernel.test.cpp | 6 +- 6 files changed, 116 insertions(+), 26 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp index 63fa047df43..0eac135a582 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp @@ -61,6 +61,9 @@ const std::unordered_map> OPCODE_WIRE_FORMAT = { OpCode::EMITUNENCRYPTEDLOG, getter_format }, { OpCode::SLOAD, { OperandType::INDIRECT, OperandType::UINT32, OperandType::UINT32 } }, { OpCode::SSTORE, { OperandType::INDIRECT, OperandType::UINT32, OperandType::UINT32 } }, + { OpCode::NOTEHASHEXISTS, { OperandType::INDIRECT, OperandType::UINT32, OperandType::UINT32 } }, + { OpCode::NULLIFIEREXISTS, { OperandType::INDIRECT, OperandType::UINT32, OperandType::UINT32 } }, + { OpCode::L1TOL2MSGEXISTS, { OperandType::INDIRECT, OperandType::UINT32, OperandType::UINT32 } }, // CONTRACTCALLDEPTH, -- not in simulator // Execution Environment - Globals { OpCode::CHAINID, getter_format }, diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.cpp index 88b6964183b..b0970b009a2 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.cpp @@ -39,7 +39,9 @@ void AvmKernelTraceBuilder::perform_kernel_output_lookup(uint32_t write_offset, std::get(public_inputs)[write_offset] = side_effect_counter; std::get(public_inputs)[write_offset] = metadata; - info("output writing side effect counter: ", side_effect_counter); + info("outputing value @ offset: ", write_offset, ": ", value); + info("output writing side effect @ offset: ", write_offset, ": ", side_effect_counter); + info("output writing metadata @ offset: ", write_offset, ": ", metadata); // Lookup counts kernel_output_selector_counter[write_offset]++; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp index 4b1369a598c..53848a8f17b 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp @@ -1362,18 +1362,21 @@ Row AvmTraceBuilder::create_sload( } Row AvmTraceBuilder::create_kernel_output_opcode_with_set_metadata_output( - uint32_t clk, uint32_t data_offset, AvmMemoryTag data_r_tag, uint32_t metadata_offset, FF write_value) + uint32_t clk, uint32_t data_offset, uint32_t metadata_offset, std::unordered_map const& exists_hint) { AvmMemTraceBuilder::MemRead read_a = mem_trace_builder.read_and_load_from_memory( - call_ptr, clk, IntermRegister::IA, data_offset, data_r_tag, AvmMemoryTag::U8); + call_ptr, clk, IntermRegister::IA, data_offset, AvmMemoryTag::FF, AvmMemoryTag::U8); + + bool exists = exists_hint.at(read_a.val); + // TODO: throw error if incorrect mem_trace_builder.write_into_memory( - call_ptr, clk, IntermRegister::IB, metadata_offset, write_value, data_r_tag, AvmMemoryTag::U8); + call_ptr, clk, IntermRegister::IB, metadata_offset, exists, AvmMemoryTag::FF, AvmMemoryTag::U8); return Row{ .avm_main_clk = clk, .avm_main_ia = read_a.val, - .avm_main_ib = write_value, + .avm_main_ib = exists, .avm_main_ind_a = 0, .avm_main_ind_b = 0, .avm_main_internal_return_ptr = internal_return_ptr, @@ -1383,7 +1386,7 @@ Row AvmTraceBuilder::create_kernel_output_opcode_with_set_metadata_output( .avm_main_mem_op_b = 1, .avm_main_pc = pc++, .avm_main_q_kernel_output_lookup = 1, - .avm_main_r_in_tag = static_cast(data_r_tag), + .avm_main_r_in_tag = static_cast(AvmMemoryTag::FF), .avm_main_rwa = 0, .avm_main_rwb = 1, .avm_main_w_in_tag = static_cast(AvmMemoryTag::U8), @@ -1451,11 +1454,9 @@ void AvmTraceBuilder::op_l1_to_l2_msg_exists(uint32_t log_offset, uint32_t dest_ { auto const clk = static_cast(main_trace.size()) + 1; - // TODO(https://github.com/AztecProtocol/aztec-packages/issues/6481): success or fail must come from hint - it is - bool result = execution_hints.l1_to_l2_msg_exists.at(log_offset); - Row row = - create_kernel_output_opcode_with_set_metadata_output(clk, log_offset, AvmMemoryTag::FF, dest_offset, result); - kernel_trace_builder.op_l1_to_l2_msg_exists(clk, row.avm_main_ia, result); + Row row = create_kernel_output_opcode_with_set_metadata_output( + clk, log_offset, dest_offset, execution_hints.l1_to_l2_msg_exists); + kernel_trace_builder.op_l1_to_l2_msg_exists(clk, row.avm_main_ia, /*safe*/ static_cast(row.avm_main_ib)); row.avm_main_sel_op_l1_to_l2_msg_exists = FF(1); // Constrain gas cost @@ -1468,11 +1469,9 @@ void AvmTraceBuilder::op_note_hash_exists(uint32_t note_offset, uint32_t dest_of { auto const clk = static_cast(main_trace.size()) + 1; - // TODO(ISSUE_NUMBER): success or fail must come from hint - it is always 1 for now - bool result = execution_hints.note_hash_exists.at(note_offset); - Row row = - create_kernel_output_opcode_with_set_metadata_output(clk, note_offset, AvmMemoryTag::FF, dest_offset, result); - kernel_trace_builder.op_note_hash_exists(clk, row.avm_main_ia, result); + Row row = create_kernel_output_opcode_with_set_metadata_output( + clk, note_offset, dest_offset, execution_hints.note_hash_exists); + kernel_trace_builder.op_note_hash_exists(clk, row.avm_main_ia, /*safe*/ static_cast(row.avm_main_ib)); row.avm_main_sel_op_l1_to_l2_msg_exists = FF(1); // Constrain gas cost @@ -1485,11 +1484,9 @@ void AvmTraceBuilder::op_nullifier_exists(uint32_t note_offset, uint32_t dest_of { auto const clk = static_cast(main_trace.size()) + 1; - // TODO(ISSUE_NUMBER): success or fail must come from hint - it is always 1 for now - bool result = execution_hints.nullifier_exists.at(note_offset); - Row row = - create_kernel_output_opcode_with_set_metadata_output(clk, note_offset, AvmMemoryTag::FF, dest_offset, result); - kernel_trace_builder.op_nullifier_exists(clk, row.avm_main_ia, result); + Row row = create_kernel_output_opcode_with_set_metadata_output( + clk, note_offset, dest_offset, execution_hints.nullifier_exists); + kernel_trace_builder.op_nullifier_exists(clk, row.avm_main_ia, /*safe*/ static_cast(row.avm_main_ib)); row.avm_main_sel_op_nullifier_exists = FF(1); // Constrain gas cost diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp index bdbc145f015..e0c06ac4ba0 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp @@ -253,8 +253,11 @@ class AvmTraceBuilder { * @param write_value - The value to be written into the result - in all instances this is used - it is a boolean * @return Row */ - Row create_kernel_output_opcode_with_set_metadata_output( - uint32_t clk, uint32_t data_offset, AvmMemoryTag data_r_tag, uint32_t metadata_offset, FF write_value); + // TODO: update info + Row create_kernel_output_opcode_with_set_metadata_output(uint32_t clk, + uint32_t data_offset, + uint32_t metadata_offset, + std::unordered_map const& exists_hint); void finalise_mem_trace_lookup_counts(); diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp index b95520cdbd5..e6b31b6045e 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp @@ -1715,6 +1715,91 @@ TEST_F(AvmExecutionTests, kernelOutputStorageOpcodes) validate_trace(std::move(trace)); } +TEST_F(AvmExecutionTests, kernelOutputHashExistsOpcodes) +{ + // Sload from a value that has not previously been written to will require a hint to process + std::string bytecode_hex = to_hex(OpCode::SET) + // opcode SET + "00" // Indirect flag + "03" // U32 + "00000001" // value 1 + "00000001" // dst_offset 1 + // Cast set to field + + to_hex(OpCode::CAST) + // opcode CAST + "00" // Indirect flag + "06" // tag field + "00000001" // dst 1 + "00000001" // dst 1 + + to_hex(OpCode::NOTEHASHEXISTS) + // opcode NOTEHASHEXISTS + "00" // Indirect flag + "00000001" // slot offset 1 + "00000002" // write storage value to offset 2 (exists value) + + to_hex(OpCode::NULLIFIEREXISTS) + // opcode NULLIFIEREXISTS + "00" // Indirect flag + "00000001" // slot offset 1 + "00000002" // value write offset 2 (exists value) + + to_hex(OpCode::L1TOL2MSGEXISTS) + // opcode L1TOL2MSGEXISTS + "00" // Indirect flag + "00000001" // slot offset 1 + "00000002" // value write offset 2 (exists value) + + to_hex(OpCode::RETURN) + // opcode RETURN + "00" // Indirect flag + "00000000" // ret offset 0 + "00000000"; // ret size 0 + + auto bytecode = hex_to_bytes(bytecode_hex); + auto instructions = Deserialization::parse(bytecode); + + // 2 instructions + ASSERT_THAT(instructions, SizeIs(6)); + + std::vector calldata = {}; + std::vector returndata = {}; + + // Craft public inputs object - in this case all return values are known to be a fixed value 1 + std::vector public_inputs_vec(PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH); + + // Generate Hint for Sload operation + ExecutionHints execution_hints = {}; + execution_hints.note_hash_exists[FF(1)] = true; // Slot 1 = true + execution_hints.nullifier_exists[FF(1)] = true; // Slot 1 = true + execution_hints.l1_to_l2_msg_exists[FF(1)] = true; // Slot 1 = true + + auto trace = Execution::gen_trace(instructions, returndata, calldata, public_inputs_vec, execution_hints); + + // CHECK NOTEHASHEXISTS + auto note_hash_row = + std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_note_hash_exists == 1; }); + EXPECT_EQ(note_hash_row->avm_main_ia, 1); // Read value + EXPECT_EQ(note_hash_row->avm_main_ib, 1); // Storage slot + EXPECT_EQ(note_hash_row->avm_kernel_side_effect_counter, 0); + + // Get the row of the first note hash out + uint32_t note_hash_exists_offset = AvmKernelTraceBuilder::START_NOTE_HASH_EXISTS_WRITE_OFFSET; + info("note hash offset: ", note_hash_exists_offset); + auto note_hash_out_row = + // TODO: it appears that as note_hash_exists_offset is zero, there are two posisitons where the clk is 0, so it + // is getting the wrong one + std::ranges::find_if( + trace.begin() + sizeof(Row), trace.end(), [&](Row r) { return r.avm_main_clk == note_hash_exists_offset; }); + info("gotten value: @ offset ", + note_hash_exists_offset, + ": value: ", + note_hash_out_row->avm_kernel_kernel_value_out__is_public); + EXPECT_EQ(note_hash_out_row->avm_kernel_kernel_value_out__is_public, 1); // value + info("gotten sec: @ offset ", + note_hash_exists_offset, + ": sec: ", + note_hash_out_row->avm_kernel_kernel_side_effect_out__is_public); + EXPECT_EQ(note_hash_out_row->avm_kernel_kernel_side_effect_out__is_public, 0); + info("gotten metadata: @ offset ", + note_hash_exists_offset, + ": meta: ", + note_hash_out_row->avm_kernel_kernel_metadata_out__is_public); + EXPECT_EQ(note_hash_out_row->avm_kernel_kernel_metadata_out__is_public, 1); // slot + + validate_trace(std::move(trace)); +} + // Negative test detecting an invalid opcode byte. TEST_F(AvmExecutionTests, invalidOpcode) { diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp index 5e42333e307..6731c182cb1 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp @@ -840,7 +840,7 @@ TEST_F(AvmKernelOutputPositiveTests, kernelNoteHashExists) auto exists = 1; ExecutionHints execution_hints = {}; - execution_hints.note_hash_exists[value_offset] = static_cast(exists); + execution_hints.note_hash_exists[FF(value)] = static_cast(exists); auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_set(0, static_cast(value), value_offset, AvmMemoryTag::FF); @@ -879,7 +879,7 @@ TEST_F(AvmKernelOutputPositiveTests, kernelNullifierExists) auto exists = 1; ExecutionHints execution_hints = {}; - execution_hints.nullifier_exists[value_offset] = static_cast(exists); + execution_hints.nullifier_exists[FF(value)] = static_cast(exists); auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_set(0, static_cast(value), value_offset, AvmMemoryTag::FF); @@ -918,7 +918,7 @@ TEST_F(AvmKernelOutputPositiveTests, kernelL1ToL2MsgExists) // Create an execution hints object with the result of the operation ExecutionHints execution_hints = {}; - execution_hints.l1_to_l2_msg_exists[value_offset] = static_cast(exists); + execution_hints.l1_to_l2_msg_exists[FF(value)] = static_cast(exists); auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_set(0, static_cast(value), value_offset, AvmMemoryTag::FF); From 81d1ff55c0f652e8af6507c2bac362838e9bdc29 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Sun, 2 Jun 2024 18:49:25 +0000 Subject: [PATCH 11/20] feat: kernel exists opcodes with hints --- barretenberg/cpp/src/barretenberg/bb/main.cpp | 4 +- .../vm/avm_trace/avm_deserialization.cpp | 2 - .../vm/avm_trace/avm_execution.cpp | 8 ++- .../vm/avm_trace/avm_execution.hpp | 3 +- .../vm/avm_trace/avm_kernel_trace.cpp | 4 -- .../barretenberg/vm/avm_trace/avm_trace.cpp | 5 -- .../vm/tests/avm_execution.test.cpp | 71 +++++++++---------- 7 files changed, 44 insertions(+), 53 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/bb/main.cpp b/barretenberg/cpp/src/barretenberg/bb/main.cpp index 0742fe3ee60..521eea432cc 100644 --- a/barretenberg/cpp/src/barretenberg/bb/main.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/main.cpp @@ -910,9 +910,11 @@ int main(int argc, char* argv[]) } else if (command == "avm_prove") { std::filesystem::path avm_bytecode_path = get_option(args, "-b", "./target/avm_bytecode.bin"); std::filesystem::path calldata_path = get_option(args, "-d", "./target/call_data.bin"); + std::filesystem::path public_inputs_path = get_option(args, "-u", "./target/public_inputs.bin"); + std::filesystem::path execution_hints_path = get_option(args, "-e", "./target/execution_hints.bin"); // This outputs both files: proof and vk, under the given directory. std::filesystem::path output_path = get_option(args, "-o", "./proofs"); - avm_prove(avm_bytecode_path, calldata_path, output_path); + avm_prove(avm_bytecode_path, calldata_path, public_inputs_path, execution_hints_path, output_path); } else if (command == "avm_verify") { return avm_verify(proof_path, vk_path) ? 0 : 1; } else if (command == "prove_ultra_honk") { diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp index 0eac135a582..f932b7d2fa3 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp @@ -163,7 +163,6 @@ std::vector Deserialization::parse(std::vector const& byte auto const opcode = static_cast(opcode_byte); std::vector inst_format; - info("opcode byte: ", opcode_byte); if (opcode == OpCode::SET) { // Small hack here because of the structure of SET (where Indirect is the first flag). // Right now pos is pointing to the indirect flag, but we want it to point to the memory tag. @@ -273,7 +272,6 @@ std::vector Deserialization::parse(std::vector const& byte } instructions.emplace_back(opcode, operands); } - info("have all instructions"); return instructions; }; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp index 4fc2df36fae..15c3c7f7c12 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp @@ -51,7 +51,8 @@ std::tuple Execution::prove(std::vector const& public_inputs_vec, ExecutionHints const& execution_hints) { - info("silence warning: ", public_inputs_vec[0]); + // TODO: temp + info("logging to silence warning for now: ", public_inputs_vec.size()); auto instructions = Deserialization::parse(bytecode); std::vector returndata{}; @@ -158,10 +159,11 @@ bool Execution::verify(AvmFlavor::VerificationKey vk, HonkProof const& proof) * @param calldata expressed as a vector of finite field elements. * @return The trace as a vector of Row. */ -std::vector Execution::gen_trace(std::vector const& instructions, std::vector const& calldata) +std::vector Execution::gen_trace(std::vector const& instructions, + std::vector const& calldata, + std::vector const& public_inputs_vec) { std::vector returndata{}; - std::vector public_inputs_vec = {}; return gen_trace(instructions, returndata, calldata, public_inputs_vec); } diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.hpp index e8a53ea60cf..aa4696f0aa6 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.hpp @@ -26,7 +26,8 @@ class Execution { std::vector const& public_inputs, ExecutionHints const& execution_hints = {}); static std::vector gen_trace(std::vector const& instructions, - std::vector const& calldata = {}); + std::vector const& calldata = {}, + std::vector const& public_inputs = {}); static std::vector gen_trace(std::vector const& instructions, std::vector const& calldata, std::vector const& public_inputs, diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.cpp index b0970b009a2..a2af2684653 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.cpp @@ -39,10 +39,6 @@ void AvmKernelTraceBuilder::perform_kernel_output_lookup(uint32_t write_offset, std::get(public_inputs)[write_offset] = side_effect_counter; std::get(public_inputs)[write_offset] = metadata; - info("outputing value @ offset: ", write_offset, ": ", value); - info("output writing side effect @ offset: ", write_offset, ": ", side_effect_counter); - info("output writing metadata @ offset: ", write_offset, ": ", metadata); - // Lookup counts kernel_output_selector_counter[write_offset]++; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp index 53848a8f17b..08db833346e 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp @@ -3656,10 +3656,6 @@ std::vector AvmTraceBuilder::finalize(uint32_t min_trace_size, bool range_c if (clk < main_trace_size) { Row& next = main_trace.at(clk + 1); - if (src.op_emit_unencrypted_log) { - info("side effect counter when emiting log: ", curr.avm_kernel_side_effect_counter); - } - // Increment the write offset counter for the following row next.avm_kernel_note_hash_exist_write_offset = curr.avm_kernel_note_hash_exist_write_offset + static_cast(src.op_note_hash_exists); @@ -3718,7 +3714,6 @@ std::vector AvmTraceBuilder::finalize(uint32_t min_trace_size, bool range_c dest.avm_kernel_side_effect_counter = prev.avm_kernel_side_effect_counter; } } - ////////// WORK IN PROGRESS ////////////////////////// /////////// GAS ACCOUNTING ////////////////////////// // Add the gas cost table to the main trace diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp index e6b31b6045e..ee53c2e7fd2 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp @@ -1059,7 +1059,6 @@ TEST_F(AvmExecutionTests, poseidon2PermutationOpCode) // Assign a vector that we will mutate internally in gen_trace to store the return values; std::vector returndata = std::vector(); - std::vector public_inputs_vec(PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH); std::vector expected_output = { FF(std::string("0x2bf1eaf87f7d27e8dc4056e9af975985bccc89077a21891d6c7b6ccce0631f95")), FF(std::string("0x0c01fa1b8d0748becafbe452c0cb0231c38224ea824554c9362518eebdd5701f")), @@ -1583,16 +1582,11 @@ TEST_F(AvmExecutionTests, kernelOutputEmitOpcodes) auto bytecode = hex_to_bytes(bytecode_hex); auto instructions = Deserialization::parse(bytecode); - // 2 instructions ASSERT_THAT(instructions, SizeIs(6)); std::vector calldata = {}; - std::vector reutrndata = {}; - - // Craft public inputs object - in this case all return values are known to be a fixed value 1 - std::vector public_inputs_vec(PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH); - - auto trace = Execution::gen_trace(instructions); + std::vector returndata = {}; + auto trace = Execution::gen_trace(instructions, returndata, calldata, public_inputs_vec); // CHECK EMIT NOTE HASH // Check output data + side effect counters have been set correctly @@ -1666,15 +1660,11 @@ TEST_F(AvmExecutionTests, kernelOutputStorageOpcodes) auto bytecode = hex_to_bytes(bytecode_hex); auto instructions = Deserialization::parse(bytecode); - // 2 instructions ASSERT_THAT(instructions, SizeIs(5)); std::vector calldata = {}; std::vector returndata = {}; - // Craft public inputs object - in this case all return values are known to be a fixed value 1 - std::vector public_inputs_vec(PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH); - // Generate Hint for Sload operation ExecutionHints execution_hints = {}; execution_hints.storage_values[FF(9)] = FF(42); // Slot 9 = value 42 @@ -1749,15 +1739,11 @@ TEST_F(AvmExecutionTests, kernelOutputHashExistsOpcodes) auto bytecode = hex_to_bytes(bytecode_hex); auto instructions = Deserialization::parse(bytecode); - // 2 instructions ASSERT_THAT(instructions, SizeIs(6)); std::vector calldata = {}; std::vector returndata = {}; - // Craft public inputs object - in this case all return values are known to be a fixed value 1 - std::vector public_inputs_vec(PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH); - // Generate Hint for Sload operation ExecutionHints execution_hints = {}; execution_hints.note_hash_exists[FF(1)] = true; // Slot 1 = true @@ -1773,29 +1759,40 @@ TEST_F(AvmExecutionTests, kernelOutputHashExistsOpcodes) EXPECT_EQ(note_hash_row->avm_main_ib, 1); // Storage slot EXPECT_EQ(note_hash_row->avm_kernel_side_effect_counter, 0); - // Get the row of the first note hash out - uint32_t note_hash_exists_offset = AvmKernelTraceBuilder::START_NOTE_HASH_EXISTS_WRITE_OFFSET; - info("note hash offset: ", note_hash_exists_offset); - auto note_hash_out_row = - // TODO: it appears that as note_hash_exists_offset is zero, there are two posisitons where the clk is 0, so it - // is getting the wrong one - std::ranges::find_if( - trace.begin() + sizeof(Row), trace.end(), [&](Row r) { return r.avm_main_clk == note_hash_exists_offset; }); - info("gotten value: @ offset ", - note_hash_exists_offset, - ": value: ", - note_hash_out_row->avm_kernel_kernel_value_out__is_public); + auto note_hash_out_row = std::ranges::find_if(trace.begin(), trace.end(), [&](Row r) { + return r.avm_main_clk == AvmKernelTraceBuilder::START_NOTE_HASH_EXISTS_WRITE_OFFSET; + }); EXPECT_EQ(note_hash_out_row->avm_kernel_kernel_value_out__is_public, 1); // value - info("gotten sec: @ offset ", - note_hash_exists_offset, - ": sec: ", - note_hash_out_row->avm_kernel_kernel_side_effect_out__is_public); EXPECT_EQ(note_hash_out_row->avm_kernel_kernel_side_effect_out__is_public, 0); - info("gotten metadata: @ offset ", - note_hash_exists_offset, - ": meta: ", - note_hash_out_row->avm_kernel_kernel_metadata_out__is_public); - EXPECT_EQ(note_hash_out_row->avm_kernel_kernel_metadata_out__is_public, 1); // slot + EXPECT_EQ(note_hash_out_row->avm_kernel_kernel_metadata_out__is_public, 1); // exists + + // CHECK NULLIFIEREXISTS + auto nullifier_row = + std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_nullifier_exists == 1; }); + EXPECT_EQ(nullifier_row->avm_main_ia, 1); // Read value + EXPECT_EQ(nullifier_row->avm_main_ib, 1); // Storage slot + EXPECT_EQ(nullifier_row->avm_kernel_side_effect_counter, 1); + + auto nullifier_out_row = std::ranges::find_if(trace.begin(), trace.end(), [&](Row r) { + return r.avm_main_clk == AvmKernelTraceBuilder::START_NULLIFIER_EXISTS_OFFSET; + }); + EXPECT_EQ(nullifier_out_row->avm_kernel_kernel_value_out__is_public, 1); // value + EXPECT_EQ(nullifier_out_row->avm_kernel_kernel_side_effect_out__is_public, 1); + EXPECT_EQ(nullifier_out_row->avm_kernel_kernel_metadata_out__is_public, 1); // exists + + // CHECK L1TOL2MSGEXISTS + auto l1_to_l2_row = std::ranges::find_if( + trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_l1_to_l2_msg_exists == 1; }); + EXPECT_EQ(l1_to_l2_row->avm_main_ia, 1); // Read value + EXPECT_EQ(l1_to_l2_row->avm_main_ib, 1); // Storage slot + EXPECT_EQ(l1_to_l2_row->avm_kernel_side_effect_counter, 2); + + auto msg_out_row = std::ranges::find_if(trace.begin(), trace.end(), [&](Row r) { + return r.avm_main_clk == AvmKernelTraceBuilder::START_L1_TO_L2_MSG_EXISTS_WRITE_OFFSET; + }); + EXPECT_EQ(msg_out_row->avm_kernel_kernel_value_out__is_public, 1); // value + EXPECT_EQ(msg_out_row->avm_kernel_kernel_side_effect_out__is_public, 2); + EXPECT_EQ(msg_out_row->avm_kernel_kernel_metadata_out__is_public, 1); // exists validate_trace(std::move(trace)); } From e9c3acde52874024125dd9fc20e62eaeaeeb9e16 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Mon, 3 Jun 2024 15:04:19 +0000 Subject: [PATCH 12/20] feat: update execution hints to map side effect counter to value --- .../barretenberg/vm/avm_trace/avm_common.hpp | 45 +--------------- .../vm/avm_trace/avm_kernel_trace.cpp | 52 +++++++++++-------- .../vm/avm_trace/avm_kernel_trace.hpp | 27 +++++----- .../barretenberg/vm/avm_trace/avm_trace.cpp | 48 ++++++++++------- .../barretenberg/vm/avm_trace/avm_trace.hpp | 9 ++-- .../vm/tests/avm_execution.test.cpp | 8 +-- .../barretenberg/vm/tests/avm_kernel.test.cpp | 8 +-- 7 files changed, 89 insertions(+), 108 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_common.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_common.hpp index 338841832fd..b27edb64782 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_common.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_common.hpp @@ -14,19 +14,6 @@ using FF = Flavor::FF; } // namespace bb::avm_trace -// TODO: where is the best place for this to live? -namespace std { -template <> struct hash { - // We define a hash function for the AVM FF type for an unordered_map integration - size_t operator()(const bb::avm_trace::FF& ff) const - { - return ( - std::hash()(ff.data[0]) ^ - std::hash()(ff.data[1] ^ std::hash()(ff.data[2]) ^ std::hash()(ff.data[3]))); - } -}; -} // namespace std - namespace bb::avm_trace { // There are 4 public input columns, 1 for context inputs, and 3 for emitting side effects @@ -53,35 +40,7 @@ static const size_t NUM_MEM_SPACES = 256; static const uint8_t INTERNAL_CALL_SPACE_ID = 255; static const uint32_t MAX_SIZE_INTERNAL_STACK = 1 << 16; -// TODO: find a more suitable place for these -/** - * Auxiliary hints are required when the executor is unable to work out a witness value - * These hints will be required for any opcodes that will require database information - */ -struct ExecutionHints { - // slot -> value - std::unordered_map storage_values; - - // Note hash value -> exists - std::unordered_map note_hash_exists; - - // Nullifier -> exists - std::unordered_map nullifier_exists; - - // L1 to L2 message exists - std::unordered_map l1_to_l2_msg_exists; - - ExecutionHints() - { - storage_values = std::unordered_map(); - note_hash_exists = std::unordered_map(); - nullifier_exists = std::unordered_map(); - l1_to_l2_msg_exists = std::unordered_map(); - } - - friend bool operator==(const ExecutionHints&, const ExecutionHints&); - std::vector bincodeSerialize() const; - static ExecutionHints bincodeDeserialize(std::vector); -}; +// Side effect counter -> value +using ExecutionHints = std::unordered_map; } // namespace bb::avm_trace diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.cpp index a2af2684653..196165cc3c3 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.cpp @@ -33,7 +33,10 @@ FF AvmKernelTraceBuilder::perform_kernel_input_lookup(uint32_t selector) return result; } -void AvmKernelTraceBuilder::perform_kernel_output_lookup(uint32_t write_offset, const FF& value, const FF& metadata) +void AvmKernelTraceBuilder::perform_kernel_output_lookup(uint32_t write_offset, + uint32_t side_effect_counter, + const FF& value, + const FF& metadata) { std::get(public_inputs)[write_offset] = value; std::get(public_inputs)[write_offset] = side_effect_counter; @@ -41,8 +44,6 @@ void AvmKernelTraceBuilder::perform_kernel_output_lookup(uint32_t write_offset, // Lookup counts kernel_output_selector_counter[write_offset]++; - - side_effect_counter++; } // We want to be able to get the return value from the public inputs column @@ -100,11 +101,14 @@ FF AvmKernelTraceBuilder::op_timestamp() // TODO(https://github.com/AztecProtocol/aztec-packages/issues/6481): need to process hint from avm in order to know if // output should be set to true or not -void AvmKernelTraceBuilder::op_note_hash_exists(uint32_t clk, const FF& note_hash, uint32_t result) +void AvmKernelTraceBuilder::op_note_hash_exists(uint32_t clk, + uint32_t side_effect_counter, + const FF& note_hash, + uint32_t result) { uint32_t offset = START_NOTE_HASH_EXISTS_WRITE_OFFSET + note_hash_exists_offset; - perform_kernel_output_lookup(offset, note_hash, FF(result)); + perform_kernel_output_lookup(offset, side_effect_counter, note_hash, FF(result)); note_hash_exists_offset++; KernelTraceEntry entry = { @@ -116,10 +120,10 @@ void AvmKernelTraceBuilder::op_note_hash_exists(uint32_t clk, const FF& note_has kernel_trace.push_back(entry); } -void AvmKernelTraceBuilder::op_emit_note_hash(uint32_t clk, const FF& note_hash) +void AvmKernelTraceBuilder::op_emit_note_hash(uint32_t clk, uint32_t side_effect_counter, const FF& note_hash) { uint32_t offset = START_EMIT_NOTE_HASH_WRITE_OFFSET + emit_note_hash_offset; - perform_kernel_output_lookup(offset, note_hash, FF(0)); + perform_kernel_output_lookup(offset, side_effect_counter, note_hash, FF(0)); emit_note_hash_offset++; KernelTraceEntry entry = { @@ -133,10 +137,13 @@ void AvmKernelTraceBuilder::op_emit_note_hash(uint32_t clk, const FF& note_hash) // TODO(https://github.com/AztecProtocol/aztec-packages/issues/6481): need to process hint from avm in order to know if // output should be set to true or not -void AvmKernelTraceBuilder::op_nullifier_exists(uint32_t clk, const FF& nullifier, uint32_t result) +void AvmKernelTraceBuilder::op_nullifier_exists(uint32_t clk, + uint32_t side_effect_counter, + const FF& nullifier, + uint32_t result) { uint32_t offset = START_NULLIFIER_EXISTS_OFFSET + nullifier_exists_offset; - perform_kernel_output_lookup(offset, nullifier, FF(result)); + perform_kernel_output_lookup(offset, side_effect_counter, nullifier, FF(result)); nullifier_exists_offset++; KernelTraceEntry entry = { @@ -148,10 +155,10 @@ void AvmKernelTraceBuilder::op_nullifier_exists(uint32_t clk, const FF& nullifie kernel_trace.push_back(entry); } -void AvmKernelTraceBuilder::op_emit_nullifier(uint32_t clk, const FF& nullifier) +void AvmKernelTraceBuilder::op_emit_nullifier(uint32_t clk, uint32_t side_effect_counter, const FF& nullifier) { uint32_t offset = START_EMIT_NULLIFIER_WRITE_OFFSET + emit_nullifier_offset; - perform_kernel_output_lookup(offset, nullifier, FF(0)); + perform_kernel_output_lookup(offset, side_effect_counter, nullifier, FF(0)); emit_nullifier_offset++; KernelTraceEntry entry = { @@ -165,10 +172,13 @@ void AvmKernelTraceBuilder::op_emit_nullifier(uint32_t clk, const FF& nullifier) // TODO(https://github.com/AztecProtocol/aztec-packages/issues/6481): need to process hint from avm in order to know if // output should be set to true or not -void AvmKernelTraceBuilder::op_l1_to_l2_msg_exists(uint32_t clk, const FF& message, uint32_t result) +void AvmKernelTraceBuilder::op_l1_to_l2_msg_exists(uint32_t clk, + uint32_t side_effect_counter, + const FF& message, + uint32_t result) { uint32_t offset = START_L1_TO_L2_MSG_EXISTS_WRITE_OFFSET + l1_to_l2_msg_exists_offset; - perform_kernel_output_lookup(offset, message, FF(result)); + perform_kernel_output_lookup(offset, side_effect_counter, message, FF(result)); l1_to_l2_msg_exists_offset++; KernelTraceEntry entry = { @@ -180,10 +190,10 @@ void AvmKernelTraceBuilder::op_l1_to_l2_msg_exists(uint32_t clk, const FF& messa kernel_trace.push_back(entry); } -void AvmKernelTraceBuilder::op_emit_unencrypted_log(uint32_t clk, const FF& log_hash) +void AvmKernelTraceBuilder::op_emit_unencrypted_log(uint32_t clk, uint32_t side_effect_counter, const FF& log_hash) { uint32_t offset = START_EMIT_UNENCRYPTED_LOG_WRITE_OFFSET + emit_unencrypted_log_offset; - perform_kernel_output_lookup(offset, log_hash, FF(0)); + perform_kernel_output_lookup(offset, side_effect_counter, log_hash, FF(0)); emit_unencrypted_log_offset++; KernelTraceEntry entry = { @@ -195,10 +205,10 @@ void AvmKernelTraceBuilder::op_emit_unencrypted_log(uint32_t clk, const FF& log_ kernel_trace.push_back(entry); } -void AvmKernelTraceBuilder::op_emit_l2_to_l1_msg(uint32_t clk, const FF& l2_to_l1_msg) +void AvmKernelTraceBuilder::op_emit_l2_to_l1_msg(uint32_t clk, uint32_t side_effect_counter, const FF& l2_to_l1_msg) { uint32_t offset = START_L2_TO_L1_MSG_WRITE_OFFSET + emit_l2_to_l1_msg_offset; - perform_kernel_output_lookup(offset, l2_to_l1_msg, FF(0)); + perform_kernel_output_lookup(offset, side_effect_counter, l2_to_l1_msg, FF(0)); emit_l2_to_l1_msg_offset++; KernelTraceEntry entry = { @@ -210,10 +220,10 @@ void AvmKernelTraceBuilder::op_emit_l2_to_l1_msg(uint32_t clk, const FF& l2_to_l kernel_trace.push_back(entry); } -void AvmKernelTraceBuilder::op_sload(uint32_t clk, const FF& slot, const FF& value) +void AvmKernelTraceBuilder::op_sload(uint32_t clk, uint32_t side_effect_counter, const FF& slot, const FF& value) { uint32_t offset = START_SLOAD_WRITE_OFFSET + sload_write_offset; - perform_kernel_output_lookup(offset, value, slot); + perform_kernel_output_lookup(offset, side_effect_counter, value, slot); sload_write_offset++; KernelTraceEntry entry = { @@ -225,10 +235,10 @@ void AvmKernelTraceBuilder::op_sload(uint32_t clk, const FF& slot, const FF& val kernel_trace.push_back(entry); } -void AvmKernelTraceBuilder::op_sstore(uint32_t clk, const FF& slot, const FF& value) +void AvmKernelTraceBuilder::op_sstore(uint32_t clk, uint32_t side_effect_counter, const FF& slot, const FF& value) { uint32_t offset = START_SSTORE_WRITE_OFFSET + sstore_write_offset; - perform_kernel_output_lookup(offset, value, slot); + perform_kernel_output_lookup(offset, side_effect_counter, value, slot); sstore_write_offset++; KernelTraceEntry entry = { diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.hpp index dd9d9b9dd96..38b86d949ec 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.hpp @@ -89,16 +89,16 @@ class AvmKernelTraceBuilder { // Outputs // Each returns the selector that was used - void op_note_hash_exists(uint32_t clk, const FF& note_hash, uint32_t result); - void op_emit_note_hash(uint32_t clk, const FF& note_hash); - void op_nullifier_exists(uint32_t clk, const FF& nullifier, uint32_t result); - void op_emit_nullifier(uint32_t clk, const FF& nullifier); - void op_l1_to_l2_msg_exists(uint32_t clk, const FF& message, uint32_t result); - void op_emit_unencrypted_log(uint32_t clk, const FF& log_hash); - void op_emit_l2_to_l1_msg(uint32_t clk, const FF& message); + void op_note_hash_exists(uint32_t clk, uint32_t side_effect_counter, const FF& note_hash, uint32_t result); + void op_emit_note_hash(uint32_t clk, uint32_t side_effect_counter, const FF& note_hash); + void op_nullifier_exists(uint32_t clk, uint32_t side_effect_counter, const FF& nullifier, uint32_t result); + void op_emit_nullifier(uint32_t clk, uint32_t side_effect_counter, const FF& nullifier); + void op_l1_to_l2_msg_exists(uint32_t clk, uint32_t side_effect_counter, const FF& message, uint32_t result); + void op_emit_unencrypted_log(uint32_t clk, uint32_t side_effect_counter, const FF& log_hash); + void op_emit_l2_to_l1_msg(uint32_t clk, uint32_t side_effect_counter, const FF& message); - void op_sload(uint32_t clk, const FF& slot, const FF& value); - void op_sstore(uint32_t clk, const FF& slot, const FF& value); + void op_sload(uint32_t clk, uint32_t side_effect_counter, const FF& slot, const FF& value); + void op_sstore(uint32_t clk, uint32_t side_effect_counter, const FF& slot, const FF& value); // TODO: Move into constants.hpp? static const uint32_t START_NOTE_HASH_EXISTS_WRITE_OFFSET = 0; @@ -124,10 +124,6 @@ class AvmKernelTraceBuilder { private: std::vector kernel_trace; - // Side effect counter will incremenent when any state writing values are - // encountered - uint32_t side_effect_counter = 0; - // Output index counters uint32_t note_hash_exists_offset = 0; uint32_t emit_note_hash_offset = 0; @@ -141,6 +137,9 @@ class AvmKernelTraceBuilder { uint32_t sstore_write_offset = 0; FF perform_kernel_input_lookup(uint32_t selector); - void perform_kernel_output_lookup(uint32_t write_offset, const FF& value, const FF& metadata); + void perform_kernel_output_lookup(uint32_t write_offset, + uint32_t side_effect_counter, + const FF& value, + const FF& metadata); }; } // namespace bb::avm_trace \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp index 08db833346e..745d170691d 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp @@ -1361,13 +1361,14 @@ Row AvmTraceBuilder::create_sload( }; } -Row AvmTraceBuilder::create_kernel_output_opcode_with_set_metadata_output( - uint32_t clk, uint32_t data_offset, uint32_t metadata_offset, std::unordered_map const& exists_hint) +Row AvmTraceBuilder::create_kernel_output_opcode_with_set_metadata_output(uint32_t clk, + uint32_t data_offset, + uint32_t metadata_offset) { AvmMemTraceBuilder::MemRead read_a = mem_trace_builder.read_and_load_from_memory( call_ptr, clk, IntermRegister::IA, data_offset, AvmMemoryTag::FF, AvmMemoryTag::U8); - bool exists = exists_hint.at(read_a.val); + FF exists = execution_hints.at(side_effect_counter); // TODO: throw error if incorrect mem_trace_builder.write_into_memory( @@ -1398,13 +1399,14 @@ void AvmTraceBuilder::op_emit_note_hash(uint32_t note_hash_offset) auto const clk = static_cast(main_trace.size()) + 1; Row row = create_kernel_output_opcode(clk, note_hash_offset); - kernel_trace_builder.op_emit_note_hash(clk, row.avm_main_ia); + kernel_trace_builder.op_emit_note_hash(clk, side_effect_counter, row.avm_main_ia); row.avm_main_sel_op_emit_note_hash = FF(1); // Constrain gas cost gas_trace_builder.constrain_gas_lookup(clk, OpCode::EMITNOTEHASH); main_trace.push_back(row); + side_effect_counter++; } void AvmTraceBuilder::op_emit_nullifier(uint32_t nullifier_offset) @@ -1412,13 +1414,14 @@ void AvmTraceBuilder::op_emit_nullifier(uint32_t nullifier_offset) auto const clk = static_cast(main_trace.size()) + 1; Row row = create_kernel_output_opcode(clk, nullifier_offset); - kernel_trace_builder.op_emit_nullifier(clk, row.avm_main_ia); + kernel_trace_builder.op_emit_nullifier(clk, side_effect_counter, row.avm_main_ia); row.avm_main_sel_op_emit_nullifier = FF(1); // Constrain gas cost gas_trace_builder.constrain_gas_lookup(clk, OpCode::EMITNULLIFIER); main_trace.push_back(row); + side_effect_counter++; } void AvmTraceBuilder::op_emit_l2_to_l1_msg(uint32_t msg_offset) @@ -1426,13 +1429,14 @@ void AvmTraceBuilder::op_emit_l2_to_l1_msg(uint32_t msg_offset) auto const clk = static_cast(main_trace.size()) + 1; Row row = create_kernel_output_opcode(clk, msg_offset); - kernel_trace_builder.op_emit_l2_to_l1_msg(clk, row.avm_main_ia); + kernel_trace_builder.op_emit_l2_to_l1_msg(clk, side_effect_counter, row.avm_main_ia); row.avm_main_sel_op_emit_l2_to_l1_msg = FF(1); // Constrain gas cost gas_trace_builder.constrain_gas_lookup(clk, OpCode::SENDL2TOL1MSG); main_trace.push_back(row); + side_effect_counter++; } void AvmTraceBuilder::op_emit_unencrypted_log(uint32_t log_offset) @@ -1440,13 +1444,14 @@ void AvmTraceBuilder::op_emit_unencrypted_log(uint32_t log_offset) auto const clk = static_cast(main_trace.size()) + 1; Row row = create_kernel_output_opcode(clk, log_offset); - kernel_trace_builder.op_emit_unencrypted_log(clk, row.avm_main_ia); + kernel_trace_builder.op_emit_unencrypted_log(clk, side_effect_counter, row.avm_main_ia); row.avm_main_sel_op_emit_unencrypted_log = FF(1); // Constrain gas cost gas_trace_builder.constrain_gas_lookup(clk, OpCode::EMITUNENCRYPTEDLOG); main_trace.push_back(row); + side_effect_counter++; } // State output opcodes that include metadata @@ -1454,45 +1459,48 @@ void AvmTraceBuilder::op_l1_to_l2_msg_exists(uint32_t log_offset, uint32_t dest_ { auto const clk = static_cast(main_trace.size()) + 1; - Row row = create_kernel_output_opcode_with_set_metadata_output( - clk, log_offset, dest_offset, execution_hints.l1_to_l2_msg_exists); - kernel_trace_builder.op_l1_to_l2_msg_exists(clk, row.avm_main_ia, /*safe*/ static_cast(row.avm_main_ib)); + Row row = create_kernel_output_opcode_with_set_metadata_output(clk, log_offset, dest_offset); + kernel_trace_builder.op_l1_to_l2_msg_exists( + clk, side_effect_counter, row.avm_main_ia, /*safe*/ static_cast(row.avm_main_ib)); row.avm_main_sel_op_l1_to_l2_msg_exists = FF(1); // Constrain gas cost gas_trace_builder.constrain_gas_lookup(clk, OpCode::L1TOL2MSGEXISTS); main_trace.push_back(row); + side_effect_counter++; } void AvmTraceBuilder::op_note_hash_exists(uint32_t note_offset, uint32_t dest_offset) { auto const clk = static_cast(main_trace.size()) + 1; - Row row = create_kernel_output_opcode_with_set_metadata_output( - clk, note_offset, dest_offset, execution_hints.note_hash_exists); - kernel_trace_builder.op_note_hash_exists(clk, row.avm_main_ia, /*safe*/ static_cast(row.avm_main_ib)); + Row row = create_kernel_output_opcode_with_set_metadata_output(clk, note_offset, dest_offset); + kernel_trace_builder.op_note_hash_exists( + clk, side_effect_counter, row.avm_main_ia, /*safe*/ static_cast(row.avm_main_ib)); row.avm_main_sel_op_l1_to_l2_msg_exists = FF(1); // Constrain gas cost gas_trace_builder.constrain_gas_lookup(clk, OpCode::NOTEHASHEXISTS); main_trace.push_back(row); + side_effect_counter++; } void AvmTraceBuilder::op_nullifier_exists(uint32_t note_offset, uint32_t dest_offset) { auto const clk = static_cast(main_trace.size()) + 1; - Row row = create_kernel_output_opcode_with_set_metadata_output( - clk, note_offset, dest_offset, execution_hints.nullifier_exists); - kernel_trace_builder.op_nullifier_exists(clk, row.avm_main_ia, /*safe*/ static_cast(row.avm_main_ib)); + Row row = create_kernel_output_opcode_with_set_metadata_output(clk, note_offset, dest_offset); + kernel_trace_builder.op_nullifier_exists( + clk, side_effect_counter, row.avm_main_ia, /*safe*/ static_cast(row.avm_main_ib)); row.avm_main_sel_op_nullifier_exists = FF(1); // Constrain gas cost gas_trace_builder.constrain_gas_lookup(clk, OpCode::NULLIFIEREXISTS); main_trace.push_back(row); + side_effect_counter++; } void AvmTraceBuilder::op_sload(uint32_t slot_offset, uint32_t write_offset) @@ -1506,11 +1514,11 @@ void AvmTraceBuilder::op_sload(uint32_t slot_offset, uint32_t write_offset) // Get the data value from the execution_hints // TODO: for now the hints are being offset by the offset - this will NOT fly, but i struggled to get the hash // working for FF - FF value = execution_hints.storage_values.at(slot_read.val); + FF value = execution_hints.at(side_effect_counter); // TODO: throw error if the hint does not exist Row row = create_sload(clk, write_offset, value, slot_read.val, slot_offset); - kernel_trace_builder.op_sload(clk, row.avm_main_ib, value); + kernel_trace_builder.op_sload(clk, side_effect_counter, row.avm_main_ib, value); row.avm_main_sel_op_sload = FF(1); @@ -1518,6 +1526,7 @@ void AvmTraceBuilder::op_sload(uint32_t slot_offset, uint32_t write_offset) gas_trace_builder.constrain_gas_lookup(clk, OpCode::SLOAD); main_trace.push_back(row); + side_effect_counter++; } void AvmTraceBuilder::op_sstore(uint32_t slot_offset, uint32_t value_offset) @@ -1526,13 +1535,14 @@ void AvmTraceBuilder::op_sstore(uint32_t slot_offset, uint32_t value_offset) Row row = create_kernel_output_opcode_with_metadata(clk, value_offset, AvmMemoryTag::FF, slot_offset, AvmMemoryTag::FF); - kernel_trace_builder.op_sstore(clk, row.avm_main_ib, row.avm_main_ia); + kernel_trace_builder.op_sstore(clk, side_effect_counter, row.avm_main_ib, row.avm_main_ia); row.avm_main_sel_op_sstore = FF(1); // Constrain gas cost gas_trace_builder.constrain_gas_lookup(clk, OpCode::SSTORE); main_trace.push_back(row); + side_effect_counter++; } /** diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp index e0c06ac4ba0..e1a9dc952c0 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp @@ -253,11 +253,10 @@ class AvmTraceBuilder { * @param write_value - The value to be written into the result - in all instances this is used - it is a boolean * @return Row */ - // TODO: update info + // TODO: update info -> really to do with when a hint is used Row create_kernel_output_opcode_with_set_metadata_output(uint32_t clk, uint32_t data_offset, - uint32_t metadata_offset, - std::unordered_map const& exists_hint); + uint32_t metadata_offset); void finalise_mem_trace_lookup_counts(); @@ -269,6 +268,10 @@ class AvmTraceBuilder { 0; // After a nested call, it should be initialized with MAX_SIZE_INTERNAL_STACK * call_ptr uint8_t call_ptr = 0; + // Side effect counter will incremenent when any state writing values are + // encountered + uint32_t side_effect_counter = 0; + // TODO: more info // Execution hints aid witness solving for instructions that require auxiliary information to construct ExecutionHints execution_hints; diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp index ee53c2e7fd2..6e6b1239423 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp @@ -1667,7 +1667,7 @@ TEST_F(AvmExecutionTests, kernelOutputStorageOpcodes) // Generate Hint for Sload operation ExecutionHints execution_hints = {}; - execution_hints.storage_values[FF(9)] = FF(42); // Slot 9 = value 42 + execution_hints[0] = FF(42); // side effect counter 0 = value 42 auto trace = Execution::gen_trace(instructions, returndata, calldata, public_inputs_vec, execution_hints); @@ -1746,9 +1746,9 @@ TEST_F(AvmExecutionTests, kernelOutputHashExistsOpcodes) // Generate Hint for Sload operation ExecutionHints execution_hints = {}; - execution_hints.note_hash_exists[FF(1)] = true; // Slot 1 = true - execution_hints.nullifier_exists[FF(1)] = true; // Slot 1 = true - execution_hints.l1_to_l2_msg_exists[FF(1)] = true; // Slot 1 = true + execution_hints[0] = 1; // Side effect counter 0 = true + execution_hints[1] = 1; // Side effect counter 1 = true + execution_hints[2] = 1; // Side effect counter 2 = true auto trace = Execution::gen_trace(instructions, returndata, calldata, public_inputs_vec, execution_hints); diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp index 6731c182cb1..36b56212873 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp @@ -765,7 +765,7 @@ TEST_F(AvmKernelOutputPositiveTests, kernelSload) // Provide a hint for sload value slot ExecutionHints execution_hints; - execution_hints.storage_values[FF(slot)] = FF(value); + execution_hints[0] = FF(value); // side effect counter -> value auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_set(0, static_cast(slot), slot_offset, AvmMemoryTag::FF); @@ -840,7 +840,7 @@ TEST_F(AvmKernelOutputPositiveTests, kernelNoteHashExists) auto exists = 1; ExecutionHints execution_hints = {}; - execution_hints.note_hash_exists[FF(value)] = static_cast(exists); + execution_hints[0] = exists; // side effect counter -> value auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_set(0, static_cast(value), value_offset, AvmMemoryTag::FF); @@ -879,7 +879,7 @@ TEST_F(AvmKernelOutputPositiveTests, kernelNullifierExists) auto exists = 1; ExecutionHints execution_hints = {}; - execution_hints.nullifier_exists[FF(value)] = static_cast(exists); + execution_hints[0] = exists; // side effect counter -> value auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_set(0, static_cast(value), value_offset, AvmMemoryTag::FF); @@ -918,7 +918,7 @@ TEST_F(AvmKernelOutputPositiveTests, kernelL1ToL2MsgExists) // Create an execution hints object with the result of the operation ExecutionHints execution_hints = {}; - execution_hints.l1_to_l2_msg_exists[FF(value)] = static_cast(exists); + execution_hints[0] = exists; auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_set(0, static_cast(value), value_offset, AvmMemoryTag::FF); From aca948c4e9a93a49503993ef164d8d959c6bab93 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Mon, 3 Jun 2024 15:14:58 +0000 Subject: [PATCH 13/20] chore: rebase fix, update constants --- .../vm/avm_trace/aztec_constants.hpp | 74 ++++++++----------- .../circuits.js/src/scripts/constants.in.ts | 1 + 2 files changed, 32 insertions(+), 43 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/aztec_constants.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/aztec_constants.hpp index 2f2bfe59682..c6ea15ba1ea 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/aztec_constants.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/aztec_constants.hpp @@ -1,46 +1,34 @@ // GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants in circuits.js #pragma once -const size_t MAX_NEW_NOTE_HASHES_PER_CALL = 16; -const size_t MAX_NEW_NULLIFIERS_PER_CALL = 16; -const size_t MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL = 16; -const size_t MAX_NEW_L2_TO_L1_MSGS_PER_CALL = 2; -const size_t MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL = 32; -const size_t MAX_PUBLIC_DATA_READS_PER_CALL = 16; -const size_t MAX_NOTE_HASH_READ_REQUESTS_PER_CALL = 32; -const size_t MAX_NULLIFIER_READ_REQUESTS_PER_CALL = 32; -const size_t MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL = 32; -const size_t MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL = 16; -const size_t MAX_UNENCRYPTED_LOGS_PER_CALL = 4; -const size_t AZTEC_ADDRESS_LENGTH = 1; -const size_t GAS_FEES_LENGTH = 2; -const size_t GAS_LENGTH = 2; -const size_t CALL_CONTEXT_LENGTH = 6; -const size_t CONTENT_COMMITMENT_LENGTH = 4; -const size_t CONTRACT_STORAGE_READ_LENGTH = 2; -const size_t CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH = 3; -const size_t GLOBAL_VARIABLES_LENGTH = 6 + GAS_FEES_LENGTH; -const size_t APPEND_ONLY_TREE_SNAPSHOT_LENGTH = 2; -const size_t L2_TO_L1_MESSAGE_LENGTH = 3; -const size_t PARTIAL_STATE_REFERENCE_LENGTH = 6; -const size_t READ_REQUEST_LENGTH = 2; -const size_t LOG_HASH_LENGTH = 3; -const size_t NOTE_HASH_LENGTH = 2; -const size_t NULLIFIER_LENGTH = 3; -const size_t STATE_REFERENCE_LENGTH = APPEND_ONLY_TREE_SNAPSHOT_LENGTH + PARTIAL_STATE_REFERENCE_LENGTH; -const size_t TOTAL_FEES_LENGTH = 1; -const size_t HEADER_LENGTH = APPEND_ONLY_TREE_SNAPSHOT_LENGTH + CONTENT_COMMITMENT_LENGTH + STATE_REFERENCE_LENGTH + - GLOBAL_VARIABLES_LENGTH + TOTAL_FEES_LENGTH; -const size_t PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH = - CALL_CONTEXT_LENGTH + /*argsHash + returnsHash*/ 2 + (READ_REQUEST_LENGTH * MAX_NOTE_HASH_READ_REQUESTS_PER_CALL) + - (READ_REQUEST_LENGTH * MAX_NULLIFIER_READ_REQUESTS_PER_CALL) + - (READ_REQUEST_LENGTH * MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL) + - (READ_REQUEST_LENGTH * MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL) + - (CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH * MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL) + - (CONTRACT_STORAGE_READ_LENGTH * MAX_PUBLIC_DATA_READS_PER_CALL) + MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL + - (NOTE_HASH_LENGTH * MAX_NEW_NOTE_HASHES_PER_CALL) + (NULLIFIER_LENGTH * MAX_NEW_NULLIFIERS_PER_CALL) + - (L2_TO_L1_MESSAGE_LENGTH * MAX_NEW_L2_TO_L1_MSGS_PER_CALL) + 2 + (LOG_HASH_LENGTH * MAX_UNENCRYPTED_LOGS_PER_CALL) + - HEADER_LENGTH + GLOBAL_VARIABLES_LENGTH + AZTEC_ADDRESS_LENGTH + /* revert_code */ 1 + 2 * GAS_LENGTH + - /* transaction_fee */ 1; -const size_t PUBLIC_CONTEXT_INPUTS_LENGTH = - CALL_CONTEXT_LENGTH + HEADER_LENGTH + GLOBAL_VARIABLES_LENGTH + GAS_LENGTH + 2; +#define MAX_NEW_NOTE_HASHES_PER_CALL 16 +#define MAX_NEW_NULLIFIERS_PER_CALL 16 +#define MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL 16 +#define MAX_NEW_L2_TO_L1_MSGS_PER_CALL 2 +#define MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL 32 +#define MAX_PUBLIC_DATA_READS_PER_CALL 16 +#define MAX_NOTE_HASH_READ_REQUESTS_PER_CALL 32 +#define MAX_NULLIFIER_READ_REQUESTS_PER_CALL 32 +#define MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL 32 +#define MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL 16 +#define MAX_UNENCRYPTED_LOGS_PER_CALL 4 +#define AZTEC_ADDRESS_LENGTH 1 +#define GAS_FEES_LENGTH 2 +#define GAS_LENGTH 2 +#define CALL_CONTEXT_LENGTH 6 +#define CONTENT_COMMITMENT_LENGTH 4 +#define CONTRACT_STORAGE_READ_LENGTH 2 +#define CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH 3 +#define GLOBAL_VARIABLES_LENGTH 8 +#define APPEND_ONLY_TREE_SNAPSHOT_LENGTH 2 +#define L2_TO_L1_MESSAGE_LENGTH 3 +#define PARTIAL_STATE_REFERENCE_LENGTH 6 +#define READ_REQUEST_LENGTH 2 +#define LOG_HASH_LENGTH 3 +#define NOTE_HASH_LENGTH 2 +#define NULLIFIER_LENGTH 3 +#define STATE_REFERENCE_LENGTH 8 +#define TOTAL_FEES_LENGTH 1 +#define HEADER_LENGTH 23 +#define PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH 514 +#define PUBLIC_CONTEXT_INPUTS_LENGTH 41 diff --git a/yarn-project/circuits.js/src/scripts/constants.in.ts b/yarn-project/circuits.js/src/scripts/constants.in.ts index 11b606b16a8..da2f6d4f221 100644 --- a/yarn-project/circuits.js/src/scripts/constants.in.ts +++ b/yarn-project/circuits.js/src/scripts/constants.in.ts @@ -25,6 +25,7 @@ const CPP_CONSTANTS = [ 'READ_REQUEST_LENGTH', 'MAX_NOTE_HASH_READ_REQUESTS_PER_CALL', 'MAX_NULLIFIER_READ_REQUESTS_PER_CALL', + 'MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL', 'MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL', 'CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH', 'MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL', From c4816e7442c828a8569f20b59111bfc2c3857525 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Mon, 3 Jun 2024 15:39:34 +0000 Subject: [PATCH 14/20] fix: generalise sload --- .../barretenberg/vm/avm_trace/avm_helper.cpp | 64 ++++++------- .../barretenberg/vm/avm_trace/avm_trace.cpp | 95 ++++++++++++------- .../barretenberg/vm/avm_trace/avm_trace.hpp | 8 +- 3 files changed, 92 insertions(+), 75 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp index 207d03175e0..900ef90f7a9 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp @@ -43,11 +43,11 @@ void log_avm_trace(std::vector const& trace, size_t beg, size_t end, bool e info("internal_return: ", trace.at(i).avm_main_sel_internal_return); info("internal_return_ptr:", trace.at(i).avm_main_internal_return_ptr); - // info("=======ALU TRACE====================================================================="); - // info("alu_clk ", trace.at(i).avm_alu_clk); - // info("alu_ia ", trace.at(i).avm_alu_ia); - // info("alu_ib ", trace.at(i).avm_alu_ib); - // info("alu_ic ", trace.at(i).avm_alu_ic); + info("=======ALU TRACE====================================================================="); + info("alu_clk ", trace.at(i).avm_alu_clk); + info("alu_ia ", trace.at(i).avm_alu_ia); + info("alu_ib ", trace.at(i).avm_alu_ib); + info("alu_ic ", trace.at(i).avm_alu_ic); info("=======MAIN TRACE===================================================================="); info("clk: ", trace.at(i).avm_main_clk); @@ -60,28 +60,23 @@ void log_avm_trace(std::vector const& trace, size_t beg, size_t end, bool e info("first: ", trace.at(i).avm_main_first); info("last: ", trace.at(i).avm_main_last); - // info("=======MEM_OP_A======================================================================"); - // info("mem_op_a: ", trace.at(i).avm_main_mem_op_a); - // info("mem_idx_a: ", trace.at(i).avm_main_mem_idx_a); - // info("rwa: ", trace.at(i).avm_main_rwa); - - // info("=======MEM_OP_B======================================================================"); - // info("mem_op_b: ", trace.at(i).avm_main_mem_op_b); - // info("mem_idx_b: ", trace.at(i).avm_main_mem_idx_b); - // info("rwb: ", trace.at(i).avm_main_rwb); - - // info("=======MEM_OP_C======================================================================"); - // info("mem_op_c: ", trace.at(i).avm_main_mem_op_c); - // info("mem_idx_c: ", trace.at(i).avm_main_mem_idx_c); - // info("rwc: ", trace.at(i).avm_main_rwc); - // info("diff_hi: ", trace.at(i).avm_mem_diff_hi); - // info("diff_mid: ", trace.at(i).avm_mem_diff_mid); - // info("diff_lo: ", trace.at(i).avm_mem_diff_lo); - - info("=======OUT_CONSISTENCY======================================================================"); - info("note_hash_write: ", trace.at(i).avm_kernel_emit_note_hash_write_offset); - info("nullifier_write: ", trace.at(i).avm_kernel_emit_nullifier_write_offset); - info("unencrypted_write: ", trace.at(i).avm_kernel_emit_unencrypted_log_write_offset); + info("=======MEM_OP_A======================================================================"); + info("mem_op_a: ", trace.at(i).avm_main_mem_op_a); + info("mem_idx_a: ", trace.at(i).avm_main_mem_idx_a); + info("rwa: ", trace.at(i).avm_main_rwa); + + info("=======MEM_OP_B======================================================================"); + info("mem_op_b: ", trace.at(i).avm_main_mem_op_b); + info("mem_idx_b: ", trace.at(i).avm_main_mem_idx_b); + info("rwb: ", trace.at(i).avm_main_rwb); + + info("=======MEM_OP_C======================================================================"); + info("mem_op_c: ", trace.at(i).avm_main_mem_op_c); + info("mem_idx_c: ", trace.at(i).avm_main_mem_idx_c); + info("rwc: ", trace.at(i).avm_main_rwc); + info("diff_hi: ", trace.at(i).avm_mem_diff_hi); + info("diff_mid: ", trace.at(i).avm_mem_diff_mid); + info("diff_lo: ", trace.at(i).avm_mem_diff_lo); info("=======GAS ACCOUNTING================================================================"); info("opcode active: ", trace.at(i).avm_main_gas_cost_active); @@ -92,15 +87,12 @@ void log_avm_trace(std::vector const& trace, size_t beg, size_t end, bool e if (enable_selectors) { info("=======SELECTORS======================================================================"); - info("sel_op_emit_note_hash: ", trace.at(i).avm_main_sel_op_emit_note_hash); - info("sel_op_emit_nullifier: ", trace.at(i).avm_main_sel_op_emit_nullifier); - info("sel_op_emit_unencryped_log: ", trace.at(i).avm_main_sel_op_emit_unencrypted_log); - // info("sel_op_add: ", trace.at(i).avm_main_sel_op_add); - // info("sel_op_sub: ", trace.at(i).avm_main_sel_op_sub); - // info("sel_op_mul: ", trace.at(i).avm_main_sel_op_mul); - // info("sel_op_eq: ", trace.at(i).avm_main_sel_op_eq); - // info("sel_op_not: ", trace.at(i).avm_main_sel_op_not); - // info("sel_op_sel_alu: ", trace.at(i).avm_main_alu_sel); + info("sel_op_add: ", trace.at(i).avm_main_sel_op_add); + info("sel_op_sub: ", trace.at(i).avm_main_sel_op_sub); + info("sel_op_mul: ", trace.at(i).avm_main_sel_op_mul); + info("sel_op_eq: ", trace.at(i).avm_main_sel_op_eq); + info("sel_op_not: ", trace.at(i).avm_main_sel_op_not); + info("sel_op_sel_alu: ", trace.at(i).avm_main_alu_sel); } info("\n"); } diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp index 745d170691d..68c316aade8 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp @@ -1334,50 +1334,83 @@ Row AvmTraceBuilder::create_kernel_output_opcode_with_metadata( } // TODO: fix the naming here - we need it to be different as we are writing a hint -Row AvmTraceBuilder::create_sload( - uint32_t clk, uint32_t data_offset, FF const& data_value, FF const& slot_value, uint32_t slot_offset) +// Row AvmTraceBuilder::create_sload( +// uint32_t clk, uint32_t data_offset, FF const& data_value, FF const& slot_value, uint32_t slot_offset) +// { +// // We write the sload into memory, where the sload is an injected value that is mapped to the public inputs +// mem_trace_builder.write_into_memory( +// call_ptr, clk, IntermRegister::IA, data_offset, data_value, AvmMemoryTag::FF, AvmMemoryTag::FF); + +// return Row{ +// .avm_main_clk = clk, +// .avm_main_ia = data_value, +// .avm_main_ib = slot_value, +// .avm_main_ind_a = 0, +// .avm_main_ind_b = 0, +// .avm_main_internal_return_ptr = internal_return_ptr, +// .avm_main_mem_idx_a = data_offset, +// .avm_main_mem_idx_b = slot_offset, +// .avm_main_mem_op_a = 1, +// .avm_main_mem_op_b = 1, +// .avm_main_pc = pc++, +// .avm_main_q_kernel_output_lookup = 1, +// .avm_main_r_in_tag = static_cast(AvmMemoryTag::FF), +// .avm_main_rwa = 1, +// .avm_main_rwb = 0, +// .avm_main_w_in_tag = static_cast(AvmMemoryTag::FF), +// }; +// } + +Row AvmTraceBuilder::create_kernel_output_opcode_with_set_metadata_output_from_hint(uint32_t clk, + uint32_t data_offset, + uint32_t metadata_offset) { - // We write the sload into memory, where the sload is an injected value that is mapped to the public inputs + AvmMemTraceBuilder::MemRead read_a = mem_trace_builder.read_and_load_from_memory( + call_ptr, clk, IntermRegister::IA, data_offset, AvmMemoryTag::FF, AvmMemoryTag::U8); + + FF exists = execution_hints.at(side_effect_counter); + // TODO: throw error if incorrect + mem_trace_builder.write_into_memory( - call_ptr, clk, IntermRegister::IA, data_offset, data_value, AvmMemoryTag::FF, AvmMemoryTag::FF); + call_ptr, clk, IntermRegister::IB, metadata_offset, exists, AvmMemoryTag::FF, AvmMemoryTag::U8); return Row{ .avm_main_clk = clk, - .avm_main_ia = data_value, - .avm_main_ib = slot_value, + .avm_main_ia = read_a.val, + .avm_main_ib = exists, .avm_main_ind_a = 0, .avm_main_ind_b = 0, .avm_main_internal_return_ptr = internal_return_ptr, .avm_main_mem_idx_a = data_offset, - .avm_main_mem_idx_b = slot_offset, + .avm_main_mem_idx_b = metadata_offset, .avm_main_mem_op_a = 1, .avm_main_mem_op_b = 1, .avm_main_pc = pc++, .avm_main_q_kernel_output_lookup = 1, .avm_main_r_in_tag = static_cast(AvmMemoryTag::FF), - .avm_main_rwa = 1, - .avm_main_rwb = 0, - .avm_main_w_in_tag = static_cast(AvmMemoryTag::FF), + .avm_main_rwa = 0, + .avm_main_rwb = 1, + .avm_main_w_in_tag = static_cast(AvmMemoryTag::U8), }; } -Row AvmTraceBuilder::create_kernel_output_opcode_with_set_metadata_output(uint32_t clk, +Row AvmTraceBuilder::create_kernel_output_opcode_with_set_value_from_hint(uint32_t clk, uint32_t data_offset, uint32_t metadata_offset) { - AvmMemTraceBuilder::MemRead read_a = mem_trace_builder.read_and_load_from_memory( - call_ptr, clk, IntermRegister::IA, data_offset, AvmMemoryTag::FF, AvmMemoryTag::U8); - - FF exists = execution_hints.at(side_effect_counter); + FF value = execution_hints.at(side_effect_counter); // TODO: throw error if incorrect mem_trace_builder.write_into_memory( - call_ptr, clk, IntermRegister::IB, metadata_offset, exists, AvmMemoryTag::FF, AvmMemoryTag::U8); + call_ptr, clk, IntermRegister::IA, data_offset, value, AvmMemoryTag::FF, AvmMemoryTag::FF); + + AvmMemTraceBuilder::MemRead read_b = mem_trace_builder.read_and_load_from_memory( + call_ptr, clk, IntermRegister::IB, metadata_offset, AvmMemoryTag::FF, AvmMemoryTag::FF); return Row{ .avm_main_clk = clk, - .avm_main_ia = read_a.val, - .avm_main_ib = exists, + .avm_main_ia = value, + .avm_main_ib = read_b.val, .avm_main_ind_a = 0, .avm_main_ind_b = 0, .avm_main_internal_return_ptr = internal_return_ptr, @@ -1388,9 +1421,9 @@ Row AvmTraceBuilder::create_kernel_output_opcode_with_set_metadata_output(uint32 .avm_main_pc = pc++, .avm_main_q_kernel_output_lookup = 1, .avm_main_r_in_tag = static_cast(AvmMemoryTag::FF), - .avm_main_rwa = 0, - .avm_main_rwb = 1, - .avm_main_w_in_tag = static_cast(AvmMemoryTag::U8), + .avm_main_rwa = 1, + .avm_main_rwb = 0, + .avm_main_w_in_tag = static_cast(AvmMemoryTag::FF), }; } @@ -1459,7 +1492,7 @@ void AvmTraceBuilder::op_l1_to_l2_msg_exists(uint32_t log_offset, uint32_t dest_ { auto const clk = static_cast(main_trace.size()) + 1; - Row row = create_kernel_output_opcode_with_set_metadata_output(clk, log_offset, dest_offset); + Row row = create_kernel_output_opcode_with_set_metadata_output_from_hint(clk, log_offset, dest_offset); kernel_trace_builder.op_l1_to_l2_msg_exists( clk, side_effect_counter, row.avm_main_ia, /*safe*/ static_cast(row.avm_main_ib)); row.avm_main_sel_op_l1_to_l2_msg_exists = FF(1); @@ -1475,7 +1508,7 @@ void AvmTraceBuilder::op_note_hash_exists(uint32_t note_offset, uint32_t dest_of { auto const clk = static_cast(main_trace.size()) + 1; - Row row = create_kernel_output_opcode_with_set_metadata_output(clk, note_offset, dest_offset); + Row row = create_kernel_output_opcode_with_set_metadata_output_from_hint(clk, note_offset, dest_offset); kernel_trace_builder.op_note_hash_exists( clk, side_effect_counter, row.avm_main_ia, /*safe*/ static_cast(row.avm_main_ib)); row.avm_main_sel_op_l1_to_l2_msg_exists = FF(1); @@ -1491,7 +1524,7 @@ void AvmTraceBuilder::op_nullifier_exists(uint32_t note_offset, uint32_t dest_of { auto const clk = static_cast(main_trace.size()) + 1; - Row row = create_kernel_output_opcode_with_set_metadata_output(clk, note_offset, dest_offset); + Row row = create_kernel_output_opcode_with_set_metadata_output_from_hint(clk, note_offset, dest_offset); kernel_trace_builder.op_nullifier_exists( clk, side_effect_counter, row.avm_main_ia, /*safe*/ static_cast(row.avm_main_ib)); row.avm_main_sel_op_nullifier_exists = FF(1); @@ -1508,17 +1541,9 @@ void AvmTraceBuilder::op_sload(uint32_t slot_offset, uint32_t write_offset) auto const clk = static_cast(main_trace.size()) + 1; // Read the slot - AvmMemTraceBuilder::MemRead slot_read = mem_trace_builder.read_and_load_from_memory( - call_ptr, clk, IntermRegister::IB, slot_offset, AvmMemoryTag::FF, AvmMemoryTag::FF); - - // Get the data value from the execution_hints - // TODO: for now the hints are being offset by the offset - this will NOT fly, but i struggled to get the hash - // working for FF - FF value = execution_hints.at(side_effect_counter); - // TODO: throw error if the hint does not exist - - Row row = create_sload(clk, write_offset, value, slot_read.val, slot_offset); - kernel_trace_builder.op_sload(clk, side_effect_counter, row.avm_main_ib, value); + Row row = create_kernel_output_opcode_with_set_value_from_hint(clk, write_offset, slot_offset); + // Row row = create_sload(clk, write_offset, value, slot_read.val, slot_offset); + kernel_trace_builder.op_sload(clk, side_effect_counter, row.avm_main_ib, row.avm_main_ia); row.avm_main_sel_op_sload = FF(1); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp index e1a9dc952c0..5d254a55c8f 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp @@ -254,7 +254,10 @@ class AvmTraceBuilder { * @return Row */ // TODO: update info -> really to do with when a hint is used - Row create_kernel_output_opcode_with_set_metadata_output(uint32_t clk, + Row create_kernel_output_opcode_with_set_metadata_output_from_hint(uint32_t clk, + uint32_t data_offset, + uint32_t metadata_offset); + Row create_kernel_output_opcode_with_set_value_from_hint(uint32_t clk, uint32_t data_offset, uint32_t metadata_offset); @@ -276,9 +279,6 @@ class AvmTraceBuilder { // Execution hints aid witness solving for instructions that require auxiliary information to construct ExecutionHints execution_hints; - Row create_sload( - uint32_t clk, uint32_t data_offset, FF const& data_value, FF const& slot_value, uint32_t solt_offset); - // TODO(ilyas: #6383): Temporary way to bulk read slices template uint32_t read_slice_to_memory(uint8_t space_id, From 390ec2d87ebd7368c53bc7916154160415f30a9e Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Mon, 3 Jun 2024 15:49:04 +0000 Subject: [PATCH 15/20] chore: cleanup kernel test --- .../barretenberg/vm/tests/avm_kernel.test.cpp | 50 ++++--------------- 1 file changed, 9 insertions(+), 41 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp index 36b56212873..b17cbc308a2 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp @@ -79,7 +79,8 @@ void expect_output_table_row(std::vector::const_iterator row, FF ia, FF mem_idx_a, AvmMemoryTag r_in_tag, - uint32_t side_effect_counter) + uint32_t side_effect_counter, + uint32_t rwa = 0) { // Checks dependent on the opcode EXPECT_EQ(row->avm_kernel_kernel_out_offset, selector); @@ -87,7 +88,7 @@ void expect_output_table_row(std::vector::const_iterator row, EXPECT_EQ(row->avm_main_mem_idx_a, mem_idx_a); // Checks that are fixed for kernel inputs - EXPECT_EQ(row->avm_main_rwa, FF(0)); + EXPECT_EQ(row->avm_main_rwa, FF(rwa)); EXPECT_EQ(row->avm_main_ind_a, FF(0)); EXPECT_EQ(row->avm_main_mem_op_a, FF(1)); EXPECT_EQ(row->avm_main_r_in_tag, static_cast(r_in_tag)); @@ -103,43 +104,10 @@ void expect_output_table_row_with_metadata(std::vector::const_iterator row, FF ib, FF mem_idx_b, AvmMemoryTag r_in_tag, - uint32_t side_effect_counter) + uint32_t side_effect_counter, + uint32_t rwa = 0) { - expect_output_table_row(row, selector, ia, mem_idx_a, r_in_tag, side_effect_counter); - - EXPECT_EQ(row->avm_main_ib, ib); - EXPECT_EQ(row->avm_main_mem_idx_b, mem_idx_b); - - // Checks that are fixed for kernel inputs - EXPECT_EQ(row->avm_main_rwb, FF(0)); - EXPECT_EQ(row->avm_main_ind_b, FF(0)); - EXPECT_EQ(row->avm_main_mem_op_b, FF(1)); -} - -// TODO: rework - temporary for PoC -void expect_output_table_row_with_metadata_hint(std::vector::const_iterator row, - FF selector, - FF ia, - FF mem_idx_a, - FF ib, - FF mem_idx_b, - AvmMemoryTag r_in_tag, - uint32_t side_effect_counter) -{ - // Checks dependent on the opcode - EXPECT_EQ(row->avm_kernel_kernel_out_offset, selector); - EXPECT_EQ(row->avm_main_ia, ia); - EXPECT_EQ(row->avm_main_mem_idx_a, mem_idx_a); - - // Checks that are fixed for kernel inputs - EXPECT_EQ(row->avm_main_rwa, FF(1)); - EXPECT_EQ(row->avm_main_ind_a, FF(0)); - EXPECT_EQ(row->avm_main_mem_op_a, FF(1)); - EXPECT_EQ(row->avm_main_w_in_tag, static_cast(r_in_tag)); - EXPECT_EQ(row->avm_main_r_in_tag, static_cast(r_in_tag)); - EXPECT_EQ(row->avm_main_q_kernel_output_lookup, FF(1)); - - EXPECT_EQ(row->avm_kernel_side_effect_counter, FF(side_effect_counter)); + expect_output_table_row(row, selector, ia, mem_idx_a, r_in_tag, side_effect_counter, rwa); EXPECT_EQ(row->avm_main_ib, ib); EXPECT_EQ(row->avm_main_mem_idx_b, mem_idx_b); @@ -779,8 +747,7 @@ TEST_F(AvmKernelOutputPositiveTests, kernelSload) // Check the outputs of the trace uint32_t output_offset = AvmKernelTraceBuilder::START_SLOAD_WRITE_OFFSET; - // TODO: unify this with the existing metadata checking thing - it should not be different - expect_output_table_row_with_metadata_hint( + expect_output_table_row_with_metadata( row, /*kernel_in_offset=*/output_offset, /*ia=*/value, // Note the value generated above for public inputs is the same as the index read + 1 @@ -788,7 +755,8 @@ TEST_F(AvmKernelOutputPositiveTests, kernelSload) /*ib=*/slot, /*mem_idx_b=*/slot_offset, /*w_in_tag=*/AvmMemoryTag::FF, - /*side_effect_counter=*/0); + /*side_effect_counter=*/0, + /*rwa=*/1); check_kernel_outputs(trace.at(output_offset), value, /*side_effect_counter=*/0, slot); }; From c5298427c38449f5a55e2ab03ab0b21831aa167d Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Mon, 3 Jun 2024 15:57:54 +0000 Subject: [PATCH 16/20] chore: revert bb main.cpp changes --- barretenberg/cpp/src/barretenberg/bb/main.cpp | 23 ++----------------- .../barretenberg/vm/avm_trace/avm_trace.hpp | 19 +++++++++++---- 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/bb/main.cpp b/barretenberg/cpp/src/barretenberg/bb/main.cpp index 521eea432cc..ec7da2a62ea 100644 --- a/barretenberg/cpp/src/barretenberg/bb/main.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/main.cpp @@ -521,8 +521,6 @@ void vk_as_fields(const std::string& vk_path, const std::string& output_path) */ void avm_prove(const std::filesystem::path& bytecode_path, const std::filesystem::path& calldata_path, - const std::filesystem::path& public_inputs_path, - const std::filesystem::path& hints_path, const std::filesystem::path& output_path) { // Get Bytecode @@ -534,26 +532,11 @@ void avm_prove(const std::filesystem::path& bytecode_path, } std::vector const call_data = many_from_buffer(call_data_bytes); - std::vector public_inputs_bytes{}; - if (std::filesystem::exists(public_inputs_path)) { - public_inputs_bytes = read_file(public_inputs_path); - } - std::vector const public_inputs_vec = many_from_buffer(public_inputs_bytes); - - std::vector hints_bytes{}; - if (std::filesystem::exists(hints_path)) { - hints_bytes = read_file(hints_path); - } - - // ExecutionHints const execution_hints = ExecutionHints::from_buffer(hints_bytes); - // ExecutionHints const execution_hints = {}; - // Hardcoded circuit size for now, with enough to support 16-bit range checks init_bn254_crs(1 << 17); // Prove execution and return vk - auto const [verification_key, proof] = - avm_trace::Execution::prove(avm_bytecode, call_data, public_inputs_vec /*, execution_hints*/); + auto const [verification_key, proof] = avm_trace::Execution::prove(avm_bytecode, call_data); // TODO(ilyas): <#4887>: Currently we only need these two parts of the vk, look into pcs_verification key reqs std::vector vk_vector = { verification_key.circuit_size, verification_key.num_public_inputs }; std::vector vk_as_fields = { verification_key.circuit_size, verification_key.num_public_inputs }; @@ -910,11 +893,9 @@ int main(int argc, char* argv[]) } else if (command == "avm_prove") { std::filesystem::path avm_bytecode_path = get_option(args, "-b", "./target/avm_bytecode.bin"); std::filesystem::path calldata_path = get_option(args, "-d", "./target/call_data.bin"); - std::filesystem::path public_inputs_path = get_option(args, "-u", "./target/public_inputs.bin"); - std::filesystem::path execution_hints_path = get_option(args, "-e", "./target/execution_hints.bin"); // This outputs both files: proof and vk, under the given directory. std::filesystem::path output_path = get_option(args, "-o", "./proofs"); - avm_prove(avm_bytecode_path, calldata_path, public_inputs_path, execution_hints_path, output_path); + avm_prove(avm_bytecode_path, calldata_path, output_path); } else if (command == "avm_verify") { return avm_verify(proof_path, vk_path) ? 0 : 1; } else if (command == "prove_ultra_honk") { diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp index 5d254a55c8f..dcb4c370b33 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp @@ -243,20 +243,29 @@ class AvmTraceBuilder { /** * @brief Create a kernel output opcode with set metadata output object * - * Used for writing output opcode where one value is written and comes from a hint + * Used for writing output opcode where one metadata value is written and comes from a hint * {note_hash_exists, nullifier_exists, etc. } Where a boolean output if it exists must also be written * * @param clk - The trace clk * @param data_offset - The offset of the main value to output - * @param data_r_tag - The data type of the value * @param metadata_offset - The offset of the metadata (slot in the sload example) - * @param write_value - The value to be written into the result - in all instances this is used - it is a boolean * @return Row */ - // TODO: update info -> really to do with when a hint is used Row create_kernel_output_opcode_with_set_metadata_output_from_hint(uint32_t clk, uint32_t data_offset, uint32_t metadata_offset); + + /** + * @brief Create a kernel output opcode with set metadata output object + * + * Used for writing output opcode where one value is written and comes from a hint + * {sload} + * + * @param clk - The trace clk + * @param data_offset - The offset of the main value to output + * @param metadata_offset - The offset of the metadata (slot in the sload example) + * @return Row + */ Row create_kernel_output_opcode_with_set_value_from_hint(uint32_t clk, uint32_t data_offset, uint32_t metadata_offset); @@ -275,8 +284,8 @@ class AvmTraceBuilder { // encountered uint32_t side_effect_counter = 0; - // TODO: more info // Execution hints aid witness solving for instructions that require auxiliary information to construct + // Mapping of side effect counter -> value ExecutionHints execution_hints; // TODO(ilyas: #6383): Temporary way to bulk read slices From 36060f1f46fbc13f62fbed968cb1bbc270e1762d Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Mon, 3 Jun 2024 16:37:21 +0000 Subject: [PATCH 17/20] fix: gcc build error - no int cast --- .../barretenberg/vm/avm_trace/avm_trace.cpp | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp index 68c316aade8..c63a6a7e0ad 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp @@ -3693,23 +3693,21 @@ std::vector AvmTraceBuilder::finalize(uint32_t min_trace_size, bool range_c // Increment the write offset counter for the following row next.avm_kernel_note_hash_exist_write_offset = - curr.avm_kernel_note_hash_exist_write_offset + static_cast(src.op_note_hash_exists); + curr.avm_kernel_note_hash_exist_write_offset + static_cast(src.op_note_hash_exists); next.avm_kernel_emit_note_hash_write_offset = - curr.avm_kernel_emit_note_hash_write_offset + static_cast(src.op_emit_note_hash); + curr.avm_kernel_emit_note_hash_write_offset + static_cast(src.op_emit_note_hash); next.avm_kernel_emit_nullifier_write_offset = - curr.avm_kernel_emit_nullifier_write_offset + static_cast(src.op_emit_nullifier); + curr.avm_kernel_emit_nullifier_write_offset + static_cast(src.op_emit_nullifier); next.avm_kernel_nullifier_exists_write_offset = - curr.avm_kernel_nullifier_exists_write_offset + static_cast(src.op_nullifier_exists); + curr.avm_kernel_nullifier_exists_write_offset + static_cast(src.op_nullifier_exists); next.avm_kernel_l1_to_l2_msg_exists_write_offset = - curr.avm_kernel_l1_to_l2_msg_exists_write_offset + static_cast(src.op_l1_to_l2_msg_exists); + curr.avm_kernel_l1_to_l2_msg_exists_write_offset + static_cast(src.op_l1_to_l2_msg_exists); next.avm_kernel_emit_l2_to_l1_msg_write_offset = - curr.avm_kernel_emit_l2_to_l1_msg_write_offset + static_cast(src.op_emit_l2_to_l1_msg); + curr.avm_kernel_emit_l2_to_l1_msg_write_offset + static_cast(src.op_emit_l2_to_l1_msg); next.avm_kernel_emit_unencrypted_log_write_offset = - curr.avm_kernel_emit_unencrypted_log_write_offset + static_cast(src.op_emit_unencrypted_log); - next.avm_kernel_sload_write_offset = - curr.avm_kernel_sload_write_offset + static_cast(src.op_sload); - next.avm_kernel_sstore_write_offset = - curr.avm_kernel_sstore_write_offset + static_cast(src.op_sstore); + curr.avm_kernel_emit_unencrypted_log_write_offset + static_cast(src.op_emit_unencrypted_log); + next.avm_kernel_sload_write_offset = curr.avm_kernel_sload_write_offset + static_cast(src.op_sload); + next.avm_kernel_sstore_write_offset = curr.avm_kernel_sstore_write_offset + static_cast(src.op_sstore); // The side effect counter will increment regardless of the offset value next.avm_kernel_side_effect_counter = curr.avm_kernel_side_effect_counter + 1; From 5bd1ddb4c15b05f5a74b338bfbb874c263104b23 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Tue, 28 May 2024 16:06:43 +0000 Subject: [PATCH 18/20] feat: unconstrained op_call --- barretenberg/cpp/pil/avm/avm_main.pil | 4 +- barretenberg/cpp/pil/avm/constants.pil | 11 + .../relations/generated/avm/avm_alu.hpp | 2354 ++++++++--------- .../relations/generated/avm/avm_binary.hpp | 296 ++- .../generated/avm/avm_conversion.hpp | 65 +- .../generated/avm/avm_keccakf1600.hpp | 65 +- .../relations/generated/avm/avm_kernel.hpp | 332 +-- .../relations/generated/avm/avm_main.hpp | 376 +-- .../relations/generated/avm/avm_mem.hpp | 982 +++---- .../relations/generated/avm/avm_pedersen.hpp | 65 +- .../relations/generated/avm/avm_poseidon2.hpp | 65 +- .../relations/generated/avm/avm_sha256.hpp | 65 +- .../relations/generated/avm/declare_views.hpp | 1 + .../generated/avm/incl_main_tag_err.hpp | 317 +-- .../generated/avm/incl_mem_tag_err.hpp | 316 +-- .../generated/avm/kernel_output_lookup.hpp | 341 +-- .../generated/avm/lookup_byte_lengths.hpp | 325 +-- .../generated/avm/lookup_byte_operations.hpp | 341 +-- .../generated/avm/lookup_div_u16_0.hpp | 316 +-- .../generated/avm/lookup_div_u16_1.hpp | 316 +-- .../generated/avm/lookup_div_u16_2.hpp | 316 +-- .../generated/avm/lookup_div_u16_3.hpp | 316 +-- .../generated/avm/lookup_div_u16_4.hpp | 316 +-- .../generated/avm/lookup_div_u16_5.hpp | 316 +-- .../generated/avm/lookup_div_u16_6.hpp | 316 +-- .../generated/avm/lookup_div_u16_7.hpp | 316 +-- .../generated/avm/lookup_into_kernel.hpp | 325 +-- .../generated/avm/lookup_mem_rng_chk_hi.hpp | 317 +-- .../generated/avm/lookup_mem_rng_chk_lo.hpp | 317 +-- .../generated/avm/lookup_mem_rng_chk_mid.hpp | 317 +-- .../generated/avm/lookup_opcode_gas.hpp | 333 +-- .../generated/avm/lookup_pow_2_0.hpp | 324 +-- .../generated/avm/lookup_pow_2_1.hpp | 324 +-- .../relations/generated/avm/lookup_u16_0.hpp | 316 +-- .../relations/generated/avm/lookup_u16_1.hpp | 316 +-- .../relations/generated/avm/lookup_u16_10.hpp | 316 +-- .../relations/generated/avm/lookup_u16_11.hpp | 316 +-- .../relations/generated/avm/lookup_u16_12.hpp | 316 +-- .../relations/generated/avm/lookup_u16_13.hpp | 316 +-- .../relations/generated/avm/lookup_u16_14.hpp | 316 +-- .../relations/generated/avm/lookup_u16_2.hpp | 316 +-- .../relations/generated/avm/lookup_u16_3.hpp | 316 +-- .../relations/generated/avm/lookup_u16_4.hpp | 316 +-- .../relations/generated/avm/lookup_u16_5.hpp | 316 +-- .../relations/generated/avm/lookup_u16_6.hpp | 316 +-- .../relations/generated/avm/lookup_u16_7.hpp | 316 +-- .../relations/generated/avm/lookup_u16_8.hpp | 316 +-- .../relations/generated/avm/lookup_u16_9.hpp | 316 +-- .../relations/generated/avm/lookup_u8_0.hpp | 316 +-- .../relations/generated/avm/lookup_u8_1.hpp | 316 +-- .../relations/generated/avm/perm_main_alu.hpp | 295 ++- .../relations/generated/avm/perm_main_bin.hpp | 215 +- .../generated/avm/perm_main_conv.hpp | 199 +- .../generated/avm/perm_main_mem_a.hpp | 239 +- .../generated/avm/perm_main_mem_b.hpp | 239 +- .../generated/avm/perm_main_mem_c.hpp | 223 +- .../generated/avm/perm_main_mem_d.hpp | 231 +- .../generated/avm/perm_main_mem_ind_a.hpp | 199 +- .../generated/avm/perm_main_mem_ind_b.hpp | 199 +- .../generated/avm/perm_main_mem_ind_c.hpp | 199 +- .../generated/avm/perm_main_mem_ind_d.hpp | 199 +- .../generated/avm/perm_main_pedersen.hpp | 183 +- .../generated/avm/perm_main_pos2_perm.hpp | 191 +- .../barretenberg/vm/avm_trace/avm_common.hpp | 20 +- .../vm/avm_trace/avm_deserialization.cpp | 12 +- .../vm/avm_trace/avm_execution.cpp | 12 + .../barretenberg/vm/avm_trace/avm_helper.cpp | 64 +- .../barretenberg/vm/avm_trace/avm_trace.cpp | 132 +- .../barretenberg/vm/avm_trace/avm_trace.hpp | 12 + .../barretenberg/vm/avm_trace/constants.hpp | 4 +- .../vm/generated/avm_circuit_builder.hpp | 6 +- .../vm/generated/avm_composer.cpp | 12 +- .../vm/generated/avm_composer.hpp | 112 +- .../barretenberg/vm/generated/avm_flavor.hpp | 13 +- .../barretenberg/vm/generated/avm_prover.cpp | 3 + .../barretenberg/vm/generated/avm_prover.hpp | 111 +- .../vm/generated/avm_verifier.cpp | 2 + .../vm/generated/avm_verifier.hpp | 58 +- .../vm/tests/avm_execution.test.cpp | 81 +- .../barretenberg/vm/tests/avm_kernel.test.cpp | 10 +- .../circuits.js/src/scripts/constants.in.ts | 1 + 81 files changed, 10325 insertions(+), 9629 deletions(-) diff --git a/barretenberg/cpp/pil/avm/avm_main.pil b/barretenberg/cpp/pil/avm/avm_main.pil index cdcc2054211..8d62d03e8e1 100644 --- a/barretenberg/cpp/pil/avm/avm_main.pil +++ b/barretenberg/cpp/pil/avm/avm_main.pil @@ -116,6 +116,7 @@ namespace avm_main(256); pol commit sel_internal_return; pol commit sel_jump; pol commit sel_jumpi; + pol commit sel_external_call; // Halt program execution pol commit sel_halt; @@ -276,6 +277,7 @@ namespace avm_main(256); sel_jump * (1 - sel_jump) = 0; sel_jumpi * (1 - sel_jumpi) = 0; sel_halt * (1 - sel_halt) = 0; + sel_external_call * (1 - sel_external_call) = 0; // Might be removed if derived from opcode based on a lookup of constants sel_mov * ( 1 - sel_mov) = 0; @@ -413,7 +415,7 @@ namespace avm_main(256); //===== CONTROL_FLOW_CONSISTENCY ============================================ pol INTERNAL_CALL_STACK_SELECTORS = (first + sel_internal_call + sel_internal_return + sel_halt); - pol ALL_CTRL_FLOW_SEL = sel_jump + sel_jumpi + sel_internal_call + sel_internal_return; + pol ALL_CTRL_FLOW_SEL = sel_jump + sel_jumpi + sel_internal_call + sel_internal_return + sel_external_call; pol ALL_BINARY_SEL = sel_op_and + sel_op_or + sel_op_xor; pol ALL_GADGET_SEL = sel_op_radix_le + sel_op_sha256 + sel_op_poseidon2 + sel_op_keccak + sel_op_pedersen; diff --git a/barretenberg/cpp/pil/avm/constants.pil b/barretenberg/cpp/pil/avm/constants.pil index cda546c6754..bfd243d2016 100644 --- a/barretenberg/cpp/pil/avm/constants.pil +++ b/barretenberg/cpp/pil/avm/constants.pil @@ -30,3 +30,14 @@ namespace constants(256); // Other AVM specific constants pol INTERNAL_CALL_SPACE_ID = 255; + // Lengths of kernel output vectors + // Read requests + pol MAX_NULLIFIER_READ_REQUESTS_PER_CALL = 32; + pol MAX_NOTE_HASH_READ_REQUESTS_PER_CALL = 32; + pol MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL = 32; + pol MAX_PUBLIC_DATA_READS_PER_CALL = 16; + + // Emitting Data + pol MAX_NEW_NOTE_HASHES_PER_CALL = 16; + pol MAX_NEW_NULLIIFIERS_PER_CALL = 16; + pol MAX_NEW_L2_TO_L1_MSGS_PER_CALL = 2; diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_alu.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_alu.hpp index 2022d640185..00b9bbc203b 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_alu.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_alu.hpp @@ -6,1215 +6,1165 @@ namespace bb::Avm_vm { -template struct Avm_aluRow { - FF avm_alu_a_hi{}; - FF avm_alu_a_hi_shift{}; - FF avm_alu_a_lo{}; - FF avm_alu_a_lo_shift{}; - FF avm_alu_alu_sel{}; - FF avm_alu_alu_sel_shift{}; - FF avm_alu_b_hi{}; - FF avm_alu_b_hi_shift{}; - FF avm_alu_b_lo{}; - FF avm_alu_b_lo_shift{}; - FF avm_alu_borrow{}; - FF avm_alu_cf{}; - FF avm_alu_cmp_rng_ctr{}; - FF avm_alu_cmp_rng_ctr_shift{}; - FF avm_alu_cmp_sel{}; - FF avm_alu_cmp_sel_shift{}; - FF avm_alu_div_rng_chk_selector{}; - FF avm_alu_div_rng_chk_selector_shift{}; - FF avm_alu_div_u16_r0{}; - FF avm_alu_div_u16_r0_shift{}; - FF avm_alu_div_u16_r1{}; - FF avm_alu_div_u16_r1_shift{}; - FF avm_alu_div_u16_r2{}; - FF avm_alu_div_u16_r2_shift{}; - FF avm_alu_div_u16_r3{}; - FF avm_alu_div_u16_r3_shift{}; - FF avm_alu_div_u16_r4{}; - FF avm_alu_div_u16_r4_shift{}; - FF avm_alu_div_u16_r5{}; - FF avm_alu_div_u16_r5_shift{}; - FF avm_alu_div_u16_r6{}; - FF avm_alu_div_u16_r6_shift{}; - FF avm_alu_div_u16_r7{}; - FF avm_alu_div_u16_r7_shift{}; - FF avm_alu_divisor_hi{}; - FF avm_alu_divisor_lo{}; - FF avm_alu_ff_tag{}; - FF avm_alu_ia{}; - FF avm_alu_ib{}; - FF avm_alu_ic{}; - FF avm_alu_in_tag{}; - FF avm_alu_op_add{}; - FF avm_alu_op_add_shift{}; - FF avm_alu_op_cast{}; - FF avm_alu_op_cast_prev{}; - FF avm_alu_op_cast_prev_shift{}; - FF avm_alu_op_cast_shift{}; - FF avm_alu_op_div{}; - FF avm_alu_op_div_a_lt_b{}; - FF avm_alu_op_div_shift{}; - FF avm_alu_op_div_std{}; - FF avm_alu_op_eq{}; - FF avm_alu_op_eq_diff_inv{}; - FF avm_alu_op_lt{}; - FF avm_alu_op_lte{}; - FF avm_alu_op_mul{}; - FF avm_alu_op_mul_shift{}; - FF avm_alu_op_not{}; - FF avm_alu_op_shl{}; - FF avm_alu_op_shl_shift{}; - FF avm_alu_op_shr{}; - FF avm_alu_op_shr_shift{}; - FF avm_alu_op_sub{}; - FF avm_alu_op_sub_shift{}; - FF avm_alu_p_a_borrow{}; - FF avm_alu_p_b_borrow{}; - FF avm_alu_p_sub_a_hi{}; - FF avm_alu_p_sub_a_hi_shift{}; - FF avm_alu_p_sub_a_lo{}; - FF avm_alu_p_sub_a_lo_shift{}; - FF avm_alu_p_sub_b_hi{}; - FF avm_alu_p_sub_b_hi_shift{}; - FF avm_alu_p_sub_b_lo{}; - FF avm_alu_p_sub_b_lo_shift{}; - FF avm_alu_partial_prod_hi{}; - FF avm_alu_partial_prod_lo{}; - FF avm_alu_quotient_hi{}; - FF avm_alu_quotient_lo{}; - FF avm_alu_remainder{}; - FF avm_alu_res_hi{}; - FF avm_alu_res_lo{}; - FF avm_alu_rng_chk_lookup_selector_shift{}; - FF avm_alu_rng_chk_sel{}; - FF avm_alu_rng_chk_sel_shift{}; - FF avm_alu_shift_lt_bit_len{}; - FF avm_alu_shift_sel{}; - FF avm_alu_t_sub_s_bits{}; - FF avm_alu_two_pow_s{}; - FF avm_alu_two_pow_t_sub_s{}; - FF avm_alu_u128_tag{}; - FF avm_alu_u16_r0{}; - FF avm_alu_u16_r0_shift{}; - FF avm_alu_u16_r1{}; - FF avm_alu_u16_r10{}; - FF avm_alu_u16_r11{}; - FF avm_alu_u16_r12{}; - FF avm_alu_u16_r13{}; - FF avm_alu_u16_r14{}; - FF avm_alu_u16_r1_shift{}; - FF avm_alu_u16_r2{}; - FF avm_alu_u16_r2_shift{}; - FF avm_alu_u16_r3{}; - FF avm_alu_u16_r3_shift{}; - FF avm_alu_u16_r4{}; - FF avm_alu_u16_r4_shift{}; - FF avm_alu_u16_r5{}; - FF avm_alu_u16_r5_shift{}; - FF avm_alu_u16_r6{}; - FF avm_alu_u16_r6_shift{}; - FF avm_alu_u16_r7{}; - FF avm_alu_u16_r8{}; - FF avm_alu_u16_r9{}; - FF avm_alu_u16_tag{}; - FF avm_alu_u32_tag{}; - FF avm_alu_u64_tag{}; - FF avm_alu_u8_r0{}; - FF avm_alu_u8_r0_shift{}; - FF avm_alu_u8_r1{}; - FF avm_alu_u8_r1_shift{}; - FF avm_alu_u8_tag{}; -}; - -inline std::string get_relation_label_avm_alu(int index) -{ - switch (index) { - case 12: - return "ALU_ADD_SUB_1"; - - case 13: - return "ALU_ADD_SUB_2"; - - case 14: - return "ALU_MULTIPLICATION_FF"; - - case 15: - return "ALU_MUL_COMMON_1"; - - case 16: - return "ALU_MUL_COMMON_2"; - - case 19: - return "ALU_MULTIPLICATION_OUT_U128"; - - case 20: - return "ALU_FF_NOT_XOR"; - - case 21: - return "ALU_OP_NOT"; - - case 22: - return "ALU_RES_IS_BOOL"; - - case 23: - return "ALU_OP_EQ"; - - case 24: - return "INPUT_DECOMP_1"; - - case 25: - return "INPUT_DECOMP_2"; - - case 27: - return "SUB_LO_1"; - - case 28: - return "SUB_HI_1"; - - case 30: - return "SUB_LO_2"; - - case 31: - return "SUB_HI_2"; - - case 32: - return "RES_LO"; - - case 33: - return "RES_HI"; - - case 34: - return "CMP_CTR_REL_1"; - - case 35: - return "CMP_CTR_REL_2"; - - case 38: - return "CTR_NON_ZERO_REL"; - - case 39: - return "RNG_CHK_LOOKUP_SELECTOR"; - - case 40: - return "LOWER_CMP_RNG_CHK"; - - case 41: - return "UPPER_CMP_RNG_CHK"; - - case 42: - return "SHIFT_RELS_0"; - - case 44: - return "SHIFT_RELS_1"; - - case 46: - return "SHIFT_RELS_2"; - - case 48: - return "SHIFT_RELS_3"; - - case 50: - return "OP_CAST_PREV_LINE"; - - case 51: - return "ALU_OP_CAST"; - - case 52: - return "OP_CAST_RNG_CHECK_P_SUB_A_LOW"; - - case 53: - return "OP_CAST_RNG_CHECK_P_SUB_A_HIGH"; - - case 54: - return "TWO_LINE_OP_NO_OVERLAP"; - - case 55: - return "SHR_RANGE_0"; - - case 56: - return "SHR_RANGE_1"; - - case 57: - return "SHL_RANGE_0"; - - case 58: - return "SHL_RANGE_1"; - - case 60: - return "SHIFT_LT_BIT_LEN"; - - case 61: - return "SHR_INPUT_DECOMPOSITION"; - - case 62: - return "SHR_OUTPUT"; - - case 63: - return "SHL_INPUT_DECOMPOSITION"; - - case 64: - return "SHL_OUTPUT"; - - case 74: - return "ALU_PROD_DIV"; - - case 75: - return "REMAINDER_RANGE_CHK"; - - case 76: - return "CMP_CTR_REL_3"; - - case 78: - return "DIVISION_RELATION"; +template struct Avm_aluRow { + FF avm_alu_a_hi {}; + FF avm_alu_a_hi_shift {}; + FF avm_alu_a_lo {}; + FF avm_alu_a_lo_shift {}; + FF avm_alu_alu_sel {}; + FF avm_alu_alu_sel_shift {}; + FF avm_alu_b_hi {}; + FF avm_alu_b_hi_shift {}; + FF avm_alu_b_lo {}; + FF avm_alu_b_lo_shift {}; + FF avm_alu_borrow {}; + FF avm_alu_cf {}; + FF avm_alu_cmp_rng_ctr {}; + FF avm_alu_cmp_rng_ctr_shift {}; + FF avm_alu_cmp_sel {}; + FF avm_alu_cmp_sel_shift {}; + FF avm_alu_div_rng_chk_selector {}; + FF avm_alu_div_rng_chk_selector_shift {}; + FF avm_alu_div_u16_r0 {}; + FF avm_alu_div_u16_r0_shift {}; + FF avm_alu_div_u16_r1 {}; + FF avm_alu_div_u16_r1_shift {}; + FF avm_alu_div_u16_r2 {}; + FF avm_alu_div_u16_r2_shift {}; + FF avm_alu_div_u16_r3 {}; + FF avm_alu_div_u16_r3_shift {}; + FF avm_alu_div_u16_r4 {}; + FF avm_alu_div_u16_r4_shift {}; + FF avm_alu_div_u16_r5 {}; + FF avm_alu_div_u16_r5_shift {}; + FF avm_alu_div_u16_r6 {}; + FF avm_alu_div_u16_r6_shift {}; + FF avm_alu_div_u16_r7 {}; + FF avm_alu_div_u16_r7_shift {}; + FF avm_alu_divisor_hi {}; + FF avm_alu_divisor_lo {}; + FF avm_alu_ff_tag {}; + FF avm_alu_ia {}; + FF avm_alu_ib {}; + FF avm_alu_ic {}; + FF avm_alu_in_tag {}; + FF avm_alu_op_add {}; + FF avm_alu_op_add_shift {}; + FF avm_alu_op_cast {}; + FF avm_alu_op_cast_prev {}; + FF avm_alu_op_cast_prev_shift {}; + FF avm_alu_op_cast_shift {}; + FF avm_alu_op_div {}; + FF avm_alu_op_div_a_lt_b {}; + FF avm_alu_op_div_shift {}; + FF avm_alu_op_div_std {}; + FF avm_alu_op_eq {}; + FF avm_alu_op_eq_diff_inv {}; + FF avm_alu_op_lt {}; + FF avm_alu_op_lte {}; + FF avm_alu_op_mul {}; + FF avm_alu_op_mul_shift {}; + FF avm_alu_op_not {}; + FF avm_alu_op_shl {}; + FF avm_alu_op_shl_shift {}; + FF avm_alu_op_shr {}; + FF avm_alu_op_shr_shift {}; + FF avm_alu_op_sub {}; + FF avm_alu_op_sub_shift {}; + FF avm_alu_p_a_borrow {}; + FF avm_alu_p_b_borrow {}; + FF avm_alu_p_sub_a_hi {}; + FF avm_alu_p_sub_a_hi_shift {}; + FF avm_alu_p_sub_a_lo {}; + FF avm_alu_p_sub_a_lo_shift {}; + FF avm_alu_p_sub_b_hi {}; + FF avm_alu_p_sub_b_hi_shift {}; + FF avm_alu_p_sub_b_lo {}; + FF avm_alu_p_sub_b_lo_shift {}; + FF avm_alu_partial_prod_hi {}; + FF avm_alu_partial_prod_lo {}; + FF avm_alu_quotient_hi {}; + FF avm_alu_quotient_lo {}; + FF avm_alu_remainder {}; + FF avm_alu_res_hi {}; + FF avm_alu_res_lo {}; + FF avm_alu_rng_chk_lookup_selector_shift {}; + FF avm_alu_rng_chk_sel {}; + FF avm_alu_rng_chk_sel_shift {}; + FF avm_alu_shift_lt_bit_len {}; + FF avm_alu_shift_sel {}; + FF avm_alu_t_sub_s_bits {}; + FF avm_alu_two_pow_s {}; + FF avm_alu_two_pow_t_sub_s {}; + FF avm_alu_u128_tag {}; + FF avm_alu_u16_r0 {}; + FF avm_alu_u16_r0_shift {}; + FF avm_alu_u16_r1 {}; + FF avm_alu_u16_r10 {}; + FF avm_alu_u16_r11 {}; + FF avm_alu_u16_r12 {}; + FF avm_alu_u16_r13 {}; + FF avm_alu_u16_r14 {}; + FF avm_alu_u16_r1_shift {}; + FF avm_alu_u16_r2 {}; + FF avm_alu_u16_r2_shift {}; + FF avm_alu_u16_r3 {}; + FF avm_alu_u16_r3_shift {}; + FF avm_alu_u16_r4 {}; + FF avm_alu_u16_r4_shift {}; + FF avm_alu_u16_r5 {}; + FF avm_alu_u16_r5_shift {}; + FF avm_alu_u16_r6 {}; + FF avm_alu_u16_r6_shift {}; + FF avm_alu_u16_r7 {}; + FF avm_alu_u16_r8 {}; + FF avm_alu_u16_r9 {}; + FF avm_alu_u16_tag {}; + FF avm_alu_u32_tag {}; + FF avm_alu_u64_tag {}; + FF avm_alu_u8_r0 {}; + FF avm_alu_u8_r0_shift {}; + FF avm_alu_u8_r1 {}; + FF avm_alu_u8_r1_shift {}; + FF avm_alu_u8_tag {}; + }; + + + inline std::string get_relation_label_avm_alu(int index) { + switch (index) { + case 12: + return "ALU_ADD_SUB_1"; + +case 13: + return "ALU_ADD_SUB_2"; + +case 14: + return "ALU_MULTIPLICATION_FF"; + +case 15: + return "ALU_MUL_COMMON_1"; + +case 16: + return "ALU_MUL_COMMON_2"; + +case 19: + return "ALU_MULTIPLICATION_OUT_U128"; + +case 20: + return "ALU_FF_NOT_XOR"; + +case 21: + return "ALU_OP_NOT"; + +case 22: + return "ALU_RES_IS_BOOL"; + +case 23: + return "ALU_OP_EQ"; + +case 24: + return "INPUT_DECOMP_1"; + +case 25: + return "INPUT_DECOMP_2"; + +case 27: + return "SUB_LO_1"; + +case 28: + return "SUB_HI_1"; + +case 30: + return "SUB_LO_2"; + +case 31: + return "SUB_HI_2"; + +case 32: + return "RES_LO"; + +case 33: + return "RES_HI"; + +case 34: + return "CMP_CTR_REL_1"; + +case 35: + return "CMP_CTR_REL_2"; + +case 38: + return "CTR_NON_ZERO_REL"; + +case 39: + return "RNG_CHK_LOOKUP_SELECTOR"; + +case 40: + return "LOWER_CMP_RNG_CHK"; + +case 41: + return "UPPER_CMP_RNG_CHK"; + +case 42: + return "SHIFT_RELS_0"; + +case 44: + return "SHIFT_RELS_1"; + +case 46: + return "SHIFT_RELS_2"; + +case 48: + return "SHIFT_RELS_3"; + +case 50: + return "OP_CAST_PREV_LINE"; + +case 51: + return "ALU_OP_CAST"; + +case 52: + return "OP_CAST_RNG_CHECK_P_SUB_A_LOW"; + +case 53: + return "OP_CAST_RNG_CHECK_P_SUB_A_HIGH"; + +case 54: + return "TWO_LINE_OP_NO_OVERLAP"; + +case 55: + return "SHR_RANGE_0"; + +case 56: + return "SHR_RANGE_1"; + +case 57: + return "SHL_RANGE_0"; + +case 58: + return "SHL_RANGE_1"; + +case 60: + return "SHIFT_LT_BIT_LEN"; + +case 61: + return "SHR_INPUT_DECOMPOSITION"; + +case 62: + return "SHR_OUTPUT"; + +case 63: + return "SHL_INPUT_DECOMPOSITION"; + +case 64: + return "SHL_OUTPUT"; + +case 74: + return "ALU_PROD_DIV"; + +case 75: + return "REMAINDER_RANGE_CHK"; + +case 76: + return "CMP_CTR_REL_3"; + +case 78: + return "DIVISION_RELATION"; + + } + return std::to_string(index); } - return std::to_string(index); -} + template class avm_aluImpl { - public: - using FF = FF_; - - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 5, 5, 5, 6, 6, 8, 3, 4, 4, 5, 4, 4, 3, 4, 3, - 3, 4, 3, 6, 5, 3, 3, 3, 3, 4, 3, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 2, 5, 3, 3, 4, 4, 4, 4, - 4, 3, 5, 5, 4, 5, 5, 2, 3, 3, 3, 3, 3, 4, 4, 3, 5, 3, 3, 3, 5, 3, 3, 4, 4, 4, 4, 4, 4, - }; - + public: + using FF = FF_; + + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 2, + 2, + 2, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 4, + 5, + 5, + 5, + 5, + 6, + 6, + 8, + 3, + 4, + 4, + 5, + 4, + 4, + 3, + 4, + 3, + 3, + 4, + 3, + 6, + 5, + 3, + 3, + 3, + 3, + 4, + 3, + 4, + 4, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 2, + 5, + 3, + 3, + 4, + 4, + 4, + 4, + 4, + 3, + 5, + 5, + 4, + 5, + 5, + 2, + 3, + 3, + 3, + 3, + 3, + 4, + 4, + 3, + 5, + 3, + 3, + 3, + 5, + 3, + 3, + 4, + 4, + 4, + 4, + 4, + 4, +}; + + template - void static accumulate(ContainerOverSubrelations& evals, - const AllEntities& new_term, - [[maybe_unused]] const RelationParameters&, - [[maybe_unused]] const FF& scaling_factor) + void static accumulate( + ContainerOverSubrelations& evals, + const AllEntities& new_term, + [[maybe_unused]] const RelationParameters&, + [[maybe_unused]] const FF& scaling_factor + ){ + + //Contribution 0 { +Avm_DECLARE_VIEWS(0); + + + auto tmp = (avm_alu_alu_sel - ((((((((((avm_alu_op_add + avm_alu_op_sub) + avm_alu_op_mul) + avm_alu_op_not) + avm_alu_op_eq) + avm_alu_op_cast) + avm_alu_op_lt) + avm_alu_op_lte) + avm_alu_op_shr) + avm_alu_op_shl) + avm_alu_op_div)); + tmp *= scaling_factor; + std::get<0>(evals) += tmp; +} +//Contribution 1 + { +Avm_DECLARE_VIEWS(1); + + + auto tmp = (avm_alu_cmp_sel - (avm_alu_op_lt + avm_alu_op_lte)); + tmp *= scaling_factor; + std::get<1>(evals) += tmp; +} +//Contribution 2 + { +Avm_DECLARE_VIEWS(2); + + + auto tmp = (avm_alu_shift_sel - (avm_alu_op_shl + avm_alu_op_shr)); + tmp *= scaling_factor; + std::get<2>(evals) += tmp; +} +//Contribution 3 + { +Avm_DECLARE_VIEWS(3); + + + auto tmp = (avm_alu_cf * (-avm_alu_cf + FF(1))); + tmp *= scaling_factor; + std::get<3>(evals) += tmp; +} +//Contribution 4 + { +Avm_DECLARE_VIEWS(4); + + + auto tmp = (avm_alu_ff_tag * (-avm_alu_ff_tag + FF(1))); + tmp *= scaling_factor; + std::get<4>(evals) += tmp; +} +//Contribution 5 + { +Avm_DECLARE_VIEWS(5); + + + auto tmp = (avm_alu_u8_tag * (-avm_alu_u8_tag + FF(1))); + tmp *= scaling_factor; + std::get<5>(evals) += tmp; +} +//Contribution 6 + { +Avm_DECLARE_VIEWS(6); + + + auto tmp = (avm_alu_u16_tag * (-avm_alu_u16_tag + FF(1))); + tmp *= scaling_factor; + std::get<6>(evals) += tmp; +} +//Contribution 7 + { +Avm_DECLARE_VIEWS(7); + + + auto tmp = (avm_alu_u32_tag * (-avm_alu_u32_tag + FF(1))); + tmp *= scaling_factor; + std::get<7>(evals) += tmp; +} +//Contribution 8 + { +Avm_DECLARE_VIEWS(8); + + + auto tmp = (avm_alu_u64_tag * (-avm_alu_u64_tag + FF(1))); + tmp *= scaling_factor; + std::get<8>(evals) += tmp; +} +//Contribution 9 + { +Avm_DECLARE_VIEWS(9); + + + auto tmp = (avm_alu_u128_tag * (-avm_alu_u128_tag + FF(1))); + tmp *= scaling_factor; + std::get<9>(evals) += tmp; +} +//Contribution 10 + { +Avm_DECLARE_VIEWS(10); + + + auto tmp = (avm_alu_alu_sel * ((((((avm_alu_ff_tag + avm_alu_u8_tag) + avm_alu_u16_tag) + avm_alu_u32_tag) + avm_alu_u64_tag) + avm_alu_u128_tag) - FF(1))); + tmp *= scaling_factor; + std::get<10>(evals) += tmp; +} +//Contribution 11 + { +Avm_DECLARE_VIEWS(11); + + + auto tmp = (avm_alu_in_tag - (((((avm_alu_u8_tag + (avm_alu_u16_tag * FF(2))) + (avm_alu_u32_tag * FF(3))) + (avm_alu_u64_tag * FF(4))) + (avm_alu_u128_tag * FF(5))) + (avm_alu_ff_tag * FF(6)))); + tmp *= scaling_factor; + std::get<11>(evals) += tmp; +} +//Contribution 12 + { +Avm_DECLARE_VIEWS(12); + + + auto tmp = (((avm_alu_op_add + avm_alu_op_sub) * ((((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + (avm_alu_u16_r1 * FF(4294967296UL))) + (avm_alu_u16_r2 * FF(281474976710656UL))) + (avm_alu_u16_r3 * FF(uint256_t{0UL, 1UL, 0UL, 0UL}))) + (avm_alu_u16_r4 * FF(uint256_t{0UL, 65536UL, 0UL, 0UL}))) + (avm_alu_u16_r5 * FF(uint256_t{0UL, 4294967296UL, 0UL, 0UL}))) + (avm_alu_u16_r6 * FF(uint256_t{0UL, 281474976710656UL, 0UL, 0UL}))) - avm_alu_ia) + (avm_alu_ff_tag * avm_alu_ic))) + ((avm_alu_op_add - avm_alu_op_sub) * ((avm_alu_cf * FF(uint256_t{0UL, 0UL, 1UL, 0UL})) - avm_alu_ib))); + tmp *= scaling_factor; + std::get<12>(evals) += tmp; +} +//Contribution 13 + { +Avm_DECLARE_VIEWS(13); + + + auto tmp = (((avm_alu_op_add + avm_alu_op_sub) * (((((((avm_alu_u8_tag * avm_alu_u8_r0) + (avm_alu_u16_tag * (avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))))) + (avm_alu_u32_tag * ((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))))) + (avm_alu_u64_tag * ((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + (avm_alu_u16_r1 * FF(4294967296UL))) + (avm_alu_u16_r2 * FF(281474976710656UL))))) + (avm_alu_u128_tag * ((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + (avm_alu_u16_r1 * FF(4294967296UL))) + (avm_alu_u16_r2 * FF(281474976710656UL))) + (avm_alu_u16_r3 * FF(uint256_t{0UL, 1UL, 0UL, 0UL}))) + (avm_alu_u16_r4 * FF(uint256_t{0UL, 65536UL, 0UL, 0UL}))) + (avm_alu_u16_r5 * FF(uint256_t{0UL, 4294967296UL, 0UL, 0UL}))) + (avm_alu_u16_r6 * FF(uint256_t{0UL, 281474976710656UL, 0UL, 0UL}))))) + (avm_alu_ff_tag * avm_alu_ia)) - avm_alu_ic)) + ((avm_alu_ff_tag * (avm_alu_op_add - avm_alu_op_sub)) * avm_alu_ib)); + tmp *= scaling_factor; + std::get<13>(evals) += tmp; +} +//Contribution 14 + { +Avm_DECLARE_VIEWS(14); + + + auto tmp = ((avm_alu_ff_tag * avm_alu_op_mul) * ((avm_alu_ia * avm_alu_ib) - avm_alu_ic)); + tmp *= scaling_factor; + std::get<14>(evals) += tmp; +} +//Contribution 15 + { +Avm_DECLARE_VIEWS(15); + + + auto tmp = ((((-avm_alu_ff_tag + FF(1)) - avm_alu_u128_tag) * avm_alu_op_mul) * (((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + (avm_alu_u16_r1 * FF(4294967296UL))) + (avm_alu_u16_r2 * FF(281474976710656UL))) + (avm_alu_u16_r3 * FF(uint256_t{0UL, 1UL, 0UL, 0UL}))) + (avm_alu_u16_r4 * FF(uint256_t{0UL, 65536UL, 0UL, 0UL}))) + (avm_alu_u16_r5 * FF(uint256_t{0UL, 4294967296UL, 0UL, 0UL}))) + (avm_alu_u16_r6 * FF(uint256_t{0UL, 281474976710656UL, 0UL, 0UL}))) - (avm_alu_ia * avm_alu_ib))); + tmp *= scaling_factor; + std::get<15>(evals) += tmp; +} +//Contribution 16 + { +Avm_DECLARE_VIEWS(16); + + + auto tmp = (avm_alu_op_mul * (((((avm_alu_u8_tag * avm_alu_u8_r0) + (avm_alu_u16_tag * (avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))))) + (avm_alu_u32_tag * ((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))))) + (avm_alu_u64_tag * ((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + (avm_alu_u16_r1 * FF(4294967296UL))) + (avm_alu_u16_r2 * FF(281474976710656UL))))) - (((-avm_alu_ff_tag + FF(1)) - avm_alu_u128_tag) * avm_alu_ic))); + tmp *= scaling_factor; + std::get<16>(evals) += tmp; +} +//Contribution 17 + { +Avm_DECLARE_VIEWS(17); + + + auto tmp = ((avm_alu_u128_tag * avm_alu_op_mul) * ((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + (avm_alu_u16_r1 * FF(4294967296UL))) + (avm_alu_u16_r2 * FF(281474976710656UL))) + ((((avm_alu_u16_r3 + (avm_alu_u16_r4 * FF(65536))) + (avm_alu_u16_r5 * FF(4294967296UL))) + (avm_alu_u16_r6 * FF(281474976710656UL))) * FF(uint256_t{0UL, 1UL, 0UL, 0UL}))) - avm_alu_ia)); + tmp *= scaling_factor; + std::get<17>(evals) += tmp; +} +//Contribution 18 + { +Avm_DECLARE_VIEWS(18); + + + auto tmp = ((avm_alu_u128_tag * avm_alu_op_mul) * ((((((avm_alu_u8_r0_shift + (avm_alu_u8_r1_shift * FF(256))) + (avm_alu_u16_r0_shift * FF(65536))) + (avm_alu_u16_r1_shift * FF(4294967296UL))) + (avm_alu_u16_r2_shift * FF(281474976710656UL))) + ((((avm_alu_u16_r3_shift + (avm_alu_u16_r4_shift * FF(65536))) + (avm_alu_u16_r5_shift * FF(4294967296UL))) + (avm_alu_u16_r6_shift * FF(281474976710656UL))) * FF(uint256_t{0UL, 1UL, 0UL, 0UL}))) - avm_alu_ib)); + tmp *= scaling_factor; + std::get<18>(evals) += tmp; +} +//Contribution 19 + { +Avm_DECLARE_VIEWS(19); + + + auto tmp = ((avm_alu_u128_tag * avm_alu_op_mul) * ((((avm_alu_ia * ((((avm_alu_u8_r0_shift + (avm_alu_u8_r1_shift * FF(256))) + (avm_alu_u16_r0_shift * FF(65536))) + (avm_alu_u16_r1_shift * FF(4294967296UL))) + (avm_alu_u16_r2_shift * FF(281474976710656UL)))) + ((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + (avm_alu_u16_r1 * FF(4294967296UL))) + (avm_alu_u16_r2 * FF(281474976710656UL))) * (((avm_alu_u16_r3_shift + (avm_alu_u16_r4_shift * FF(65536))) + (avm_alu_u16_r5_shift * FF(4294967296UL))) + (avm_alu_u16_r6_shift * FF(281474976710656UL)))) * FF(uint256_t{0UL, 1UL, 0UL, 0UL}))) - (((avm_alu_cf * FF(uint256_t{0UL, 1UL, 0UL, 0UL})) + (((avm_alu_u16_r7 + (avm_alu_u16_r8 * FF(65536))) + (avm_alu_u16_r9 * FF(4294967296UL))) + (avm_alu_u16_r10 * FF(281474976710656UL)))) * FF(uint256_t{0UL, 0UL, 1UL, 0UL}))) - avm_alu_ic)); + tmp *= scaling_factor; + std::get<19>(evals) += tmp; +} +//Contribution 20 + { +Avm_DECLARE_VIEWS(20); + + + auto tmp = (avm_alu_op_not * avm_alu_ff_tag); + tmp *= scaling_factor; + std::get<20>(evals) += tmp; +} +//Contribution 21 + { +Avm_DECLARE_VIEWS(21); + + + auto tmp = (avm_alu_op_not * ((avm_alu_ia + avm_alu_ic) - ((((((avm_alu_u8_tag * FF(256)) + (avm_alu_u16_tag * FF(65536))) + (avm_alu_u32_tag * FF(4294967296UL))) + (avm_alu_u64_tag * FF(uint256_t{0UL, 1UL, 0UL, 0UL}))) + (avm_alu_u128_tag * FF(uint256_t{0UL, 0UL, 1UL, 0UL}))) - FF(1)))); + tmp *= scaling_factor; + std::get<21>(evals) += tmp; +} +//Contribution 22 + { +Avm_DECLARE_VIEWS(22); + + + auto tmp = ((avm_alu_cmp_sel + avm_alu_op_eq) * (avm_alu_ic * (-avm_alu_ic + FF(1)))); + tmp *= scaling_factor; + std::get<22>(evals) += tmp; +} +//Contribution 23 + { +Avm_DECLARE_VIEWS(23); + + + auto tmp = (avm_alu_op_eq * ((((avm_alu_ia - avm_alu_ib) * ((avm_alu_ic * (-avm_alu_op_eq_diff_inv + FF(1))) + avm_alu_op_eq_diff_inv)) - FF(1)) + avm_alu_ic)); + tmp *= scaling_factor; + std::get<23>(evals) += tmp; +} +//Contribution 24 + { +Avm_DECLARE_VIEWS(24); + + + auto tmp = (((avm_alu_op_lt * avm_alu_ib) + ((avm_alu_op_lte + avm_alu_op_cast) * avm_alu_ia)) - ((avm_alu_a_lo + (avm_alu_a_hi * FF(uint256_t{0UL, 0UL, 1UL, 0UL}))) * (avm_alu_cmp_sel + avm_alu_op_cast))); + tmp *= scaling_factor; + std::get<24>(evals) += tmp; +} +//Contribution 25 + { +Avm_DECLARE_VIEWS(25); + + + auto tmp = (((avm_alu_op_lt * avm_alu_ia) + (avm_alu_op_lte * avm_alu_ib)) - ((avm_alu_b_lo + (avm_alu_b_hi * FF(uint256_t{0UL, 0UL, 1UL, 0UL}))) * avm_alu_cmp_sel)); + tmp *= scaling_factor; + std::get<25>(evals) += tmp; +} +//Contribution 26 + { +Avm_DECLARE_VIEWS(26); + + + auto tmp = (avm_alu_p_a_borrow * (-avm_alu_p_a_borrow + FF(1))); + tmp *= scaling_factor; + std::get<26>(evals) += tmp; +} +//Contribution 27 + { +Avm_DECLARE_VIEWS(27); + + + auto tmp = ((avm_alu_p_sub_a_lo - ((-avm_alu_a_lo + FF(uint256_t{4891460686036598784UL, 2896914383306846353UL, 0UL, 0UL})) + (avm_alu_p_a_borrow * FF(uint256_t{0UL, 0UL, 1UL, 0UL})))) * ((avm_alu_cmp_sel + avm_alu_op_cast) + avm_alu_op_div_std)); + tmp *= scaling_factor; + std::get<27>(evals) += tmp; +} +//Contribution 28 + { +Avm_DECLARE_VIEWS(28); + + + auto tmp = ((avm_alu_p_sub_a_hi - ((-avm_alu_a_hi + FF(uint256_t{13281191951274694749UL, 3486998266802970665UL, 0UL, 0UL})) - avm_alu_p_a_borrow)) * ((avm_alu_cmp_sel + avm_alu_op_cast) + avm_alu_op_div_std)); + tmp *= scaling_factor; + std::get<28>(evals) += tmp; +} +//Contribution 29 + { +Avm_DECLARE_VIEWS(29); + + + auto tmp = (avm_alu_p_b_borrow * (-avm_alu_p_b_borrow + FF(1))); + tmp *= scaling_factor; + std::get<29>(evals) += tmp; +} +//Contribution 30 + { +Avm_DECLARE_VIEWS(30); + + + auto tmp = ((avm_alu_p_sub_b_lo - ((-avm_alu_b_lo + FF(uint256_t{4891460686036598784UL, 2896914383306846353UL, 0UL, 0UL})) + (avm_alu_p_b_borrow * FF(uint256_t{0UL, 0UL, 1UL, 0UL})))) * avm_alu_cmp_sel); + tmp *= scaling_factor; + std::get<30>(evals) += tmp; +} +//Contribution 31 + { +Avm_DECLARE_VIEWS(31); + + + auto tmp = ((avm_alu_p_sub_b_hi - ((-avm_alu_b_hi + FF(uint256_t{13281191951274694749UL, 3486998266802970665UL, 0UL, 0UL})) - avm_alu_p_b_borrow)) * avm_alu_cmp_sel); + tmp *= scaling_factor; + std::get<31>(evals) += tmp; +} +//Contribution 32 + { +Avm_DECLARE_VIEWS(32); + + + auto tmp = ((avm_alu_res_lo - (((((avm_alu_a_lo - avm_alu_b_lo) - FF(1)) + (avm_alu_borrow * FF(uint256_t{0UL, 0UL, 1UL, 0UL}))) * ((avm_alu_op_lt * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_op_lte))) + (((avm_alu_b_lo - avm_alu_a_lo) + (avm_alu_borrow * FF(uint256_t{0UL, 0UL, 1UL, 0UL}))) * (-((avm_alu_op_lt * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_op_lte)) + FF(1))))) * avm_alu_cmp_sel); + tmp *= scaling_factor; + std::get<32>(evals) += tmp; +} +//Contribution 33 + { +Avm_DECLARE_VIEWS(33); + + + auto tmp = ((avm_alu_res_hi - ((((avm_alu_a_hi - avm_alu_b_hi) - avm_alu_borrow) * ((avm_alu_op_lt * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_op_lte))) + (((avm_alu_b_hi - avm_alu_a_hi) - avm_alu_borrow) * (-((avm_alu_op_lt * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_op_lte)) + FF(1))))) * avm_alu_cmp_sel); + tmp *= scaling_factor; + std::get<33>(evals) += tmp; +} +//Contribution 34 + { +Avm_DECLARE_VIEWS(34); + + + auto tmp = (((avm_alu_cmp_rng_ctr_shift - avm_alu_cmp_rng_ctr) + FF(1)) * avm_alu_cmp_rng_ctr); + tmp *= scaling_factor; + std::get<34>(evals) += tmp; +} +//Contribution 35 + { +Avm_DECLARE_VIEWS(35); + + + auto tmp = ((avm_alu_cmp_rng_ctr_shift - FF(4)) * avm_alu_cmp_sel); + tmp *= scaling_factor; + std::get<35>(evals) += tmp; +} +//Contribution 36 + { +Avm_DECLARE_VIEWS(36); + + + auto tmp = (avm_alu_rng_chk_sel * (-avm_alu_rng_chk_sel + FF(1))); + tmp *= scaling_factor; + std::get<36>(evals) += tmp; +} +//Contribution 37 + { +Avm_DECLARE_VIEWS(37); + + + auto tmp = (avm_alu_rng_chk_sel * avm_alu_cmp_sel); + tmp *= scaling_factor; + std::get<37>(evals) += tmp; +} +//Contribution 38 + { +Avm_DECLARE_VIEWS(38); + + + auto tmp = ((avm_alu_cmp_rng_ctr * (((-avm_alu_rng_chk_sel + FF(1)) * (-avm_alu_op_eq_diff_inv + FF(1))) + avm_alu_op_eq_diff_inv)) - avm_alu_rng_chk_sel); + tmp *= scaling_factor; + std::get<38>(evals) += tmp; +} +//Contribution 39 + { +Avm_DECLARE_VIEWS(39); + + + auto tmp = (avm_alu_rng_chk_lookup_selector_shift - ((((((((((avm_alu_cmp_sel_shift + avm_alu_rng_chk_sel_shift) + avm_alu_op_add_shift) + avm_alu_op_sub_shift) + avm_alu_op_mul_shift) + (avm_alu_op_mul * avm_alu_u128_tag)) + avm_alu_op_cast_shift) + avm_alu_op_cast_prev_shift) + avm_alu_op_shl_shift) + avm_alu_op_shr_shift) + avm_alu_op_div_shift)); + tmp *= scaling_factor; + std::get<39>(evals) += tmp; +} +//Contribution 40 + { +Avm_DECLARE_VIEWS(40); + + + auto tmp = (avm_alu_a_lo - (((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + (avm_alu_u16_r1 * FF(4294967296UL))) + (avm_alu_u16_r2 * FF(281474976710656UL))) + (avm_alu_u16_r3 * FF(uint256_t{0UL, 1UL, 0UL, 0UL}))) + (avm_alu_u16_r4 * FF(uint256_t{0UL, 65536UL, 0UL, 0UL}))) + (avm_alu_u16_r5 * FF(uint256_t{0UL, 4294967296UL, 0UL, 0UL}))) + (avm_alu_u16_r6 * FF(uint256_t{0UL, 281474976710656UL, 0UL, 0UL}))) * (((((avm_alu_rng_chk_sel + avm_alu_cmp_sel) + avm_alu_op_cast) + avm_alu_op_cast_prev) + avm_alu_shift_lt_bit_len) + avm_alu_op_div))); + tmp *= scaling_factor; + std::get<40>(evals) += tmp; +} +//Contribution 41 + { +Avm_DECLARE_VIEWS(41); + + + auto tmp = (avm_alu_a_hi - ((((((((avm_alu_u16_r7 + (avm_alu_u16_r8 * FF(65536))) + (avm_alu_u16_r9 * FF(4294967296UL))) + (avm_alu_u16_r10 * FF(281474976710656UL))) + (avm_alu_u16_r11 * FF(uint256_t{0UL, 1UL, 0UL, 0UL}))) + (avm_alu_u16_r12 * FF(uint256_t{0UL, 65536UL, 0UL, 0UL}))) + (avm_alu_u16_r13 * FF(uint256_t{0UL, 4294967296UL, 0UL, 0UL}))) + (avm_alu_u16_r14 * FF(uint256_t{0UL, 281474976710656UL, 0UL, 0UL}))) * (((((avm_alu_rng_chk_sel + avm_alu_cmp_sel) + avm_alu_op_cast) + avm_alu_op_cast_prev) + avm_alu_shift_lt_bit_len) + avm_alu_op_div))); + tmp *= scaling_factor; + std::get<41>(evals) += tmp; +} +//Contribution 42 + { +Avm_DECLARE_VIEWS(42); + + + auto tmp = ((avm_alu_a_lo_shift - avm_alu_b_lo) * avm_alu_rng_chk_sel_shift); + tmp *= scaling_factor; + std::get<42>(evals) += tmp; +} +//Contribution 43 + { +Avm_DECLARE_VIEWS(43); + + + auto tmp = ((avm_alu_a_hi_shift - avm_alu_b_hi) * avm_alu_rng_chk_sel_shift); + tmp *= scaling_factor; + std::get<43>(evals) += tmp; +} +//Contribution 44 + { +Avm_DECLARE_VIEWS(44); + + + auto tmp = ((avm_alu_b_lo_shift - avm_alu_p_sub_a_lo) * avm_alu_rng_chk_sel_shift); + tmp *= scaling_factor; + std::get<44>(evals) += tmp; +} +//Contribution 45 + { +Avm_DECLARE_VIEWS(45); + + + auto tmp = ((avm_alu_b_hi_shift - avm_alu_p_sub_a_hi) * avm_alu_rng_chk_sel_shift); + tmp *= scaling_factor; + std::get<45>(evals) += tmp; +} +//Contribution 46 + { +Avm_DECLARE_VIEWS(46); + + + auto tmp = ((avm_alu_p_sub_a_lo_shift - avm_alu_p_sub_b_lo) * avm_alu_rng_chk_sel_shift); + tmp *= scaling_factor; + std::get<46>(evals) += tmp; +} +//Contribution 47 + { +Avm_DECLARE_VIEWS(47); + + + auto tmp = ((avm_alu_p_sub_a_hi_shift - avm_alu_p_sub_b_hi) * avm_alu_rng_chk_sel_shift); + tmp *= scaling_factor; + std::get<47>(evals) += tmp; +} +//Contribution 48 + { +Avm_DECLARE_VIEWS(48); + + + auto tmp = ((avm_alu_p_sub_b_lo_shift - avm_alu_res_lo) * avm_alu_rng_chk_sel_shift); + tmp *= scaling_factor; + std::get<48>(evals) += tmp; +} +//Contribution 49 + { +Avm_DECLARE_VIEWS(49); + + + auto tmp = ((avm_alu_p_sub_b_hi_shift - avm_alu_res_hi) * avm_alu_rng_chk_sel_shift); + tmp *= scaling_factor; + std::get<49>(evals) += tmp; +} +//Contribution 50 + { +Avm_DECLARE_VIEWS(50); + + + auto tmp = (avm_alu_op_cast_prev_shift - avm_alu_op_cast); + tmp *= scaling_factor; + std::get<50>(evals) += tmp; +} +//Contribution 51 + { +Avm_DECLARE_VIEWS(51); + + + auto tmp = (avm_alu_op_cast * (((((((avm_alu_u8_tag * avm_alu_u8_r0) + (avm_alu_u16_tag * (avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))))) + (avm_alu_u32_tag * ((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))))) + (avm_alu_u64_tag * ((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + (avm_alu_u16_r1 * FF(4294967296UL))) + (avm_alu_u16_r2 * FF(281474976710656UL))))) + (avm_alu_u128_tag * ((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + (avm_alu_u16_r1 * FF(4294967296UL))) + (avm_alu_u16_r2 * FF(281474976710656UL))) + (avm_alu_u16_r3 * FF(uint256_t{0UL, 1UL, 0UL, 0UL}))) + (avm_alu_u16_r4 * FF(uint256_t{0UL, 65536UL, 0UL, 0UL}))) + (avm_alu_u16_r5 * FF(uint256_t{0UL, 4294967296UL, 0UL, 0UL}))) + (avm_alu_u16_r6 * FF(uint256_t{0UL, 281474976710656UL, 0UL, 0UL}))))) + (avm_alu_ff_tag * avm_alu_ia)) - avm_alu_ic)); + tmp *= scaling_factor; + std::get<51>(evals) += tmp; +} +//Contribution 52 + { +Avm_DECLARE_VIEWS(52); + + + auto tmp = (avm_alu_op_cast * (avm_alu_a_lo_shift - avm_alu_p_sub_a_lo)); + tmp *= scaling_factor; + std::get<52>(evals) += tmp; +} +//Contribution 53 + { +Avm_DECLARE_VIEWS(53); + + + auto tmp = (avm_alu_op_cast * (avm_alu_a_hi_shift - avm_alu_p_sub_a_hi)); + tmp *= scaling_factor; + std::get<53>(evals) += tmp; +} +//Contribution 54 + { +Avm_DECLARE_VIEWS(54); + + + auto tmp = (((avm_alu_op_mul * avm_alu_ff_tag) + avm_alu_op_cast) * avm_alu_alu_sel_shift); + tmp *= scaling_factor; + std::get<54>(evals) += tmp; +} +//Contribution 55 + { +Avm_DECLARE_VIEWS(55); + + + auto tmp = ((avm_alu_shift_lt_bit_len * avm_alu_op_shr) * (avm_alu_a_lo - ((avm_alu_two_pow_s - avm_alu_b_lo) - FF(1)))); + tmp *= scaling_factor; + std::get<55>(evals) += tmp; +} +//Contribution 56 + { +Avm_DECLARE_VIEWS(56); + + + auto tmp = ((avm_alu_shift_lt_bit_len * avm_alu_op_shr) * (avm_alu_a_hi - ((avm_alu_two_pow_t_sub_s - avm_alu_b_hi) - FF(1)))); + tmp *= scaling_factor; + std::get<56>(evals) += tmp; +} +//Contribution 57 + { +Avm_DECLARE_VIEWS(57); + + + auto tmp = ((avm_alu_shift_lt_bit_len * avm_alu_op_shl) * (avm_alu_a_lo - ((avm_alu_two_pow_t_sub_s - avm_alu_b_lo) - FF(1)))); + tmp *= scaling_factor; + std::get<57>(evals) += tmp; +} +//Contribution 58 + { +Avm_DECLARE_VIEWS(58); + + + auto tmp = ((avm_alu_shift_lt_bit_len * avm_alu_op_shl) * (avm_alu_a_hi - ((avm_alu_two_pow_s - avm_alu_b_hi) - FF(1)))); + tmp *= scaling_factor; + std::get<58>(evals) += tmp; +} +//Contribution 59 + { +Avm_DECLARE_VIEWS(59); + + + auto tmp = (avm_alu_shift_lt_bit_len * (-avm_alu_shift_lt_bit_len + FF(1))); + tmp *= scaling_factor; + std::get<59>(evals) += tmp; +} +//Contribution 60 + { +Avm_DECLARE_VIEWS(60); + + + auto tmp = (avm_alu_t_sub_s_bits - (avm_alu_shift_sel * ((avm_alu_shift_lt_bit_len * ((((((avm_alu_u8_tag * FF(8)) + (avm_alu_u16_tag * FF(16))) + (avm_alu_u32_tag * FF(32))) + (avm_alu_u64_tag * FF(64))) + (avm_alu_u128_tag * FF(128))) - avm_alu_ib)) + ((-avm_alu_shift_lt_bit_len + FF(1)) * (avm_alu_ib - (((((avm_alu_u8_tag * FF(8)) + (avm_alu_u16_tag * FF(16))) + (avm_alu_u32_tag * FF(32))) + (avm_alu_u64_tag * FF(64))) + (avm_alu_u128_tag * FF(128)))))))); + tmp *= scaling_factor; + std::get<60>(evals) += tmp; +} +//Contribution 61 + { +Avm_DECLARE_VIEWS(61); + + + auto tmp = ((avm_alu_shift_lt_bit_len * avm_alu_op_shr) * (((avm_alu_b_hi * avm_alu_two_pow_s) + avm_alu_b_lo) - avm_alu_ia)); + tmp *= scaling_factor; + std::get<61>(evals) += tmp; +} +//Contribution 62 + { +Avm_DECLARE_VIEWS(62); + + + auto tmp = (avm_alu_op_shr * (avm_alu_ic - (avm_alu_b_hi * avm_alu_shift_lt_bit_len))); + tmp *= scaling_factor; + std::get<62>(evals) += tmp; +} +//Contribution 63 + { +Avm_DECLARE_VIEWS(63); + + + auto tmp = ((avm_alu_shift_lt_bit_len * avm_alu_op_shl) * (((avm_alu_b_hi * avm_alu_two_pow_t_sub_s) + avm_alu_b_lo) - avm_alu_ia)); + tmp *= scaling_factor; + std::get<63>(evals) += tmp; +} +//Contribution 64 + { +Avm_DECLARE_VIEWS(64); + + + auto tmp = (avm_alu_op_shl * (avm_alu_ic - ((avm_alu_b_lo * avm_alu_two_pow_s) * avm_alu_shift_lt_bit_len))); + tmp *= scaling_factor; + std::get<64>(evals) += tmp; +} +//Contribution 65 + { +Avm_DECLARE_VIEWS(65); + + + auto tmp = (avm_alu_op_div - (avm_alu_op_div_std + avm_alu_op_div_a_lt_b)); + tmp *= scaling_factor; + std::get<65>(evals) += tmp; +} +//Contribution 66 + { +Avm_DECLARE_VIEWS(66); + + + auto tmp = (avm_alu_op_div_a_lt_b * (-avm_alu_op_div_a_lt_b + FF(1))); + tmp *= scaling_factor; + std::get<66>(evals) += tmp; +} +//Contribution 67 + { +Avm_DECLARE_VIEWS(67); + + + auto tmp = (avm_alu_op_div_a_lt_b * (avm_alu_a_lo - ((avm_alu_ib - avm_alu_ia) - FF(1)))); + tmp *= scaling_factor; + std::get<67>(evals) += tmp; +} +//Contribution 68 + { +Avm_DECLARE_VIEWS(68); + + + auto tmp = (avm_alu_op_div_a_lt_b * avm_alu_ic); + tmp *= scaling_factor; + std::get<68>(evals) += tmp; +} +//Contribution 69 + { +Avm_DECLARE_VIEWS(69); + + + auto tmp = (avm_alu_op_div_a_lt_b * (avm_alu_ia - avm_alu_remainder)); + tmp *= scaling_factor; + std::get<69>(evals) += tmp; +} +//Contribution 70 + { +Avm_DECLARE_VIEWS(70); + + + auto tmp = (avm_alu_op_div_std * (-avm_alu_op_div_std + FF(1))); + tmp *= scaling_factor; + std::get<70>(evals) += tmp; +} +//Contribution 71 + { +Avm_DECLARE_VIEWS(71); + + + auto tmp = (avm_alu_op_div_std * ((avm_alu_ib - avm_alu_divisor_lo) - (avm_alu_divisor_hi * FF(uint256_t{0UL, 1UL, 0UL, 0UL})))); + tmp *= scaling_factor; + std::get<71>(evals) += tmp; +} +//Contribution 72 + { +Avm_DECLARE_VIEWS(72); + + + auto tmp = (avm_alu_op_div_std * ((avm_alu_ic - avm_alu_quotient_lo) - (avm_alu_quotient_hi * FF(uint256_t{0UL, 1UL, 0UL, 0UL})))); + tmp *= scaling_factor; + std::get<72>(evals) += tmp; +} +//Contribution 73 + { +Avm_DECLARE_VIEWS(73); + + + auto tmp = (((avm_alu_divisor_hi * avm_alu_quotient_lo) + (avm_alu_divisor_lo * avm_alu_quotient_hi)) - (avm_alu_partial_prod_lo + (avm_alu_partial_prod_hi * FF(uint256_t{0UL, 1UL, 0UL, 0UL})))); + tmp *= scaling_factor; + std::get<73>(evals) += tmp; +} +//Contribution 74 + { +Avm_DECLARE_VIEWS(74); + + + auto tmp = (avm_alu_op_div_std * ((((avm_alu_divisor_lo * avm_alu_quotient_lo) + (avm_alu_partial_prod_lo * FF(uint256_t{0UL, 1UL, 0UL, 0UL}))) + ((avm_alu_partial_prod_hi + (avm_alu_divisor_hi * avm_alu_quotient_hi)) * FF(uint256_t{0UL, 0UL, 1UL, 0UL}))) - (avm_alu_a_lo + (avm_alu_a_hi * FF(uint256_t{0UL, 0UL, 1UL, 0UL}))))); + tmp *= scaling_factor; + std::get<74>(evals) += tmp; +} +//Contribution 75 + { +Avm_DECLARE_VIEWS(75); + + + auto tmp = (avm_alu_op_div_std * (avm_alu_b_hi - ((avm_alu_ib - avm_alu_remainder) - FF(1)))); + tmp *= scaling_factor; + std::get<75>(evals) += tmp; +} +//Contribution 76 + { +Avm_DECLARE_VIEWS(76); + + + auto tmp = ((avm_alu_cmp_rng_ctr_shift - FF(2)) * avm_alu_op_div_std); + tmp *= scaling_factor; + std::get<76>(evals) += tmp; +} +//Contribution 77 + { +Avm_DECLARE_VIEWS(77); + + + auto tmp = (avm_alu_rng_chk_sel * avm_alu_op_div_std); + tmp *= scaling_factor; + std::get<77>(evals) += tmp; +} +//Contribution 78 + { +Avm_DECLARE_VIEWS(78); + + + auto tmp = (avm_alu_op_div_std * ((((avm_alu_divisor_lo * avm_alu_quotient_lo) + (avm_alu_partial_prod_lo * FF(uint256_t{0UL, 1UL, 0UL, 0UL}))) + ((avm_alu_partial_prod_hi + (avm_alu_divisor_hi * avm_alu_quotient_hi)) * FF(uint256_t{0UL, 0UL, 1UL, 0UL}))) - (avm_alu_ia - avm_alu_remainder))); + tmp *= scaling_factor; + std::get<78>(evals) += tmp; +} +//Contribution 79 + { +Avm_DECLARE_VIEWS(79); + + + auto tmp = (avm_alu_div_rng_chk_selector * (-avm_alu_div_rng_chk_selector + FF(1))); + tmp *= scaling_factor; + std::get<79>(evals) += tmp; +} +//Contribution 80 + { +Avm_DECLARE_VIEWS(80); + + + auto tmp = ((avm_alu_div_rng_chk_selector * avm_alu_div_rng_chk_selector_shift) - avm_alu_op_div_std); + tmp *= scaling_factor; + std::get<80>(evals) += tmp; +} +//Contribution 81 + { +Avm_DECLARE_VIEWS(81); + + + auto tmp = (avm_alu_divisor_lo - (avm_alu_op_div_std * (((avm_alu_div_u16_r0 + (avm_alu_div_u16_r1 * FF(65536))) + (avm_alu_div_u16_r2 * FF(4294967296UL))) + (avm_alu_div_u16_r3 * FF(281474976710656UL))))); + tmp *= scaling_factor; + std::get<81>(evals) += tmp; +} +//Contribution 82 + { +Avm_DECLARE_VIEWS(82); + + + auto tmp = (avm_alu_divisor_hi - (avm_alu_op_div_std * (((avm_alu_div_u16_r4 + (avm_alu_div_u16_r5 * FF(65536))) + (avm_alu_div_u16_r6 * FF(4294967296UL))) + (avm_alu_div_u16_r7 * FF(281474976710656UL))))); + tmp *= scaling_factor; + std::get<82>(evals) += tmp; +} +//Contribution 83 + { +Avm_DECLARE_VIEWS(83); + + + auto tmp = (avm_alu_quotient_lo - (avm_alu_op_div_std * (((avm_alu_div_u16_r0_shift + (avm_alu_div_u16_r1_shift * FF(65536))) + (avm_alu_div_u16_r2_shift * FF(4294967296UL))) + (avm_alu_div_u16_r3_shift * FF(281474976710656UL))))); + tmp *= scaling_factor; + std::get<83>(evals) += tmp; +} +//Contribution 84 + { +Avm_DECLARE_VIEWS(84); + + + auto tmp = (avm_alu_quotient_hi - (avm_alu_op_div_std * (((avm_alu_div_u16_r4_shift + (avm_alu_div_u16_r5_shift * FF(65536))) + (avm_alu_div_u16_r6_shift * FF(4294967296UL))) + (avm_alu_div_u16_r7_shift * FF(281474976710656UL))))); + tmp *= scaling_factor; + std::get<84>(evals) += tmp; +} +//Contribution 85 + { +Avm_DECLARE_VIEWS(85); + + + auto tmp = (avm_alu_partial_prod_lo - (avm_alu_op_div_std * ((((avm_alu_u8_r0_shift + (avm_alu_u8_r1_shift * FF(256))) + (avm_alu_u16_r0_shift * FF(65536))) + (avm_alu_u16_r1_shift * FF(4294967296UL))) + (avm_alu_u16_r2_shift * FF(281474976710656UL))))); + tmp *= scaling_factor; + std::get<85>(evals) += tmp; +} +//Contribution 86 + { +Avm_DECLARE_VIEWS(86); + + + auto tmp = (avm_alu_partial_prod_hi - (avm_alu_op_div_std * (((avm_alu_u16_r3_shift + (avm_alu_u16_r4_shift * FF(65536))) + (avm_alu_u16_r5_shift * FF(4294967296UL))) + (avm_alu_u16_r6_shift * FF(281474976710656UL))))); + tmp *= scaling_factor; + std::get<86>(evals) += tmp; +} +} - // Contribution 0 - { - Avm_DECLARE_VIEWS(0); - - auto tmp = - (avm_alu_alu_sel - - ((((((((((avm_alu_op_add + avm_alu_op_sub) + avm_alu_op_mul) + avm_alu_op_not) + avm_alu_op_eq) + - avm_alu_op_cast) + - avm_alu_op_lt) + - avm_alu_op_lte) + - avm_alu_op_shr) + - avm_alu_op_shl) + - avm_alu_op_div)); - tmp *= scaling_factor; - std::get<0>(evals) += tmp; - } - // Contribution 1 - { - Avm_DECLARE_VIEWS(1); - - auto tmp = (avm_alu_cmp_sel - (avm_alu_op_lt + avm_alu_op_lte)); - tmp *= scaling_factor; - std::get<1>(evals) += tmp; - } - // Contribution 2 - { - Avm_DECLARE_VIEWS(2); - - auto tmp = (avm_alu_shift_sel - (avm_alu_op_shl + avm_alu_op_shr)); - tmp *= scaling_factor; - std::get<2>(evals) += tmp; - } - // Contribution 3 - { - Avm_DECLARE_VIEWS(3); - - auto tmp = (avm_alu_cf * (-avm_alu_cf + FF(1))); - tmp *= scaling_factor; - std::get<3>(evals) += tmp; - } - // Contribution 4 - { - Avm_DECLARE_VIEWS(4); - - auto tmp = (avm_alu_ff_tag * (-avm_alu_ff_tag + FF(1))); - tmp *= scaling_factor; - std::get<4>(evals) += tmp; - } - // Contribution 5 - { - Avm_DECLARE_VIEWS(5); - - auto tmp = (avm_alu_u8_tag * (-avm_alu_u8_tag + FF(1))); - tmp *= scaling_factor; - std::get<5>(evals) += tmp; - } - // Contribution 6 - { - Avm_DECLARE_VIEWS(6); - - auto tmp = (avm_alu_u16_tag * (-avm_alu_u16_tag + FF(1))); - tmp *= scaling_factor; - std::get<6>(evals) += tmp; - } - // Contribution 7 - { - Avm_DECLARE_VIEWS(7); - - auto tmp = (avm_alu_u32_tag * (-avm_alu_u32_tag + FF(1))); - tmp *= scaling_factor; - std::get<7>(evals) += tmp; - } - // Contribution 8 - { - Avm_DECLARE_VIEWS(8); - - auto tmp = (avm_alu_u64_tag * (-avm_alu_u64_tag + FF(1))); - tmp *= scaling_factor; - std::get<8>(evals) += tmp; - } - // Contribution 9 - { - Avm_DECLARE_VIEWS(9); - - auto tmp = (avm_alu_u128_tag * (-avm_alu_u128_tag + FF(1))); - tmp *= scaling_factor; - std::get<9>(evals) += tmp; - } - // Contribution 10 - { - Avm_DECLARE_VIEWS(10); - - auto tmp = - (avm_alu_alu_sel * - ((((((avm_alu_ff_tag + avm_alu_u8_tag) + avm_alu_u16_tag) + avm_alu_u32_tag) + avm_alu_u64_tag) + - avm_alu_u128_tag) - - FF(1))); - tmp *= scaling_factor; - std::get<10>(evals) += tmp; - } - // Contribution 11 - { - Avm_DECLARE_VIEWS(11); - - auto tmp = (avm_alu_in_tag - (((((avm_alu_u8_tag + (avm_alu_u16_tag * FF(2))) + (avm_alu_u32_tag * FF(3))) + - (avm_alu_u64_tag * FF(4))) + - (avm_alu_u128_tag * FF(5))) + - (avm_alu_ff_tag * FF(6)))); - tmp *= scaling_factor; - std::get<11>(evals) += tmp; - } - // Contribution 12 - { - Avm_DECLARE_VIEWS(12); - - auto tmp = (((avm_alu_op_add + avm_alu_op_sub) * - ((((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + - (avm_alu_u16_r1 * FF(4294967296UL))) + - (avm_alu_u16_r2 * FF(281474976710656UL))) + - (avm_alu_u16_r3 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + - (avm_alu_u16_r4 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + - (avm_alu_u16_r5 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + - (avm_alu_u16_r6 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }))) - - avm_alu_ia) + - (avm_alu_ff_tag * avm_alu_ic))) + - ((avm_alu_op_add - avm_alu_op_sub) * - ((avm_alu_cf * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL })) - avm_alu_ib))); - tmp *= scaling_factor; - std::get<12>(evals) += tmp; - } - // Contribution 13 - { - Avm_DECLARE_VIEWS(13); - - auto tmp = (((avm_alu_op_add + avm_alu_op_sub) * - (((((((avm_alu_u8_tag * avm_alu_u8_r0) + - (avm_alu_u16_tag * (avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))))) + - (avm_alu_u32_tag * - ((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))))) + - (avm_alu_u64_tag * - ((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + - (avm_alu_u16_r1 * FF(4294967296UL))) + - (avm_alu_u16_r2 * FF(281474976710656UL))))) + - (avm_alu_u128_tag * - ((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + - (avm_alu_u16_r1 * FF(4294967296UL))) + - (avm_alu_u16_r2 * FF(281474976710656UL))) + - (avm_alu_u16_r3 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + - (avm_alu_u16_r4 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + - (avm_alu_u16_r5 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + - (avm_alu_u16_r6 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }))))) + - (avm_alu_ff_tag * avm_alu_ia)) - - avm_alu_ic)) + - ((avm_alu_ff_tag * (avm_alu_op_add - avm_alu_op_sub)) * avm_alu_ib)); - tmp *= scaling_factor; - std::get<13>(evals) += tmp; - } - // Contribution 14 - { - Avm_DECLARE_VIEWS(14); - - auto tmp = ((avm_alu_ff_tag * avm_alu_op_mul) * ((avm_alu_ia * avm_alu_ib) - avm_alu_ic)); - tmp *= scaling_factor; - std::get<14>(evals) += tmp; - } - // Contribution 15 - { - Avm_DECLARE_VIEWS(15); - - auto tmp = ((((-avm_alu_ff_tag + FF(1)) - avm_alu_u128_tag) * avm_alu_op_mul) * - (((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + - (avm_alu_u16_r1 * FF(4294967296UL))) + - (avm_alu_u16_r2 * FF(281474976710656UL))) + - (avm_alu_u16_r3 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + - (avm_alu_u16_r4 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + - (avm_alu_u16_r5 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + - (avm_alu_u16_r6 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }))) - - (avm_alu_ia * avm_alu_ib))); - tmp *= scaling_factor; - std::get<15>(evals) += tmp; - } - // Contribution 16 - { - Avm_DECLARE_VIEWS(16); - - auto tmp = - (avm_alu_op_mul * - (((((avm_alu_u8_tag * avm_alu_u8_r0) + - (avm_alu_u16_tag * (avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))))) + - (avm_alu_u32_tag * ((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))))) + - (avm_alu_u64_tag * ((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + - (avm_alu_u16_r1 * FF(4294967296UL))) + - (avm_alu_u16_r2 * FF(281474976710656UL))))) - - (((-avm_alu_ff_tag + FF(1)) - avm_alu_u128_tag) * avm_alu_ic))); - tmp *= scaling_factor; - std::get<16>(evals) += tmp; - } - // Contribution 17 - { - Avm_DECLARE_VIEWS(17); - - auto tmp = ((avm_alu_u128_tag * avm_alu_op_mul) * - ((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + - (avm_alu_u16_r1 * FF(4294967296UL))) + - (avm_alu_u16_r2 * FF(281474976710656UL))) + - ((((avm_alu_u16_r3 + (avm_alu_u16_r4 * FF(65536))) + (avm_alu_u16_r5 * FF(4294967296UL))) + - (avm_alu_u16_r6 * FF(281474976710656UL))) * - FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) - - avm_alu_ia)); - tmp *= scaling_factor; - std::get<17>(evals) += tmp; - } - // Contribution 18 - { - Avm_DECLARE_VIEWS(18); - - auto tmp = - ((avm_alu_u128_tag * avm_alu_op_mul) * - ((((((avm_alu_u8_r0_shift + (avm_alu_u8_r1_shift * FF(256))) + (avm_alu_u16_r0_shift * FF(65536))) + - (avm_alu_u16_r1_shift * FF(4294967296UL))) + - (avm_alu_u16_r2_shift * FF(281474976710656UL))) + - ((((avm_alu_u16_r3_shift + (avm_alu_u16_r4_shift * FF(65536))) + - (avm_alu_u16_r5_shift * FF(4294967296UL))) + - (avm_alu_u16_r6_shift * FF(281474976710656UL))) * - FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) - - avm_alu_ib)); - tmp *= scaling_factor; - std::get<18>(evals) += tmp; - } - // Contribution 19 - { - Avm_DECLARE_VIEWS(19); - - auto tmp = - ((avm_alu_u128_tag * avm_alu_op_mul) * - ((((avm_alu_ia * - ((((avm_alu_u8_r0_shift + (avm_alu_u8_r1_shift * FF(256))) + (avm_alu_u16_r0_shift * FF(65536))) + - (avm_alu_u16_r1_shift * FF(4294967296UL))) + - (avm_alu_u16_r2_shift * FF(281474976710656UL)))) + - ((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + - (avm_alu_u16_r1 * FF(4294967296UL))) + - (avm_alu_u16_r2 * FF(281474976710656UL))) * - (((avm_alu_u16_r3_shift + (avm_alu_u16_r4_shift * FF(65536))) + - (avm_alu_u16_r5_shift * FF(4294967296UL))) + - (avm_alu_u16_r6_shift * FF(281474976710656UL)))) * - FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) - - (((avm_alu_cf * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL })) + - (((avm_alu_u16_r7 + (avm_alu_u16_r8 * FF(65536))) + (avm_alu_u16_r9 * FF(4294967296UL))) + - (avm_alu_u16_r10 * FF(281474976710656UL)))) * - FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) - - avm_alu_ic)); - tmp *= scaling_factor; - std::get<19>(evals) += tmp; - } - // Contribution 20 - { - Avm_DECLARE_VIEWS(20); - - auto tmp = (avm_alu_op_not * avm_alu_ff_tag); - tmp *= scaling_factor; - std::get<20>(evals) += tmp; - } - // Contribution 21 - { - Avm_DECLARE_VIEWS(21); - - auto tmp = (avm_alu_op_not * - ((avm_alu_ia + avm_alu_ic) - ((((((avm_alu_u8_tag * FF(256)) + (avm_alu_u16_tag * FF(65536))) + - (avm_alu_u32_tag * FF(4294967296UL))) + - (avm_alu_u64_tag * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + - (avm_alu_u128_tag * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) - - FF(1)))); - tmp *= scaling_factor; - std::get<21>(evals) += tmp; - } - // Contribution 22 - { - Avm_DECLARE_VIEWS(22); - - auto tmp = ((avm_alu_cmp_sel + avm_alu_op_eq) * (avm_alu_ic * (-avm_alu_ic + FF(1)))); - tmp *= scaling_factor; - std::get<22>(evals) += tmp; - } - // Contribution 23 - { - Avm_DECLARE_VIEWS(23); - - auto tmp = - (avm_alu_op_eq * ((((avm_alu_ia - avm_alu_ib) * - ((avm_alu_ic * (-avm_alu_op_eq_diff_inv + FF(1))) + avm_alu_op_eq_diff_inv)) - - FF(1)) + - avm_alu_ic)); - tmp *= scaling_factor; - std::get<23>(evals) += tmp; - } - // Contribution 24 - { - Avm_DECLARE_VIEWS(24); - - auto tmp = (((avm_alu_op_lt * avm_alu_ib) + ((avm_alu_op_lte + avm_alu_op_cast) * avm_alu_ia)) - - ((avm_alu_a_lo + (avm_alu_a_hi * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) * - (avm_alu_cmp_sel + avm_alu_op_cast))); - tmp *= scaling_factor; - std::get<24>(evals) += tmp; - } - // Contribution 25 - { - Avm_DECLARE_VIEWS(25); - - auto tmp = (((avm_alu_op_lt * avm_alu_ia) + (avm_alu_op_lte * avm_alu_ib)) - - ((avm_alu_b_lo + (avm_alu_b_hi * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) * avm_alu_cmp_sel)); - tmp *= scaling_factor; - std::get<25>(evals) += tmp; - } - // Contribution 26 - { - Avm_DECLARE_VIEWS(26); - - auto tmp = (avm_alu_p_a_borrow * (-avm_alu_p_a_borrow + FF(1))); - tmp *= scaling_factor; - std::get<26>(evals) += tmp; - } - // Contribution 27 - { - Avm_DECLARE_VIEWS(27); - - auto tmp = ((avm_alu_p_sub_a_lo - - ((-avm_alu_a_lo + FF(uint256_t{ 4891460686036598784UL, 2896914383306846353UL, 0UL, 0UL })) + - (avm_alu_p_a_borrow * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL })))) * - ((avm_alu_cmp_sel + avm_alu_op_cast) + avm_alu_op_div_std)); - tmp *= scaling_factor; - std::get<27>(evals) += tmp; - } - // Contribution 28 - { - Avm_DECLARE_VIEWS(28); - - auto tmp = ((avm_alu_p_sub_a_hi - - ((-avm_alu_a_hi + FF(uint256_t{ 13281191951274694749UL, 3486998266802970665UL, 0UL, 0UL })) - - avm_alu_p_a_borrow)) * - ((avm_alu_cmp_sel + avm_alu_op_cast) + avm_alu_op_div_std)); - tmp *= scaling_factor; - std::get<28>(evals) += tmp; - } - // Contribution 29 - { - Avm_DECLARE_VIEWS(29); - - auto tmp = (avm_alu_p_b_borrow * (-avm_alu_p_b_borrow + FF(1))); - tmp *= scaling_factor; - std::get<29>(evals) += tmp; - } - // Contribution 30 - { - Avm_DECLARE_VIEWS(30); - - auto tmp = ((avm_alu_p_sub_b_lo - - ((-avm_alu_b_lo + FF(uint256_t{ 4891460686036598784UL, 2896914383306846353UL, 0UL, 0UL })) + - (avm_alu_p_b_borrow * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL })))) * - avm_alu_cmp_sel); - tmp *= scaling_factor; - std::get<30>(evals) += tmp; - } - // Contribution 31 - { - Avm_DECLARE_VIEWS(31); - - auto tmp = ((avm_alu_p_sub_b_hi - - ((-avm_alu_b_hi + FF(uint256_t{ 13281191951274694749UL, 3486998266802970665UL, 0UL, 0UL })) - - avm_alu_p_b_borrow)) * - avm_alu_cmp_sel); - tmp *= scaling_factor; - std::get<31>(evals) += tmp; - } - // Contribution 32 - { - Avm_DECLARE_VIEWS(32); - - auto tmp = - ((avm_alu_res_lo - - (((((avm_alu_a_lo - avm_alu_b_lo) - FF(1)) + (avm_alu_borrow * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) * - ((avm_alu_op_lt * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_op_lte))) + - (((avm_alu_b_lo - avm_alu_a_lo) + (avm_alu_borrow * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) * - (-((avm_alu_op_lt * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_op_lte)) + FF(1))))) * - avm_alu_cmp_sel); - tmp *= scaling_factor; - std::get<32>(evals) += tmp; - } - // Contribution 33 - { - Avm_DECLARE_VIEWS(33); - - auto tmp = ((avm_alu_res_hi - - ((((avm_alu_a_hi - avm_alu_b_hi) - avm_alu_borrow) * - ((avm_alu_op_lt * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_op_lte))) + - (((avm_alu_b_hi - avm_alu_a_hi) - avm_alu_borrow) * - (-((avm_alu_op_lt * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_op_lte)) + FF(1))))) * - avm_alu_cmp_sel); - tmp *= scaling_factor; - std::get<33>(evals) += tmp; - } - // Contribution 34 - { - Avm_DECLARE_VIEWS(34); - - auto tmp = (((avm_alu_cmp_rng_ctr_shift - avm_alu_cmp_rng_ctr) + FF(1)) * avm_alu_cmp_rng_ctr); - tmp *= scaling_factor; - std::get<34>(evals) += tmp; - } - // Contribution 35 - { - Avm_DECLARE_VIEWS(35); - - auto tmp = ((avm_alu_cmp_rng_ctr_shift - FF(4)) * avm_alu_cmp_sel); - tmp *= scaling_factor; - std::get<35>(evals) += tmp; - } - // Contribution 36 - { - Avm_DECLARE_VIEWS(36); - - auto tmp = (avm_alu_rng_chk_sel * (-avm_alu_rng_chk_sel + FF(1))); - tmp *= scaling_factor; - std::get<36>(evals) += tmp; - } - // Contribution 37 - { - Avm_DECLARE_VIEWS(37); - - auto tmp = (avm_alu_rng_chk_sel * avm_alu_cmp_sel); - tmp *= scaling_factor; - std::get<37>(evals) += tmp; - } - // Contribution 38 - { - Avm_DECLARE_VIEWS(38); - - auto tmp = ((avm_alu_cmp_rng_ctr * (((-avm_alu_rng_chk_sel + FF(1)) * (-avm_alu_op_eq_diff_inv + FF(1))) + - avm_alu_op_eq_diff_inv)) - - avm_alu_rng_chk_sel); - tmp *= scaling_factor; - std::get<38>(evals) += tmp; - } - // Contribution 39 - { - Avm_DECLARE_VIEWS(39); - - auto tmp = (avm_alu_rng_chk_lookup_selector_shift - - ((((((((((avm_alu_cmp_sel_shift + avm_alu_rng_chk_sel_shift) + avm_alu_op_add_shift) + - avm_alu_op_sub_shift) + - avm_alu_op_mul_shift) + - (avm_alu_op_mul * avm_alu_u128_tag)) + - avm_alu_op_cast_shift) + - avm_alu_op_cast_prev_shift) + - avm_alu_op_shl_shift) + - avm_alu_op_shr_shift) + - avm_alu_op_div_shift)); - tmp *= scaling_factor; - std::get<39>(evals) += tmp; - } - // Contribution 40 - { - Avm_DECLARE_VIEWS(40); - - auto tmp = (avm_alu_a_lo - - (((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + - (avm_alu_u16_r1 * FF(4294967296UL))) + - (avm_alu_u16_r2 * FF(281474976710656UL))) + - (avm_alu_u16_r3 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + - (avm_alu_u16_r4 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + - (avm_alu_u16_r5 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + - (avm_alu_u16_r6 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }))) * - (((((avm_alu_rng_chk_sel + avm_alu_cmp_sel) + avm_alu_op_cast) + avm_alu_op_cast_prev) + - avm_alu_shift_lt_bit_len) + - avm_alu_op_div))); - tmp *= scaling_factor; - std::get<40>(evals) += tmp; - } - // Contribution 41 - { - Avm_DECLARE_VIEWS(41); - - auto tmp = (avm_alu_a_hi - - ((((((((avm_alu_u16_r7 + (avm_alu_u16_r8 * FF(65536))) + (avm_alu_u16_r9 * FF(4294967296UL))) + - (avm_alu_u16_r10 * FF(281474976710656UL))) + - (avm_alu_u16_r11 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + - (avm_alu_u16_r12 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + - (avm_alu_u16_r13 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + - (avm_alu_u16_r14 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }))) * - (((((avm_alu_rng_chk_sel + avm_alu_cmp_sel) + avm_alu_op_cast) + avm_alu_op_cast_prev) + - avm_alu_shift_lt_bit_len) + - avm_alu_op_div))); - tmp *= scaling_factor; - std::get<41>(evals) += tmp; - } - // Contribution 42 - { - Avm_DECLARE_VIEWS(42); - - auto tmp = ((avm_alu_a_lo_shift - avm_alu_b_lo) * avm_alu_rng_chk_sel_shift); - tmp *= scaling_factor; - std::get<42>(evals) += tmp; - } - // Contribution 43 - { - Avm_DECLARE_VIEWS(43); - - auto tmp = ((avm_alu_a_hi_shift - avm_alu_b_hi) * avm_alu_rng_chk_sel_shift); - tmp *= scaling_factor; - std::get<43>(evals) += tmp; - } - // Contribution 44 - { - Avm_DECLARE_VIEWS(44); - - auto tmp = ((avm_alu_b_lo_shift - avm_alu_p_sub_a_lo) * avm_alu_rng_chk_sel_shift); - tmp *= scaling_factor; - std::get<44>(evals) += tmp; - } - // Contribution 45 - { - Avm_DECLARE_VIEWS(45); - - auto tmp = ((avm_alu_b_hi_shift - avm_alu_p_sub_a_hi) * avm_alu_rng_chk_sel_shift); - tmp *= scaling_factor; - std::get<45>(evals) += tmp; - } - // Contribution 46 - { - Avm_DECLARE_VIEWS(46); - - auto tmp = ((avm_alu_p_sub_a_lo_shift - avm_alu_p_sub_b_lo) * avm_alu_rng_chk_sel_shift); - tmp *= scaling_factor; - std::get<46>(evals) += tmp; - } - // Contribution 47 - { - Avm_DECLARE_VIEWS(47); - - auto tmp = ((avm_alu_p_sub_a_hi_shift - avm_alu_p_sub_b_hi) * avm_alu_rng_chk_sel_shift); - tmp *= scaling_factor; - std::get<47>(evals) += tmp; - } - // Contribution 48 - { - Avm_DECLARE_VIEWS(48); - - auto tmp = ((avm_alu_p_sub_b_lo_shift - avm_alu_res_lo) * avm_alu_rng_chk_sel_shift); - tmp *= scaling_factor; - std::get<48>(evals) += tmp; - } - // Contribution 49 - { - Avm_DECLARE_VIEWS(49); - - auto tmp = ((avm_alu_p_sub_b_hi_shift - avm_alu_res_hi) * avm_alu_rng_chk_sel_shift); - tmp *= scaling_factor; - std::get<49>(evals) += tmp; - } - // Contribution 50 - { - Avm_DECLARE_VIEWS(50); - - auto tmp = (avm_alu_op_cast_prev_shift - avm_alu_op_cast); - tmp *= scaling_factor; - std::get<50>(evals) += tmp; - } - // Contribution 51 - { - Avm_DECLARE_VIEWS(51); - - auto tmp = - (avm_alu_op_cast * - (((((((avm_alu_u8_tag * avm_alu_u8_r0) + - (avm_alu_u16_tag * (avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))))) + - (avm_alu_u32_tag * - ((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))))) + - (avm_alu_u64_tag * ((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + - (avm_alu_u16_r1 * FF(4294967296UL))) + - (avm_alu_u16_r2 * FF(281474976710656UL))))) + - (avm_alu_u128_tag * - ((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + - (avm_alu_u16_r1 * FF(4294967296UL))) + - (avm_alu_u16_r2 * FF(281474976710656UL))) + - (avm_alu_u16_r3 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + - (avm_alu_u16_r4 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + - (avm_alu_u16_r5 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + - (avm_alu_u16_r6 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }))))) + - (avm_alu_ff_tag * avm_alu_ia)) - - avm_alu_ic)); - tmp *= scaling_factor; - std::get<51>(evals) += tmp; - } - // Contribution 52 - { - Avm_DECLARE_VIEWS(52); - - auto tmp = (avm_alu_op_cast * (avm_alu_a_lo_shift - avm_alu_p_sub_a_lo)); - tmp *= scaling_factor; - std::get<52>(evals) += tmp; - } - // Contribution 53 - { - Avm_DECLARE_VIEWS(53); - - auto tmp = (avm_alu_op_cast * (avm_alu_a_hi_shift - avm_alu_p_sub_a_hi)); - tmp *= scaling_factor; - std::get<53>(evals) += tmp; - } - // Contribution 54 - { - Avm_DECLARE_VIEWS(54); - - auto tmp = (((avm_alu_op_mul * avm_alu_ff_tag) + avm_alu_op_cast) * avm_alu_alu_sel_shift); - tmp *= scaling_factor; - std::get<54>(evals) += tmp; - } - // Contribution 55 - { - Avm_DECLARE_VIEWS(55); - - auto tmp = ((avm_alu_shift_lt_bit_len * avm_alu_op_shr) * - (avm_alu_a_lo - ((avm_alu_two_pow_s - avm_alu_b_lo) - FF(1)))); - tmp *= scaling_factor; - std::get<55>(evals) += tmp; - } - // Contribution 56 - { - Avm_DECLARE_VIEWS(56); - - auto tmp = ((avm_alu_shift_lt_bit_len * avm_alu_op_shr) * - (avm_alu_a_hi - ((avm_alu_two_pow_t_sub_s - avm_alu_b_hi) - FF(1)))); - tmp *= scaling_factor; - std::get<56>(evals) += tmp; - } - // Contribution 57 - { - Avm_DECLARE_VIEWS(57); - - auto tmp = ((avm_alu_shift_lt_bit_len * avm_alu_op_shl) * - (avm_alu_a_lo - ((avm_alu_two_pow_t_sub_s - avm_alu_b_lo) - FF(1)))); - tmp *= scaling_factor; - std::get<57>(evals) += tmp; - } - // Contribution 58 - { - Avm_DECLARE_VIEWS(58); - - auto tmp = ((avm_alu_shift_lt_bit_len * avm_alu_op_shl) * - (avm_alu_a_hi - ((avm_alu_two_pow_s - avm_alu_b_hi) - FF(1)))); - tmp *= scaling_factor; - std::get<58>(evals) += tmp; - } - // Contribution 59 - { - Avm_DECLARE_VIEWS(59); - - auto tmp = (avm_alu_shift_lt_bit_len * (-avm_alu_shift_lt_bit_len + FF(1))); - tmp *= scaling_factor; - std::get<59>(evals) += tmp; - } - // Contribution 60 - { - Avm_DECLARE_VIEWS(60); - - auto tmp = (avm_alu_t_sub_s_bits - - (avm_alu_shift_sel * - ((avm_alu_shift_lt_bit_len * - ((((((avm_alu_u8_tag * FF(8)) + (avm_alu_u16_tag * FF(16))) + (avm_alu_u32_tag * FF(32))) + - (avm_alu_u64_tag * FF(64))) + - (avm_alu_u128_tag * FF(128))) - - avm_alu_ib)) + - ((-avm_alu_shift_lt_bit_len + FF(1)) * - (avm_alu_ib - - (((((avm_alu_u8_tag * FF(8)) + (avm_alu_u16_tag * FF(16))) + (avm_alu_u32_tag * FF(32))) + - (avm_alu_u64_tag * FF(64))) + - (avm_alu_u128_tag * FF(128)))))))); - tmp *= scaling_factor; - std::get<60>(evals) += tmp; - } - // Contribution 61 - { - Avm_DECLARE_VIEWS(61); - - auto tmp = ((avm_alu_shift_lt_bit_len * avm_alu_op_shr) * - (((avm_alu_b_hi * avm_alu_two_pow_s) + avm_alu_b_lo) - avm_alu_ia)); - tmp *= scaling_factor; - std::get<61>(evals) += tmp; - } - // Contribution 62 - { - Avm_DECLARE_VIEWS(62); - - auto tmp = (avm_alu_op_shr * (avm_alu_ic - (avm_alu_b_hi * avm_alu_shift_lt_bit_len))); - tmp *= scaling_factor; - std::get<62>(evals) += tmp; - } - // Contribution 63 - { - Avm_DECLARE_VIEWS(63); - - auto tmp = ((avm_alu_shift_lt_bit_len * avm_alu_op_shl) * - (((avm_alu_b_hi * avm_alu_two_pow_t_sub_s) + avm_alu_b_lo) - avm_alu_ia)); - tmp *= scaling_factor; - std::get<63>(evals) += tmp; - } - // Contribution 64 - { - Avm_DECLARE_VIEWS(64); - - auto tmp = - (avm_alu_op_shl * (avm_alu_ic - ((avm_alu_b_lo * avm_alu_two_pow_s) * avm_alu_shift_lt_bit_len))); - tmp *= scaling_factor; - std::get<64>(evals) += tmp; - } - // Contribution 65 - { - Avm_DECLARE_VIEWS(65); - - auto tmp = (avm_alu_op_div - (avm_alu_op_div_std + avm_alu_op_div_a_lt_b)); - tmp *= scaling_factor; - std::get<65>(evals) += tmp; - } - // Contribution 66 - { - Avm_DECLARE_VIEWS(66); - - auto tmp = (avm_alu_op_div_a_lt_b * (-avm_alu_op_div_a_lt_b + FF(1))); - tmp *= scaling_factor; - std::get<66>(evals) += tmp; - } - // Contribution 67 - { - Avm_DECLARE_VIEWS(67); - - auto tmp = (avm_alu_op_div_a_lt_b * (avm_alu_a_lo - ((avm_alu_ib - avm_alu_ia) - FF(1)))); - tmp *= scaling_factor; - std::get<67>(evals) += tmp; - } - // Contribution 68 - { - Avm_DECLARE_VIEWS(68); - - auto tmp = (avm_alu_op_div_a_lt_b * avm_alu_ic); - tmp *= scaling_factor; - std::get<68>(evals) += tmp; - } - // Contribution 69 - { - Avm_DECLARE_VIEWS(69); - - auto tmp = (avm_alu_op_div_a_lt_b * (avm_alu_ia - avm_alu_remainder)); - tmp *= scaling_factor; - std::get<69>(evals) += tmp; - } - // Contribution 70 - { - Avm_DECLARE_VIEWS(70); - - auto tmp = (avm_alu_op_div_std * (-avm_alu_op_div_std + FF(1))); - tmp *= scaling_factor; - std::get<70>(evals) += tmp; - } - // Contribution 71 - { - Avm_DECLARE_VIEWS(71); - - auto tmp = (avm_alu_op_div_std * ((avm_alu_ib - avm_alu_divisor_lo) - - (avm_alu_divisor_hi * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL })))); - tmp *= scaling_factor; - std::get<71>(evals) += tmp; - } - // Contribution 72 - { - Avm_DECLARE_VIEWS(72); - - auto tmp = (avm_alu_op_div_std * ((avm_alu_ic - avm_alu_quotient_lo) - - (avm_alu_quotient_hi * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL })))); - tmp *= scaling_factor; - std::get<72>(evals) += tmp; - } - // Contribution 73 - { - Avm_DECLARE_VIEWS(73); - - auto tmp = (((avm_alu_divisor_hi * avm_alu_quotient_lo) + (avm_alu_divisor_lo * avm_alu_quotient_hi)) - - (avm_alu_partial_prod_lo + (avm_alu_partial_prod_hi * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL })))); - tmp *= scaling_factor; - std::get<73>(evals) += tmp; - } - // Contribution 74 - { - Avm_DECLARE_VIEWS(74); - - auto tmp = (avm_alu_op_div_std * ((((avm_alu_divisor_lo * avm_alu_quotient_lo) + - (avm_alu_partial_prod_lo * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + - ((avm_alu_partial_prod_hi + (avm_alu_divisor_hi * avm_alu_quotient_hi)) * - FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) - - (avm_alu_a_lo + (avm_alu_a_hi * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))))); - tmp *= scaling_factor; - std::get<74>(evals) += tmp; - } - // Contribution 75 - { - Avm_DECLARE_VIEWS(75); - - auto tmp = (avm_alu_op_div_std * (avm_alu_b_hi - ((avm_alu_ib - avm_alu_remainder) - FF(1)))); - tmp *= scaling_factor; - std::get<75>(evals) += tmp; - } - // Contribution 76 - { - Avm_DECLARE_VIEWS(76); - - auto tmp = ((avm_alu_cmp_rng_ctr_shift - FF(2)) * avm_alu_op_div_std); - tmp *= scaling_factor; - std::get<76>(evals) += tmp; - } - // Contribution 77 - { - Avm_DECLARE_VIEWS(77); - - auto tmp = (avm_alu_rng_chk_sel * avm_alu_op_div_std); - tmp *= scaling_factor; - std::get<77>(evals) += tmp; - } - // Contribution 78 - { - Avm_DECLARE_VIEWS(78); - - auto tmp = (avm_alu_op_div_std * ((((avm_alu_divisor_lo * avm_alu_quotient_lo) + - (avm_alu_partial_prod_lo * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + - ((avm_alu_partial_prod_hi + (avm_alu_divisor_hi * avm_alu_quotient_hi)) * - FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) - - (avm_alu_ia - avm_alu_remainder))); - tmp *= scaling_factor; - std::get<78>(evals) += tmp; - } - // Contribution 79 - { - Avm_DECLARE_VIEWS(79); - - auto tmp = (avm_alu_div_rng_chk_selector * (-avm_alu_div_rng_chk_selector + FF(1))); - tmp *= scaling_factor; - std::get<79>(evals) += tmp; - } - // Contribution 80 - { - Avm_DECLARE_VIEWS(80); - - auto tmp = ((avm_alu_div_rng_chk_selector * avm_alu_div_rng_chk_selector_shift) - avm_alu_op_div_std); - tmp *= scaling_factor; - std::get<80>(evals) += tmp; - } - // Contribution 81 - { - Avm_DECLARE_VIEWS(81); - - auto tmp = - (avm_alu_divisor_lo - (avm_alu_op_div_std * (((avm_alu_div_u16_r0 + (avm_alu_div_u16_r1 * FF(65536))) + - (avm_alu_div_u16_r2 * FF(4294967296UL))) + - (avm_alu_div_u16_r3 * FF(281474976710656UL))))); - tmp *= scaling_factor; - std::get<81>(evals) += tmp; - } - // Contribution 82 - { - Avm_DECLARE_VIEWS(82); - - auto tmp = - (avm_alu_divisor_hi - (avm_alu_op_div_std * (((avm_alu_div_u16_r4 + (avm_alu_div_u16_r5 * FF(65536))) + - (avm_alu_div_u16_r6 * FF(4294967296UL))) + - (avm_alu_div_u16_r7 * FF(281474976710656UL))))); - tmp *= scaling_factor; - std::get<82>(evals) += tmp; - } - // Contribution 83 - { - Avm_DECLARE_VIEWS(83); - - auto tmp = (avm_alu_quotient_lo - - (avm_alu_op_div_std * (((avm_alu_div_u16_r0_shift + (avm_alu_div_u16_r1_shift * FF(65536))) + - (avm_alu_div_u16_r2_shift * FF(4294967296UL))) + - (avm_alu_div_u16_r3_shift * FF(281474976710656UL))))); - tmp *= scaling_factor; - std::get<83>(evals) += tmp; - } - // Contribution 84 - { - Avm_DECLARE_VIEWS(84); - - auto tmp = (avm_alu_quotient_hi - - (avm_alu_op_div_std * (((avm_alu_div_u16_r4_shift + (avm_alu_div_u16_r5_shift * FF(65536))) + - (avm_alu_div_u16_r6_shift * FF(4294967296UL))) + - (avm_alu_div_u16_r7_shift * FF(281474976710656UL))))); - tmp *= scaling_factor; - std::get<84>(evals) += tmp; - } - // Contribution 85 - { - Avm_DECLARE_VIEWS(85); - - auto tmp = - (avm_alu_partial_prod_lo - - (avm_alu_op_div_std * - ((((avm_alu_u8_r0_shift + (avm_alu_u8_r1_shift * FF(256))) + (avm_alu_u16_r0_shift * FF(65536))) + - (avm_alu_u16_r1_shift * FF(4294967296UL))) + - (avm_alu_u16_r2_shift * FF(281474976710656UL))))); - tmp *= scaling_factor; - std::get<85>(evals) += tmp; - } - // Contribution 86 - { - Avm_DECLARE_VIEWS(86); - - auto tmp = (avm_alu_partial_prod_hi - - (avm_alu_op_div_std * (((avm_alu_u16_r3_shift + (avm_alu_u16_r4_shift * FF(65536))) + - (avm_alu_u16_r5_shift * FF(4294967296UL))) + - (avm_alu_u16_r6_shift * FF(281474976710656UL))))); - tmp *= scaling_factor; - std::get<86>(evals) += tmp; - } - } }; template using avm_alu = Relation>; -} // namespace bb::Avm_vm \ No newline at end of file + } \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_binary.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_binary.hpp index e58112cbfd7..e99d59d2e7a 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_binary.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_binary.hpp @@ -6,152 +6,170 @@ namespace bb::Avm_vm { -template struct Avm_binaryRow { - FF avm_binary_acc_ia{}; - FF avm_binary_acc_ia_shift{}; - FF avm_binary_acc_ib{}; - FF avm_binary_acc_ib_shift{}; - FF avm_binary_acc_ic{}; - FF avm_binary_acc_ic_shift{}; - FF avm_binary_bin_sel{}; - FF avm_binary_ia_bytes{}; - FF avm_binary_ib_bytes{}; - FF avm_binary_ic_bytes{}; - FF avm_binary_mem_tag_ctr{}; - FF avm_binary_mem_tag_ctr_inv{}; - FF avm_binary_mem_tag_ctr_shift{}; - FF avm_binary_op_id{}; - FF avm_binary_op_id_shift{}; -}; - -inline std::string get_relation_label_avm_binary(int index) -{ - switch (index) { - case 1: - return "OP_ID_REL"; - - case 2: - return "MEM_TAG_REL"; - - case 3: - return "BIN_SEL_CTR_REL"; - - case 7: - return "ACC_REL_A"; - - case 8: - return "ACC_REL_B"; - - case 9: - return "ACC_REL_C"; +template struct Avm_binaryRow { + FF avm_binary_acc_ia {}; + FF avm_binary_acc_ia_shift {}; + FF avm_binary_acc_ib {}; + FF avm_binary_acc_ib_shift {}; + FF avm_binary_acc_ic {}; + FF avm_binary_acc_ic_shift {}; + FF avm_binary_bin_sel {}; + FF avm_binary_ia_bytes {}; + FF avm_binary_ib_bytes {}; + FF avm_binary_ic_bytes {}; + FF avm_binary_mem_tag_ctr {}; + FF avm_binary_mem_tag_ctr_inv {}; + FF avm_binary_mem_tag_ctr_shift {}; + FF avm_binary_op_id {}; + FF avm_binary_op_id_shift {}; + }; + + + inline std::string get_relation_label_avm_binary(int index) { + switch (index) { + case 1: + return "OP_ID_REL"; + +case 2: + return "MEM_TAG_REL"; + +case 3: + return "BIN_SEL_CTR_REL"; + +case 7: + return "ACC_REL_A"; + +case 8: + return "ACC_REL_B"; + +case 9: + return "ACC_REL_C"; + + } + return std::to_string(index); } - return std::to_string(index); -} + template class avm_binaryImpl { - public: - using FF = FF_; - - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, 3, 3, 4, 3, 3, 3, 4, 4, 4, - }; - + public: + using FF = FF_; + + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 3, + 3, + 3, + 4, + 3, + 3, + 3, + 4, + 4, + 4, +}; + + template - void static accumulate(ContainerOverSubrelations& evals, - const AllEntities& new_term, - [[maybe_unused]] const RelationParameters&, - [[maybe_unused]] const FF& scaling_factor) + void static accumulate( + ContainerOverSubrelations& evals, + const AllEntities& new_term, + [[maybe_unused]] const RelationParameters&, + [[maybe_unused]] const FF& scaling_factor + ){ + + //Contribution 0 { +Avm_DECLARE_VIEWS(0); + + + auto tmp = (avm_binary_bin_sel * (-avm_binary_bin_sel + FF(1))); + tmp *= scaling_factor; + std::get<0>(evals) += tmp; +} +//Contribution 1 + { +Avm_DECLARE_VIEWS(1); + + + auto tmp = ((avm_binary_op_id_shift - avm_binary_op_id) * avm_binary_mem_tag_ctr); + tmp *= scaling_factor; + std::get<1>(evals) += tmp; +} +//Contribution 2 + { +Avm_DECLARE_VIEWS(2); + + + auto tmp = (((avm_binary_mem_tag_ctr_shift - avm_binary_mem_tag_ctr) + FF(1)) * avm_binary_mem_tag_ctr); + tmp *= scaling_factor; + std::get<2>(evals) += tmp; +} +//Contribution 3 + { +Avm_DECLARE_VIEWS(3); + + + auto tmp = ((avm_binary_mem_tag_ctr * (((-avm_binary_bin_sel + FF(1)) * (-avm_binary_mem_tag_ctr_inv + FF(1))) + avm_binary_mem_tag_ctr_inv)) - avm_binary_bin_sel); + tmp *= scaling_factor; + std::get<3>(evals) += tmp; +} +//Contribution 4 + { +Avm_DECLARE_VIEWS(4); + + + auto tmp = ((-avm_binary_bin_sel + FF(1)) * avm_binary_acc_ia); + tmp *= scaling_factor; + std::get<4>(evals) += tmp; +} +//Contribution 5 + { +Avm_DECLARE_VIEWS(5); + + + auto tmp = ((-avm_binary_bin_sel + FF(1)) * avm_binary_acc_ib); + tmp *= scaling_factor; + std::get<5>(evals) += tmp; +} +//Contribution 6 + { +Avm_DECLARE_VIEWS(6); + + + auto tmp = ((-avm_binary_bin_sel + FF(1)) * avm_binary_acc_ic); + tmp *= scaling_factor; + std::get<6>(evals) += tmp; +} +//Contribution 7 + { +Avm_DECLARE_VIEWS(7); + + + auto tmp = (((avm_binary_acc_ia - avm_binary_ia_bytes) - (avm_binary_acc_ia_shift * FF(256))) * avm_binary_mem_tag_ctr); + tmp *= scaling_factor; + std::get<7>(evals) += tmp; +} +//Contribution 8 + { +Avm_DECLARE_VIEWS(8); + + + auto tmp = (((avm_binary_acc_ib - avm_binary_ib_bytes) - (avm_binary_acc_ib_shift * FF(256))) * avm_binary_mem_tag_ctr); + tmp *= scaling_factor; + std::get<8>(evals) += tmp; +} +//Contribution 9 + { +Avm_DECLARE_VIEWS(9); + + + auto tmp = (((avm_binary_acc_ic - avm_binary_ic_bytes) - (avm_binary_acc_ic_shift * FF(256))) * avm_binary_mem_tag_ctr); + tmp *= scaling_factor; + std::get<9>(evals) += tmp; +} +} - // Contribution 0 - { - Avm_DECLARE_VIEWS(0); - - auto tmp = (avm_binary_bin_sel * (-avm_binary_bin_sel + FF(1))); - tmp *= scaling_factor; - std::get<0>(evals) += tmp; - } - // Contribution 1 - { - Avm_DECLARE_VIEWS(1); - - auto tmp = ((avm_binary_op_id_shift - avm_binary_op_id) * avm_binary_mem_tag_ctr); - tmp *= scaling_factor; - std::get<1>(evals) += tmp; - } - // Contribution 2 - { - Avm_DECLARE_VIEWS(2); - - auto tmp = (((avm_binary_mem_tag_ctr_shift - avm_binary_mem_tag_ctr) + FF(1)) * avm_binary_mem_tag_ctr); - tmp *= scaling_factor; - std::get<2>(evals) += tmp; - } - // Contribution 3 - { - Avm_DECLARE_VIEWS(3); - - auto tmp = - ((avm_binary_mem_tag_ctr * (((-avm_binary_bin_sel + FF(1)) * (-avm_binary_mem_tag_ctr_inv + FF(1))) + - avm_binary_mem_tag_ctr_inv)) - - avm_binary_bin_sel); - tmp *= scaling_factor; - std::get<3>(evals) += tmp; - } - // Contribution 4 - { - Avm_DECLARE_VIEWS(4); - - auto tmp = ((-avm_binary_bin_sel + FF(1)) * avm_binary_acc_ia); - tmp *= scaling_factor; - std::get<4>(evals) += tmp; - } - // Contribution 5 - { - Avm_DECLARE_VIEWS(5); - - auto tmp = ((-avm_binary_bin_sel + FF(1)) * avm_binary_acc_ib); - tmp *= scaling_factor; - std::get<5>(evals) += tmp; - } - // Contribution 6 - { - Avm_DECLARE_VIEWS(6); - - auto tmp = ((-avm_binary_bin_sel + FF(1)) * avm_binary_acc_ic); - tmp *= scaling_factor; - std::get<6>(evals) += tmp; - } - // Contribution 7 - { - Avm_DECLARE_VIEWS(7); - - auto tmp = (((avm_binary_acc_ia - avm_binary_ia_bytes) - (avm_binary_acc_ia_shift * FF(256))) * - avm_binary_mem_tag_ctr); - tmp *= scaling_factor; - std::get<7>(evals) += tmp; - } - // Contribution 8 - { - Avm_DECLARE_VIEWS(8); - - auto tmp = (((avm_binary_acc_ib - avm_binary_ib_bytes) - (avm_binary_acc_ib_shift * FF(256))) * - avm_binary_mem_tag_ctr); - tmp *= scaling_factor; - std::get<8>(evals) += tmp; - } - // Contribution 9 - { - Avm_DECLARE_VIEWS(9); - - auto tmp = (((avm_binary_acc_ic - avm_binary_ic_bytes) - (avm_binary_acc_ic_shift * FF(256))) * - avm_binary_mem_tag_ctr); - tmp *= scaling_factor; - std::get<9>(evals) += tmp; - } - } }; template using avm_binary = Relation>; -} // namespace bb::Avm_vm \ No newline at end of file + } \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_conversion.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_conversion.hpp index 9ecfc59cfc4..f3de5f3f392 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_conversion.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_conversion.hpp @@ -6,42 +6,49 @@ namespace bb::Avm_vm { -template struct Avm_conversionRow { - FF avm_conversion_to_radix_le_sel{}; -}; - -inline std::string get_relation_label_avm_conversion(int index) -{ - switch (index) {} - return std::to_string(index); -} +template struct Avm_conversionRow { + FF avm_conversion_to_radix_le_sel {}; + }; -template class avm_conversionImpl { - public: - using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, - }; + inline std::string get_relation_label_avm_conversion(int index) { + switch (index) { + + } + return std::to_string(index); + } + +template class avm_conversionImpl { + public: + using FF = FF_; + + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 3, +}; + + template - void static accumulate(ContainerOverSubrelations& evals, - const AllEntities& new_term, - [[maybe_unused]] const RelationParameters&, - [[maybe_unused]] const FF& scaling_factor) + void static accumulate( + ContainerOverSubrelations& evals, + const AllEntities& new_term, + [[maybe_unused]] const RelationParameters&, + [[maybe_unused]] const FF& scaling_factor + ){ + + //Contribution 0 { +Avm_DECLARE_VIEWS(0); + + + auto tmp = (avm_conversion_to_radix_le_sel * (-avm_conversion_to_radix_le_sel + FF(1))); + tmp *= scaling_factor; + std::get<0>(evals) += tmp; +} +} - // Contribution 0 - { - Avm_DECLARE_VIEWS(0); - - auto tmp = (avm_conversion_to_radix_le_sel * (-avm_conversion_to_radix_le_sel + FF(1))); - tmp *= scaling_factor; - std::get<0>(evals) += tmp; - } - } }; template using avm_conversion = Relation>; -} // namespace bb::Avm_vm \ No newline at end of file + } \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_keccakf1600.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_keccakf1600.hpp index b5df59d290b..924862136fb 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_keccakf1600.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_keccakf1600.hpp @@ -6,42 +6,49 @@ namespace bb::Avm_vm { -template struct Avm_keccakf1600Row { - FF avm_keccakf1600_keccakf1600_sel{}; -}; - -inline std::string get_relation_label_avm_keccakf1600(int index) -{ - switch (index) {} - return std::to_string(index); -} +template struct Avm_keccakf1600Row { + FF avm_keccakf1600_keccakf1600_sel {}; + }; -template class avm_keccakf1600Impl { - public: - using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, - }; + inline std::string get_relation_label_avm_keccakf1600(int index) { + switch (index) { + + } + return std::to_string(index); + } + +template class avm_keccakf1600Impl { + public: + using FF = FF_; + + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 3, +}; + + template - void static accumulate(ContainerOverSubrelations& evals, - const AllEntities& new_term, - [[maybe_unused]] const RelationParameters&, - [[maybe_unused]] const FF& scaling_factor) + void static accumulate( + ContainerOverSubrelations& evals, + const AllEntities& new_term, + [[maybe_unused]] const RelationParameters&, + [[maybe_unused]] const FF& scaling_factor + ){ + + //Contribution 0 { +Avm_DECLARE_VIEWS(0); + + + auto tmp = (avm_keccakf1600_keccakf1600_sel * (-avm_keccakf1600_keccakf1600_sel + FF(1))); + tmp *= scaling_factor; + std::get<0>(evals) += tmp; +} +} - // Contribution 0 - { - Avm_DECLARE_VIEWS(0); - - auto tmp = (avm_keccakf1600_keccakf1600_sel * (-avm_keccakf1600_keccakf1600_sel + FF(1))); - tmp *= scaling_factor; - std::get<0>(evals) += tmp; - } - } }; template using avm_keccakf1600 = Relation>; -} // namespace bb::Avm_vm \ No newline at end of file + } \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_kernel.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_kernel.hpp index 01b346e7a49..1f4a80e919e 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_kernel.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_kernel.hpp @@ -6,176 +6,182 @@ namespace bb::Avm_vm { -template struct Avm_kernelRow { - FF avm_kernel_emit_l2_to_l1_msg_write_offset{}; - FF avm_kernel_emit_l2_to_l1_msg_write_offset_shift{}; - FF avm_kernel_emit_note_hash_write_offset{}; - FF avm_kernel_emit_note_hash_write_offset_shift{}; - FF avm_kernel_emit_nullifier_write_offset{}; - FF avm_kernel_emit_nullifier_write_offset_shift{}; - FF avm_kernel_emit_unencrypted_log_write_offset{}; - FF avm_kernel_emit_unencrypted_log_write_offset_shift{}; - FF avm_kernel_l1_to_l2_msg_exists_write_offset{}; - FF avm_kernel_l1_to_l2_msg_exists_write_offset_shift{}; - FF avm_kernel_note_hash_exist_write_offset{}; - FF avm_kernel_note_hash_exist_write_offset_shift{}; - FF avm_kernel_nullifier_exists_write_offset{}; - FF avm_kernel_nullifier_exists_write_offset_shift{}; - FF avm_kernel_sload_write_offset{}; - FF avm_kernel_sload_write_offset_shift{}; - FF avm_kernel_sstore_write_offset{}; - FF avm_kernel_sstore_write_offset_shift{}; - FF avm_main_last{}; - FF avm_main_sel_op_emit_l2_to_l1_msg{}; - FF avm_main_sel_op_emit_note_hash{}; - FF avm_main_sel_op_emit_nullifier{}; - FF avm_main_sel_op_emit_unencrypted_log{}; - FF avm_main_sel_op_l1_to_l2_msg_exists{}; - FF avm_main_sel_op_note_hash_exists{}; - FF avm_main_sel_op_nullifier_exists{}; - FF avm_main_sel_op_sload{}; - FF avm_main_sel_op_sstore{}; -}; - -inline std::string get_relation_label_avm_kernel(int index) -{ - switch (index) { - case 0: - return "NOTE_HASH_EXISTS_INC_CONSISTENCY_CHECK"; - - case 1: - return "EMIT_NOTE_HASH_INC_CONSISTENCY_CHECK"; - - case 2: - return "NULLIFIER_EXISTS_INC_CONSISTENCY_CHECK"; - - case 3: - return "EMIT_NULLIFIER_INC_CONSISTENCY_CHECK"; - - case 4: - return "L1_TO_L2_MSG_EXISTS_INC_CONSISTENCY_CHECK"; - - case 5: - return "EMIT_UNENCRYPTED_LOG_INC_CONSISTENCY_CHECK"; - - case 6: - return "EMIT_L2_TO_L1_MSG_INC_CONSISTENCY_CHECK"; - - case 7: - return "SLOAD_INC_CONSISTENCY_CHECK"; - - case 8: - return "SSTORE_INC_CONSISTENCY_CHECK"; +template struct Avm_kernelRow { + FF avm_kernel_emit_l2_to_l1_msg_write_offset {}; + FF avm_kernel_emit_l2_to_l1_msg_write_offset_shift {}; + FF avm_kernel_emit_note_hash_write_offset {}; + FF avm_kernel_emit_note_hash_write_offset_shift {}; + FF avm_kernel_emit_nullifier_write_offset {}; + FF avm_kernel_emit_nullifier_write_offset_shift {}; + FF avm_kernel_emit_unencrypted_log_write_offset {}; + FF avm_kernel_emit_unencrypted_log_write_offset_shift {}; + FF avm_kernel_l1_to_l2_msg_exists_write_offset {}; + FF avm_kernel_l1_to_l2_msg_exists_write_offset_shift {}; + FF avm_kernel_note_hash_exist_write_offset {}; + FF avm_kernel_note_hash_exist_write_offset_shift {}; + FF avm_kernel_nullifier_exists_write_offset {}; + FF avm_kernel_nullifier_exists_write_offset_shift {}; + FF avm_kernel_sload_write_offset {}; + FF avm_kernel_sload_write_offset_shift {}; + FF avm_kernel_sstore_write_offset {}; + FF avm_kernel_sstore_write_offset_shift {}; + FF avm_main_last {}; + FF avm_main_sel_op_emit_l2_to_l1_msg {}; + FF avm_main_sel_op_emit_note_hash {}; + FF avm_main_sel_op_emit_nullifier {}; + FF avm_main_sel_op_emit_unencrypted_log {}; + FF avm_main_sel_op_l1_to_l2_msg_exists {}; + FF avm_main_sel_op_note_hash_exists {}; + FF avm_main_sel_op_nullifier_exists {}; + FF avm_main_sel_op_sload {}; + FF avm_main_sel_op_sstore {}; + }; + + + inline std::string get_relation_label_avm_kernel(int index) { + switch (index) { + case 0: + return "NOTE_HASH_EXISTS_INC_CONSISTENCY_CHECK"; + +case 1: + return "EMIT_NOTE_HASH_INC_CONSISTENCY_CHECK"; + +case 2: + return "NULLIFIER_EXISTS_INC_CONSISTENCY_CHECK"; + +case 3: + return "EMIT_NULLIFIER_INC_CONSISTENCY_CHECK"; + +case 4: + return "L1_TO_L2_MSG_EXISTS_INC_CONSISTENCY_CHECK"; + +case 5: + return "EMIT_UNENCRYPTED_LOG_INC_CONSISTENCY_CHECK"; + +case 6: + return "EMIT_L2_TO_L1_MSG_INC_CONSISTENCY_CHECK"; + +case 7: + return "SLOAD_INC_CONSISTENCY_CHECK"; + +case 8: + return "SSTORE_INC_CONSISTENCY_CHECK"; + + } + return std::to_string(index); } - return std::to_string(index); -} + template class avm_kernelImpl { - public: - using FF = FF_; - - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, 3, 3, 3, 3, 3, 3, 3, 3, - }; - + public: + using FF = FF_; + + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, +}; + + template - void static accumulate(ContainerOverSubrelations& evals, - const AllEntities& new_term, - [[maybe_unused]] const RelationParameters&, - [[maybe_unused]] const FF& scaling_factor) + void static accumulate( + ContainerOverSubrelations& evals, + const AllEntities& new_term, + [[maybe_unused]] const RelationParameters&, + [[maybe_unused]] const FF& scaling_factor + ){ + + //Contribution 0 { +Avm_DECLARE_VIEWS(0); + + + auto tmp = ((-avm_main_last + FF(1)) * (avm_kernel_note_hash_exist_write_offset_shift - (avm_kernel_note_hash_exist_write_offset + avm_main_sel_op_note_hash_exists))); + tmp *= scaling_factor; + std::get<0>(evals) += tmp; +} +//Contribution 1 + { +Avm_DECLARE_VIEWS(1); + + + auto tmp = ((-avm_main_last + FF(1)) * (avm_kernel_emit_note_hash_write_offset_shift - (avm_kernel_emit_note_hash_write_offset + avm_main_sel_op_emit_note_hash))); + tmp *= scaling_factor; + std::get<1>(evals) += tmp; +} +//Contribution 2 + { +Avm_DECLARE_VIEWS(2); + + + auto tmp = ((-avm_main_last + FF(1)) * (avm_kernel_nullifier_exists_write_offset_shift - (avm_kernel_nullifier_exists_write_offset + avm_main_sel_op_nullifier_exists))); + tmp *= scaling_factor; + std::get<2>(evals) += tmp; +} +//Contribution 3 + { +Avm_DECLARE_VIEWS(3); + + + auto tmp = ((-avm_main_last + FF(1)) * (avm_kernel_emit_nullifier_write_offset_shift - (avm_kernel_emit_nullifier_write_offset + avm_main_sel_op_emit_nullifier))); + tmp *= scaling_factor; + std::get<3>(evals) += tmp; +} +//Contribution 4 + { +Avm_DECLARE_VIEWS(4); + + + auto tmp = ((-avm_main_last + FF(1)) * (avm_kernel_l1_to_l2_msg_exists_write_offset_shift - (avm_kernel_l1_to_l2_msg_exists_write_offset + avm_main_sel_op_l1_to_l2_msg_exists))); + tmp *= scaling_factor; + std::get<4>(evals) += tmp; +} +//Contribution 5 + { +Avm_DECLARE_VIEWS(5); + + + auto tmp = ((-avm_main_last + FF(1)) * (avm_kernel_emit_unencrypted_log_write_offset_shift - (avm_kernel_emit_unencrypted_log_write_offset + avm_main_sel_op_emit_unencrypted_log))); + tmp *= scaling_factor; + std::get<5>(evals) += tmp; +} +//Contribution 6 + { +Avm_DECLARE_VIEWS(6); + + + auto tmp = ((-avm_main_last + FF(1)) * (avm_kernel_emit_l2_to_l1_msg_write_offset_shift - (avm_kernel_emit_l2_to_l1_msg_write_offset + avm_main_sel_op_emit_l2_to_l1_msg))); + tmp *= scaling_factor; + std::get<6>(evals) += tmp; +} +//Contribution 7 + { +Avm_DECLARE_VIEWS(7); + + + auto tmp = ((-avm_main_last + FF(1)) * (avm_kernel_sload_write_offset_shift - (avm_kernel_sload_write_offset + avm_main_sel_op_sload))); + tmp *= scaling_factor; + std::get<7>(evals) += tmp; +} +//Contribution 8 + { +Avm_DECLARE_VIEWS(8); + + + auto tmp = ((-avm_main_last + FF(1)) * (avm_kernel_sstore_write_offset_shift - (avm_kernel_sstore_write_offset + avm_main_sel_op_sstore))); + tmp *= scaling_factor; + std::get<8>(evals) += tmp; +} +} - // Contribution 0 - { - Avm_DECLARE_VIEWS(0); - - auto tmp = ((-avm_main_last + FF(1)) * - (avm_kernel_note_hash_exist_write_offset_shift - - (avm_kernel_note_hash_exist_write_offset + avm_main_sel_op_note_hash_exists))); - tmp *= scaling_factor; - std::get<0>(evals) += tmp; - } - // Contribution 1 - { - Avm_DECLARE_VIEWS(1); - - auto tmp = ((-avm_main_last + FF(1)) * - (avm_kernel_emit_note_hash_write_offset_shift - - (avm_kernel_emit_note_hash_write_offset + avm_main_sel_op_emit_note_hash))); - tmp *= scaling_factor; - std::get<1>(evals) += tmp; - } - // Contribution 2 - { - Avm_DECLARE_VIEWS(2); - - auto tmp = ((-avm_main_last + FF(1)) * - (avm_kernel_nullifier_exists_write_offset_shift - - (avm_kernel_nullifier_exists_write_offset + avm_main_sel_op_nullifier_exists))); - tmp *= scaling_factor; - std::get<2>(evals) += tmp; - } - // Contribution 3 - { - Avm_DECLARE_VIEWS(3); - - auto tmp = ((-avm_main_last + FF(1)) * - (avm_kernel_emit_nullifier_write_offset_shift - - (avm_kernel_emit_nullifier_write_offset + avm_main_sel_op_emit_nullifier))); - tmp *= scaling_factor; - std::get<3>(evals) += tmp; - } - // Contribution 4 - { - Avm_DECLARE_VIEWS(4); - - auto tmp = ((-avm_main_last + FF(1)) * - (avm_kernel_l1_to_l2_msg_exists_write_offset_shift - - (avm_kernel_l1_to_l2_msg_exists_write_offset + avm_main_sel_op_l1_to_l2_msg_exists))); - tmp *= scaling_factor; - std::get<4>(evals) += tmp; - } - // Contribution 5 - { - Avm_DECLARE_VIEWS(5); - - auto tmp = ((-avm_main_last + FF(1)) * - (avm_kernel_emit_unencrypted_log_write_offset_shift - - (avm_kernel_emit_unencrypted_log_write_offset + avm_main_sel_op_emit_unencrypted_log))); - tmp *= scaling_factor; - std::get<5>(evals) += tmp; - } - // Contribution 6 - { - Avm_DECLARE_VIEWS(6); - - auto tmp = ((-avm_main_last + FF(1)) * - (avm_kernel_emit_l2_to_l1_msg_write_offset_shift - - (avm_kernel_emit_l2_to_l1_msg_write_offset + avm_main_sel_op_emit_l2_to_l1_msg))); - tmp *= scaling_factor; - std::get<6>(evals) += tmp; - } - // Contribution 7 - { - Avm_DECLARE_VIEWS(7); - - auto tmp = ((-avm_main_last + FF(1)) * (avm_kernel_sload_write_offset_shift - - (avm_kernel_sload_write_offset + avm_main_sel_op_sload))); - tmp *= scaling_factor; - std::get<7>(evals) += tmp; - } - // Contribution 8 - { - Avm_DECLARE_VIEWS(8); - - auto tmp = ((-avm_main_last + FF(1)) * (avm_kernel_sstore_write_offset_shift - - (avm_kernel_sstore_write_offset + avm_main_sel_op_sstore))); - tmp *= scaling_factor; - std::get<8>(evals) += tmp; - } - } }; template using avm_kernel = Relation>; -} // namespace bb::Avm_vm \ No newline at end of file + } \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_main.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_main.hpp index 0744e52c63f..73de46a4bb9 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_main.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_main.hpp @@ -63,6 +63,7 @@ template struct Avm_mainRow { FF avm_main_rwc{}; FF avm_main_rwd{}; FF avm_main_sel_cmov{}; + FF avm_main_sel_external_call{}; FF avm_main_sel_halt{}; FF avm_main_sel_internal_call{}; FF avm_main_sel_internal_return{}; @@ -130,133 +131,133 @@ inline std::string get_relation_label_avm_main(int index) case 3: return "DA_GAS_INACTIVE"; - case 65: + case 66: return "OUTPUT_U8"; - case 66: + case 67: return "SUBOP_FDIV"; - case 67: + case 68: return "SUBOP_FDIV_ZERO_ERR1"; - case 68: + case 69: return "SUBOP_FDIV_ZERO_ERR2"; - case 69: + case 70: return "SUBOP_FDIV_R_IN_TAG_FF"; - case 70: + case 71: return "SUBOP_FDIV_W_IN_TAG_FF"; - case 71: + case 72: return "SUBOP_ERROR_RELEVANT_OP"; - case 72: + case 73: return "KERNEL_INPUT_ACTIVE_CHECK"; - case 73: + case 74: return "KERNEL_OUTPUT_ACTIVE_CHECK"; - case 74: + case 75: return "PC_JUMP"; - case 75: + case 76: return "PC_JUMPI"; - case 76: + case 77: return "RETURN_POINTER_INCREMENT"; - case 82: + case 83: return "RETURN_POINTER_DECREMENT"; - case 88: + case 89: return "PC_INCREMENT"; - case 89: + case 90: return "INTERNAL_RETURN_POINTER_CONSISTENCY"; - case 90: + case 91: return "SPACE_ID_INTERNAL"; - case 91: + case 92: return "SPACE_ID_STANDARD_OPCODES"; - case 92: + case 93: return "CMOV_CONDITION_RES_1"; - case 93: + case 94: return "CMOV_CONDITION_RES_2"; - case 96: + case 97: return "MOV_SAME_VALUE_A"; - case 97: + case 98: return "MOV_SAME_VALUE_B"; - case 98: + case 99: return "MOV_MAIN_SAME_TAG"; - case 102: + case 103: return "SENDER_KERNEL"; - case 103: + case 104: return "ADDRESS_KERNEL"; - case 104: + case 105: return "FEE_DA_GAS_KERNEL"; - case 105: + case 106: return "FEE_L2_GAS_KERNEL"; - case 106: + case 107: return "FEE_TRANSACTION_FEE_KERNEL"; - case 107: + case 108: return "CHAIN_ID_KERNEL"; - case 108: + case 109: return "VERSION_KERNEL"; - case 109: + case 110: return "BLOCK_NUMBER_KERNEL"; - case 110: + case 111: return "COINBASE_KERNEL"; - case 111: + case 112: return "TIMESTAMP_KERNEL"; - case 112: + case 113: return "NOTE_HASH_KERNEL_OUTPUT"; - case 114: + case 115: return "EMIT_NOTE_HASH_KERNEL_OUTPUT"; - case 116: + case 117: return "NULLIFIER_EXISTS_KERNEL_OUTPUT"; - case 118: + case 119: return "EMIT_NULLIFIER_KERNEL_OUTPUT"; - case 120: + case 121: return "L1_TO_L2_MSG_EXISTS_KERNEL_OUTPUT"; - case 122: + case 123: return "EMIT_UNENCRYPTED_LOG_KERNEL_OUTPUT"; - case 124: + case 125: return "EMIT_L2_TO_L1_MSGS_KERNEL_OUTPUT"; - case 126: + case 127: return "SLOAD_KERNEL_OUTPUT"; - case 128: + case 129: return "SSTORE_KERNEL_OUTPUT"; - case 131: + case 132: return "BIN_SEL_1"; - case 132: + case 133: return "BIN_SEL_2"; } return std::to_string(index); @@ -266,11 +267,11 @@ template class avm_mainImpl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 4, - 4, 3, 3, 3, 3, 3, 3, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 5, 3, 3, 3, 4, 4, 3, 3, 3, 3, 3, 4, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, + 4, 4, 3, 3, 3, 3, 3, 3, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 5, 3, 3, 3, 4, 4, 3, 3, 3, 3, 3, 4, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, }; template @@ -670,7 +671,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(48); - auto tmp = (avm_main_sel_mov * (-avm_main_sel_mov + FF(1))); + auto tmp = (avm_main_sel_external_call * (-avm_main_sel_external_call + FF(1))); tmp *= scaling_factor; std::get<48>(evals) += tmp; } @@ -678,7 +679,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(49); - auto tmp = (avm_main_sel_cmov * (-avm_main_sel_cmov + FF(1))); + auto tmp = (avm_main_sel_mov * (-avm_main_sel_mov + FF(1))); tmp *= scaling_factor; std::get<49>(evals) += tmp; } @@ -686,7 +687,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(50); - auto tmp = (avm_main_op_err * (-avm_main_op_err + FF(1))); + auto tmp = (avm_main_sel_cmov * (-avm_main_sel_cmov + FF(1))); tmp *= scaling_factor; std::get<50>(evals) += tmp; } @@ -694,7 +695,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(51); - auto tmp = (avm_main_tag_err * (-avm_main_tag_err + FF(1))); + auto tmp = (avm_main_op_err * (-avm_main_op_err + FF(1))); tmp *= scaling_factor; std::get<51>(evals) += tmp; } @@ -702,7 +703,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(52); - auto tmp = (avm_main_id_zero * (-avm_main_id_zero + FF(1))); + auto tmp = (avm_main_tag_err * (-avm_main_tag_err + FF(1))); tmp *= scaling_factor; std::get<52>(evals) += tmp; } @@ -710,7 +711,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(53); - auto tmp = (avm_main_mem_op_a * (-avm_main_mem_op_a + FF(1))); + auto tmp = (avm_main_id_zero * (-avm_main_id_zero + FF(1))); tmp *= scaling_factor; std::get<53>(evals) += tmp; } @@ -718,7 +719,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(54); - auto tmp = (avm_main_mem_op_b * (-avm_main_mem_op_b + FF(1))); + auto tmp = (avm_main_mem_op_a * (-avm_main_mem_op_a + FF(1))); tmp *= scaling_factor; std::get<54>(evals) += tmp; } @@ -726,7 +727,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(55); - auto tmp = (avm_main_mem_op_c * (-avm_main_mem_op_c + FF(1))); + auto tmp = (avm_main_mem_op_b * (-avm_main_mem_op_b + FF(1))); tmp *= scaling_factor; std::get<55>(evals) += tmp; } @@ -734,7 +735,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(56); - auto tmp = (avm_main_mem_op_d * (-avm_main_mem_op_d + FF(1))); + auto tmp = (avm_main_mem_op_c * (-avm_main_mem_op_c + FF(1))); tmp *= scaling_factor; std::get<56>(evals) += tmp; } @@ -742,7 +743,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(57); - auto tmp = (avm_main_rwa * (-avm_main_rwa + FF(1))); + auto tmp = (avm_main_mem_op_d * (-avm_main_mem_op_d + FF(1))); tmp *= scaling_factor; std::get<57>(evals) += tmp; } @@ -750,7 +751,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(58); - auto tmp = (avm_main_rwb * (-avm_main_rwb + FF(1))); + auto tmp = (avm_main_rwa * (-avm_main_rwa + FF(1))); tmp *= scaling_factor; std::get<58>(evals) += tmp; } @@ -758,7 +759,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(59); - auto tmp = (avm_main_rwc * (-avm_main_rwc + FF(1))); + auto tmp = (avm_main_rwb * (-avm_main_rwb + FF(1))); tmp *= scaling_factor; std::get<59>(evals) += tmp; } @@ -766,7 +767,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(60); - auto tmp = (avm_main_rwd * (-avm_main_rwd + FF(1))); + auto tmp = (avm_main_rwc * (-avm_main_rwc + FF(1))); tmp *= scaling_factor; std::get<60>(evals) += tmp; } @@ -774,7 +775,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(61); - auto tmp = (avm_main_ind_op_a * (-avm_main_ind_op_a + FF(1))); + auto tmp = (avm_main_rwd * (-avm_main_rwd + FF(1))); tmp *= scaling_factor; std::get<61>(evals) += tmp; } @@ -782,7 +783,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(62); - auto tmp = (avm_main_ind_op_b * (-avm_main_ind_op_b + FF(1))); + auto tmp = (avm_main_ind_op_a * (-avm_main_ind_op_a + FF(1))); tmp *= scaling_factor; std::get<62>(evals) += tmp; } @@ -790,7 +791,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(63); - auto tmp = (avm_main_ind_op_c * (-avm_main_ind_op_c + FF(1))); + auto tmp = (avm_main_ind_op_b * (-avm_main_ind_op_b + FF(1))); tmp *= scaling_factor; std::get<63>(evals) += tmp; } @@ -798,7 +799,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(64); - auto tmp = (avm_main_ind_op_d * (-avm_main_ind_op_d + FF(1))); + auto tmp = (avm_main_ind_op_c * (-avm_main_ind_op_c + FF(1))); tmp *= scaling_factor; std::get<64>(evals) += tmp; } @@ -806,8 +807,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(65); - auto tmp = - (((avm_main_sel_op_eq + avm_main_sel_op_lte) + avm_main_sel_op_lt) * (avm_main_w_in_tag - FF(1))); + auto tmp = (avm_main_ind_op_d * (-avm_main_ind_op_d + FF(1))); tmp *= scaling_factor; std::get<65>(evals) += tmp; } @@ -816,7 +816,7 @@ template class avm_mainImpl { Avm_DECLARE_VIEWS(66); auto tmp = - ((avm_main_sel_op_fdiv * (-avm_main_op_err + FF(1))) * ((avm_main_ic * avm_main_ib) - avm_main_ia)); + (((avm_main_sel_op_eq + avm_main_sel_op_lte) + avm_main_sel_op_lt) * (avm_main_w_in_tag - FF(1))); tmp *= scaling_factor; std::get<66>(evals) += tmp; } @@ -824,8 +824,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(67); - auto tmp = ((avm_main_sel_op_fdiv + avm_main_sel_op_div) * - (((avm_main_ib * avm_main_inv) - FF(1)) + avm_main_op_err)); + auto tmp = + ((avm_main_sel_op_fdiv * (-avm_main_op_err + FF(1))) * ((avm_main_ic * avm_main_ib) - avm_main_ia)); tmp *= scaling_factor; std::get<67>(evals) += tmp; } @@ -833,7 +833,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(68); - auto tmp = (((avm_main_sel_op_fdiv + avm_main_sel_op_div) * avm_main_op_err) * (-avm_main_inv + FF(1))); + auto tmp = ((avm_main_sel_op_fdiv + avm_main_sel_op_div) * + (((avm_main_ib * avm_main_inv) - FF(1)) + avm_main_op_err)); tmp *= scaling_factor; std::get<68>(evals) += tmp; } @@ -841,7 +842,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(69); - auto tmp = (avm_main_sel_op_fdiv * (avm_main_r_in_tag - FF(6))); + auto tmp = (((avm_main_sel_op_fdiv + avm_main_sel_op_div) * avm_main_op_err) * (-avm_main_inv + FF(1))); tmp *= scaling_factor; std::get<69>(evals) += tmp; } @@ -849,7 +850,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(70); - auto tmp = (avm_main_sel_op_fdiv * (avm_main_w_in_tag - FF(6))); + auto tmp = (avm_main_sel_op_fdiv * (avm_main_r_in_tag - FF(6))); tmp *= scaling_factor; std::get<70>(evals) += tmp; } @@ -857,7 +858,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(71); - auto tmp = (avm_main_op_err * ((avm_main_sel_op_fdiv + avm_main_sel_op_div) - FF(1))); + auto tmp = (avm_main_sel_op_fdiv * (avm_main_w_in_tag - FF(6))); tmp *= scaling_factor; std::get<71>(evals) += tmp; } @@ -865,6 +866,14 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(72); + auto tmp = (avm_main_op_err * ((avm_main_sel_op_fdiv + avm_main_sel_op_div) - FF(1))); + tmp *= scaling_factor; + std::get<72>(evals) += tmp; + } + // Contribution 73 + { + Avm_DECLARE_VIEWS(73); + auto tmp = ((((((((((avm_main_sel_op_sender + avm_main_sel_op_address) + avm_main_sel_op_chain_id) + avm_main_sel_op_version) + avm_main_sel_op_block_number) + @@ -875,11 +884,11 @@ template class avm_mainImpl { avm_main_sel_op_transaction_fee) * (-avm_main_q_kernel_lookup + FF(1))); tmp *= scaling_factor; - std::get<72>(evals) += tmp; + std::get<73>(evals) += tmp; } - // Contribution 73 + // Contribution 74 { - Avm_DECLARE_VIEWS(73); + Avm_DECLARE_VIEWS(74); auto tmp = (((((((((avm_main_sel_op_note_hash_exists + avm_main_sel_op_emit_note_hash) + avm_main_sel_op_nullifier_exists) + @@ -891,22 +900,13 @@ template class avm_mainImpl { avm_main_sel_op_sstore) * (-avm_main_q_kernel_output_lookup + FF(1))); tmp *= scaling_factor; - std::get<73>(evals) += tmp; - } - // Contribution 74 - { - Avm_DECLARE_VIEWS(74); - - auto tmp = (avm_main_sel_jump * (avm_main_pc_shift - avm_main_ia)); - tmp *= scaling_factor; std::get<74>(evals) += tmp; } // Contribution 75 { Avm_DECLARE_VIEWS(75); - auto tmp = (avm_main_sel_jumpi * (((-avm_main_id_zero + FF(1)) * (avm_main_pc_shift - avm_main_ia)) + - (avm_main_id_zero * ((avm_main_pc_shift - avm_main_pc) - FF(1))))); + auto tmp = (avm_main_sel_jump * (avm_main_pc_shift - avm_main_ia)); tmp *= scaling_factor; std::get<75>(evals) += tmp; } @@ -914,8 +914,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(76); - auto tmp = (avm_main_sel_internal_call * - (avm_main_internal_return_ptr_shift - (avm_main_internal_return_ptr + FF(1)))); + auto tmp = (avm_main_sel_jumpi * (((-avm_main_id_zero + FF(1)) * (avm_main_pc_shift - avm_main_ia)) + + (avm_main_id_zero * ((avm_main_pc_shift - avm_main_pc) - FF(1))))); tmp *= scaling_factor; std::get<76>(evals) += tmp; } @@ -923,7 +923,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(77); - auto tmp = (avm_main_sel_internal_call * (avm_main_internal_return_ptr - avm_main_mem_idx_b)); + auto tmp = (avm_main_sel_internal_call * + (avm_main_internal_return_ptr_shift - (avm_main_internal_return_ptr + FF(1)))); tmp *= scaling_factor; std::get<77>(evals) += tmp; } @@ -931,7 +932,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(78); - auto tmp = (avm_main_sel_internal_call * (avm_main_pc_shift - avm_main_ia)); + auto tmp = (avm_main_sel_internal_call * (avm_main_internal_return_ptr - avm_main_mem_idx_b)); tmp *= scaling_factor; std::get<78>(evals) += tmp; } @@ -939,7 +940,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(79); - auto tmp = (avm_main_sel_internal_call * ((avm_main_pc + FF(1)) - avm_main_ib)); + auto tmp = (avm_main_sel_internal_call * (avm_main_pc_shift - avm_main_ia)); tmp *= scaling_factor; std::get<79>(evals) += tmp; } @@ -947,7 +948,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(80); - auto tmp = (avm_main_sel_internal_call * (avm_main_rwb - FF(1))); + auto tmp = (avm_main_sel_internal_call * ((avm_main_pc + FF(1)) - avm_main_ib)); tmp *= scaling_factor; std::get<80>(evals) += tmp; } @@ -955,7 +956,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(81); - auto tmp = (avm_main_sel_internal_call * (avm_main_mem_op_b - FF(1))); + auto tmp = (avm_main_sel_internal_call * (avm_main_rwb - FF(1))); tmp *= scaling_factor; std::get<81>(evals) += tmp; } @@ -963,8 +964,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(82); - auto tmp = (avm_main_sel_internal_return * - (avm_main_internal_return_ptr_shift - (avm_main_internal_return_ptr - FF(1)))); + auto tmp = (avm_main_sel_internal_call * (avm_main_mem_op_b - FF(1))); tmp *= scaling_factor; std::get<82>(evals) += tmp; } @@ -972,7 +972,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(83); - auto tmp = (avm_main_sel_internal_return * ((avm_main_internal_return_ptr - FF(1)) - avm_main_mem_idx_a)); + auto tmp = (avm_main_sel_internal_return * + (avm_main_internal_return_ptr_shift - (avm_main_internal_return_ptr - FF(1)))); tmp *= scaling_factor; std::get<83>(evals) += tmp; } @@ -980,7 +981,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(84); - auto tmp = (avm_main_sel_internal_return * (avm_main_pc_shift - avm_main_ia)); + auto tmp = (avm_main_sel_internal_return * ((avm_main_internal_return_ptr - FF(1)) - avm_main_mem_idx_a)); tmp *= scaling_factor; std::get<84>(evals) += tmp; } @@ -988,7 +989,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(85); - auto tmp = (avm_main_sel_internal_return * avm_main_rwa); + auto tmp = (avm_main_sel_internal_return * (avm_main_pc_shift - avm_main_ia)); tmp *= scaling_factor; std::get<85>(evals) += tmp; } @@ -996,7 +997,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(86); - auto tmp = (avm_main_sel_internal_return * (avm_main_mem_op_a - FF(1))); + auto tmp = (avm_main_sel_internal_return * avm_main_rwa); tmp *= scaling_factor; std::get<86>(evals) += tmp; } @@ -1004,6 +1005,14 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(87); + auto tmp = (avm_main_sel_internal_return * (avm_main_mem_op_a - FF(1))); + tmp *= scaling_factor; + std::get<87>(evals) += tmp; + } + // Contribution 88 + { + Avm_DECLARE_VIEWS(88); + auto tmp = (((avm_main_gas_cost_active - ((((((avm_main_sel_op_fdiv + ((((((((((avm_main_sel_op_add + avm_main_sel_op_sub) + avm_main_sel_op_mul) + @@ -1036,15 +1045,16 @@ template class avm_mainImpl { avm_main_sel_op_emit_l2_to_l1_msg) + avm_main_sel_op_sload) + avm_main_sel_op_sstore))) - - (((avm_main_sel_jump + avm_main_sel_jumpi) + avm_main_sel_internal_call) + - avm_main_sel_internal_return)) - + ((((avm_main_sel_jump + avm_main_sel_jumpi) + avm_main_sel_internal_call) + + avm_main_sel_internal_return) + + avm_main_sel_external_call)) - avm_main_mem_op_activate_gas); tmp *= scaling_factor; - std::get<87>(evals) += tmp; + std::get<88>(evals) += tmp; } - // Contribution 88 + // Contribution 89 { - Avm_DECLARE_VIEWS(88); + Avm_DECLARE_VIEWS(89); auto tmp = ((((-avm_main_first + FF(1)) * (-avm_main_sel_halt + FF(1))) * ((((((avm_main_sel_op_fdiv + @@ -1080,30 +1090,30 @@ template class avm_mainImpl { avm_main_sel_op_sstore))) * (avm_main_pc_shift - (avm_main_pc + FF(1)))); tmp *= scaling_factor; - std::get<88>(evals) += tmp; + std::get<89>(evals) += tmp; } - // Contribution 89 + // Contribution 90 { - Avm_DECLARE_VIEWS(89); + Avm_DECLARE_VIEWS(90); auto tmp = ((-(((avm_main_first + avm_main_sel_internal_call) + avm_main_sel_internal_return) + avm_main_sel_halt) + FF(1)) * (avm_main_internal_return_ptr_shift - avm_main_internal_return_ptr)); tmp *= scaling_factor; - std::get<89>(evals) += tmp; + std::get<90>(evals) += tmp; } - // Contribution 90 + // Contribution 91 { - Avm_DECLARE_VIEWS(90); + Avm_DECLARE_VIEWS(91); auto tmp = ((avm_main_sel_internal_call + avm_main_sel_internal_return) * (avm_main_space_id - FF(255))); tmp *= scaling_factor; - std::get<90>(evals) += tmp; + std::get<91>(evals) += tmp; } - // Contribution 91 + // Contribution 92 { - Avm_DECLARE_VIEWS(91); + Avm_DECLARE_VIEWS(92); auto tmp = (((((((avm_main_sel_op_fdiv + ((((((((((avm_main_sel_op_add + avm_main_sel_op_sub) + avm_main_sel_op_mul) + @@ -1138,22 +1148,14 @@ template class avm_mainImpl { avm_main_sel_op_sstore)) * (avm_main_call_ptr - avm_main_space_id)); tmp *= scaling_factor; - std::get<91>(evals) += tmp; - } - // Contribution 92 - { - Avm_DECLARE_VIEWS(92); - - auto tmp = ((avm_main_sel_cmov + avm_main_sel_jumpi) * - (((avm_main_id * avm_main_inv) - FF(1)) + avm_main_id_zero)); - tmp *= scaling_factor; std::get<92>(evals) += tmp; } // Contribution 93 { Avm_DECLARE_VIEWS(93); - auto tmp = (((avm_main_sel_cmov + avm_main_sel_jumpi) * avm_main_id_zero) * (-avm_main_inv + FF(1))); + auto tmp = ((avm_main_sel_cmov + avm_main_sel_jumpi) * + (((avm_main_id * avm_main_inv) - FF(1)) + avm_main_id_zero)); tmp *= scaling_factor; std::get<93>(evals) += tmp; } @@ -1161,7 +1163,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(94); - auto tmp = (avm_main_sel_mov_a - (avm_main_sel_mov + (avm_main_sel_cmov * (-avm_main_id_zero + FF(1))))); + auto tmp = (((avm_main_sel_cmov + avm_main_sel_jumpi) * avm_main_id_zero) * (-avm_main_inv + FF(1))); tmp *= scaling_factor; std::get<94>(evals) += tmp; } @@ -1169,7 +1171,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(95); - auto tmp = (avm_main_sel_mov_b - (avm_main_sel_cmov * avm_main_id_zero)); + auto tmp = (avm_main_sel_mov_a - (avm_main_sel_mov + (avm_main_sel_cmov * (-avm_main_id_zero + FF(1))))); tmp *= scaling_factor; std::get<95>(evals) += tmp; } @@ -1177,7 +1179,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(96); - auto tmp = (avm_main_sel_mov_a * (avm_main_ia - avm_main_ic)); + auto tmp = (avm_main_sel_mov_b - (avm_main_sel_cmov * avm_main_id_zero)); tmp *= scaling_factor; std::get<96>(evals) += tmp; } @@ -1185,7 +1187,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(97); - auto tmp = (avm_main_sel_mov_b * (avm_main_ib - avm_main_ic)); + auto tmp = (avm_main_sel_mov_a * (avm_main_ia - avm_main_ic)); tmp *= scaling_factor; std::get<97>(evals) += tmp; } @@ -1193,7 +1195,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(98); - auto tmp = ((avm_main_sel_mov + avm_main_sel_cmov) * (avm_main_r_in_tag - avm_main_w_in_tag)); + auto tmp = (avm_main_sel_mov_b * (avm_main_ib - avm_main_ic)); tmp *= scaling_factor; std::get<98>(evals) += tmp; } @@ -1201,6 +1203,14 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(99); + auto tmp = ((avm_main_sel_mov + avm_main_sel_cmov) * (avm_main_r_in_tag - avm_main_w_in_tag)); + tmp *= scaling_factor; + std::get<99>(evals) += tmp; + } + // Contribution 100 + { + Avm_DECLARE_VIEWS(100); + auto tmp = (avm_main_alu_sel - ((((((((((((avm_main_sel_op_add + avm_main_sel_op_sub) + avm_main_sel_op_mul) + avm_main_sel_op_div) + @@ -1214,11 +1224,11 @@ template class avm_mainImpl { (-avm_main_tag_err + FF(1))) * (-avm_main_op_err + FF(1)))); tmp *= scaling_factor; - std::get<99>(evals) += tmp; + std::get<100>(evals) += tmp; } - // Contribution 100 + // Contribution 101 { - Avm_DECLARE_VIEWS(100); + Avm_DECLARE_VIEWS(101); auto tmp = ((((((((((avm_main_sel_op_add + avm_main_sel_op_sub) + avm_main_sel_op_mul) + avm_main_sel_op_div) + @@ -1230,21 +1240,13 @@ template class avm_mainImpl { avm_main_sel_op_shl) * (avm_main_alu_in_tag - avm_main_r_in_tag)); tmp *= scaling_factor; - std::get<100>(evals) += tmp; - } - // Contribution 101 - { - Avm_DECLARE_VIEWS(101); - - auto tmp = (avm_main_sel_op_cast * (avm_main_alu_in_tag - avm_main_w_in_tag)); - tmp *= scaling_factor; std::get<101>(evals) += tmp; } // Contribution 102 { Avm_DECLARE_VIEWS(102); - auto tmp = (avm_main_sel_op_sender * (avm_kernel_kernel_in_offset - FF(0))); + auto tmp = (avm_main_sel_op_cast * (avm_main_alu_in_tag - avm_main_w_in_tag)); tmp *= scaling_factor; std::get<102>(evals) += tmp; } @@ -1252,7 +1254,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(103); - auto tmp = (avm_main_sel_op_address * (avm_kernel_kernel_in_offset - FF(1))); + auto tmp = (avm_main_sel_op_sender * (avm_kernel_kernel_in_offset - FF(0))); tmp *= scaling_factor; std::get<103>(evals) += tmp; } @@ -1260,7 +1262,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(104); - auto tmp = (avm_main_sel_op_fee_per_da_gas * (avm_kernel_kernel_in_offset - FF(35))); + auto tmp = (avm_main_sel_op_address * (avm_kernel_kernel_in_offset - FF(1))); tmp *= scaling_factor; std::get<104>(evals) += tmp; } @@ -1268,7 +1270,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(105); - auto tmp = (avm_main_sel_op_fee_per_l2_gas * (avm_kernel_kernel_in_offset - FF(36))); + auto tmp = (avm_main_sel_op_fee_per_da_gas * (avm_kernel_kernel_in_offset - FF(35))); tmp *= scaling_factor; std::get<105>(evals) += tmp; } @@ -1276,7 +1278,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(106); - auto tmp = (avm_main_sel_op_transaction_fee * (avm_kernel_kernel_in_offset - FF(40))); + auto tmp = (avm_main_sel_op_fee_per_l2_gas * (avm_kernel_kernel_in_offset - FF(36))); tmp *= scaling_factor; std::get<106>(evals) += tmp; } @@ -1284,7 +1286,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(107); - auto tmp = (avm_main_sel_op_chain_id * (avm_kernel_kernel_in_offset - FF(29))); + auto tmp = (avm_main_sel_op_transaction_fee * (avm_kernel_kernel_in_offset - FF(40))); tmp *= scaling_factor; std::get<107>(evals) += tmp; } @@ -1292,7 +1294,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(108); - auto tmp = (avm_main_sel_op_version * (avm_kernel_kernel_in_offset - FF(30))); + auto tmp = (avm_main_sel_op_chain_id * (avm_kernel_kernel_in_offset - FF(29))); tmp *= scaling_factor; std::get<108>(evals) += tmp; } @@ -1300,7 +1302,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(109); - auto tmp = (avm_main_sel_op_block_number * (avm_kernel_kernel_in_offset - FF(31))); + auto tmp = (avm_main_sel_op_version * (avm_kernel_kernel_in_offset - FF(30))); tmp *= scaling_factor; std::get<109>(evals) += tmp; } @@ -1308,7 +1310,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(110); - auto tmp = (avm_main_sel_op_coinbase * (avm_kernel_kernel_in_offset - FF(33))); + auto tmp = (avm_main_sel_op_block_number * (avm_kernel_kernel_in_offset - FF(31))); tmp *= scaling_factor; std::get<110>(evals) += tmp; } @@ -1316,7 +1318,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(111); - auto tmp = (avm_main_sel_op_timestamp * (avm_kernel_kernel_in_offset - FF(32))); + auto tmp = (avm_main_sel_op_coinbase * (avm_kernel_kernel_in_offset - FF(33))); tmp *= scaling_factor; std::get<111>(evals) += tmp; } @@ -1324,8 +1326,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(112); - auto tmp = (avm_main_sel_op_note_hash_exists * - (avm_kernel_kernel_out_offset - (avm_kernel_note_hash_exist_write_offset + FF(0)))); + auto tmp = (avm_main_sel_op_timestamp * (avm_kernel_kernel_in_offset - FF(32))); tmp *= scaling_factor; std::get<112>(evals) += tmp; } @@ -1333,7 +1334,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(113); - auto tmp = (avm_main_first * avm_kernel_note_hash_exist_write_offset); + auto tmp = (avm_main_sel_op_note_hash_exists * + (avm_kernel_kernel_out_offset - (avm_kernel_note_hash_exist_write_offset + FF(0)))); tmp *= scaling_factor; std::get<113>(evals) += tmp; } @@ -1341,8 +1343,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(114); - auto tmp = (avm_main_sel_op_emit_note_hash * - (avm_kernel_kernel_out_offset - (avm_kernel_emit_note_hash_write_offset + FF(160)))); + auto tmp = (avm_main_first * avm_kernel_note_hash_exist_write_offset); tmp *= scaling_factor; std::get<114>(evals) += tmp; } @@ -1350,7 +1351,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(115); - auto tmp = (avm_main_first * avm_kernel_emit_note_hash_write_offset); + auto tmp = (avm_main_sel_op_emit_note_hash * + (avm_kernel_kernel_out_offset - (avm_kernel_emit_note_hash_write_offset + FF(160)))); tmp *= scaling_factor; std::get<115>(evals) += tmp; } @@ -1358,8 +1360,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(116); - auto tmp = (avm_main_sel_op_nullifier_exists * - (avm_kernel_kernel_out_offset - (avm_kernel_nullifier_exists_write_offset + FF(32)))); + auto tmp = (avm_main_first * avm_kernel_emit_note_hash_write_offset); tmp *= scaling_factor; std::get<116>(evals) += tmp; } @@ -1367,7 +1368,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(117); - auto tmp = (avm_main_first * avm_kernel_nullifier_exists_write_offset); + auto tmp = (avm_main_sel_op_nullifier_exists * + (avm_kernel_kernel_out_offset - (avm_kernel_nullifier_exists_write_offset + FF(32)))); tmp *= scaling_factor; std::get<117>(evals) += tmp; } @@ -1375,8 +1377,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(118); - auto tmp = (avm_main_sel_op_emit_nullifier * - (avm_kernel_kernel_out_offset - (avm_kernel_emit_nullifier_write_offset + FF(176)))); + auto tmp = (avm_main_first * avm_kernel_nullifier_exists_write_offset); tmp *= scaling_factor; std::get<118>(evals) += tmp; } @@ -1384,7 +1385,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(119); - auto tmp = (avm_main_first * avm_kernel_emit_nullifier_write_offset); + auto tmp = (avm_main_sel_op_emit_nullifier * + (avm_kernel_kernel_out_offset - (avm_kernel_emit_nullifier_write_offset + FF(176)))); tmp *= scaling_factor; std::get<119>(evals) += tmp; } @@ -1392,8 +1394,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(120); - auto tmp = (avm_main_sel_op_l1_to_l2_msg_exists * - (avm_kernel_kernel_out_offset - (avm_kernel_l1_to_l2_msg_exists_write_offset + FF(96)))); + auto tmp = (avm_main_first * avm_kernel_emit_nullifier_write_offset); tmp *= scaling_factor; std::get<120>(evals) += tmp; } @@ -1401,7 +1402,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(121); - auto tmp = (avm_main_first * avm_kernel_l1_to_l2_msg_exists_write_offset); + auto tmp = (avm_main_sel_op_l1_to_l2_msg_exists * + (avm_kernel_kernel_out_offset - (avm_kernel_l1_to_l2_msg_exists_write_offset + FF(96)))); tmp *= scaling_factor; std::get<121>(evals) += tmp; } @@ -1409,8 +1411,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(122); - auto tmp = (avm_main_sel_op_emit_unencrypted_log * - (avm_kernel_kernel_out_offset - (avm_kernel_emit_unencrypted_log_write_offset + FF(194)))); + auto tmp = (avm_main_first * avm_kernel_l1_to_l2_msg_exists_write_offset); tmp *= scaling_factor; std::get<122>(evals) += tmp; } @@ -1418,7 +1419,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(123); - auto tmp = (avm_main_first * avm_kernel_emit_unencrypted_log_write_offset); + auto tmp = (avm_main_sel_op_emit_unencrypted_log * + (avm_kernel_kernel_out_offset - (avm_kernel_emit_unencrypted_log_write_offset + FF(194)))); tmp *= scaling_factor; std::get<123>(evals) += tmp; } @@ -1426,8 +1428,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(124); - auto tmp = (avm_main_sel_op_emit_l2_to_l1_msg * - (avm_kernel_kernel_out_offset - (avm_kernel_emit_l2_to_l1_msg_write_offset + FF(192)))); + auto tmp = (avm_main_first * avm_kernel_emit_unencrypted_log_write_offset); tmp *= scaling_factor; std::get<124>(evals) += tmp; } @@ -1435,7 +1436,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(125); - auto tmp = (avm_main_first * avm_kernel_emit_l2_to_l1_msg_write_offset); + auto tmp = (avm_main_sel_op_emit_l2_to_l1_msg * + (avm_kernel_kernel_out_offset - (avm_kernel_emit_l2_to_l1_msg_write_offset + FF(192)))); tmp *= scaling_factor; std::get<125>(evals) += tmp; } @@ -1443,8 +1445,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(126); - auto tmp = - (avm_main_sel_op_sload * (avm_kernel_kernel_out_offset - (avm_kernel_sload_write_offset + FF(112)))); + auto tmp = (avm_main_first * avm_kernel_emit_l2_to_l1_msg_write_offset); tmp *= scaling_factor; std::get<126>(evals) += tmp; } @@ -1452,7 +1453,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(127); - auto tmp = (avm_main_first * avm_kernel_sload_write_offset); + auto tmp = + (avm_main_sel_op_sload * (avm_kernel_kernel_out_offset - (avm_kernel_sload_write_offset + FF(112)))); tmp *= scaling_factor; std::get<127>(evals) += tmp; } @@ -1460,8 +1462,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(128); - auto tmp = - (avm_main_sel_op_sstore * (avm_kernel_kernel_out_offset - (avm_kernel_sstore_write_offset + FF(144)))); + auto tmp = (avm_main_first * avm_kernel_sload_write_offset); tmp *= scaling_factor; std::get<128>(evals) += tmp; } @@ -1469,7 +1470,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(129); - auto tmp = (avm_main_first * avm_kernel_sstore_write_offset); + auto tmp = + (avm_main_sel_op_sstore * (avm_kernel_kernel_out_offset - (avm_kernel_sstore_write_offset + FF(144)))); tmp *= scaling_factor; std::get<129>(evals) += tmp; } @@ -1477,6 +1479,14 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(130); + auto tmp = (avm_main_first * avm_kernel_sstore_write_offset); + tmp *= scaling_factor; + std::get<130>(evals) += tmp; + } + // Contribution 131 + { + Avm_DECLARE_VIEWS(131); + auto tmp = (((((((((avm_main_sel_op_note_hash_exists + avm_main_sel_op_emit_note_hash) + avm_main_sel_op_nullifier_exists) + avm_main_sel_op_emit_nullifier) + @@ -1487,23 +1497,23 @@ template class avm_mainImpl { avm_main_sel_op_sstore) * (avm_kernel_side_effect_counter_shift - (avm_kernel_side_effect_counter + FF(1)))); tmp *= scaling_factor; - std::get<130>(evals) += tmp; + std::get<131>(evals) += tmp; } - // Contribution 131 + // Contribution 132 { - Avm_DECLARE_VIEWS(131); + Avm_DECLARE_VIEWS(132); auto tmp = (avm_main_bin_op_id - (avm_main_sel_op_or + (avm_main_sel_op_xor * FF(2)))); tmp *= scaling_factor; - std::get<131>(evals) += tmp; + std::get<132>(evals) += tmp; } - // Contribution 132 + // Contribution 133 { - Avm_DECLARE_VIEWS(132); + Avm_DECLARE_VIEWS(133); auto tmp = (avm_main_bin_sel - ((avm_main_sel_op_and + avm_main_sel_op_or) + avm_main_sel_op_xor)); tmp *= scaling_factor; - std::get<132>(evals) += tmp; + std::get<133>(evals) += tmp; } } }; diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_mem.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_mem.hpp index f69768d2f6e..49cb36d3ba6 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_mem.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_mem.hpp @@ -6,472 +6,536 @@ namespace bb::Avm_vm { -template struct Avm_memRow { - FF avm_main_first{}; - FF avm_mem_addr{}; - FF avm_mem_clk{}; - FF avm_mem_diff_hi{}; - FF avm_mem_diff_lo{}; - FF avm_mem_diff_mid{}; - FF avm_mem_glob_addr{}; - FF avm_mem_glob_addr_shift{}; - FF avm_mem_ind_op_a{}; - FF avm_mem_ind_op_b{}; - FF avm_mem_ind_op_c{}; - FF avm_mem_ind_op_d{}; - FF avm_mem_last{}; - FF avm_mem_lastAccess{}; - FF avm_mem_mem_sel{}; - FF avm_mem_mem_sel_shift{}; - FF avm_mem_one_min_inv{}; - FF avm_mem_op_a{}; - FF avm_mem_op_b{}; - FF avm_mem_op_c{}; - FF avm_mem_op_d{}; - FF avm_mem_r_in_tag{}; - FF avm_mem_rng_chk_sel{}; - FF avm_mem_rw{}; - FF avm_mem_rw_shift{}; - FF avm_mem_sel_cmov{}; - FF avm_mem_sel_mov_a{}; - FF avm_mem_sel_mov_b{}; - FF avm_mem_skip_check_tag{}; - FF avm_mem_space_id{}; - FF avm_mem_tag{}; - FF avm_mem_tag_err{}; - FF avm_mem_tag_shift{}; - FF avm_mem_tsp{}; - FF avm_mem_tsp_shift{}; - FF avm_mem_val{}; - FF avm_mem_val_shift{}; - FF avm_mem_w_in_tag{}; -}; - -inline std::string get_relation_label_avm_mem(int index) -{ - switch (index) { - case 14: - return "MEM_CONTIGUOUS"; - - case 15: - return "MEM_FIRST_EMPTY"; - - case 16: - return "MEM_LAST"; - - case 18: - return "TIMESTAMP"; - - case 19: - return "GLOBAL_ADDR"; - - case 20: - return "LAST_ACCESS_FIRST_ROW"; - - case 21: - return "MEM_LAST_ACCESS_DELIMITER"; - - case 22: - return "DIFF_RNG_CHK_DEC"; - - case 23: - return "MEM_READ_WRITE_VAL_CONSISTENCY"; - - case 24: - return "MEM_READ_WRITE_TAG_CONSISTENCY"; - - case 25: - return "MEM_ZERO_INIT"; - - case 26: - return "SKIP_CHECK_TAG"; - - case 27: - return "MEM_IN_TAG_CONSISTENCY_1"; - - case 28: - return "MEM_IN_TAG_CONSISTENCY_2"; - - case 29: - return "NO_TAG_ERR_WRITE_OR_SKIP"; - - case 31: - return "NO_TAG_ERR_WRITE"; - - case 40: - return "MOV_SAME_TAG"; +template struct Avm_memRow { + FF avm_main_first {}; + FF avm_mem_addr {}; + FF avm_mem_clk {}; + FF avm_mem_diff_hi {}; + FF avm_mem_diff_lo {}; + FF avm_mem_diff_mid {}; + FF avm_mem_glob_addr {}; + FF avm_mem_glob_addr_shift {}; + FF avm_mem_ind_op_a {}; + FF avm_mem_ind_op_b {}; + FF avm_mem_ind_op_c {}; + FF avm_mem_ind_op_d {}; + FF avm_mem_last {}; + FF avm_mem_lastAccess {}; + FF avm_mem_mem_sel {}; + FF avm_mem_mem_sel_shift {}; + FF avm_mem_one_min_inv {}; + FF avm_mem_op_a {}; + FF avm_mem_op_b {}; + FF avm_mem_op_c {}; + FF avm_mem_op_d {}; + FF avm_mem_r_in_tag {}; + FF avm_mem_rng_chk_sel {}; + FF avm_mem_rw {}; + FF avm_mem_rw_shift {}; + FF avm_mem_sel_cmov {}; + FF avm_mem_sel_mov_a {}; + FF avm_mem_sel_mov_b {}; + FF avm_mem_skip_check_tag {}; + FF avm_mem_space_id {}; + FF avm_mem_tag {}; + FF avm_mem_tag_err {}; + FF avm_mem_tag_shift {}; + FF avm_mem_tsp {}; + FF avm_mem_tsp_shift {}; + FF avm_mem_val {}; + FF avm_mem_val_shift {}; + FF avm_mem_w_in_tag {}; + }; + + + inline std::string get_relation_label_avm_mem(int index) { + switch (index) { + case 14: + return "MEM_CONTIGUOUS"; + +case 15: + return "MEM_FIRST_EMPTY"; + +case 16: + return "MEM_LAST"; + +case 18: + return "TIMESTAMP"; + +case 19: + return "GLOBAL_ADDR"; + +case 20: + return "LAST_ACCESS_FIRST_ROW"; + +case 21: + return "MEM_LAST_ACCESS_DELIMITER"; + +case 22: + return "DIFF_RNG_CHK_DEC"; + +case 23: + return "MEM_READ_WRITE_VAL_CONSISTENCY"; + +case 24: + return "MEM_READ_WRITE_TAG_CONSISTENCY"; + +case 25: + return "MEM_ZERO_INIT"; + +case 26: + return "SKIP_CHECK_TAG"; + +case 27: + return "MEM_IN_TAG_CONSISTENCY_1"; + +case 28: + return "MEM_IN_TAG_CONSISTENCY_2"; + +case 29: + return "NO_TAG_ERR_WRITE_OR_SKIP"; + +case 31: + return "NO_TAG_ERR_WRITE"; + +case 40: + return "MOV_SAME_TAG"; + + } + return std::to_string(index); } - return std::to_string(index); -} + template class avm_memImpl { - public: - using FF = FF_; - - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 4, 3, 4, 3, 4, 3, 3, - 3, 4, 4, 4, 4, 4, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - }; - + public: + using FF = FF_; + + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 2, + 3, + 4, + 3, + 4, + 3, + 4, + 3, + 3, + 3, + 4, + 4, + 4, + 4, + 4, + 5, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, +}; + + template - void static accumulate(ContainerOverSubrelations& evals, - const AllEntities& new_term, - [[maybe_unused]] const RelationParameters&, - [[maybe_unused]] const FF& scaling_factor) + void static accumulate( + ContainerOverSubrelations& evals, + const AllEntities& new_term, + [[maybe_unused]] const RelationParameters&, + [[maybe_unused]] const FF& scaling_factor + ){ + + //Contribution 0 { +Avm_DECLARE_VIEWS(0); + + + auto tmp = (avm_mem_lastAccess * (-avm_mem_lastAccess + FF(1))); + tmp *= scaling_factor; + std::get<0>(evals) += tmp; +} +//Contribution 1 + { +Avm_DECLARE_VIEWS(1); + + + auto tmp = (avm_mem_last * (-avm_mem_last + FF(1))); + tmp *= scaling_factor; + std::get<1>(evals) += tmp; +} +//Contribution 2 + { +Avm_DECLARE_VIEWS(2); + + + auto tmp = (avm_mem_rw * (-avm_mem_rw + FF(1))); + tmp *= scaling_factor; + std::get<2>(evals) += tmp; +} +//Contribution 3 + { +Avm_DECLARE_VIEWS(3); + + + auto tmp = (avm_mem_tag_err * (-avm_mem_tag_err + FF(1))); + tmp *= scaling_factor; + std::get<3>(evals) += tmp; +} +//Contribution 4 + { +Avm_DECLARE_VIEWS(4); + + + auto tmp = (avm_mem_op_a * (-avm_mem_op_a + FF(1))); + tmp *= scaling_factor; + std::get<4>(evals) += tmp; +} +//Contribution 5 + { +Avm_DECLARE_VIEWS(5); + + + auto tmp = (avm_mem_op_b * (-avm_mem_op_b + FF(1))); + tmp *= scaling_factor; + std::get<5>(evals) += tmp; +} +//Contribution 6 + { +Avm_DECLARE_VIEWS(6); + + + auto tmp = (avm_mem_op_c * (-avm_mem_op_c + FF(1))); + tmp *= scaling_factor; + std::get<6>(evals) += tmp; +} +//Contribution 7 + { +Avm_DECLARE_VIEWS(7); + + + auto tmp = (avm_mem_op_d * (-avm_mem_op_d + FF(1))); + tmp *= scaling_factor; + std::get<7>(evals) += tmp; +} +//Contribution 8 + { +Avm_DECLARE_VIEWS(8); + + + auto tmp = (avm_mem_ind_op_a * (-avm_mem_ind_op_a + FF(1))); + tmp *= scaling_factor; + std::get<8>(evals) += tmp; +} +//Contribution 9 + { +Avm_DECLARE_VIEWS(9); + + + auto tmp = (avm_mem_ind_op_b * (-avm_mem_ind_op_b + FF(1))); + tmp *= scaling_factor; + std::get<9>(evals) += tmp; +} +//Contribution 10 + { +Avm_DECLARE_VIEWS(10); + + + auto tmp = (avm_mem_ind_op_c * (-avm_mem_ind_op_c + FF(1))); + tmp *= scaling_factor; + std::get<10>(evals) += tmp; +} +//Contribution 11 + { +Avm_DECLARE_VIEWS(11); + + + auto tmp = (avm_mem_ind_op_d * (-avm_mem_ind_op_d + FF(1))); + tmp *= scaling_factor; + std::get<11>(evals) += tmp; +} +//Contribution 12 + { +Avm_DECLARE_VIEWS(12); + + + auto tmp = (avm_mem_mem_sel - (((((((avm_mem_op_a + avm_mem_op_b) + avm_mem_op_c) + avm_mem_op_d) + avm_mem_ind_op_a) + avm_mem_ind_op_b) + avm_mem_ind_op_c) + avm_mem_ind_op_d)); + tmp *= scaling_factor; + std::get<12>(evals) += tmp; +} +//Contribution 13 + { +Avm_DECLARE_VIEWS(13); + + + auto tmp = (avm_mem_mem_sel * (avm_mem_mem_sel - FF(1))); + tmp *= scaling_factor; + std::get<13>(evals) += tmp; +} +//Contribution 14 + { +Avm_DECLARE_VIEWS(14); + + + auto tmp = (((-avm_main_first + FF(1)) * avm_mem_mem_sel_shift) * (-avm_mem_mem_sel + FF(1))); + tmp *= scaling_factor; + std::get<14>(evals) += tmp; +} +//Contribution 15 + { +Avm_DECLARE_VIEWS(15); + + + auto tmp = (avm_main_first * avm_mem_mem_sel); + tmp *= scaling_factor; + std::get<15>(evals) += tmp; +} +//Contribution 16 + { +Avm_DECLARE_VIEWS(16); + + + auto tmp = (((-avm_mem_last + FF(1)) * avm_mem_mem_sel) * (-avm_mem_mem_sel_shift + FF(1))); + tmp *= scaling_factor; + std::get<16>(evals) += tmp; +} +//Contribution 17 + { +Avm_DECLARE_VIEWS(17); + + + auto tmp = (avm_mem_rng_chk_sel - (avm_mem_mem_sel * (-avm_mem_last + FF(1)))); + tmp *= scaling_factor; + std::get<17>(evals) += tmp; +} +//Contribution 18 + { +Avm_DECLARE_VIEWS(18); + + + auto tmp = (avm_mem_tsp - ((avm_mem_clk * FF(12)) + (avm_mem_mem_sel * ((((avm_mem_ind_op_b + avm_mem_op_b) + ((avm_mem_ind_op_c + avm_mem_op_c) * FF(2))) + ((avm_mem_ind_op_d + avm_mem_op_d) * FF(3))) + (((-(((avm_mem_ind_op_a + avm_mem_ind_op_b) + avm_mem_ind_op_c) + avm_mem_ind_op_d) + FF(1)) + avm_mem_rw) * FF(4)))))); + tmp *= scaling_factor; + std::get<18>(evals) += tmp; +} +//Contribution 19 + { +Avm_DECLARE_VIEWS(19); + + + auto tmp = (avm_mem_glob_addr - ((avm_mem_space_id * FF(4294967296UL)) + avm_mem_addr)); + tmp *= scaling_factor; + std::get<19>(evals) += tmp; +} +//Contribution 20 + { +Avm_DECLARE_VIEWS(20); + + + auto tmp = (avm_main_first * (-avm_mem_lastAccess + FF(1))); + tmp *= scaling_factor; + std::get<20>(evals) += tmp; +} +//Contribution 21 + { +Avm_DECLARE_VIEWS(21); + + + auto tmp = ((-avm_mem_lastAccess + FF(1)) * (avm_mem_glob_addr_shift - avm_mem_glob_addr)); + tmp *= scaling_factor; + std::get<21>(evals) += tmp; +} +//Contribution 22 + { +Avm_DECLARE_VIEWS(22); + + + auto tmp = (avm_mem_rng_chk_sel * (((((avm_mem_lastAccess * (avm_mem_glob_addr_shift - avm_mem_glob_addr)) + ((-avm_mem_lastAccess + FF(1)) * (avm_mem_tsp_shift - avm_mem_tsp))) - (avm_mem_diff_hi * FF(4294967296UL))) - (avm_mem_diff_mid * FF(65536))) - avm_mem_diff_lo)); + tmp *= scaling_factor; + std::get<22>(evals) += tmp; +} +//Contribution 23 + { +Avm_DECLARE_VIEWS(23); + + + auto tmp = (((-avm_mem_lastAccess + FF(1)) * (-avm_mem_rw_shift + FF(1))) * (avm_mem_val_shift - avm_mem_val)); + tmp *= scaling_factor; + std::get<23>(evals) += tmp; +} +//Contribution 24 + { +Avm_DECLARE_VIEWS(24); + + + auto tmp = (((-avm_mem_lastAccess + FF(1)) * (-avm_mem_rw_shift + FF(1))) * (avm_mem_tag_shift - avm_mem_tag)); + tmp *= scaling_factor; + std::get<24>(evals) += tmp; +} +//Contribution 25 + { +Avm_DECLARE_VIEWS(25); + + + auto tmp = ((avm_mem_lastAccess * (-avm_mem_rw_shift + FF(1))) * avm_mem_val_shift); + tmp *= scaling_factor; + std::get<25>(evals) += tmp; +} +//Contribution 26 + { +Avm_DECLARE_VIEWS(26); + + + auto tmp = (avm_mem_skip_check_tag - (avm_mem_sel_cmov * ((avm_mem_op_d + (avm_mem_op_a * (-avm_mem_sel_mov_a + FF(1)))) + (avm_mem_op_b * (-avm_mem_sel_mov_b + FF(1)))))); + tmp *= scaling_factor; + std::get<26>(evals) += tmp; +} +//Contribution 27 + { +Avm_DECLARE_VIEWS(27); + + + auto tmp = (((-avm_mem_skip_check_tag + FF(1)) * (-avm_mem_rw + FF(1))) * (((avm_mem_r_in_tag - avm_mem_tag) * (-avm_mem_one_min_inv + FF(1))) - avm_mem_tag_err)); + tmp *= scaling_factor; + std::get<27>(evals) += tmp; +} +//Contribution 28 + { +Avm_DECLARE_VIEWS(28); + + + auto tmp = ((-avm_mem_tag_err + FF(1)) * avm_mem_one_min_inv); + tmp *= scaling_factor; + std::get<28>(evals) += tmp; +} +//Contribution 29 + { +Avm_DECLARE_VIEWS(29); + + + auto tmp = ((avm_mem_skip_check_tag + avm_mem_rw) * avm_mem_tag_err); + tmp *= scaling_factor; + std::get<29>(evals) += tmp; +} +//Contribution 30 + { +Avm_DECLARE_VIEWS(30); + + + auto tmp = (avm_mem_rw * (avm_mem_w_in_tag - avm_mem_tag)); + tmp *= scaling_factor; + std::get<30>(evals) += tmp; +} +//Contribution 31 + { +Avm_DECLARE_VIEWS(31); + + + auto tmp = (avm_mem_rw * avm_mem_tag_err); + tmp *= scaling_factor; + std::get<31>(evals) += tmp; +} +//Contribution 32 + { +Avm_DECLARE_VIEWS(32); + + + auto tmp = (avm_mem_ind_op_a * (avm_mem_r_in_tag - FF(3))); + tmp *= scaling_factor; + std::get<32>(evals) += tmp; +} +//Contribution 33 + { +Avm_DECLARE_VIEWS(33); + + + auto tmp = (avm_mem_ind_op_b * (avm_mem_r_in_tag - FF(3))); + tmp *= scaling_factor; + std::get<33>(evals) += tmp; +} +//Contribution 34 + { +Avm_DECLARE_VIEWS(34); + + + auto tmp = (avm_mem_ind_op_c * (avm_mem_r_in_tag - FF(3))); + tmp *= scaling_factor; + std::get<34>(evals) += tmp; +} +//Contribution 35 + { +Avm_DECLARE_VIEWS(35); + + + auto tmp = (avm_mem_ind_op_d * (avm_mem_r_in_tag - FF(3))); + tmp *= scaling_factor; + std::get<35>(evals) += tmp; +} +//Contribution 36 + { +Avm_DECLARE_VIEWS(36); + + + auto tmp = (avm_mem_ind_op_a * avm_mem_rw); + tmp *= scaling_factor; + std::get<36>(evals) += tmp; +} +//Contribution 37 + { +Avm_DECLARE_VIEWS(37); + + + auto tmp = (avm_mem_ind_op_b * avm_mem_rw); + tmp *= scaling_factor; + std::get<37>(evals) += tmp; +} +//Contribution 38 + { +Avm_DECLARE_VIEWS(38); + + + auto tmp = (avm_mem_ind_op_c * avm_mem_rw); + tmp *= scaling_factor; + std::get<38>(evals) += tmp; +} +//Contribution 39 + { +Avm_DECLARE_VIEWS(39); + + + auto tmp = (avm_mem_ind_op_d * avm_mem_rw); + tmp *= scaling_factor; + std::get<39>(evals) += tmp; +} +//Contribution 40 + { +Avm_DECLARE_VIEWS(40); + + + auto tmp = ((avm_mem_sel_mov_a + avm_mem_sel_mov_b) * avm_mem_tag_err); + tmp *= scaling_factor; + std::get<40>(evals) += tmp; +} +} - // Contribution 0 - { - Avm_DECLARE_VIEWS(0); - - auto tmp = (avm_mem_lastAccess * (-avm_mem_lastAccess + FF(1))); - tmp *= scaling_factor; - std::get<0>(evals) += tmp; - } - // Contribution 1 - { - Avm_DECLARE_VIEWS(1); - - auto tmp = (avm_mem_last * (-avm_mem_last + FF(1))); - tmp *= scaling_factor; - std::get<1>(evals) += tmp; - } - // Contribution 2 - { - Avm_DECLARE_VIEWS(2); - - auto tmp = (avm_mem_rw * (-avm_mem_rw + FF(1))); - tmp *= scaling_factor; - std::get<2>(evals) += tmp; - } - // Contribution 3 - { - Avm_DECLARE_VIEWS(3); - - auto tmp = (avm_mem_tag_err * (-avm_mem_tag_err + FF(1))); - tmp *= scaling_factor; - std::get<3>(evals) += tmp; - } - // Contribution 4 - { - Avm_DECLARE_VIEWS(4); - - auto tmp = (avm_mem_op_a * (-avm_mem_op_a + FF(1))); - tmp *= scaling_factor; - std::get<4>(evals) += tmp; - } - // Contribution 5 - { - Avm_DECLARE_VIEWS(5); - - auto tmp = (avm_mem_op_b * (-avm_mem_op_b + FF(1))); - tmp *= scaling_factor; - std::get<5>(evals) += tmp; - } - // Contribution 6 - { - Avm_DECLARE_VIEWS(6); - - auto tmp = (avm_mem_op_c * (-avm_mem_op_c + FF(1))); - tmp *= scaling_factor; - std::get<6>(evals) += tmp; - } - // Contribution 7 - { - Avm_DECLARE_VIEWS(7); - - auto tmp = (avm_mem_op_d * (-avm_mem_op_d + FF(1))); - tmp *= scaling_factor; - std::get<7>(evals) += tmp; - } - // Contribution 8 - { - Avm_DECLARE_VIEWS(8); - - auto tmp = (avm_mem_ind_op_a * (-avm_mem_ind_op_a + FF(1))); - tmp *= scaling_factor; - std::get<8>(evals) += tmp; - } - // Contribution 9 - { - Avm_DECLARE_VIEWS(9); - - auto tmp = (avm_mem_ind_op_b * (-avm_mem_ind_op_b + FF(1))); - tmp *= scaling_factor; - std::get<9>(evals) += tmp; - } - // Contribution 10 - { - Avm_DECLARE_VIEWS(10); - - auto tmp = (avm_mem_ind_op_c * (-avm_mem_ind_op_c + FF(1))); - tmp *= scaling_factor; - std::get<10>(evals) += tmp; - } - // Contribution 11 - { - Avm_DECLARE_VIEWS(11); - - auto tmp = (avm_mem_ind_op_d * (-avm_mem_ind_op_d + FF(1))); - tmp *= scaling_factor; - std::get<11>(evals) += tmp; - } - // Contribution 12 - { - Avm_DECLARE_VIEWS(12); - - auto tmp = (avm_mem_mem_sel - - (((((((avm_mem_op_a + avm_mem_op_b) + avm_mem_op_c) + avm_mem_op_d) + avm_mem_ind_op_a) + - avm_mem_ind_op_b) + - avm_mem_ind_op_c) + - avm_mem_ind_op_d)); - tmp *= scaling_factor; - std::get<12>(evals) += tmp; - } - // Contribution 13 - { - Avm_DECLARE_VIEWS(13); - - auto tmp = (avm_mem_mem_sel * (avm_mem_mem_sel - FF(1))); - tmp *= scaling_factor; - std::get<13>(evals) += tmp; - } - // Contribution 14 - { - Avm_DECLARE_VIEWS(14); - - auto tmp = (((-avm_main_first + FF(1)) * avm_mem_mem_sel_shift) * (-avm_mem_mem_sel + FF(1))); - tmp *= scaling_factor; - std::get<14>(evals) += tmp; - } - // Contribution 15 - { - Avm_DECLARE_VIEWS(15); - - auto tmp = (avm_main_first * avm_mem_mem_sel); - tmp *= scaling_factor; - std::get<15>(evals) += tmp; - } - // Contribution 16 - { - Avm_DECLARE_VIEWS(16); - - auto tmp = (((-avm_mem_last + FF(1)) * avm_mem_mem_sel) * (-avm_mem_mem_sel_shift + FF(1))); - tmp *= scaling_factor; - std::get<16>(evals) += tmp; - } - // Contribution 17 - { - Avm_DECLARE_VIEWS(17); - - auto tmp = (avm_mem_rng_chk_sel - (avm_mem_mem_sel * (-avm_mem_last + FF(1)))); - tmp *= scaling_factor; - std::get<17>(evals) += tmp; - } - // Contribution 18 - { - Avm_DECLARE_VIEWS(18); - - auto tmp = - (avm_mem_tsp - - ((avm_mem_clk * FF(12)) + - (avm_mem_mem_sel * - ((((avm_mem_ind_op_b + avm_mem_op_b) + ((avm_mem_ind_op_c + avm_mem_op_c) * FF(2))) + - ((avm_mem_ind_op_d + avm_mem_op_d) * FF(3))) + - (((-(((avm_mem_ind_op_a + avm_mem_ind_op_b) + avm_mem_ind_op_c) + avm_mem_ind_op_d) + FF(1)) + - avm_mem_rw) * - FF(4)))))); - tmp *= scaling_factor; - std::get<18>(evals) += tmp; - } - // Contribution 19 - { - Avm_DECLARE_VIEWS(19); - - auto tmp = (avm_mem_glob_addr - ((avm_mem_space_id * FF(4294967296UL)) + avm_mem_addr)); - tmp *= scaling_factor; - std::get<19>(evals) += tmp; - } - // Contribution 20 - { - Avm_DECLARE_VIEWS(20); - - auto tmp = (avm_main_first * (-avm_mem_lastAccess + FF(1))); - tmp *= scaling_factor; - std::get<20>(evals) += tmp; - } - // Contribution 21 - { - Avm_DECLARE_VIEWS(21); - - auto tmp = ((-avm_mem_lastAccess + FF(1)) * (avm_mem_glob_addr_shift - avm_mem_glob_addr)); - tmp *= scaling_factor; - std::get<21>(evals) += tmp; - } - // Contribution 22 - { - Avm_DECLARE_VIEWS(22); - - auto tmp = (avm_mem_rng_chk_sel * (((((avm_mem_lastAccess * (avm_mem_glob_addr_shift - avm_mem_glob_addr)) + - ((-avm_mem_lastAccess + FF(1)) * (avm_mem_tsp_shift - avm_mem_tsp))) - - (avm_mem_diff_hi * FF(4294967296UL))) - - (avm_mem_diff_mid * FF(65536))) - - avm_mem_diff_lo)); - tmp *= scaling_factor; - std::get<22>(evals) += tmp; - } - // Contribution 23 - { - Avm_DECLARE_VIEWS(23); - - auto tmp = - (((-avm_mem_lastAccess + FF(1)) * (-avm_mem_rw_shift + FF(1))) * (avm_mem_val_shift - avm_mem_val)); - tmp *= scaling_factor; - std::get<23>(evals) += tmp; - } - // Contribution 24 - { - Avm_DECLARE_VIEWS(24); - - auto tmp = - (((-avm_mem_lastAccess + FF(1)) * (-avm_mem_rw_shift + FF(1))) * (avm_mem_tag_shift - avm_mem_tag)); - tmp *= scaling_factor; - std::get<24>(evals) += tmp; - } - // Contribution 25 - { - Avm_DECLARE_VIEWS(25); - - auto tmp = ((avm_mem_lastAccess * (-avm_mem_rw_shift + FF(1))) * avm_mem_val_shift); - tmp *= scaling_factor; - std::get<25>(evals) += tmp; - } - // Contribution 26 - { - Avm_DECLARE_VIEWS(26); - - auto tmp = (avm_mem_skip_check_tag - - (avm_mem_sel_cmov * ((avm_mem_op_d + (avm_mem_op_a * (-avm_mem_sel_mov_a + FF(1)))) + - (avm_mem_op_b * (-avm_mem_sel_mov_b + FF(1)))))); - tmp *= scaling_factor; - std::get<26>(evals) += tmp; - } - // Contribution 27 - { - Avm_DECLARE_VIEWS(27); - - auto tmp = (((-avm_mem_skip_check_tag + FF(1)) * (-avm_mem_rw + FF(1))) * - (((avm_mem_r_in_tag - avm_mem_tag) * (-avm_mem_one_min_inv + FF(1))) - avm_mem_tag_err)); - tmp *= scaling_factor; - std::get<27>(evals) += tmp; - } - // Contribution 28 - { - Avm_DECLARE_VIEWS(28); - - auto tmp = ((-avm_mem_tag_err + FF(1)) * avm_mem_one_min_inv); - tmp *= scaling_factor; - std::get<28>(evals) += tmp; - } - // Contribution 29 - { - Avm_DECLARE_VIEWS(29); - - auto tmp = ((avm_mem_skip_check_tag + avm_mem_rw) * avm_mem_tag_err); - tmp *= scaling_factor; - std::get<29>(evals) += tmp; - } - // Contribution 30 - { - Avm_DECLARE_VIEWS(30); - - auto tmp = (avm_mem_rw * (avm_mem_w_in_tag - avm_mem_tag)); - tmp *= scaling_factor; - std::get<30>(evals) += tmp; - } - // Contribution 31 - { - Avm_DECLARE_VIEWS(31); - - auto tmp = (avm_mem_rw * avm_mem_tag_err); - tmp *= scaling_factor; - std::get<31>(evals) += tmp; - } - // Contribution 32 - { - Avm_DECLARE_VIEWS(32); - - auto tmp = (avm_mem_ind_op_a * (avm_mem_r_in_tag - FF(3))); - tmp *= scaling_factor; - std::get<32>(evals) += tmp; - } - // Contribution 33 - { - Avm_DECLARE_VIEWS(33); - - auto tmp = (avm_mem_ind_op_b * (avm_mem_r_in_tag - FF(3))); - tmp *= scaling_factor; - std::get<33>(evals) += tmp; - } - // Contribution 34 - { - Avm_DECLARE_VIEWS(34); - - auto tmp = (avm_mem_ind_op_c * (avm_mem_r_in_tag - FF(3))); - tmp *= scaling_factor; - std::get<34>(evals) += tmp; - } - // Contribution 35 - { - Avm_DECLARE_VIEWS(35); - - auto tmp = (avm_mem_ind_op_d * (avm_mem_r_in_tag - FF(3))); - tmp *= scaling_factor; - std::get<35>(evals) += tmp; - } - // Contribution 36 - { - Avm_DECLARE_VIEWS(36); - - auto tmp = (avm_mem_ind_op_a * avm_mem_rw); - tmp *= scaling_factor; - std::get<36>(evals) += tmp; - } - // Contribution 37 - { - Avm_DECLARE_VIEWS(37); - - auto tmp = (avm_mem_ind_op_b * avm_mem_rw); - tmp *= scaling_factor; - std::get<37>(evals) += tmp; - } - // Contribution 38 - { - Avm_DECLARE_VIEWS(38); - - auto tmp = (avm_mem_ind_op_c * avm_mem_rw); - tmp *= scaling_factor; - std::get<38>(evals) += tmp; - } - // Contribution 39 - { - Avm_DECLARE_VIEWS(39); - - auto tmp = (avm_mem_ind_op_d * avm_mem_rw); - tmp *= scaling_factor; - std::get<39>(evals) += tmp; - } - // Contribution 40 - { - Avm_DECLARE_VIEWS(40); - - auto tmp = ((avm_mem_sel_mov_a + avm_mem_sel_mov_b) * avm_mem_tag_err); - tmp *= scaling_factor; - std::get<40>(evals) += tmp; - } - } }; template using avm_mem = Relation>; -} // namespace bb::Avm_vm \ No newline at end of file + } \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_pedersen.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_pedersen.hpp index 6a0c0be6824..e5c37f65804 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_pedersen.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_pedersen.hpp @@ -6,42 +6,49 @@ namespace bb::Avm_vm { -template struct Avm_pedersenRow { - FF avm_pedersen_pedersen_sel{}; -}; - -inline std::string get_relation_label_avm_pedersen(int index) -{ - switch (index) {} - return std::to_string(index); -} +template struct Avm_pedersenRow { + FF avm_pedersen_pedersen_sel {}; + }; -template class avm_pedersenImpl { - public: - using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, - }; + inline std::string get_relation_label_avm_pedersen(int index) { + switch (index) { + + } + return std::to_string(index); + } + +template class avm_pedersenImpl { + public: + using FF = FF_; + + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 3, +}; + + template - void static accumulate(ContainerOverSubrelations& evals, - const AllEntities& new_term, - [[maybe_unused]] const RelationParameters&, - [[maybe_unused]] const FF& scaling_factor) + void static accumulate( + ContainerOverSubrelations& evals, + const AllEntities& new_term, + [[maybe_unused]] const RelationParameters&, + [[maybe_unused]] const FF& scaling_factor + ){ + + //Contribution 0 { +Avm_DECLARE_VIEWS(0); + + + auto tmp = (avm_pedersen_pedersen_sel * (-avm_pedersen_pedersen_sel + FF(1))); + tmp *= scaling_factor; + std::get<0>(evals) += tmp; +} +} - // Contribution 0 - { - Avm_DECLARE_VIEWS(0); - - auto tmp = (avm_pedersen_pedersen_sel * (-avm_pedersen_pedersen_sel + FF(1))); - tmp *= scaling_factor; - std::get<0>(evals) += tmp; - } - } }; template using avm_pedersen = Relation>; -} // namespace bb::Avm_vm \ No newline at end of file + } \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_poseidon2.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_poseidon2.hpp index 31f558e82db..8fa8420c1cd 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_poseidon2.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_poseidon2.hpp @@ -6,42 +6,49 @@ namespace bb::Avm_vm { -template struct Avm_poseidon2Row { - FF avm_poseidon2_poseidon_perm_sel{}; -}; - -inline std::string get_relation_label_avm_poseidon2(int index) -{ - switch (index) {} - return std::to_string(index); -} +template struct Avm_poseidon2Row { + FF avm_poseidon2_poseidon_perm_sel {}; + }; -template class avm_poseidon2Impl { - public: - using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, - }; + inline std::string get_relation_label_avm_poseidon2(int index) { + switch (index) { + + } + return std::to_string(index); + } + +template class avm_poseidon2Impl { + public: + using FF = FF_; + + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 3, +}; + + template - void static accumulate(ContainerOverSubrelations& evals, - const AllEntities& new_term, - [[maybe_unused]] const RelationParameters&, - [[maybe_unused]] const FF& scaling_factor) + void static accumulate( + ContainerOverSubrelations& evals, + const AllEntities& new_term, + [[maybe_unused]] const RelationParameters&, + [[maybe_unused]] const FF& scaling_factor + ){ + + //Contribution 0 { +Avm_DECLARE_VIEWS(0); + + + auto tmp = (avm_poseidon2_poseidon_perm_sel * (-avm_poseidon2_poseidon_perm_sel + FF(1))); + tmp *= scaling_factor; + std::get<0>(evals) += tmp; +} +} - // Contribution 0 - { - Avm_DECLARE_VIEWS(0); - - auto tmp = (avm_poseidon2_poseidon_perm_sel * (-avm_poseidon2_poseidon_perm_sel + FF(1))); - tmp *= scaling_factor; - std::get<0>(evals) += tmp; - } - } }; template using avm_poseidon2 = Relation>; -} // namespace bb::Avm_vm \ No newline at end of file + } \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_sha256.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_sha256.hpp index 8daf1fce39f..a6459e54f71 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_sha256.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_sha256.hpp @@ -6,42 +6,49 @@ namespace bb::Avm_vm { -template struct Avm_sha256Row { - FF avm_sha256_sha256_compression_sel{}; -}; - -inline std::string get_relation_label_avm_sha256(int index) -{ - switch (index) {} - return std::to_string(index); -} +template struct Avm_sha256Row { + FF avm_sha256_sha256_compression_sel {}; + }; -template class avm_sha256Impl { - public: - using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, - }; + inline std::string get_relation_label_avm_sha256(int index) { + switch (index) { + + } + return std::to_string(index); + } + +template class avm_sha256Impl { + public: + using FF = FF_; + + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 3, +}; + + template - void static accumulate(ContainerOverSubrelations& evals, - const AllEntities& new_term, - [[maybe_unused]] const RelationParameters&, - [[maybe_unused]] const FF& scaling_factor) + void static accumulate( + ContainerOverSubrelations& evals, + const AllEntities& new_term, + [[maybe_unused]] const RelationParameters&, + [[maybe_unused]] const FF& scaling_factor + ){ + + //Contribution 0 { +Avm_DECLARE_VIEWS(0); + + + auto tmp = (avm_sha256_sha256_compression_sel * (-avm_sha256_sha256_compression_sel + FF(1))); + tmp *= scaling_factor; + std::get<0>(evals) += tmp; +} +} - // Contribution 0 - { - Avm_DECLARE_VIEWS(0); - - auto tmp = (avm_sha256_sha256_compression_sel * (-avm_sha256_sha256_compression_sel + FF(1))); - tmp *= scaling_factor; - std::get<0>(evals) += tmp; - } - } }; template using avm_sha256 = Relation>; -} // namespace bb::Avm_vm \ No newline at end of file + } \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/declare_views.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/declare_views.hpp index 8fd2367fab7..4afab78909a 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/declare_views.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/declare_views.hpp @@ -195,6 +195,7 @@ [[maybe_unused]] auto avm_main_rwc = View(new_term.avm_main_rwc); \ [[maybe_unused]] auto avm_main_rwd = View(new_term.avm_main_rwd); \ [[maybe_unused]] auto avm_main_sel_cmov = View(new_term.avm_main_sel_cmov); \ + [[maybe_unused]] auto avm_main_sel_external_call = View(new_term.avm_main_sel_external_call); \ [[maybe_unused]] auto avm_main_sel_halt = View(new_term.avm_main_sel_halt); \ [[maybe_unused]] auto avm_main_sel_internal_call = View(new_term.avm_main_sel_internal_call); \ [[maybe_unused]] auto avm_main_sel_internal_return = View(new_term.avm_main_sel_internal_return); \ diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_main_tag_err.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_main_tag_err.hpp index cfb4885c4b5..4a5e364abab 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_main_tag_err.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_main_tag_err.hpp @@ -1,167 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class incl_main_tag_err_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class incl_main_tag_err_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_mem_tag_err == 1 || in.avm_main_tag_err == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_mem_tag_err); const auto is_table_entry = View(in.avm_main_tag_err); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.incl_main_tag_err, - in.incl_main_tag_err_counts, - in.avm_mem_tag_err, - in.avm_main_tag_err, - in.avm_mem_clk, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.incl_main_tag_err, +in.incl_main_tag_err_counts, +in.avm_mem_tag_err, +in.avm_main_tag_err, +in.avm_mem_clk, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.incl_main_tag_err, - in.incl_main_tag_err_counts, - in.avm_mem_tag_err, - in.avm_main_tag_err, - in.avm_mem_clk, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.incl_main_tag_err, +in.incl_main_tag_err_counts, +in.avm_mem_tag_err, +in.avm_main_tag_err, +in.avm_mem_clk, +in.avm_main_clk + ); + } -}; - -template -using incl_main_tag_err_relation = GenericLookupRelation; -template using incl_main_tag_err = GenericLookup; + + }; -} // namespace bb + + template using incl_main_tag_err_relation = GenericLookupRelation; + template using incl_main_tag_err = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_mem_tag_err.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_mem_tag_err.hpp index 4055ceb7951..fc6d5d99751 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_mem_tag_err.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_mem_tag_err.hpp @@ -1,166 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class incl_mem_tag_err_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class incl_mem_tag_err_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_main_tag_err == 1 || in.avm_mem_tag_err == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_main_tag_err); const auto is_table_entry = View(in.avm_mem_tag_err); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.incl_mem_tag_err, - in.incl_mem_tag_err_counts, - in.avm_main_tag_err, - in.avm_mem_tag_err, - in.avm_main_clk, - in.avm_mem_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.incl_mem_tag_err, +in.incl_mem_tag_err_counts, +in.avm_main_tag_err, +in.avm_mem_tag_err, +in.avm_main_clk, +in.avm_mem_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.incl_mem_tag_err, - in.incl_mem_tag_err_counts, - in.avm_main_tag_err, - in.avm_mem_tag_err, - in.avm_main_clk, - in.avm_mem_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.incl_mem_tag_err, +in.incl_mem_tag_err_counts, +in.avm_main_tag_err, +in.avm_mem_tag_err, +in.avm_main_clk, +in.avm_mem_clk + ); + } -}; - -template using incl_mem_tag_err_relation = GenericLookupRelation; -template using incl_mem_tag_err = GenericLookup; + + }; -} // namespace bb + + template using incl_mem_tag_err_relation = GenericLookupRelation; + template using incl_mem_tag_err = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/kernel_output_lookup.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/kernel_output_lookup.hpp index 49023977d03..0207fe421cd 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/kernel_output_lookup.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/kernel_output_lookup.hpp @@ -1,179 +1,184 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class kernel_output_lookup_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 4; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class kernel_output_lookup_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 4; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_main_q_kernel_output_lookup == 1 || in.avm_kernel_q_public_input_kernel_out_add_to_table == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_main_q_kernel_output_lookup); const auto is_table_entry = View(in.avm_kernel_q_public_input_kernel_out_add_to_table); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.kernel_output_lookup, - in.kernel_output_lookup_counts, - in.avm_main_q_kernel_output_lookup, - in.avm_kernel_q_public_input_kernel_out_add_to_table, - in.avm_kernel_kernel_out_offset, - in.avm_main_ia, - in.avm_kernel_side_effect_counter, - in.avm_main_ib, - in.avm_main_clk, - in.avm_kernel_kernel_value_out__is_public, - in.avm_kernel_kernel_side_effect_out__is_public, - in.avm_kernel_kernel_metadata_out__is_public); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.kernel_output_lookup, +in.kernel_output_lookup_counts, +in.avm_main_q_kernel_output_lookup, +in.avm_kernel_q_public_input_kernel_out_add_to_table, +in.avm_kernel_kernel_out_offset, +in.avm_main_ia, +in.avm_kernel_side_effect_counter, +in.avm_main_ib, +in.avm_main_clk, +in.avm_kernel_kernel_value_out__is_public, +in.avm_kernel_kernel_side_effect_out__is_public, +in.avm_kernel_kernel_metadata_out__is_public + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.kernel_output_lookup, - in.kernel_output_lookup_counts, - in.avm_main_q_kernel_output_lookup, - in.avm_kernel_q_public_input_kernel_out_add_to_table, - in.avm_kernel_kernel_out_offset, - in.avm_main_ia, - in.avm_kernel_side_effect_counter, - in.avm_main_ib, - in.avm_main_clk, - in.avm_kernel_kernel_value_out__is_public, - in.avm_kernel_kernel_side_effect_out__is_public, - in.avm_kernel_kernel_metadata_out__is_public); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.kernel_output_lookup, +in.kernel_output_lookup_counts, +in.avm_main_q_kernel_output_lookup, +in.avm_kernel_q_public_input_kernel_out_add_to_table, +in.avm_kernel_kernel_out_offset, +in.avm_main_ia, +in.avm_kernel_side_effect_counter, +in.avm_main_ib, +in.avm_main_clk, +in.avm_kernel_kernel_value_out__is_public, +in.avm_kernel_kernel_side_effect_out__is_public, +in.avm_kernel_kernel_metadata_out__is_public + ); + } -}; - -template -using kernel_output_lookup_relation = GenericLookupRelation; -template using kernel_output_lookup = GenericLookup; + + }; -} // namespace bb + + template using kernel_output_lookup_relation = GenericLookupRelation; + template using kernel_output_lookup = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_lengths.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_lengths.hpp index 66268991c7c..dd0e670d158 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_lengths.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_lengths.hpp @@ -1,171 +1,176 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_byte_lengths_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 2; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_byte_lengths_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 2; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_binary_start == 1 || in.avm_byte_lookup_bin_sel == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_binary_start); const auto is_table_entry = View(in.avm_byte_lookup_bin_sel); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_byte_lengths, - in.lookup_byte_lengths_counts, - in.avm_binary_start, - in.avm_byte_lookup_bin_sel, - in.avm_binary_in_tag, - in.avm_binary_mem_tag_ctr, - in.avm_byte_lookup_table_in_tags, - in.avm_byte_lookup_table_byte_lengths); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_byte_lengths, +in.lookup_byte_lengths_counts, +in.avm_binary_start, +in.avm_byte_lookup_bin_sel, +in.avm_binary_in_tag, +in.avm_binary_mem_tag_ctr, +in.avm_byte_lookup_table_in_tags, +in.avm_byte_lookup_table_byte_lengths + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_byte_lengths, - in.lookup_byte_lengths_counts, - in.avm_binary_start, - in.avm_byte_lookup_bin_sel, - in.avm_binary_in_tag, - in.avm_binary_mem_tag_ctr, - in.avm_byte_lookup_table_in_tags, - in.avm_byte_lookup_table_byte_lengths); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_byte_lengths, +in.lookup_byte_lengths_counts, +in.avm_binary_start, +in.avm_byte_lookup_bin_sel, +in.avm_binary_in_tag, +in.avm_binary_mem_tag_ctr, +in.avm_byte_lookup_table_in_tags, +in.avm_byte_lookup_table_byte_lengths + ); + } -}; - -template -using lookup_byte_lengths_relation = GenericLookupRelation; -template using lookup_byte_lengths = GenericLookup; + + }; -} // namespace bb + + template using lookup_byte_lengths_relation = GenericLookupRelation; + template using lookup_byte_lengths = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_operations.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_operations.hpp index baf2995fcb8..537002aeff0 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_operations.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_operations.hpp @@ -1,179 +1,184 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_byte_operations_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 4; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_byte_operations_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 4; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_binary_bin_sel == 1 || in.avm_byte_lookup_bin_sel == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_binary_bin_sel); const auto is_table_entry = View(in.avm_byte_lookup_bin_sel); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_byte_operations, - in.lookup_byte_operations_counts, - in.avm_binary_bin_sel, - in.avm_byte_lookup_bin_sel, - in.avm_binary_op_id, - in.avm_binary_ia_bytes, - in.avm_binary_ib_bytes, - in.avm_binary_ic_bytes, - in.avm_byte_lookup_table_op_id, - in.avm_byte_lookup_table_input_a, - in.avm_byte_lookup_table_input_b, - in.avm_byte_lookup_table_output); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_byte_operations, +in.lookup_byte_operations_counts, +in.avm_binary_bin_sel, +in.avm_byte_lookup_bin_sel, +in.avm_binary_op_id, +in.avm_binary_ia_bytes, +in.avm_binary_ib_bytes, +in.avm_binary_ic_bytes, +in.avm_byte_lookup_table_op_id, +in.avm_byte_lookup_table_input_a, +in.avm_byte_lookup_table_input_b, +in.avm_byte_lookup_table_output + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_byte_operations, - in.lookup_byte_operations_counts, - in.avm_binary_bin_sel, - in.avm_byte_lookup_bin_sel, - in.avm_binary_op_id, - in.avm_binary_ia_bytes, - in.avm_binary_ib_bytes, - in.avm_binary_ic_bytes, - in.avm_byte_lookup_table_op_id, - in.avm_byte_lookup_table_input_a, - in.avm_byte_lookup_table_input_b, - in.avm_byte_lookup_table_output); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_byte_operations, +in.lookup_byte_operations_counts, +in.avm_binary_bin_sel, +in.avm_byte_lookup_bin_sel, +in.avm_binary_op_id, +in.avm_binary_ia_bytes, +in.avm_binary_ib_bytes, +in.avm_binary_ic_bytes, +in.avm_byte_lookup_table_op_id, +in.avm_byte_lookup_table_input_a, +in.avm_byte_lookup_table_input_b, +in.avm_byte_lookup_table_output + ); + } -}; - -template -using lookup_byte_operations_relation = GenericLookupRelation; -template using lookup_byte_operations = GenericLookup; + + }; -} // namespace bb + + template using lookup_byte_operations_relation = GenericLookupRelation; + template using lookup_byte_operations = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_0.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_0.hpp index 67284e42972..326c9d0d379 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_0.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_0.hpp @@ -1,166 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_div_u16_0_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_div_u16_0_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_alu_div_rng_chk_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_div_rng_chk_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_div_u16_0, - in.lookup_div_u16_0_counts, - in.avm_alu_div_rng_chk_selector, - in.avm_main_sel_rng_16, - in.avm_alu_div_u16_r0, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_div_u16_0, +in.lookup_div_u16_0_counts, +in.avm_alu_div_rng_chk_selector, +in.avm_main_sel_rng_16, +in.avm_alu_div_u16_r0, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_div_u16_0, - in.lookup_div_u16_0_counts, - in.avm_alu_div_rng_chk_selector, - in.avm_main_sel_rng_16, - in.avm_alu_div_u16_r0, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_div_u16_0, +in.lookup_div_u16_0_counts, +in.avm_alu_div_rng_chk_selector, +in.avm_main_sel_rng_16, +in.avm_alu_div_u16_r0, +in.avm_main_clk + ); + } -}; - -template using lookup_div_u16_0_relation = GenericLookupRelation; -template using lookup_div_u16_0 = GenericLookup; + + }; -} // namespace bb + + template using lookup_div_u16_0_relation = GenericLookupRelation; + template using lookup_div_u16_0 = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_1.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_1.hpp index 38c6fd614f8..39ccf37124a 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_1.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_1.hpp @@ -1,166 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_div_u16_1_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_div_u16_1_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_alu_div_rng_chk_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_div_rng_chk_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_div_u16_1, - in.lookup_div_u16_1_counts, - in.avm_alu_div_rng_chk_selector, - in.avm_main_sel_rng_16, - in.avm_alu_div_u16_r1, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_div_u16_1, +in.lookup_div_u16_1_counts, +in.avm_alu_div_rng_chk_selector, +in.avm_main_sel_rng_16, +in.avm_alu_div_u16_r1, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_div_u16_1, - in.lookup_div_u16_1_counts, - in.avm_alu_div_rng_chk_selector, - in.avm_main_sel_rng_16, - in.avm_alu_div_u16_r1, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_div_u16_1, +in.lookup_div_u16_1_counts, +in.avm_alu_div_rng_chk_selector, +in.avm_main_sel_rng_16, +in.avm_alu_div_u16_r1, +in.avm_main_clk + ); + } -}; - -template using lookup_div_u16_1_relation = GenericLookupRelation; -template using lookup_div_u16_1 = GenericLookup; + + }; -} // namespace bb + + template using lookup_div_u16_1_relation = GenericLookupRelation; + template using lookup_div_u16_1 = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_2.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_2.hpp index 36c347a5ba9..bc389c085d9 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_2.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_2.hpp @@ -1,166 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_div_u16_2_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_div_u16_2_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_alu_div_rng_chk_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_div_rng_chk_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_div_u16_2, - in.lookup_div_u16_2_counts, - in.avm_alu_div_rng_chk_selector, - in.avm_main_sel_rng_16, - in.avm_alu_div_u16_r2, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_div_u16_2, +in.lookup_div_u16_2_counts, +in.avm_alu_div_rng_chk_selector, +in.avm_main_sel_rng_16, +in.avm_alu_div_u16_r2, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_div_u16_2, - in.lookup_div_u16_2_counts, - in.avm_alu_div_rng_chk_selector, - in.avm_main_sel_rng_16, - in.avm_alu_div_u16_r2, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_div_u16_2, +in.lookup_div_u16_2_counts, +in.avm_alu_div_rng_chk_selector, +in.avm_main_sel_rng_16, +in.avm_alu_div_u16_r2, +in.avm_main_clk + ); + } -}; - -template using lookup_div_u16_2_relation = GenericLookupRelation; -template using lookup_div_u16_2 = GenericLookup; + + }; -} // namespace bb + + template using lookup_div_u16_2_relation = GenericLookupRelation; + template using lookup_div_u16_2 = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_3.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_3.hpp index e167bae69bb..fc7aa8e0d6b 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_3.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_3.hpp @@ -1,166 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_div_u16_3_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_div_u16_3_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_alu_div_rng_chk_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_div_rng_chk_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_div_u16_3, - in.lookup_div_u16_3_counts, - in.avm_alu_div_rng_chk_selector, - in.avm_main_sel_rng_16, - in.avm_alu_div_u16_r3, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_div_u16_3, +in.lookup_div_u16_3_counts, +in.avm_alu_div_rng_chk_selector, +in.avm_main_sel_rng_16, +in.avm_alu_div_u16_r3, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_div_u16_3, - in.lookup_div_u16_3_counts, - in.avm_alu_div_rng_chk_selector, - in.avm_main_sel_rng_16, - in.avm_alu_div_u16_r3, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_div_u16_3, +in.lookup_div_u16_3_counts, +in.avm_alu_div_rng_chk_selector, +in.avm_main_sel_rng_16, +in.avm_alu_div_u16_r3, +in.avm_main_clk + ); + } -}; - -template using lookup_div_u16_3_relation = GenericLookupRelation; -template using lookup_div_u16_3 = GenericLookup; + + }; -} // namespace bb + + template using lookup_div_u16_3_relation = GenericLookupRelation; + template using lookup_div_u16_3 = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_4.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_4.hpp index 6248bc098d6..3082eaef986 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_4.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_4.hpp @@ -1,166 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_div_u16_4_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_div_u16_4_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_alu_div_rng_chk_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_div_rng_chk_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_div_u16_4, - in.lookup_div_u16_4_counts, - in.avm_alu_div_rng_chk_selector, - in.avm_main_sel_rng_16, - in.avm_alu_div_u16_r4, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_div_u16_4, +in.lookup_div_u16_4_counts, +in.avm_alu_div_rng_chk_selector, +in.avm_main_sel_rng_16, +in.avm_alu_div_u16_r4, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_div_u16_4, - in.lookup_div_u16_4_counts, - in.avm_alu_div_rng_chk_selector, - in.avm_main_sel_rng_16, - in.avm_alu_div_u16_r4, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_div_u16_4, +in.lookup_div_u16_4_counts, +in.avm_alu_div_rng_chk_selector, +in.avm_main_sel_rng_16, +in.avm_alu_div_u16_r4, +in.avm_main_clk + ); + } -}; - -template using lookup_div_u16_4_relation = GenericLookupRelation; -template using lookup_div_u16_4 = GenericLookup; + + }; -} // namespace bb + + template using lookup_div_u16_4_relation = GenericLookupRelation; + template using lookup_div_u16_4 = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_5.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_5.hpp index 052eafcaa3b..e86b9b94a32 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_5.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_5.hpp @@ -1,166 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_div_u16_5_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_div_u16_5_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_alu_div_rng_chk_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_div_rng_chk_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_div_u16_5, - in.lookup_div_u16_5_counts, - in.avm_alu_div_rng_chk_selector, - in.avm_main_sel_rng_16, - in.avm_alu_div_u16_r5, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_div_u16_5, +in.lookup_div_u16_5_counts, +in.avm_alu_div_rng_chk_selector, +in.avm_main_sel_rng_16, +in.avm_alu_div_u16_r5, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_div_u16_5, - in.lookup_div_u16_5_counts, - in.avm_alu_div_rng_chk_selector, - in.avm_main_sel_rng_16, - in.avm_alu_div_u16_r5, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_div_u16_5, +in.lookup_div_u16_5_counts, +in.avm_alu_div_rng_chk_selector, +in.avm_main_sel_rng_16, +in.avm_alu_div_u16_r5, +in.avm_main_clk + ); + } -}; - -template using lookup_div_u16_5_relation = GenericLookupRelation; -template using lookup_div_u16_5 = GenericLookup; + + }; -} // namespace bb + + template using lookup_div_u16_5_relation = GenericLookupRelation; + template using lookup_div_u16_5 = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_6.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_6.hpp index c52d71bdb99..d1dee82d616 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_6.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_6.hpp @@ -1,166 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_div_u16_6_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_div_u16_6_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_alu_div_rng_chk_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_div_rng_chk_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_div_u16_6, - in.lookup_div_u16_6_counts, - in.avm_alu_div_rng_chk_selector, - in.avm_main_sel_rng_16, - in.avm_alu_div_u16_r6, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_div_u16_6, +in.lookup_div_u16_6_counts, +in.avm_alu_div_rng_chk_selector, +in.avm_main_sel_rng_16, +in.avm_alu_div_u16_r6, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_div_u16_6, - in.lookup_div_u16_6_counts, - in.avm_alu_div_rng_chk_selector, - in.avm_main_sel_rng_16, - in.avm_alu_div_u16_r6, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_div_u16_6, +in.lookup_div_u16_6_counts, +in.avm_alu_div_rng_chk_selector, +in.avm_main_sel_rng_16, +in.avm_alu_div_u16_r6, +in.avm_main_clk + ); + } -}; - -template using lookup_div_u16_6_relation = GenericLookupRelation; -template using lookup_div_u16_6 = GenericLookup; + + }; -} // namespace bb + + template using lookup_div_u16_6_relation = GenericLookupRelation; + template using lookup_div_u16_6 = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_7.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_7.hpp index dde1e6f54b4..61e0bc705f2 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_7.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_7.hpp @@ -1,166 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_div_u16_7_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_div_u16_7_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_alu_div_rng_chk_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_div_rng_chk_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_div_u16_7, - in.lookup_div_u16_7_counts, - in.avm_alu_div_rng_chk_selector, - in.avm_main_sel_rng_16, - in.avm_alu_div_u16_r7, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_div_u16_7, +in.lookup_div_u16_7_counts, +in.avm_alu_div_rng_chk_selector, +in.avm_main_sel_rng_16, +in.avm_alu_div_u16_r7, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_div_u16_7, - in.lookup_div_u16_7_counts, - in.avm_alu_div_rng_chk_selector, - in.avm_main_sel_rng_16, - in.avm_alu_div_u16_r7, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_div_u16_7, +in.lookup_div_u16_7_counts, +in.avm_alu_div_rng_chk_selector, +in.avm_main_sel_rng_16, +in.avm_alu_div_u16_r7, +in.avm_main_clk + ); + } -}; - -template using lookup_div_u16_7_relation = GenericLookupRelation; -template using lookup_div_u16_7 = GenericLookup; + + }; -} // namespace bb + + template using lookup_div_u16_7_relation = GenericLookupRelation; + template using lookup_div_u16_7 = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_into_kernel.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_into_kernel.hpp index 8ece5f016e7..9fc1f2f47ef 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_into_kernel.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_into_kernel.hpp @@ -1,171 +1,176 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_into_kernel_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 2; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_into_kernel_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 2; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_main_q_kernel_lookup == 1 || in.avm_kernel_q_public_input_kernel_add_to_table == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_main_q_kernel_lookup); const auto is_table_entry = View(in.avm_kernel_q_public_input_kernel_add_to_table); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_into_kernel, - in.lookup_into_kernel_counts, - in.avm_main_q_kernel_lookup, - in.avm_kernel_q_public_input_kernel_add_to_table, - in.avm_main_ia, - in.avm_kernel_kernel_in_offset, - in.avm_kernel_kernel_inputs__is_public, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_into_kernel, +in.lookup_into_kernel_counts, +in.avm_main_q_kernel_lookup, +in.avm_kernel_q_public_input_kernel_add_to_table, +in.avm_main_ia, +in.avm_kernel_kernel_in_offset, +in.avm_kernel_kernel_inputs__is_public, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_into_kernel, - in.lookup_into_kernel_counts, - in.avm_main_q_kernel_lookup, - in.avm_kernel_q_public_input_kernel_add_to_table, - in.avm_main_ia, - in.avm_kernel_kernel_in_offset, - in.avm_kernel_kernel_inputs__is_public, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_into_kernel, +in.lookup_into_kernel_counts, +in.avm_main_q_kernel_lookup, +in.avm_kernel_q_public_input_kernel_add_to_table, +in.avm_main_ia, +in.avm_kernel_kernel_in_offset, +in.avm_kernel_kernel_inputs__is_public, +in.avm_main_clk + ); + } -}; - -template -using lookup_into_kernel_relation = GenericLookupRelation; -template using lookup_into_kernel = GenericLookup; + + }; -} // namespace bb + + template using lookup_into_kernel_relation = GenericLookupRelation; + template using lookup_into_kernel = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_mem_rng_chk_hi.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_mem_rng_chk_hi.hpp index d982ee18fc0..3a58825f58c 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_mem_rng_chk_hi.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_mem_rng_chk_hi.hpp @@ -1,167 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_mem_rng_chk_hi_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_mem_rng_chk_hi_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_mem_rng_chk_sel == 1 || in.avm_main_sel_rng_8 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_mem_rng_chk_sel); const auto is_table_entry = View(in.avm_main_sel_rng_8); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_mem_rng_chk_hi, - in.lookup_mem_rng_chk_hi_counts, - in.avm_mem_rng_chk_sel, - in.avm_main_sel_rng_8, - in.avm_mem_diff_hi, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_mem_rng_chk_hi, +in.lookup_mem_rng_chk_hi_counts, +in.avm_mem_rng_chk_sel, +in.avm_main_sel_rng_8, +in.avm_mem_diff_hi, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_mem_rng_chk_hi, - in.lookup_mem_rng_chk_hi_counts, - in.avm_mem_rng_chk_sel, - in.avm_main_sel_rng_8, - in.avm_mem_diff_hi, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_mem_rng_chk_hi, +in.lookup_mem_rng_chk_hi_counts, +in.avm_mem_rng_chk_sel, +in.avm_main_sel_rng_8, +in.avm_mem_diff_hi, +in.avm_main_clk + ); + } -}; - -template -using lookup_mem_rng_chk_hi_relation = GenericLookupRelation; -template using lookup_mem_rng_chk_hi = GenericLookup; + + }; -} // namespace bb + + template using lookup_mem_rng_chk_hi_relation = GenericLookupRelation; + template using lookup_mem_rng_chk_hi = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_mem_rng_chk_lo.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_mem_rng_chk_lo.hpp index d59ef829c2d..9d0bc3fc524 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_mem_rng_chk_lo.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_mem_rng_chk_lo.hpp @@ -1,167 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_mem_rng_chk_lo_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_mem_rng_chk_lo_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_mem_rng_chk_sel == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_mem_rng_chk_sel); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_mem_rng_chk_lo, - in.lookup_mem_rng_chk_lo_counts, - in.avm_mem_rng_chk_sel, - in.avm_main_sel_rng_16, - in.avm_mem_diff_lo, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_mem_rng_chk_lo, +in.lookup_mem_rng_chk_lo_counts, +in.avm_mem_rng_chk_sel, +in.avm_main_sel_rng_16, +in.avm_mem_diff_lo, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_mem_rng_chk_lo, - in.lookup_mem_rng_chk_lo_counts, - in.avm_mem_rng_chk_sel, - in.avm_main_sel_rng_16, - in.avm_mem_diff_lo, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_mem_rng_chk_lo, +in.lookup_mem_rng_chk_lo_counts, +in.avm_mem_rng_chk_sel, +in.avm_main_sel_rng_16, +in.avm_mem_diff_lo, +in.avm_main_clk + ); + } -}; - -template -using lookup_mem_rng_chk_lo_relation = GenericLookupRelation; -template using lookup_mem_rng_chk_lo = GenericLookup; + + }; -} // namespace bb + + template using lookup_mem_rng_chk_lo_relation = GenericLookupRelation; + template using lookup_mem_rng_chk_lo = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_mem_rng_chk_mid.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_mem_rng_chk_mid.hpp index bece75f6f1a..cf20abf3493 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_mem_rng_chk_mid.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_mem_rng_chk_mid.hpp @@ -1,167 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_mem_rng_chk_mid_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_mem_rng_chk_mid_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_mem_rng_chk_sel == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_mem_rng_chk_sel); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_mem_rng_chk_mid, - in.lookup_mem_rng_chk_mid_counts, - in.avm_mem_rng_chk_sel, - in.avm_main_sel_rng_16, - in.avm_mem_diff_mid, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_mem_rng_chk_mid, +in.lookup_mem_rng_chk_mid_counts, +in.avm_mem_rng_chk_sel, +in.avm_main_sel_rng_16, +in.avm_mem_diff_mid, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_mem_rng_chk_mid, - in.lookup_mem_rng_chk_mid_counts, - in.avm_mem_rng_chk_sel, - in.avm_main_sel_rng_16, - in.avm_mem_diff_mid, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_mem_rng_chk_mid, +in.lookup_mem_rng_chk_mid_counts, +in.avm_mem_rng_chk_sel, +in.avm_main_sel_rng_16, +in.avm_mem_diff_mid, +in.avm_main_clk + ); + } -}; - -template -using lookup_mem_rng_chk_mid_relation = GenericLookupRelation; -template using lookup_mem_rng_chk_mid = GenericLookup; + + }; -} // namespace bb + + template using lookup_mem_rng_chk_mid_relation = GenericLookupRelation; + template using lookup_mem_rng_chk_mid = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_opcode_gas.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_opcode_gas.hpp index fec6ee9753d..c113338ceee 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_opcode_gas.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_opcode_gas.hpp @@ -1,175 +1,180 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_opcode_gas_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 3; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_opcode_gas_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 3; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_main_gas_cost_active == 1 || in.avm_gas_gas_cost_sel == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_main_gas_cost_active); const auto is_table_entry = View(in.avm_gas_gas_cost_sel); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_opcode_gas, - in.lookup_opcode_gas_counts, - in.avm_main_gas_cost_active, - in.avm_gas_gas_cost_sel, - in.avm_main_opcode_val, - in.avm_main_l2_gas_op, - in.avm_main_da_gas_op, - in.avm_main_clk, - in.avm_gas_l2_gas_fixed_table, - in.avm_gas_da_gas_fixed_table); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_opcode_gas, +in.lookup_opcode_gas_counts, +in.avm_main_gas_cost_active, +in.avm_gas_gas_cost_sel, +in.avm_main_opcode_val, +in.avm_main_l2_gas_op, +in.avm_main_da_gas_op, +in.avm_main_clk, +in.avm_gas_l2_gas_fixed_table, +in.avm_gas_da_gas_fixed_table + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_opcode_gas, - in.lookup_opcode_gas_counts, - in.avm_main_gas_cost_active, - in.avm_gas_gas_cost_sel, - in.avm_main_opcode_val, - in.avm_main_l2_gas_op, - in.avm_main_da_gas_op, - in.avm_main_clk, - in.avm_gas_l2_gas_fixed_table, - in.avm_gas_da_gas_fixed_table); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_opcode_gas, +in.lookup_opcode_gas_counts, +in.avm_main_gas_cost_active, +in.avm_gas_gas_cost_sel, +in.avm_main_opcode_val, +in.avm_main_l2_gas_op, +in.avm_main_da_gas_op, +in.avm_main_clk, +in.avm_gas_l2_gas_fixed_table, +in.avm_gas_da_gas_fixed_table + ); + } -}; - -template -using lookup_opcode_gas_relation = GenericLookupRelation; -template using lookup_opcode_gas = GenericLookup; + + }; -} // namespace bb + + template using lookup_opcode_gas_relation = GenericLookupRelation; + template using lookup_opcode_gas = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_pow_2_0.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_pow_2_0.hpp index a4629615a75..41b126f32ab 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_pow_2_0.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_pow_2_0.hpp @@ -1,170 +1,176 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_pow_2_0_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 2; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_pow_2_0_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 2; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_alu_shift_sel == 1 || in.avm_main_sel_rng_8 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_shift_sel); const auto is_table_entry = View(in.avm_main_sel_rng_8); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_pow_2_0, - in.lookup_pow_2_0_counts, - in.avm_alu_shift_sel, - in.avm_main_sel_rng_8, - in.avm_alu_ib, - in.avm_alu_two_pow_s, - in.avm_main_clk, - in.avm_main_table_pow_2); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_pow_2_0, +in.lookup_pow_2_0_counts, +in.avm_alu_shift_sel, +in.avm_main_sel_rng_8, +in.avm_alu_ib, +in.avm_alu_two_pow_s, +in.avm_main_clk, +in.avm_main_table_pow_2 + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_pow_2_0, - in.lookup_pow_2_0_counts, - in.avm_alu_shift_sel, - in.avm_main_sel_rng_8, - in.avm_alu_ib, - in.avm_alu_two_pow_s, - in.avm_main_clk, - in.avm_main_table_pow_2); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_pow_2_0, +in.lookup_pow_2_0_counts, +in.avm_alu_shift_sel, +in.avm_main_sel_rng_8, +in.avm_alu_ib, +in.avm_alu_two_pow_s, +in.avm_main_clk, +in.avm_main_table_pow_2 + ); + } -}; - -template using lookup_pow_2_0_relation = GenericLookupRelation; -template using lookup_pow_2_0 = GenericLookup; + + }; -} // namespace bb + + template using lookup_pow_2_0_relation = GenericLookupRelation; + template using lookup_pow_2_0 = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_pow_2_1.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_pow_2_1.hpp index e1e7284056e..c1aca450ed1 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_pow_2_1.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_pow_2_1.hpp @@ -1,170 +1,176 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_pow_2_1_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 2; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_pow_2_1_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 2; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_alu_shift_sel == 1 || in.avm_main_sel_rng_8 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_shift_sel); const auto is_table_entry = View(in.avm_main_sel_rng_8); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_pow_2_1, - in.lookup_pow_2_1_counts, - in.avm_alu_shift_sel, - in.avm_main_sel_rng_8, - in.avm_alu_t_sub_s_bits, - in.avm_alu_two_pow_t_sub_s, - in.avm_main_clk, - in.avm_main_table_pow_2); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_pow_2_1, +in.lookup_pow_2_1_counts, +in.avm_alu_shift_sel, +in.avm_main_sel_rng_8, +in.avm_alu_t_sub_s_bits, +in.avm_alu_two_pow_t_sub_s, +in.avm_main_clk, +in.avm_main_table_pow_2 + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_pow_2_1, - in.lookup_pow_2_1_counts, - in.avm_alu_shift_sel, - in.avm_main_sel_rng_8, - in.avm_alu_t_sub_s_bits, - in.avm_alu_two_pow_t_sub_s, - in.avm_main_clk, - in.avm_main_table_pow_2); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_pow_2_1, +in.lookup_pow_2_1_counts, +in.avm_alu_shift_sel, +in.avm_main_sel_rng_8, +in.avm_alu_t_sub_s_bits, +in.avm_alu_two_pow_t_sub_s, +in.avm_main_clk, +in.avm_main_table_pow_2 + ); + } -}; - -template using lookup_pow_2_1_relation = GenericLookupRelation; -template using lookup_pow_2_1 = GenericLookup; + + }; -} // namespace bb + + template using lookup_pow_2_1_relation = GenericLookupRelation; + template using lookup_pow_2_1 = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_0.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_0.hpp index 67c79053609..88fe289a098 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_0.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_0.hpp @@ -1,166 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_u16_0_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_u16_0_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_0, - in.lookup_u16_0_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r0, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_0, +in.lookup_u16_0_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r0, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_0, - in.lookup_u16_0_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r0, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_0, +in.lookup_u16_0_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r0, +in.avm_main_clk + ); + } -}; - -template using lookup_u16_0_relation = GenericLookupRelation; -template using lookup_u16_0 = GenericLookup; + + }; -} // namespace bb + + template using lookup_u16_0_relation = GenericLookupRelation; + template using lookup_u16_0 = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_1.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_1.hpp index c5c39dd2f80..b78029d9003 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_1.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_1.hpp @@ -1,166 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_u16_1_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_u16_1_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_1, - in.lookup_u16_1_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r1, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_1, +in.lookup_u16_1_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r1, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_1, - in.lookup_u16_1_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r1, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_1, +in.lookup_u16_1_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r1, +in.avm_main_clk + ); + } -}; - -template using lookup_u16_1_relation = GenericLookupRelation; -template using lookup_u16_1 = GenericLookup; + + }; -} // namespace bb + + template using lookup_u16_1_relation = GenericLookupRelation; + template using lookup_u16_1 = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_10.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_10.hpp index 275dcb0f824..1f67f41a02d 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_10.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_10.hpp @@ -1,166 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_u16_10_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_u16_10_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_10, - in.lookup_u16_10_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r10, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_10, +in.lookup_u16_10_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r10, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_10, - in.lookup_u16_10_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r10, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_10, +in.lookup_u16_10_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r10, +in.avm_main_clk + ); + } -}; - -template using lookup_u16_10_relation = GenericLookupRelation; -template using lookup_u16_10 = GenericLookup; + + }; -} // namespace bb + + template using lookup_u16_10_relation = GenericLookupRelation; + template using lookup_u16_10 = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_11.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_11.hpp index b94a5f65d84..f98a686b914 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_11.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_11.hpp @@ -1,166 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_u16_11_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_u16_11_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_11, - in.lookup_u16_11_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r11, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_11, +in.lookup_u16_11_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r11, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_11, - in.lookup_u16_11_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r11, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_11, +in.lookup_u16_11_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r11, +in.avm_main_clk + ); + } -}; - -template using lookup_u16_11_relation = GenericLookupRelation; -template using lookup_u16_11 = GenericLookup; + + }; -} // namespace bb + + template using lookup_u16_11_relation = GenericLookupRelation; + template using lookup_u16_11 = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_12.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_12.hpp index 4fc5cca4ebe..6aadbd421e9 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_12.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_12.hpp @@ -1,166 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_u16_12_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_u16_12_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_12, - in.lookup_u16_12_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r12, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_12, +in.lookup_u16_12_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r12, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_12, - in.lookup_u16_12_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r12, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_12, +in.lookup_u16_12_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r12, +in.avm_main_clk + ); + } -}; - -template using lookup_u16_12_relation = GenericLookupRelation; -template using lookup_u16_12 = GenericLookup; + + }; -} // namespace bb + + template using lookup_u16_12_relation = GenericLookupRelation; + template using lookup_u16_12 = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_13.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_13.hpp index 908d478b8ad..ff3af5c9592 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_13.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_13.hpp @@ -1,166 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_u16_13_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_u16_13_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_13, - in.lookup_u16_13_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r13, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_13, +in.lookup_u16_13_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r13, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_13, - in.lookup_u16_13_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r13, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_13, +in.lookup_u16_13_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r13, +in.avm_main_clk + ); + } -}; - -template using lookup_u16_13_relation = GenericLookupRelation; -template using lookup_u16_13 = GenericLookup; + + }; -} // namespace bb + + template using lookup_u16_13_relation = GenericLookupRelation; + template using lookup_u16_13 = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_14.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_14.hpp index 735361f8e6c..92dc0c2c84e 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_14.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_14.hpp @@ -1,166 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_u16_14_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_u16_14_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_14, - in.lookup_u16_14_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r14, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_14, +in.lookup_u16_14_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r14, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_14, - in.lookup_u16_14_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r14, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_14, +in.lookup_u16_14_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r14, +in.avm_main_clk + ); + } -}; - -template using lookup_u16_14_relation = GenericLookupRelation; -template using lookup_u16_14 = GenericLookup; + + }; -} // namespace bb + + template using lookup_u16_14_relation = GenericLookupRelation; + template using lookup_u16_14 = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_2.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_2.hpp index 8aa66dc7a70..7a40a19fc2e 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_2.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_2.hpp @@ -1,166 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_u16_2_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_u16_2_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_2, - in.lookup_u16_2_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r2, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_2, +in.lookup_u16_2_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r2, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_2, - in.lookup_u16_2_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r2, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_2, +in.lookup_u16_2_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r2, +in.avm_main_clk + ); + } -}; - -template using lookup_u16_2_relation = GenericLookupRelation; -template using lookup_u16_2 = GenericLookup; + + }; -} // namespace bb + + template using lookup_u16_2_relation = GenericLookupRelation; + template using lookup_u16_2 = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_3.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_3.hpp index b1bda551024..2519e05a478 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_3.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_3.hpp @@ -1,166 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_u16_3_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_u16_3_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_3, - in.lookup_u16_3_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r3, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_3, +in.lookup_u16_3_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r3, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_3, - in.lookup_u16_3_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r3, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_3, +in.lookup_u16_3_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r3, +in.avm_main_clk + ); + } -}; - -template using lookup_u16_3_relation = GenericLookupRelation; -template using lookup_u16_3 = GenericLookup; + + }; -} // namespace bb + + template using lookup_u16_3_relation = GenericLookupRelation; + template using lookup_u16_3 = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_4.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_4.hpp index 5984e1a6e59..caf45234db0 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_4.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_4.hpp @@ -1,166 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_u16_4_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_u16_4_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_4, - in.lookup_u16_4_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r4, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_4, +in.lookup_u16_4_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r4, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_4, - in.lookup_u16_4_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r4, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_4, +in.lookup_u16_4_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r4, +in.avm_main_clk + ); + } -}; - -template using lookup_u16_4_relation = GenericLookupRelation; -template using lookup_u16_4 = GenericLookup; + + }; -} // namespace bb + + template using lookup_u16_4_relation = GenericLookupRelation; + template using lookup_u16_4 = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_5.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_5.hpp index d1bc6db3a29..effff724035 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_5.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_5.hpp @@ -1,166 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_u16_5_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_u16_5_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_5, - in.lookup_u16_5_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r5, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_5, +in.lookup_u16_5_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r5, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_5, - in.lookup_u16_5_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r5, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_5, +in.lookup_u16_5_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r5, +in.avm_main_clk + ); + } -}; - -template using lookup_u16_5_relation = GenericLookupRelation; -template using lookup_u16_5 = GenericLookup; + + }; -} // namespace bb + + template using lookup_u16_5_relation = GenericLookupRelation; + template using lookup_u16_5 = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_6.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_6.hpp index 3838f21e967..5d90864905f 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_6.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_6.hpp @@ -1,166 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_u16_6_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_u16_6_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_6, - in.lookup_u16_6_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r6, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_6, +in.lookup_u16_6_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r6, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_6, - in.lookup_u16_6_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r6, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_6, +in.lookup_u16_6_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r6, +in.avm_main_clk + ); + } -}; - -template using lookup_u16_6_relation = GenericLookupRelation; -template using lookup_u16_6 = GenericLookup; + + }; -} // namespace bb + + template using lookup_u16_6_relation = GenericLookupRelation; + template using lookup_u16_6 = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_7.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_7.hpp index 84b098172e9..57e012a9fc8 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_7.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_7.hpp @@ -1,166 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_u16_7_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_u16_7_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_7, - in.lookup_u16_7_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r7, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_7, +in.lookup_u16_7_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r7, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_7, - in.lookup_u16_7_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r7, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_7, +in.lookup_u16_7_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r7, +in.avm_main_clk + ); + } -}; - -template using lookup_u16_7_relation = GenericLookupRelation; -template using lookup_u16_7 = GenericLookup; + + }; -} // namespace bb + + template using lookup_u16_7_relation = GenericLookupRelation; + template using lookup_u16_7 = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_8.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_8.hpp index f75f9fa9c28..89a39d1b16e 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_8.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_8.hpp @@ -1,166 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_u16_8_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_u16_8_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_8, - in.lookup_u16_8_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r8, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_8, +in.lookup_u16_8_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r8, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_8, - in.lookup_u16_8_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r8, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_8, +in.lookup_u16_8_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r8, +in.avm_main_clk + ); + } -}; - -template using lookup_u16_8_relation = GenericLookupRelation; -template using lookup_u16_8 = GenericLookup; + + }; -} // namespace bb + + template using lookup_u16_8_relation = GenericLookupRelation; + template using lookup_u16_8 = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_9.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_9.hpp index 5e72a369ac4..6c1e6fc86aa 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_9.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_9.hpp @@ -1,166 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_u16_9_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_u16_9_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_9, - in.lookup_u16_9_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r9, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_9, +in.lookup_u16_9_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r9, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u16_9, - in.lookup_u16_9_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_16, - in.avm_alu_u16_r9, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u16_9, +in.lookup_u16_9_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_16, +in.avm_alu_u16_r9, +in.avm_main_clk + ); + } -}; - -template using lookup_u16_9_relation = GenericLookupRelation; -template using lookup_u16_9 = GenericLookup; + + }; -} // namespace bb + + template using lookup_u16_9_relation = GenericLookupRelation; + template using lookup_u16_9 = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_0.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_0.hpp index 37b5936f008..4ab9eda3c0e 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_0.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_0.hpp @@ -1,166 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_u8_0_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_u8_0_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_8 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_8); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u8_0, - in.lookup_u8_0_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_8, - in.avm_alu_u8_r0, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u8_0, +in.lookup_u8_0_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_8, +in.avm_alu_u8_r0, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u8_0, - in.lookup_u8_0_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_8, - in.avm_alu_u8_r0, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u8_0, +in.lookup_u8_0_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_8, +in.avm_alu_u8_r0, +in.avm_main_clk + ); + } -}; - -template using lookup_u8_0_relation = GenericLookupRelation; -template using lookup_u8_0 = GenericLookup; + + }; -} // namespace bb + + template using lookup_u8_0_relation = GenericLookupRelation; + template using lookup_u8_0 = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_1.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_1.hpp index 7941ecb1aee..6ffac9227bf 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_1.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_1.hpp @@ -1,166 +1,172 @@ - -#pragma once - -#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - -#include -#include - -namespace bb { - -/** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ -class lookup_u8_1_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + + #include + #include + + + namespace bb { + + /** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ + class lookup_u8_1_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_8 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template - static inline auto compute_inverse_exists(const AllEntities& in) - { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template static inline auto compute_inverse_exists(const AllEntities& in) { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_8); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u8_1, - in.lookup_u8_1_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_8, - in.avm_alu_u8_r1, - in.avm_main_clk); + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u8_1, +in.lookup_u8_1_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_8, +in.avm_alu_u8_r1, +in.avm_main_clk + ); + } - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.lookup_u8_1, - in.lookup_u8_1_counts, - in.avm_alu_rng_chk_lookup_selector, - in.avm_main_sel_rng_8, - in.avm_alu_u8_r1, - in.avm_main_clk); + + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.lookup_u8_1, +in.lookup_u8_1_counts, +in.avm_alu_rng_chk_lookup_selector, +in.avm_main_sel_rng_8, +in.avm_alu_u8_r1, +in.avm_main_clk + ); + } -}; - -template using lookup_u8_1_relation = GenericLookupRelation; -template using lookup_u8_1 = GenericLookup; + + }; -} // namespace bb + + template using lookup_u8_1_relation = GenericLookupRelation; + template using lookup_u8_1 = GenericLookup; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_alu.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_alu.hpp index 83506a187ff..8fe374e3e42 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_alu.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_alu.hpp @@ -1,150 +1,157 @@ - -#pragma once - -#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" - -#include -#include - -namespace bb { - -class perm_main_alu_permutation_settings { - public: - // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 16; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the - * value needs to be set to zero. - * - * @details If this is true then permutation takes place in this row - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + + #include + #include + + + namespace bb { + + class perm_main_alu_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 16; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the + * value needs to be set to zero. + * + * @details If this is true then permutation takes place in this row + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_main_alu_sel == 1 || in.avm_alu_alu_sel == 1); } - - /** - * @brief Get all the entities for the permutation when we don't need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.perm_main_alu, - in.avm_main_alu_sel, - in.avm_main_alu_sel, - in.avm_alu_alu_sel, - in.avm_main_clk, - in.avm_main_ia, - in.avm_main_ib, - in.avm_main_ic, - in.avm_main_sel_op_add, - in.avm_main_sel_op_sub, - in.avm_main_sel_op_mul, - in.avm_main_sel_op_div, - in.avm_main_sel_op_eq, - in.avm_main_sel_op_not, - in.avm_main_sel_op_cast, - in.avm_main_sel_op_lt, - in.avm_main_sel_op_lte, - in.avm_main_sel_op_shr, - in.avm_main_sel_op_shl, - in.avm_main_alu_in_tag, - in.avm_alu_clk, - in.avm_alu_ia, - in.avm_alu_ib, - in.avm_alu_ic, - in.avm_alu_op_add, - in.avm_alu_op_sub, - in.avm_alu_op_mul, - in.avm_alu_op_div, - in.avm_alu_op_eq, - in.avm_alu_op_not, - in.avm_alu_op_cast, - in.avm_alu_op_lt, - in.avm_alu_op_lte, - in.avm_alu_op_shr, - in.avm_alu_op_shl, - in.avm_alu_in_tag); + + /** + * @brief Get all the entities for the permutation when we don't need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.perm_main_alu, +in.avm_main_alu_sel, +in.avm_main_alu_sel, +in.avm_alu_alu_sel, +in.avm_main_clk, +in.avm_main_ia, +in.avm_main_ib, +in.avm_main_ic, +in.avm_main_sel_op_add, +in.avm_main_sel_op_sub, +in.avm_main_sel_op_mul, +in.avm_main_sel_op_div, +in.avm_main_sel_op_eq, +in.avm_main_sel_op_not, +in.avm_main_sel_op_cast, +in.avm_main_sel_op_lt, +in.avm_main_sel_op_lte, +in.avm_main_sel_op_shr, +in.avm_main_sel_op_shl, +in.avm_main_alu_in_tag, +in.avm_alu_clk, +in.avm_alu_ia, +in.avm_alu_ib, +in.avm_alu_ic, +in.avm_alu_op_add, +in.avm_alu_op_sub, +in.avm_alu_op_mul, +in.avm_alu_op_div, +in.avm_alu_op_eq, +in.avm_alu_op_not, +in.avm_alu_op_cast, +in.avm_alu_op_lt, +in.avm_alu_op_lte, +in.avm_alu_op_shr, +in.avm_alu_op_shl, +in.avm_alu_in_tag + ); + } - - /** - * @brief Get all the entities for the permutation when need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.perm_main_alu, - in.avm_main_alu_sel, - in.avm_main_alu_sel, - in.avm_alu_alu_sel, - in.avm_main_clk, - in.avm_main_ia, - in.avm_main_ib, - in.avm_main_ic, - in.avm_main_sel_op_add, - in.avm_main_sel_op_sub, - in.avm_main_sel_op_mul, - in.avm_main_sel_op_div, - in.avm_main_sel_op_eq, - in.avm_main_sel_op_not, - in.avm_main_sel_op_cast, - in.avm_main_sel_op_lt, - in.avm_main_sel_op_lte, - in.avm_main_sel_op_shr, - in.avm_main_sel_op_shl, - in.avm_main_alu_in_tag, - in.avm_alu_clk, - in.avm_alu_ia, - in.avm_alu_ib, - in.avm_alu_ic, - in.avm_alu_op_add, - in.avm_alu_op_sub, - in.avm_alu_op_mul, - in.avm_alu_op_div, - in.avm_alu_op_eq, - in.avm_alu_op_not, - in.avm_alu_op_cast, - in.avm_alu_op_lt, - in.avm_alu_op_lte, - in.avm_alu_op_shr, - in.avm_alu_op_shl, - in.avm_alu_in_tag); + + + /** + * @brief Get all the entities for the permutation when need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.perm_main_alu, +in.avm_main_alu_sel, +in.avm_main_alu_sel, +in.avm_alu_alu_sel, +in.avm_main_clk, +in.avm_main_ia, +in.avm_main_ib, +in.avm_main_ic, +in.avm_main_sel_op_add, +in.avm_main_sel_op_sub, +in.avm_main_sel_op_mul, +in.avm_main_sel_op_div, +in.avm_main_sel_op_eq, +in.avm_main_sel_op_not, +in.avm_main_sel_op_cast, +in.avm_main_sel_op_lt, +in.avm_main_sel_op_lte, +in.avm_main_sel_op_shr, +in.avm_main_sel_op_shl, +in.avm_main_alu_in_tag, +in.avm_alu_clk, +in.avm_alu_ia, +in.avm_alu_ib, +in.avm_alu_ic, +in.avm_alu_op_add, +in.avm_alu_op_sub, +in.avm_alu_op_mul, +in.avm_alu_op_div, +in.avm_alu_op_eq, +in.avm_alu_op_not, +in.avm_alu_op_cast, +in.avm_alu_op_lt, +in.avm_alu_op_lte, +in.avm_alu_op_shr, +in.avm_alu_op_shl, +in.avm_alu_in_tag + ); + } -}; - -template -using perm_main_alu_relation = GenericPermutationRelation; -template using perm_main_alu = GenericPermutation; + + }; -} // namespace bb + + template using perm_main_alu_relation = GenericPermutationRelation; + template using perm_main_alu = GenericPermutation; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_bin.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_bin.hpp index 0e3533051d1..679685f9a1e 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_bin.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_bin.hpp @@ -1,110 +1,117 @@ - -#pragma once - -#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" - -#include -#include - -namespace bb { - -class perm_main_bin_permutation_settings { - public: - // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 6; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the - * value needs to be set to zero. - * - * @details If this is true then permutation takes place in this row - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + + #include + #include + + + namespace bb { + + class perm_main_bin_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 6; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the + * value needs to be set to zero. + * + * @details If this is true then permutation takes place in this row + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_main_bin_sel == 1 || in.avm_binary_start == 1); } - - /** - * @brief Get all the entities for the permutation when we don't need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.perm_main_bin, - in.avm_main_bin_sel, - in.avm_main_bin_sel, - in.avm_binary_start, - in.avm_main_clk, - in.avm_main_ia, - in.avm_main_ib, - in.avm_main_ic, - in.avm_main_bin_op_id, - in.avm_main_r_in_tag, - in.avm_binary_clk, - in.avm_binary_acc_ia, - in.avm_binary_acc_ib, - in.avm_binary_acc_ic, - in.avm_binary_op_id, - in.avm_binary_in_tag); + + /** + * @brief Get all the entities for the permutation when we don't need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.perm_main_bin, +in.avm_main_bin_sel, +in.avm_main_bin_sel, +in.avm_binary_start, +in.avm_main_clk, +in.avm_main_ia, +in.avm_main_ib, +in.avm_main_ic, +in.avm_main_bin_op_id, +in.avm_main_r_in_tag, +in.avm_binary_clk, +in.avm_binary_acc_ia, +in.avm_binary_acc_ib, +in.avm_binary_acc_ic, +in.avm_binary_op_id, +in.avm_binary_in_tag + ); + } - - /** - * @brief Get all the entities for the permutation when need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.perm_main_bin, - in.avm_main_bin_sel, - in.avm_main_bin_sel, - in.avm_binary_start, - in.avm_main_clk, - in.avm_main_ia, - in.avm_main_ib, - in.avm_main_ic, - in.avm_main_bin_op_id, - in.avm_main_r_in_tag, - in.avm_binary_clk, - in.avm_binary_acc_ia, - in.avm_binary_acc_ib, - in.avm_binary_acc_ic, - in.avm_binary_op_id, - in.avm_binary_in_tag); + + + /** + * @brief Get all the entities for the permutation when need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.perm_main_bin, +in.avm_main_bin_sel, +in.avm_main_bin_sel, +in.avm_binary_start, +in.avm_main_clk, +in.avm_main_ia, +in.avm_main_ib, +in.avm_main_ic, +in.avm_main_bin_op_id, +in.avm_main_r_in_tag, +in.avm_binary_clk, +in.avm_binary_acc_ia, +in.avm_binary_acc_ib, +in.avm_binary_acc_ic, +in.avm_binary_op_id, +in.avm_binary_in_tag + ); + } -}; - -template -using perm_main_bin_relation = GenericPermutationRelation; -template using perm_main_bin = GenericPermutation; + + }; -} // namespace bb + + template using perm_main_bin_relation = GenericPermutationRelation; + template using perm_main_bin = GenericPermutation; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_conv.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_conv.hpp index 2d7ac39f44e..aa702a5ec18 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_conv.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_conv.hpp @@ -1,102 +1,109 @@ - -#pragma once - -#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" - -#include -#include - -namespace bb { - -class perm_main_conv_permutation_settings { - public: - // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 4; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the - * value needs to be set to zero. - * - * @details If this is true then permutation takes place in this row - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + + #include + #include + + + namespace bb { + + class perm_main_conv_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 4; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the + * value needs to be set to zero. + * + * @details If this is true then permutation takes place in this row + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_main_sel_op_radix_le == 1 || in.avm_conversion_to_radix_le_sel == 1); } - - /** - * @brief Get all the entities for the permutation when we don't need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.perm_main_conv, - in.avm_main_sel_op_radix_le, - in.avm_main_sel_op_radix_le, - in.avm_conversion_to_radix_le_sel, - in.avm_main_clk, - in.avm_main_ia, - in.avm_main_ic, - in.avm_main_id, - in.avm_conversion_clk, - in.avm_conversion_input, - in.avm_conversion_radix, - in.avm_conversion_num_limbs); + + /** + * @brief Get all the entities for the permutation when we don't need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.perm_main_conv, +in.avm_main_sel_op_radix_le, +in.avm_main_sel_op_radix_le, +in.avm_conversion_to_radix_le_sel, +in.avm_main_clk, +in.avm_main_ia, +in.avm_main_ic, +in.avm_main_id, +in.avm_conversion_clk, +in.avm_conversion_input, +in.avm_conversion_radix, +in.avm_conversion_num_limbs + ); + } - - /** - * @brief Get all the entities for the permutation when need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.perm_main_conv, - in.avm_main_sel_op_radix_le, - in.avm_main_sel_op_radix_le, - in.avm_conversion_to_radix_le_sel, - in.avm_main_clk, - in.avm_main_ia, - in.avm_main_ic, - in.avm_main_id, - in.avm_conversion_clk, - in.avm_conversion_input, - in.avm_conversion_radix, - in.avm_conversion_num_limbs); + + + /** + * @brief Get all the entities for the permutation when need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.perm_main_conv, +in.avm_main_sel_op_radix_le, +in.avm_main_sel_op_radix_le, +in.avm_conversion_to_radix_le_sel, +in.avm_main_clk, +in.avm_main_ia, +in.avm_main_ic, +in.avm_main_id, +in.avm_conversion_clk, +in.avm_conversion_input, +in.avm_conversion_radix, +in.avm_conversion_num_limbs + ); + } -}; - -template -using perm_main_conv_relation = GenericPermutationRelation; -template using perm_main_conv = GenericPermutation; + + }; -} // namespace bb + + template using perm_main_conv_relation = GenericPermutationRelation; + template using perm_main_conv = GenericPermutation; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_a.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_a.hpp index d7647bcc463..eb6fb871229 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_a.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_a.hpp @@ -1,122 +1,129 @@ - -#pragma once - -#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" - -#include -#include - -namespace bb { - -class perm_main_mem_a_permutation_settings { - public: - // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 9; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the - * value needs to be set to zero. - * - * @details If this is true then permutation takes place in this row - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + + #include + #include + + + namespace bb { + + class perm_main_mem_a_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 9; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the + * value needs to be set to zero. + * + * @details If this is true then permutation takes place in this row + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_main_mem_op_a == 1 || in.avm_mem_op_a == 1); } - - /** - * @brief Get all the entities for the permutation when we don't need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.perm_main_mem_a, - in.avm_main_mem_op_a, - in.avm_main_mem_op_a, - in.avm_mem_op_a, - in.avm_main_clk, - in.avm_main_space_id, - in.avm_main_mem_idx_a, - in.avm_main_ia, - in.avm_main_rwa, - in.avm_main_r_in_tag, - in.avm_main_w_in_tag, - in.avm_main_sel_mov_a, - in.avm_main_sel_cmov, - in.avm_mem_clk, - in.avm_mem_space_id, - in.avm_mem_addr, - in.avm_mem_val, - in.avm_mem_rw, - in.avm_mem_r_in_tag, - in.avm_mem_w_in_tag, - in.avm_mem_sel_mov_a, - in.avm_mem_sel_cmov); + + /** + * @brief Get all the entities for the permutation when we don't need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.perm_main_mem_a, +in.avm_main_mem_op_a, +in.avm_main_mem_op_a, +in.avm_mem_op_a, +in.avm_main_clk, +in.avm_main_space_id, +in.avm_main_mem_idx_a, +in.avm_main_ia, +in.avm_main_rwa, +in.avm_main_r_in_tag, +in.avm_main_w_in_tag, +in.avm_main_sel_mov_a, +in.avm_main_sel_cmov, +in.avm_mem_clk, +in.avm_mem_space_id, +in.avm_mem_addr, +in.avm_mem_val, +in.avm_mem_rw, +in.avm_mem_r_in_tag, +in.avm_mem_w_in_tag, +in.avm_mem_sel_mov_a, +in.avm_mem_sel_cmov + ); + } - - /** - * @brief Get all the entities for the permutation when need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.perm_main_mem_a, - in.avm_main_mem_op_a, - in.avm_main_mem_op_a, - in.avm_mem_op_a, - in.avm_main_clk, - in.avm_main_space_id, - in.avm_main_mem_idx_a, - in.avm_main_ia, - in.avm_main_rwa, - in.avm_main_r_in_tag, - in.avm_main_w_in_tag, - in.avm_main_sel_mov_a, - in.avm_main_sel_cmov, - in.avm_mem_clk, - in.avm_mem_space_id, - in.avm_mem_addr, - in.avm_mem_val, - in.avm_mem_rw, - in.avm_mem_r_in_tag, - in.avm_mem_w_in_tag, - in.avm_mem_sel_mov_a, - in.avm_mem_sel_cmov); + + + /** + * @brief Get all the entities for the permutation when need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.perm_main_mem_a, +in.avm_main_mem_op_a, +in.avm_main_mem_op_a, +in.avm_mem_op_a, +in.avm_main_clk, +in.avm_main_space_id, +in.avm_main_mem_idx_a, +in.avm_main_ia, +in.avm_main_rwa, +in.avm_main_r_in_tag, +in.avm_main_w_in_tag, +in.avm_main_sel_mov_a, +in.avm_main_sel_cmov, +in.avm_mem_clk, +in.avm_mem_space_id, +in.avm_mem_addr, +in.avm_mem_val, +in.avm_mem_rw, +in.avm_mem_r_in_tag, +in.avm_mem_w_in_tag, +in.avm_mem_sel_mov_a, +in.avm_mem_sel_cmov + ); + } -}; - -template -using perm_main_mem_a_relation = GenericPermutationRelation; -template using perm_main_mem_a = GenericPermutation; + + }; -} // namespace bb + + template using perm_main_mem_a_relation = GenericPermutationRelation; + template using perm_main_mem_a = GenericPermutation; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_b.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_b.hpp index 7d873de8722..6192eecd8b0 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_b.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_b.hpp @@ -1,122 +1,129 @@ - -#pragma once - -#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" - -#include -#include - -namespace bb { - -class perm_main_mem_b_permutation_settings { - public: - // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 9; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the - * value needs to be set to zero. - * - * @details If this is true then permutation takes place in this row - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + + #include + #include + + + namespace bb { + + class perm_main_mem_b_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 9; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the + * value needs to be set to zero. + * + * @details If this is true then permutation takes place in this row + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_main_mem_op_b == 1 || in.avm_mem_op_b == 1); } - - /** - * @brief Get all the entities for the permutation when we don't need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.perm_main_mem_b, - in.avm_main_mem_op_b, - in.avm_main_mem_op_b, - in.avm_mem_op_b, - in.avm_main_clk, - in.avm_main_space_id, - in.avm_main_mem_idx_b, - in.avm_main_ib, - in.avm_main_rwb, - in.avm_main_r_in_tag, - in.avm_main_w_in_tag, - in.avm_main_sel_mov_b, - in.avm_main_sel_cmov, - in.avm_mem_clk, - in.avm_mem_space_id, - in.avm_mem_addr, - in.avm_mem_val, - in.avm_mem_rw, - in.avm_mem_r_in_tag, - in.avm_mem_w_in_tag, - in.avm_mem_sel_mov_b, - in.avm_mem_sel_cmov); + + /** + * @brief Get all the entities for the permutation when we don't need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.perm_main_mem_b, +in.avm_main_mem_op_b, +in.avm_main_mem_op_b, +in.avm_mem_op_b, +in.avm_main_clk, +in.avm_main_space_id, +in.avm_main_mem_idx_b, +in.avm_main_ib, +in.avm_main_rwb, +in.avm_main_r_in_tag, +in.avm_main_w_in_tag, +in.avm_main_sel_mov_b, +in.avm_main_sel_cmov, +in.avm_mem_clk, +in.avm_mem_space_id, +in.avm_mem_addr, +in.avm_mem_val, +in.avm_mem_rw, +in.avm_mem_r_in_tag, +in.avm_mem_w_in_tag, +in.avm_mem_sel_mov_b, +in.avm_mem_sel_cmov + ); + } - - /** - * @brief Get all the entities for the permutation when need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.perm_main_mem_b, - in.avm_main_mem_op_b, - in.avm_main_mem_op_b, - in.avm_mem_op_b, - in.avm_main_clk, - in.avm_main_space_id, - in.avm_main_mem_idx_b, - in.avm_main_ib, - in.avm_main_rwb, - in.avm_main_r_in_tag, - in.avm_main_w_in_tag, - in.avm_main_sel_mov_b, - in.avm_main_sel_cmov, - in.avm_mem_clk, - in.avm_mem_space_id, - in.avm_mem_addr, - in.avm_mem_val, - in.avm_mem_rw, - in.avm_mem_r_in_tag, - in.avm_mem_w_in_tag, - in.avm_mem_sel_mov_b, - in.avm_mem_sel_cmov); + + + /** + * @brief Get all the entities for the permutation when need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.perm_main_mem_b, +in.avm_main_mem_op_b, +in.avm_main_mem_op_b, +in.avm_mem_op_b, +in.avm_main_clk, +in.avm_main_space_id, +in.avm_main_mem_idx_b, +in.avm_main_ib, +in.avm_main_rwb, +in.avm_main_r_in_tag, +in.avm_main_w_in_tag, +in.avm_main_sel_mov_b, +in.avm_main_sel_cmov, +in.avm_mem_clk, +in.avm_mem_space_id, +in.avm_mem_addr, +in.avm_mem_val, +in.avm_mem_rw, +in.avm_mem_r_in_tag, +in.avm_mem_w_in_tag, +in.avm_mem_sel_mov_b, +in.avm_mem_sel_cmov + ); + } -}; - -template -using perm_main_mem_b_relation = GenericPermutationRelation; -template using perm_main_mem_b = GenericPermutation; + + }; -} // namespace bb + + template using perm_main_mem_b_relation = GenericPermutationRelation; + template using perm_main_mem_b = GenericPermutation; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_c.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_c.hpp index 64919b1ca3d..02629487ecd 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_c.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_c.hpp @@ -1,114 +1,121 @@ - -#pragma once - -#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" - -#include -#include - -namespace bb { - -class perm_main_mem_c_permutation_settings { - public: - // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 7; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the - * value needs to be set to zero. - * - * @details If this is true then permutation takes place in this row - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + + #include + #include + + + namespace bb { + + class perm_main_mem_c_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 7; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the + * value needs to be set to zero. + * + * @details If this is true then permutation takes place in this row + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_main_mem_op_c == 1 || in.avm_mem_op_c == 1); } - - /** - * @brief Get all the entities for the permutation when we don't need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.perm_main_mem_c, - in.avm_main_mem_op_c, - in.avm_main_mem_op_c, - in.avm_mem_op_c, - in.avm_main_clk, - in.avm_main_space_id, - in.avm_main_mem_idx_c, - in.avm_main_ic, - in.avm_main_rwc, - in.avm_main_r_in_tag, - in.avm_main_w_in_tag, - in.avm_mem_clk, - in.avm_mem_space_id, - in.avm_mem_addr, - in.avm_mem_val, - in.avm_mem_rw, - in.avm_mem_r_in_tag, - in.avm_mem_w_in_tag); + + /** + * @brief Get all the entities for the permutation when we don't need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.perm_main_mem_c, +in.avm_main_mem_op_c, +in.avm_main_mem_op_c, +in.avm_mem_op_c, +in.avm_main_clk, +in.avm_main_space_id, +in.avm_main_mem_idx_c, +in.avm_main_ic, +in.avm_main_rwc, +in.avm_main_r_in_tag, +in.avm_main_w_in_tag, +in.avm_mem_clk, +in.avm_mem_space_id, +in.avm_mem_addr, +in.avm_mem_val, +in.avm_mem_rw, +in.avm_mem_r_in_tag, +in.avm_mem_w_in_tag + ); + } - - /** - * @brief Get all the entities for the permutation when need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.perm_main_mem_c, - in.avm_main_mem_op_c, - in.avm_main_mem_op_c, - in.avm_mem_op_c, - in.avm_main_clk, - in.avm_main_space_id, - in.avm_main_mem_idx_c, - in.avm_main_ic, - in.avm_main_rwc, - in.avm_main_r_in_tag, - in.avm_main_w_in_tag, - in.avm_mem_clk, - in.avm_mem_space_id, - in.avm_mem_addr, - in.avm_mem_val, - in.avm_mem_rw, - in.avm_mem_r_in_tag, - in.avm_mem_w_in_tag); + + + /** + * @brief Get all the entities for the permutation when need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.perm_main_mem_c, +in.avm_main_mem_op_c, +in.avm_main_mem_op_c, +in.avm_mem_op_c, +in.avm_main_clk, +in.avm_main_space_id, +in.avm_main_mem_idx_c, +in.avm_main_ic, +in.avm_main_rwc, +in.avm_main_r_in_tag, +in.avm_main_w_in_tag, +in.avm_mem_clk, +in.avm_mem_space_id, +in.avm_mem_addr, +in.avm_mem_val, +in.avm_mem_rw, +in.avm_mem_r_in_tag, +in.avm_mem_w_in_tag + ); + } -}; - -template -using perm_main_mem_c_relation = GenericPermutationRelation; -template using perm_main_mem_c = GenericPermutation; + + }; -} // namespace bb + + template using perm_main_mem_c_relation = GenericPermutationRelation; + template using perm_main_mem_c = GenericPermutation; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_d.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_d.hpp index b6f64c60a27..9decb0a8658 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_d.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_d.hpp @@ -1,118 +1,125 @@ - -#pragma once - -#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" - -#include -#include - -namespace bb { - -class perm_main_mem_d_permutation_settings { - public: - // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 8; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the - * value needs to be set to zero. - * - * @details If this is true then permutation takes place in this row - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + + #include + #include + + + namespace bb { + + class perm_main_mem_d_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 8; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the + * value needs to be set to zero. + * + * @details If this is true then permutation takes place in this row + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_main_mem_op_d == 1 || in.avm_mem_op_d == 1); } - - /** - * @brief Get all the entities for the permutation when we don't need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.perm_main_mem_d, - in.avm_main_mem_op_d, - in.avm_main_mem_op_d, - in.avm_mem_op_d, - in.avm_main_clk, - in.avm_main_space_id, - in.avm_main_mem_idx_d, - in.avm_main_id, - in.avm_main_rwd, - in.avm_main_r_in_tag, - in.avm_main_w_in_tag, - in.avm_main_sel_cmov, - in.avm_mem_clk, - in.avm_mem_space_id, - in.avm_mem_addr, - in.avm_mem_val, - in.avm_mem_rw, - in.avm_mem_r_in_tag, - in.avm_mem_w_in_tag, - in.avm_mem_sel_cmov); + + /** + * @brief Get all the entities for the permutation when we don't need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.perm_main_mem_d, +in.avm_main_mem_op_d, +in.avm_main_mem_op_d, +in.avm_mem_op_d, +in.avm_main_clk, +in.avm_main_space_id, +in.avm_main_mem_idx_d, +in.avm_main_id, +in.avm_main_rwd, +in.avm_main_r_in_tag, +in.avm_main_w_in_tag, +in.avm_main_sel_cmov, +in.avm_mem_clk, +in.avm_mem_space_id, +in.avm_mem_addr, +in.avm_mem_val, +in.avm_mem_rw, +in.avm_mem_r_in_tag, +in.avm_mem_w_in_tag, +in.avm_mem_sel_cmov + ); + } - - /** - * @brief Get all the entities for the permutation when need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.perm_main_mem_d, - in.avm_main_mem_op_d, - in.avm_main_mem_op_d, - in.avm_mem_op_d, - in.avm_main_clk, - in.avm_main_space_id, - in.avm_main_mem_idx_d, - in.avm_main_id, - in.avm_main_rwd, - in.avm_main_r_in_tag, - in.avm_main_w_in_tag, - in.avm_main_sel_cmov, - in.avm_mem_clk, - in.avm_mem_space_id, - in.avm_mem_addr, - in.avm_mem_val, - in.avm_mem_rw, - in.avm_mem_r_in_tag, - in.avm_mem_w_in_tag, - in.avm_mem_sel_cmov); + + + /** + * @brief Get all the entities for the permutation when need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.perm_main_mem_d, +in.avm_main_mem_op_d, +in.avm_main_mem_op_d, +in.avm_mem_op_d, +in.avm_main_clk, +in.avm_main_space_id, +in.avm_main_mem_idx_d, +in.avm_main_id, +in.avm_main_rwd, +in.avm_main_r_in_tag, +in.avm_main_w_in_tag, +in.avm_main_sel_cmov, +in.avm_mem_clk, +in.avm_mem_space_id, +in.avm_mem_addr, +in.avm_mem_val, +in.avm_mem_rw, +in.avm_mem_r_in_tag, +in.avm_mem_w_in_tag, +in.avm_mem_sel_cmov + ); + } -}; - -template -using perm_main_mem_d_relation = GenericPermutationRelation; -template using perm_main_mem_d = GenericPermutation; + + }; -} // namespace bb + + template using perm_main_mem_d_relation = GenericPermutationRelation; + template using perm_main_mem_d = GenericPermutation; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_a.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_a.hpp index fde1c682370..0108ecbf364 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_a.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_a.hpp @@ -1,102 +1,109 @@ - -#pragma once - -#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" - -#include -#include - -namespace bb { - -class perm_main_mem_ind_a_permutation_settings { - public: - // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 4; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the - * value needs to be set to zero. - * - * @details If this is true then permutation takes place in this row - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + + #include + #include + + + namespace bb { + + class perm_main_mem_ind_a_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 4; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the + * value needs to be set to zero. + * + * @details If this is true then permutation takes place in this row + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_main_ind_op_a == 1 || in.avm_mem_ind_op_a == 1); } - - /** - * @brief Get all the entities for the permutation when we don't need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.perm_main_mem_ind_a, - in.avm_main_ind_op_a, - in.avm_main_ind_op_a, - in.avm_mem_ind_op_a, - in.avm_main_clk, - in.avm_main_space_id, - in.avm_main_ind_a, - in.avm_main_mem_idx_a, - in.avm_mem_clk, - in.avm_mem_space_id, - in.avm_mem_addr, - in.avm_mem_val); + + /** + * @brief Get all the entities for the permutation when we don't need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.perm_main_mem_ind_a, +in.avm_main_ind_op_a, +in.avm_main_ind_op_a, +in.avm_mem_ind_op_a, +in.avm_main_clk, +in.avm_main_space_id, +in.avm_main_ind_a, +in.avm_main_mem_idx_a, +in.avm_mem_clk, +in.avm_mem_space_id, +in.avm_mem_addr, +in.avm_mem_val + ); + } - - /** - * @brief Get all the entities for the permutation when need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.perm_main_mem_ind_a, - in.avm_main_ind_op_a, - in.avm_main_ind_op_a, - in.avm_mem_ind_op_a, - in.avm_main_clk, - in.avm_main_space_id, - in.avm_main_ind_a, - in.avm_main_mem_idx_a, - in.avm_mem_clk, - in.avm_mem_space_id, - in.avm_mem_addr, - in.avm_mem_val); + + + /** + * @brief Get all the entities for the permutation when need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.perm_main_mem_ind_a, +in.avm_main_ind_op_a, +in.avm_main_ind_op_a, +in.avm_mem_ind_op_a, +in.avm_main_clk, +in.avm_main_space_id, +in.avm_main_ind_a, +in.avm_main_mem_idx_a, +in.avm_mem_clk, +in.avm_mem_space_id, +in.avm_mem_addr, +in.avm_mem_val + ); + } -}; - -template -using perm_main_mem_ind_a_relation = GenericPermutationRelation; -template using perm_main_mem_ind_a = GenericPermutation; + + }; -} // namespace bb + + template using perm_main_mem_ind_a_relation = GenericPermutationRelation; + template using perm_main_mem_ind_a = GenericPermutation; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_b.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_b.hpp index 0fb572b5302..53ce0e52669 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_b.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_b.hpp @@ -1,102 +1,109 @@ - -#pragma once - -#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" - -#include -#include - -namespace bb { - -class perm_main_mem_ind_b_permutation_settings { - public: - // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 4; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the - * value needs to be set to zero. - * - * @details If this is true then permutation takes place in this row - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + + #include + #include + + + namespace bb { + + class perm_main_mem_ind_b_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 4; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the + * value needs to be set to zero. + * + * @details If this is true then permutation takes place in this row + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_main_ind_op_b == 1 || in.avm_mem_ind_op_b == 1); } - - /** - * @brief Get all the entities for the permutation when we don't need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.perm_main_mem_ind_b, - in.avm_main_ind_op_b, - in.avm_main_ind_op_b, - in.avm_mem_ind_op_b, - in.avm_main_clk, - in.avm_main_space_id, - in.avm_main_ind_b, - in.avm_main_mem_idx_b, - in.avm_mem_clk, - in.avm_mem_space_id, - in.avm_mem_addr, - in.avm_mem_val); + + /** + * @brief Get all the entities for the permutation when we don't need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.perm_main_mem_ind_b, +in.avm_main_ind_op_b, +in.avm_main_ind_op_b, +in.avm_mem_ind_op_b, +in.avm_main_clk, +in.avm_main_space_id, +in.avm_main_ind_b, +in.avm_main_mem_idx_b, +in.avm_mem_clk, +in.avm_mem_space_id, +in.avm_mem_addr, +in.avm_mem_val + ); + } - - /** - * @brief Get all the entities for the permutation when need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.perm_main_mem_ind_b, - in.avm_main_ind_op_b, - in.avm_main_ind_op_b, - in.avm_mem_ind_op_b, - in.avm_main_clk, - in.avm_main_space_id, - in.avm_main_ind_b, - in.avm_main_mem_idx_b, - in.avm_mem_clk, - in.avm_mem_space_id, - in.avm_mem_addr, - in.avm_mem_val); + + + /** + * @brief Get all the entities for the permutation when need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.perm_main_mem_ind_b, +in.avm_main_ind_op_b, +in.avm_main_ind_op_b, +in.avm_mem_ind_op_b, +in.avm_main_clk, +in.avm_main_space_id, +in.avm_main_ind_b, +in.avm_main_mem_idx_b, +in.avm_mem_clk, +in.avm_mem_space_id, +in.avm_mem_addr, +in.avm_mem_val + ); + } -}; - -template -using perm_main_mem_ind_b_relation = GenericPermutationRelation; -template using perm_main_mem_ind_b = GenericPermutation; + + }; -} // namespace bb + + template using perm_main_mem_ind_b_relation = GenericPermutationRelation; + template using perm_main_mem_ind_b = GenericPermutation; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_c.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_c.hpp index 98676a0d8b3..19a95a70842 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_c.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_c.hpp @@ -1,102 +1,109 @@ - -#pragma once - -#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" - -#include -#include - -namespace bb { - -class perm_main_mem_ind_c_permutation_settings { - public: - // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 4; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the - * value needs to be set to zero. - * - * @details If this is true then permutation takes place in this row - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + + #include + #include + + + namespace bb { + + class perm_main_mem_ind_c_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 4; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the + * value needs to be set to zero. + * + * @details If this is true then permutation takes place in this row + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_main_ind_op_c == 1 || in.avm_mem_ind_op_c == 1); } - - /** - * @brief Get all the entities for the permutation when we don't need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.perm_main_mem_ind_c, - in.avm_main_ind_op_c, - in.avm_main_ind_op_c, - in.avm_mem_ind_op_c, - in.avm_main_clk, - in.avm_main_space_id, - in.avm_main_ind_c, - in.avm_main_mem_idx_c, - in.avm_mem_clk, - in.avm_mem_space_id, - in.avm_mem_addr, - in.avm_mem_val); + + /** + * @brief Get all the entities for the permutation when we don't need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.perm_main_mem_ind_c, +in.avm_main_ind_op_c, +in.avm_main_ind_op_c, +in.avm_mem_ind_op_c, +in.avm_main_clk, +in.avm_main_space_id, +in.avm_main_ind_c, +in.avm_main_mem_idx_c, +in.avm_mem_clk, +in.avm_mem_space_id, +in.avm_mem_addr, +in.avm_mem_val + ); + } - - /** - * @brief Get all the entities for the permutation when need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.perm_main_mem_ind_c, - in.avm_main_ind_op_c, - in.avm_main_ind_op_c, - in.avm_mem_ind_op_c, - in.avm_main_clk, - in.avm_main_space_id, - in.avm_main_ind_c, - in.avm_main_mem_idx_c, - in.avm_mem_clk, - in.avm_mem_space_id, - in.avm_mem_addr, - in.avm_mem_val); + + + /** + * @brief Get all the entities for the permutation when need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.perm_main_mem_ind_c, +in.avm_main_ind_op_c, +in.avm_main_ind_op_c, +in.avm_mem_ind_op_c, +in.avm_main_clk, +in.avm_main_space_id, +in.avm_main_ind_c, +in.avm_main_mem_idx_c, +in.avm_mem_clk, +in.avm_mem_space_id, +in.avm_mem_addr, +in.avm_mem_val + ); + } -}; - -template -using perm_main_mem_ind_c_relation = GenericPermutationRelation; -template using perm_main_mem_ind_c = GenericPermutation; + + }; -} // namespace bb + + template using perm_main_mem_ind_c_relation = GenericPermutationRelation; + template using perm_main_mem_ind_c = GenericPermutation; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_d.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_d.hpp index c66b01e035a..5dcf9081cc7 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_d.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_d.hpp @@ -1,102 +1,109 @@ - -#pragma once - -#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" - -#include -#include - -namespace bb { - -class perm_main_mem_ind_d_permutation_settings { - public: - // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 4; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the - * value needs to be set to zero. - * - * @details If this is true then permutation takes place in this row - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + + #include + #include + + + namespace bb { + + class perm_main_mem_ind_d_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 4; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the + * value needs to be set to zero. + * + * @details If this is true then permutation takes place in this row + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_main_ind_op_d == 1 || in.avm_mem_ind_op_d == 1); } - - /** - * @brief Get all the entities for the permutation when we don't need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.perm_main_mem_ind_d, - in.avm_main_ind_op_d, - in.avm_main_ind_op_d, - in.avm_mem_ind_op_d, - in.avm_main_clk, - in.avm_main_space_id, - in.avm_main_ind_d, - in.avm_main_mem_idx_d, - in.avm_mem_clk, - in.avm_mem_space_id, - in.avm_mem_addr, - in.avm_mem_val); + + /** + * @brief Get all the entities for the permutation when we don't need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.perm_main_mem_ind_d, +in.avm_main_ind_op_d, +in.avm_main_ind_op_d, +in.avm_mem_ind_op_d, +in.avm_main_clk, +in.avm_main_space_id, +in.avm_main_ind_d, +in.avm_main_mem_idx_d, +in.avm_mem_clk, +in.avm_mem_space_id, +in.avm_mem_addr, +in.avm_mem_val + ); + } - - /** - * @brief Get all the entities for the permutation when need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.perm_main_mem_ind_d, - in.avm_main_ind_op_d, - in.avm_main_ind_op_d, - in.avm_mem_ind_op_d, - in.avm_main_clk, - in.avm_main_space_id, - in.avm_main_ind_d, - in.avm_main_mem_idx_d, - in.avm_mem_clk, - in.avm_mem_space_id, - in.avm_mem_addr, - in.avm_mem_val); + + + /** + * @brief Get all the entities for the permutation when need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.perm_main_mem_ind_d, +in.avm_main_ind_op_d, +in.avm_main_ind_op_d, +in.avm_mem_ind_op_d, +in.avm_main_clk, +in.avm_main_space_id, +in.avm_main_ind_d, +in.avm_main_mem_idx_d, +in.avm_mem_clk, +in.avm_mem_space_id, +in.avm_mem_addr, +in.avm_mem_val + ); + } -}; - -template -using perm_main_mem_ind_d_relation = GenericPermutationRelation; -template using perm_main_mem_ind_d = GenericPermutation; + + }; -} // namespace bb + + template using perm_main_mem_ind_d_relation = GenericPermutationRelation; + template using perm_main_mem_ind_d = GenericPermutation; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_pedersen.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_pedersen.hpp index 75d4809336f..1452d0be369 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_pedersen.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_pedersen.hpp @@ -1,94 +1,101 @@ - -#pragma once - -#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" - -#include -#include - -namespace bb { - -class perm_main_pedersen_permutation_settings { - public: - // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 2; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the - * value needs to be set to zero. - * - * @details If this is true then permutation takes place in this row - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + + #include + #include + + + namespace bb { + + class perm_main_pedersen_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 2; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the + * value needs to be set to zero. + * + * @details If this is true then permutation takes place in this row + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_main_sel_op_pedersen == 1 || in.avm_pedersen_pedersen_sel == 1); } - - /** - * @brief Get all the entities for the permutation when we don't need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.perm_main_pedersen, - in.avm_main_sel_op_pedersen, - in.avm_main_sel_op_pedersen, - in.avm_pedersen_pedersen_sel, - in.avm_main_clk, - in.avm_main_ia, - in.avm_pedersen_clk, - in.avm_pedersen_input); + + /** + * @brief Get all the entities for the permutation when we don't need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.perm_main_pedersen, +in.avm_main_sel_op_pedersen, +in.avm_main_sel_op_pedersen, +in.avm_pedersen_pedersen_sel, +in.avm_main_clk, +in.avm_main_ia, +in.avm_pedersen_clk, +in.avm_pedersen_input + ); + } - - /** - * @brief Get all the entities for the permutation when need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.perm_main_pedersen, - in.avm_main_sel_op_pedersen, - in.avm_main_sel_op_pedersen, - in.avm_pedersen_pedersen_sel, - in.avm_main_clk, - in.avm_main_ia, - in.avm_pedersen_clk, - in.avm_pedersen_input); + + + /** + * @brief Get all the entities for the permutation when need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.perm_main_pedersen, +in.avm_main_sel_op_pedersen, +in.avm_main_sel_op_pedersen, +in.avm_pedersen_pedersen_sel, +in.avm_main_clk, +in.avm_main_ia, +in.avm_pedersen_clk, +in.avm_pedersen_input + ); + } -}; - -template -using perm_main_pedersen_relation = GenericPermutationRelation; -template using perm_main_pedersen = GenericPermutation; + + }; -} // namespace bb + + template using perm_main_pedersen_relation = GenericPermutationRelation; + template using perm_main_pedersen = GenericPermutation; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_pos2_perm.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_pos2_perm.hpp index e75d3658eca..886d8318195 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_pos2_perm.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_pos2_perm.hpp @@ -1,98 +1,105 @@ - -#pragma once - -#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" - -#include -#include - -namespace bb { - -class perm_main_pos2_perm_permutation_settings { - public: - // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 3; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the - * value needs to be set to zero. - * - * @details If this is true then permutation takes place in this row - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { + + #pragma once + + #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + + #include + #include + + + namespace bb { + + class perm_main_pos2_perm_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 3; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the + * value needs to be set to zero. + * + * @details If this is true then permutation takes place in this row + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { return (in.avm_main_sel_op_poseidon2 == 1 || in.avm_poseidon2_poseidon_perm_sel == 1); } - - /** - * @brief Get all the entities for the permutation when we don't need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_const_entities(const AllEntities& in) - { - - return std::forward_as_tuple(in.perm_main_pos2_perm, - in.avm_main_sel_op_poseidon2, - in.avm_main_sel_op_poseidon2, - in.avm_poseidon2_poseidon_perm_sel, - in.avm_main_clk, - in.avm_main_ia, - in.avm_main_ib, - in.avm_poseidon2_clk, - in.avm_poseidon2_input, - in.avm_poseidon2_output); + + /** + * @brief Get all the entities for the permutation when we don't need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_const_entities(const AllEntities& in) { + + return std::forward_as_tuple( + in.perm_main_pos2_perm, +in.avm_main_sel_op_poseidon2, +in.avm_main_sel_op_poseidon2, +in.avm_poseidon2_poseidon_perm_sel, +in.avm_main_clk, +in.avm_main_ia, +in.avm_main_ib, +in.avm_poseidon2_clk, +in.avm_poseidon2_input, +in.avm_poseidon2_output + ); + } - - /** - * @brief Get all the entities for the permutation when need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_nonconst_entities(AllEntities& in) - { - - return std::forward_as_tuple(in.perm_main_pos2_perm, - in.avm_main_sel_op_poseidon2, - in.avm_main_sel_op_poseidon2, - in.avm_poseidon2_poseidon_perm_sel, - in.avm_main_clk, - in.avm_main_ia, - in.avm_main_ib, - in.avm_poseidon2_clk, - in.avm_poseidon2_input, - in.avm_poseidon2_output); + + + /** + * @brief Get all the entities for the permutation when need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_nonconst_entities(AllEntities& in) { + + return std::forward_as_tuple( + in.perm_main_pos2_perm, +in.avm_main_sel_op_poseidon2, +in.avm_main_sel_op_poseidon2, +in.avm_poseidon2_poseidon_perm_sel, +in.avm_main_clk, +in.avm_main_ia, +in.avm_main_ib, +in.avm_poseidon2_clk, +in.avm_poseidon2_input, +in.avm_poseidon2_output + ); + } -}; - -template -using perm_main_pos2_perm_relation = GenericPermutationRelation; -template using perm_main_pos2_perm = GenericPermutation; + + }; -} // namespace bb + + template using perm_main_pos2_perm_relation = GenericPermutationRelation; + template using perm_main_pos2_perm = GenericPermutation; + + } + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_common.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_common.hpp index b27edb64782..02ec120cac3 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_common.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_common.hpp @@ -14,6 +14,21 @@ using FF = Flavor::FF; } // namespace bb::avm_trace +namespace bb::avm_trace {} // namespace bb::avm_trace + +// TODO: where is the best place for this to live? +namespace std { +template <> struct hash { + // We define a hash function for the AVM FF type for an unordered_map integration + size_t operator()(const bb::avm_trace::FF& ff) const + { + return ( + std::hash()(ff.data[0]) ^ + std::hash()(ff.data[1] ^ std::hash()(ff.data[2]) ^ std::hash()(ff.data[3]))); + } +}; +} // namespace std + namespace bb::avm_trace { // There are 4 public input columns, 1 for context inputs, and 3 for emitting side effects @@ -41,6 +56,9 @@ static const uint8_t INTERNAL_CALL_SPACE_ID = 255; static const uint32_t MAX_SIZE_INTERNAL_STACK = 1 << 16; // Side effect counter -> value -using ExecutionHints = std::unordered_map; +struct ExecutionHints { + std::unordered_map side_effect_hints; + std::vector> returndata_hints; +}; } // namespace bb::avm_trace diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp index f932b7d2fa3..3354a071d4b 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp @@ -24,6 +24,16 @@ const std::vector getter_format = { OperandType::UINT32, }; +const std::vector external_call_format = { OperandType::INDIRECT, + /*gasOffset=*/OperandType::UINT32, + /*addrOffset=*/OperandType::UINT32, + /*argsOffset=*/OperandType::UINT32, + /*argsSize=*/OperandType::UINT32, + /*retOffset=*/OperandType::UINT32, + /*retSize*/ OperandType::UINT32, + /*successOffset=*/OperandType::UINT32, + /*functionSelector=*/OperandType::UINT32 }; + // Contrary to TS, the format does not contain the opcode byte which prefixes any instruction. // The format for OpCode::SET has to be handled separately as it is variable based on the tag. const std::unordered_map> OPCODE_WIRE_FORMAT = { @@ -102,7 +112,7 @@ const std::unordered_map> OPCODE_WIRE_FORMAT = // EMITUNENCRYPTEDLOG, // SENDL2TOL1MSG, // Control Flow - Contract Calls - // CALL, + { OpCode::CALL, external_call_format }, // STATICCALL, // DELEGATECALL, -- not in simulator { OpCode::RETURN, { OperandType::INDIRECT, OperandType::UINT32, OperandType::UINT32 } }, diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp index 15c3c7f7c12..e45b8f80afc 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp @@ -438,6 +438,7 @@ std::vector Execution::gen_trace(std::vector const& instructio std::get(inst.operands.at(1)), std::get(inst.operands.at(2))); returndata.insert(returndata.end(), ret.begin(), ret.end()); + break; } case OpCode::DEBUGLOG: @@ -445,6 +446,17 @@ std::vector Execution::gen_trace(std::vector const& instructio // and adds a valid row to the trace. trace_builder.jump(pc + 1); break; + case OpCode::CALL: + trace_builder.op_call(std::get(inst.operands.at(0)), + std::get(inst.operands.at(1)), + std::get(inst.operands.at(2)), + std::get(inst.operands.at(3)), + std::get(inst.operands.at(4)), + std::get(inst.operands.at(5)), + std::get(inst.operands.at(6)), + std::get(inst.operands.at(7)), + std::get(inst.operands.at(8))); + break; case OpCode::TORADIXLE: trace_builder.op_to_radix_le(std::get(inst.operands.at(0)), std::get(inst.operands.at(1)), diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp index 900ef90f7a9..207d03175e0 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp @@ -43,11 +43,11 @@ void log_avm_trace(std::vector const& trace, size_t beg, size_t end, bool e info("internal_return: ", trace.at(i).avm_main_sel_internal_return); info("internal_return_ptr:", trace.at(i).avm_main_internal_return_ptr); - info("=======ALU TRACE====================================================================="); - info("alu_clk ", trace.at(i).avm_alu_clk); - info("alu_ia ", trace.at(i).avm_alu_ia); - info("alu_ib ", trace.at(i).avm_alu_ib); - info("alu_ic ", trace.at(i).avm_alu_ic); + // info("=======ALU TRACE====================================================================="); + // info("alu_clk ", trace.at(i).avm_alu_clk); + // info("alu_ia ", trace.at(i).avm_alu_ia); + // info("alu_ib ", trace.at(i).avm_alu_ib); + // info("alu_ic ", trace.at(i).avm_alu_ic); info("=======MAIN TRACE===================================================================="); info("clk: ", trace.at(i).avm_main_clk); @@ -60,23 +60,28 @@ void log_avm_trace(std::vector const& trace, size_t beg, size_t end, bool e info("first: ", trace.at(i).avm_main_first); info("last: ", trace.at(i).avm_main_last); - info("=======MEM_OP_A======================================================================"); - info("mem_op_a: ", trace.at(i).avm_main_mem_op_a); - info("mem_idx_a: ", trace.at(i).avm_main_mem_idx_a); - info("rwa: ", trace.at(i).avm_main_rwa); - - info("=======MEM_OP_B======================================================================"); - info("mem_op_b: ", trace.at(i).avm_main_mem_op_b); - info("mem_idx_b: ", trace.at(i).avm_main_mem_idx_b); - info("rwb: ", trace.at(i).avm_main_rwb); - - info("=======MEM_OP_C======================================================================"); - info("mem_op_c: ", trace.at(i).avm_main_mem_op_c); - info("mem_idx_c: ", trace.at(i).avm_main_mem_idx_c); - info("rwc: ", trace.at(i).avm_main_rwc); - info("diff_hi: ", trace.at(i).avm_mem_diff_hi); - info("diff_mid: ", trace.at(i).avm_mem_diff_mid); - info("diff_lo: ", trace.at(i).avm_mem_diff_lo); + // info("=======MEM_OP_A======================================================================"); + // info("mem_op_a: ", trace.at(i).avm_main_mem_op_a); + // info("mem_idx_a: ", trace.at(i).avm_main_mem_idx_a); + // info("rwa: ", trace.at(i).avm_main_rwa); + + // info("=======MEM_OP_B======================================================================"); + // info("mem_op_b: ", trace.at(i).avm_main_mem_op_b); + // info("mem_idx_b: ", trace.at(i).avm_main_mem_idx_b); + // info("rwb: ", trace.at(i).avm_main_rwb); + + // info("=======MEM_OP_C======================================================================"); + // info("mem_op_c: ", trace.at(i).avm_main_mem_op_c); + // info("mem_idx_c: ", trace.at(i).avm_main_mem_idx_c); + // info("rwc: ", trace.at(i).avm_main_rwc); + // info("diff_hi: ", trace.at(i).avm_mem_diff_hi); + // info("diff_mid: ", trace.at(i).avm_mem_diff_mid); + // info("diff_lo: ", trace.at(i).avm_mem_diff_lo); + + info("=======OUT_CONSISTENCY======================================================================"); + info("note_hash_write: ", trace.at(i).avm_kernel_emit_note_hash_write_offset); + info("nullifier_write: ", trace.at(i).avm_kernel_emit_nullifier_write_offset); + info("unencrypted_write: ", trace.at(i).avm_kernel_emit_unencrypted_log_write_offset); info("=======GAS ACCOUNTING================================================================"); info("opcode active: ", trace.at(i).avm_main_gas_cost_active); @@ -87,12 +92,15 @@ void log_avm_trace(std::vector const& trace, size_t beg, size_t end, bool e if (enable_selectors) { info("=======SELECTORS======================================================================"); - info("sel_op_add: ", trace.at(i).avm_main_sel_op_add); - info("sel_op_sub: ", trace.at(i).avm_main_sel_op_sub); - info("sel_op_mul: ", trace.at(i).avm_main_sel_op_mul); - info("sel_op_eq: ", trace.at(i).avm_main_sel_op_eq); - info("sel_op_not: ", trace.at(i).avm_main_sel_op_not); - info("sel_op_sel_alu: ", trace.at(i).avm_main_alu_sel); + info("sel_op_emit_note_hash: ", trace.at(i).avm_main_sel_op_emit_note_hash); + info("sel_op_emit_nullifier: ", trace.at(i).avm_main_sel_op_emit_nullifier); + info("sel_op_emit_unencryped_log: ", trace.at(i).avm_main_sel_op_emit_unencrypted_log); + // info("sel_op_add: ", trace.at(i).avm_main_sel_op_add); + // info("sel_op_sub: ", trace.at(i).avm_main_sel_op_sub); + // info("sel_op_mul: ", trace.at(i).avm_main_sel_op_mul); + // info("sel_op_eq: ", trace.at(i).avm_main_sel_op_eq); + // info("sel_op_not: ", trace.at(i).avm_main_sel_op_not); + // info("sel_op_sel_alu: ", trace.at(i).avm_main_alu_sel); } info("\n"); } diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp index c63a6a7e0ad..835333a7f5f 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp @@ -47,6 +47,7 @@ void AvmTraceBuilder::reset() alu_trace_builder.reset(); bin_trace_builder.reset(); kernel_trace_builder.reset(); + return_data_counter = 0; } AvmTraceBuilder::IndirectThreeResolution AvmTraceBuilder::resolve_ind_three( @@ -1368,7 +1369,7 @@ Row AvmTraceBuilder::create_kernel_output_opcode_with_set_metadata_output_from_h AvmMemTraceBuilder::MemRead read_a = mem_trace_builder.read_and_load_from_memory( call_ptr, clk, IntermRegister::IA, data_offset, AvmMemoryTag::FF, AvmMemoryTag::U8); - FF exists = execution_hints.at(side_effect_counter); + FF exists = execution_hints.side_effect_hints.at(side_effect_counter); // TODO: throw error if incorrect mem_trace_builder.write_into_memory( @@ -1398,7 +1399,7 @@ Row AvmTraceBuilder::create_kernel_output_opcode_with_set_value_from_hint(uint32 uint32_t data_offset, uint32_t metadata_offset) { - FF value = execution_hints.at(side_effect_counter); + FF value = execution_hints.side_effect_hints.at(side_effect_counter); // TODO: throw error if incorrect mem_trace_builder.write_into_memory( @@ -2295,6 +2296,130 @@ uint32_t AvmTraceBuilder::read_slice_to_memory(uint8_t space_id, return num_main_rows; } +// Use the indirect later to support all the indirect accesses +void AvmTraceBuilder::op_call([[maybe_unused]] uint8_t indirect, + uint32_t gas_offset, + uint32_t addr_offset, + uint32_t args_offset, + uint32_t args_size, + [[maybe_unused]] uint32_t ret_offset, + [[maybe_unused]] uint32_t ret_size, + [[maybe_unused]] uint32_t success_offset, + [[maybe_unused]] uint32_t function_selector_offset) +{ + auto clk = static_cast(main_trace.size()) + 1; + // We can load up to 4 things per row + auto register_order = std::array{ IntermRegister::IA, IntermRegister::IB, IntermRegister::IC, IntermRegister::ID }; + // Constrain gas cost + gas_trace_builder.constrain_gas_lookup(clk, OpCode::CALL); + // Indirect is ZEROTH, SECOND and FOURTH bit COME BACK TO MAKING THIS ALL SUPPORTED + auto read_ind_gas_offset = + mem_trace_builder.indirect_read_and_load_from_memory(call_ptr, clk, IndirectRegister::IND_A, gas_offset); + auto read_ind_args_offset = + mem_trace_builder.indirect_read_and_load_from_memory(call_ptr, clk, IndirectRegister::IND_C, args_offset); + + std::vector first_row_load = { + uint32_t(read_ind_gas_offset.val), addr_offset, uint32_t(read_ind_args_offset.val), args_size + }; + std::vector first_row_values = {}; + for (uint32_t j = 0; j < first_row_load.size(); j++) { + // We just read and load to set up the constraints, we dont actually use these values for now. + auto mem_read = mem_trace_builder.read_and_load_from_memory(call_ptr, + clk, + register_order[j % register_order.size()], + first_row_load[j], + AvmMemoryTag::U32, + AvmMemoryTag::U0); + first_row_values.emplace_back(mem_read.val); + } + + // We read the input and output addresses in one row as they should contain FF elements + main_trace.push_back(Row{ + .avm_main_clk = clk, + .avm_main_ia = first_row_values[0], /* gas_offset */ + .avm_main_ib = first_row_values[1], /* addr_offset */ + .avm_main_ic = first_row_values[2], /* args_offset */ + .avm_main_id = first_row_values[3], /* args_size */ + .avm_main_ind_a = gas_offset, + .avm_main_ind_c = args_offset, + .avm_main_ind_op_a = FF(1), + .avm_main_ind_op_c = FF(1), + .avm_main_internal_return_ptr = FF(internal_return_ptr), + .avm_main_mem_idx_a = read_ind_gas_offset.val, + .avm_main_mem_idx_b = addr_offset, + .avm_main_mem_idx_c = read_ind_args_offset.val, + .avm_main_mem_idx_d = args_size, + .avm_main_mem_op_a = FF(1), + .avm_main_mem_op_b = FF(1), + .avm_main_mem_op_c = FF(1), + .avm_main_mem_op_d = FF(1), + .avm_main_pc = FF(pc++), + .avm_main_r_in_tag = FF(static_cast(AvmMemoryTag::U32)), + .avm_main_sel_external_call = FF(1), + }); + clk++; + // Read the rest on a separate line, remember that the 4th operand is indirect + auto read_ind_ret_offset = + mem_trace_builder.indirect_read_and_load_from_memory(call_ptr, clk, IndirectRegister::IND_A, ret_offset); + std::vector second_row_values = {}; + std::vector second_row_load = { + uint32_t(read_ind_ret_offset.val), function_selector_offset, ret_size, success_offset + }; + for (uint32_t j = 0; j < second_row_load.size(); j++) { + // We just read and load to set up the constraints, we dont actually use these values for now. + auto mem_read = mem_trace_builder.read_and_load_from_memory(call_ptr, + clk, + register_order[j % register_order.size()], + second_row_load[j], + AvmMemoryTag::U32, + AvmMemoryTag::U0); + second_row_values.emplace_back(mem_read.val); + } + main_trace.push_back(Row{ + .avm_main_clk = clk, + .avm_main_ia = second_row_values[0], /* ret_offset */ + .avm_main_ib = second_row_values[1], /* function_selector_offset */ + .avm_main_ic = second_row_values[2], /* ret_size */ + .avm_main_id = second_row_values[3], /* success_offset */ + .avm_main_ind_a = ret_offset, + .avm_main_ind_op_a = FF(1), + .avm_main_internal_return_ptr = FF(internal_return_ptr), + .avm_main_mem_idx_a = read_ind_ret_offset.val, + .avm_main_mem_idx_b = function_selector_offset, + .avm_main_mem_idx_c = ret_size, + .avm_main_mem_idx_d = success_offset, + .avm_main_mem_op_a = FF(1), + .avm_main_mem_op_b = FF(1), + .avm_main_mem_op_c = FF(1), + .avm_main_mem_op_d = FF(1), + .avm_main_pc = FF(pc), + .avm_main_r_in_tag = FF(static_cast(AvmMemoryTag::U32)), + }); + // NOTE: we do not constrain this here as it's behaviour will change fully once we have a full enqueued function + // call in one vm circuit + clk++; + // PLAN + // 1. We load and constrain all of the operands ( of which there are loads, (either 4 more registers or we send + // it across two rows (we might be able to get away with this - and break a shit load of other stuff))) + std::vector write_operands = { ret_offset, success_offset }; + // 2. Use the write slice to memory once we get the entire return data size from the hint + write_slice_to_memory(call_ptr, + clk, + uint32_t(read_ind_ret_offset.val), + AvmMemoryTag::U0, + AvmMemoryTag::FF, + internal_return_ptr, + execution_hints.returndata_hints.at(return_data_counter)); + return_data_counter++; + clk++; + write_slice_to_memory( + call_ptr, clk, success_offset, AvmMemoryTag::U0, AvmMemoryTag::U8, internal_return_ptr, { FF(1) }); + + // Getting the return values + // We should be able to receive return data values from the hints, and do an (unconstrained) sanity check that + // the correct values are here +} + /** * @brief To_Radix_LE with direct or indirect memory access. * @@ -3691,6 +3816,9 @@ std::vector AvmTraceBuilder::finalize(uint32_t min_trace_size, bool range_c if (clk < main_trace_size) { Row& next = main_trace.at(clk + 1); + if (src.op_emit_unencrypted_log) { + info("side effect counter when emiting log: ", curr.avm_kernel_side_effect_counter); + } // Increment the write offset counter for the following row next.avm_kernel_note_hash_exist_write_offset = curr.avm_kernel_note_hash_exist_write_offset + static_cast(src.op_note_hash_exists); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp index dcb4c370b33..1bc54468ca2 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp @@ -151,6 +151,17 @@ class AvmTraceBuilder { // indirect: return(M[M[ret_offset]:M[ret_offset]+ret_size]) std::vector return_op(uint8_t indirect, uint32_t ret_offset, uint32_t ret_size); + // Calls + void op_call(uint8_t indirect, + uint32_t gas_offset, + uint32_t addr_offset, + uint32_t args_offset, + uint32_t args_size, + uint32_t ret_offset, + uint32_t ret_size, + uint32_t success_offset, + uint32_t function_selector_offset); + // Gadgets // --- Conversions // To Radix LE conversion operation. @@ -283,6 +294,7 @@ class AvmTraceBuilder { // Side effect counter will incremenent when any state writing values are // encountered uint32_t side_effect_counter = 0; + uint32_t return_data_counter = 0; // Execution hints aid witness solving for instructions that require auxiliary information to construct // Mapping of side effect counter -> value diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/constants.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/constants.hpp index 06ff6677574..9b96f341490 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/constants.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/constants.hpp @@ -35,6 +35,8 @@ inline const uint32_t DA_GAS_LEFT_PCPI_OFFSET = PUBLIC_CIRCUIT_PUBLIC_INPUTS_LEN inline const uint32_t L2_GAS_LEFT_PCPI_OFFSET = PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH - 2 - GAS_LENGTH; // Kernel output pil offset (Where update objects are inlined) +// Kernel outputs public inputs offsets +// Kernel outputs offsets // Kernel outputs public inputs offsets inline const uint32_t NULLIFIER_EXISTS_OFFSET = CALL_CONTEXT_LENGTH + 2; @@ -58,4 +60,4 @@ inline const uint32_t UNENCRYPTED_LOGS_OFFSET = // L2 and Da gas left are the 3rd last and 2nd last items in the context kernel inputs respectively inline const std::size_t DA_GAS_LEFT_CONTEXT_INPUTS_OFFSET = KERNEL_INPUTS_LENGTH - 3; -inline const std::size_t L2_GAS_LEFT_CONTEXT_INPUTS_OFFSET = KERNEL_INPUTS_LENGTH - 2; \ No newline at end of file +inline const std::size_t L2_GAS_LEFT_CONTEXT_INPUTS_OFFSET = KERNEL_INPUTS_LENGTH - 2; diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp index f9e597143eb..0c990afecb4 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp @@ -262,6 +262,7 @@ template struct AvmFullRow { FF avm_main_rwc{}; FF avm_main_rwd{}; FF avm_main_sel_cmov{}; + FF avm_main_sel_external_call{}; FF avm_main_sel_halt{}; FF avm_main_sel_internal_call{}; FF avm_main_sel_internal_return{}; @@ -522,8 +523,8 @@ class AvmCircuitBuilder { using Polynomial = Flavor::Polynomial; using ProverPolynomials = Flavor::ProverPolynomials; - static constexpr size_t num_fixed_columns = 429; - static constexpr size_t num_polys = 365; + static constexpr size_t num_fixed_columns = 430; + static constexpr size_t num_polys = 366; std::vector rows; void set_trace(std::vector&& trace) { rows = std::move(trace); } @@ -724,6 +725,7 @@ class AvmCircuitBuilder { polys.avm_main_rwc[i] = rows[i].avm_main_rwc; polys.avm_main_rwd[i] = rows[i].avm_main_rwd; polys.avm_main_sel_cmov[i] = rows[i].avm_main_sel_cmov; + polys.avm_main_sel_external_call[i] = rows[i].avm_main_sel_external_call; polys.avm_main_sel_halt[i] = rows[i].avm_main_sel_halt; polys.avm_main_sel_internal_call[i] = rows[i].avm_main_sel_internal_call; polys.avm_main_sel_internal_return[i] = rows[i].avm_main_sel_internal_return; diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.cpp index d923c58c1cc..6c235688fb0 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.cpp @@ -6,6 +6,7 @@ #include "barretenberg/vm/generated/avm_circuit_builder.hpp" #include "barretenberg/vm/generated/avm_verifier.hpp" + namespace bb { using Flavor = AvmFlavor; @@ -36,7 +37,8 @@ AvmProver AvmComposer::create_prover(CircuitConstructor& circuit_constructor) return output_state; } -AvmVerifier AvmComposer::create_verifier(CircuitConstructor& circuit_constructor) +AvmVerifier AvmComposer::create_verifier( + CircuitConstructor& circuit_constructor) { auto verification_key = compute_verification_key(circuit_constructor); @@ -49,7 +51,8 @@ AvmVerifier AvmComposer::create_verifier(CircuitConstructor& circuit_constructor return output_state; } -std::shared_ptr AvmComposer::compute_proving_key(CircuitConstructor& circuit_constructor) +std::shared_ptr AvmComposer::compute_proving_key( + CircuitConstructor& circuit_constructor) { if (proving_key) { return proving_key; @@ -66,7 +69,8 @@ std::shared_ptr AvmComposer::compute_proving_key(CircuitCons return proving_key; } -std::shared_ptr AvmComposer::compute_verification_key(CircuitConstructor& circuit_constructor) +std::shared_ptr AvmComposer::compute_verification_key( + CircuitConstructor& circuit_constructor) { if (verification_key) { return verification_key; @@ -82,4 +86,4 @@ std::shared_ptr AvmComposer::compute_verification_key(C return verification_key; } -} // namespace bb +} diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.hpp index a2f9fe68dcf..6d168c52d3b 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.hpp @@ -7,63 +7,67 @@ #include "barretenberg/vm/generated/avm_circuit_builder.hpp" #include "barretenberg/vm/generated/avm_prover.hpp" #include "barretenberg/vm/generated/avm_verifier.hpp" + namespace bb { class AvmComposer { - public: - using Flavor = AvmFlavor; - using CircuitConstructor = AvmCircuitBuilder; - using ProvingKey = Flavor::ProvingKey; - using VerificationKey = Flavor::VerificationKey; - using PCS = Flavor::PCS; - using CommitmentKey = Flavor::CommitmentKey; - using VerifierCommitmentKey = Flavor::VerifierCommitmentKey; - - // TODO: which of these will we really need - static constexpr std::string_view NAME_STRING = "Avm"; - static constexpr size_t NUM_RESERVED_GATES = 0; - static constexpr size_t NUM_WIRES = Flavor::NUM_WIRES; - - std::shared_ptr proving_key; - std::shared_ptr verification_key; - - // The crs_factory holds the path to the srs and exposes methods to extract the srs elements - std::shared_ptr> crs_factory_; - - // The commitment key is passed to the prover but also used herein to compute the verfication key commitments - std::shared_ptr commitment_key; - - std::vector recursive_proof_public_input_indices; - bool contains_recursive_proof = false; - bool computed_witness = false; - - AvmComposer() { crs_factory_ = bb::srs::get_bn254_crs_factory(); } - - AvmComposer(std::shared_ptr p_key, std::shared_ptr v_key) - : proving_key(std::move(p_key)) - , verification_key(std::move(v_key)) - {} - - AvmComposer(AvmComposer&& other) noexcept = default; - AvmComposer(AvmComposer const& other) noexcept = default; - AvmComposer& operator=(AvmComposer&& other) noexcept = default; - AvmComposer& operator=(AvmComposer const& other) noexcept = default; - ~AvmComposer() = default; - - std::shared_ptr compute_proving_key(CircuitConstructor& circuit_constructor); - std::shared_ptr compute_verification_key(CircuitConstructor& circuit_constructor); - - void compute_witness(CircuitConstructor& circuit_constructor); - - AvmProver create_prover(CircuitConstructor& circuit_constructor); - AvmVerifier create_verifier(CircuitConstructor& circuit_constructor); - - void add_table_column_selector_poly_to_proving_key(bb::polynomial& small, const std::string& tag); - - void compute_commitment_key(size_t circuit_size) - { - proving_key->commitment_key = std::make_shared(circuit_size); - }; + public: + using Flavor = AvmFlavor; + using CircuitConstructor = AvmCircuitBuilder; + using ProvingKey = Flavor::ProvingKey; + using VerificationKey = Flavor::VerificationKey; + using PCS = Flavor::PCS; + using CommitmentKey = Flavor::CommitmentKey; + using VerifierCommitmentKey = Flavor::VerifierCommitmentKey; + + // TODO: which of these will we really need + static constexpr std::string_view NAME_STRING = "Avm"; + static constexpr size_t NUM_RESERVED_GATES = 0; + static constexpr size_t NUM_WIRES = Flavor::NUM_WIRES; + + std::shared_ptr proving_key; + std::shared_ptr verification_key; + + // The crs_factory holds the path to the srs and exposes methods to extract the srs elements + std::shared_ptr> crs_factory_; + + // The commitment key is passed to the prover but also used herein to compute the verfication key commitments + std::shared_ptr commitment_key; + + std::vector recursive_proof_public_input_indices; + bool contains_recursive_proof = false; + bool computed_witness = false; + + AvmComposer() + { + crs_factory_ = bb::srs::get_bn254_crs_factory(); + } + + AvmComposer(std::shared_ptr p_key, std::shared_ptr v_key) + : proving_key(std::move(p_key)) + , verification_key(std::move(v_key)) + {} + + AvmComposer(AvmComposer&& other) noexcept = default; + AvmComposer(AvmComposer const& other) noexcept = default; + AvmComposer& operator=(AvmComposer&& other) noexcept = default; + AvmComposer& operator=(AvmComposer const& other) noexcept = default; + ~AvmComposer() = default; + + std::shared_ptr compute_proving_key(CircuitConstructor& circuit_constructor); + std::shared_ptr compute_verification_key(CircuitConstructor& circuit_constructor); + + void compute_witness(CircuitConstructor& circuit_constructor); + + AvmProver create_prover(CircuitConstructor& circuit_constructor); + AvmVerifier create_verifier(CircuitConstructor& circuit_constructor); + + void add_table_column_selector_poly_to_proving_key(bb::polynomial& small, const std::string& tag); + + void compute_commitment_key(size_t circuit_size) + { + proving_key->commitment_key = std::make_shared(circuit_size); + }; }; } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp index 9465d14df18..d6f8497dcbc 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp @@ -94,11 +94,11 @@ class AvmFlavor { using RelationSeparator = FF; static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 2; - static constexpr size_t NUM_WITNESS_ENTITIES = 363; + static constexpr size_t NUM_WITNESS_ENTITIES = 364; static constexpr size_t NUM_WIRES = NUM_WITNESS_ENTITIES + NUM_PRECOMPUTED_ENTITIES; // We have two copies of the witness entities, so we subtract the number of fixed ones (they have no shift), one for // the unshifted and one for the shifted - static constexpr size_t NUM_ALL_ENTITIES = 429; + static constexpr size_t NUM_ALL_ENTITIES = 430; using GrandProductRelations = std::tuple, perm_main_bin_relation, @@ -423,6 +423,7 @@ class AvmFlavor { avm_main_rwc, avm_main_rwd, avm_main_sel_cmov, + avm_main_sel_external_call, avm_main_sel_halt, avm_main_sel_internal_call, avm_main_sel_internal_return, @@ -789,6 +790,7 @@ class AvmFlavor { avm_main_rwc, avm_main_rwd, avm_main_sel_cmov, + avm_main_sel_external_call, avm_main_sel_halt, avm_main_sel_internal_call, avm_main_sel_internal_return, @@ -1160,6 +1162,7 @@ class AvmFlavor { avm_main_rwc, avm_main_rwd, avm_main_sel_cmov, + avm_main_sel_external_call, avm_main_sel_halt, avm_main_sel_internal_call, avm_main_sel_internal_return, @@ -1592,6 +1595,7 @@ class AvmFlavor { avm_main_rwc, avm_main_rwd, avm_main_sel_cmov, + avm_main_sel_external_call, avm_main_sel_halt, avm_main_sel_internal_call, avm_main_sel_internal_return, @@ -2024,6 +2028,7 @@ class AvmFlavor { avm_main_rwc, avm_main_rwd, avm_main_sel_cmov, + avm_main_sel_external_call, avm_main_sel_halt, avm_main_sel_internal_call, avm_main_sel_internal_return, @@ -2803,6 +2808,7 @@ class AvmFlavor { Base::avm_main_rwc = "AVM_MAIN_RWC"; Base::avm_main_rwd = "AVM_MAIN_RWD"; Base::avm_main_sel_cmov = "AVM_MAIN_SEL_CMOV"; + Base::avm_main_sel_external_call = "AVM_MAIN_SEL_EXTERNAL_CALL"; Base::avm_main_sel_halt = "AVM_MAIN_SEL_HALT"; Base::avm_main_sel_internal_call = "AVM_MAIN_SEL_INTERNAL_CALL"; Base::avm_main_sel_internal_return = "AVM_MAIN_SEL_INTERNAL_RETURN"; @@ -3185,6 +3191,7 @@ class AvmFlavor { Commitment avm_main_rwc; Commitment avm_main_rwd; Commitment avm_main_sel_cmov; + Commitment avm_main_sel_external_call; Commitment avm_main_sel_halt; Commitment avm_main_sel_internal_call; Commitment avm_main_sel_internal_return; @@ -3581,6 +3588,7 @@ class AvmFlavor { avm_main_rwc = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_rwd = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_sel_cmov = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_external_call = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_sel_halt = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_sel_internal_call = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_sel_internal_return = deserialize_from_buffer(Transcript::proof_data, num_frs_read); @@ -3973,6 +3981,7 @@ class AvmFlavor { serialize_to_buffer(avm_main_rwc, Transcript::proof_data); serialize_to_buffer(avm_main_rwd, Transcript::proof_data); serialize_to_buffer(avm_main_sel_cmov, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_external_call, Transcript::proof_data); serialize_to_buffer(avm_main_sel_halt, Transcript::proof_data); serialize_to_buffer(avm_main_sel_internal_call, Transcript::proof_data); serialize_to_buffer(avm_main_sel_internal_return, Transcript::proof_data); diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp index 9d310a20005..480caa57aea 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp @@ -252,6 +252,7 @@ void AvmProver::execute_wire_commitments_round() witness_commitments.avm_main_rwc = commitment_key->commit(key->avm_main_rwc); witness_commitments.avm_main_rwd = commitment_key->commit(key->avm_main_rwd); witness_commitments.avm_main_sel_cmov = commitment_key->commit(key->avm_main_sel_cmov); + witness_commitments.avm_main_sel_external_call = commitment_key->commit(key->avm_main_sel_external_call); witness_commitments.avm_main_sel_halt = commitment_key->commit(key->avm_main_sel_halt); witness_commitments.avm_main_sel_internal_call = commitment_key->commit(key->avm_main_sel_internal_call); witness_commitments.avm_main_sel_internal_return = commitment_key->commit(key->avm_main_sel_internal_return); @@ -617,6 +618,8 @@ void AvmProver::execute_wire_commitments_round() transcript->send_to_verifier(commitment_labels.avm_main_rwc, witness_commitments.avm_main_rwc); transcript->send_to_verifier(commitment_labels.avm_main_rwd, witness_commitments.avm_main_rwd); transcript->send_to_verifier(commitment_labels.avm_main_sel_cmov, witness_commitments.avm_main_sel_cmov); + transcript->send_to_verifier(commitment_labels.avm_main_sel_external_call, + witness_commitments.avm_main_sel_external_call); transcript->send_to_verifier(commitment_labels.avm_main_sel_halt, witness_commitments.avm_main_sel_halt); transcript->send_to_verifier(commitment_labels.avm_main_sel_internal_call, witness_commitments.avm_main_sel_internal_call); diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.hpp index 74d504446a3..3ec501782cd 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.hpp @@ -1,5 +1,5 @@ - + #pragma once #include "barretenberg/commitment_schemes/zeromorph/zeromorph.hpp" #include "barretenberg/plonk/proof_system/types/proof.hpp" @@ -9,56 +9,59 @@ #include "barretenberg/vm/generated/avm_flavor.hpp" -namespace bb { - -class AvmProver { - - using Flavor = AvmFlavor; - using FF = Flavor::FF; - using PCS = Flavor::PCS; - using PCSCommitmentKey = Flavor::CommitmentKey; - using ProvingKey = Flavor::ProvingKey; - using Polynomial = Flavor::Polynomial; - using ProverPolynomials = Flavor::ProverPolynomials; - using CommitmentLabels = Flavor::CommitmentLabels; - using Transcript = Flavor::Transcript; - - public: - explicit AvmProver(std::shared_ptr input_key, std::shared_ptr commitment_key); - - void execute_preamble_round(); - void execute_wire_commitments_round(); - void execute_log_derivative_inverse_round(); - void execute_relation_check_rounds(); - void execute_zeromorph_rounds(); - - HonkProof export_proof(); - HonkProof construct_proof(); - - std::shared_ptr transcript = std::make_shared(); - - std::vector public_inputs; - - bb::RelationParameters relation_parameters; - - std::shared_ptr key; - - // Container for spans of all polynomials required by the prover (i.e. all multivariates evaluated by Sumcheck). - ProverPolynomials prover_polynomials; - - CommitmentLabels commitment_labels; - typename Flavor::WitnessCommitments witness_commitments; - - Polynomial quotient_W; - - SumcheckOutput sumcheck_output; - - std::shared_ptr commitment_key; - - using ZeroMorph = ZeroMorphProver_; - - private: - HonkProof proof; -}; - -} // namespace bb + + namespace bb { + + class AvmProver { + + using Flavor = AvmFlavor; + using FF = Flavor::FF; + using PCS = Flavor::PCS; + using PCSCommitmentKey = Flavor::CommitmentKey; + using ProvingKey = Flavor::ProvingKey; + using Polynomial = Flavor::Polynomial; + using ProverPolynomials = Flavor::ProverPolynomials; + using CommitmentLabels = Flavor::CommitmentLabels; + using Transcript = Flavor::Transcript; + + public: + explicit AvmProver(std::shared_ptr input_key, std::shared_ptr commitment_key); + + void execute_preamble_round(); + void execute_wire_commitments_round(); + void execute_log_derivative_inverse_round(); + void execute_relation_check_rounds(); + void execute_zeromorph_rounds(); + + HonkProof export_proof(); + HonkProof construct_proof(); + + std::shared_ptr transcript = std::make_shared(); + + std::vector public_inputs; + + bb::RelationParameters relation_parameters; + + std::shared_ptr key; + + // Container for spans of all polynomials required by the prover (i.e. all multivariates evaluated by Sumcheck). + ProverPolynomials prover_polynomials; + + CommitmentLabels commitment_labels; + typename Flavor::WitnessCommitments witness_commitments; + + Polynomial quotient_W; + + SumcheckOutput sumcheck_output; + + std::shared_ptr commitment_key; + + using ZeroMorph = ZeroMorphProver_; + + private: + HonkProof proof; + }; + + } // namespace bb + + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp index f659fb269a7..429fca41dc7 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp @@ -376,6 +376,8 @@ bool AvmVerifier::verify_proof(const HonkProof& proof, const std::vectortemplate receive_from_prover(commitment_labels.avm_main_rwd); commitments.avm_main_sel_cmov = transcript->template receive_from_prover(commitment_labels.avm_main_sel_cmov); + commitments.avm_main_sel_external_call = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_external_call); commitments.avm_main_sel_halt = transcript->template receive_from_prover(commitment_labels.avm_main_sel_halt); commitments.avm_main_sel_internal_call = diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.hpp index 2b7e126f1f1..c86de5921f0 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.hpp @@ -3,32 +3,36 @@ #pragma once #include "barretenberg/plonk/proof_system/types/proof.hpp" #include "barretenberg/sumcheck/sumcheck.hpp" -#include "barretenberg/vm/avm_trace/constants.hpp" #include "barretenberg/vm/generated/avm_flavor.hpp" +#include "barretenberg/vm/avm_trace/constants.hpp" -namespace bb { -class AvmVerifier { - using Flavor = AvmFlavor; - using FF = Flavor::FF; - using Commitment = Flavor::Commitment; - using VerificationKey = Flavor::VerificationKey; - using VerifierCommitmentKey = Flavor::VerifierCommitmentKey; - using Transcript = Flavor::Transcript; - - public: - explicit AvmVerifier(std::shared_ptr verifier_key = nullptr); - AvmVerifier(AvmVerifier&& other) noexcept; - AvmVerifier(const AvmVerifier& other) = delete; - - AvmVerifier& operator=(const AvmVerifier& other) = delete; - AvmVerifier& operator=(AvmVerifier&& other) noexcept; - - bool verify_proof(const HonkProof& proof, const std::vector>& public_inputs); - - std::shared_ptr key; - std::map commitments; - std::shared_ptr pcs_verification_key; - std::shared_ptr transcript; -}; - -} // namespace bb + + namespace bb { + class AvmVerifier { + using Flavor = AvmFlavor; + using FF = Flavor::FF; + using Commitment = Flavor::Commitment; + using VerificationKey = Flavor::VerificationKey; + using VerifierCommitmentKey = Flavor::VerifierCommitmentKey; + using Transcript = Flavor::Transcript; + + public: + explicit AvmVerifier(std::shared_ptr verifier_key = nullptr); + AvmVerifier(AvmVerifier&& other) noexcept; + AvmVerifier(const AvmVerifier& other) = delete; + + AvmVerifier& operator=(const AvmVerifier& other) = delete; + AvmVerifier& operator=(AvmVerifier&& other) noexcept; + + bool verify_proof(const HonkProof& proof, const std::vector>& public_inputs); + + std::shared_ptr key; + std::map commitments; + std::shared_ptr pcs_verification_key; + std::shared_ptr transcript; + }; + + } // namespace bb + + + \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp index 6e6b1239423..28a679249b3 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp @@ -1667,7 +1667,7 @@ TEST_F(AvmExecutionTests, kernelOutputStorageOpcodes) // Generate Hint for Sload operation ExecutionHints execution_hints = {}; - execution_hints[0] = FF(42); // side effect counter 0 = value 42 + execution_hints.side_effect_hints[0] = FF(42); // side effect counter 0 = value 42 auto trace = Execution::gen_trace(instructions, returndata, calldata, public_inputs_vec, execution_hints); @@ -1746,9 +1746,9 @@ TEST_F(AvmExecutionTests, kernelOutputHashExistsOpcodes) // Generate Hint for Sload operation ExecutionHints execution_hints = {}; - execution_hints[0] = 1; // Side effect counter 0 = true - execution_hints[1] = 1; // Side effect counter 1 = true - execution_hints[2] = 1; // Side effect counter 2 = true + execution_hints.side_effect_hints[0] = 1; // Side effect counter 0 = true + execution_hints.side_effect_hints[1] = 1; // Side effect counter 1 = true + execution_hints.side_effect_hints[2] = 1; // Side effect counter 2 = true auto trace = Execution::gen_trace(instructions, returndata, calldata, public_inputs_vec, execution_hints); @@ -1797,6 +1797,79 @@ TEST_F(AvmExecutionTests, kernelOutputHashExistsOpcodes) validate_trace(std::move(trace)); } +TEST_F(AvmExecutionTests, opCallOpcodes) +{ + // Sload from a value that has not previously been written to will require a hint to process + // SET gas, addr, args, args size, ret offset, success, function selector in the order they appear for + // simplicity + std::string bytecode_preamble; + // Gas offset preamble + bytecode_preamble += to_hex(OpCode::SET) + // opcode SET for gas offset indirect + "00" // Indirect flag + "03" // U32 + "00000010" // val 16 (address where gas offset is located) + "00000011" + // dst_offset 17 + to_hex(OpCode::SET) + // opcode SET for value stored in gas offset + "00" // Indirect flag + "03" // U32 + "00000011" // val i + "00000000"; + // args offset preamble + bytecode_preamble += to_hex(OpCode::SET) + // opcode SET for args offset indirect + "00" // Indirect flag + "03" // U32 + "00000100" // val i + "00000012" + // dst_offset 0 + to_hex(OpCode::SET) + // opcode SET for value stored in args offset + "00" // Indirect flag + "03" // U32 + "00000012" // val i + "00000001"; + // ret offset preamble + bytecode_preamble += to_hex(OpCode::SET) + // opcode SET for ret offset indirect + "00" // Indirect flag + "03" // U32 + "00000008" // val i + "00000004" + // dst_offset 0 + to_hex(OpCode::SET) + // opcode SET for value stored in ret offset + "00" // Indirect flag + "03" // U32 + "00000002" // val i + "00000007"; + std::string bytecode_hex = bytecode_preamble // SET gas, addr, args size, ret offset, success, function selector + + to_hex(OpCode::CALL) + // opcode CALL + "15" // Indirect flag + "00000000" // gas offset + "00000001" // addr offset + "00000002" // args offset + "00000003" // args size offset + "00000004" // ret offset + "00000007" // ret size + "0000000a" // success offset + "00000006" // function_selector_offset + + to_hex(OpCode::RETURN) + // opcode RETURN + "00" // Indirect flag + "00000008" // ret offset 8 + "00000003"; // ret size 3 + + auto bytecode = hex_to_bytes(bytecode_hex); + auto instructions = Deserialization::parse(bytecode); + + // ASSERT_THAT(instructions, SizeIs(3)); + + std::vector calldata = {}; + std::vector returndata = {}; + + // Generate Hint for call operation + ExecutionHints execution_hints = {}; + execution_hints.returndata_hints.push_back({ 9, 8 }); // Return data + + auto trace = Execution::gen_trace(instructions, returndata, calldata, public_inputs_vec, execution_hints); + EXPECT_EQ(returndata, std::vector({ 9, 8, 1 })); // The 1 represents the success + + validate_trace(std::move(trace)); +} + // Negative test detecting an invalid opcode byte. TEST_F(AvmExecutionTests, invalidOpcode) { diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp index b17cbc308a2..4776b01ac7c 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp @@ -733,7 +733,7 @@ TEST_F(AvmKernelOutputPositiveTests, kernelSload) // Provide a hint for sload value slot ExecutionHints execution_hints; - execution_hints[0] = FF(value); // side effect counter -> value + execution_hints.side_effect_hints[0] = FF(value); // side effect counter -> value auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_set(0, static_cast(slot), slot_offset, AvmMemoryTag::FF); @@ -808,7 +808,7 @@ TEST_F(AvmKernelOutputPositiveTests, kernelNoteHashExists) auto exists = 1; ExecutionHints execution_hints = {}; - execution_hints[0] = exists; // side effect counter -> value + execution_hints.side_effect_hints[0] = exists; // side effect counter -> value auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_set(0, static_cast(value), value_offset, AvmMemoryTag::FF); @@ -847,7 +847,7 @@ TEST_F(AvmKernelOutputPositiveTests, kernelNullifierExists) auto exists = 1; ExecutionHints execution_hints = {}; - execution_hints[0] = exists; // side effect counter -> value + execution_hints.side_effect_hints[0] = exists; // side effect counter -> value auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_set(0, static_cast(value), value_offset, AvmMemoryTag::FF); @@ -886,7 +886,7 @@ TEST_F(AvmKernelOutputPositiveTests, kernelL1ToL2MsgExists) // Create an execution hints object with the result of the operation ExecutionHints execution_hints = {}; - execution_hints[0] = exists; + execution_hints.side_effect_hints[0] = exists; auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_set(0, static_cast(value), value_offset, AvmMemoryTag::FF); @@ -916,4 +916,4 @@ TEST_F(AvmKernelOutputPositiveTests, kernelL1ToL2MsgExists) test_kernel_lookup(apply_opcodes, checks, execution_hints); } -} // namespace tests_avm \ No newline at end of file +} // namespace tests_avm diff --git a/yarn-project/circuits.js/src/scripts/constants.in.ts b/yarn-project/circuits.js/src/scripts/constants.in.ts index da2f6d4f221..8d8109cbd4d 100644 --- a/yarn-project/circuits.js/src/scripts/constants.in.ts +++ b/yarn-project/circuits.js/src/scripts/constants.in.ts @@ -25,6 +25,7 @@ const CPP_CONSTANTS = [ 'READ_REQUEST_LENGTH', 'MAX_NOTE_HASH_READ_REQUESTS_PER_CALL', 'MAX_NULLIFIER_READ_REQUESTS_PER_CALL', + 'MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL', 'MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL', 'MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL', 'CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH', From 70aa415caaed5159b997abf1bd873de8547d657f Mon Sep 17 00:00:00 2001 From: IlyasRidhuan Date: Tue, 4 Jun 2024 06:38:13 +0000 Subject: [PATCH 19/20] fix: formatter + cleanup --- .../relations/generated/avm/avm_alu.hpp | 2354 +++++++++-------- .../relations/generated/avm/avm_binary.hpp | 296 +-- .../generated/avm/avm_conversion.hpp | 65 +- .../generated/avm/avm_keccakf1600.hpp | 65 +- .../relations/generated/avm/avm_kernel.hpp | 332 ++- .../relations/generated/avm/avm_mem.hpp | 982 ++++--- .../relations/generated/avm/avm_pedersen.hpp | 65 +- .../relations/generated/avm/avm_poseidon2.hpp | 65 +- .../relations/generated/avm/avm_sha256.hpp | 65 +- .../generated/avm/incl_main_tag_err.hpp | 317 ++- .../generated/avm/incl_mem_tag_err.hpp | 316 ++- .../generated/avm/kernel_output_lookup.hpp | 341 ++- .../generated/avm/lookup_byte_lengths.hpp | 325 ++- .../generated/avm/lookup_byte_operations.hpp | 341 ++- .../generated/avm/lookup_div_u16_0.hpp | 316 ++- .../generated/avm/lookup_div_u16_1.hpp | 316 ++- .../generated/avm/lookup_div_u16_2.hpp | 316 ++- .../generated/avm/lookup_div_u16_3.hpp | 316 ++- .../generated/avm/lookup_div_u16_4.hpp | 316 ++- .../generated/avm/lookup_div_u16_5.hpp | 316 ++- .../generated/avm/lookup_div_u16_6.hpp | 316 ++- .../generated/avm/lookup_div_u16_7.hpp | 316 ++- .../generated/avm/lookup_into_kernel.hpp | 325 ++- .../generated/avm/lookup_mem_rng_chk_hi.hpp | 317 ++- .../generated/avm/lookup_mem_rng_chk_lo.hpp | 317 ++- .../generated/avm/lookup_mem_rng_chk_mid.hpp | 317 ++- .../generated/avm/lookup_opcode_gas.hpp | 333 ++- .../generated/avm/lookup_pow_2_0.hpp | 324 ++- .../generated/avm/lookup_pow_2_1.hpp | 324 ++- .../relations/generated/avm/lookup_u16_0.hpp | 316 ++- .../relations/generated/avm/lookup_u16_1.hpp | 316 ++- .../relations/generated/avm/lookup_u16_10.hpp | 316 ++- .../relations/generated/avm/lookup_u16_11.hpp | 316 ++- .../relations/generated/avm/lookup_u16_12.hpp | 316 ++- .../relations/generated/avm/lookup_u16_13.hpp | 316 ++- .../relations/generated/avm/lookup_u16_14.hpp | 316 ++- .../relations/generated/avm/lookup_u16_2.hpp | 316 ++- .../relations/generated/avm/lookup_u16_3.hpp | 316 ++- .../relations/generated/avm/lookup_u16_4.hpp | 316 ++- .../relations/generated/avm/lookup_u16_5.hpp | 316 ++- .../relations/generated/avm/lookup_u16_6.hpp | 316 ++- .../relations/generated/avm/lookup_u16_7.hpp | 316 ++- .../relations/generated/avm/lookup_u16_8.hpp | 316 ++- .../relations/generated/avm/lookup_u16_9.hpp | 316 ++- .../relations/generated/avm/lookup_u8_0.hpp | 316 ++- .../relations/generated/avm/lookup_u8_1.hpp | 316 ++- .../relations/generated/avm/perm_main_alu.hpp | 295 +-- .../relations/generated/avm/perm_main_bin.hpp | 215 +- .../generated/avm/perm_main_conv.hpp | 199 +- .../generated/avm/perm_main_mem_a.hpp | 239 +- .../generated/avm/perm_main_mem_b.hpp | 239 +- .../generated/avm/perm_main_mem_c.hpp | 223 +- .../generated/avm/perm_main_mem_d.hpp | 231 +- .../generated/avm/perm_main_mem_ind_a.hpp | 199 +- .../generated/avm/perm_main_mem_ind_b.hpp | 199 +- .../generated/avm/perm_main_mem_ind_c.hpp | 199 +- .../generated/avm/perm_main_mem_ind_d.hpp | 199 +- .../generated/avm/perm_main_pedersen.hpp | 183 +- .../generated/avm/perm_main_pos2_perm.hpp | 191 +- .../barretenberg/vm/avm_trace/avm_trace.cpp | 38 +- .../vm/generated/avm_composer.cpp | 12 +- .../vm/generated/avm_composer.hpp | 112 +- .../barretenberg/vm/generated/avm_prover.hpp | 111 +- .../vm/generated/avm_verifier.hpp | 58 +- .../vm/tests/avm_execution.test.cpp | 5 - 65 files changed, 9421 insertions(+), 9812 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_alu.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_alu.hpp index 00b9bbc203b..2022d640185 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_alu.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_alu.hpp @@ -6,1165 +6,1215 @@ namespace bb::Avm_vm { -template struct Avm_aluRow { - FF avm_alu_a_hi {}; - FF avm_alu_a_hi_shift {}; - FF avm_alu_a_lo {}; - FF avm_alu_a_lo_shift {}; - FF avm_alu_alu_sel {}; - FF avm_alu_alu_sel_shift {}; - FF avm_alu_b_hi {}; - FF avm_alu_b_hi_shift {}; - FF avm_alu_b_lo {}; - FF avm_alu_b_lo_shift {}; - FF avm_alu_borrow {}; - FF avm_alu_cf {}; - FF avm_alu_cmp_rng_ctr {}; - FF avm_alu_cmp_rng_ctr_shift {}; - FF avm_alu_cmp_sel {}; - FF avm_alu_cmp_sel_shift {}; - FF avm_alu_div_rng_chk_selector {}; - FF avm_alu_div_rng_chk_selector_shift {}; - FF avm_alu_div_u16_r0 {}; - FF avm_alu_div_u16_r0_shift {}; - FF avm_alu_div_u16_r1 {}; - FF avm_alu_div_u16_r1_shift {}; - FF avm_alu_div_u16_r2 {}; - FF avm_alu_div_u16_r2_shift {}; - FF avm_alu_div_u16_r3 {}; - FF avm_alu_div_u16_r3_shift {}; - FF avm_alu_div_u16_r4 {}; - FF avm_alu_div_u16_r4_shift {}; - FF avm_alu_div_u16_r5 {}; - FF avm_alu_div_u16_r5_shift {}; - FF avm_alu_div_u16_r6 {}; - FF avm_alu_div_u16_r6_shift {}; - FF avm_alu_div_u16_r7 {}; - FF avm_alu_div_u16_r7_shift {}; - FF avm_alu_divisor_hi {}; - FF avm_alu_divisor_lo {}; - FF avm_alu_ff_tag {}; - FF avm_alu_ia {}; - FF avm_alu_ib {}; - FF avm_alu_ic {}; - FF avm_alu_in_tag {}; - FF avm_alu_op_add {}; - FF avm_alu_op_add_shift {}; - FF avm_alu_op_cast {}; - FF avm_alu_op_cast_prev {}; - FF avm_alu_op_cast_prev_shift {}; - FF avm_alu_op_cast_shift {}; - FF avm_alu_op_div {}; - FF avm_alu_op_div_a_lt_b {}; - FF avm_alu_op_div_shift {}; - FF avm_alu_op_div_std {}; - FF avm_alu_op_eq {}; - FF avm_alu_op_eq_diff_inv {}; - FF avm_alu_op_lt {}; - FF avm_alu_op_lte {}; - FF avm_alu_op_mul {}; - FF avm_alu_op_mul_shift {}; - FF avm_alu_op_not {}; - FF avm_alu_op_shl {}; - FF avm_alu_op_shl_shift {}; - FF avm_alu_op_shr {}; - FF avm_alu_op_shr_shift {}; - FF avm_alu_op_sub {}; - FF avm_alu_op_sub_shift {}; - FF avm_alu_p_a_borrow {}; - FF avm_alu_p_b_borrow {}; - FF avm_alu_p_sub_a_hi {}; - FF avm_alu_p_sub_a_hi_shift {}; - FF avm_alu_p_sub_a_lo {}; - FF avm_alu_p_sub_a_lo_shift {}; - FF avm_alu_p_sub_b_hi {}; - FF avm_alu_p_sub_b_hi_shift {}; - FF avm_alu_p_sub_b_lo {}; - FF avm_alu_p_sub_b_lo_shift {}; - FF avm_alu_partial_prod_hi {}; - FF avm_alu_partial_prod_lo {}; - FF avm_alu_quotient_hi {}; - FF avm_alu_quotient_lo {}; - FF avm_alu_remainder {}; - FF avm_alu_res_hi {}; - FF avm_alu_res_lo {}; - FF avm_alu_rng_chk_lookup_selector_shift {}; - FF avm_alu_rng_chk_sel {}; - FF avm_alu_rng_chk_sel_shift {}; - FF avm_alu_shift_lt_bit_len {}; - FF avm_alu_shift_sel {}; - FF avm_alu_t_sub_s_bits {}; - FF avm_alu_two_pow_s {}; - FF avm_alu_two_pow_t_sub_s {}; - FF avm_alu_u128_tag {}; - FF avm_alu_u16_r0 {}; - FF avm_alu_u16_r0_shift {}; - FF avm_alu_u16_r1 {}; - FF avm_alu_u16_r10 {}; - FF avm_alu_u16_r11 {}; - FF avm_alu_u16_r12 {}; - FF avm_alu_u16_r13 {}; - FF avm_alu_u16_r14 {}; - FF avm_alu_u16_r1_shift {}; - FF avm_alu_u16_r2 {}; - FF avm_alu_u16_r2_shift {}; - FF avm_alu_u16_r3 {}; - FF avm_alu_u16_r3_shift {}; - FF avm_alu_u16_r4 {}; - FF avm_alu_u16_r4_shift {}; - FF avm_alu_u16_r5 {}; - FF avm_alu_u16_r5_shift {}; - FF avm_alu_u16_r6 {}; - FF avm_alu_u16_r6_shift {}; - FF avm_alu_u16_r7 {}; - FF avm_alu_u16_r8 {}; - FF avm_alu_u16_r9 {}; - FF avm_alu_u16_tag {}; - FF avm_alu_u32_tag {}; - FF avm_alu_u64_tag {}; - FF avm_alu_u8_r0 {}; - FF avm_alu_u8_r0_shift {}; - FF avm_alu_u8_r1 {}; - FF avm_alu_u8_r1_shift {}; - FF avm_alu_u8_tag {}; - }; - - - inline std::string get_relation_label_avm_alu(int index) { - switch (index) { - case 12: - return "ALU_ADD_SUB_1"; - -case 13: - return "ALU_ADD_SUB_2"; - -case 14: - return "ALU_MULTIPLICATION_FF"; - -case 15: - return "ALU_MUL_COMMON_1"; - -case 16: - return "ALU_MUL_COMMON_2"; - -case 19: - return "ALU_MULTIPLICATION_OUT_U128"; - -case 20: - return "ALU_FF_NOT_XOR"; - -case 21: - return "ALU_OP_NOT"; - -case 22: - return "ALU_RES_IS_BOOL"; - -case 23: - return "ALU_OP_EQ"; - -case 24: - return "INPUT_DECOMP_1"; - -case 25: - return "INPUT_DECOMP_2"; - -case 27: - return "SUB_LO_1"; - -case 28: - return "SUB_HI_1"; - -case 30: - return "SUB_LO_2"; - -case 31: - return "SUB_HI_2"; - -case 32: - return "RES_LO"; - -case 33: - return "RES_HI"; - -case 34: - return "CMP_CTR_REL_1"; - -case 35: - return "CMP_CTR_REL_2"; - -case 38: - return "CTR_NON_ZERO_REL"; - -case 39: - return "RNG_CHK_LOOKUP_SELECTOR"; - -case 40: - return "LOWER_CMP_RNG_CHK"; - -case 41: - return "UPPER_CMP_RNG_CHK"; - -case 42: - return "SHIFT_RELS_0"; - -case 44: - return "SHIFT_RELS_1"; - -case 46: - return "SHIFT_RELS_2"; - -case 48: - return "SHIFT_RELS_3"; - -case 50: - return "OP_CAST_PREV_LINE"; - -case 51: - return "ALU_OP_CAST"; - -case 52: - return "OP_CAST_RNG_CHECK_P_SUB_A_LOW"; - -case 53: - return "OP_CAST_RNG_CHECK_P_SUB_A_HIGH"; - -case 54: - return "TWO_LINE_OP_NO_OVERLAP"; - -case 55: - return "SHR_RANGE_0"; - -case 56: - return "SHR_RANGE_1"; - -case 57: - return "SHL_RANGE_0"; - -case 58: - return "SHL_RANGE_1"; - -case 60: - return "SHIFT_LT_BIT_LEN"; - -case 61: - return "SHR_INPUT_DECOMPOSITION"; - -case 62: - return "SHR_OUTPUT"; - -case 63: - return "SHL_INPUT_DECOMPOSITION"; - -case 64: - return "SHL_OUTPUT"; - -case 74: - return "ALU_PROD_DIV"; - -case 75: - return "REMAINDER_RANGE_CHK"; - -case 76: - return "CMP_CTR_REL_3"; - -case 78: - return "DIVISION_RELATION"; - - } - return std::to_string(index); +template struct Avm_aluRow { + FF avm_alu_a_hi{}; + FF avm_alu_a_hi_shift{}; + FF avm_alu_a_lo{}; + FF avm_alu_a_lo_shift{}; + FF avm_alu_alu_sel{}; + FF avm_alu_alu_sel_shift{}; + FF avm_alu_b_hi{}; + FF avm_alu_b_hi_shift{}; + FF avm_alu_b_lo{}; + FF avm_alu_b_lo_shift{}; + FF avm_alu_borrow{}; + FF avm_alu_cf{}; + FF avm_alu_cmp_rng_ctr{}; + FF avm_alu_cmp_rng_ctr_shift{}; + FF avm_alu_cmp_sel{}; + FF avm_alu_cmp_sel_shift{}; + FF avm_alu_div_rng_chk_selector{}; + FF avm_alu_div_rng_chk_selector_shift{}; + FF avm_alu_div_u16_r0{}; + FF avm_alu_div_u16_r0_shift{}; + FF avm_alu_div_u16_r1{}; + FF avm_alu_div_u16_r1_shift{}; + FF avm_alu_div_u16_r2{}; + FF avm_alu_div_u16_r2_shift{}; + FF avm_alu_div_u16_r3{}; + FF avm_alu_div_u16_r3_shift{}; + FF avm_alu_div_u16_r4{}; + FF avm_alu_div_u16_r4_shift{}; + FF avm_alu_div_u16_r5{}; + FF avm_alu_div_u16_r5_shift{}; + FF avm_alu_div_u16_r6{}; + FF avm_alu_div_u16_r6_shift{}; + FF avm_alu_div_u16_r7{}; + FF avm_alu_div_u16_r7_shift{}; + FF avm_alu_divisor_hi{}; + FF avm_alu_divisor_lo{}; + FF avm_alu_ff_tag{}; + FF avm_alu_ia{}; + FF avm_alu_ib{}; + FF avm_alu_ic{}; + FF avm_alu_in_tag{}; + FF avm_alu_op_add{}; + FF avm_alu_op_add_shift{}; + FF avm_alu_op_cast{}; + FF avm_alu_op_cast_prev{}; + FF avm_alu_op_cast_prev_shift{}; + FF avm_alu_op_cast_shift{}; + FF avm_alu_op_div{}; + FF avm_alu_op_div_a_lt_b{}; + FF avm_alu_op_div_shift{}; + FF avm_alu_op_div_std{}; + FF avm_alu_op_eq{}; + FF avm_alu_op_eq_diff_inv{}; + FF avm_alu_op_lt{}; + FF avm_alu_op_lte{}; + FF avm_alu_op_mul{}; + FF avm_alu_op_mul_shift{}; + FF avm_alu_op_not{}; + FF avm_alu_op_shl{}; + FF avm_alu_op_shl_shift{}; + FF avm_alu_op_shr{}; + FF avm_alu_op_shr_shift{}; + FF avm_alu_op_sub{}; + FF avm_alu_op_sub_shift{}; + FF avm_alu_p_a_borrow{}; + FF avm_alu_p_b_borrow{}; + FF avm_alu_p_sub_a_hi{}; + FF avm_alu_p_sub_a_hi_shift{}; + FF avm_alu_p_sub_a_lo{}; + FF avm_alu_p_sub_a_lo_shift{}; + FF avm_alu_p_sub_b_hi{}; + FF avm_alu_p_sub_b_hi_shift{}; + FF avm_alu_p_sub_b_lo{}; + FF avm_alu_p_sub_b_lo_shift{}; + FF avm_alu_partial_prod_hi{}; + FF avm_alu_partial_prod_lo{}; + FF avm_alu_quotient_hi{}; + FF avm_alu_quotient_lo{}; + FF avm_alu_remainder{}; + FF avm_alu_res_hi{}; + FF avm_alu_res_lo{}; + FF avm_alu_rng_chk_lookup_selector_shift{}; + FF avm_alu_rng_chk_sel{}; + FF avm_alu_rng_chk_sel_shift{}; + FF avm_alu_shift_lt_bit_len{}; + FF avm_alu_shift_sel{}; + FF avm_alu_t_sub_s_bits{}; + FF avm_alu_two_pow_s{}; + FF avm_alu_two_pow_t_sub_s{}; + FF avm_alu_u128_tag{}; + FF avm_alu_u16_r0{}; + FF avm_alu_u16_r0_shift{}; + FF avm_alu_u16_r1{}; + FF avm_alu_u16_r10{}; + FF avm_alu_u16_r11{}; + FF avm_alu_u16_r12{}; + FF avm_alu_u16_r13{}; + FF avm_alu_u16_r14{}; + FF avm_alu_u16_r1_shift{}; + FF avm_alu_u16_r2{}; + FF avm_alu_u16_r2_shift{}; + FF avm_alu_u16_r3{}; + FF avm_alu_u16_r3_shift{}; + FF avm_alu_u16_r4{}; + FF avm_alu_u16_r4_shift{}; + FF avm_alu_u16_r5{}; + FF avm_alu_u16_r5_shift{}; + FF avm_alu_u16_r6{}; + FF avm_alu_u16_r6_shift{}; + FF avm_alu_u16_r7{}; + FF avm_alu_u16_r8{}; + FF avm_alu_u16_r9{}; + FF avm_alu_u16_tag{}; + FF avm_alu_u32_tag{}; + FF avm_alu_u64_tag{}; + FF avm_alu_u8_r0{}; + FF avm_alu_u8_r0_shift{}; + FF avm_alu_u8_r1{}; + FF avm_alu_u8_r1_shift{}; + FF avm_alu_u8_tag{}; +}; + +inline std::string get_relation_label_avm_alu(int index) +{ + switch (index) { + case 12: + return "ALU_ADD_SUB_1"; + + case 13: + return "ALU_ADD_SUB_2"; + + case 14: + return "ALU_MULTIPLICATION_FF"; + + case 15: + return "ALU_MUL_COMMON_1"; + + case 16: + return "ALU_MUL_COMMON_2"; + + case 19: + return "ALU_MULTIPLICATION_OUT_U128"; + + case 20: + return "ALU_FF_NOT_XOR"; + + case 21: + return "ALU_OP_NOT"; + + case 22: + return "ALU_RES_IS_BOOL"; + + case 23: + return "ALU_OP_EQ"; + + case 24: + return "INPUT_DECOMP_1"; + + case 25: + return "INPUT_DECOMP_2"; + + case 27: + return "SUB_LO_1"; + + case 28: + return "SUB_HI_1"; + + case 30: + return "SUB_LO_2"; + + case 31: + return "SUB_HI_2"; + + case 32: + return "RES_LO"; + + case 33: + return "RES_HI"; + + case 34: + return "CMP_CTR_REL_1"; + + case 35: + return "CMP_CTR_REL_2"; + + case 38: + return "CTR_NON_ZERO_REL"; + + case 39: + return "RNG_CHK_LOOKUP_SELECTOR"; + + case 40: + return "LOWER_CMP_RNG_CHK"; + + case 41: + return "UPPER_CMP_RNG_CHK"; + + case 42: + return "SHIFT_RELS_0"; + + case 44: + return "SHIFT_RELS_1"; + + case 46: + return "SHIFT_RELS_2"; + + case 48: + return "SHIFT_RELS_3"; + + case 50: + return "OP_CAST_PREV_LINE"; + + case 51: + return "ALU_OP_CAST"; + + case 52: + return "OP_CAST_RNG_CHECK_P_SUB_A_LOW"; + + case 53: + return "OP_CAST_RNG_CHECK_P_SUB_A_HIGH"; + + case 54: + return "TWO_LINE_OP_NO_OVERLAP"; + + case 55: + return "SHR_RANGE_0"; + + case 56: + return "SHR_RANGE_1"; + + case 57: + return "SHL_RANGE_0"; + + case 58: + return "SHL_RANGE_1"; + + case 60: + return "SHIFT_LT_BIT_LEN"; + + case 61: + return "SHR_INPUT_DECOMPOSITION"; + + case 62: + return "SHR_OUTPUT"; + + case 63: + return "SHL_INPUT_DECOMPOSITION"; + + case 64: + return "SHL_OUTPUT"; + + case 74: + return "ALU_PROD_DIV"; + + case 75: + return "REMAINDER_RANGE_CHK"; + + case 76: + return "CMP_CTR_REL_3"; + + case 78: + return "DIVISION_RELATION"; } - + return std::to_string(index); +} template class avm_aluImpl { - public: - using FF = FF_; - - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 2, - 2, - 2, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 4, - 5, - 5, - 5, - 5, - 6, - 6, - 8, - 3, - 4, - 4, - 5, - 4, - 4, - 3, - 4, - 3, - 3, - 4, - 3, - 6, - 5, - 3, - 3, - 3, - 3, - 4, - 3, - 4, - 4, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 2, - 5, - 3, - 3, - 4, - 4, - 4, - 4, - 4, - 3, - 5, - 5, - 4, - 5, - 5, - 2, - 3, - 3, - 3, - 3, - 3, - 4, - 4, - 3, - 5, - 3, - 3, - 3, - 5, - 3, - 3, - 4, - 4, - 4, - 4, - 4, - 4, -}; - - + public: + using FF = FF_; + + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 5, 5, 5, 6, 6, 8, 3, 4, 4, 5, 4, 4, 3, 4, 3, + 3, 4, 3, 6, 5, 3, 3, 3, 3, 4, 3, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 2, 5, 3, 3, 4, 4, 4, 4, + 4, 3, 5, 5, 4, 5, 5, 2, 3, 3, 3, 3, 3, 4, 4, 3, 5, 3, 3, 3, 5, 3, 3, 4, 4, 4, 4, 4, 4, + }; + template - void static accumulate( - ContainerOverSubrelations& evals, - const AllEntities& new_term, - [[maybe_unused]] const RelationParameters&, - [[maybe_unused]] const FF& scaling_factor - ){ - - //Contribution 0 - { -Avm_DECLARE_VIEWS(0); - - - auto tmp = (avm_alu_alu_sel - ((((((((((avm_alu_op_add + avm_alu_op_sub) + avm_alu_op_mul) + avm_alu_op_not) + avm_alu_op_eq) + avm_alu_op_cast) + avm_alu_op_lt) + avm_alu_op_lte) + avm_alu_op_shr) + avm_alu_op_shl) + avm_alu_op_div)); - tmp *= scaling_factor; - std::get<0>(evals) += tmp; -} -//Contribution 1 - { -Avm_DECLARE_VIEWS(1); - - - auto tmp = (avm_alu_cmp_sel - (avm_alu_op_lt + avm_alu_op_lte)); - tmp *= scaling_factor; - std::get<1>(evals) += tmp; -} -//Contribution 2 - { -Avm_DECLARE_VIEWS(2); - - - auto tmp = (avm_alu_shift_sel - (avm_alu_op_shl + avm_alu_op_shr)); - tmp *= scaling_factor; - std::get<2>(evals) += tmp; -} -//Contribution 3 - { -Avm_DECLARE_VIEWS(3); - - - auto tmp = (avm_alu_cf * (-avm_alu_cf + FF(1))); - tmp *= scaling_factor; - std::get<3>(evals) += tmp; -} -//Contribution 4 - { -Avm_DECLARE_VIEWS(4); - - - auto tmp = (avm_alu_ff_tag * (-avm_alu_ff_tag + FF(1))); - tmp *= scaling_factor; - std::get<4>(evals) += tmp; -} -//Contribution 5 - { -Avm_DECLARE_VIEWS(5); - - - auto tmp = (avm_alu_u8_tag * (-avm_alu_u8_tag + FF(1))); - tmp *= scaling_factor; - std::get<5>(evals) += tmp; -} -//Contribution 6 - { -Avm_DECLARE_VIEWS(6); - - - auto tmp = (avm_alu_u16_tag * (-avm_alu_u16_tag + FF(1))); - tmp *= scaling_factor; - std::get<6>(evals) += tmp; -} -//Contribution 7 - { -Avm_DECLARE_VIEWS(7); - - - auto tmp = (avm_alu_u32_tag * (-avm_alu_u32_tag + FF(1))); - tmp *= scaling_factor; - std::get<7>(evals) += tmp; -} -//Contribution 8 - { -Avm_DECLARE_VIEWS(8); - - - auto tmp = (avm_alu_u64_tag * (-avm_alu_u64_tag + FF(1))); - tmp *= scaling_factor; - std::get<8>(evals) += tmp; -} -//Contribution 9 - { -Avm_DECLARE_VIEWS(9); - - - auto tmp = (avm_alu_u128_tag * (-avm_alu_u128_tag + FF(1))); - tmp *= scaling_factor; - std::get<9>(evals) += tmp; -} -//Contribution 10 - { -Avm_DECLARE_VIEWS(10); - - - auto tmp = (avm_alu_alu_sel * ((((((avm_alu_ff_tag + avm_alu_u8_tag) + avm_alu_u16_tag) + avm_alu_u32_tag) + avm_alu_u64_tag) + avm_alu_u128_tag) - FF(1))); - tmp *= scaling_factor; - std::get<10>(evals) += tmp; -} -//Contribution 11 - { -Avm_DECLARE_VIEWS(11); - - - auto tmp = (avm_alu_in_tag - (((((avm_alu_u8_tag + (avm_alu_u16_tag * FF(2))) + (avm_alu_u32_tag * FF(3))) + (avm_alu_u64_tag * FF(4))) + (avm_alu_u128_tag * FF(5))) + (avm_alu_ff_tag * FF(6)))); - tmp *= scaling_factor; - std::get<11>(evals) += tmp; -} -//Contribution 12 - { -Avm_DECLARE_VIEWS(12); - - - auto tmp = (((avm_alu_op_add + avm_alu_op_sub) * ((((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + (avm_alu_u16_r1 * FF(4294967296UL))) + (avm_alu_u16_r2 * FF(281474976710656UL))) + (avm_alu_u16_r3 * FF(uint256_t{0UL, 1UL, 0UL, 0UL}))) + (avm_alu_u16_r4 * FF(uint256_t{0UL, 65536UL, 0UL, 0UL}))) + (avm_alu_u16_r5 * FF(uint256_t{0UL, 4294967296UL, 0UL, 0UL}))) + (avm_alu_u16_r6 * FF(uint256_t{0UL, 281474976710656UL, 0UL, 0UL}))) - avm_alu_ia) + (avm_alu_ff_tag * avm_alu_ic))) + ((avm_alu_op_add - avm_alu_op_sub) * ((avm_alu_cf * FF(uint256_t{0UL, 0UL, 1UL, 0UL})) - avm_alu_ib))); - tmp *= scaling_factor; - std::get<12>(evals) += tmp; -} -//Contribution 13 - { -Avm_DECLARE_VIEWS(13); - - - auto tmp = (((avm_alu_op_add + avm_alu_op_sub) * (((((((avm_alu_u8_tag * avm_alu_u8_r0) + (avm_alu_u16_tag * (avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))))) + (avm_alu_u32_tag * ((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))))) + (avm_alu_u64_tag * ((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + (avm_alu_u16_r1 * FF(4294967296UL))) + (avm_alu_u16_r2 * FF(281474976710656UL))))) + (avm_alu_u128_tag * ((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + (avm_alu_u16_r1 * FF(4294967296UL))) + (avm_alu_u16_r2 * FF(281474976710656UL))) + (avm_alu_u16_r3 * FF(uint256_t{0UL, 1UL, 0UL, 0UL}))) + (avm_alu_u16_r4 * FF(uint256_t{0UL, 65536UL, 0UL, 0UL}))) + (avm_alu_u16_r5 * FF(uint256_t{0UL, 4294967296UL, 0UL, 0UL}))) + (avm_alu_u16_r6 * FF(uint256_t{0UL, 281474976710656UL, 0UL, 0UL}))))) + (avm_alu_ff_tag * avm_alu_ia)) - avm_alu_ic)) + ((avm_alu_ff_tag * (avm_alu_op_add - avm_alu_op_sub)) * avm_alu_ib)); - tmp *= scaling_factor; - std::get<13>(evals) += tmp; -} -//Contribution 14 - { -Avm_DECLARE_VIEWS(14); - - - auto tmp = ((avm_alu_ff_tag * avm_alu_op_mul) * ((avm_alu_ia * avm_alu_ib) - avm_alu_ic)); - tmp *= scaling_factor; - std::get<14>(evals) += tmp; -} -//Contribution 15 - { -Avm_DECLARE_VIEWS(15); - - - auto tmp = ((((-avm_alu_ff_tag + FF(1)) - avm_alu_u128_tag) * avm_alu_op_mul) * (((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + (avm_alu_u16_r1 * FF(4294967296UL))) + (avm_alu_u16_r2 * FF(281474976710656UL))) + (avm_alu_u16_r3 * FF(uint256_t{0UL, 1UL, 0UL, 0UL}))) + (avm_alu_u16_r4 * FF(uint256_t{0UL, 65536UL, 0UL, 0UL}))) + (avm_alu_u16_r5 * FF(uint256_t{0UL, 4294967296UL, 0UL, 0UL}))) + (avm_alu_u16_r6 * FF(uint256_t{0UL, 281474976710656UL, 0UL, 0UL}))) - (avm_alu_ia * avm_alu_ib))); - tmp *= scaling_factor; - std::get<15>(evals) += tmp; -} -//Contribution 16 - { -Avm_DECLARE_VIEWS(16); - - - auto tmp = (avm_alu_op_mul * (((((avm_alu_u8_tag * avm_alu_u8_r0) + (avm_alu_u16_tag * (avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))))) + (avm_alu_u32_tag * ((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))))) + (avm_alu_u64_tag * ((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + (avm_alu_u16_r1 * FF(4294967296UL))) + (avm_alu_u16_r2 * FF(281474976710656UL))))) - (((-avm_alu_ff_tag + FF(1)) - avm_alu_u128_tag) * avm_alu_ic))); - tmp *= scaling_factor; - std::get<16>(evals) += tmp; -} -//Contribution 17 - { -Avm_DECLARE_VIEWS(17); - - - auto tmp = ((avm_alu_u128_tag * avm_alu_op_mul) * ((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + (avm_alu_u16_r1 * FF(4294967296UL))) + (avm_alu_u16_r2 * FF(281474976710656UL))) + ((((avm_alu_u16_r3 + (avm_alu_u16_r4 * FF(65536))) + (avm_alu_u16_r5 * FF(4294967296UL))) + (avm_alu_u16_r6 * FF(281474976710656UL))) * FF(uint256_t{0UL, 1UL, 0UL, 0UL}))) - avm_alu_ia)); - tmp *= scaling_factor; - std::get<17>(evals) += tmp; -} -//Contribution 18 - { -Avm_DECLARE_VIEWS(18); - - - auto tmp = ((avm_alu_u128_tag * avm_alu_op_mul) * ((((((avm_alu_u8_r0_shift + (avm_alu_u8_r1_shift * FF(256))) + (avm_alu_u16_r0_shift * FF(65536))) + (avm_alu_u16_r1_shift * FF(4294967296UL))) + (avm_alu_u16_r2_shift * FF(281474976710656UL))) + ((((avm_alu_u16_r3_shift + (avm_alu_u16_r4_shift * FF(65536))) + (avm_alu_u16_r5_shift * FF(4294967296UL))) + (avm_alu_u16_r6_shift * FF(281474976710656UL))) * FF(uint256_t{0UL, 1UL, 0UL, 0UL}))) - avm_alu_ib)); - tmp *= scaling_factor; - std::get<18>(evals) += tmp; -} -//Contribution 19 - { -Avm_DECLARE_VIEWS(19); - - - auto tmp = ((avm_alu_u128_tag * avm_alu_op_mul) * ((((avm_alu_ia * ((((avm_alu_u8_r0_shift + (avm_alu_u8_r1_shift * FF(256))) + (avm_alu_u16_r0_shift * FF(65536))) + (avm_alu_u16_r1_shift * FF(4294967296UL))) + (avm_alu_u16_r2_shift * FF(281474976710656UL)))) + ((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + (avm_alu_u16_r1 * FF(4294967296UL))) + (avm_alu_u16_r2 * FF(281474976710656UL))) * (((avm_alu_u16_r3_shift + (avm_alu_u16_r4_shift * FF(65536))) + (avm_alu_u16_r5_shift * FF(4294967296UL))) + (avm_alu_u16_r6_shift * FF(281474976710656UL)))) * FF(uint256_t{0UL, 1UL, 0UL, 0UL}))) - (((avm_alu_cf * FF(uint256_t{0UL, 1UL, 0UL, 0UL})) + (((avm_alu_u16_r7 + (avm_alu_u16_r8 * FF(65536))) + (avm_alu_u16_r9 * FF(4294967296UL))) + (avm_alu_u16_r10 * FF(281474976710656UL)))) * FF(uint256_t{0UL, 0UL, 1UL, 0UL}))) - avm_alu_ic)); - tmp *= scaling_factor; - std::get<19>(evals) += tmp; -} -//Contribution 20 - { -Avm_DECLARE_VIEWS(20); - - - auto tmp = (avm_alu_op_not * avm_alu_ff_tag); - tmp *= scaling_factor; - std::get<20>(evals) += tmp; -} -//Contribution 21 - { -Avm_DECLARE_VIEWS(21); - - - auto tmp = (avm_alu_op_not * ((avm_alu_ia + avm_alu_ic) - ((((((avm_alu_u8_tag * FF(256)) + (avm_alu_u16_tag * FF(65536))) + (avm_alu_u32_tag * FF(4294967296UL))) + (avm_alu_u64_tag * FF(uint256_t{0UL, 1UL, 0UL, 0UL}))) + (avm_alu_u128_tag * FF(uint256_t{0UL, 0UL, 1UL, 0UL}))) - FF(1)))); - tmp *= scaling_factor; - std::get<21>(evals) += tmp; -} -//Contribution 22 - { -Avm_DECLARE_VIEWS(22); - - - auto tmp = ((avm_alu_cmp_sel + avm_alu_op_eq) * (avm_alu_ic * (-avm_alu_ic + FF(1)))); - tmp *= scaling_factor; - std::get<22>(evals) += tmp; -} -//Contribution 23 - { -Avm_DECLARE_VIEWS(23); - - - auto tmp = (avm_alu_op_eq * ((((avm_alu_ia - avm_alu_ib) * ((avm_alu_ic * (-avm_alu_op_eq_diff_inv + FF(1))) + avm_alu_op_eq_diff_inv)) - FF(1)) + avm_alu_ic)); - tmp *= scaling_factor; - std::get<23>(evals) += tmp; -} -//Contribution 24 - { -Avm_DECLARE_VIEWS(24); - - - auto tmp = (((avm_alu_op_lt * avm_alu_ib) + ((avm_alu_op_lte + avm_alu_op_cast) * avm_alu_ia)) - ((avm_alu_a_lo + (avm_alu_a_hi * FF(uint256_t{0UL, 0UL, 1UL, 0UL}))) * (avm_alu_cmp_sel + avm_alu_op_cast))); - tmp *= scaling_factor; - std::get<24>(evals) += tmp; -} -//Contribution 25 - { -Avm_DECLARE_VIEWS(25); - - - auto tmp = (((avm_alu_op_lt * avm_alu_ia) + (avm_alu_op_lte * avm_alu_ib)) - ((avm_alu_b_lo + (avm_alu_b_hi * FF(uint256_t{0UL, 0UL, 1UL, 0UL}))) * avm_alu_cmp_sel)); - tmp *= scaling_factor; - std::get<25>(evals) += tmp; -} -//Contribution 26 - { -Avm_DECLARE_VIEWS(26); - - - auto tmp = (avm_alu_p_a_borrow * (-avm_alu_p_a_borrow + FF(1))); - tmp *= scaling_factor; - std::get<26>(evals) += tmp; -} -//Contribution 27 - { -Avm_DECLARE_VIEWS(27); - - - auto tmp = ((avm_alu_p_sub_a_lo - ((-avm_alu_a_lo + FF(uint256_t{4891460686036598784UL, 2896914383306846353UL, 0UL, 0UL})) + (avm_alu_p_a_borrow * FF(uint256_t{0UL, 0UL, 1UL, 0UL})))) * ((avm_alu_cmp_sel + avm_alu_op_cast) + avm_alu_op_div_std)); - tmp *= scaling_factor; - std::get<27>(evals) += tmp; -} -//Contribution 28 - { -Avm_DECLARE_VIEWS(28); - - - auto tmp = ((avm_alu_p_sub_a_hi - ((-avm_alu_a_hi + FF(uint256_t{13281191951274694749UL, 3486998266802970665UL, 0UL, 0UL})) - avm_alu_p_a_borrow)) * ((avm_alu_cmp_sel + avm_alu_op_cast) + avm_alu_op_div_std)); - tmp *= scaling_factor; - std::get<28>(evals) += tmp; -} -//Contribution 29 - { -Avm_DECLARE_VIEWS(29); - - - auto tmp = (avm_alu_p_b_borrow * (-avm_alu_p_b_borrow + FF(1))); - tmp *= scaling_factor; - std::get<29>(evals) += tmp; -} -//Contribution 30 - { -Avm_DECLARE_VIEWS(30); - - - auto tmp = ((avm_alu_p_sub_b_lo - ((-avm_alu_b_lo + FF(uint256_t{4891460686036598784UL, 2896914383306846353UL, 0UL, 0UL})) + (avm_alu_p_b_borrow * FF(uint256_t{0UL, 0UL, 1UL, 0UL})))) * avm_alu_cmp_sel); - tmp *= scaling_factor; - std::get<30>(evals) += tmp; -} -//Contribution 31 - { -Avm_DECLARE_VIEWS(31); - - - auto tmp = ((avm_alu_p_sub_b_hi - ((-avm_alu_b_hi + FF(uint256_t{13281191951274694749UL, 3486998266802970665UL, 0UL, 0UL})) - avm_alu_p_b_borrow)) * avm_alu_cmp_sel); - tmp *= scaling_factor; - std::get<31>(evals) += tmp; -} -//Contribution 32 - { -Avm_DECLARE_VIEWS(32); - - - auto tmp = ((avm_alu_res_lo - (((((avm_alu_a_lo - avm_alu_b_lo) - FF(1)) + (avm_alu_borrow * FF(uint256_t{0UL, 0UL, 1UL, 0UL}))) * ((avm_alu_op_lt * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_op_lte))) + (((avm_alu_b_lo - avm_alu_a_lo) + (avm_alu_borrow * FF(uint256_t{0UL, 0UL, 1UL, 0UL}))) * (-((avm_alu_op_lt * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_op_lte)) + FF(1))))) * avm_alu_cmp_sel); - tmp *= scaling_factor; - std::get<32>(evals) += tmp; -} -//Contribution 33 - { -Avm_DECLARE_VIEWS(33); - - - auto tmp = ((avm_alu_res_hi - ((((avm_alu_a_hi - avm_alu_b_hi) - avm_alu_borrow) * ((avm_alu_op_lt * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_op_lte))) + (((avm_alu_b_hi - avm_alu_a_hi) - avm_alu_borrow) * (-((avm_alu_op_lt * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_op_lte)) + FF(1))))) * avm_alu_cmp_sel); - tmp *= scaling_factor; - std::get<33>(evals) += tmp; -} -//Contribution 34 - { -Avm_DECLARE_VIEWS(34); - - - auto tmp = (((avm_alu_cmp_rng_ctr_shift - avm_alu_cmp_rng_ctr) + FF(1)) * avm_alu_cmp_rng_ctr); - tmp *= scaling_factor; - std::get<34>(evals) += tmp; -} -//Contribution 35 - { -Avm_DECLARE_VIEWS(35); - - - auto tmp = ((avm_alu_cmp_rng_ctr_shift - FF(4)) * avm_alu_cmp_sel); - tmp *= scaling_factor; - std::get<35>(evals) += tmp; -} -//Contribution 36 - { -Avm_DECLARE_VIEWS(36); - - - auto tmp = (avm_alu_rng_chk_sel * (-avm_alu_rng_chk_sel + FF(1))); - tmp *= scaling_factor; - std::get<36>(evals) += tmp; -} -//Contribution 37 - { -Avm_DECLARE_VIEWS(37); - - - auto tmp = (avm_alu_rng_chk_sel * avm_alu_cmp_sel); - tmp *= scaling_factor; - std::get<37>(evals) += tmp; -} -//Contribution 38 - { -Avm_DECLARE_VIEWS(38); - - - auto tmp = ((avm_alu_cmp_rng_ctr * (((-avm_alu_rng_chk_sel + FF(1)) * (-avm_alu_op_eq_diff_inv + FF(1))) + avm_alu_op_eq_diff_inv)) - avm_alu_rng_chk_sel); - tmp *= scaling_factor; - std::get<38>(evals) += tmp; -} -//Contribution 39 - { -Avm_DECLARE_VIEWS(39); - - - auto tmp = (avm_alu_rng_chk_lookup_selector_shift - ((((((((((avm_alu_cmp_sel_shift + avm_alu_rng_chk_sel_shift) + avm_alu_op_add_shift) + avm_alu_op_sub_shift) + avm_alu_op_mul_shift) + (avm_alu_op_mul * avm_alu_u128_tag)) + avm_alu_op_cast_shift) + avm_alu_op_cast_prev_shift) + avm_alu_op_shl_shift) + avm_alu_op_shr_shift) + avm_alu_op_div_shift)); - tmp *= scaling_factor; - std::get<39>(evals) += tmp; -} -//Contribution 40 - { -Avm_DECLARE_VIEWS(40); - - - auto tmp = (avm_alu_a_lo - (((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + (avm_alu_u16_r1 * FF(4294967296UL))) + (avm_alu_u16_r2 * FF(281474976710656UL))) + (avm_alu_u16_r3 * FF(uint256_t{0UL, 1UL, 0UL, 0UL}))) + (avm_alu_u16_r4 * FF(uint256_t{0UL, 65536UL, 0UL, 0UL}))) + (avm_alu_u16_r5 * FF(uint256_t{0UL, 4294967296UL, 0UL, 0UL}))) + (avm_alu_u16_r6 * FF(uint256_t{0UL, 281474976710656UL, 0UL, 0UL}))) * (((((avm_alu_rng_chk_sel + avm_alu_cmp_sel) + avm_alu_op_cast) + avm_alu_op_cast_prev) + avm_alu_shift_lt_bit_len) + avm_alu_op_div))); - tmp *= scaling_factor; - std::get<40>(evals) += tmp; -} -//Contribution 41 - { -Avm_DECLARE_VIEWS(41); - - - auto tmp = (avm_alu_a_hi - ((((((((avm_alu_u16_r7 + (avm_alu_u16_r8 * FF(65536))) + (avm_alu_u16_r9 * FF(4294967296UL))) + (avm_alu_u16_r10 * FF(281474976710656UL))) + (avm_alu_u16_r11 * FF(uint256_t{0UL, 1UL, 0UL, 0UL}))) + (avm_alu_u16_r12 * FF(uint256_t{0UL, 65536UL, 0UL, 0UL}))) + (avm_alu_u16_r13 * FF(uint256_t{0UL, 4294967296UL, 0UL, 0UL}))) + (avm_alu_u16_r14 * FF(uint256_t{0UL, 281474976710656UL, 0UL, 0UL}))) * (((((avm_alu_rng_chk_sel + avm_alu_cmp_sel) + avm_alu_op_cast) + avm_alu_op_cast_prev) + avm_alu_shift_lt_bit_len) + avm_alu_op_div))); - tmp *= scaling_factor; - std::get<41>(evals) += tmp; -} -//Contribution 42 - { -Avm_DECLARE_VIEWS(42); - - - auto tmp = ((avm_alu_a_lo_shift - avm_alu_b_lo) * avm_alu_rng_chk_sel_shift); - tmp *= scaling_factor; - std::get<42>(evals) += tmp; -} -//Contribution 43 - { -Avm_DECLARE_VIEWS(43); - - - auto tmp = ((avm_alu_a_hi_shift - avm_alu_b_hi) * avm_alu_rng_chk_sel_shift); - tmp *= scaling_factor; - std::get<43>(evals) += tmp; -} -//Contribution 44 - { -Avm_DECLARE_VIEWS(44); - - - auto tmp = ((avm_alu_b_lo_shift - avm_alu_p_sub_a_lo) * avm_alu_rng_chk_sel_shift); - tmp *= scaling_factor; - std::get<44>(evals) += tmp; -} -//Contribution 45 - { -Avm_DECLARE_VIEWS(45); - - - auto tmp = ((avm_alu_b_hi_shift - avm_alu_p_sub_a_hi) * avm_alu_rng_chk_sel_shift); - tmp *= scaling_factor; - std::get<45>(evals) += tmp; -} -//Contribution 46 - { -Avm_DECLARE_VIEWS(46); - - - auto tmp = ((avm_alu_p_sub_a_lo_shift - avm_alu_p_sub_b_lo) * avm_alu_rng_chk_sel_shift); - tmp *= scaling_factor; - std::get<46>(evals) += tmp; -} -//Contribution 47 - { -Avm_DECLARE_VIEWS(47); - - - auto tmp = ((avm_alu_p_sub_a_hi_shift - avm_alu_p_sub_b_hi) * avm_alu_rng_chk_sel_shift); - tmp *= scaling_factor; - std::get<47>(evals) += tmp; -} -//Contribution 48 - { -Avm_DECLARE_VIEWS(48); - - - auto tmp = ((avm_alu_p_sub_b_lo_shift - avm_alu_res_lo) * avm_alu_rng_chk_sel_shift); - tmp *= scaling_factor; - std::get<48>(evals) += tmp; -} -//Contribution 49 - { -Avm_DECLARE_VIEWS(49); - - - auto tmp = ((avm_alu_p_sub_b_hi_shift - avm_alu_res_hi) * avm_alu_rng_chk_sel_shift); - tmp *= scaling_factor; - std::get<49>(evals) += tmp; -} -//Contribution 50 - { -Avm_DECLARE_VIEWS(50); - - - auto tmp = (avm_alu_op_cast_prev_shift - avm_alu_op_cast); - tmp *= scaling_factor; - std::get<50>(evals) += tmp; -} -//Contribution 51 - { -Avm_DECLARE_VIEWS(51); - - - auto tmp = (avm_alu_op_cast * (((((((avm_alu_u8_tag * avm_alu_u8_r0) + (avm_alu_u16_tag * (avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))))) + (avm_alu_u32_tag * ((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))))) + (avm_alu_u64_tag * ((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + (avm_alu_u16_r1 * FF(4294967296UL))) + (avm_alu_u16_r2 * FF(281474976710656UL))))) + (avm_alu_u128_tag * ((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + (avm_alu_u16_r1 * FF(4294967296UL))) + (avm_alu_u16_r2 * FF(281474976710656UL))) + (avm_alu_u16_r3 * FF(uint256_t{0UL, 1UL, 0UL, 0UL}))) + (avm_alu_u16_r4 * FF(uint256_t{0UL, 65536UL, 0UL, 0UL}))) + (avm_alu_u16_r5 * FF(uint256_t{0UL, 4294967296UL, 0UL, 0UL}))) + (avm_alu_u16_r6 * FF(uint256_t{0UL, 281474976710656UL, 0UL, 0UL}))))) + (avm_alu_ff_tag * avm_alu_ia)) - avm_alu_ic)); - tmp *= scaling_factor; - std::get<51>(evals) += tmp; -} -//Contribution 52 - { -Avm_DECLARE_VIEWS(52); - - - auto tmp = (avm_alu_op_cast * (avm_alu_a_lo_shift - avm_alu_p_sub_a_lo)); - tmp *= scaling_factor; - std::get<52>(evals) += tmp; -} -//Contribution 53 - { -Avm_DECLARE_VIEWS(53); - - - auto tmp = (avm_alu_op_cast * (avm_alu_a_hi_shift - avm_alu_p_sub_a_hi)); - tmp *= scaling_factor; - std::get<53>(evals) += tmp; -} -//Contribution 54 - { -Avm_DECLARE_VIEWS(54); - - - auto tmp = (((avm_alu_op_mul * avm_alu_ff_tag) + avm_alu_op_cast) * avm_alu_alu_sel_shift); - tmp *= scaling_factor; - std::get<54>(evals) += tmp; -} -//Contribution 55 - { -Avm_DECLARE_VIEWS(55); - - - auto tmp = ((avm_alu_shift_lt_bit_len * avm_alu_op_shr) * (avm_alu_a_lo - ((avm_alu_two_pow_s - avm_alu_b_lo) - FF(1)))); - tmp *= scaling_factor; - std::get<55>(evals) += tmp; -} -//Contribution 56 - { -Avm_DECLARE_VIEWS(56); - - - auto tmp = ((avm_alu_shift_lt_bit_len * avm_alu_op_shr) * (avm_alu_a_hi - ((avm_alu_two_pow_t_sub_s - avm_alu_b_hi) - FF(1)))); - tmp *= scaling_factor; - std::get<56>(evals) += tmp; -} -//Contribution 57 - { -Avm_DECLARE_VIEWS(57); - - - auto tmp = ((avm_alu_shift_lt_bit_len * avm_alu_op_shl) * (avm_alu_a_lo - ((avm_alu_two_pow_t_sub_s - avm_alu_b_lo) - FF(1)))); - tmp *= scaling_factor; - std::get<57>(evals) += tmp; -} -//Contribution 58 - { -Avm_DECLARE_VIEWS(58); - - - auto tmp = ((avm_alu_shift_lt_bit_len * avm_alu_op_shl) * (avm_alu_a_hi - ((avm_alu_two_pow_s - avm_alu_b_hi) - FF(1)))); - tmp *= scaling_factor; - std::get<58>(evals) += tmp; -} -//Contribution 59 - { -Avm_DECLARE_VIEWS(59); - - - auto tmp = (avm_alu_shift_lt_bit_len * (-avm_alu_shift_lt_bit_len + FF(1))); - tmp *= scaling_factor; - std::get<59>(evals) += tmp; -} -//Contribution 60 - { -Avm_DECLARE_VIEWS(60); - - - auto tmp = (avm_alu_t_sub_s_bits - (avm_alu_shift_sel * ((avm_alu_shift_lt_bit_len * ((((((avm_alu_u8_tag * FF(8)) + (avm_alu_u16_tag * FF(16))) + (avm_alu_u32_tag * FF(32))) + (avm_alu_u64_tag * FF(64))) + (avm_alu_u128_tag * FF(128))) - avm_alu_ib)) + ((-avm_alu_shift_lt_bit_len + FF(1)) * (avm_alu_ib - (((((avm_alu_u8_tag * FF(8)) + (avm_alu_u16_tag * FF(16))) + (avm_alu_u32_tag * FF(32))) + (avm_alu_u64_tag * FF(64))) + (avm_alu_u128_tag * FF(128)))))))); - tmp *= scaling_factor; - std::get<60>(evals) += tmp; -} -//Contribution 61 - { -Avm_DECLARE_VIEWS(61); - - - auto tmp = ((avm_alu_shift_lt_bit_len * avm_alu_op_shr) * (((avm_alu_b_hi * avm_alu_two_pow_s) + avm_alu_b_lo) - avm_alu_ia)); - tmp *= scaling_factor; - std::get<61>(evals) += tmp; -} -//Contribution 62 - { -Avm_DECLARE_VIEWS(62); - - - auto tmp = (avm_alu_op_shr * (avm_alu_ic - (avm_alu_b_hi * avm_alu_shift_lt_bit_len))); - tmp *= scaling_factor; - std::get<62>(evals) += tmp; -} -//Contribution 63 - { -Avm_DECLARE_VIEWS(63); - - - auto tmp = ((avm_alu_shift_lt_bit_len * avm_alu_op_shl) * (((avm_alu_b_hi * avm_alu_two_pow_t_sub_s) + avm_alu_b_lo) - avm_alu_ia)); - tmp *= scaling_factor; - std::get<63>(evals) += tmp; -} -//Contribution 64 - { -Avm_DECLARE_VIEWS(64); - - - auto tmp = (avm_alu_op_shl * (avm_alu_ic - ((avm_alu_b_lo * avm_alu_two_pow_s) * avm_alu_shift_lt_bit_len))); - tmp *= scaling_factor; - std::get<64>(evals) += tmp; -} -//Contribution 65 - { -Avm_DECLARE_VIEWS(65); - - - auto tmp = (avm_alu_op_div - (avm_alu_op_div_std + avm_alu_op_div_a_lt_b)); - tmp *= scaling_factor; - std::get<65>(evals) += tmp; -} -//Contribution 66 - { -Avm_DECLARE_VIEWS(66); - - - auto tmp = (avm_alu_op_div_a_lt_b * (-avm_alu_op_div_a_lt_b + FF(1))); - tmp *= scaling_factor; - std::get<66>(evals) += tmp; -} -//Contribution 67 - { -Avm_DECLARE_VIEWS(67); - - - auto tmp = (avm_alu_op_div_a_lt_b * (avm_alu_a_lo - ((avm_alu_ib - avm_alu_ia) - FF(1)))); - tmp *= scaling_factor; - std::get<67>(evals) += tmp; -} -//Contribution 68 - { -Avm_DECLARE_VIEWS(68); - - - auto tmp = (avm_alu_op_div_a_lt_b * avm_alu_ic); - tmp *= scaling_factor; - std::get<68>(evals) += tmp; -} -//Contribution 69 - { -Avm_DECLARE_VIEWS(69); - - - auto tmp = (avm_alu_op_div_a_lt_b * (avm_alu_ia - avm_alu_remainder)); - tmp *= scaling_factor; - std::get<69>(evals) += tmp; -} -//Contribution 70 - { -Avm_DECLARE_VIEWS(70); - - - auto tmp = (avm_alu_op_div_std * (-avm_alu_op_div_std + FF(1))); - tmp *= scaling_factor; - std::get<70>(evals) += tmp; -} -//Contribution 71 - { -Avm_DECLARE_VIEWS(71); - - - auto tmp = (avm_alu_op_div_std * ((avm_alu_ib - avm_alu_divisor_lo) - (avm_alu_divisor_hi * FF(uint256_t{0UL, 1UL, 0UL, 0UL})))); - tmp *= scaling_factor; - std::get<71>(evals) += tmp; -} -//Contribution 72 - { -Avm_DECLARE_VIEWS(72); - - - auto tmp = (avm_alu_op_div_std * ((avm_alu_ic - avm_alu_quotient_lo) - (avm_alu_quotient_hi * FF(uint256_t{0UL, 1UL, 0UL, 0UL})))); - tmp *= scaling_factor; - std::get<72>(evals) += tmp; -} -//Contribution 73 - { -Avm_DECLARE_VIEWS(73); - - - auto tmp = (((avm_alu_divisor_hi * avm_alu_quotient_lo) + (avm_alu_divisor_lo * avm_alu_quotient_hi)) - (avm_alu_partial_prod_lo + (avm_alu_partial_prod_hi * FF(uint256_t{0UL, 1UL, 0UL, 0UL})))); - tmp *= scaling_factor; - std::get<73>(evals) += tmp; -} -//Contribution 74 - { -Avm_DECLARE_VIEWS(74); - - - auto tmp = (avm_alu_op_div_std * ((((avm_alu_divisor_lo * avm_alu_quotient_lo) + (avm_alu_partial_prod_lo * FF(uint256_t{0UL, 1UL, 0UL, 0UL}))) + ((avm_alu_partial_prod_hi + (avm_alu_divisor_hi * avm_alu_quotient_hi)) * FF(uint256_t{0UL, 0UL, 1UL, 0UL}))) - (avm_alu_a_lo + (avm_alu_a_hi * FF(uint256_t{0UL, 0UL, 1UL, 0UL}))))); - tmp *= scaling_factor; - std::get<74>(evals) += tmp; -} -//Contribution 75 - { -Avm_DECLARE_VIEWS(75); - - - auto tmp = (avm_alu_op_div_std * (avm_alu_b_hi - ((avm_alu_ib - avm_alu_remainder) - FF(1)))); - tmp *= scaling_factor; - std::get<75>(evals) += tmp; -} -//Contribution 76 - { -Avm_DECLARE_VIEWS(76); - - - auto tmp = ((avm_alu_cmp_rng_ctr_shift - FF(2)) * avm_alu_op_div_std); - tmp *= scaling_factor; - std::get<76>(evals) += tmp; -} -//Contribution 77 - { -Avm_DECLARE_VIEWS(77); - - - auto tmp = (avm_alu_rng_chk_sel * avm_alu_op_div_std); - tmp *= scaling_factor; - std::get<77>(evals) += tmp; -} -//Contribution 78 - { -Avm_DECLARE_VIEWS(78); - - - auto tmp = (avm_alu_op_div_std * ((((avm_alu_divisor_lo * avm_alu_quotient_lo) + (avm_alu_partial_prod_lo * FF(uint256_t{0UL, 1UL, 0UL, 0UL}))) + ((avm_alu_partial_prod_hi + (avm_alu_divisor_hi * avm_alu_quotient_hi)) * FF(uint256_t{0UL, 0UL, 1UL, 0UL}))) - (avm_alu_ia - avm_alu_remainder))); - tmp *= scaling_factor; - std::get<78>(evals) += tmp; -} -//Contribution 79 - { -Avm_DECLARE_VIEWS(79); - - - auto tmp = (avm_alu_div_rng_chk_selector * (-avm_alu_div_rng_chk_selector + FF(1))); - tmp *= scaling_factor; - std::get<79>(evals) += tmp; -} -//Contribution 80 - { -Avm_DECLARE_VIEWS(80); - - - auto tmp = ((avm_alu_div_rng_chk_selector * avm_alu_div_rng_chk_selector_shift) - avm_alu_op_div_std); - tmp *= scaling_factor; - std::get<80>(evals) += tmp; -} -//Contribution 81 + void static accumulate(ContainerOverSubrelations& evals, + const AllEntities& new_term, + [[maybe_unused]] const RelationParameters&, + [[maybe_unused]] const FF& scaling_factor) { -Avm_DECLARE_VIEWS(81); - - - auto tmp = (avm_alu_divisor_lo - (avm_alu_op_div_std * (((avm_alu_div_u16_r0 + (avm_alu_div_u16_r1 * FF(65536))) + (avm_alu_div_u16_r2 * FF(4294967296UL))) + (avm_alu_div_u16_r3 * FF(281474976710656UL))))); - tmp *= scaling_factor; - std::get<81>(evals) += tmp; -} -//Contribution 82 - { -Avm_DECLARE_VIEWS(82); - - - auto tmp = (avm_alu_divisor_hi - (avm_alu_op_div_std * (((avm_alu_div_u16_r4 + (avm_alu_div_u16_r5 * FF(65536))) + (avm_alu_div_u16_r6 * FF(4294967296UL))) + (avm_alu_div_u16_r7 * FF(281474976710656UL))))); - tmp *= scaling_factor; - std::get<82>(evals) += tmp; -} -//Contribution 83 - { -Avm_DECLARE_VIEWS(83); - - - auto tmp = (avm_alu_quotient_lo - (avm_alu_op_div_std * (((avm_alu_div_u16_r0_shift + (avm_alu_div_u16_r1_shift * FF(65536))) + (avm_alu_div_u16_r2_shift * FF(4294967296UL))) + (avm_alu_div_u16_r3_shift * FF(281474976710656UL))))); - tmp *= scaling_factor; - std::get<83>(evals) += tmp; -} -//Contribution 84 - { -Avm_DECLARE_VIEWS(84); - - - auto tmp = (avm_alu_quotient_hi - (avm_alu_op_div_std * (((avm_alu_div_u16_r4_shift + (avm_alu_div_u16_r5_shift * FF(65536))) + (avm_alu_div_u16_r6_shift * FF(4294967296UL))) + (avm_alu_div_u16_r7_shift * FF(281474976710656UL))))); - tmp *= scaling_factor; - std::get<84>(evals) += tmp; -} -//Contribution 85 - { -Avm_DECLARE_VIEWS(85); - - - auto tmp = (avm_alu_partial_prod_lo - (avm_alu_op_div_std * ((((avm_alu_u8_r0_shift + (avm_alu_u8_r1_shift * FF(256))) + (avm_alu_u16_r0_shift * FF(65536))) + (avm_alu_u16_r1_shift * FF(4294967296UL))) + (avm_alu_u16_r2_shift * FF(281474976710656UL))))); - tmp *= scaling_factor; - std::get<85>(evals) += tmp; -} -//Contribution 86 - { -Avm_DECLARE_VIEWS(86); - - - auto tmp = (avm_alu_partial_prod_hi - (avm_alu_op_div_std * (((avm_alu_u16_r3_shift + (avm_alu_u16_r4_shift * FF(65536))) + (avm_alu_u16_r5_shift * FF(4294967296UL))) + (avm_alu_u16_r6_shift * FF(281474976710656UL))))); - tmp *= scaling_factor; - std::get<86>(evals) += tmp; -} -} + // Contribution 0 + { + Avm_DECLARE_VIEWS(0); + + auto tmp = + (avm_alu_alu_sel - + ((((((((((avm_alu_op_add + avm_alu_op_sub) + avm_alu_op_mul) + avm_alu_op_not) + avm_alu_op_eq) + + avm_alu_op_cast) + + avm_alu_op_lt) + + avm_alu_op_lte) + + avm_alu_op_shr) + + avm_alu_op_shl) + + avm_alu_op_div)); + tmp *= scaling_factor; + std::get<0>(evals) += tmp; + } + // Contribution 1 + { + Avm_DECLARE_VIEWS(1); + + auto tmp = (avm_alu_cmp_sel - (avm_alu_op_lt + avm_alu_op_lte)); + tmp *= scaling_factor; + std::get<1>(evals) += tmp; + } + // Contribution 2 + { + Avm_DECLARE_VIEWS(2); + + auto tmp = (avm_alu_shift_sel - (avm_alu_op_shl + avm_alu_op_shr)); + tmp *= scaling_factor; + std::get<2>(evals) += tmp; + } + // Contribution 3 + { + Avm_DECLARE_VIEWS(3); + + auto tmp = (avm_alu_cf * (-avm_alu_cf + FF(1))); + tmp *= scaling_factor; + std::get<3>(evals) += tmp; + } + // Contribution 4 + { + Avm_DECLARE_VIEWS(4); + + auto tmp = (avm_alu_ff_tag * (-avm_alu_ff_tag + FF(1))); + tmp *= scaling_factor; + std::get<4>(evals) += tmp; + } + // Contribution 5 + { + Avm_DECLARE_VIEWS(5); + + auto tmp = (avm_alu_u8_tag * (-avm_alu_u8_tag + FF(1))); + tmp *= scaling_factor; + std::get<5>(evals) += tmp; + } + // Contribution 6 + { + Avm_DECLARE_VIEWS(6); + + auto tmp = (avm_alu_u16_tag * (-avm_alu_u16_tag + FF(1))); + tmp *= scaling_factor; + std::get<6>(evals) += tmp; + } + // Contribution 7 + { + Avm_DECLARE_VIEWS(7); + + auto tmp = (avm_alu_u32_tag * (-avm_alu_u32_tag + FF(1))); + tmp *= scaling_factor; + std::get<7>(evals) += tmp; + } + // Contribution 8 + { + Avm_DECLARE_VIEWS(8); + + auto tmp = (avm_alu_u64_tag * (-avm_alu_u64_tag + FF(1))); + tmp *= scaling_factor; + std::get<8>(evals) += tmp; + } + // Contribution 9 + { + Avm_DECLARE_VIEWS(9); + + auto tmp = (avm_alu_u128_tag * (-avm_alu_u128_tag + FF(1))); + tmp *= scaling_factor; + std::get<9>(evals) += tmp; + } + // Contribution 10 + { + Avm_DECLARE_VIEWS(10); + + auto tmp = + (avm_alu_alu_sel * + ((((((avm_alu_ff_tag + avm_alu_u8_tag) + avm_alu_u16_tag) + avm_alu_u32_tag) + avm_alu_u64_tag) + + avm_alu_u128_tag) - + FF(1))); + tmp *= scaling_factor; + std::get<10>(evals) += tmp; + } + // Contribution 11 + { + Avm_DECLARE_VIEWS(11); + + auto tmp = (avm_alu_in_tag - (((((avm_alu_u8_tag + (avm_alu_u16_tag * FF(2))) + (avm_alu_u32_tag * FF(3))) + + (avm_alu_u64_tag * FF(4))) + + (avm_alu_u128_tag * FF(5))) + + (avm_alu_ff_tag * FF(6)))); + tmp *= scaling_factor; + std::get<11>(evals) += tmp; + } + // Contribution 12 + { + Avm_DECLARE_VIEWS(12); + + auto tmp = (((avm_alu_op_add + avm_alu_op_sub) * + ((((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + + (avm_alu_u16_r1 * FF(4294967296UL))) + + (avm_alu_u16_r2 * FF(281474976710656UL))) + + (avm_alu_u16_r3 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + + (avm_alu_u16_r4 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + + (avm_alu_u16_r5 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + + (avm_alu_u16_r6 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }))) - + avm_alu_ia) + + (avm_alu_ff_tag * avm_alu_ic))) + + ((avm_alu_op_add - avm_alu_op_sub) * + ((avm_alu_cf * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL })) - avm_alu_ib))); + tmp *= scaling_factor; + std::get<12>(evals) += tmp; + } + // Contribution 13 + { + Avm_DECLARE_VIEWS(13); + + auto tmp = (((avm_alu_op_add + avm_alu_op_sub) * + (((((((avm_alu_u8_tag * avm_alu_u8_r0) + + (avm_alu_u16_tag * (avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))))) + + (avm_alu_u32_tag * + ((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))))) + + (avm_alu_u64_tag * + ((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + + (avm_alu_u16_r1 * FF(4294967296UL))) + + (avm_alu_u16_r2 * FF(281474976710656UL))))) + + (avm_alu_u128_tag * + ((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + + (avm_alu_u16_r1 * FF(4294967296UL))) + + (avm_alu_u16_r2 * FF(281474976710656UL))) + + (avm_alu_u16_r3 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + + (avm_alu_u16_r4 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + + (avm_alu_u16_r5 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + + (avm_alu_u16_r6 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }))))) + + (avm_alu_ff_tag * avm_alu_ia)) - + avm_alu_ic)) + + ((avm_alu_ff_tag * (avm_alu_op_add - avm_alu_op_sub)) * avm_alu_ib)); + tmp *= scaling_factor; + std::get<13>(evals) += tmp; + } + // Contribution 14 + { + Avm_DECLARE_VIEWS(14); + + auto tmp = ((avm_alu_ff_tag * avm_alu_op_mul) * ((avm_alu_ia * avm_alu_ib) - avm_alu_ic)); + tmp *= scaling_factor; + std::get<14>(evals) += tmp; + } + // Contribution 15 + { + Avm_DECLARE_VIEWS(15); + + auto tmp = ((((-avm_alu_ff_tag + FF(1)) - avm_alu_u128_tag) * avm_alu_op_mul) * + (((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + + (avm_alu_u16_r1 * FF(4294967296UL))) + + (avm_alu_u16_r2 * FF(281474976710656UL))) + + (avm_alu_u16_r3 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + + (avm_alu_u16_r4 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + + (avm_alu_u16_r5 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + + (avm_alu_u16_r6 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }))) - + (avm_alu_ia * avm_alu_ib))); + tmp *= scaling_factor; + std::get<15>(evals) += tmp; + } + // Contribution 16 + { + Avm_DECLARE_VIEWS(16); + + auto tmp = + (avm_alu_op_mul * + (((((avm_alu_u8_tag * avm_alu_u8_r0) + + (avm_alu_u16_tag * (avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))))) + + (avm_alu_u32_tag * ((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))))) + + (avm_alu_u64_tag * ((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + + (avm_alu_u16_r1 * FF(4294967296UL))) + + (avm_alu_u16_r2 * FF(281474976710656UL))))) - + (((-avm_alu_ff_tag + FF(1)) - avm_alu_u128_tag) * avm_alu_ic))); + tmp *= scaling_factor; + std::get<16>(evals) += tmp; + } + // Contribution 17 + { + Avm_DECLARE_VIEWS(17); + + auto tmp = ((avm_alu_u128_tag * avm_alu_op_mul) * + ((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + + (avm_alu_u16_r1 * FF(4294967296UL))) + + (avm_alu_u16_r2 * FF(281474976710656UL))) + + ((((avm_alu_u16_r3 + (avm_alu_u16_r4 * FF(65536))) + (avm_alu_u16_r5 * FF(4294967296UL))) + + (avm_alu_u16_r6 * FF(281474976710656UL))) * + FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) - + avm_alu_ia)); + tmp *= scaling_factor; + std::get<17>(evals) += tmp; + } + // Contribution 18 + { + Avm_DECLARE_VIEWS(18); + + auto tmp = + ((avm_alu_u128_tag * avm_alu_op_mul) * + ((((((avm_alu_u8_r0_shift + (avm_alu_u8_r1_shift * FF(256))) + (avm_alu_u16_r0_shift * FF(65536))) + + (avm_alu_u16_r1_shift * FF(4294967296UL))) + + (avm_alu_u16_r2_shift * FF(281474976710656UL))) + + ((((avm_alu_u16_r3_shift + (avm_alu_u16_r4_shift * FF(65536))) + + (avm_alu_u16_r5_shift * FF(4294967296UL))) + + (avm_alu_u16_r6_shift * FF(281474976710656UL))) * + FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) - + avm_alu_ib)); + tmp *= scaling_factor; + std::get<18>(evals) += tmp; + } + // Contribution 19 + { + Avm_DECLARE_VIEWS(19); + + auto tmp = + ((avm_alu_u128_tag * avm_alu_op_mul) * + ((((avm_alu_ia * + ((((avm_alu_u8_r0_shift + (avm_alu_u8_r1_shift * FF(256))) + (avm_alu_u16_r0_shift * FF(65536))) + + (avm_alu_u16_r1_shift * FF(4294967296UL))) + + (avm_alu_u16_r2_shift * FF(281474976710656UL)))) + + ((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + + (avm_alu_u16_r1 * FF(4294967296UL))) + + (avm_alu_u16_r2 * FF(281474976710656UL))) * + (((avm_alu_u16_r3_shift + (avm_alu_u16_r4_shift * FF(65536))) + + (avm_alu_u16_r5_shift * FF(4294967296UL))) + + (avm_alu_u16_r6_shift * FF(281474976710656UL)))) * + FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) - + (((avm_alu_cf * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL })) + + (((avm_alu_u16_r7 + (avm_alu_u16_r8 * FF(65536))) + (avm_alu_u16_r9 * FF(4294967296UL))) + + (avm_alu_u16_r10 * FF(281474976710656UL)))) * + FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) - + avm_alu_ic)); + tmp *= scaling_factor; + std::get<19>(evals) += tmp; + } + // Contribution 20 + { + Avm_DECLARE_VIEWS(20); + + auto tmp = (avm_alu_op_not * avm_alu_ff_tag); + tmp *= scaling_factor; + std::get<20>(evals) += tmp; + } + // Contribution 21 + { + Avm_DECLARE_VIEWS(21); + + auto tmp = (avm_alu_op_not * + ((avm_alu_ia + avm_alu_ic) - ((((((avm_alu_u8_tag * FF(256)) + (avm_alu_u16_tag * FF(65536))) + + (avm_alu_u32_tag * FF(4294967296UL))) + + (avm_alu_u64_tag * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + + (avm_alu_u128_tag * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) - + FF(1)))); + tmp *= scaling_factor; + std::get<21>(evals) += tmp; + } + // Contribution 22 + { + Avm_DECLARE_VIEWS(22); + + auto tmp = ((avm_alu_cmp_sel + avm_alu_op_eq) * (avm_alu_ic * (-avm_alu_ic + FF(1)))); + tmp *= scaling_factor; + std::get<22>(evals) += tmp; + } + // Contribution 23 + { + Avm_DECLARE_VIEWS(23); + + auto tmp = + (avm_alu_op_eq * ((((avm_alu_ia - avm_alu_ib) * + ((avm_alu_ic * (-avm_alu_op_eq_diff_inv + FF(1))) + avm_alu_op_eq_diff_inv)) - + FF(1)) + + avm_alu_ic)); + tmp *= scaling_factor; + std::get<23>(evals) += tmp; + } + // Contribution 24 + { + Avm_DECLARE_VIEWS(24); + + auto tmp = (((avm_alu_op_lt * avm_alu_ib) + ((avm_alu_op_lte + avm_alu_op_cast) * avm_alu_ia)) - + ((avm_alu_a_lo + (avm_alu_a_hi * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) * + (avm_alu_cmp_sel + avm_alu_op_cast))); + tmp *= scaling_factor; + std::get<24>(evals) += tmp; + } + // Contribution 25 + { + Avm_DECLARE_VIEWS(25); + + auto tmp = (((avm_alu_op_lt * avm_alu_ia) + (avm_alu_op_lte * avm_alu_ib)) - + ((avm_alu_b_lo + (avm_alu_b_hi * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) * avm_alu_cmp_sel)); + tmp *= scaling_factor; + std::get<25>(evals) += tmp; + } + // Contribution 26 + { + Avm_DECLARE_VIEWS(26); + + auto tmp = (avm_alu_p_a_borrow * (-avm_alu_p_a_borrow + FF(1))); + tmp *= scaling_factor; + std::get<26>(evals) += tmp; + } + // Contribution 27 + { + Avm_DECLARE_VIEWS(27); + + auto tmp = ((avm_alu_p_sub_a_lo - + ((-avm_alu_a_lo + FF(uint256_t{ 4891460686036598784UL, 2896914383306846353UL, 0UL, 0UL })) + + (avm_alu_p_a_borrow * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL })))) * + ((avm_alu_cmp_sel + avm_alu_op_cast) + avm_alu_op_div_std)); + tmp *= scaling_factor; + std::get<27>(evals) += tmp; + } + // Contribution 28 + { + Avm_DECLARE_VIEWS(28); + + auto tmp = ((avm_alu_p_sub_a_hi - + ((-avm_alu_a_hi + FF(uint256_t{ 13281191951274694749UL, 3486998266802970665UL, 0UL, 0UL })) - + avm_alu_p_a_borrow)) * + ((avm_alu_cmp_sel + avm_alu_op_cast) + avm_alu_op_div_std)); + tmp *= scaling_factor; + std::get<28>(evals) += tmp; + } + // Contribution 29 + { + Avm_DECLARE_VIEWS(29); + + auto tmp = (avm_alu_p_b_borrow * (-avm_alu_p_b_borrow + FF(1))); + tmp *= scaling_factor; + std::get<29>(evals) += tmp; + } + // Contribution 30 + { + Avm_DECLARE_VIEWS(30); + + auto tmp = ((avm_alu_p_sub_b_lo - + ((-avm_alu_b_lo + FF(uint256_t{ 4891460686036598784UL, 2896914383306846353UL, 0UL, 0UL })) + + (avm_alu_p_b_borrow * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL })))) * + avm_alu_cmp_sel); + tmp *= scaling_factor; + std::get<30>(evals) += tmp; + } + // Contribution 31 + { + Avm_DECLARE_VIEWS(31); + + auto tmp = ((avm_alu_p_sub_b_hi - + ((-avm_alu_b_hi + FF(uint256_t{ 13281191951274694749UL, 3486998266802970665UL, 0UL, 0UL })) - + avm_alu_p_b_borrow)) * + avm_alu_cmp_sel); + tmp *= scaling_factor; + std::get<31>(evals) += tmp; + } + // Contribution 32 + { + Avm_DECLARE_VIEWS(32); + + auto tmp = + ((avm_alu_res_lo - + (((((avm_alu_a_lo - avm_alu_b_lo) - FF(1)) + (avm_alu_borrow * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) * + ((avm_alu_op_lt * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_op_lte))) + + (((avm_alu_b_lo - avm_alu_a_lo) + (avm_alu_borrow * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) * + (-((avm_alu_op_lt * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_op_lte)) + FF(1))))) * + avm_alu_cmp_sel); + tmp *= scaling_factor; + std::get<32>(evals) += tmp; + } + // Contribution 33 + { + Avm_DECLARE_VIEWS(33); + + auto tmp = ((avm_alu_res_hi - + ((((avm_alu_a_hi - avm_alu_b_hi) - avm_alu_borrow) * + ((avm_alu_op_lt * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_op_lte))) + + (((avm_alu_b_hi - avm_alu_a_hi) - avm_alu_borrow) * + (-((avm_alu_op_lt * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_op_lte)) + FF(1))))) * + avm_alu_cmp_sel); + tmp *= scaling_factor; + std::get<33>(evals) += tmp; + } + // Contribution 34 + { + Avm_DECLARE_VIEWS(34); + + auto tmp = (((avm_alu_cmp_rng_ctr_shift - avm_alu_cmp_rng_ctr) + FF(1)) * avm_alu_cmp_rng_ctr); + tmp *= scaling_factor; + std::get<34>(evals) += tmp; + } + // Contribution 35 + { + Avm_DECLARE_VIEWS(35); + + auto tmp = ((avm_alu_cmp_rng_ctr_shift - FF(4)) * avm_alu_cmp_sel); + tmp *= scaling_factor; + std::get<35>(evals) += tmp; + } + // Contribution 36 + { + Avm_DECLARE_VIEWS(36); + + auto tmp = (avm_alu_rng_chk_sel * (-avm_alu_rng_chk_sel + FF(1))); + tmp *= scaling_factor; + std::get<36>(evals) += tmp; + } + // Contribution 37 + { + Avm_DECLARE_VIEWS(37); + + auto tmp = (avm_alu_rng_chk_sel * avm_alu_cmp_sel); + tmp *= scaling_factor; + std::get<37>(evals) += tmp; + } + // Contribution 38 + { + Avm_DECLARE_VIEWS(38); + + auto tmp = ((avm_alu_cmp_rng_ctr * (((-avm_alu_rng_chk_sel + FF(1)) * (-avm_alu_op_eq_diff_inv + FF(1))) + + avm_alu_op_eq_diff_inv)) - + avm_alu_rng_chk_sel); + tmp *= scaling_factor; + std::get<38>(evals) += tmp; + } + // Contribution 39 + { + Avm_DECLARE_VIEWS(39); + + auto tmp = (avm_alu_rng_chk_lookup_selector_shift - + ((((((((((avm_alu_cmp_sel_shift + avm_alu_rng_chk_sel_shift) + avm_alu_op_add_shift) + + avm_alu_op_sub_shift) + + avm_alu_op_mul_shift) + + (avm_alu_op_mul * avm_alu_u128_tag)) + + avm_alu_op_cast_shift) + + avm_alu_op_cast_prev_shift) + + avm_alu_op_shl_shift) + + avm_alu_op_shr_shift) + + avm_alu_op_div_shift)); + tmp *= scaling_factor; + std::get<39>(evals) += tmp; + } + // Contribution 40 + { + Avm_DECLARE_VIEWS(40); + + auto tmp = (avm_alu_a_lo - + (((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + + (avm_alu_u16_r1 * FF(4294967296UL))) + + (avm_alu_u16_r2 * FF(281474976710656UL))) + + (avm_alu_u16_r3 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + + (avm_alu_u16_r4 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + + (avm_alu_u16_r5 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + + (avm_alu_u16_r6 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }))) * + (((((avm_alu_rng_chk_sel + avm_alu_cmp_sel) + avm_alu_op_cast) + avm_alu_op_cast_prev) + + avm_alu_shift_lt_bit_len) + + avm_alu_op_div))); + tmp *= scaling_factor; + std::get<40>(evals) += tmp; + } + // Contribution 41 + { + Avm_DECLARE_VIEWS(41); + + auto tmp = (avm_alu_a_hi - + ((((((((avm_alu_u16_r7 + (avm_alu_u16_r8 * FF(65536))) + (avm_alu_u16_r9 * FF(4294967296UL))) + + (avm_alu_u16_r10 * FF(281474976710656UL))) + + (avm_alu_u16_r11 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + + (avm_alu_u16_r12 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + + (avm_alu_u16_r13 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + + (avm_alu_u16_r14 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }))) * + (((((avm_alu_rng_chk_sel + avm_alu_cmp_sel) + avm_alu_op_cast) + avm_alu_op_cast_prev) + + avm_alu_shift_lt_bit_len) + + avm_alu_op_div))); + tmp *= scaling_factor; + std::get<41>(evals) += tmp; + } + // Contribution 42 + { + Avm_DECLARE_VIEWS(42); + + auto tmp = ((avm_alu_a_lo_shift - avm_alu_b_lo) * avm_alu_rng_chk_sel_shift); + tmp *= scaling_factor; + std::get<42>(evals) += tmp; + } + // Contribution 43 + { + Avm_DECLARE_VIEWS(43); + + auto tmp = ((avm_alu_a_hi_shift - avm_alu_b_hi) * avm_alu_rng_chk_sel_shift); + tmp *= scaling_factor; + std::get<43>(evals) += tmp; + } + // Contribution 44 + { + Avm_DECLARE_VIEWS(44); + + auto tmp = ((avm_alu_b_lo_shift - avm_alu_p_sub_a_lo) * avm_alu_rng_chk_sel_shift); + tmp *= scaling_factor; + std::get<44>(evals) += tmp; + } + // Contribution 45 + { + Avm_DECLARE_VIEWS(45); + + auto tmp = ((avm_alu_b_hi_shift - avm_alu_p_sub_a_hi) * avm_alu_rng_chk_sel_shift); + tmp *= scaling_factor; + std::get<45>(evals) += tmp; + } + // Contribution 46 + { + Avm_DECLARE_VIEWS(46); + + auto tmp = ((avm_alu_p_sub_a_lo_shift - avm_alu_p_sub_b_lo) * avm_alu_rng_chk_sel_shift); + tmp *= scaling_factor; + std::get<46>(evals) += tmp; + } + // Contribution 47 + { + Avm_DECLARE_VIEWS(47); + + auto tmp = ((avm_alu_p_sub_a_hi_shift - avm_alu_p_sub_b_hi) * avm_alu_rng_chk_sel_shift); + tmp *= scaling_factor; + std::get<47>(evals) += tmp; + } + // Contribution 48 + { + Avm_DECLARE_VIEWS(48); + + auto tmp = ((avm_alu_p_sub_b_lo_shift - avm_alu_res_lo) * avm_alu_rng_chk_sel_shift); + tmp *= scaling_factor; + std::get<48>(evals) += tmp; + } + // Contribution 49 + { + Avm_DECLARE_VIEWS(49); + + auto tmp = ((avm_alu_p_sub_b_hi_shift - avm_alu_res_hi) * avm_alu_rng_chk_sel_shift); + tmp *= scaling_factor; + std::get<49>(evals) += tmp; + } + // Contribution 50 + { + Avm_DECLARE_VIEWS(50); + + auto tmp = (avm_alu_op_cast_prev_shift - avm_alu_op_cast); + tmp *= scaling_factor; + std::get<50>(evals) += tmp; + } + // Contribution 51 + { + Avm_DECLARE_VIEWS(51); + + auto tmp = + (avm_alu_op_cast * + (((((((avm_alu_u8_tag * avm_alu_u8_r0) + + (avm_alu_u16_tag * (avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))))) + + (avm_alu_u32_tag * + ((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))))) + + (avm_alu_u64_tag * ((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + + (avm_alu_u16_r1 * FF(4294967296UL))) + + (avm_alu_u16_r2 * FF(281474976710656UL))))) + + (avm_alu_u128_tag * + ((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + + (avm_alu_u16_r1 * FF(4294967296UL))) + + (avm_alu_u16_r2 * FF(281474976710656UL))) + + (avm_alu_u16_r3 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + + (avm_alu_u16_r4 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + + (avm_alu_u16_r5 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + + (avm_alu_u16_r6 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }))))) + + (avm_alu_ff_tag * avm_alu_ia)) - + avm_alu_ic)); + tmp *= scaling_factor; + std::get<51>(evals) += tmp; + } + // Contribution 52 + { + Avm_DECLARE_VIEWS(52); + + auto tmp = (avm_alu_op_cast * (avm_alu_a_lo_shift - avm_alu_p_sub_a_lo)); + tmp *= scaling_factor; + std::get<52>(evals) += tmp; + } + // Contribution 53 + { + Avm_DECLARE_VIEWS(53); + + auto tmp = (avm_alu_op_cast * (avm_alu_a_hi_shift - avm_alu_p_sub_a_hi)); + tmp *= scaling_factor; + std::get<53>(evals) += tmp; + } + // Contribution 54 + { + Avm_DECLARE_VIEWS(54); + + auto tmp = (((avm_alu_op_mul * avm_alu_ff_tag) + avm_alu_op_cast) * avm_alu_alu_sel_shift); + tmp *= scaling_factor; + std::get<54>(evals) += tmp; + } + // Contribution 55 + { + Avm_DECLARE_VIEWS(55); + + auto tmp = ((avm_alu_shift_lt_bit_len * avm_alu_op_shr) * + (avm_alu_a_lo - ((avm_alu_two_pow_s - avm_alu_b_lo) - FF(1)))); + tmp *= scaling_factor; + std::get<55>(evals) += tmp; + } + // Contribution 56 + { + Avm_DECLARE_VIEWS(56); + + auto tmp = ((avm_alu_shift_lt_bit_len * avm_alu_op_shr) * + (avm_alu_a_hi - ((avm_alu_two_pow_t_sub_s - avm_alu_b_hi) - FF(1)))); + tmp *= scaling_factor; + std::get<56>(evals) += tmp; + } + // Contribution 57 + { + Avm_DECLARE_VIEWS(57); + + auto tmp = ((avm_alu_shift_lt_bit_len * avm_alu_op_shl) * + (avm_alu_a_lo - ((avm_alu_two_pow_t_sub_s - avm_alu_b_lo) - FF(1)))); + tmp *= scaling_factor; + std::get<57>(evals) += tmp; + } + // Contribution 58 + { + Avm_DECLARE_VIEWS(58); + + auto tmp = ((avm_alu_shift_lt_bit_len * avm_alu_op_shl) * + (avm_alu_a_hi - ((avm_alu_two_pow_s - avm_alu_b_hi) - FF(1)))); + tmp *= scaling_factor; + std::get<58>(evals) += tmp; + } + // Contribution 59 + { + Avm_DECLARE_VIEWS(59); + + auto tmp = (avm_alu_shift_lt_bit_len * (-avm_alu_shift_lt_bit_len + FF(1))); + tmp *= scaling_factor; + std::get<59>(evals) += tmp; + } + // Contribution 60 + { + Avm_DECLARE_VIEWS(60); + + auto tmp = (avm_alu_t_sub_s_bits - + (avm_alu_shift_sel * + ((avm_alu_shift_lt_bit_len * + ((((((avm_alu_u8_tag * FF(8)) + (avm_alu_u16_tag * FF(16))) + (avm_alu_u32_tag * FF(32))) + + (avm_alu_u64_tag * FF(64))) + + (avm_alu_u128_tag * FF(128))) - + avm_alu_ib)) + + ((-avm_alu_shift_lt_bit_len + FF(1)) * + (avm_alu_ib - + (((((avm_alu_u8_tag * FF(8)) + (avm_alu_u16_tag * FF(16))) + (avm_alu_u32_tag * FF(32))) + + (avm_alu_u64_tag * FF(64))) + + (avm_alu_u128_tag * FF(128)))))))); + tmp *= scaling_factor; + std::get<60>(evals) += tmp; + } + // Contribution 61 + { + Avm_DECLARE_VIEWS(61); + + auto tmp = ((avm_alu_shift_lt_bit_len * avm_alu_op_shr) * + (((avm_alu_b_hi * avm_alu_two_pow_s) + avm_alu_b_lo) - avm_alu_ia)); + tmp *= scaling_factor; + std::get<61>(evals) += tmp; + } + // Contribution 62 + { + Avm_DECLARE_VIEWS(62); + + auto tmp = (avm_alu_op_shr * (avm_alu_ic - (avm_alu_b_hi * avm_alu_shift_lt_bit_len))); + tmp *= scaling_factor; + std::get<62>(evals) += tmp; + } + // Contribution 63 + { + Avm_DECLARE_VIEWS(63); + + auto tmp = ((avm_alu_shift_lt_bit_len * avm_alu_op_shl) * + (((avm_alu_b_hi * avm_alu_two_pow_t_sub_s) + avm_alu_b_lo) - avm_alu_ia)); + tmp *= scaling_factor; + std::get<63>(evals) += tmp; + } + // Contribution 64 + { + Avm_DECLARE_VIEWS(64); + + auto tmp = + (avm_alu_op_shl * (avm_alu_ic - ((avm_alu_b_lo * avm_alu_two_pow_s) * avm_alu_shift_lt_bit_len))); + tmp *= scaling_factor; + std::get<64>(evals) += tmp; + } + // Contribution 65 + { + Avm_DECLARE_VIEWS(65); + + auto tmp = (avm_alu_op_div - (avm_alu_op_div_std + avm_alu_op_div_a_lt_b)); + tmp *= scaling_factor; + std::get<65>(evals) += tmp; + } + // Contribution 66 + { + Avm_DECLARE_VIEWS(66); + + auto tmp = (avm_alu_op_div_a_lt_b * (-avm_alu_op_div_a_lt_b + FF(1))); + tmp *= scaling_factor; + std::get<66>(evals) += tmp; + } + // Contribution 67 + { + Avm_DECLARE_VIEWS(67); + + auto tmp = (avm_alu_op_div_a_lt_b * (avm_alu_a_lo - ((avm_alu_ib - avm_alu_ia) - FF(1)))); + tmp *= scaling_factor; + std::get<67>(evals) += tmp; + } + // Contribution 68 + { + Avm_DECLARE_VIEWS(68); + + auto tmp = (avm_alu_op_div_a_lt_b * avm_alu_ic); + tmp *= scaling_factor; + std::get<68>(evals) += tmp; + } + // Contribution 69 + { + Avm_DECLARE_VIEWS(69); + + auto tmp = (avm_alu_op_div_a_lt_b * (avm_alu_ia - avm_alu_remainder)); + tmp *= scaling_factor; + std::get<69>(evals) += tmp; + } + // Contribution 70 + { + Avm_DECLARE_VIEWS(70); + + auto tmp = (avm_alu_op_div_std * (-avm_alu_op_div_std + FF(1))); + tmp *= scaling_factor; + std::get<70>(evals) += tmp; + } + // Contribution 71 + { + Avm_DECLARE_VIEWS(71); + + auto tmp = (avm_alu_op_div_std * ((avm_alu_ib - avm_alu_divisor_lo) - + (avm_alu_divisor_hi * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL })))); + tmp *= scaling_factor; + std::get<71>(evals) += tmp; + } + // Contribution 72 + { + Avm_DECLARE_VIEWS(72); + + auto tmp = (avm_alu_op_div_std * ((avm_alu_ic - avm_alu_quotient_lo) - + (avm_alu_quotient_hi * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL })))); + tmp *= scaling_factor; + std::get<72>(evals) += tmp; + } + // Contribution 73 + { + Avm_DECLARE_VIEWS(73); + + auto tmp = (((avm_alu_divisor_hi * avm_alu_quotient_lo) + (avm_alu_divisor_lo * avm_alu_quotient_hi)) - + (avm_alu_partial_prod_lo + (avm_alu_partial_prod_hi * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL })))); + tmp *= scaling_factor; + std::get<73>(evals) += tmp; + } + // Contribution 74 + { + Avm_DECLARE_VIEWS(74); + + auto tmp = (avm_alu_op_div_std * ((((avm_alu_divisor_lo * avm_alu_quotient_lo) + + (avm_alu_partial_prod_lo * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + + ((avm_alu_partial_prod_hi + (avm_alu_divisor_hi * avm_alu_quotient_hi)) * + FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) - + (avm_alu_a_lo + (avm_alu_a_hi * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))))); + tmp *= scaling_factor; + std::get<74>(evals) += tmp; + } + // Contribution 75 + { + Avm_DECLARE_VIEWS(75); + + auto tmp = (avm_alu_op_div_std * (avm_alu_b_hi - ((avm_alu_ib - avm_alu_remainder) - FF(1)))); + tmp *= scaling_factor; + std::get<75>(evals) += tmp; + } + // Contribution 76 + { + Avm_DECLARE_VIEWS(76); + + auto tmp = ((avm_alu_cmp_rng_ctr_shift - FF(2)) * avm_alu_op_div_std); + tmp *= scaling_factor; + std::get<76>(evals) += tmp; + } + // Contribution 77 + { + Avm_DECLARE_VIEWS(77); + + auto tmp = (avm_alu_rng_chk_sel * avm_alu_op_div_std); + tmp *= scaling_factor; + std::get<77>(evals) += tmp; + } + // Contribution 78 + { + Avm_DECLARE_VIEWS(78); + + auto tmp = (avm_alu_op_div_std * ((((avm_alu_divisor_lo * avm_alu_quotient_lo) + + (avm_alu_partial_prod_lo * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + + ((avm_alu_partial_prod_hi + (avm_alu_divisor_hi * avm_alu_quotient_hi)) * + FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) - + (avm_alu_ia - avm_alu_remainder))); + tmp *= scaling_factor; + std::get<78>(evals) += tmp; + } + // Contribution 79 + { + Avm_DECLARE_VIEWS(79); + + auto tmp = (avm_alu_div_rng_chk_selector * (-avm_alu_div_rng_chk_selector + FF(1))); + tmp *= scaling_factor; + std::get<79>(evals) += tmp; + } + // Contribution 80 + { + Avm_DECLARE_VIEWS(80); + + auto tmp = ((avm_alu_div_rng_chk_selector * avm_alu_div_rng_chk_selector_shift) - avm_alu_op_div_std); + tmp *= scaling_factor; + std::get<80>(evals) += tmp; + } + // Contribution 81 + { + Avm_DECLARE_VIEWS(81); + + auto tmp = + (avm_alu_divisor_lo - (avm_alu_op_div_std * (((avm_alu_div_u16_r0 + (avm_alu_div_u16_r1 * FF(65536))) + + (avm_alu_div_u16_r2 * FF(4294967296UL))) + + (avm_alu_div_u16_r3 * FF(281474976710656UL))))); + tmp *= scaling_factor; + std::get<81>(evals) += tmp; + } + // Contribution 82 + { + Avm_DECLARE_VIEWS(82); + + auto tmp = + (avm_alu_divisor_hi - (avm_alu_op_div_std * (((avm_alu_div_u16_r4 + (avm_alu_div_u16_r5 * FF(65536))) + + (avm_alu_div_u16_r6 * FF(4294967296UL))) + + (avm_alu_div_u16_r7 * FF(281474976710656UL))))); + tmp *= scaling_factor; + std::get<82>(evals) += tmp; + } + // Contribution 83 + { + Avm_DECLARE_VIEWS(83); + + auto tmp = (avm_alu_quotient_lo - + (avm_alu_op_div_std * (((avm_alu_div_u16_r0_shift + (avm_alu_div_u16_r1_shift * FF(65536))) + + (avm_alu_div_u16_r2_shift * FF(4294967296UL))) + + (avm_alu_div_u16_r3_shift * FF(281474976710656UL))))); + tmp *= scaling_factor; + std::get<83>(evals) += tmp; + } + // Contribution 84 + { + Avm_DECLARE_VIEWS(84); + + auto tmp = (avm_alu_quotient_hi - + (avm_alu_op_div_std * (((avm_alu_div_u16_r4_shift + (avm_alu_div_u16_r5_shift * FF(65536))) + + (avm_alu_div_u16_r6_shift * FF(4294967296UL))) + + (avm_alu_div_u16_r7_shift * FF(281474976710656UL))))); + tmp *= scaling_factor; + std::get<84>(evals) += tmp; + } + // Contribution 85 + { + Avm_DECLARE_VIEWS(85); + + auto tmp = + (avm_alu_partial_prod_lo - + (avm_alu_op_div_std * + ((((avm_alu_u8_r0_shift + (avm_alu_u8_r1_shift * FF(256))) + (avm_alu_u16_r0_shift * FF(65536))) + + (avm_alu_u16_r1_shift * FF(4294967296UL))) + + (avm_alu_u16_r2_shift * FF(281474976710656UL))))); + tmp *= scaling_factor; + std::get<85>(evals) += tmp; + } + // Contribution 86 + { + Avm_DECLARE_VIEWS(86); + + auto tmp = (avm_alu_partial_prod_hi - + (avm_alu_op_div_std * (((avm_alu_u16_r3_shift + (avm_alu_u16_r4_shift * FF(65536))) + + (avm_alu_u16_r5_shift * FF(4294967296UL))) + + (avm_alu_u16_r6_shift * FF(281474976710656UL))))); + tmp *= scaling_factor; + std::get<86>(evals) += tmp; + } + } }; template using avm_alu = Relation>; - } \ No newline at end of file +} // namespace bb::Avm_vm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_binary.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_binary.hpp index e99d59d2e7a..e58112cbfd7 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_binary.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_binary.hpp @@ -6,170 +6,152 @@ namespace bb::Avm_vm { -template struct Avm_binaryRow { - FF avm_binary_acc_ia {}; - FF avm_binary_acc_ia_shift {}; - FF avm_binary_acc_ib {}; - FF avm_binary_acc_ib_shift {}; - FF avm_binary_acc_ic {}; - FF avm_binary_acc_ic_shift {}; - FF avm_binary_bin_sel {}; - FF avm_binary_ia_bytes {}; - FF avm_binary_ib_bytes {}; - FF avm_binary_ic_bytes {}; - FF avm_binary_mem_tag_ctr {}; - FF avm_binary_mem_tag_ctr_inv {}; - FF avm_binary_mem_tag_ctr_shift {}; - FF avm_binary_op_id {}; - FF avm_binary_op_id_shift {}; - }; - - - inline std::string get_relation_label_avm_binary(int index) { - switch (index) { - case 1: - return "OP_ID_REL"; - -case 2: - return "MEM_TAG_REL"; - -case 3: - return "BIN_SEL_CTR_REL"; - -case 7: - return "ACC_REL_A"; - -case 8: - return "ACC_REL_B"; - -case 9: - return "ACC_REL_C"; - - } - return std::to_string(index); +template struct Avm_binaryRow { + FF avm_binary_acc_ia{}; + FF avm_binary_acc_ia_shift{}; + FF avm_binary_acc_ib{}; + FF avm_binary_acc_ib_shift{}; + FF avm_binary_acc_ic{}; + FF avm_binary_acc_ic_shift{}; + FF avm_binary_bin_sel{}; + FF avm_binary_ia_bytes{}; + FF avm_binary_ib_bytes{}; + FF avm_binary_ic_bytes{}; + FF avm_binary_mem_tag_ctr{}; + FF avm_binary_mem_tag_ctr_inv{}; + FF avm_binary_mem_tag_ctr_shift{}; + FF avm_binary_op_id{}; + FF avm_binary_op_id_shift{}; +}; + +inline std::string get_relation_label_avm_binary(int index) +{ + switch (index) { + case 1: + return "OP_ID_REL"; + + case 2: + return "MEM_TAG_REL"; + + case 3: + return "BIN_SEL_CTR_REL"; + + case 7: + return "ACC_REL_A"; + + case 8: + return "ACC_REL_B"; + + case 9: + return "ACC_REL_C"; } - + return std::to_string(index); +} template class avm_binaryImpl { - public: - using FF = FF_; - - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, - 3, - 3, - 4, - 3, - 3, - 3, - 4, - 4, - 4, -}; - - + public: + using FF = FF_; + + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 3, 3, 3, 4, 3, 3, 3, 4, 4, 4, + }; + template - void static accumulate( - ContainerOverSubrelations& evals, - const AllEntities& new_term, - [[maybe_unused]] const RelationParameters&, - [[maybe_unused]] const FF& scaling_factor - ){ - - //Contribution 0 - { -Avm_DECLARE_VIEWS(0); - - - auto tmp = (avm_binary_bin_sel * (-avm_binary_bin_sel + FF(1))); - tmp *= scaling_factor; - std::get<0>(evals) += tmp; -} -//Contribution 1 + void static accumulate(ContainerOverSubrelations& evals, + const AllEntities& new_term, + [[maybe_unused]] const RelationParameters&, + [[maybe_unused]] const FF& scaling_factor) { -Avm_DECLARE_VIEWS(1); - - - auto tmp = ((avm_binary_op_id_shift - avm_binary_op_id) * avm_binary_mem_tag_ctr); - tmp *= scaling_factor; - std::get<1>(evals) += tmp; -} -//Contribution 2 - { -Avm_DECLARE_VIEWS(2); - - - auto tmp = (((avm_binary_mem_tag_ctr_shift - avm_binary_mem_tag_ctr) + FF(1)) * avm_binary_mem_tag_ctr); - tmp *= scaling_factor; - std::get<2>(evals) += tmp; -} -//Contribution 3 - { -Avm_DECLARE_VIEWS(3); - - - auto tmp = ((avm_binary_mem_tag_ctr * (((-avm_binary_bin_sel + FF(1)) * (-avm_binary_mem_tag_ctr_inv + FF(1))) + avm_binary_mem_tag_ctr_inv)) - avm_binary_bin_sel); - tmp *= scaling_factor; - std::get<3>(evals) += tmp; -} -//Contribution 4 - { -Avm_DECLARE_VIEWS(4); - - - auto tmp = ((-avm_binary_bin_sel + FF(1)) * avm_binary_acc_ia); - tmp *= scaling_factor; - std::get<4>(evals) += tmp; -} -//Contribution 5 - { -Avm_DECLARE_VIEWS(5); - - - auto tmp = ((-avm_binary_bin_sel + FF(1)) * avm_binary_acc_ib); - tmp *= scaling_factor; - std::get<5>(evals) += tmp; -} -//Contribution 6 - { -Avm_DECLARE_VIEWS(6); - - - auto tmp = ((-avm_binary_bin_sel + FF(1)) * avm_binary_acc_ic); - tmp *= scaling_factor; - std::get<6>(evals) += tmp; -} -//Contribution 7 - { -Avm_DECLARE_VIEWS(7); - - - auto tmp = (((avm_binary_acc_ia - avm_binary_ia_bytes) - (avm_binary_acc_ia_shift * FF(256))) * avm_binary_mem_tag_ctr); - tmp *= scaling_factor; - std::get<7>(evals) += tmp; -} -//Contribution 8 - { -Avm_DECLARE_VIEWS(8); - - - auto tmp = (((avm_binary_acc_ib - avm_binary_ib_bytes) - (avm_binary_acc_ib_shift * FF(256))) * avm_binary_mem_tag_ctr); - tmp *= scaling_factor; - std::get<8>(evals) += tmp; -} -//Contribution 9 - { -Avm_DECLARE_VIEWS(9); - - - auto tmp = (((avm_binary_acc_ic - avm_binary_ic_bytes) - (avm_binary_acc_ic_shift * FF(256))) * avm_binary_mem_tag_ctr); - tmp *= scaling_factor; - std::get<9>(evals) += tmp; -} -} + // Contribution 0 + { + Avm_DECLARE_VIEWS(0); + + auto tmp = (avm_binary_bin_sel * (-avm_binary_bin_sel + FF(1))); + tmp *= scaling_factor; + std::get<0>(evals) += tmp; + } + // Contribution 1 + { + Avm_DECLARE_VIEWS(1); + + auto tmp = ((avm_binary_op_id_shift - avm_binary_op_id) * avm_binary_mem_tag_ctr); + tmp *= scaling_factor; + std::get<1>(evals) += tmp; + } + // Contribution 2 + { + Avm_DECLARE_VIEWS(2); + + auto tmp = (((avm_binary_mem_tag_ctr_shift - avm_binary_mem_tag_ctr) + FF(1)) * avm_binary_mem_tag_ctr); + tmp *= scaling_factor; + std::get<2>(evals) += tmp; + } + // Contribution 3 + { + Avm_DECLARE_VIEWS(3); + + auto tmp = + ((avm_binary_mem_tag_ctr * (((-avm_binary_bin_sel + FF(1)) * (-avm_binary_mem_tag_ctr_inv + FF(1))) + + avm_binary_mem_tag_ctr_inv)) - + avm_binary_bin_sel); + tmp *= scaling_factor; + std::get<3>(evals) += tmp; + } + // Contribution 4 + { + Avm_DECLARE_VIEWS(4); + + auto tmp = ((-avm_binary_bin_sel + FF(1)) * avm_binary_acc_ia); + tmp *= scaling_factor; + std::get<4>(evals) += tmp; + } + // Contribution 5 + { + Avm_DECLARE_VIEWS(5); + + auto tmp = ((-avm_binary_bin_sel + FF(1)) * avm_binary_acc_ib); + tmp *= scaling_factor; + std::get<5>(evals) += tmp; + } + // Contribution 6 + { + Avm_DECLARE_VIEWS(6); + + auto tmp = ((-avm_binary_bin_sel + FF(1)) * avm_binary_acc_ic); + tmp *= scaling_factor; + std::get<6>(evals) += tmp; + } + // Contribution 7 + { + Avm_DECLARE_VIEWS(7); + + auto tmp = (((avm_binary_acc_ia - avm_binary_ia_bytes) - (avm_binary_acc_ia_shift * FF(256))) * + avm_binary_mem_tag_ctr); + tmp *= scaling_factor; + std::get<7>(evals) += tmp; + } + // Contribution 8 + { + Avm_DECLARE_VIEWS(8); + + auto tmp = (((avm_binary_acc_ib - avm_binary_ib_bytes) - (avm_binary_acc_ib_shift * FF(256))) * + avm_binary_mem_tag_ctr); + tmp *= scaling_factor; + std::get<8>(evals) += tmp; + } + // Contribution 9 + { + Avm_DECLARE_VIEWS(9); + + auto tmp = (((avm_binary_acc_ic - avm_binary_ic_bytes) - (avm_binary_acc_ic_shift * FF(256))) * + avm_binary_mem_tag_ctr); + tmp *= scaling_factor; + std::get<9>(evals) += tmp; + } + } }; template using avm_binary = Relation>; - } \ No newline at end of file +} // namespace bb::Avm_vm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_conversion.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_conversion.hpp index f3de5f3f392..9ecfc59cfc4 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_conversion.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_conversion.hpp @@ -6,49 +6,42 @@ namespace bb::Avm_vm { -template struct Avm_conversionRow { - FF avm_conversion_to_radix_le_sel {}; - }; - +template struct Avm_conversionRow { + FF avm_conversion_to_radix_le_sel{}; +}; - inline std::string get_relation_label_avm_conversion(int index) { - switch (index) { - - } - return std::to_string(index); - } - +inline std::string get_relation_label_avm_conversion(int index) +{ + switch (index) {} + return std::to_string(index); +} template class avm_conversionImpl { - public: - using FF = FF_; - - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, -}; - - + public: + using FF = FF_; + + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 3, + }; + template - void static accumulate( - ContainerOverSubrelations& evals, - const AllEntities& new_term, - [[maybe_unused]] const RelationParameters&, - [[maybe_unused]] const FF& scaling_factor - ){ - - //Contribution 0 + void static accumulate(ContainerOverSubrelations& evals, + const AllEntities& new_term, + [[maybe_unused]] const RelationParameters&, + [[maybe_unused]] const FF& scaling_factor) { -Avm_DECLARE_VIEWS(0); - - - auto tmp = (avm_conversion_to_radix_le_sel * (-avm_conversion_to_radix_le_sel + FF(1))); - tmp *= scaling_factor; - std::get<0>(evals) += tmp; -} -} + // Contribution 0 + { + Avm_DECLARE_VIEWS(0); + + auto tmp = (avm_conversion_to_radix_le_sel * (-avm_conversion_to_radix_le_sel + FF(1))); + tmp *= scaling_factor; + std::get<0>(evals) += tmp; + } + } }; template using avm_conversion = Relation>; - } \ No newline at end of file +} // namespace bb::Avm_vm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_keccakf1600.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_keccakf1600.hpp index 924862136fb..b5df59d290b 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_keccakf1600.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_keccakf1600.hpp @@ -6,49 +6,42 @@ namespace bb::Avm_vm { -template struct Avm_keccakf1600Row { - FF avm_keccakf1600_keccakf1600_sel {}; - }; - +template struct Avm_keccakf1600Row { + FF avm_keccakf1600_keccakf1600_sel{}; +}; - inline std::string get_relation_label_avm_keccakf1600(int index) { - switch (index) { - - } - return std::to_string(index); - } - +inline std::string get_relation_label_avm_keccakf1600(int index) +{ + switch (index) {} + return std::to_string(index); +} template class avm_keccakf1600Impl { - public: - using FF = FF_; - - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, -}; - - + public: + using FF = FF_; + + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 3, + }; + template - void static accumulate( - ContainerOverSubrelations& evals, - const AllEntities& new_term, - [[maybe_unused]] const RelationParameters&, - [[maybe_unused]] const FF& scaling_factor - ){ - - //Contribution 0 + void static accumulate(ContainerOverSubrelations& evals, + const AllEntities& new_term, + [[maybe_unused]] const RelationParameters&, + [[maybe_unused]] const FF& scaling_factor) { -Avm_DECLARE_VIEWS(0); - - - auto tmp = (avm_keccakf1600_keccakf1600_sel * (-avm_keccakf1600_keccakf1600_sel + FF(1))); - tmp *= scaling_factor; - std::get<0>(evals) += tmp; -} -} + // Contribution 0 + { + Avm_DECLARE_VIEWS(0); + + auto tmp = (avm_keccakf1600_keccakf1600_sel * (-avm_keccakf1600_keccakf1600_sel + FF(1))); + tmp *= scaling_factor; + std::get<0>(evals) += tmp; + } + } }; template using avm_keccakf1600 = Relation>; - } \ No newline at end of file +} // namespace bb::Avm_vm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_kernel.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_kernel.hpp index 1f4a80e919e..01b346e7a49 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_kernel.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_kernel.hpp @@ -6,182 +6,176 @@ namespace bb::Avm_vm { -template struct Avm_kernelRow { - FF avm_kernel_emit_l2_to_l1_msg_write_offset {}; - FF avm_kernel_emit_l2_to_l1_msg_write_offset_shift {}; - FF avm_kernel_emit_note_hash_write_offset {}; - FF avm_kernel_emit_note_hash_write_offset_shift {}; - FF avm_kernel_emit_nullifier_write_offset {}; - FF avm_kernel_emit_nullifier_write_offset_shift {}; - FF avm_kernel_emit_unencrypted_log_write_offset {}; - FF avm_kernel_emit_unencrypted_log_write_offset_shift {}; - FF avm_kernel_l1_to_l2_msg_exists_write_offset {}; - FF avm_kernel_l1_to_l2_msg_exists_write_offset_shift {}; - FF avm_kernel_note_hash_exist_write_offset {}; - FF avm_kernel_note_hash_exist_write_offset_shift {}; - FF avm_kernel_nullifier_exists_write_offset {}; - FF avm_kernel_nullifier_exists_write_offset_shift {}; - FF avm_kernel_sload_write_offset {}; - FF avm_kernel_sload_write_offset_shift {}; - FF avm_kernel_sstore_write_offset {}; - FF avm_kernel_sstore_write_offset_shift {}; - FF avm_main_last {}; - FF avm_main_sel_op_emit_l2_to_l1_msg {}; - FF avm_main_sel_op_emit_note_hash {}; - FF avm_main_sel_op_emit_nullifier {}; - FF avm_main_sel_op_emit_unencrypted_log {}; - FF avm_main_sel_op_l1_to_l2_msg_exists {}; - FF avm_main_sel_op_note_hash_exists {}; - FF avm_main_sel_op_nullifier_exists {}; - FF avm_main_sel_op_sload {}; - FF avm_main_sel_op_sstore {}; - }; - - - inline std::string get_relation_label_avm_kernel(int index) { - switch (index) { - case 0: - return "NOTE_HASH_EXISTS_INC_CONSISTENCY_CHECK"; - -case 1: - return "EMIT_NOTE_HASH_INC_CONSISTENCY_CHECK"; - -case 2: - return "NULLIFIER_EXISTS_INC_CONSISTENCY_CHECK"; - -case 3: - return "EMIT_NULLIFIER_INC_CONSISTENCY_CHECK"; - -case 4: - return "L1_TO_L2_MSG_EXISTS_INC_CONSISTENCY_CHECK"; - -case 5: - return "EMIT_UNENCRYPTED_LOG_INC_CONSISTENCY_CHECK"; - -case 6: - return "EMIT_L2_TO_L1_MSG_INC_CONSISTENCY_CHECK"; - -case 7: - return "SLOAD_INC_CONSISTENCY_CHECK"; - -case 8: - return "SSTORE_INC_CONSISTENCY_CHECK"; - - } - return std::to_string(index); +template struct Avm_kernelRow { + FF avm_kernel_emit_l2_to_l1_msg_write_offset{}; + FF avm_kernel_emit_l2_to_l1_msg_write_offset_shift{}; + FF avm_kernel_emit_note_hash_write_offset{}; + FF avm_kernel_emit_note_hash_write_offset_shift{}; + FF avm_kernel_emit_nullifier_write_offset{}; + FF avm_kernel_emit_nullifier_write_offset_shift{}; + FF avm_kernel_emit_unencrypted_log_write_offset{}; + FF avm_kernel_emit_unencrypted_log_write_offset_shift{}; + FF avm_kernel_l1_to_l2_msg_exists_write_offset{}; + FF avm_kernel_l1_to_l2_msg_exists_write_offset_shift{}; + FF avm_kernel_note_hash_exist_write_offset{}; + FF avm_kernel_note_hash_exist_write_offset_shift{}; + FF avm_kernel_nullifier_exists_write_offset{}; + FF avm_kernel_nullifier_exists_write_offset_shift{}; + FF avm_kernel_sload_write_offset{}; + FF avm_kernel_sload_write_offset_shift{}; + FF avm_kernel_sstore_write_offset{}; + FF avm_kernel_sstore_write_offset_shift{}; + FF avm_main_last{}; + FF avm_main_sel_op_emit_l2_to_l1_msg{}; + FF avm_main_sel_op_emit_note_hash{}; + FF avm_main_sel_op_emit_nullifier{}; + FF avm_main_sel_op_emit_unencrypted_log{}; + FF avm_main_sel_op_l1_to_l2_msg_exists{}; + FF avm_main_sel_op_note_hash_exists{}; + FF avm_main_sel_op_nullifier_exists{}; + FF avm_main_sel_op_sload{}; + FF avm_main_sel_op_sstore{}; +}; + +inline std::string get_relation_label_avm_kernel(int index) +{ + switch (index) { + case 0: + return "NOTE_HASH_EXISTS_INC_CONSISTENCY_CHECK"; + + case 1: + return "EMIT_NOTE_HASH_INC_CONSISTENCY_CHECK"; + + case 2: + return "NULLIFIER_EXISTS_INC_CONSISTENCY_CHECK"; + + case 3: + return "EMIT_NULLIFIER_INC_CONSISTENCY_CHECK"; + + case 4: + return "L1_TO_L2_MSG_EXISTS_INC_CONSISTENCY_CHECK"; + + case 5: + return "EMIT_UNENCRYPTED_LOG_INC_CONSISTENCY_CHECK"; + + case 6: + return "EMIT_L2_TO_L1_MSG_INC_CONSISTENCY_CHECK"; + + case 7: + return "SLOAD_INC_CONSISTENCY_CHECK"; + + case 8: + return "SSTORE_INC_CONSISTENCY_CHECK"; } - + return std::to_string(index); +} template class avm_kernelImpl { - public: - using FF = FF_; - - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, -}; - - + public: + using FF = FF_; + + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 3, 3, 3, 3, 3, 3, 3, 3, 3, + }; + template - void static accumulate( - ContainerOverSubrelations& evals, - const AllEntities& new_term, - [[maybe_unused]] const RelationParameters&, - [[maybe_unused]] const FF& scaling_factor - ){ - - //Contribution 0 - { -Avm_DECLARE_VIEWS(0); - - - auto tmp = ((-avm_main_last + FF(1)) * (avm_kernel_note_hash_exist_write_offset_shift - (avm_kernel_note_hash_exist_write_offset + avm_main_sel_op_note_hash_exists))); - tmp *= scaling_factor; - std::get<0>(evals) += tmp; -} -//Contribution 1 - { -Avm_DECLARE_VIEWS(1); - - - auto tmp = ((-avm_main_last + FF(1)) * (avm_kernel_emit_note_hash_write_offset_shift - (avm_kernel_emit_note_hash_write_offset + avm_main_sel_op_emit_note_hash))); - tmp *= scaling_factor; - std::get<1>(evals) += tmp; -} -//Contribution 2 - { -Avm_DECLARE_VIEWS(2); - - - auto tmp = ((-avm_main_last + FF(1)) * (avm_kernel_nullifier_exists_write_offset_shift - (avm_kernel_nullifier_exists_write_offset + avm_main_sel_op_nullifier_exists))); - tmp *= scaling_factor; - std::get<2>(evals) += tmp; -} -//Contribution 3 - { -Avm_DECLARE_VIEWS(3); - - - auto tmp = ((-avm_main_last + FF(1)) * (avm_kernel_emit_nullifier_write_offset_shift - (avm_kernel_emit_nullifier_write_offset + avm_main_sel_op_emit_nullifier))); - tmp *= scaling_factor; - std::get<3>(evals) += tmp; -} -//Contribution 4 - { -Avm_DECLARE_VIEWS(4); - - - auto tmp = ((-avm_main_last + FF(1)) * (avm_kernel_l1_to_l2_msg_exists_write_offset_shift - (avm_kernel_l1_to_l2_msg_exists_write_offset + avm_main_sel_op_l1_to_l2_msg_exists))); - tmp *= scaling_factor; - std::get<4>(evals) += tmp; -} -//Contribution 5 - { -Avm_DECLARE_VIEWS(5); - - - auto tmp = ((-avm_main_last + FF(1)) * (avm_kernel_emit_unencrypted_log_write_offset_shift - (avm_kernel_emit_unencrypted_log_write_offset + avm_main_sel_op_emit_unencrypted_log))); - tmp *= scaling_factor; - std::get<5>(evals) += tmp; -} -//Contribution 6 - { -Avm_DECLARE_VIEWS(6); - - - auto tmp = ((-avm_main_last + FF(1)) * (avm_kernel_emit_l2_to_l1_msg_write_offset_shift - (avm_kernel_emit_l2_to_l1_msg_write_offset + avm_main_sel_op_emit_l2_to_l1_msg))); - tmp *= scaling_factor; - std::get<6>(evals) += tmp; -} -//Contribution 7 + void static accumulate(ContainerOverSubrelations& evals, + const AllEntities& new_term, + [[maybe_unused]] const RelationParameters&, + [[maybe_unused]] const FF& scaling_factor) { -Avm_DECLARE_VIEWS(7); - - - auto tmp = ((-avm_main_last + FF(1)) * (avm_kernel_sload_write_offset_shift - (avm_kernel_sload_write_offset + avm_main_sel_op_sload))); - tmp *= scaling_factor; - std::get<7>(evals) += tmp; -} -//Contribution 8 - { -Avm_DECLARE_VIEWS(8); - - - auto tmp = ((-avm_main_last + FF(1)) * (avm_kernel_sstore_write_offset_shift - (avm_kernel_sstore_write_offset + avm_main_sel_op_sstore))); - tmp *= scaling_factor; - std::get<8>(evals) += tmp; -} -} + // Contribution 0 + { + Avm_DECLARE_VIEWS(0); + + auto tmp = ((-avm_main_last + FF(1)) * + (avm_kernel_note_hash_exist_write_offset_shift - + (avm_kernel_note_hash_exist_write_offset + avm_main_sel_op_note_hash_exists))); + tmp *= scaling_factor; + std::get<0>(evals) += tmp; + } + // Contribution 1 + { + Avm_DECLARE_VIEWS(1); + + auto tmp = ((-avm_main_last + FF(1)) * + (avm_kernel_emit_note_hash_write_offset_shift - + (avm_kernel_emit_note_hash_write_offset + avm_main_sel_op_emit_note_hash))); + tmp *= scaling_factor; + std::get<1>(evals) += tmp; + } + // Contribution 2 + { + Avm_DECLARE_VIEWS(2); + + auto tmp = ((-avm_main_last + FF(1)) * + (avm_kernel_nullifier_exists_write_offset_shift - + (avm_kernel_nullifier_exists_write_offset + avm_main_sel_op_nullifier_exists))); + tmp *= scaling_factor; + std::get<2>(evals) += tmp; + } + // Contribution 3 + { + Avm_DECLARE_VIEWS(3); + + auto tmp = ((-avm_main_last + FF(1)) * + (avm_kernel_emit_nullifier_write_offset_shift - + (avm_kernel_emit_nullifier_write_offset + avm_main_sel_op_emit_nullifier))); + tmp *= scaling_factor; + std::get<3>(evals) += tmp; + } + // Contribution 4 + { + Avm_DECLARE_VIEWS(4); + + auto tmp = ((-avm_main_last + FF(1)) * + (avm_kernel_l1_to_l2_msg_exists_write_offset_shift - + (avm_kernel_l1_to_l2_msg_exists_write_offset + avm_main_sel_op_l1_to_l2_msg_exists))); + tmp *= scaling_factor; + std::get<4>(evals) += tmp; + } + // Contribution 5 + { + Avm_DECLARE_VIEWS(5); + + auto tmp = ((-avm_main_last + FF(1)) * + (avm_kernel_emit_unencrypted_log_write_offset_shift - + (avm_kernel_emit_unencrypted_log_write_offset + avm_main_sel_op_emit_unencrypted_log))); + tmp *= scaling_factor; + std::get<5>(evals) += tmp; + } + // Contribution 6 + { + Avm_DECLARE_VIEWS(6); + + auto tmp = ((-avm_main_last + FF(1)) * + (avm_kernel_emit_l2_to_l1_msg_write_offset_shift - + (avm_kernel_emit_l2_to_l1_msg_write_offset + avm_main_sel_op_emit_l2_to_l1_msg))); + tmp *= scaling_factor; + std::get<6>(evals) += tmp; + } + // Contribution 7 + { + Avm_DECLARE_VIEWS(7); + + auto tmp = ((-avm_main_last + FF(1)) * (avm_kernel_sload_write_offset_shift - + (avm_kernel_sload_write_offset + avm_main_sel_op_sload))); + tmp *= scaling_factor; + std::get<7>(evals) += tmp; + } + // Contribution 8 + { + Avm_DECLARE_VIEWS(8); + + auto tmp = ((-avm_main_last + FF(1)) * (avm_kernel_sstore_write_offset_shift - + (avm_kernel_sstore_write_offset + avm_main_sel_op_sstore))); + tmp *= scaling_factor; + std::get<8>(evals) += tmp; + } + } }; template using avm_kernel = Relation>; - } \ No newline at end of file +} // namespace bb::Avm_vm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_mem.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_mem.hpp index 49cb36d3ba6..f69768d2f6e 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_mem.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_mem.hpp @@ -6,536 +6,472 @@ namespace bb::Avm_vm { -template struct Avm_memRow { - FF avm_main_first {}; - FF avm_mem_addr {}; - FF avm_mem_clk {}; - FF avm_mem_diff_hi {}; - FF avm_mem_diff_lo {}; - FF avm_mem_diff_mid {}; - FF avm_mem_glob_addr {}; - FF avm_mem_glob_addr_shift {}; - FF avm_mem_ind_op_a {}; - FF avm_mem_ind_op_b {}; - FF avm_mem_ind_op_c {}; - FF avm_mem_ind_op_d {}; - FF avm_mem_last {}; - FF avm_mem_lastAccess {}; - FF avm_mem_mem_sel {}; - FF avm_mem_mem_sel_shift {}; - FF avm_mem_one_min_inv {}; - FF avm_mem_op_a {}; - FF avm_mem_op_b {}; - FF avm_mem_op_c {}; - FF avm_mem_op_d {}; - FF avm_mem_r_in_tag {}; - FF avm_mem_rng_chk_sel {}; - FF avm_mem_rw {}; - FF avm_mem_rw_shift {}; - FF avm_mem_sel_cmov {}; - FF avm_mem_sel_mov_a {}; - FF avm_mem_sel_mov_b {}; - FF avm_mem_skip_check_tag {}; - FF avm_mem_space_id {}; - FF avm_mem_tag {}; - FF avm_mem_tag_err {}; - FF avm_mem_tag_shift {}; - FF avm_mem_tsp {}; - FF avm_mem_tsp_shift {}; - FF avm_mem_val {}; - FF avm_mem_val_shift {}; - FF avm_mem_w_in_tag {}; - }; - - - inline std::string get_relation_label_avm_mem(int index) { - switch (index) { - case 14: - return "MEM_CONTIGUOUS"; - -case 15: - return "MEM_FIRST_EMPTY"; - -case 16: - return "MEM_LAST"; - -case 18: - return "TIMESTAMP"; - -case 19: - return "GLOBAL_ADDR"; - -case 20: - return "LAST_ACCESS_FIRST_ROW"; - -case 21: - return "MEM_LAST_ACCESS_DELIMITER"; - -case 22: - return "DIFF_RNG_CHK_DEC"; - -case 23: - return "MEM_READ_WRITE_VAL_CONSISTENCY"; - -case 24: - return "MEM_READ_WRITE_TAG_CONSISTENCY"; - -case 25: - return "MEM_ZERO_INIT"; - -case 26: - return "SKIP_CHECK_TAG"; - -case 27: - return "MEM_IN_TAG_CONSISTENCY_1"; - -case 28: - return "MEM_IN_TAG_CONSISTENCY_2"; - -case 29: - return "NO_TAG_ERR_WRITE_OR_SKIP"; - -case 31: - return "NO_TAG_ERR_WRITE"; - -case 40: - return "MOV_SAME_TAG"; - - } - return std::to_string(index); +template struct Avm_memRow { + FF avm_main_first{}; + FF avm_mem_addr{}; + FF avm_mem_clk{}; + FF avm_mem_diff_hi{}; + FF avm_mem_diff_lo{}; + FF avm_mem_diff_mid{}; + FF avm_mem_glob_addr{}; + FF avm_mem_glob_addr_shift{}; + FF avm_mem_ind_op_a{}; + FF avm_mem_ind_op_b{}; + FF avm_mem_ind_op_c{}; + FF avm_mem_ind_op_d{}; + FF avm_mem_last{}; + FF avm_mem_lastAccess{}; + FF avm_mem_mem_sel{}; + FF avm_mem_mem_sel_shift{}; + FF avm_mem_one_min_inv{}; + FF avm_mem_op_a{}; + FF avm_mem_op_b{}; + FF avm_mem_op_c{}; + FF avm_mem_op_d{}; + FF avm_mem_r_in_tag{}; + FF avm_mem_rng_chk_sel{}; + FF avm_mem_rw{}; + FF avm_mem_rw_shift{}; + FF avm_mem_sel_cmov{}; + FF avm_mem_sel_mov_a{}; + FF avm_mem_sel_mov_b{}; + FF avm_mem_skip_check_tag{}; + FF avm_mem_space_id{}; + FF avm_mem_tag{}; + FF avm_mem_tag_err{}; + FF avm_mem_tag_shift{}; + FF avm_mem_tsp{}; + FF avm_mem_tsp_shift{}; + FF avm_mem_val{}; + FF avm_mem_val_shift{}; + FF avm_mem_w_in_tag{}; +}; + +inline std::string get_relation_label_avm_mem(int index) +{ + switch (index) { + case 14: + return "MEM_CONTIGUOUS"; + + case 15: + return "MEM_FIRST_EMPTY"; + + case 16: + return "MEM_LAST"; + + case 18: + return "TIMESTAMP"; + + case 19: + return "GLOBAL_ADDR"; + + case 20: + return "LAST_ACCESS_FIRST_ROW"; + + case 21: + return "MEM_LAST_ACCESS_DELIMITER"; + + case 22: + return "DIFF_RNG_CHK_DEC"; + + case 23: + return "MEM_READ_WRITE_VAL_CONSISTENCY"; + + case 24: + return "MEM_READ_WRITE_TAG_CONSISTENCY"; + + case 25: + return "MEM_ZERO_INIT"; + + case 26: + return "SKIP_CHECK_TAG"; + + case 27: + return "MEM_IN_TAG_CONSISTENCY_1"; + + case 28: + return "MEM_IN_TAG_CONSISTENCY_2"; + + case 29: + return "NO_TAG_ERR_WRITE_OR_SKIP"; + + case 31: + return "NO_TAG_ERR_WRITE"; + + case 40: + return "MOV_SAME_TAG"; } - + return std::to_string(index); +} template class avm_memImpl { - public: - using FF = FF_; - - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 2, - 3, - 4, - 3, - 4, - 3, - 4, - 3, - 3, - 3, - 4, - 4, - 4, - 4, - 4, - 5, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, -}; - - + public: + using FF = FF_; + + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 4, 3, 4, 3, 4, 3, 3, + 3, 4, 4, 4, 4, 4, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + }; + template - void static accumulate( - ContainerOverSubrelations& evals, - const AllEntities& new_term, - [[maybe_unused]] const RelationParameters&, - [[maybe_unused]] const FF& scaling_factor - ){ - - //Contribution 0 - { -Avm_DECLARE_VIEWS(0); - - - auto tmp = (avm_mem_lastAccess * (-avm_mem_lastAccess + FF(1))); - tmp *= scaling_factor; - std::get<0>(evals) += tmp; -} -//Contribution 1 - { -Avm_DECLARE_VIEWS(1); - - - auto tmp = (avm_mem_last * (-avm_mem_last + FF(1))); - tmp *= scaling_factor; - std::get<1>(evals) += tmp; -} -//Contribution 2 - { -Avm_DECLARE_VIEWS(2); - - - auto tmp = (avm_mem_rw * (-avm_mem_rw + FF(1))); - tmp *= scaling_factor; - std::get<2>(evals) += tmp; -} -//Contribution 3 - { -Avm_DECLARE_VIEWS(3); - - - auto tmp = (avm_mem_tag_err * (-avm_mem_tag_err + FF(1))); - tmp *= scaling_factor; - std::get<3>(evals) += tmp; -} -//Contribution 4 - { -Avm_DECLARE_VIEWS(4); - - - auto tmp = (avm_mem_op_a * (-avm_mem_op_a + FF(1))); - tmp *= scaling_factor; - std::get<4>(evals) += tmp; -} -//Contribution 5 - { -Avm_DECLARE_VIEWS(5); - - - auto tmp = (avm_mem_op_b * (-avm_mem_op_b + FF(1))); - tmp *= scaling_factor; - std::get<5>(evals) += tmp; -} -//Contribution 6 - { -Avm_DECLARE_VIEWS(6); - - - auto tmp = (avm_mem_op_c * (-avm_mem_op_c + FF(1))); - tmp *= scaling_factor; - std::get<6>(evals) += tmp; -} -//Contribution 7 - { -Avm_DECLARE_VIEWS(7); - - - auto tmp = (avm_mem_op_d * (-avm_mem_op_d + FF(1))); - tmp *= scaling_factor; - std::get<7>(evals) += tmp; -} -//Contribution 8 - { -Avm_DECLARE_VIEWS(8); - - - auto tmp = (avm_mem_ind_op_a * (-avm_mem_ind_op_a + FF(1))); - tmp *= scaling_factor; - std::get<8>(evals) += tmp; -} -//Contribution 9 - { -Avm_DECLARE_VIEWS(9); - - - auto tmp = (avm_mem_ind_op_b * (-avm_mem_ind_op_b + FF(1))); - tmp *= scaling_factor; - std::get<9>(evals) += tmp; -} -//Contribution 10 - { -Avm_DECLARE_VIEWS(10); - - - auto tmp = (avm_mem_ind_op_c * (-avm_mem_ind_op_c + FF(1))); - tmp *= scaling_factor; - std::get<10>(evals) += tmp; -} -//Contribution 11 - { -Avm_DECLARE_VIEWS(11); - - - auto tmp = (avm_mem_ind_op_d * (-avm_mem_ind_op_d + FF(1))); - tmp *= scaling_factor; - std::get<11>(evals) += tmp; -} -//Contribution 12 - { -Avm_DECLARE_VIEWS(12); - - - auto tmp = (avm_mem_mem_sel - (((((((avm_mem_op_a + avm_mem_op_b) + avm_mem_op_c) + avm_mem_op_d) + avm_mem_ind_op_a) + avm_mem_ind_op_b) + avm_mem_ind_op_c) + avm_mem_ind_op_d)); - tmp *= scaling_factor; - std::get<12>(evals) += tmp; -} -//Contribution 13 - { -Avm_DECLARE_VIEWS(13); - - - auto tmp = (avm_mem_mem_sel * (avm_mem_mem_sel - FF(1))); - tmp *= scaling_factor; - std::get<13>(evals) += tmp; -} -//Contribution 14 - { -Avm_DECLARE_VIEWS(14); - - - auto tmp = (((-avm_main_first + FF(1)) * avm_mem_mem_sel_shift) * (-avm_mem_mem_sel + FF(1))); - tmp *= scaling_factor; - std::get<14>(evals) += tmp; -} -//Contribution 15 - { -Avm_DECLARE_VIEWS(15); - - - auto tmp = (avm_main_first * avm_mem_mem_sel); - tmp *= scaling_factor; - std::get<15>(evals) += tmp; -} -//Contribution 16 - { -Avm_DECLARE_VIEWS(16); - - - auto tmp = (((-avm_mem_last + FF(1)) * avm_mem_mem_sel) * (-avm_mem_mem_sel_shift + FF(1))); - tmp *= scaling_factor; - std::get<16>(evals) += tmp; -} -//Contribution 17 - { -Avm_DECLARE_VIEWS(17); - - - auto tmp = (avm_mem_rng_chk_sel - (avm_mem_mem_sel * (-avm_mem_last + FF(1)))); - tmp *= scaling_factor; - std::get<17>(evals) += tmp; -} -//Contribution 18 - { -Avm_DECLARE_VIEWS(18); - - - auto tmp = (avm_mem_tsp - ((avm_mem_clk * FF(12)) + (avm_mem_mem_sel * ((((avm_mem_ind_op_b + avm_mem_op_b) + ((avm_mem_ind_op_c + avm_mem_op_c) * FF(2))) + ((avm_mem_ind_op_d + avm_mem_op_d) * FF(3))) + (((-(((avm_mem_ind_op_a + avm_mem_ind_op_b) + avm_mem_ind_op_c) + avm_mem_ind_op_d) + FF(1)) + avm_mem_rw) * FF(4)))))); - tmp *= scaling_factor; - std::get<18>(evals) += tmp; -} -//Contribution 19 - { -Avm_DECLARE_VIEWS(19); - - - auto tmp = (avm_mem_glob_addr - ((avm_mem_space_id * FF(4294967296UL)) + avm_mem_addr)); - tmp *= scaling_factor; - std::get<19>(evals) += tmp; -} -//Contribution 20 - { -Avm_DECLARE_VIEWS(20); - - - auto tmp = (avm_main_first * (-avm_mem_lastAccess + FF(1))); - tmp *= scaling_factor; - std::get<20>(evals) += tmp; -} -//Contribution 21 - { -Avm_DECLARE_VIEWS(21); - - - auto tmp = ((-avm_mem_lastAccess + FF(1)) * (avm_mem_glob_addr_shift - avm_mem_glob_addr)); - tmp *= scaling_factor; - std::get<21>(evals) += tmp; -} -//Contribution 22 - { -Avm_DECLARE_VIEWS(22); - - - auto tmp = (avm_mem_rng_chk_sel * (((((avm_mem_lastAccess * (avm_mem_glob_addr_shift - avm_mem_glob_addr)) + ((-avm_mem_lastAccess + FF(1)) * (avm_mem_tsp_shift - avm_mem_tsp))) - (avm_mem_diff_hi * FF(4294967296UL))) - (avm_mem_diff_mid * FF(65536))) - avm_mem_diff_lo)); - tmp *= scaling_factor; - std::get<22>(evals) += tmp; -} -//Contribution 23 - { -Avm_DECLARE_VIEWS(23); - - - auto tmp = (((-avm_mem_lastAccess + FF(1)) * (-avm_mem_rw_shift + FF(1))) * (avm_mem_val_shift - avm_mem_val)); - tmp *= scaling_factor; - std::get<23>(evals) += tmp; -} -//Contribution 24 - { -Avm_DECLARE_VIEWS(24); - - - auto tmp = (((-avm_mem_lastAccess + FF(1)) * (-avm_mem_rw_shift + FF(1))) * (avm_mem_tag_shift - avm_mem_tag)); - tmp *= scaling_factor; - std::get<24>(evals) += tmp; -} -//Contribution 25 - { -Avm_DECLARE_VIEWS(25); - - - auto tmp = ((avm_mem_lastAccess * (-avm_mem_rw_shift + FF(1))) * avm_mem_val_shift); - tmp *= scaling_factor; - std::get<25>(evals) += tmp; -} -//Contribution 26 - { -Avm_DECLARE_VIEWS(26); - - - auto tmp = (avm_mem_skip_check_tag - (avm_mem_sel_cmov * ((avm_mem_op_d + (avm_mem_op_a * (-avm_mem_sel_mov_a + FF(1)))) + (avm_mem_op_b * (-avm_mem_sel_mov_b + FF(1)))))); - tmp *= scaling_factor; - std::get<26>(evals) += tmp; -} -//Contribution 27 - { -Avm_DECLARE_VIEWS(27); - - - auto tmp = (((-avm_mem_skip_check_tag + FF(1)) * (-avm_mem_rw + FF(1))) * (((avm_mem_r_in_tag - avm_mem_tag) * (-avm_mem_one_min_inv + FF(1))) - avm_mem_tag_err)); - tmp *= scaling_factor; - std::get<27>(evals) += tmp; -} -//Contribution 28 - { -Avm_DECLARE_VIEWS(28); - - - auto tmp = ((-avm_mem_tag_err + FF(1)) * avm_mem_one_min_inv); - tmp *= scaling_factor; - std::get<28>(evals) += tmp; -} -//Contribution 29 - { -Avm_DECLARE_VIEWS(29); - - - auto tmp = ((avm_mem_skip_check_tag + avm_mem_rw) * avm_mem_tag_err); - tmp *= scaling_factor; - std::get<29>(evals) += tmp; -} -//Contribution 30 - { -Avm_DECLARE_VIEWS(30); - - - auto tmp = (avm_mem_rw * (avm_mem_w_in_tag - avm_mem_tag)); - tmp *= scaling_factor; - std::get<30>(evals) += tmp; -} -//Contribution 31 - { -Avm_DECLARE_VIEWS(31); - - - auto tmp = (avm_mem_rw * avm_mem_tag_err); - tmp *= scaling_factor; - std::get<31>(evals) += tmp; -} -//Contribution 32 - { -Avm_DECLARE_VIEWS(32); - - - auto tmp = (avm_mem_ind_op_a * (avm_mem_r_in_tag - FF(3))); - tmp *= scaling_factor; - std::get<32>(evals) += tmp; -} -//Contribution 33 - { -Avm_DECLARE_VIEWS(33); - - - auto tmp = (avm_mem_ind_op_b * (avm_mem_r_in_tag - FF(3))); - tmp *= scaling_factor; - std::get<33>(evals) += tmp; -} -//Contribution 34 - { -Avm_DECLARE_VIEWS(34); - - - auto tmp = (avm_mem_ind_op_c * (avm_mem_r_in_tag - FF(3))); - tmp *= scaling_factor; - std::get<34>(evals) += tmp; -} -//Contribution 35 - { -Avm_DECLARE_VIEWS(35); - - - auto tmp = (avm_mem_ind_op_d * (avm_mem_r_in_tag - FF(3))); - tmp *= scaling_factor; - std::get<35>(evals) += tmp; -} -//Contribution 36 + void static accumulate(ContainerOverSubrelations& evals, + const AllEntities& new_term, + [[maybe_unused]] const RelationParameters&, + [[maybe_unused]] const FF& scaling_factor) { -Avm_DECLARE_VIEWS(36); - - - auto tmp = (avm_mem_ind_op_a * avm_mem_rw); - tmp *= scaling_factor; - std::get<36>(evals) += tmp; -} -//Contribution 37 - { -Avm_DECLARE_VIEWS(37); - - - auto tmp = (avm_mem_ind_op_b * avm_mem_rw); - tmp *= scaling_factor; - std::get<37>(evals) += tmp; -} -//Contribution 38 - { -Avm_DECLARE_VIEWS(38); - - - auto tmp = (avm_mem_ind_op_c * avm_mem_rw); - tmp *= scaling_factor; - std::get<38>(evals) += tmp; -} -//Contribution 39 - { -Avm_DECLARE_VIEWS(39); - - - auto tmp = (avm_mem_ind_op_d * avm_mem_rw); - tmp *= scaling_factor; - std::get<39>(evals) += tmp; -} -//Contribution 40 - { -Avm_DECLARE_VIEWS(40); - - - auto tmp = ((avm_mem_sel_mov_a + avm_mem_sel_mov_b) * avm_mem_tag_err); - tmp *= scaling_factor; - std::get<40>(evals) += tmp; -} -} + // Contribution 0 + { + Avm_DECLARE_VIEWS(0); + + auto tmp = (avm_mem_lastAccess * (-avm_mem_lastAccess + FF(1))); + tmp *= scaling_factor; + std::get<0>(evals) += tmp; + } + // Contribution 1 + { + Avm_DECLARE_VIEWS(1); + + auto tmp = (avm_mem_last * (-avm_mem_last + FF(1))); + tmp *= scaling_factor; + std::get<1>(evals) += tmp; + } + // Contribution 2 + { + Avm_DECLARE_VIEWS(2); + + auto tmp = (avm_mem_rw * (-avm_mem_rw + FF(1))); + tmp *= scaling_factor; + std::get<2>(evals) += tmp; + } + // Contribution 3 + { + Avm_DECLARE_VIEWS(3); + + auto tmp = (avm_mem_tag_err * (-avm_mem_tag_err + FF(1))); + tmp *= scaling_factor; + std::get<3>(evals) += tmp; + } + // Contribution 4 + { + Avm_DECLARE_VIEWS(4); + + auto tmp = (avm_mem_op_a * (-avm_mem_op_a + FF(1))); + tmp *= scaling_factor; + std::get<4>(evals) += tmp; + } + // Contribution 5 + { + Avm_DECLARE_VIEWS(5); + + auto tmp = (avm_mem_op_b * (-avm_mem_op_b + FF(1))); + tmp *= scaling_factor; + std::get<5>(evals) += tmp; + } + // Contribution 6 + { + Avm_DECLARE_VIEWS(6); + + auto tmp = (avm_mem_op_c * (-avm_mem_op_c + FF(1))); + tmp *= scaling_factor; + std::get<6>(evals) += tmp; + } + // Contribution 7 + { + Avm_DECLARE_VIEWS(7); + + auto tmp = (avm_mem_op_d * (-avm_mem_op_d + FF(1))); + tmp *= scaling_factor; + std::get<7>(evals) += tmp; + } + // Contribution 8 + { + Avm_DECLARE_VIEWS(8); + + auto tmp = (avm_mem_ind_op_a * (-avm_mem_ind_op_a + FF(1))); + tmp *= scaling_factor; + std::get<8>(evals) += tmp; + } + // Contribution 9 + { + Avm_DECLARE_VIEWS(9); + + auto tmp = (avm_mem_ind_op_b * (-avm_mem_ind_op_b + FF(1))); + tmp *= scaling_factor; + std::get<9>(evals) += tmp; + } + // Contribution 10 + { + Avm_DECLARE_VIEWS(10); + + auto tmp = (avm_mem_ind_op_c * (-avm_mem_ind_op_c + FF(1))); + tmp *= scaling_factor; + std::get<10>(evals) += tmp; + } + // Contribution 11 + { + Avm_DECLARE_VIEWS(11); + + auto tmp = (avm_mem_ind_op_d * (-avm_mem_ind_op_d + FF(1))); + tmp *= scaling_factor; + std::get<11>(evals) += tmp; + } + // Contribution 12 + { + Avm_DECLARE_VIEWS(12); + + auto tmp = (avm_mem_mem_sel - + (((((((avm_mem_op_a + avm_mem_op_b) + avm_mem_op_c) + avm_mem_op_d) + avm_mem_ind_op_a) + + avm_mem_ind_op_b) + + avm_mem_ind_op_c) + + avm_mem_ind_op_d)); + tmp *= scaling_factor; + std::get<12>(evals) += tmp; + } + // Contribution 13 + { + Avm_DECLARE_VIEWS(13); + + auto tmp = (avm_mem_mem_sel * (avm_mem_mem_sel - FF(1))); + tmp *= scaling_factor; + std::get<13>(evals) += tmp; + } + // Contribution 14 + { + Avm_DECLARE_VIEWS(14); + + auto tmp = (((-avm_main_first + FF(1)) * avm_mem_mem_sel_shift) * (-avm_mem_mem_sel + FF(1))); + tmp *= scaling_factor; + std::get<14>(evals) += tmp; + } + // Contribution 15 + { + Avm_DECLARE_VIEWS(15); + + auto tmp = (avm_main_first * avm_mem_mem_sel); + tmp *= scaling_factor; + std::get<15>(evals) += tmp; + } + // Contribution 16 + { + Avm_DECLARE_VIEWS(16); + + auto tmp = (((-avm_mem_last + FF(1)) * avm_mem_mem_sel) * (-avm_mem_mem_sel_shift + FF(1))); + tmp *= scaling_factor; + std::get<16>(evals) += tmp; + } + // Contribution 17 + { + Avm_DECLARE_VIEWS(17); + + auto tmp = (avm_mem_rng_chk_sel - (avm_mem_mem_sel * (-avm_mem_last + FF(1)))); + tmp *= scaling_factor; + std::get<17>(evals) += tmp; + } + // Contribution 18 + { + Avm_DECLARE_VIEWS(18); + + auto tmp = + (avm_mem_tsp - + ((avm_mem_clk * FF(12)) + + (avm_mem_mem_sel * + ((((avm_mem_ind_op_b + avm_mem_op_b) + ((avm_mem_ind_op_c + avm_mem_op_c) * FF(2))) + + ((avm_mem_ind_op_d + avm_mem_op_d) * FF(3))) + + (((-(((avm_mem_ind_op_a + avm_mem_ind_op_b) + avm_mem_ind_op_c) + avm_mem_ind_op_d) + FF(1)) + + avm_mem_rw) * + FF(4)))))); + tmp *= scaling_factor; + std::get<18>(evals) += tmp; + } + // Contribution 19 + { + Avm_DECLARE_VIEWS(19); + + auto tmp = (avm_mem_glob_addr - ((avm_mem_space_id * FF(4294967296UL)) + avm_mem_addr)); + tmp *= scaling_factor; + std::get<19>(evals) += tmp; + } + // Contribution 20 + { + Avm_DECLARE_VIEWS(20); + + auto tmp = (avm_main_first * (-avm_mem_lastAccess + FF(1))); + tmp *= scaling_factor; + std::get<20>(evals) += tmp; + } + // Contribution 21 + { + Avm_DECLARE_VIEWS(21); + + auto tmp = ((-avm_mem_lastAccess + FF(1)) * (avm_mem_glob_addr_shift - avm_mem_glob_addr)); + tmp *= scaling_factor; + std::get<21>(evals) += tmp; + } + // Contribution 22 + { + Avm_DECLARE_VIEWS(22); + + auto tmp = (avm_mem_rng_chk_sel * (((((avm_mem_lastAccess * (avm_mem_glob_addr_shift - avm_mem_glob_addr)) + + ((-avm_mem_lastAccess + FF(1)) * (avm_mem_tsp_shift - avm_mem_tsp))) - + (avm_mem_diff_hi * FF(4294967296UL))) - + (avm_mem_diff_mid * FF(65536))) - + avm_mem_diff_lo)); + tmp *= scaling_factor; + std::get<22>(evals) += tmp; + } + // Contribution 23 + { + Avm_DECLARE_VIEWS(23); + + auto tmp = + (((-avm_mem_lastAccess + FF(1)) * (-avm_mem_rw_shift + FF(1))) * (avm_mem_val_shift - avm_mem_val)); + tmp *= scaling_factor; + std::get<23>(evals) += tmp; + } + // Contribution 24 + { + Avm_DECLARE_VIEWS(24); + + auto tmp = + (((-avm_mem_lastAccess + FF(1)) * (-avm_mem_rw_shift + FF(1))) * (avm_mem_tag_shift - avm_mem_tag)); + tmp *= scaling_factor; + std::get<24>(evals) += tmp; + } + // Contribution 25 + { + Avm_DECLARE_VIEWS(25); + + auto tmp = ((avm_mem_lastAccess * (-avm_mem_rw_shift + FF(1))) * avm_mem_val_shift); + tmp *= scaling_factor; + std::get<25>(evals) += tmp; + } + // Contribution 26 + { + Avm_DECLARE_VIEWS(26); + + auto tmp = (avm_mem_skip_check_tag - + (avm_mem_sel_cmov * ((avm_mem_op_d + (avm_mem_op_a * (-avm_mem_sel_mov_a + FF(1)))) + + (avm_mem_op_b * (-avm_mem_sel_mov_b + FF(1)))))); + tmp *= scaling_factor; + std::get<26>(evals) += tmp; + } + // Contribution 27 + { + Avm_DECLARE_VIEWS(27); + + auto tmp = (((-avm_mem_skip_check_tag + FF(1)) * (-avm_mem_rw + FF(1))) * + (((avm_mem_r_in_tag - avm_mem_tag) * (-avm_mem_one_min_inv + FF(1))) - avm_mem_tag_err)); + tmp *= scaling_factor; + std::get<27>(evals) += tmp; + } + // Contribution 28 + { + Avm_DECLARE_VIEWS(28); + + auto tmp = ((-avm_mem_tag_err + FF(1)) * avm_mem_one_min_inv); + tmp *= scaling_factor; + std::get<28>(evals) += tmp; + } + // Contribution 29 + { + Avm_DECLARE_VIEWS(29); + + auto tmp = ((avm_mem_skip_check_tag + avm_mem_rw) * avm_mem_tag_err); + tmp *= scaling_factor; + std::get<29>(evals) += tmp; + } + // Contribution 30 + { + Avm_DECLARE_VIEWS(30); + + auto tmp = (avm_mem_rw * (avm_mem_w_in_tag - avm_mem_tag)); + tmp *= scaling_factor; + std::get<30>(evals) += tmp; + } + // Contribution 31 + { + Avm_DECLARE_VIEWS(31); + + auto tmp = (avm_mem_rw * avm_mem_tag_err); + tmp *= scaling_factor; + std::get<31>(evals) += tmp; + } + // Contribution 32 + { + Avm_DECLARE_VIEWS(32); + + auto tmp = (avm_mem_ind_op_a * (avm_mem_r_in_tag - FF(3))); + tmp *= scaling_factor; + std::get<32>(evals) += tmp; + } + // Contribution 33 + { + Avm_DECLARE_VIEWS(33); + + auto tmp = (avm_mem_ind_op_b * (avm_mem_r_in_tag - FF(3))); + tmp *= scaling_factor; + std::get<33>(evals) += tmp; + } + // Contribution 34 + { + Avm_DECLARE_VIEWS(34); + + auto tmp = (avm_mem_ind_op_c * (avm_mem_r_in_tag - FF(3))); + tmp *= scaling_factor; + std::get<34>(evals) += tmp; + } + // Contribution 35 + { + Avm_DECLARE_VIEWS(35); + + auto tmp = (avm_mem_ind_op_d * (avm_mem_r_in_tag - FF(3))); + tmp *= scaling_factor; + std::get<35>(evals) += tmp; + } + // Contribution 36 + { + Avm_DECLARE_VIEWS(36); + + auto tmp = (avm_mem_ind_op_a * avm_mem_rw); + tmp *= scaling_factor; + std::get<36>(evals) += tmp; + } + // Contribution 37 + { + Avm_DECLARE_VIEWS(37); + + auto tmp = (avm_mem_ind_op_b * avm_mem_rw); + tmp *= scaling_factor; + std::get<37>(evals) += tmp; + } + // Contribution 38 + { + Avm_DECLARE_VIEWS(38); + + auto tmp = (avm_mem_ind_op_c * avm_mem_rw); + tmp *= scaling_factor; + std::get<38>(evals) += tmp; + } + // Contribution 39 + { + Avm_DECLARE_VIEWS(39); + + auto tmp = (avm_mem_ind_op_d * avm_mem_rw); + tmp *= scaling_factor; + std::get<39>(evals) += tmp; + } + // Contribution 40 + { + Avm_DECLARE_VIEWS(40); + + auto tmp = ((avm_mem_sel_mov_a + avm_mem_sel_mov_b) * avm_mem_tag_err); + tmp *= scaling_factor; + std::get<40>(evals) += tmp; + } + } }; template using avm_mem = Relation>; - } \ No newline at end of file +} // namespace bb::Avm_vm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_pedersen.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_pedersen.hpp index e5c37f65804..6a0c0be6824 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_pedersen.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_pedersen.hpp @@ -6,49 +6,42 @@ namespace bb::Avm_vm { -template struct Avm_pedersenRow { - FF avm_pedersen_pedersen_sel {}; - }; - +template struct Avm_pedersenRow { + FF avm_pedersen_pedersen_sel{}; +}; - inline std::string get_relation_label_avm_pedersen(int index) { - switch (index) { - - } - return std::to_string(index); - } - +inline std::string get_relation_label_avm_pedersen(int index) +{ + switch (index) {} + return std::to_string(index); +} template class avm_pedersenImpl { - public: - using FF = FF_; - - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, -}; - - + public: + using FF = FF_; + + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 3, + }; + template - void static accumulate( - ContainerOverSubrelations& evals, - const AllEntities& new_term, - [[maybe_unused]] const RelationParameters&, - [[maybe_unused]] const FF& scaling_factor - ){ - - //Contribution 0 + void static accumulate(ContainerOverSubrelations& evals, + const AllEntities& new_term, + [[maybe_unused]] const RelationParameters&, + [[maybe_unused]] const FF& scaling_factor) { -Avm_DECLARE_VIEWS(0); - - - auto tmp = (avm_pedersen_pedersen_sel * (-avm_pedersen_pedersen_sel + FF(1))); - tmp *= scaling_factor; - std::get<0>(evals) += tmp; -} -} + // Contribution 0 + { + Avm_DECLARE_VIEWS(0); + + auto tmp = (avm_pedersen_pedersen_sel * (-avm_pedersen_pedersen_sel + FF(1))); + tmp *= scaling_factor; + std::get<0>(evals) += tmp; + } + } }; template using avm_pedersen = Relation>; - } \ No newline at end of file +} // namespace bb::Avm_vm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_poseidon2.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_poseidon2.hpp index 8fa8420c1cd..31f558e82db 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_poseidon2.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_poseidon2.hpp @@ -6,49 +6,42 @@ namespace bb::Avm_vm { -template struct Avm_poseidon2Row { - FF avm_poseidon2_poseidon_perm_sel {}; - }; - +template struct Avm_poseidon2Row { + FF avm_poseidon2_poseidon_perm_sel{}; +}; - inline std::string get_relation_label_avm_poseidon2(int index) { - switch (index) { - - } - return std::to_string(index); - } - +inline std::string get_relation_label_avm_poseidon2(int index) +{ + switch (index) {} + return std::to_string(index); +} template class avm_poseidon2Impl { - public: - using FF = FF_; - - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, -}; - - + public: + using FF = FF_; + + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 3, + }; + template - void static accumulate( - ContainerOverSubrelations& evals, - const AllEntities& new_term, - [[maybe_unused]] const RelationParameters&, - [[maybe_unused]] const FF& scaling_factor - ){ - - //Contribution 0 + void static accumulate(ContainerOverSubrelations& evals, + const AllEntities& new_term, + [[maybe_unused]] const RelationParameters&, + [[maybe_unused]] const FF& scaling_factor) { -Avm_DECLARE_VIEWS(0); - - - auto tmp = (avm_poseidon2_poseidon_perm_sel * (-avm_poseidon2_poseidon_perm_sel + FF(1))); - tmp *= scaling_factor; - std::get<0>(evals) += tmp; -} -} + // Contribution 0 + { + Avm_DECLARE_VIEWS(0); + + auto tmp = (avm_poseidon2_poseidon_perm_sel * (-avm_poseidon2_poseidon_perm_sel + FF(1))); + tmp *= scaling_factor; + std::get<0>(evals) += tmp; + } + } }; template using avm_poseidon2 = Relation>; - } \ No newline at end of file +} // namespace bb::Avm_vm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_sha256.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_sha256.hpp index a6459e54f71..8daf1fce39f 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_sha256.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_sha256.hpp @@ -6,49 +6,42 @@ namespace bb::Avm_vm { -template struct Avm_sha256Row { - FF avm_sha256_sha256_compression_sel {}; - }; - +template struct Avm_sha256Row { + FF avm_sha256_sha256_compression_sel{}; +}; - inline std::string get_relation_label_avm_sha256(int index) { - switch (index) { - - } - return std::to_string(index); - } - +inline std::string get_relation_label_avm_sha256(int index) +{ + switch (index) {} + return std::to_string(index); +} template class avm_sha256Impl { - public: - using FF = FF_; - - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, -}; - - + public: + using FF = FF_; + + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 3, + }; + template - void static accumulate( - ContainerOverSubrelations& evals, - const AllEntities& new_term, - [[maybe_unused]] const RelationParameters&, - [[maybe_unused]] const FF& scaling_factor - ){ - - //Contribution 0 + void static accumulate(ContainerOverSubrelations& evals, + const AllEntities& new_term, + [[maybe_unused]] const RelationParameters&, + [[maybe_unused]] const FF& scaling_factor) { -Avm_DECLARE_VIEWS(0); - - - auto tmp = (avm_sha256_sha256_compression_sel * (-avm_sha256_sha256_compression_sel + FF(1))); - tmp *= scaling_factor; - std::get<0>(evals) += tmp; -} -} + // Contribution 0 + { + Avm_DECLARE_VIEWS(0); + + auto tmp = (avm_sha256_sha256_compression_sel * (-avm_sha256_sha256_compression_sel + FF(1))); + tmp *= scaling_factor; + std::get<0>(evals) += tmp; + } + } }; template using avm_sha256 = Relation>; - } \ No newline at end of file +} // namespace bb::Avm_vm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_main_tag_err.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_main_tag_err.hpp index 4a5e364abab..cfb4885c4b5 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_main_tag_err.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_main_tag_err.hpp @@ -1,172 +1,167 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class incl_main_tag_err_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class incl_main_tag_err_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_mem_tag_err == 1 || in.avm_main_tag_err == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_mem_tag_err); const auto is_table_entry = View(in.avm_main_tag_err); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.incl_main_tag_err, -in.incl_main_tag_err_counts, -in.avm_mem_tag_err, -in.avm_main_tag_err, -in.avm_mem_clk, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.incl_main_tag_err, -in.incl_main_tag_err_counts, -in.avm_mem_tag_err, -in.avm_main_tag_err, -in.avm_mem_clk, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.incl_main_tag_err, + in.incl_main_tag_err_counts, + in.avm_mem_tag_err, + in.avm_main_tag_err, + in.avm_mem_clk, + in.avm_main_clk); } - - }; - - template using incl_main_tag_err_relation = GenericLookupRelation; - template using incl_main_tag_err = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.incl_main_tag_err, + in.incl_main_tag_err_counts, + in.avm_mem_tag_err, + in.avm_main_tag_err, + in.avm_mem_clk, + in.avm_main_clk); } - \ No newline at end of file +}; + +template +using incl_main_tag_err_relation = GenericLookupRelation; +template using incl_main_tag_err = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_mem_tag_err.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_mem_tag_err.hpp index fc6d5d99751..4055ceb7951 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_mem_tag_err.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_mem_tag_err.hpp @@ -1,172 +1,166 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class incl_mem_tag_err_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class incl_mem_tag_err_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_main_tag_err == 1 || in.avm_mem_tag_err == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_main_tag_err); const auto is_table_entry = View(in.avm_mem_tag_err); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.incl_mem_tag_err, -in.incl_mem_tag_err_counts, -in.avm_main_tag_err, -in.avm_mem_tag_err, -in.avm_main_clk, -in.avm_mem_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.incl_mem_tag_err, -in.incl_mem_tag_err_counts, -in.avm_main_tag_err, -in.avm_mem_tag_err, -in.avm_main_clk, -in.avm_mem_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.incl_mem_tag_err, + in.incl_mem_tag_err_counts, + in.avm_main_tag_err, + in.avm_mem_tag_err, + in.avm_main_clk, + in.avm_mem_clk); } - - }; - - template using incl_mem_tag_err_relation = GenericLookupRelation; - template using incl_mem_tag_err = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.incl_mem_tag_err, + in.incl_mem_tag_err_counts, + in.avm_main_tag_err, + in.avm_mem_tag_err, + in.avm_main_clk, + in.avm_mem_clk); } - \ No newline at end of file +}; + +template using incl_mem_tag_err_relation = GenericLookupRelation; +template using incl_mem_tag_err = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/kernel_output_lookup.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/kernel_output_lookup.hpp index 0207fe421cd..49023977d03 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/kernel_output_lookup.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/kernel_output_lookup.hpp @@ -1,184 +1,179 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class kernel_output_lookup_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 4; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class kernel_output_lookup_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 4; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_main_q_kernel_output_lookup == 1 || in.avm_kernel_q_public_input_kernel_out_add_to_table == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_main_q_kernel_output_lookup); const auto is_table_entry = View(in.avm_kernel_q_public_input_kernel_out_add_to_table); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.kernel_output_lookup, -in.kernel_output_lookup_counts, -in.avm_main_q_kernel_output_lookup, -in.avm_kernel_q_public_input_kernel_out_add_to_table, -in.avm_kernel_kernel_out_offset, -in.avm_main_ia, -in.avm_kernel_side_effect_counter, -in.avm_main_ib, -in.avm_main_clk, -in.avm_kernel_kernel_value_out__is_public, -in.avm_kernel_kernel_side_effect_out__is_public, -in.avm_kernel_kernel_metadata_out__is_public - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.kernel_output_lookup, -in.kernel_output_lookup_counts, -in.avm_main_q_kernel_output_lookup, -in.avm_kernel_q_public_input_kernel_out_add_to_table, -in.avm_kernel_kernel_out_offset, -in.avm_main_ia, -in.avm_kernel_side_effect_counter, -in.avm_main_ib, -in.avm_main_clk, -in.avm_kernel_kernel_value_out__is_public, -in.avm_kernel_kernel_side_effect_out__is_public, -in.avm_kernel_kernel_metadata_out__is_public - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.kernel_output_lookup, + in.kernel_output_lookup_counts, + in.avm_main_q_kernel_output_lookup, + in.avm_kernel_q_public_input_kernel_out_add_to_table, + in.avm_kernel_kernel_out_offset, + in.avm_main_ia, + in.avm_kernel_side_effect_counter, + in.avm_main_ib, + in.avm_main_clk, + in.avm_kernel_kernel_value_out__is_public, + in.avm_kernel_kernel_side_effect_out__is_public, + in.avm_kernel_kernel_metadata_out__is_public); } - - }; - - template using kernel_output_lookup_relation = GenericLookupRelation; - template using kernel_output_lookup = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.kernel_output_lookup, + in.kernel_output_lookup_counts, + in.avm_main_q_kernel_output_lookup, + in.avm_kernel_q_public_input_kernel_out_add_to_table, + in.avm_kernel_kernel_out_offset, + in.avm_main_ia, + in.avm_kernel_side_effect_counter, + in.avm_main_ib, + in.avm_main_clk, + in.avm_kernel_kernel_value_out__is_public, + in.avm_kernel_kernel_side_effect_out__is_public, + in.avm_kernel_kernel_metadata_out__is_public); } - \ No newline at end of file +}; + +template +using kernel_output_lookup_relation = GenericLookupRelation; +template using kernel_output_lookup = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_lengths.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_lengths.hpp index dd0e670d158..66268991c7c 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_lengths.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_lengths.hpp @@ -1,176 +1,171 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_byte_lengths_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 2; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_byte_lengths_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 2; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_binary_start == 1 || in.avm_byte_lookup_bin_sel == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_binary_start); const auto is_table_entry = View(in.avm_byte_lookup_bin_sel); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_byte_lengths, -in.lookup_byte_lengths_counts, -in.avm_binary_start, -in.avm_byte_lookup_bin_sel, -in.avm_binary_in_tag, -in.avm_binary_mem_tag_ctr, -in.avm_byte_lookup_table_in_tags, -in.avm_byte_lookup_table_byte_lengths - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_byte_lengths, -in.lookup_byte_lengths_counts, -in.avm_binary_start, -in.avm_byte_lookup_bin_sel, -in.avm_binary_in_tag, -in.avm_binary_mem_tag_ctr, -in.avm_byte_lookup_table_in_tags, -in.avm_byte_lookup_table_byte_lengths - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_byte_lengths, + in.lookup_byte_lengths_counts, + in.avm_binary_start, + in.avm_byte_lookup_bin_sel, + in.avm_binary_in_tag, + in.avm_binary_mem_tag_ctr, + in.avm_byte_lookup_table_in_tags, + in.avm_byte_lookup_table_byte_lengths); } - - }; - - template using lookup_byte_lengths_relation = GenericLookupRelation; - template using lookup_byte_lengths = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_byte_lengths, + in.lookup_byte_lengths_counts, + in.avm_binary_start, + in.avm_byte_lookup_bin_sel, + in.avm_binary_in_tag, + in.avm_binary_mem_tag_ctr, + in.avm_byte_lookup_table_in_tags, + in.avm_byte_lookup_table_byte_lengths); } - \ No newline at end of file +}; + +template +using lookup_byte_lengths_relation = GenericLookupRelation; +template using lookup_byte_lengths = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_operations.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_operations.hpp index 537002aeff0..baf2995fcb8 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_operations.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_operations.hpp @@ -1,184 +1,179 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_byte_operations_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 4; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_byte_operations_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 4; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_binary_bin_sel == 1 || in.avm_byte_lookup_bin_sel == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_binary_bin_sel); const auto is_table_entry = View(in.avm_byte_lookup_bin_sel); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_byte_operations, -in.lookup_byte_operations_counts, -in.avm_binary_bin_sel, -in.avm_byte_lookup_bin_sel, -in.avm_binary_op_id, -in.avm_binary_ia_bytes, -in.avm_binary_ib_bytes, -in.avm_binary_ic_bytes, -in.avm_byte_lookup_table_op_id, -in.avm_byte_lookup_table_input_a, -in.avm_byte_lookup_table_input_b, -in.avm_byte_lookup_table_output - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_byte_operations, -in.lookup_byte_operations_counts, -in.avm_binary_bin_sel, -in.avm_byte_lookup_bin_sel, -in.avm_binary_op_id, -in.avm_binary_ia_bytes, -in.avm_binary_ib_bytes, -in.avm_binary_ic_bytes, -in.avm_byte_lookup_table_op_id, -in.avm_byte_lookup_table_input_a, -in.avm_byte_lookup_table_input_b, -in.avm_byte_lookup_table_output - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_byte_operations, + in.lookup_byte_operations_counts, + in.avm_binary_bin_sel, + in.avm_byte_lookup_bin_sel, + in.avm_binary_op_id, + in.avm_binary_ia_bytes, + in.avm_binary_ib_bytes, + in.avm_binary_ic_bytes, + in.avm_byte_lookup_table_op_id, + in.avm_byte_lookup_table_input_a, + in.avm_byte_lookup_table_input_b, + in.avm_byte_lookup_table_output); } - - }; - - template using lookup_byte_operations_relation = GenericLookupRelation; - template using lookup_byte_operations = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_byte_operations, + in.lookup_byte_operations_counts, + in.avm_binary_bin_sel, + in.avm_byte_lookup_bin_sel, + in.avm_binary_op_id, + in.avm_binary_ia_bytes, + in.avm_binary_ib_bytes, + in.avm_binary_ic_bytes, + in.avm_byte_lookup_table_op_id, + in.avm_byte_lookup_table_input_a, + in.avm_byte_lookup_table_input_b, + in.avm_byte_lookup_table_output); } - \ No newline at end of file +}; + +template +using lookup_byte_operations_relation = GenericLookupRelation; +template using lookup_byte_operations = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_0.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_0.hpp index 326c9d0d379..67284e42972 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_0.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_0.hpp @@ -1,172 +1,166 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_div_u16_0_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_div_u16_0_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_alu_div_rng_chk_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_div_rng_chk_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_div_u16_0, -in.lookup_div_u16_0_counts, -in.avm_alu_div_rng_chk_selector, -in.avm_main_sel_rng_16, -in.avm_alu_div_u16_r0, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_div_u16_0, -in.lookup_div_u16_0_counts, -in.avm_alu_div_rng_chk_selector, -in.avm_main_sel_rng_16, -in.avm_alu_div_u16_r0, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_div_u16_0, + in.lookup_div_u16_0_counts, + in.avm_alu_div_rng_chk_selector, + in.avm_main_sel_rng_16, + in.avm_alu_div_u16_r0, + in.avm_main_clk); } - - }; - - template using lookup_div_u16_0_relation = GenericLookupRelation; - template using lookup_div_u16_0 = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_div_u16_0, + in.lookup_div_u16_0_counts, + in.avm_alu_div_rng_chk_selector, + in.avm_main_sel_rng_16, + in.avm_alu_div_u16_r0, + in.avm_main_clk); } - \ No newline at end of file +}; + +template using lookup_div_u16_0_relation = GenericLookupRelation; +template using lookup_div_u16_0 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_1.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_1.hpp index 39ccf37124a..38c6fd614f8 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_1.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_1.hpp @@ -1,172 +1,166 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_div_u16_1_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_div_u16_1_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_alu_div_rng_chk_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_div_rng_chk_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_div_u16_1, -in.lookup_div_u16_1_counts, -in.avm_alu_div_rng_chk_selector, -in.avm_main_sel_rng_16, -in.avm_alu_div_u16_r1, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_div_u16_1, -in.lookup_div_u16_1_counts, -in.avm_alu_div_rng_chk_selector, -in.avm_main_sel_rng_16, -in.avm_alu_div_u16_r1, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_div_u16_1, + in.lookup_div_u16_1_counts, + in.avm_alu_div_rng_chk_selector, + in.avm_main_sel_rng_16, + in.avm_alu_div_u16_r1, + in.avm_main_clk); } - - }; - - template using lookup_div_u16_1_relation = GenericLookupRelation; - template using lookup_div_u16_1 = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_div_u16_1, + in.lookup_div_u16_1_counts, + in.avm_alu_div_rng_chk_selector, + in.avm_main_sel_rng_16, + in.avm_alu_div_u16_r1, + in.avm_main_clk); } - \ No newline at end of file +}; + +template using lookup_div_u16_1_relation = GenericLookupRelation; +template using lookup_div_u16_1 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_2.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_2.hpp index bc389c085d9..36c347a5ba9 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_2.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_2.hpp @@ -1,172 +1,166 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_div_u16_2_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_div_u16_2_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_alu_div_rng_chk_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_div_rng_chk_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_div_u16_2, -in.lookup_div_u16_2_counts, -in.avm_alu_div_rng_chk_selector, -in.avm_main_sel_rng_16, -in.avm_alu_div_u16_r2, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_div_u16_2, -in.lookup_div_u16_2_counts, -in.avm_alu_div_rng_chk_selector, -in.avm_main_sel_rng_16, -in.avm_alu_div_u16_r2, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_div_u16_2, + in.lookup_div_u16_2_counts, + in.avm_alu_div_rng_chk_selector, + in.avm_main_sel_rng_16, + in.avm_alu_div_u16_r2, + in.avm_main_clk); } - - }; - - template using lookup_div_u16_2_relation = GenericLookupRelation; - template using lookup_div_u16_2 = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_div_u16_2, + in.lookup_div_u16_2_counts, + in.avm_alu_div_rng_chk_selector, + in.avm_main_sel_rng_16, + in.avm_alu_div_u16_r2, + in.avm_main_clk); } - \ No newline at end of file +}; + +template using lookup_div_u16_2_relation = GenericLookupRelation; +template using lookup_div_u16_2 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_3.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_3.hpp index fc7aa8e0d6b..e167bae69bb 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_3.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_3.hpp @@ -1,172 +1,166 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_div_u16_3_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_div_u16_3_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_alu_div_rng_chk_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_div_rng_chk_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_div_u16_3, -in.lookup_div_u16_3_counts, -in.avm_alu_div_rng_chk_selector, -in.avm_main_sel_rng_16, -in.avm_alu_div_u16_r3, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_div_u16_3, -in.lookup_div_u16_3_counts, -in.avm_alu_div_rng_chk_selector, -in.avm_main_sel_rng_16, -in.avm_alu_div_u16_r3, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_div_u16_3, + in.lookup_div_u16_3_counts, + in.avm_alu_div_rng_chk_selector, + in.avm_main_sel_rng_16, + in.avm_alu_div_u16_r3, + in.avm_main_clk); } - - }; - - template using lookup_div_u16_3_relation = GenericLookupRelation; - template using lookup_div_u16_3 = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_div_u16_3, + in.lookup_div_u16_3_counts, + in.avm_alu_div_rng_chk_selector, + in.avm_main_sel_rng_16, + in.avm_alu_div_u16_r3, + in.avm_main_clk); } - \ No newline at end of file +}; + +template using lookup_div_u16_3_relation = GenericLookupRelation; +template using lookup_div_u16_3 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_4.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_4.hpp index 3082eaef986..6248bc098d6 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_4.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_4.hpp @@ -1,172 +1,166 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_div_u16_4_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_div_u16_4_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_alu_div_rng_chk_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_div_rng_chk_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_div_u16_4, -in.lookup_div_u16_4_counts, -in.avm_alu_div_rng_chk_selector, -in.avm_main_sel_rng_16, -in.avm_alu_div_u16_r4, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_div_u16_4, -in.lookup_div_u16_4_counts, -in.avm_alu_div_rng_chk_selector, -in.avm_main_sel_rng_16, -in.avm_alu_div_u16_r4, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_div_u16_4, + in.lookup_div_u16_4_counts, + in.avm_alu_div_rng_chk_selector, + in.avm_main_sel_rng_16, + in.avm_alu_div_u16_r4, + in.avm_main_clk); } - - }; - - template using lookup_div_u16_4_relation = GenericLookupRelation; - template using lookup_div_u16_4 = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_div_u16_4, + in.lookup_div_u16_4_counts, + in.avm_alu_div_rng_chk_selector, + in.avm_main_sel_rng_16, + in.avm_alu_div_u16_r4, + in.avm_main_clk); } - \ No newline at end of file +}; + +template using lookup_div_u16_4_relation = GenericLookupRelation; +template using lookup_div_u16_4 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_5.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_5.hpp index e86b9b94a32..052eafcaa3b 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_5.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_5.hpp @@ -1,172 +1,166 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_div_u16_5_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_div_u16_5_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_alu_div_rng_chk_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_div_rng_chk_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_div_u16_5, -in.lookup_div_u16_5_counts, -in.avm_alu_div_rng_chk_selector, -in.avm_main_sel_rng_16, -in.avm_alu_div_u16_r5, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_div_u16_5, -in.lookup_div_u16_5_counts, -in.avm_alu_div_rng_chk_selector, -in.avm_main_sel_rng_16, -in.avm_alu_div_u16_r5, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_div_u16_5, + in.lookup_div_u16_5_counts, + in.avm_alu_div_rng_chk_selector, + in.avm_main_sel_rng_16, + in.avm_alu_div_u16_r5, + in.avm_main_clk); } - - }; - - template using lookup_div_u16_5_relation = GenericLookupRelation; - template using lookup_div_u16_5 = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_div_u16_5, + in.lookup_div_u16_5_counts, + in.avm_alu_div_rng_chk_selector, + in.avm_main_sel_rng_16, + in.avm_alu_div_u16_r5, + in.avm_main_clk); } - \ No newline at end of file +}; + +template using lookup_div_u16_5_relation = GenericLookupRelation; +template using lookup_div_u16_5 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_6.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_6.hpp index d1dee82d616..c52d71bdb99 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_6.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_6.hpp @@ -1,172 +1,166 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_div_u16_6_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_div_u16_6_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_alu_div_rng_chk_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_div_rng_chk_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_div_u16_6, -in.lookup_div_u16_6_counts, -in.avm_alu_div_rng_chk_selector, -in.avm_main_sel_rng_16, -in.avm_alu_div_u16_r6, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_div_u16_6, -in.lookup_div_u16_6_counts, -in.avm_alu_div_rng_chk_selector, -in.avm_main_sel_rng_16, -in.avm_alu_div_u16_r6, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_div_u16_6, + in.lookup_div_u16_6_counts, + in.avm_alu_div_rng_chk_selector, + in.avm_main_sel_rng_16, + in.avm_alu_div_u16_r6, + in.avm_main_clk); } - - }; - - template using lookup_div_u16_6_relation = GenericLookupRelation; - template using lookup_div_u16_6 = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_div_u16_6, + in.lookup_div_u16_6_counts, + in.avm_alu_div_rng_chk_selector, + in.avm_main_sel_rng_16, + in.avm_alu_div_u16_r6, + in.avm_main_clk); } - \ No newline at end of file +}; + +template using lookup_div_u16_6_relation = GenericLookupRelation; +template using lookup_div_u16_6 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_7.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_7.hpp index 61e0bc705f2..dde1e6f54b4 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_7.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_div_u16_7.hpp @@ -1,172 +1,166 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_div_u16_7_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_div_u16_7_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_alu_div_rng_chk_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_div_rng_chk_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_div_u16_7, -in.lookup_div_u16_7_counts, -in.avm_alu_div_rng_chk_selector, -in.avm_main_sel_rng_16, -in.avm_alu_div_u16_r7, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_div_u16_7, -in.lookup_div_u16_7_counts, -in.avm_alu_div_rng_chk_selector, -in.avm_main_sel_rng_16, -in.avm_alu_div_u16_r7, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_div_u16_7, + in.lookup_div_u16_7_counts, + in.avm_alu_div_rng_chk_selector, + in.avm_main_sel_rng_16, + in.avm_alu_div_u16_r7, + in.avm_main_clk); } - - }; - - template using lookup_div_u16_7_relation = GenericLookupRelation; - template using lookup_div_u16_7 = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_div_u16_7, + in.lookup_div_u16_7_counts, + in.avm_alu_div_rng_chk_selector, + in.avm_main_sel_rng_16, + in.avm_alu_div_u16_r7, + in.avm_main_clk); } - \ No newline at end of file +}; + +template using lookup_div_u16_7_relation = GenericLookupRelation; +template using lookup_div_u16_7 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_into_kernel.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_into_kernel.hpp index 9fc1f2f47ef..8ece5f016e7 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_into_kernel.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_into_kernel.hpp @@ -1,176 +1,171 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_into_kernel_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 2; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_into_kernel_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 2; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_main_q_kernel_lookup == 1 || in.avm_kernel_q_public_input_kernel_add_to_table == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_main_q_kernel_lookup); const auto is_table_entry = View(in.avm_kernel_q_public_input_kernel_add_to_table); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_into_kernel, -in.lookup_into_kernel_counts, -in.avm_main_q_kernel_lookup, -in.avm_kernel_q_public_input_kernel_add_to_table, -in.avm_main_ia, -in.avm_kernel_kernel_in_offset, -in.avm_kernel_kernel_inputs__is_public, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_into_kernel, -in.lookup_into_kernel_counts, -in.avm_main_q_kernel_lookup, -in.avm_kernel_q_public_input_kernel_add_to_table, -in.avm_main_ia, -in.avm_kernel_kernel_in_offset, -in.avm_kernel_kernel_inputs__is_public, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_into_kernel, + in.lookup_into_kernel_counts, + in.avm_main_q_kernel_lookup, + in.avm_kernel_q_public_input_kernel_add_to_table, + in.avm_main_ia, + in.avm_kernel_kernel_in_offset, + in.avm_kernel_kernel_inputs__is_public, + in.avm_main_clk); } - - }; - - template using lookup_into_kernel_relation = GenericLookupRelation; - template using lookup_into_kernel = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_into_kernel, + in.lookup_into_kernel_counts, + in.avm_main_q_kernel_lookup, + in.avm_kernel_q_public_input_kernel_add_to_table, + in.avm_main_ia, + in.avm_kernel_kernel_in_offset, + in.avm_kernel_kernel_inputs__is_public, + in.avm_main_clk); } - \ No newline at end of file +}; + +template +using lookup_into_kernel_relation = GenericLookupRelation; +template using lookup_into_kernel = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_mem_rng_chk_hi.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_mem_rng_chk_hi.hpp index 3a58825f58c..d982ee18fc0 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_mem_rng_chk_hi.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_mem_rng_chk_hi.hpp @@ -1,172 +1,167 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_mem_rng_chk_hi_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_mem_rng_chk_hi_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_mem_rng_chk_sel == 1 || in.avm_main_sel_rng_8 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_mem_rng_chk_sel); const auto is_table_entry = View(in.avm_main_sel_rng_8); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_mem_rng_chk_hi, -in.lookup_mem_rng_chk_hi_counts, -in.avm_mem_rng_chk_sel, -in.avm_main_sel_rng_8, -in.avm_mem_diff_hi, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_mem_rng_chk_hi, -in.lookup_mem_rng_chk_hi_counts, -in.avm_mem_rng_chk_sel, -in.avm_main_sel_rng_8, -in.avm_mem_diff_hi, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_mem_rng_chk_hi, + in.lookup_mem_rng_chk_hi_counts, + in.avm_mem_rng_chk_sel, + in.avm_main_sel_rng_8, + in.avm_mem_diff_hi, + in.avm_main_clk); } - - }; - - template using lookup_mem_rng_chk_hi_relation = GenericLookupRelation; - template using lookup_mem_rng_chk_hi = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_mem_rng_chk_hi, + in.lookup_mem_rng_chk_hi_counts, + in.avm_mem_rng_chk_sel, + in.avm_main_sel_rng_8, + in.avm_mem_diff_hi, + in.avm_main_clk); } - \ No newline at end of file +}; + +template +using lookup_mem_rng_chk_hi_relation = GenericLookupRelation; +template using lookup_mem_rng_chk_hi = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_mem_rng_chk_lo.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_mem_rng_chk_lo.hpp index 9d0bc3fc524..d59ef829c2d 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_mem_rng_chk_lo.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_mem_rng_chk_lo.hpp @@ -1,172 +1,167 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_mem_rng_chk_lo_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_mem_rng_chk_lo_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_mem_rng_chk_sel == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_mem_rng_chk_sel); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_mem_rng_chk_lo, -in.lookup_mem_rng_chk_lo_counts, -in.avm_mem_rng_chk_sel, -in.avm_main_sel_rng_16, -in.avm_mem_diff_lo, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_mem_rng_chk_lo, -in.lookup_mem_rng_chk_lo_counts, -in.avm_mem_rng_chk_sel, -in.avm_main_sel_rng_16, -in.avm_mem_diff_lo, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_mem_rng_chk_lo, + in.lookup_mem_rng_chk_lo_counts, + in.avm_mem_rng_chk_sel, + in.avm_main_sel_rng_16, + in.avm_mem_diff_lo, + in.avm_main_clk); } - - }; - - template using lookup_mem_rng_chk_lo_relation = GenericLookupRelation; - template using lookup_mem_rng_chk_lo = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_mem_rng_chk_lo, + in.lookup_mem_rng_chk_lo_counts, + in.avm_mem_rng_chk_sel, + in.avm_main_sel_rng_16, + in.avm_mem_diff_lo, + in.avm_main_clk); } - \ No newline at end of file +}; + +template +using lookup_mem_rng_chk_lo_relation = GenericLookupRelation; +template using lookup_mem_rng_chk_lo = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_mem_rng_chk_mid.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_mem_rng_chk_mid.hpp index cf20abf3493..bece75f6f1a 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_mem_rng_chk_mid.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_mem_rng_chk_mid.hpp @@ -1,172 +1,167 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_mem_rng_chk_mid_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_mem_rng_chk_mid_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_mem_rng_chk_sel == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_mem_rng_chk_sel); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_mem_rng_chk_mid, -in.lookup_mem_rng_chk_mid_counts, -in.avm_mem_rng_chk_sel, -in.avm_main_sel_rng_16, -in.avm_mem_diff_mid, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_mem_rng_chk_mid, -in.lookup_mem_rng_chk_mid_counts, -in.avm_mem_rng_chk_sel, -in.avm_main_sel_rng_16, -in.avm_mem_diff_mid, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_mem_rng_chk_mid, + in.lookup_mem_rng_chk_mid_counts, + in.avm_mem_rng_chk_sel, + in.avm_main_sel_rng_16, + in.avm_mem_diff_mid, + in.avm_main_clk); } - - }; - - template using lookup_mem_rng_chk_mid_relation = GenericLookupRelation; - template using lookup_mem_rng_chk_mid = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_mem_rng_chk_mid, + in.lookup_mem_rng_chk_mid_counts, + in.avm_mem_rng_chk_sel, + in.avm_main_sel_rng_16, + in.avm_mem_diff_mid, + in.avm_main_clk); } - \ No newline at end of file +}; + +template +using lookup_mem_rng_chk_mid_relation = GenericLookupRelation; +template using lookup_mem_rng_chk_mid = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_opcode_gas.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_opcode_gas.hpp index c113338ceee..fec6ee9753d 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_opcode_gas.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_opcode_gas.hpp @@ -1,180 +1,175 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_opcode_gas_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 3; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_opcode_gas_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 3; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_main_gas_cost_active == 1 || in.avm_gas_gas_cost_sel == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_main_gas_cost_active); const auto is_table_entry = View(in.avm_gas_gas_cost_sel); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_opcode_gas, -in.lookup_opcode_gas_counts, -in.avm_main_gas_cost_active, -in.avm_gas_gas_cost_sel, -in.avm_main_opcode_val, -in.avm_main_l2_gas_op, -in.avm_main_da_gas_op, -in.avm_main_clk, -in.avm_gas_l2_gas_fixed_table, -in.avm_gas_da_gas_fixed_table - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_opcode_gas, -in.lookup_opcode_gas_counts, -in.avm_main_gas_cost_active, -in.avm_gas_gas_cost_sel, -in.avm_main_opcode_val, -in.avm_main_l2_gas_op, -in.avm_main_da_gas_op, -in.avm_main_clk, -in.avm_gas_l2_gas_fixed_table, -in.avm_gas_da_gas_fixed_table - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_opcode_gas, + in.lookup_opcode_gas_counts, + in.avm_main_gas_cost_active, + in.avm_gas_gas_cost_sel, + in.avm_main_opcode_val, + in.avm_main_l2_gas_op, + in.avm_main_da_gas_op, + in.avm_main_clk, + in.avm_gas_l2_gas_fixed_table, + in.avm_gas_da_gas_fixed_table); } - - }; - - template using lookup_opcode_gas_relation = GenericLookupRelation; - template using lookup_opcode_gas = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_opcode_gas, + in.lookup_opcode_gas_counts, + in.avm_main_gas_cost_active, + in.avm_gas_gas_cost_sel, + in.avm_main_opcode_val, + in.avm_main_l2_gas_op, + in.avm_main_da_gas_op, + in.avm_main_clk, + in.avm_gas_l2_gas_fixed_table, + in.avm_gas_da_gas_fixed_table); } - \ No newline at end of file +}; + +template +using lookup_opcode_gas_relation = GenericLookupRelation; +template using lookup_opcode_gas = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_pow_2_0.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_pow_2_0.hpp index 41b126f32ab..a4629615a75 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_pow_2_0.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_pow_2_0.hpp @@ -1,176 +1,170 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_pow_2_0_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 2; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_pow_2_0_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 2; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_alu_shift_sel == 1 || in.avm_main_sel_rng_8 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_shift_sel); const auto is_table_entry = View(in.avm_main_sel_rng_8); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_pow_2_0, -in.lookup_pow_2_0_counts, -in.avm_alu_shift_sel, -in.avm_main_sel_rng_8, -in.avm_alu_ib, -in.avm_alu_two_pow_s, -in.avm_main_clk, -in.avm_main_table_pow_2 - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_pow_2_0, -in.lookup_pow_2_0_counts, -in.avm_alu_shift_sel, -in.avm_main_sel_rng_8, -in.avm_alu_ib, -in.avm_alu_two_pow_s, -in.avm_main_clk, -in.avm_main_table_pow_2 - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_pow_2_0, + in.lookup_pow_2_0_counts, + in.avm_alu_shift_sel, + in.avm_main_sel_rng_8, + in.avm_alu_ib, + in.avm_alu_two_pow_s, + in.avm_main_clk, + in.avm_main_table_pow_2); } - - }; - - template using lookup_pow_2_0_relation = GenericLookupRelation; - template using lookup_pow_2_0 = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_pow_2_0, + in.lookup_pow_2_0_counts, + in.avm_alu_shift_sel, + in.avm_main_sel_rng_8, + in.avm_alu_ib, + in.avm_alu_two_pow_s, + in.avm_main_clk, + in.avm_main_table_pow_2); } - \ No newline at end of file +}; + +template using lookup_pow_2_0_relation = GenericLookupRelation; +template using lookup_pow_2_0 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_pow_2_1.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_pow_2_1.hpp index c1aca450ed1..e1e7284056e 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_pow_2_1.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_pow_2_1.hpp @@ -1,176 +1,170 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_pow_2_1_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 2; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_pow_2_1_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 2; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_alu_shift_sel == 1 || in.avm_main_sel_rng_8 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_shift_sel); const auto is_table_entry = View(in.avm_main_sel_rng_8); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_pow_2_1, -in.lookup_pow_2_1_counts, -in.avm_alu_shift_sel, -in.avm_main_sel_rng_8, -in.avm_alu_t_sub_s_bits, -in.avm_alu_two_pow_t_sub_s, -in.avm_main_clk, -in.avm_main_table_pow_2 - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_pow_2_1, -in.lookup_pow_2_1_counts, -in.avm_alu_shift_sel, -in.avm_main_sel_rng_8, -in.avm_alu_t_sub_s_bits, -in.avm_alu_two_pow_t_sub_s, -in.avm_main_clk, -in.avm_main_table_pow_2 - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_pow_2_1, + in.lookup_pow_2_1_counts, + in.avm_alu_shift_sel, + in.avm_main_sel_rng_8, + in.avm_alu_t_sub_s_bits, + in.avm_alu_two_pow_t_sub_s, + in.avm_main_clk, + in.avm_main_table_pow_2); } - - }; - - template using lookup_pow_2_1_relation = GenericLookupRelation; - template using lookup_pow_2_1 = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_pow_2_1, + in.lookup_pow_2_1_counts, + in.avm_alu_shift_sel, + in.avm_main_sel_rng_8, + in.avm_alu_t_sub_s_bits, + in.avm_alu_two_pow_t_sub_s, + in.avm_main_clk, + in.avm_main_table_pow_2); } - \ No newline at end of file +}; + +template using lookup_pow_2_1_relation = GenericLookupRelation; +template using lookup_pow_2_1 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_0.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_0.hpp index 88fe289a098..67c79053609 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_0.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_0.hpp @@ -1,172 +1,166 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_u16_0_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_0_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_0, -in.lookup_u16_0_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r0, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_0, -in.lookup_u16_0_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r0, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_0, + in.lookup_u16_0_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r0, + in.avm_main_clk); } - - }; - - template using lookup_u16_0_relation = GenericLookupRelation; - template using lookup_u16_0 = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_0, + in.lookup_u16_0_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r0, + in.avm_main_clk); } - \ No newline at end of file +}; + +template using lookup_u16_0_relation = GenericLookupRelation; +template using lookup_u16_0 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_1.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_1.hpp index b78029d9003..c5c39dd2f80 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_1.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_1.hpp @@ -1,172 +1,166 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_u16_1_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_1_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_1, -in.lookup_u16_1_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r1, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_1, -in.lookup_u16_1_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r1, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_1, + in.lookup_u16_1_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r1, + in.avm_main_clk); } - - }; - - template using lookup_u16_1_relation = GenericLookupRelation; - template using lookup_u16_1 = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_1, + in.lookup_u16_1_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r1, + in.avm_main_clk); } - \ No newline at end of file +}; + +template using lookup_u16_1_relation = GenericLookupRelation; +template using lookup_u16_1 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_10.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_10.hpp index 1f67f41a02d..275dcb0f824 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_10.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_10.hpp @@ -1,172 +1,166 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_u16_10_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_10_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_10, -in.lookup_u16_10_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r10, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_10, -in.lookup_u16_10_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r10, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_10, + in.lookup_u16_10_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r10, + in.avm_main_clk); } - - }; - - template using lookup_u16_10_relation = GenericLookupRelation; - template using lookup_u16_10 = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_10, + in.lookup_u16_10_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r10, + in.avm_main_clk); } - \ No newline at end of file +}; + +template using lookup_u16_10_relation = GenericLookupRelation; +template using lookup_u16_10 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_11.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_11.hpp index f98a686b914..b94a5f65d84 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_11.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_11.hpp @@ -1,172 +1,166 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_u16_11_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_11_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_11, -in.lookup_u16_11_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r11, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_11, -in.lookup_u16_11_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r11, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_11, + in.lookup_u16_11_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r11, + in.avm_main_clk); } - - }; - - template using lookup_u16_11_relation = GenericLookupRelation; - template using lookup_u16_11 = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_11, + in.lookup_u16_11_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r11, + in.avm_main_clk); } - \ No newline at end of file +}; + +template using lookup_u16_11_relation = GenericLookupRelation; +template using lookup_u16_11 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_12.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_12.hpp index 6aadbd421e9..4fc5cca4ebe 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_12.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_12.hpp @@ -1,172 +1,166 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_u16_12_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_12_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_12, -in.lookup_u16_12_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r12, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_12, -in.lookup_u16_12_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r12, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_12, + in.lookup_u16_12_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r12, + in.avm_main_clk); } - - }; - - template using lookup_u16_12_relation = GenericLookupRelation; - template using lookup_u16_12 = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_12, + in.lookup_u16_12_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r12, + in.avm_main_clk); } - \ No newline at end of file +}; + +template using lookup_u16_12_relation = GenericLookupRelation; +template using lookup_u16_12 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_13.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_13.hpp index ff3af5c9592..908d478b8ad 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_13.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_13.hpp @@ -1,172 +1,166 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_u16_13_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_13_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_13, -in.lookup_u16_13_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r13, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_13, -in.lookup_u16_13_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r13, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_13, + in.lookup_u16_13_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r13, + in.avm_main_clk); } - - }; - - template using lookup_u16_13_relation = GenericLookupRelation; - template using lookup_u16_13 = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_13, + in.lookup_u16_13_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r13, + in.avm_main_clk); } - \ No newline at end of file +}; + +template using lookup_u16_13_relation = GenericLookupRelation; +template using lookup_u16_13 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_14.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_14.hpp index 92dc0c2c84e..735361f8e6c 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_14.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_14.hpp @@ -1,172 +1,166 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_u16_14_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_14_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_14, -in.lookup_u16_14_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r14, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_14, -in.lookup_u16_14_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r14, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_14, + in.lookup_u16_14_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r14, + in.avm_main_clk); } - - }; - - template using lookup_u16_14_relation = GenericLookupRelation; - template using lookup_u16_14 = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_14, + in.lookup_u16_14_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r14, + in.avm_main_clk); } - \ No newline at end of file +}; + +template using lookup_u16_14_relation = GenericLookupRelation; +template using lookup_u16_14 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_2.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_2.hpp index 7a40a19fc2e..8aa66dc7a70 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_2.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_2.hpp @@ -1,172 +1,166 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_u16_2_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_2_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_2, -in.lookup_u16_2_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r2, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_2, -in.lookup_u16_2_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r2, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_2, + in.lookup_u16_2_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r2, + in.avm_main_clk); } - - }; - - template using lookup_u16_2_relation = GenericLookupRelation; - template using lookup_u16_2 = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_2, + in.lookup_u16_2_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r2, + in.avm_main_clk); } - \ No newline at end of file +}; + +template using lookup_u16_2_relation = GenericLookupRelation; +template using lookup_u16_2 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_3.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_3.hpp index 2519e05a478..b1bda551024 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_3.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_3.hpp @@ -1,172 +1,166 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_u16_3_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_3_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_3, -in.lookup_u16_3_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r3, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_3, -in.lookup_u16_3_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r3, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_3, + in.lookup_u16_3_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r3, + in.avm_main_clk); } - - }; - - template using lookup_u16_3_relation = GenericLookupRelation; - template using lookup_u16_3 = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_3, + in.lookup_u16_3_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r3, + in.avm_main_clk); } - \ No newline at end of file +}; + +template using lookup_u16_3_relation = GenericLookupRelation; +template using lookup_u16_3 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_4.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_4.hpp index caf45234db0..5984e1a6e59 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_4.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_4.hpp @@ -1,172 +1,166 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_u16_4_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_4_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_4, -in.lookup_u16_4_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r4, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_4, -in.lookup_u16_4_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r4, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_4, + in.lookup_u16_4_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r4, + in.avm_main_clk); } - - }; - - template using lookup_u16_4_relation = GenericLookupRelation; - template using lookup_u16_4 = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_4, + in.lookup_u16_4_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r4, + in.avm_main_clk); } - \ No newline at end of file +}; + +template using lookup_u16_4_relation = GenericLookupRelation; +template using lookup_u16_4 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_5.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_5.hpp index effff724035..d1bc6db3a29 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_5.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_5.hpp @@ -1,172 +1,166 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_u16_5_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_5_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_5, -in.lookup_u16_5_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r5, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_5, -in.lookup_u16_5_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r5, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_5, + in.lookup_u16_5_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r5, + in.avm_main_clk); } - - }; - - template using lookup_u16_5_relation = GenericLookupRelation; - template using lookup_u16_5 = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_5, + in.lookup_u16_5_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r5, + in.avm_main_clk); } - \ No newline at end of file +}; + +template using lookup_u16_5_relation = GenericLookupRelation; +template using lookup_u16_5 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_6.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_6.hpp index 5d90864905f..3838f21e967 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_6.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_6.hpp @@ -1,172 +1,166 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_u16_6_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_6_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_6, -in.lookup_u16_6_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r6, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_6, -in.lookup_u16_6_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r6, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_6, + in.lookup_u16_6_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r6, + in.avm_main_clk); } - - }; - - template using lookup_u16_6_relation = GenericLookupRelation; - template using lookup_u16_6 = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_6, + in.lookup_u16_6_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r6, + in.avm_main_clk); } - \ No newline at end of file +}; + +template using lookup_u16_6_relation = GenericLookupRelation; +template using lookup_u16_6 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_7.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_7.hpp index 57e012a9fc8..84b098172e9 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_7.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_7.hpp @@ -1,172 +1,166 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_u16_7_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_7_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_7, -in.lookup_u16_7_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r7, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_7, -in.lookup_u16_7_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r7, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_7, + in.lookup_u16_7_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r7, + in.avm_main_clk); } - - }; - - template using lookup_u16_7_relation = GenericLookupRelation; - template using lookup_u16_7 = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_7, + in.lookup_u16_7_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r7, + in.avm_main_clk); } - \ No newline at end of file +}; + +template using lookup_u16_7_relation = GenericLookupRelation; +template using lookup_u16_7 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_8.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_8.hpp index 89a39d1b16e..f75f9fa9c28 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_8.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_8.hpp @@ -1,172 +1,166 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_u16_8_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_8_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_8, -in.lookup_u16_8_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r8, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_8, -in.lookup_u16_8_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r8, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_8, + in.lookup_u16_8_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r8, + in.avm_main_clk); } - - }; - - template using lookup_u16_8_relation = GenericLookupRelation; - template using lookup_u16_8 = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_8, + in.lookup_u16_8_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r8, + in.avm_main_clk); } - \ No newline at end of file +}; + +template using lookup_u16_8_relation = GenericLookupRelation; +template using lookup_u16_8 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_9.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_9.hpp index 6c1e6fc86aa..5e72a369ac4 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_9.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_9.hpp @@ -1,172 +1,166 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_u16_9_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_9_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_16); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_9, -in.lookup_u16_9_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r9, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u16_9, -in.lookup_u16_9_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_16, -in.avm_alu_u16_r9, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_9, + in.lookup_u16_9_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r9, + in.avm_main_clk); } - - }; - - template using lookup_u16_9_relation = GenericLookupRelation; - template using lookup_u16_9 = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_9, + in.lookup_u16_9_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r9, + in.avm_main_clk); } - \ No newline at end of file +}; + +template using lookup_u16_9_relation = GenericLookupRelation; +template using lookup_u16_9 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_0.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_0.hpp index 4ab9eda3c0e..37b5936f008 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_0.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_0.hpp @@ -1,172 +1,166 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_u8_0_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u8_0_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_8 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_8); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u8_0, -in.lookup_u8_0_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_8, -in.avm_alu_u8_r0, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u8_0, -in.lookup_u8_0_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_8, -in.avm_alu_u8_r0, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u8_0, + in.lookup_u8_0_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_8, + in.avm_alu_u8_r0, + in.avm_main_clk); } - - }; - - template using lookup_u8_0_relation = GenericLookupRelation; - template using lookup_u8_0 = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u8_0, + in.lookup_u8_0_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_8, + in.avm_alu_u8_r0, + in.avm_main_clk); } - \ No newline at end of file +}; + +template using lookup_u8_0_relation = GenericLookupRelation; +template using lookup_u8_0 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_1.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_1.hpp index 6ffac9227bf..7941ecb1aee 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_1.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_1.hpp @@ -1,172 +1,166 @@ - - #pragma once - - #include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" - - #include - #include - - - namespace bb { - - /** - * @brief This class contains an example of how to set LookupSettings classes used by the - * GenericLookupRelationImpl class to specify a scaled lookup - * - * @details To create your own lookup: - * 1) Create a copy of this class and rename it - * 2) Update all the values with the ones needed for your lookup - * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to - * include the new settings - * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` - * - */ - class lookup_u8_1_lookup_settings { - public: - /** - * @brief The number of read terms (how many lookups we perform) in each row - * - */ - static constexpr size_t READ_TERMS = 1; - /** - * @brief The number of write terms (how many additions to the lookup table we make) in each row - * - */ - static constexpr size_t WRITE_TERMS = 1; - - /** - * @brief The type of READ_TERM used for each read index (basic and scaled) - * - */ - static constexpr size_t READ_TERM_TYPES[READ_TERMS] = {0}; - - /** - * @brief They type of WRITE_TERM used for each write index - * - */ - static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = {0}; - - /** - * @brief How many values represent a single lookup object. This value is used by the automatic read term - * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a - * basic tuple - * - */ - static constexpr size_t LOOKUP_TUPLE_SIZE = 1; - - /** - * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed - * - */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; - - /** - * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read - * terms, but will cause compilation error if not defined - * - */ - static constexpr size_t READ_TERM_DEGREE = 0; - - /** - * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write - * term, but will cause compilation error if not defined - * - */ - - static constexpr size_t WRITE_TERM_DEGREE = 0; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. - * Otherwise the value needs to be set to zero. - * - * @details If this is true then the lookup takes place in this row - * - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u8_1_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_8 == 1); } - - /** - * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this - * row - * - * @tparam Accumulator Type specified by the lookup relation - * @tparam AllEntities Values/Univariates of all entities row - * @param in Value/Univariate of all entities at row/edge - * @return Accumulator - */ - - template static inline auto compute_inverse_exists(const AllEntities& in) { + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { using View = typename Accumulator::View; const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); const auto is_table_entry = View(in.avm_main_sel_rng_8); return (is_operation + is_table_entry - is_operation * is_table_entry); } - - /** - * @brief Get all the entities for the lookup when need to update them - * - * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is - description for the current case: - The entities are returned as a tuple of references in the following order (this is for ): - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up - * - READ_TERMS entities/polynomials that enable individual lookup operations - * - The entity/polynomial that enables adding an entry to the lookup table in this row - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term - (scaled tuple) - * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u8_1, -in.lookup_u8_1_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_8, -in.avm_alu_u8_r1, -in.avm_main_clk - ); - - } - - - /** - * @brief Get all the entities for the lookup when we only need to read them - * @details Same as in get_const_entities, but nonconst - * - * @return All the entities needed for the lookup - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.lookup_u8_1, -in.lookup_u8_1_counts, -in.avm_alu_rng_chk_lookup_selector, -in.avm_main_sel_rng_8, -in.avm_alu_u8_r1, -in.avm_main_clk - ); - + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u8_1, + in.lookup_u8_1_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_8, + in.avm_alu_u8_r1, + in.avm_main_clk); } - - }; - - template using lookup_u8_1_relation = GenericLookupRelation; - template using lookup_u8_1 = GenericLookup; - + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u8_1, + in.lookup_u8_1_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_8, + in.avm_alu_u8_r1, + in.avm_main_clk); } - \ No newline at end of file +}; + +template using lookup_u8_1_relation = GenericLookupRelation; +template using lookup_u8_1 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_alu.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_alu.hpp index 8fe374e3e42..83506a187ff 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_alu.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_alu.hpp @@ -1,157 +1,150 @@ - - #pragma once - - #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" - - #include - #include - - - namespace bb { - - class perm_main_alu_permutation_settings { - public: - // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 16; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the - * value needs to be set to zero. - * - * @details If this is true then permutation takes place in this row - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + +#include +#include + +namespace bb { + +class perm_main_alu_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 16; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the + * value needs to be set to zero. + * + * @details If this is true then permutation takes place in this row + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_main_alu_sel == 1 || in.avm_alu_alu_sel == 1); } - - /** - * @brief Get all the entities for the permutation when we don't need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.perm_main_alu, -in.avm_main_alu_sel, -in.avm_main_alu_sel, -in.avm_alu_alu_sel, -in.avm_main_clk, -in.avm_main_ia, -in.avm_main_ib, -in.avm_main_ic, -in.avm_main_sel_op_add, -in.avm_main_sel_op_sub, -in.avm_main_sel_op_mul, -in.avm_main_sel_op_div, -in.avm_main_sel_op_eq, -in.avm_main_sel_op_not, -in.avm_main_sel_op_cast, -in.avm_main_sel_op_lt, -in.avm_main_sel_op_lte, -in.avm_main_sel_op_shr, -in.avm_main_sel_op_shl, -in.avm_main_alu_in_tag, -in.avm_alu_clk, -in.avm_alu_ia, -in.avm_alu_ib, -in.avm_alu_ic, -in.avm_alu_op_add, -in.avm_alu_op_sub, -in.avm_alu_op_mul, -in.avm_alu_op_div, -in.avm_alu_op_eq, -in.avm_alu_op_not, -in.avm_alu_op_cast, -in.avm_alu_op_lt, -in.avm_alu_op_lte, -in.avm_alu_op_shr, -in.avm_alu_op_shl, -in.avm_alu_in_tag - ); - - } - - - /** - * @brief Get all the entities for the permutation when need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.perm_main_alu, -in.avm_main_alu_sel, -in.avm_main_alu_sel, -in.avm_alu_alu_sel, -in.avm_main_clk, -in.avm_main_ia, -in.avm_main_ib, -in.avm_main_ic, -in.avm_main_sel_op_add, -in.avm_main_sel_op_sub, -in.avm_main_sel_op_mul, -in.avm_main_sel_op_div, -in.avm_main_sel_op_eq, -in.avm_main_sel_op_not, -in.avm_main_sel_op_cast, -in.avm_main_sel_op_lt, -in.avm_main_sel_op_lte, -in.avm_main_sel_op_shr, -in.avm_main_sel_op_shl, -in.avm_main_alu_in_tag, -in.avm_alu_clk, -in.avm_alu_ia, -in.avm_alu_ib, -in.avm_alu_ic, -in.avm_alu_op_add, -in.avm_alu_op_sub, -in.avm_alu_op_mul, -in.avm_alu_op_div, -in.avm_alu_op_eq, -in.avm_alu_op_not, -in.avm_alu_op_cast, -in.avm_alu_op_lt, -in.avm_alu_op_lte, -in.avm_alu_op_shr, -in.avm_alu_op_shl, -in.avm_alu_in_tag - ); - + + /** + * @brief Get all the entities for the permutation when we don't need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.perm_main_alu, + in.avm_main_alu_sel, + in.avm_main_alu_sel, + in.avm_alu_alu_sel, + in.avm_main_clk, + in.avm_main_ia, + in.avm_main_ib, + in.avm_main_ic, + in.avm_main_sel_op_add, + in.avm_main_sel_op_sub, + in.avm_main_sel_op_mul, + in.avm_main_sel_op_div, + in.avm_main_sel_op_eq, + in.avm_main_sel_op_not, + in.avm_main_sel_op_cast, + in.avm_main_sel_op_lt, + in.avm_main_sel_op_lte, + in.avm_main_sel_op_shr, + in.avm_main_sel_op_shl, + in.avm_main_alu_in_tag, + in.avm_alu_clk, + in.avm_alu_ia, + in.avm_alu_ib, + in.avm_alu_ic, + in.avm_alu_op_add, + in.avm_alu_op_sub, + in.avm_alu_op_mul, + in.avm_alu_op_div, + in.avm_alu_op_eq, + in.avm_alu_op_not, + in.avm_alu_op_cast, + in.avm_alu_op_lt, + in.avm_alu_op_lte, + in.avm_alu_op_shr, + in.avm_alu_op_shl, + in.avm_alu_in_tag); } - - }; - - template using perm_main_alu_relation = GenericPermutationRelation; - template using perm_main_alu = GenericPermutation; - + /** + * @brief Get all the entities for the permutation when need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.perm_main_alu, + in.avm_main_alu_sel, + in.avm_main_alu_sel, + in.avm_alu_alu_sel, + in.avm_main_clk, + in.avm_main_ia, + in.avm_main_ib, + in.avm_main_ic, + in.avm_main_sel_op_add, + in.avm_main_sel_op_sub, + in.avm_main_sel_op_mul, + in.avm_main_sel_op_div, + in.avm_main_sel_op_eq, + in.avm_main_sel_op_not, + in.avm_main_sel_op_cast, + in.avm_main_sel_op_lt, + in.avm_main_sel_op_lte, + in.avm_main_sel_op_shr, + in.avm_main_sel_op_shl, + in.avm_main_alu_in_tag, + in.avm_alu_clk, + in.avm_alu_ia, + in.avm_alu_ib, + in.avm_alu_ic, + in.avm_alu_op_add, + in.avm_alu_op_sub, + in.avm_alu_op_mul, + in.avm_alu_op_div, + in.avm_alu_op_eq, + in.avm_alu_op_not, + in.avm_alu_op_cast, + in.avm_alu_op_lt, + in.avm_alu_op_lte, + in.avm_alu_op_shr, + in.avm_alu_op_shl, + in.avm_alu_in_tag); } - \ No newline at end of file +}; + +template +using perm_main_alu_relation = GenericPermutationRelation; +template using perm_main_alu = GenericPermutation; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_bin.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_bin.hpp index 679685f9a1e..0e3533051d1 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_bin.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_bin.hpp @@ -1,117 +1,110 @@ - - #pragma once - - #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" - - #include - #include - - - namespace bb { - - class perm_main_bin_permutation_settings { - public: - // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 6; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the - * value needs to be set to zero. - * - * @details If this is true then permutation takes place in this row - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + +#include +#include + +namespace bb { + +class perm_main_bin_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 6; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the + * value needs to be set to zero. + * + * @details If this is true then permutation takes place in this row + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_main_bin_sel == 1 || in.avm_binary_start == 1); } - - /** - * @brief Get all the entities for the permutation when we don't need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.perm_main_bin, -in.avm_main_bin_sel, -in.avm_main_bin_sel, -in.avm_binary_start, -in.avm_main_clk, -in.avm_main_ia, -in.avm_main_ib, -in.avm_main_ic, -in.avm_main_bin_op_id, -in.avm_main_r_in_tag, -in.avm_binary_clk, -in.avm_binary_acc_ia, -in.avm_binary_acc_ib, -in.avm_binary_acc_ic, -in.avm_binary_op_id, -in.avm_binary_in_tag - ); - - } - - - /** - * @brief Get all the entities for the permutation when need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.perm_main_bin, -in.avm_main_bin_sel, -in.avm_main_bin_sel, -in.avm_binary_start, -in.avm_main_clk, -in.avm_main_ia, -in.avm_main_ib, -in.avm_main_ic, -in.avm_main_bin_op_id, -in.avm_main_r_in_tag, -in.avm_binary_clk, -in.avm_binary_acc_ia, -in.avm_binary_acc_ib, -in.avm_binary_acc_ic, -in.avm_binary_op_id, -in.avm_binary_in_tag - ); - + + /** + * @brief Get all the entities for the permutation when we don't need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.perm_main_bin, + in.avm_main_bin_sel, + in.avm_main_bin_sel, + in.avm_binary_start, + in.avm_main_clk, + in.avm_main_ia, + in.avm_main_ib, + in.avm_main_ic, + in.avm_main_bin_op_id, + in.avm_main_r_in_tag, + in.avm_binary_clk, + in.avm_binary_acc_ia, + in.avm_binary_acc_ib, + in.avm_binary_acc_ic, + in.avm_binary_op_id, + in.avm_binary_in_tag); } - - }; - - template using perm_main_bin_relation = GenericPermutationRelation; - template using perm_main_bin = GenericPermutation; - + /** + * @brief Get all the entities for the permutation when need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.perm_main_bin, + in.avm_main_bin_sel, + in.avm_main_bin_sel, + in.avm_binary_start, + in.avm_main_clk, + in.avm_main_ia, + in.avm_main_ib, + in.avm_main_ic, + in.avm_main_bin_op_id, + in.avm_main_r_in_tag, + in.avm_binary_clk, + in.avm_binary_acc_ia, + in.avm_binary_acc_ib, + in.avm_binary_acc_ic, + in.avm_binary_op_id, + in.avm_binary_in_tag); } - \ No newline at end of file +}; + +template +using perm_main_bin_relation = GenericPermutationRelation; +template using perm_main_bin = GenericPermutation; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_conv.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_conv.hpp index aa702a5ec18..2d7ac39f44e 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_conv.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_conv.hpp @@ -1,109 +1,102 @@ - - #pragma once - - #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" - - #include - #include - - - namespace bb { - - class perm_main_conv_permutation_settings { - public: - // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 4; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the - * value needs to be set to zero. - * - * @details If this is true then permutation takes place in this row - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + +#include +#include + +namespace bb { + +class perm_main_conv_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 4; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the + * value needs to be set to zero. + * + * @details If this is true then permutation takes place in this row + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_main_sel_op_radix_le == 1 || in.avm_conversion_to_radix_le_sel == 1); } - - /** - * @brief Get all the entities for the permutation when we don't need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.perm_main_conv, -in.avm_main_sel_op_radix_le, -in.avm_main_sel_op_radix_le, -in.avm_conversion_to_radix_le_sel, -in.avm_main_clk, -in.avm_main_ia, -in.avm_main_ic, -in.avm_main_id, -in.avm_conversion_clk, -in.avm_conversion_input, -in.avm_conversion_radix, -in.avm_conversion_num_limbs - ); - - } - - - /** - * @brief Get all the entities for the permutation when need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.perm_main_conv, -in.avm_main_sel_op_radix_le, -in.avm_main_sel_op_radix_le, -in.avm_conversion_to_radix_le_sel, -in.avm_main_clk, -in.avm_main_ia, -in.avm_main_ic, -in.avm_main_id, -in.avm_conversion_clk, -in.avm_conversion_input, -in.avm_conversion_radix, -in.avm_conversion_num_limbs - ); - + + /** + * @brief Get all the entities for the permutation when we don't need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.perm_main_conv, + in.avm_main_sel_op_radix_le, + in.avm_main_sel_op_radix_le, + in.avm_conversion_to_radix_le_sel, + in.avm_main_clk, + in.avm_main_ia, + in.avm_main_ic, + in.avm_main_id, + in.avm_conversion_clk, + in.avm_conversion_input, + in.avm_conversion_radix, + in.avm_conversion_num_limbs); } - - }; - - template using perm_main_conv_relation = GenericPermutationRelation; - template using perm_main_conv = GenericPermutation; - + /** + * @brief Get all the entities for the permutation when need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.perm_main_conv, + in.avm_main_sel_op_radix_le, + in.avm_main_sel_op_radix_le, + in.avm_conversion_to_radix_le_sel, + in.avm_main_clk, + in.avm_main_ia, + in.avm_main_ic, + in.avm_main_id, + in.avm_conversion_clk, + in.avm_conversion_input, + in.avm_conversion_radix, + in.avm_conversion_num_limbs); } - \ No newline at end of file +}; + +template +using perm_main_conv_relation = GenericPermutationRelation; +template using perm_main_conv = GenericPermutation; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_a.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_a.hpp index eb6fb871229..d7647bcc463 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_a.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_a.hpp @@ -1,129 +1,122 @@ - - #pragma once - - #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" - - #include - #include - - - namespace bb { - - class perm_main_mem_a_permutation_settings { - public: - // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 9; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the - * value needs to be set to zero. - * - * @details If this is true then permutation takes place in this row - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + +#include +#include + +namespace bb { + +class perm_main_mem_a_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 9; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the + * value needs to be set to zero. + * + * @details If this is true then permutation takes place in this row + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_main_mem_op_a == 1 || in.avm_mem_op_a == 1); } - - /** - * @brief Get all the entities for the permutation when we don't need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.perm_main_mem_a, -in.avm_main_mem_op_a, -in.avm_main_mem_op_a, -in.avm_mem_op_a, -in.avm_main_clk, -in.avm_main_space_id, -in.avm_main_mem_idx_a, -in.avm_main_ia, -in.avm_main_rwa, -in.avm_main_r_in_tag, -in.avm_main_w_in_tag, -in.avm_main_sel_mov_a, -in.avm_main_sel_cmov, -in.avm_mem_clk, -in.avm_mem_space_id, -in.avm_mem_addr, -in.avm_mem_val, -in.avm_mem_rw, -in.avm_mem_r_in_tag, -in.avm_mem_w_in_tag, -in.avm_mem_sel_mov_a, -in.avm_mem_sel_cmov - ); - - } - - - /** - * @brief Get all the entities for the permutation when need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.perm_main_mem_a, -in.avm_main_mem_op_a, -in.avm_main_mem_op_a, -in.avm_mem_op_a, -in.avm_main_clk, -in.avm_main_space_id, -in.avm_main_mem_idx_a, -in.avm_main_ia, -in.avm_main_rwa, -in.avm_main_r_in_tag, -in.avm_main_w_in_tag, -in.avm_main_sel_mov_a, -in.avm_main_sel_cmov, -in.avm_mem_clk, -in.avm_mem_space_id, -in.avm_mem_addr, -in.avm_mem_val, -in.avm_mem_rw, -in.avm_mem_r_in_tag, -in.avm_mem_w_in_tag, -in.avm_mem_sel_mov_a, -in.avm_mem_sel_cmov - ); - + + /** + * @brief Get all the entities for the permutation when we don't need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.perm_main_mem_a, + in.avm_main_mem_op_a, + in.avm_main_mem_op_a, + in.avm_mem_op_a, + in.avm_main_clk, + in.avm_main_space_id, + in.avm_main_mem_idx_a, + in.avm_main_ia, + in.avm_main_rwa, + in.avm_main_r_in_tag, + in.avm_main_w_in_tag, + in.avm_main_sel_mov_a, + in.avm_main_sel_cmov, + in.avm_mem_clk, + in.avm_mem_space_id, + in.avm_mem_addr, + in.avm_mem_val, + in.avm_mem_rw, + in.avm_mem_r_in_tag, + in.avm_mem_w_in_tag, + in.avm_mem_sel_mov_a, + in.avm_mem_sel_cmov); } - - }; - - template using perm_main_mem_a_relation = GenericPermutationRelation; - template using perm_main_mem_a = GenericPermutation; - + /** + * @brief Get all the entities for the permutation when need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.perm_main_mem_a, + in.avm_main_mem_op_a, + in.avm_main_mem_op_a, + in.avm_mem_op_a, + in.avm_main_clk, + in.avm_main_space_id, + in.avm_main_mem_idx_a, + in.avm_main_ia, + in.avm_main_rwa, + in.avm_main_r_in_tag, + in.avm_main_w_in_tag, + in.avm_main_sel_mov_a, + in.avm_main_sel_cmov, + in.avm_mem_clk, + in.avm_mem_space_id, + in.avm_mem_addr, + in.avm_mem_val, + in.avm_mem_rw, + in.avm_mem_r_in_tag, + in.avm_mem_w_in_tag, + in.avm_mem_sel_mov_a, + in.avm_mem_sel_cmov); } - \ No newline at end of file +}; + +template +using perm_main_mem_a_relation = GenericPermutationRelation; +template using perm_main_mem_a = GenericPermutation; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_b.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_b.hpp index 6192eecd8b0..7d873de8722 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_b.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_b.hpp @@ -1,129 +1,122 @@ - - #pragma once - - #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" - - #include - #include - - - namespace bb { - - class perm_main_mem_b_permutation_settings { - public: - // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 9; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the - * value needs to be set to zero. - * - * @details If this is true then permutation takes place in this row - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + +#include +#include + +namespace bb { + +class perm_main_mem_b_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 9; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the + * value needs to be set to zero. + * + * @details If this is true then permutation takes place in this row + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_main_mem_op_b == 1 || in.avm_mem_op_b == 1); } - - /** - * @brief Get all the entities for the permutation when we don't need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.perm_main_mem_b, -in.avm_main_mem_op_b, -in.avm_main_mem_op_b, -in.avm_mem_op_b, -in.avm_main_clk, -in.avm_main_space_id, -in.avm_main_mem_idx_b, -in.avm_main_ib, -in.avm_main_rwb, -in.avm_main_r_in_tag, -in.avm_main_w_in_tag, -in.avm_main_sel_mov_b, -in.avm_main_sel_cmov, -in.avm_mem_clk, -in.avm_mem_space_id, -in.avm_mem_addr, -in.avm_mem_val, -in.avm_mem_rw, -in.avm_mem_r_in_tag, -in.avm_mem_w_in_tag, -in.avm_mem_sel_mov_b, -in.avm_mem_sel_cmov - ); - - } - - - /** - * @brief Get all the entities for the permutation when need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.perm_main_mem_b, -in.avm_main_mem_op_b, -in.avm_main_mem_op_b, -in.avm_mem_op_b, -in.avm_main_clk, -in.avm_main_space_id, -in.avm_main_mem_idx_b, -in.avm_main_ib, -in.avm_main_rwb, -in.avm_main_r_in_tag, -in.avm_main_w_in_tag, -in.avm_main_sel_mov_b, -in.avm_main_sel_cmov, -in.avm_mem_clk, -in.avm_mem_space_id, -in.avm_mem_addr, -in.avm_mem_val, -in.avm_mem_rw, -in.avm_mem_r_in_tag, -in.avm_mem_w_in_tag, -in.avm_mem_sel_mov_b, -in.avm_mem_sel_cmov - ); - + + /** + * @brief Get all the entities for the permutation when we don't need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.perm_main_mem_b, + in.avm_main_mem_op_b, + in.avm_main_mem_op_b, + in.avm_mem_op_b, + in.avm_main_clk, + in.avm_main_space_id, + in.avm_main_mem_idx_b, + in.avm_main_ib, + in.avm_main_rwb, + in.avm_main_r_in_tag, + in.avm_main_w_in_tag, + in.avm_main_sel_mov_b, + in.avm_main_sel_cmov, + in.avm_mem_clk, + in.avm_mem_space_id, + in.avm_mem_addr, + in.avm_mem_val, + in.avm_mem_rw, + in.avm_mem_r_in_tag, + in.avm_mem_w_in_tag, + in.avm_mem_sel_mov_b, + in.avm_mem_sel_cmov); } - - }; - - template using perm_main_mem_b_relation = GenericPermutationRelation; - template using perm_main_mem_b = GenericPermutation; - + /** + * @brief Get all the entities for the permutation when need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.perm_main_mem_b, + in.avm_main_mem_op_b, + in.avm_main_mem_op_b, + in.avm_mem_op_b, + in.avm_main_clk, + in.avm_main_space_id, + in.avm_main_mem_idx_b, + in.avm_main_ib, + in.avm_main_rwb, + in.avm_main_r_in_tag, + in.avm_main_w_in_tag, + in.avm_main_sel_mov_b, + in.avm_main_sel_cmov, + in.avm_mem_clk, + in.avm_mem_space_id, + in.avm_mem_addr, + in.avm_mem_val, + in.avm_mem_rw, + in.avm_mem_r_in_tag, + in.avm_mem_w_in_tag, + in.avm_mem_sel_mov_b, + in.avm_mem_sel_cmov); } - \ No newline at end of file +}; + +template +using perm_main_mem_b_relation = GenericPermutationRelation; +template using perm_main_mem_b = GenericPermutation; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_c.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_c.hpp index 02629487ecd..64919b1ca3d 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_c.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_c.hpp @@ -1,121 +1,114 @@ - - #pragma once - - #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" - - #include - #include - - - namespace bb { - - class perm_main_mem_c_permutation_settings { - public: - // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 7; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the - * value needs to be set to zero. - * - * @details If this is true then permutation takes place in this row - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + +#include +#include + +namespace bb { + +class perm_main_mem_c_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 7; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the + * value needs to be set to zero. + * + * @details If this is true then permutation takes place in this row + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_main_mem_op_c == 1 || in.avm_mem_op_c == 1); } - - /** - * @brief Get all the entities for the permutation when we don't need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.perm_main_mem_c, -in.avm_main_mem_op_c, -in.avm_main_mem_op_c, -in.avm_mem_op_c, -in.avm_main_clk, -in.avm_main_space_id, -in.avm_main_mem_idx_c, -in.avm_main_ic, -in.avm_main_rwc, -in.avm_main_r_in_tag, -in.avm_main_w_in_tag, -in.avm_mem_clk, -in.avm_mem_space_id, -in.avm_mem_addr, -in.avm_mem_val, -in.avm_mem_rw, -in.avm_mem_r_in_tag, -in.avm_mem_w_in_tag - ); - - } - - - /** - * @brief Get all the entities for the permutation when need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.perm_main_mem_c, -in.avm_main_mem_op_c, -in.avm_main_mem_op_c, -in.avm_mem_op_c, -in.avm_main_clk, -in.avm_main_space_id, -in.avm_main_mem_idx_c, -in.avm_main_ic, -in.avm_main_rwc, -in.avm_main_r_in_tag, -in.avm_main_w_in_tag, -in.avm_mem_clk, -in.avm_mem_space_id, -in.avm_mem_addr, -in.avm_mem_val, -in.avm_mem_rw, -in.avm_mem_r_in_tag, -in.avm_mem_w_in_tag - ); - + + /** + * @brief Get all the entities for the permutation when we don't need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.perm_main_mem_c, + in.avm_main_mem_op_c, + in.avm_main_mem_op_c, + in.avm_mem_op_c, + in.avm_main_clk, + in.avm_main_space_id, + in.avm_main_mem_idx_c, + in.avm_main_ic, + in.avm_main_rwc, + in.avm_main_r_in_tag, + in.avm_main_w_in_tag, + in.avm_mem_clk, + in.avm_mem_space_id, + in.avm_mem_addr, + in.avm_mem_val, + in.avm_mem_rw, + in.avm_mem_r_in_tag, + in.avm_mem_w_in_tag); } - - }; - - template using perm_main_mem_c_relation = GenericPermutationRelation; - template using perm_main_mem_c = GenericPermutation; - + /** + * @brief Get all the entities for the permutation when need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.perm_main_mem_c, + in.avm_main_mem_op_c, + in.avm_main_mem_op_c, + in.avm_mem_op_c, + in.avm_main_clk, + in.avm_main_space_id, + in.avm_main_mem_idx_c, + in.avm_main_ic, + in.avm_main_rwc, + in.avm_main_r_in_tag, + in.avm_main_w_in_tag, + in.avm_mem_clk, + in.avm_mem_space_id, + in.avm_mem_addr, + in.avm_mem_val, + in.avm_mem_rw, + in.avm_mem_r_in_tag, + in.avm_mem_w_in_tag); } - \ No newline at end of file +}; + +template +using perm_main_mem_c_relation = GenericPermutationRelation; +template using perm_main_mem_c = GenericPermutation; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_d.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_d.hpp index 9decb0a8658..b6f64c60a27 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_d.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_d.hpp @@ -1,125 +1,118 @@ - - #pragma once - - #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" - - #include - #include - - - namespace bb { - - class perm_main_mem_d_permutation_settings { - public: - // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 8; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the - * value needs to be set to zero. - * - * @details If this is true then permutation takes place in this row - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + +#include +#include + +namespace bb { + +class perm_main_mem_d_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 8; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the + * value needs to be set to zero. + * + * @details If this is true then permutation takes place in this row + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_main_mem_op_d == 1 || in.avm_mem_op_d == 1); } - - /** - * @brief Get all the entities for the permutation when we don't need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.perm_main_mem_d, -in.avm_main_mem_op_d, -in.avm_main_mem_op_d, -in.avm_mem_op_d, -in.avm_main_clk, -in.avm_main_space_id, -in.avm_main_mem_idx_d, -in.avm_main_id, -in.avm_main_rwd, -in.avm_main_r_in_tag, -in.avm_main_w_in_tag, -in.avm_main_sel_cmov, -in.avm_mem_clk, -in.avm_mem_space_id, -in.avm_mem_addr, -in.avm_mem_val, -in.avm_mem_rw, -in.avm_mem_r_in_tag, -in.avm_mem_w_in_tag, -in.avm_mem_sel_cmov - ); - - } - - - /** - * @brief Get all the entities for the permutation when need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.perm_main_mem_d, -in.avm_main_mem_op_d, -in.avm_main_mem_op_d, -in.avm_mem_op_d, -in.avm_main_clk, -in.avm_main_space_id, -in.avm_main_mem_idx_d, -in.avm_main_id, -in.avm_main_rwd, -in.avm_main_r_in_tag, -in.avm_main_w_in_tag, -in.avm_main_sel_cmov, -in.avm_mem_clk, -in.avm_mem_space_id, -in.avm_mem_addr, -in.avm_mem_val, -in.avm_mem_rw, -in.avm_mem_r_in_tag, -in.avm_mem_w_in_tag, -in.avm_mem_sel_cmov - ); - + + /** + * @brief Get all the entities for the permutation when we don't need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.perm_main_mem_d, + in.avm_main_mem_op_d, + in.avm_main_mem_op_d, + in.avm_mem_op_d, + in.avm_main_clk, + in.avm_main_space_id, + in.avm_main_mem_idx_d, + in.avm_main_id, + in.avm_main_rwd, + in.avm_main_r_in_tag, + in.avm_main_w_in_tag, + in.avm_main_sel_cmov, + in.avm_mem_clk, + in.avm_mem_space_id, + in.avm_mem_addr, + in.avm_mem_val, + in.avm_mem_rw, + in.avm_mem_r_in_tag, + in.avm_mem_w_in_tag, + in.avm_mem_sel_cmov); } - - }; - - template using perm_main_mem_d_relation = GenericPermutationRelation; - template using perm_main_mem_d = GenericPermutation; - + /** + * @brief Get all the entities for the permutation when need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.perm_main_mem_d, + in.avm_main_mem_op_d, + in.avm_main_mem_op_d, + in.avm_mem_op_d, + in.avm_main_clk, + in.avm_main_space_id, + in.avm_main_mem_idx_d, + in.avm_main_id, + in.avm_main_rwd, + in.avm_main_r_in_tag, + in.avm_main_w_in_tag, + in.avm_main_sel_cmov, + in.avm_mem_clk, + in.avm_mem_space_id, + in.avm_mem_addr, + in.avm_mem_val, + in.avm_mem_rw, + in.avm_mem_r_in_tag, + in.avm_mem_w_in_tag, + in.avm_mem_sel_cmov); } - \ No newline at end of file +}; + +template +using perm_main_mem_d_relation = GenericPermutationRelation; +template using perm_main_mem_d = GenericPermutation; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_a.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_a.hpp index 0108ecbf364..fde1c682370 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_a.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_a.hpp @@ -1,109 +1,102 @@ - - #pragma once - - #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" - - #include - #include - - - namespace bb { - - class perm_main_mem_ind_a_permutation_settings { - public: - // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 4; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the - * value needs to be set to zero. - * - * @details If this is true then permutation takes place in this row - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + +#include +#include + +namespace bb { + +class perm_main_mem_ind_a_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 4; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the + * value needs to be set to zero. + * + * @details If this is true then permutation takes place in this row + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_main_ind_op_a == 1 || in.avm_mem_ind_op_a == 1); } - - /** - * @brief Get all the entities for the permutation when we don't need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.perm_main_mem_ind_a, -in.avm_main_ind_op_a, -in.avm_main_ind_op_a, -in.avm_mem_ind_op_a, -in.avm_main_clk, -in.avm_main_space_id, -in.avm_main_ind_a, -in.avm_main_mem_idx_a, -in.avm_mem_clk, -in.avm_mem_space_id, -in.avm_mem_addr, -in.avm_mem_val - ); - - } - - - /** - * @brief Get all the entities for the permutation when need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.perm_main_mem_ind_a, -in.avm_main_ind_op_a, -in.avm_main_ind_op_a, -in.avm_mem_ind_op_a, -in.avm_main_clk, -in.avm_main_space_id, -in.avm_main_ind_a, -in.avm_main_mem_idx_a, -in.avm_mem_clk, -in.avm_mem_space_id, -in.avm_mem_addr, -in.avm_mem_val - ); - + + /** + * @brief Get all the entities for the permutation when we don't need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.perm_main_mem_ind_a, + in.avm_main_ind_op_a, + in.avm_main_ind_op_a, + in.avm_mem_ind_op_a, + in.avm_main_clk, + in.avm_main_space_id, + in.avm_main_ind_a, + in.avm_main_mem_idx_a, + in.avm_mem_clk, + in.avm_mem_space_id, + in.avm_mem_addr, + in.avm_mem_val); } - - }; - - template using perm_main_mem_ind_a_relation = GenericPermutationRelation; - template using perm_main_mem_ind_a = GenericPermutation; - + /** + * @brief Get all the entities for the permutation when need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.perm_main_mem_ind_a, + in.avm_main_ind_op_a, + in.avm_main_ind_op_a, + in.avm_mem_ind_op_a, + in.avm_main_clk, + in.avm_main_space_id, + in.avm_main_ind_a, + in.avm_main_mem_idx_a, + in.avm_mem_clk, + in.avm_mem_space_id, + in.avm_mem_addr, + in.avm_mem_val); } - \ No newline at end of file +}; + +template +using perm_main_mem_ind_a_relation = GenericPermutationRelation; +template using perm_main_mem_ind_a = GenericPermutation; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_b.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_b.hpp index 53ce0e52669..0fb572b5302 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_b.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_b.hpp @@ -1,109 +1,102 @@ - - #pragma once - - #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" - - #include - #include - - - namespace bb { - - class perm_main_mem_ind_b_permutation_settings { - public: - // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 4; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the - * value needs to be set to zero. - * - * @details If this is true then permutation takes place in this row - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + +#include +#include + +namespace bb { + +class perm_main_mem_ind_b_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 4; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the + * value needs to be set to zero. + * + * @details If this is true then permutation takes place in this row + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_main_ind_op_b == 1 || in.avm_mem_ind_op_b == 1); } - - /** - * @brief Get all the entities for the permutation when we don't need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.perm_main_mem_ind_b, -in.avm_main_ind_op_b, -in.avm_main_ind_op_b, -in.avm_mem_ind_op_b, -in.avm_main_clk, -in.avm_main_space_id, -in.avm_main_ind_b, -in.avm_main_mem_idx_b, -in.avm_mem_clk, -in.avm_mem_space_id, -in.avm_mem_addr, -in.avm_mem_val - ); - - } - - - /** - * @brief Get all the entities for the permutation when need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.perm_main_mem_ind_b, -in.avm_main_ind_op_b, -in.avm_main_ind_op_b, -in.avm_mem_ind_op_b, -in.avm_main_clk, -in.avm_main_space_id, -in.avm_main_ind_b, -in.avm_main_mem_idx_b, -in.avm_mem_clk, -in.avm_mem_space_id, -in.avm_mem_addr, -in.avm_mem_val - ); - + + /** + * @brief Get all the entities for the permutation when we don't need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.perm_main_mem_ind_b, + in.avm_main_ind_op_b, + in.avm_main_ind_op_b, + in.avm_mem_ind_op_b, + in.avm_main_clk, + in.avm_main_space_id, + in.avm_main_ind_b, + in.avm_main_mem_idx_b, + in.avm_mem_clk, + in.avm_mem_space_id, + in.avm_mem_addr, + in.avm_mem_val); } - - }; - - template using perm_main_mem_ind_b_relation = GenericPermutationRelation; - template using perm_main_mem_ind_b = GenericPermutation; - + /** + * @brief Get all the entities for the permutation when need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.perm_main_mem_ind_b, + in.avm_main_ind_op_b, + in.avm_main_ind_op_b, + in.avm_mem_ind_op_b, + in.avm_main_clk, + in.avm_main_space_id, + in.avm_main_ind_b, + in.avm_main_mem_idx_b, + in.avm_mem_clk, + in.avm_mem_space_id, + in.avm_mem_addr, + in.avm_mem_val); } - \ No newline at end of file +}; + +template +using perm_main_mem_ind_b_relation = GenericPermutationRelation; +template using perm_main_mem_ind_b = GenericPermutation; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_c.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_c.hpp index 19a95a70842..98676a0d8b3 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_c.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_c.hpp @@ -1,109 +1,102 @@ - - #pragma once - - #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" - - #include - #include - - - namespace bb { - - class perm_main_mem_ind_c_permutation_settings { - public: - // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 4; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the - * value needs to be set to zero. - * - * @details If this is true then permutation takes place in this row - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + +#include +#include + +namespace bb { + +class perm_main_mem_ind_c_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 4; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the + * value needs to be set to zero. + * + * @details If this is true then permutation takes place in this row + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_main_ind_op_c == 1 || in.avm_mem_ind_op_c == 1); } - - /** - * @brief Get all the entities for the permutation when we don't need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.perm_main_mem_ind_c, -in.avm_main_ind_op_c, -in.avm_main_ind_op_c, -in.avm_mem_ind_op_c, -in.avm_main_clk, -in.avm_main_space_id, -in.avm_main_ind_c, -in.avm_main_mem_idx_c, -in.avm_mem_clk, -in.avm_mem_space_id, -in.avm_mem_addr, -in.avm_mem_val - ); - - } - - - /** - * @brief Get all the entities for the permutation when need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.perm_main_mem_ind_c, -in.avm_main_ind_op_c, -in.avm_main_ind_op_c, -in.avm_mem_ind_op_c, -in.avm_main_clk, -in.avm_main_space_id, -in.avm_main_ind_c, -in.avm_main_mem_idx_c, -in.avm_mem_clk, -in.avm_mem_space_id, -in.avm_mem_addr, -in.avm_mem_val - ); - + + /** + * @brief Get all the entities for the permutation when we don't need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.perm_main_mem_ind_c, + in.avm_main_ind_op_c, + in.avm_main_ind_op_c, + in.avm_mem_ind_op_c, + in.avm_main_clk, + in.avm_main_space_id, + in.avm_main_ind_c, + in.avm_main_mem_idx_c, + in.avm_mem_clk, + in.avm_mem_space_id, + in.avm_mem_addr, + in.avm_mem_val); } - - }; - - template using perm_main_mem_ind_c_relation = GenericPermutationRelation; - template using perm_main_mem_ind_c = GenericPermutation; - + /** + * @brief Get all the entities for the permutation when need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.perm_main_mem_ind_c, + in.avm_main_ind_op_c, + in.avm_main_ind_op_c, + in.avm_mem_ind_op_c, + in.avm_main_clk, + in.avm_main_space_id, + in.avm_main_ind_c, + in.avm_main_mem_idx_c, + in.avm_mem_clk, + in.avm_mem_space_id, + in.avm_mem_addr, + in.avm_mem_val); } - \ No newline at end of file +}; + +template +using perm_main_mem_ind_c_relation = GenericPermutationRelation; +template using perm_main_mem_ind_c = GenericPermutation; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_d.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_d.hpp index 5dcf9081cc7..c66b01e035a 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_d.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_d.hpp @@ -1,109 +1,102 @@ - - #pragma once - - #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" - - #include - #include - - - namespace bb { - - class perm_main_mem_ind_d_permutation_settings { - public: - // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 4; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the - * value needs to be set to zero. - * - * @details If this is true then permutation takes place in this row - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + +#include +#include + +namespace bb { + +class perm_main_mem_ind_d_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 4; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the + * value needs to be set to zero. + * + * @details If this is true then permutation takes place in this row + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_main_ind_op_d == 1 || in.avm_mem_ind_op_d == 1); } - - /** - * @brief Get all the entities for the permutation when we don't need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.perm_main_mem_ind_d, -in.avm_main_ind_op_d, -in.avm_main_ind_op_d, -in.avm_mem_ind_op_d, -in.avm_main_clk, -in.avm_main_space_id, -in.avm_main_ind_d, -in.avm_main_mem_idx_d, -in.avm_mem_clk, -in.avm_mem_space_id, -in.avm_mem_addr, -in.avm_mem_val - ); - - } - - - /** - * @brief Get all the entities for the permutation when need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.perm_main_mem_ind_d, -in.avm_main_ind_op_d, -in.avm_main_ind_op_d, -in.avm_mem_ind_op_d, -in.avm_main_clk, -in.avm_main_space_id, -in.avm_main_ind_d, -in.avm_main_mem_idx_d, -in.avm_mem_clk, -in.avm_mem_space_id, -in.avm_mem_addr, -in.avm_mem_val - ); - + + /** + * @brief Get all the entities for the permutation when we don't need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.perm_main_mem_ind_d, + in.avm_main_ind_op_d, + in.avm_main_ind_op_d, + in.avm_mem_ind_op_d, + in.avm_main_clk, + in.avm_main_space_id, + in.avm_main_ind_d, + in.avm_main_mem_idx_d, + in.avm_mem_clk, + in.avm_mem_space_id, + in.avm_mem_addr, + in.avm_mem_val); } - - }; - - template using perm_main_mem_ind_d_relation = GenericPermutationRelation; - template using perm_main_mem_ind_d = GenericPermutation; - + /** + * @brief Get all the entities for the permutation when need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.perm_main_mem_ind_d, + in.avm_main_ind_op_d, + in.avm_main_ind_op_d, + in.avm_mem_ind_op_d, + in.avm_main_clk, + in.avm_main_space_id, + in.avm_main_ind_d, + in.avm_main_mem_idx_d, + in.avm_mem_clk, + in.avm_mem_space_id, + in.avm_mem_addr, + in.avm_mem_val); } - \ No newline at end of file +}; + +template +using perm_main_mem_ind_d_relation = GenericPermutationRelation; +template using perm_main_mem_ind_d = GenericPermutation; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_pedersen.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_pedersen.hpp index 1452d0be369..75d4809336f 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_pedersen.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_pedersen.hpp @@ -1,101 +1,94 @@ - - #pragma once - - #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" - - #include - #include - - - namespace bb { - - class perm_main_pedersen_permutation_settings { - public: - // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 2; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the - * value needs to be set to zero. - * - * @details If this is true then permutation takes place in this row - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + +#include +#include + +namespace bb { + +class perm_main_pedersen_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 2; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the + * value needs to be set to zero. + * + * @details If this is true then permutation takes place in this row + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_main_sel_op_pedersen == 1 || in.avm_pedersen_pedersen_sel == 1); } - - /** - * @brief Get all the entities for the permutation when we don't need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.perm_main_pedersen, -in.avm_main_sel_op_pedersen, -in.avm_main_sel_op_pedersen, -in.avm_pedersen_pedersen_sel, -in.avm_main_clk, -in.avm_main_ia, -in.avm_pedersen_clk, -in.avm_pedersen_input - ); - - } - - - /** - * @brief Get all the entities for the permutation when need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.perm_main_pedersen, -in.avm_main_sel_op_pedersen, -in.avm_main_sel_op_pedersen, -in.avm_pedersen_pedersen_sel, -in.avm_main_clk, -in.avm_main_ia, -in.avm_pedersen_clk, -in.avm_pedersen_input - ); - + + /** + * @brief Get all the entities for the permutation when we don't need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.perm_main_pedersen, + in.avm_main_sel_op_pedersen, + in.avm_main_sel_op_pedersen, + in.avm_pedersen_pedersen_sel, + in.avm_main_clk, + in.avm_main_ia, + in.avm_pedersen_clk, + in.avm_pedersen_input); } - - }; - - template using perm_main_pedersen_relation = GenericPermutationRelation; - template using perm_main_pedersen = GenericPermutation; - + /** + * @brief Get all the entities for the permutation when need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.perm_main_pedersen, + in.avm_main_sel_op_pedersen, + in.avm_main_sel_op_pedersen, + in.avm_pedersen_pedersen_sel, + in.avm_main_clk, + in.avm_main_ia, + in.avm_pedersen_clk, + in.avm_pedersen_input); } - \ No newline at end of file +}; + +template +using perm_main_pedersen_relation = GenericPermutationRelation; +template using perm_main_pedersen = GenericPermutation; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_pos2_perm.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_pos2_perm.hpp index 886d8318195..e75d3658eca 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_pos2_perm.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_pos2_perm.hpp @@ -1,105 +1,98 @@ - - #pragma once - - #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" - - #include - #include - - - namespace bb { - - class perm_main_pos2_perm_permutation_settings { - public: - // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 3; - - /** - * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the - * value needs to be set to zero. - * - * @details If this is true then permutation takes place in this row - */ - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { + +#pragma once + +#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + +#include +#include + +namespace bb { + +class perm_main_pos2_perm_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 3; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the + * value needs to be set to zero. + * + * @details If this is true then permutation takes place in this row + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { return (in.avm_main_sel_op_poseidon2 == 1 || in.avm_poseidon2_poseidon_perm_sel == 1); } - - /** - * @brief Get all the entities for the permutation when we don't need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_const_entities(const AllEntities& in) { - - return std::forward_as_tuple( - in.perm_main_pos2_perm, -in.avm_main_sel_op_poseidon2, -in.avm_main_sel_op_poseidon2, -in.avm_poseidon2_poseidon_perm_sel, -in.avm_main_clk, -in.avm_main_ia, -in.avm_main_ib, -in.avm_poseidon2_clk, -in.avm_poseidon2_input, -in.avm_poseidon2_output - ); - - } - - - /** - * @brief Get all the entities for the permutation when need to update them - * - * @details The entities are returned as a tuple of references in the following order: - * - The entity/polynomial used to store the product of the inverse values - * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of - * the inverse polynomial - * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum - * subrelation - * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum - * subrelation - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) - * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) - * - * @return All the entities needed for the permutation - */ - - template static inline auto get_nonconst_entities(AllEntities& in) { - - return std::forward_as_tuple( - in.perm_main_pos2_perm, -in.avm_main_sel_op_poseidon2, -in.avm_main_sel_op_poseidon2, -in.avm_poseidon2_poseidon_perm_sel, -in.avm_main_clk, -in.avm_main_ia, -in.avm_main_ib, -in.avm_poseidon2_clk, -in.avm_poseidon2_input, -in.avm_poseidon2_output - ); - + + /** + * @brief Get all the entities for the permutation when we don't need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.perm_main_pos2_perm, + in.avm_main_sel_op_poseidon2, + in.avm_main_sel_op_poseidon2, + in.avm_poseidon2_poseidon_perm_sel, + in.avm_main_clk, + in.avm_main_ia, + in.avm_main_ib, + in.avm_poseidon2_clk, + in.avm_poseidon2_input, + in.avm_poseidon2_output); } - - }; - - template using perm_main_pos2_perm_relation = GenericPermutationRelation; - template using perm_main_pos2_perm = GenericPermutation; - + /** + * @brief Get all the entities for the permutation when need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.perm_main_pos2_perm, + in.avm_main_sel_op_poseidon2, + in.avm_main_sel_op_poseidon2, + in.avm_poseidon2_poseidon_perm_sel, + in.avm_main_clk, + in.avm_main_ia, + in.avm_main_ib, + in.avm_poseidon2_clk, + in.avm_poseidon2_input, + in.avm_poseidon2_output); } - \ No newline at end of file +}; + +template +using perm_main_pos2_perm_relation = GenericPermutationRelation; +template using perm_main_pos2_perm = GenericPermutation; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp index 8c56ea7dce0..f01b3509cf9 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp @@ -2296,16 +2296,33 @@ uint32_t AvmTraceBuilder::read_slice_to_memory(uint8_t space_id, return num_main_rows; } -// Use the indirect later to support all the indirect accesses +/** + * @brief External Call with direct or indirect memory access. + * + * TODO: Use the indirect later to support all the indirect accesses + * NOTE: we do not constrain this here as it's behaviour will change fully once we have a full enqueued function + * call in one vm circuit + * @param indirect byte encoding information about indirect/direct memory access. + * @param gas_offset An index in memory pointing to the first of the gas value tuple (l2Gas, daGas) + * @param addr_offset An index in memory pointing to the target contract address + * @param args_offset An index in memory pointing to the first value of the input array for the external call + * @param args_size The number of values in the input array for the external call + * @param ret_offset An index in memory pointing to where the first value of the external calls return value should be + * stored. + * @param ret_size The number of values in the return array + * @param success_offset An index in memory pointing to where the success flag (U8) of the external call should be + * stored + * @param function_selector_offset An index in memory pointing to the function selector of the external call (TEMP) + */ void AvmTraceBuilder::op_call([[maybe_unused]] uint8_t indirect, uint32_t gas_offset, uint32_t addr_offset, uint32_t args_offset, uint32_t args_size, - [[maybe_unused]] uint32_t ret_offset, - [[maybe_unused]] uint32_t ret_size, - [[maybe_unused]] uint32_t success_offset, - [[maybe_unused]] uint32_t function_selector_offset) + uint32_t ret_offset, + uint32_t ret_size, + uint32_t success_offset, + uint32_t function_selector_offset) { auto clk = static_cast(main_trace.size()) + 1; // We can load up to 4 things per row @@ -2395,14 +2412,7 @@ void AvmTraceBuilder::op_call([[maybe_unused]] uint8_t indirect, .avm_main_pc = FF(pc), .avm_main_r_in_tag = FF(static_cast(AvmMemoryTag::U32)), }); - // NOTE: we do not constrain this here as it's behaviour will change fully once we have a full enqueued function - // call in one vm circuit clk++; - // PLAN - // 1. We load and constrain all of the operands ( of which there are loads, (either 4 more registers or we send - // it across two rows (we might be able to get away with this - and break a shit load of other stuff))) - std::vector write_operands = { ret_offset, success_offset }; - // 2. Use the write slice to memory once we get the entire return data size from the hint write_slice_to_memory(call_ptr, clk, uint32_t(read_ind_ret_offset.val), @@ -2414,10 +2424,6 @@ void AvmTraceBuilder::op_call([[maybe_unused]] uint8_t indirect, clk++; write_slice_to_memory( call_ptr, clk, success_offset, AvmMemoryTag::U0, AvmMemoryTag::U8, internal_return_ptr, { FF(1) }); - - // Getting the return values - // We should be able to receive return data values from the hints, and do an (unconstrained) sanity check that - // the correct values are here } /** diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.cpp index 6c235688fb0..d923c58c1cc 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.cpp @@ -6,7 +6,6 @@ #include "barretenberg/vm/generated/avm_circuit_builder.hpp" #include "barretenberg/vm/generated/avm_verifier.hpp" - namespace bb { using Flavor = AvmFlavor; @@ -37,8 +36,7 @@ AvmProver AvmComposer::create_prover(CircuitConstructor& circuit_constructor) return output_state; } -AvmVerifier AvmComposer::create_verifier( - CircuitConstructor& circuit_constructor) +AvmVerifier AvmComposer::create_verifier(CircuitConstructor& circuit_constructor) { auto verification_key = compute_verification_key(circuit_constructor); @@ -51,8 +49,7 @@ AvmVerifier AvmComposer::create_verifier( return output_state; } -std::shared_ptr AvmComposer::compute_proving_key( - CircuitConstructor& circuit_constructor) +std::shared_ptr AvmComposer::compute_proving_key(CircuitConstructor& circuit_constructor) { if (proving_key) { return proving_key; @@ -69,8 +66,7 @@ std::shared_ptr AvmComposer::compute_proving_key( return proving_key; } -std::shared_ptr AvmComposer::compute_verification_key( - CircuitConstructor& circuit_constructor) +std::shared_ptr AvmComposer::compute_verification_key(CircuitConstructor& circuit_constructor) { if (verification_key) { return verification_key; @@ -86,4 +82,4 @@ std::shared_ptr AvmComposer::compute_verification_key( return verification_key; } -} +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.hpp index 6d168c52d3b..a2f9fe68dcf 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.hpp @@ -7,67 +7,63 @@ #include "barretenberg/vm/generated/avm_circuit_builder.hpp" #include "barretenberg/vm/generated/avm_prover.hpp" #include "barretenberg/vm/generated/avm_verifier.hpp" - namespace bb { class AvmComposer { - public: - using Flavor = AvmFlavor; - using CircuitConstructor = AvmCircuitBuilder; - using ProvingKey = Flavor::ProvingKey; - using VerificationKey = Flavor::VerificationKey; - using PCS = Flavor::PCS; - using CommitmentKey = Flavor::CommitmentKey; - using VerifierCommitmentKey = Flavor::VerifierCommitmentKey; - - // TODO: which of these will we really need - static constexpr std::string_view NAME_STRING = "Avm"; - static constexpr size_t NUM_RESERVED_GATES = 0; - static constexpr size_t NUM_WIRES = Flavor::NUM_WIRES; - - std::shared_ptr proving_key; - std::shared_ptr verification_key; - - // The crs_factory holds the path to the srs and exposes methods to extract the srs elements - std::shared_ptr> crs_factory_; - - // The commitment key is passed to the prover but also used herein to compute the verfication key commitments - std::shared_ptr commitment_key; - - std::vector recursive_proof_public_input_indices; - bool contains_recursive_proof = false; - bool computed_witness = false; - - AvmComposer() - { - crs_factory_ = bb::srs::get_bn254_crs_factory(); - } - - AvmComposer(std::shared_ptr p_key, std::shared_ptr v_key) - : proving_key(std::move(p_key)) - , verification_key(std::move(v_key)) - {} - - AvmComposer(AvmComposer&& other) noexcept = default; - AvmComposer(AvmComposer const& other) noexcept = default; - AvmComposer& operator=(AvmComposer&& other) noexcept = default; - AvmComposer& operator=(AvmComposer const& other) noexcept = default; - ~AvmComposer() = default; - - std::shared_ptr compute_proving_key(CircuitConstructor& circuit_constructor); - std::shared_ptr compute_verification_key(CircuitConstructor& circuit_constructor); - - void compute_witness(CircuitConstructor& circuit_constructor); - - AvmProver create_prover(CircuitConstructor& circuit_constructor); - AvmVerifier create_verifier(CircuitConstructor& circuit_constructor); - - void add_table_column_selector_poly_to_proving_key(bb::polynomial& small, const std::string& tag); - - void compute_commitment_key(size_t circuit_size) - { - proving_key->commitment_key = std::make_shared(circuit_size); - }; + public: + using Flavor = AvmFlavor; + using CircuitConstructor = AvmCircuitBuilder; + using ProvingKey = Flavor::ProvingKey; + using VerificationKey = Flavor::VerificationKey; + using PCS = Flavor::PCS; + using CommitmentKey = Flavor::CommitmentKey; + using VerifierCommitmentKey = Flavor::VerifierCommitmentKey; + + // TODO: which of these will we really need + static constexpr std::string_view NAME_STRING = "Avm"; + static constexpr size_t NUM_RESERVED_GATES = 0; + static constexpr size_t NUM_WIRES = Flavor::NUM_WIRES; + + std::shared_ptr proving_key; + std::shared_ptr verification_key; + + // The crs_factory holds the path to the srs and exposes methods to extract the srs elements + std::shared_ptr> crs_factory_; + + // The commitment key is passed to the prover but also used herein to compute the verfication key commitments + std::shared_ptr commitment_key; + + std::vector recursive_proof_public_input_indices; + bool contains_recursive_proof = false; + bool computed_witness = false; + + AvmComposer() { crs_factory_ = bb::srs::get_bn254_crs_factory(); } + + AvmComposer(std::shared_ptr p_key, std::shared_ptr v_key) + : proving_key(std::move(p_key)) + , verification_key(std::move(v_key)) + {} + + AvmComposer(AvmComposer&& other) noexcept = default; + AvmComposer(AvmComposer const& other) noexcept = default; + AvmComposer& operator=(AvmComposer&& other) noexcept = default; + AvmComposer& operator=(AvmComposer const& other) noexcept = default; + ~AvmComposer() = default; + + std::shared_ptr compute_proving_key(CircuitConstructor& circuit_constructor); + std::shared_ptr compute_verification_key(CircuitConstructor& circuit_constructor); + + void compute_witness(CircuitConstructor& circuit_constructor); + + AvmProver create_prover(CircuitConstructor& circuit_constructor); + AvmVerifier create_verifier(CircuitConstructor& circuit_constructor); + + void add_table_column_selector_poly_to_proving_key(bb::polynomial& small, const std::string& tag); + + void compute_commitment_key(size_t circuit_size) + { + proving_key->commitment_key = std::make_shared(circuit_size); + }; }; } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.hpp index 3ec501782cd..74d504446a3 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.hpp @@ -1,5 +1,5 @@ - + #pragma once #include "barretenberg/commitment_schemes/zeromorph/zeromorph.hpp" #include "barretenberg/plonk/proof_system/types/proof.hpp" @@ -9,59 +9,56 @@ #include "barretenberg/vm/generated/avm_flavor.hpp" - - namespace bb { - - class AvmProver { - - using Flavor = AvmFlavor; - using FF = Flavor::FF; - using PCS = Flavor::PCS; - using PCSCommitmentKey = Flavor::CommitmentKey; - using ProvingKey = Flavor::ProvingKey; - using Polynomial = Flavor::Polynomial; - using ProverPolynomials = Flavor::ProverPolynomials; - using CommitmentLabels = Flavor::CommitmentLabels; - using Transcript = Flavor::Transcript; - - public: - explicit AvmProver(std::shared_ptr input_key, std::shared_ptr commitment_key); - - void execute_preamble_round(); - void execute_wire_commitments_round(); - void execute_log_derivative_inverse_round(); - void execute_relation_check_rounds(); - void execute_zeromorph_rounds(); - - HonkProof export_proof(); - HonkProof construct_proof(); - - std::shared_ptr transcript = std::make_shared(); - - std::vector public_inputs; - - bb::RelationParameters relation_parameters; - - std::shared_ptr key; - - // Container for spans of all polynomials required by the prover (i.e. all multivariates evaluated by Sumcheck). - ProverPolynomials prover_polynomials; - - CommitmentLabels commitment_labels; - typename Flavor::WitnessCommitments witness_commitments; - - Polynomial quotient_W; - - SumcheckOutput sumcheck_output; - - std::shared_ptr commitment_key; - - using ZeroMorph = ZeroMorphProver_; - - private: - HonkProof proof; - }; - - } // namespace bb - - \ No newline at end of file +namespace bb { + +class AvmProver { + + using Flavor = AvmFlavor; + using FF = Flavor::FF; + using PCS = Flavor::PCS; + using PCSCommitmentKey = Flavor::CommitmentKey; + using ProvingKey = Flavor::ProvingKey; + using Polynomial = Flavor::Polynomial; + using ProverPolynomials = Flavor::ProverPolynomials; + using CommitmentLabels = Flavor::CommitmentLabels; + using Transcript = Flavor::Transcript; + + public: + explicit AvmProver(std::shared_ptr input_key, std::shared_ptr commitment_key); + + void execute_preamble_round(); + void execute_wire_commitments_round(); + void execute_log_derivative_inverse_round(); + void execute_relation_check_rounds(); + void execute_zeromorph_rounds(); + + HonkProof export_proof(); + HonkProof construct_proof(); + + std::shared_ptr transcript = std::make_shared(); + + std::vector public_inputs; + + bb::RelationParameters relation_parameters; + + std::shared_ptr key; + + // Container for spans of all polynomials required by the prover (i.e. all multivariates evaluated by Sumcheck). + ProverPolynomials prover_polynomials; + + CommitmentLabels commitment_labels; + typename Flavor::WitnessCommitments witness_commitments; + + Polynomial quotient_W; + + SumcheckOutput sumcheck_output; + + std::shared_ptr commitment_key; + + using ZeroMorph = ZeroMorphProver_; + + private: + HonkProof proof; +}; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.hpp index c86de5921f0..2b7e126f1f1 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.hpp @@ -3,36 +3,32 @@ #pragma once #include "barretenberg/plonk/proof_system/types/proof.hpp" #include "barretenberg/sumcheck/sumcheck.hpp" -#include "barretenberg/vm/generated/avm_flavor.hpp" #include "barretenberg/vm/avm_trace/constants.hpp" +#include "barretenberg/vm/generated/avm_flavor.hpp" + +namespace bb { +class AvmVerifier { + using Flavor = AvmFlavor; + using FF = Flavor::FF; + using Commitment = Flavor::Commitment; + using VerificationKey = Flavor::VerificationKey; + using VerifierCommitmentKey = Flavor::VerifierCommitmentKey; + using Transcript = Flavor::Transcript; + + public: + explicit AvmVerifier(std::shared_ptr verifier_key = nullptr); + AvmVerifier(AvmVerifier&& other) noexcept; + AvmVerifier(const AvmVerifier& other) = delete; + + AvmVerifier& operator=(const AvmVerifier& other) = delete; + AvmVerifier& operator=(AvmVerifier&& other) noexcept; + + bool verify_proof(const HonkProof& proof, const std::vector>& public_inputs); + + std::shared_ptr key; + std::map commitments; + std::shared_ptr pcs_verification_key; + std::shared_ptr transcript; +}; - - namespace bb { - class AvmVerifier { - using Flavor = AvmFlavor; - using FF = Flavor::FF; - using Commitment = Flavor::Commitment; - using VerificationKey = Flavor::VerificationKey; - using VerifierCommitmentKey = Flavor::VerifierCommitmentKey; - using Transcript = Flavor::Transcript; - - public: - explicit AvmVerifier(std::shared_ptr verifier_key = nullptr); - AvmVerifier(AvmVerifier&& other) noexcept; - AvmVerifier(const AvmVerifier& other) = delete; - - AvmVerifier& operator=(const AvmVerifier& other) = delete; - AvmVerifier& operator=(AvmVerifier&& other) noexcept; - - bool verify_proof(const HonkProof& proof, const std::vector>& public_inputs); - - std::shared_ptr key; - std::map commitments; - std::shared_ptr pcs_verification_key; - std::shared_ptr transcript; - }; - - } // namespace bb - - - \ No newline at end of file +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp index 28a679249b3..a18b0b5403f 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp @@ -1799,9 +1799,6 @@ TEST_F(AvmExecutionTests, kernelOutputHashExistsOpcodes) TEST_F(AvmExecutionTests, opCallOpcodes) { - // Sload from a value that has not previously been written to will require a hint to process - // SET gas, addr, args, args size, ret offset, success, function selector in the order they appear for - // simplicity std::string bytecode_preamble; // Gas offset preamble bytecode_preamble += to_hex(OpCode::SET) + // opcode SET for gas offset indirect @@ -1855,8 +1852,6 @@ TEST_F(AvmExecutionTests, opCallOpcodes) auto bytecode = hex_to_bytes(bytecode_hex); auto instructions = Deserialization::parse(bytecode); - // ASSERT_THAT(instructions, SizeIs(3)); - std::vector calldata = {}; std::vector returndata = {}; From 4edbbe366bdb037bc28985ec548f5bd4e11b17c5 Mon Sep 17 00:00:00 2001 From: IlyasRidhuan Date: Tue, 4 Jun 2024 09:30:15 +0000 Subject: [PATCH 20/20] fix: unstage avm_helper --- .../barretenberg/vm/avm_trace/avm_helper.cpp | 64 ++++++++----------- 1 file changed, 28 insertions(+), 36 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp index 207d03175e0..900ef90f7a9 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp @@ -43,11 +43,11 @@ void log_avm_trace(std::vector const& trace, size_t beg, size_t end, bool e info("internal_return: ", trace.at(i).avm_main_sel_internal_return); info("internal_return_ptr:", trace.at(i).avm_main_internal_return_ptr); - // info("=======ALU TRACE====================================================================="); - // info("alu_clk ", trace.at(i).avm_alu_clk); - // info("alu_ia ", trace.at(i).avm_alu_ia); - // info("alu_ib ", trace.at(i).avm_alu_ib); - // info("alu_ic ", trace.at(i).avm_alu_ic); + info("=======ALU TRACE====================================================================="); + info("alu_clk ", trace.at(i).avm_alu_clk); + info("alu_ia ", trace.at(i).avm_alu_ia); + info("alu_ib ", trace.at(i).avm_alu_ib); + info("alu_ic ", trace.at(i).avm_alu_ic); info("=======MAIN TRACE===================================================================="); info("clk: ", trace.at(i).avm_main_clk); @@ -60,28 +60,23 @@ void log_avm_trace(std::vector const& trace, size_t beg, size_t end, bool e info("first: ", trace.at(i).avm_main_first); info("last: ", trace.at(i).avm_main_last); - // info("=======MEM_OP_A======================================================================"); - // info("mem_op_a: ", trace.at(i).avm_main_mem_op_a); - // info("mem_idx_a: ", trace.at(i).avm_main_mem_idx_a); - // info("rwa: ", trace.at(i).avm_main_rwa); - - // info("=======MEM_OP_B======================================================================"); - // info("mem_op_b: ", trace.at(i).avm_main_mem_op_b); - // info("mem_idx_b: ", trace.at(i).avm_main_mem_idx_b); - // info("rwb: ", trace.at(i).avm_main_rwb); - - // info("=======MEM_OP_C======================================================================"); - // info("mem_op_c: ", trace.at(i).avm_main_mem_op_c); - // info("mem_idx_c: ", trace.at(i).avm_main_mem_idx_c); - // info("rwc: ", trace.at(i).avm_main_rwc); - // info("diff_hi: ", trace.at(i).avm_mem_diff_hi); - // info("diff_mid: ", trace.at(i).avm_mem_diff_mid); - // info("diff_lo: ", trace.at(i).avm_mem_diff_lo); - - info("=======OUT_CONSISTENCY======================================================================"); - info("note_hash_write: ", trace.at(i).avm_kernel_emit_note_hash_write_offset); - info("nullifier_write: ", trace.at(i).avm_kernel_emit_nullifier_write_offset); - info("unencrypted_write: ", trace.at(i).avm_kernel_emit_unencrypted_log_write_offset); + info("=======MEM_OP_A======================================================================"); + info("mem_op_a: ", trace.at(i).avm_main_mem_op_a); + info("mem_idx_a: ", trace.at(i).avm_main_mem_idx_a); + info("rwa: ", trace.at(i).avm_main_rwa); + + info("=======MEM_OP_B======================================================================"); + info("mem_op_b: ", trace.at(i).avm_main_mem_op_b); + info("mem_idx_b: ", trace.at(i).avm_main_mem_idx_b); + info("rwb: ", trace.at(i).avm_main_rwb); + + info("=======MEM_OP_C======================================================================"); + info("mem_op_c: ", trace.at(i).avm_main_mem_op_c); + info("mem_idx_c: ", trace.at(i).avm_main_mem_idx_c); + info("rwc: ", trace.at(i).avm_main_rwc); + info("diff_hi: ", trace.at(i).avm_mem_diff_hi); + info("diff_mid: ", trace.at(i).avm_mem_diff_mid); + info("diff_lo: ", trace.at(i).avm_mem_diff_lo); info("=======GAS ACCOUNTING================================================================"); info("opcode active: ", trace.at(i).avm_main_gas_cost_active); @@ -92,15 +87,12 @@ void log_avm_trace(std::vector const& trace, size_t beg, size_t end, bool e if (enable_selectors) { info("=======SELECTORS======================================================================"); - info("sel_op_emit_note_hash: ", trace.at(i).avm_main_sel_op_emit_note_hash); - info("sel_op_emit_nullifier: ", trace.at(i).avm_main_sel_op_emit_nullifier); - info("sel_op_emit_unencryped_log: ", trace.at(i).avm_main_sel_op_emit_unencrypted_log); - // info("sel_op_add: ", trace.at(i).avm_main_sel_op_add); - // info("sel_op_sub: ", trace.at(i).avm_main_sel_op_sub); - // info("sel_op_mul: ", trace.at(i).avm_main_sel_op_mul); - // info("sel_op_eq: ", trace.at(i).avm_main_sel_op_eq); - // info("sel_op_not: ", trace.at(i).avm_main_sel_op_not); - // info("sel_op_sel_alu: ", trace.at(i).avm_main_alu_sel); + info("sel_op_add: ", trace.at(i).avm_main_sel_op_add); + info("sel_op_sub: ", trace.at(i).avm_main_sel_op_sub); + info("sel_op_mul: ", trace.at(i).avm_main_sel_op_mul); + info("sel_op_eq: ", trace.at(i).avm_main_sel_op_eq); + info("sel_op_not: ", trace.at(i).avm_main_sel_op_not); + info("sel_op_sel_alu: ", trace.at(i).avm_main_alu_sel); } info("\n"); }