From 1dc705ed99f22f8569dfa510345f4dcc3ee1ca43 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Thu, 4 Apr 2024 14:32:20 +0000 Subject: [PATCH 1/9] 5557: Add an additional intermediate register id --- barretenberg/cpp/pil/avm/avm_main.pil | 23 ++- barretenberg/cpp/pil/avm/avm_mem.pil | 12 +- .../relations/generated/avm/avm_alu.hpp | 33 ++- .../relations/generated/avm/avm_main.hpp | 191 ++++++++++++++++++ .../relations/generated/avm/avm_mem.hpp | 126 ++++++++---- .../relations/generated/avm/declare_views.hpp | 10 + .../generated/avm/perm_main_mem_d.hpp | 110 ++++++++++ .../generated/avm/perm_main_mem_ind_d.hpp | 98 +++++++++ .../vm/avm_trace/avm_mem_trace.hpp | 15 +- .../barretenberg/vm/avm_trace/avm_trace.cpp | 7 + .../vm/generated/avm_circuit_builder.hpp | 52 +++++ .../barretenberg/vm/generated/avm_flavor.hpp | 119 +++++++++++ .../vm/generated/avm_verifier.cpp | 24 +++ 13 files changed, 759 insertions(+), 61 deletions(-) create mode 100644 barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_d.hpp create mode 100644 barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_d.hpp diff --git a/barretenberg/cpp/pil/avm/avm_main.pil b/barretenberg/cpp/pil/avm/avm_main.pil index 92fa0f4fa83..15ec9398016 100644 --- a/barretenberg/cpp/pil/avm/avm_main.pil +++ b/barretenberg/cpp/pil/avm/avm_main.pil @@ -80,27 +80,31 @@ namespace avm_main(256); pol commit ia; pol commit ib; pol commit ic; + pol commit id; // Memory operation selector per intermediate register pol commit mem_op_a; pol commit mem_op_b; pol commit mem_op_c; + pol commit mem_op_d; // Read-write flag per intermediate register: Read = 0, Write = 1 pol commit rwa; pol commit rwb; pol commit rwc; + pol commit rwd; // Indirect register values pol commit ind_a; pol commit ind_b; pol commit ind_c; + pol commit ind_d; // Indirect memory operation selector per indirect register pol commit ind_op_a; pol commit ind_op_b; pol commit ind_op_c; - + pol commit ind_op_d; // Memory index involved into a memory operation per pertaining intermediate register // We should range constrain it to 32 bits ultimately. For first version of the AVM, @@ -108,7 +112,7 @@ namespace avm_main(256); pol commit mem_idx_a; pol commit mem_idx_b; pol commit mem_idx_c; - + pol commit mem_idx_d; // Track the last line of the execution trace. It does NOT correspond to the last row of the whole table // of size N. As this depends on the supplied bytecode, this polynomial cannot be constant. @@ -143,19 +147,22 @@ namespace avm_main(256); mem_op_a * (1 - mem_op_a) = 0; mem_op_b * (1 - mem_op_b) = 0; mem_op_c * (1 - mem_op_c) = 0; + mem_op_d * (1 - mem_op_d) = 0; rwa * (1 - rwa) = 0; rwb * (1 - rwb) = 0; rwc * (1 - rwc) = 0; + rwd * (1 - rwd) = 0; // Might be removed if derived from opcode based on a lookup of constants ind_op_a * (1 - ind_op_a) = 0; ind_op_b * (1 - ind_op_b) = 0; ind_op_c * (1 - ind_op_c) = 0; + ind_op_d * (1 - ind_op_d) = 0; // TODO - Constraints: - // - mem_idx_a, mem_idx_b, mem_idx_c to u32 type - // - ind_a, ind_b, ind_c to u32 type + // - mem_idx_a, mem_idx_b, mem_idx_c, mem_idx_d to u32 type + // - ind_a, ind_b, ind_c, ind_d to u32 type // - 0 <= r_in_tag, w_in_tag <= 6 // Maybe not needed as probably derived by the operation decomposition. //====== COMPARATOR OPCODES CONSTRAINTS ===================================== @@ -302,6 +309,11 @@ namespace avm_main(256); is avm_mem.op_c {avm_mem.clk, avm_mem.addr, avm_mem.val, avm_mem.rw, avm_mem.r_in_tag, avm_mem.w_in_tag}; + #[PERM_MAIN_MEM_D] + mem_op_d {clk, mem_idx_d, id, rwd, r_in_tag, w_in_tag} + is + avm_mem.op_d {avm_mem.clk, avm_mem.addr, avm_mem.val, avm_mem.rw, avm_mem.r_in_tag, avm_mem.w_in_tag}; + #[PERM_MAIN_MEM_IND_A] ind_op_a {clk, ind_a, mem_idx_a} is avm_mem.ind_op_a {avm_mem.clk, avm_mem.addr, avm_mem.val}; @@ -311,6 +323,9 @@ namespace avm_main(256); #[PERM_MAIN_MEM_IND_C] ind_op_c {clk, ind_c, mem_idx_c} is avm_mem.ind_op_c {avm_mem.clk, avm_mem.addr, avm_mem.val}; + #[PERM_MAIN_MEM_IND_D] + ind_op_d {clk, ind_d, mem_idx_d} is avm_mem.ind_op_d {avm_mem.clk, avm_mem.addr, avm_mem.val}; + //====== Inter-table Constraints (Range Checks) ============================================ // TODO: Investigate optimising these range checks. Handling non-FF elements should require less range checks. #[LOOKUP_U8_0] diff --git a/barretenberg/cpp/pil/avm/avm_mem.pil b/barretenberg/cpp/pil/avm/avm_mem.pil index 7be221ed2f5..ddcdee3e9f3 100644 --- a/barretenberg/cpp/pil/avm/avm_mem.pil +++ b/barretenberg/cpp/pil/avm/avm_mem.pil @@ -20,11 +20,13 @@ namespace avm_mem(256); pol commit op_a; pol commit op_b; pol commit op_c; + pol commit op_d; // Indicator of the indirect register pertaining to the memory operation (foreign key to avm_main.ind_op_XXX) pol commit ind_op_a; pol commit ind_op_b; pol commit ind_op_c; + pol commit ind_op_d; // Selector for MOV opcode (copied from main trace for loading operation on intermediated register ia) // Boolean constraint is performed in main trace. @@ -44,20 +46,22 @@ namespace avm_mem(256); op_a * (1 - op_a) = 0; op_b * (1 - op_b) = 0; op_c * (1 - op_c) = 0; + op_d * (1 - op_d) = 0; ind_op_a * (1 - ind_op_a) = 0; ind_op_b * (1 - ind_op_b) = 0; ind_op_c * (1 - ind_op_c) = 0; + ind_op_d * (1 - ind_op_d) = 0; // TODO: addr is u32 and 0 <= tag <= 6 // (r_in_tag, w_in_tag will be constrained through inclusion check to main trace) // Maximum one memory operation enabled per row - pol MEM_SEL = op_a + op_b + op_c + ind_op_a + ind_op_b + ind_op_c; + pol MEM_SEL = op_a + op_b + op_c + op_d + ind_op_a + ind_op_b + ind_op_c + ind_op_d; MEM_SEL * (MEM_SEL - 1) = 0; // sub_clk derivation - pol IND_OP = ind_op_a + ind_op_b + ind_op_c; - sub_clk = MEM_SEL * (ind_op_b + op_b + 2 * (ind_op_c + op_c) + 3 * (1 - IND_OP + rw)); + pol IND_OP = ind_op_a + ind_op_b + ind_op_c + ind_op_d; + sub_clk = MEM_SEL * (ind_op_b + op_b + 2 * (ind_op_c + op_c) + 3 * (ind_op_d + op_d) + 4 * (1 - IND_OP + rw)); // We need the MEM_SEL factor as the right factor is not zero when all columns are zero. // Remark: lastAccess == 1 on first row and therefore any relation with the @@ -140,11 +144,13 @@ namespace avm_mem(256); ind_op_a * (r_in_tag - 3) = 0; ind_op_b * (r_in_tag - 3) = 0; ind_op_c * (r_in_tag - 3) = 0; + ind_op_d * (r_in_tag - 3) = 0; // Indirect operation is always a load ind_op_a * rw = 0; ind_op_b * rw = 0; ind_op_c * rw = 0; + ind_op_d * rw = 0; //====== MOV Opcode Tag Constraint ===================================== // The following constraint ensures that the r_in_tag is set to tag for 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 fc4fcff7998..84612d3fe23 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_alu.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_alu.hpp @@ -271,10 +271,18 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(9); - 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)))); + 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{ 0, 1, 0, 0 }))) + + (avm_alu_u16_r4 * FF(uint256_t{ 0, 65536, 0, 0 }))) + + (avm_alu_u16_r5 * FF(uint256_t{ 0, 4294967296, 0, 0 }))) + + (avm_alu_u16_r6 * FF(uint256_t{ 0, 281474976710656, 0, 0 }))) - + avm_alu_ia) + + (avm_alu_ff_tag * avm_alu_ic))) + + ((avm_alu_op_add - avm_alu_op_sub) * ((avm_alu_cf * FF(uint256_t{ 0, 0, 1, 0 })) - avm_alu_ib))); tmp *= scaling_factor; std::get<9>(evals) += tmp; } @@ -328,7 +336,15 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(12); - auto tmp = ((avm_alu_ff_tag * avm_alu_op_mul) * ((avm_alu_ia * avm_alu_ib) - avm_alu_ic)); + 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{ 0, 1, 0, 0 }))) + + (avm_alu_u16_r4 * FF(uint256_t{ 0, 65536, 0, 0 }))) + + (avm_alu_u16_r5 * FF(uint256_t{ 0, 4294967296, 0, 0 }))) + + (avm_alu_u16_r6 * FF(uint256_t{ 0, 281474976710656, 0, 0 }))) - + (avm_alu_ia * avm_alu_ib))); tmp *= scaling_factor; std::get<12>(evals) += tmp; } @@ -418,7 +434,12 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(18); - auto tmp = (avm_alu_op_not * avm_alu_ff_tag); + 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{ 0, 1, 0, 0 }))) + + (avm_alu_u128_tag * FF(uint256_t{ 0, 0, 1, 0 }))) - + FF(1)))); tmp *= scaling_factor; std::get<18>(evals) += tmp; } 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 b3ae090ccdf..7b6b7460974 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_main.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_main.hpp @@ -17,6 +17,7 @@ template struct Avm_mainRow { FF avm_main_ind_op_a{}; FF avm_main_ind_op_b{}; FF avm_main_ind_op_c{}; + FF avm_main_ind_op_d{}; FF avm_main_internal_return_ptr{}; FF avm_main_internal_return_ptr_shift{}; FF avm_main_inv{}; @@ -25,6 +26,7 @@ template struct Avm_mainRow { FF avm_main_mem_op_a{}; FF avm_main_mem_op_b{}; FF avm_main_mem_op_c{}; + FF avm_main_mem_op_d{}; FF avm_main_op_err{}; FF avm_main_pc{}; FF avm_main_pc_shift{}; @@ -32,6 +34,7 @@ template struct Avm_mainRow { FF avm_main_rwa{}; FF avm_main_rwb{}; FF avm_main_rwc{}; + FF avm_main_rwd{}; FF avm_main_sel_halt{}; FF avm_main_sel_internal_call{}; FF avm_main_sel_internal_return{}; @@ -55,6 +58,7 @@ template struct Avm_mainRow { inline std::string get_relation_label_avm_main(int index) { switch (index) { +<<<<<<< HEAD case 27: return "OUTPUT_U8"; @@ -92,6 +96,45 @@ inline std::string get_relation_label_avm_main(int index) return "BIN_SEL_1"; case 50: +======= + case 28: + return "EQ_OUTPUT_U8"; + + case 29: + return "SUBOP_DIVISION_FF"; + + case 30: + return "SUBOP_DIVISION_ZERO_ERR1"; + + case 31: + return "SUBOP_DIVISION_ZERO_ERR2"; + + case 32: + return "SUBOP_ERROR_RELEVANT_OP"; + + case 34: + return "RETURN_POINTER_INCREMENT"; + + case 40: + return "RETURN_POINTER_DECREMENT"; + + case 45: + return "PC_INCREMENT"; + + case 46: + return "INTERNAL_RETURN_POINTER_CONSISTENCY"; + + case 47: + return "MOV_SAME_VALUE"; + + case 48: + return "MOV_MAIN_SAME_TAG"; + + case 50: + return "BIN_SEL_1"; + + case 51: +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) return "BIN_SEL_2"; } return std::to_string(index); @@ -101,9 +144,15 @@ template class avm_mainImpl { public: using FF = FF_; +<<<<<<< HEAD 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, 5, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 3, 3, 3, 3, 2, +======= + 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, 5, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 3, 3, 3, 3, 2, +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) }; template @@ -269,7 +318,11 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(19); +<<<<<<< HEAD auto tmp = (avm_main_mem_op_b * (-avm_main_mem_op_b + FF(1))); +======= + auto tmp = (avm_main_mem_op_d * (-avm_main_mem_op_d + FF(1))); +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<19>(evals) += tmp; } @@ -277,7 +330,11 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(20); +<<<<<<< HEAD auto tmp = (avm_main_mem_op_c * (-avm_main_mem_op_c + FF(1))); +======= + auto tmp = (avm_main_rwa * (-avm_main_rwa + FF(1))); +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<20>(evals) += tmp; } @@ -285,7 +342,11 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(21); +<<<<<<< HEAD auto tmp = (avm_main_rwa * (-avm_main_rwa + FF(1))); +======= + auto tmp = (avm_main_rwb * (-avm_main_rwb + FF(1))); +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<21>(evals) += tmp; } @@ -293,7 +354,11 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(22); +<<<<<<< HEAD auto tmp = (avm_main_rwb * (-avm_main_rwb + FF(1))); +======= + auto tmp = (avm_main_rwc * (-avm_main_rwc + FF(1))); +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<22>(evals) += tmp; } @@ -301,7 +366,11 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(23); +<<<<<<< HEAD auto tmp = (avm_main_rwc * (-avm_main_rwc + FF(1))); +======= + auto tmp = (avm_main_rwd * (-avm_main_rwd + FF(1))); +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<23>(evals) += tmp; } @@ -333,8 +402,12 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(27); +<<<<<<< HEAD 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))); +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<27>(evals) += tmp; } @@ -342,8 +415,12 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(28); +<<<<<<< HEAD auto tmp = ((avm_main_sel_op_div * (-avm_main_op_err + FF(1))) * ((avm_main_ic * avm_main_ib) - avm_main_ia)); +======= + auto tmp = (avm_main_sel_op_eq * (avm_main_w_in_tag - FF(1))); +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<28>(evals) += tmp; } @@ -351,7 +428,12 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(29); +<<<<<<< HEAD auto tmp = (avm_main_sel_op_div * (((avm_main_ib * avm_main_inv) - FF(1)) + avm_main_op_err)); +======= + auto tmp = + ((avm_main_sel_op_div * (-avm_main_op_err + FF(1))) * ((avm_main_ic * avm_main_ib) - avm_main_ia)); +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<29>(evals) += tmp; } @@ -359,7 +441,11 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(30); +<<<<<<< HEAD auto tmp = ((avm_main_sel_op_div * avm_main_op_err) * (-avm_main_inv + FF(1))); +======= + auto tmp = (avm_main_sel_op_div * (((avm_main_ib * avm_main_inv) - FF(1)) + avm_main_op_err)); +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<30>(evals) += tmp; } @@ -367,7 +453,11 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(31); +<<<<<<< HEAD auto tmp = (avm_main_op_err * (avm_main_sel_op_div - FF(1))); +======= + auto tmp = ((avm_main_sel_op_div * avm_main_op_err) * (-avm_main_inv + FF(1))); +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<31>(evals) += tmp; } @@ -375,7 +465,11 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(32); +<<<<<<< HEAD auto tmp = (avm_main_sel_jump * (avm_main_pc_shift - avm_main_ia)); +======= + auto tmp = (avm_main_op_err * (avm_main_sel_op_div - FF(1))); +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<32>(evals) += tmp; } @@ -383,8 +477,12 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(33); +<<<<<<< HEAD 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_jump * (avm_main_pc_shift - avm_main_ia)); +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<33>(evals) += tmp; } @@ -392,7 +490,12 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(34); +<<<<<<< HEAD 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)))); +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<34>(evals) += tmp; } @@ -400,7 +503,11 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(35); +<<<<<<< HEAD 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)); +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<35>(evals) += tmp; } @@ -408,7 +515,11 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(36); +<<<<<<< HEAD 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)); +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<36>(evals) += tmp; } @@ -416,7 +527,11 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(37); +<<<<<<< HEAD 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)); +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<37>(evals) += tmp; } @@ -424,7 +539,11 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(38); +<<<<<<< HEAD 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))); +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<38>(evals) += tmp; } @@ -432,8 +551,12 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(39); +<<<<<<< HEAD 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))); +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<39>(evals) += tmp; } @@ -441,7 +564,12 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(40); +<<<<<<< HEAD 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)))); +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<40>(evals) += tmp; } @@ -449,7 +577,11 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(41); +<<<<<<< HEAD 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)); +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<41>(evals) += tmp; } @@ -457,7 +589,11 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(42); +<<<<<<< HEAD auto tmp = (avm_main_sel_internal_return * avm_main_rwa); +======= + auto tmp = (avm_main_sel_internal_return * (avm_main_pc_shift - avm_main_ia)); +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<42>(evals) += tmp; } @@ -465,7 +601,11 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(43); +<<<<<<< HEAD auto tmp = (avm_main_sel_internal_return * (avm_main_mem_op_a - FF(1))); +======= + auto tmp = (avm_main_sel_internal_return * avm_main_rwa); +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<43>(evals) += tmp; } @@ -473,6 +613,17 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(44); +<<<<<<< HEAD +======= + auto tmp = (avm_main_sel_internal_return * (avm_main_mem_op_a - FF(1))); + tmp *= scaling_factor; + std::get<44>(evals) += tmp; + } + // Contribution 45 + { + Avm_DECLARE_VIEWS(45); + +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) auto tmp = ((((-avm_main_first + FF(1)) * (-avm_main_sel_halt + FF(1))) * ((((((((avm_main_sel_op_add + avm_main_sel_op_sub) + avm_main_sel_op_div) + avm_main_sel_op_mul) + @@ -483,6 +634,7 @@ template class avm_mainImpl { avm_main_sel_op_xor)) * (avm_main_pc_shift - (avm_main_pc + FF(1)))); tmp *= scaling_factor; +<<<<<<< HEAD std::get<44>(evals) += tmp; } // Contribution 45 @@ -494,13 +646,22 @@ template class avm_mainImpl { FF(1)) * (avm_main_internal_return_ptr_shift - avm_main_internal_return_ptr)); tmp *= scaling_factor; +======= +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) std::get<45>(evals) += tmp; } // Contribution 46 { Avm_DECLARE_VIEWS(46); +<<<<<<< HEAD auto tmp = (avm_main_sel_mov * (avm_main_ia - avm_main_ic)); +======= + 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)); +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<46>(evals) += tmp; } @@ -508,7 +669,11 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(47); +<<<<<<< HEAD auto tmp = (avm_main_sel_mov * (avm_main_r_in_tag - avm_main_w_in_tag)); +======= + auto tmp = (avm_main_sel_mov * (avm_main_ia - avm_main_ic)); +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<47>(evals) += tmp; } @@ -516,6 +681,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(48); +<<<<<<< HEAD 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_not) + @@ -523,6 +689,9 @@ template class avm_mainImpl { avm_main_sel_op_lt) + avm_main_sel_op_lte) * (-avm_main_tag_err + FF(1)))); +======= + auto tmp = (avm_main_sel_mov * (avm_main_r_in_tag - avm_main_w_in_tag)); +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<48>(evals) += tmp; } @@ -530,7 +699,14 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(49); +<<<<<<< HEAD auto tmp = (avm_main_bin_op_id - (avm_main_sel_op_or + (avm_main_sel_op_xor * FF(2)))); +======= + 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_not) + + avm_main_sel_op_eq) * + (-avm_main_tag_err + FF(1)))); +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<49>(evals) += tmp; } @@ -538,10 +714,25 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(50); +<<<<<<< HEAD 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<50>(evals) += tmp; } +======= + auto tmp = (avm_main_bin_op_id - (avm_main_sel_op_or + (avm_main_sel_op_xor * FF(2)))); + tmp *= scaling_factor; + std::get<50>(evals) += tmp; + } + // Contribution 51 + { + Avm_DECLARE_VIEWS(51); + + 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<51>(evals) += tmp; + } +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) } }; 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 7ab7905c9b8..833cb65faba 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_mem.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_mem.hpp @@ -12,12 +12,14 @@ template struct Avm_memRow { 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_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_rw{}; FF avm_mem_rw_shift{}; @@ -34,28 +36,28 @@ template struct Avm_memRow { inline std::string get_relation_label_avm_mem(int index) { switch (index) { - case 12: + case 14: return "MEM_LAST_ACCESS_DELIMITER"; - case 13: + case 15: return "MEM_READ_WRITE_VAL_CONSISTENCY"; - case 14: + case 16: return "MEM_READ_WRITE_TAG_CONSISTENCY"; - case 15: + case 17: return "MEM_ZERO_INIT"; - case 16: + case 18: return "MEM_IN_TAG_CONSISTENCY_1"; - case 17: + case 19: return "MEM_IN_TAG_CONSISTENCY_2"; - case 19: + case 21: return "NO_TAG_ERR_WRITE"; - case 26: + case 30: return "MOV_SAME_TAG"; } return std::to_string(index); @@ -65,8 +67,8 @@ 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, 4, 3, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, }; template @@ -136,7 +138,7 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(7); - auto tmp = (avm_mem_ind_op_a * (-avm_mem_ind_op_a + FF(1))); + auto tmp = (avm_mem_op_d * (-avm_mem_op_d + FF(1))); tmp *= scaling_factor; std::get<7>(evals) += tmp; } @@ -144,7 +146,7 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(8); - auto tmp = (avm_mem_ind_op_b * (-avm_mem_ind_op_b + FF(1))); + auto tmp = (avm_mem_ind_op_a * (-avm_mem_ind_op_a + FF(1))); tmp *= scaling_factor; std::get<8>(evals) += tmp; } @@ -152,7 +154,7 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(9); - auto tmp = (avm_mem_ind_op_c * (-avm_mem_ind_op_c + FF(1))); + auto tmp = (avm_mem_ind_op_b * (-avm_mem_ind_op_b + FF(1))); tmp *= scaling_factor; std::get<9>(evals) += tmp; } @@ -160,11 +162,7 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(10); - auto tmp = ((((((avm_mem_op_a + avm_mem_op_b) + avm_mem_op_c) + avm_mem_ind_op_a) + avm_mem_ind_op_b) + - avm_mem_ind_op_c) * - ((((((avm_mem_op_a + avm_mem_op_b) + avm_mem_op_c) + avm_mem_ind_op_a) + avm_mem_ind_op_b) + - avm_mem_ind_op_c) - - FF(1))); + auto tmp = (avm_mem_ind_op_c * (-avm_mem_ind_op_c + FF(1))); tmp *= scaling_factor; std::get<10>(evals) += tmp; } @@ -172,12 +170,7 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(11); - auto tmp = - (avm_mem_sub_clk - - ((((((avm_mem_op_a + avm_mem_op_b) + avm_mem_op_c) + avm_mem_ind_op_a) + avm_mem_ind_op_b) + - avm_mem_ind_op_c) * - (((avm_mem_ind_op_b + avm_mem_op_b) + ((avm_mem_ind_op_c + avm_mem_op_c) * FF(2))) + - (((-((avm_mem_ind_op_a + avm_mem_ind_op_b) + avm_mem_ind_op_c) + FF(1)) + avm_mem_rw) * FF(3))))); + auto tmp = (avm_mem_ind_op_d * (-avm_mem_ind_op_d + FF(1))); tmp *= scaling_factor; std::get<11>(evals) += tmp; } @@ -185,7 +178,15 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(12); - auto tmp = ((-avm_mem_lastAccess + FF(1)) * (avm_mem_addr_shift - avm_mem_addr)); + auto tmp = ((((((((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) * + ((((((((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) - + FF(1))); tmp *= scaling_factor; std::get<12>(evals) += tmp; } @@ -193,8 +194,16 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(13); - auto tmp = - (((-avm_mem_lastAccess + FF(1)) * (-avm_mem_rw_shift + FF(1))) * (avm_mem_val_shift - avm_mem_val)); + auto tmp = (avm_mem_sub_clk - + ((((((((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) * + ((((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<13>(evals) += tmp; } @@ -202,8 +211,7 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(14); - auto tmp = - (((-avm_mem_lastAccess + FF(1)) * (-avm_mem_rw_shift + FF(1))) * (avm_mem_tag_shift - avm_mem_tag)); + auto tmp = ((-avm_mem_lastAccess + FF(1)) * (avm_mem_addr_shift - avm_mem_addr)); tmp *= scaling_factor; std::get<14>(evals) += tmp; } @@ -211,7 +219,8 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(15); - auto tmp = ((avm_mem_lastAccess * (-avm_mem_rw_shift + FF(1))) * avm_mem_val_shift); + 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<15>(evals) += tmp; } @@ -219,8 +228,8 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(16); - auto tmp = ((-avm_mem_rw + FF(1)) * - (((avm_mem_r_in_tag - avm_mem_tag) * (-avm_mem_one_min_inv + FF(1))) - avm_mem_tag_err)); + 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<16>(evals) += tmp; } @@ -228,7 +237,7 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(17); - auto tmp = ((-avm_mem_tag_err + FF(1)) * avm_mem_one_min_inv); + auto tmp = ((avm_mem_lastAccess * (-avm_mem_rw_shift + FF(1))) * avm_mem_val_shift); tmp *= scaling_factor; std::get<17>(evals) += tmp; } @@ -236,7 +245,8 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(18); - auto tmp = (avm_mem_rw * (avm_mem_w_in_tag - avm_mem_tag)); + auto tmp = ((-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<18>(evals) += tmp; } @@ -244,7 +254,7 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(19); - auto tmp = (avm_mem_rw * avm_mem_tag_err); + auto tmp = ((-avm_mem_tag_err + FF(1)) * avm_mem_one_min_inv); tmp *= scaling_factor; std::get<19>(evals) += tmp; } @@ -252,7 +262,7 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(20); - auto tmp = (avm_mem_ind_op_a * (avm_mem_r_in_tag - FF(3))); + auto tmp = (avm_mem_rw * (avm_mem_w_in_tag - avm_mem_tag)); tmp *= scaling_factor; std::get<20>(evals) += tmp; } @@ -260,7 +270,7 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(21); - auto tmp = (avm_mem_ind_op_b * (avm_mem_r_in_tag - FF(3))); + auto tmp = (avm_mem_rw * avm_mem_tag_err); tmp *= scaling_factor; std::get<21>(evals) += tmp; } @@ -268,7 +278,7 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(22); - auto tmp = (avm_mem_ind_op_c * (avm_mem_r_in_tag - FF(3))); + auto tmp = (avm_mem_ind_op_a * (avm_mem_r_in_tag - FF(3))); tmp *= scaling_factor; std::get<22>(evals) += tmp; } @@ -276,7 +286,7 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(23); - auto tmp = (avm_mem_ind_op_a * avm_mem_rw); + auto tmp = (avm_mem_ind_op_b * (avm_mem_r_in_tag - FF(3))); tmp *= scaling_factor; std::get<23>(evals) += tmp; } @@ -284,7 +294,7 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(24); - auto tmp = (avm_mem_ind_op_b * avm_mem_rw); + auto tmp = (avm_mem_ind_op_c * (avm_mem_r_in_tag - FF(3))); tmp *= scaling_factor; std::get<24>(evals) += tmp; } @@ -292,7 +302,7 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(25); - auto tmp = (avm_mem_ind_op_c * avm_mem_rw); + auto tmp = (avm_mem_ind_op_d * (avm_mem_r_in_tag - FF(3))); tmp *= scaling_factor; std::get<25>(evals) += tmp; } @@ -300,10 +310,42 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(26); - auto tmp = (avm_mem_sel_mov * avm_mem_tag_err); + auto tmp = (avm_mem_ind_op_a * avm_mem_rw); tmp *= scaling_factor; std::get<26>(evals) += tmp; } + // Contribution 27 + { + Avm_DECLARE_VIEWS(27); + + auto tmp = (avm_mem_ind_op_b * avm_mem_rw); + tmp *= scaling_factor; + std::get<27>(evals) += tmp; + } + // Contribution 28 + { + Avm_DECLARE_VIEWS(28); + + auto tmp = (avm_mem_ind_op_c * avm_mem_rw); + tmp *= scaling_factor; + std::get<28>(evals) += tmp; + } + // Contribution 29 + { + Avm_DECLARE_VIEWS(29); + + auto tmp = (avm_mem_ind_op_d * avm_mem_rw); + tmp *= scaling_factor; + std::get<29>(evals) += tmp; + } + // Contribution 30 + { + Avm_DECLARE_VIEWS(30); + + auto tmp = (avm_mem_sel_mov * avm_mem_tag_err); + tmp *= scaling_factor; + std::get<30>(evals) += tmp; + } } }; 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 8bebe5f792d..bf017cbff19 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/declare_views.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/declare_views.hpp @@ -87,27 +87,33 @@ [[maybe_unused]] auto avm_main_ia = View(new_term.avm_main_ia); \ [[maybe_unused]] auto avm_main_ib = View(new_term.avm_main_ib); \ [[maybe_unused]] auto avm_main_ic = View(new_term.avm_main_ic); \ + [[maybe_unused]] auto avm_main_id = View(new_term.avm_main_id); \ [[maybe_unused]] auto avm_main_ind_a = View(new_term.avm_main_ind_a); \ [[maybe_unused]] auto avm_main_ind_b = View(new_term.avm_main_ind_b); \ [[maybe_unused]] auto avm_main_ind_c = View(new_term.avm_main_ind_c); \ + [[maybe_unused]] auto avm_main_ind_d = View(new_term.avm_main_ind_d); \ [[maybe_unused]] auto avm_main_ind_op_a = View(new_term.avm_main_ind_op_a); \ [[maybe_unused]] auto avm_main_ind_op_b = View(new_term.avm_main_ind_op_b); \ [[maybe_unused]] auto avm_main_ind_op_c = View(new_term.avm_main_ind_op_c); \ + [[maybe_unused]] auto avm_main_ind_op_d = View(new_term.avm_main_ind_op_d); \ [[maybe_unused]] auto avm_main_internal_return_ptr = View(new_term.avm_main_internal_return_ptr); \ [[maybe_unused]] auto avm_main_inv = View(new_term.avm_main_inv); \ [[maybe_unused]] auto avm_main_last = View(new_term.avm_main_last); \ [[maybe_unused]] auto avm_main_mem_idx_a = View(new_term.avm_main_mem_idx_a); \ [[maybe_unused]] auto avm_main_mem_idx_b = View(new_term.avm_main_mem_idx_b); \ [[maybe_unused]] auto avm_main_mem_idx_c = View(new_term.avm_main_mem_idx_c); \ + [[maybe_unused]] auto avm_main_mem_idx_d = View(new_term.avm_main_mem_idx_d); \ [[maybe_unused]] auto avm_main_mem_op_a = View(new_term.avm_main_mem_op_a); \ [[maybe_unused]] auto avm_main_mem_op_b = View(new_term.avm_main_mem_op_b); \ [[maybe_unused]] auto avm_main_mem_op_c = View(new_term.avm_main_mem_op_c); \ + [[maybe_unused]] auto avm_main_mem_op_d = View(new_term.avm_main_mem_op_d); \ [[maybe_unused]] auto avm_main_op_err = View(new_term.avm_main_op_err); \ [[maybe_unused]] auto avm_main_pc = View(new_term.avm_main_pc); \ [[maybe_unused]] auto avm_main_r_in_tag = View(new_term.avm_main_r_in_tag); \ [[maybe_unused]] auto avm_main_rwa = View(new_term.avm_main_rwa); \ [[maybe_unused]] auto avm_main_rwb = View(new_term.avm_main_rwb); \ [[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_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); \ @@ -133,12 +139,14 @@ [[maybe_unused]] auto avm_mem_ind_op_a = View(new_term.avm_mem_ind_op_a); \ [[maybe_unused]] auto avm_mem_ind_op_b = View(new_term.avm_mem_ind_op_b); \ [[maybe_unused]] auto avm_mem_ind_op_c = View(new_term.avm_mem_ind_op_c); \ + [[maybe_unused]] auto avm_mem_ind_op_d = View(new_term.avm_mem_ind_op_d); \ [[maybe_unused]] auto avm_mem_last = View(new_term.avm_mem_last); \ [[maybe_unused]] auto avm_mem_lastAccess = View(new_term.avm_mem_lastAccess); \ [[maybe_unused]] auto avm_mem_one_min_inv = View(new_term.avm_mem_one_min_inv); \ [[maybe_unused]] auto avm_mem_op_a = View(new_term.avm_mem_op_a); \ [[maybe_unused]] auto avm_mem_op_b = View(new_term.avm_mem_op_b); \ [[maybe_unused]] auto avm_mem_op_c = View(new_term.avm_mem_op_c); \ + [[maybe_unused]] auto avm_mem_op_d = View(new_term.avm_mem_op_d); \ [[maybe_unused]] auto avm_mem_r_in_tag = View(new_term.avm_mem_r_in_tag); \ [[maybe_unused]] auto avm_mem_rw = View(new_term.avm_mem_rw); \ [[maybe_unused]] auto avm_mem_sel_mov = View(new_term.avm_mem_sel_mov); \ @@ -152,9 +160,11 @@ [[maybe_unused]] auto perm_main_mem_a = View(new_term.perm_main_mem_a); \ [[maybe_unused]] auto perm_main_mem_b = View(new_term.perm_main_mem_b); \ [[maybe_unused]] auto perm_main_mem_c = View(new_term.perm_main_mem_c); \ + [[maybe_unused]] auto perm_main_mem_d = View(new_term.perm_main_mem_d); \ [[maybe_unused]] auto perm_main_mem_ind_a = View(new_term.perm_main_mem_ind_a); \ [[maybe_unused]] auto perm_main_mem_ind_b = View(new_term.perm_main_mem_ind_b); \ [[maybe_unused]] auto perm_main_mem_ind_c = View(new_term.perm_main_mem_ind_c); \ + [[maybe_unused]] auto perm_main_mem_ind_d = View(new_term.perm_main_mem_ind_d); \ [[maybe_unused]] auto lookup_byte_lengths = View(new_term.lookup_byte_lengths); \ [[maybe_unused]] auto lookup_byte_operations = View(new_term.lookup_byte_operations); \ [[maybe_unused]] auto incl_main_tag_err = View(new_term.incl_main_tag_err); \ 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 new file mode 100644 index 00000000000..309221775d6 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_d.hpp @@ -0,0 +1,110 @@ + + +#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 = 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_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_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_mem_clk, + 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_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_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_mem_clk, + 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_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_d.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_d.hpp new file mode 100644 index 00000000000..4b005cb3495 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_mem_ind_d.hpp @@ -0,0 +1,98 @@ + + +#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 = 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_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_ind_d, + in.avm_main_mem_idx_d, + in.avm_mem_clk, + 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_ind_d, + in.avm_main_mem_idx_d, + in.avm_mem_clk, + 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 diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.hpp index 14c1d8accc5..1b7f461179e 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.hpp @@ -11,12 +11,15 @@ class AvmMemTraceBuilder { static const uint32_t SUB_CLK_IND_LOAD_A = 0; static const uint32_t SUB_CLK_IND_LOAD_B = 1; static const uint32_t SUB_CLK_IND_LOAD_C = 2; - static const uint32_t SUB_CLK_LOAD_A = 3; - static const uint32_t SUB_CLK_LOAD_B = 4; - static const uint32_t SUB_CLK_LOAD_C = 5; - static const uint32_t SUB_CLK_STORE_A = 6; - static const uint32_t SUB_CLK_STORE_B = 7; - static const uint32_t SUB_CLK_STORE_C = 8; + static const uint32_t SUB_CLK_IND_LOAD_D = 3; + static const uint32_t SUB_CLK_LOAD_A = 4; + static const uint32_t SUB_CLK_LOAD_B = 5; + static const uint32_t SUB_CLK_LOAD_C = 6; + static const uint32_t SUB_CLK_LOAD_D = 7; + static const uint32_t SUB_CLK_STORE_A = 8; + static const uint32_t SUB_CLK_STORE_B = 9; + static const uint32_t SUB_CLK_STORE_C = 10; + static const uint32_t SUB_CLK_STORE_D = 11; // Keeps track of the number of times a mem tag err should appear in the trace // clk -> count 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 4a31987c2b1..5615c406d23 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp @@ -1284,6 +1284,10 @@ std::vector AvmTraceBuilder::finalize() case AvmMemTraceBuilder::SUB_CLK_STORE_C: dest.avm_mem_op_c = 1; break; + case AvmMemTraceBuilder::SUB_CLK_LOAD_D: + case AvmMemTraceBuilder::SUB_CLK_STORE_D: + dest.avm_mem_op_d = 1; + break; case AvmMemTraceBuilder::SUB_CLK_IND_LOAD_A: dest.avm_mem_ind_op_a = 1; break; @@ -1293,6 +1297,9 @@ std::vector AvmTraceBuilder::finalize() case AvmMemTraceBuilder::SUB_CLK_IND_LOAD_C: dest.avm_mem_ind_op_c = 1; break; + case AvmMemTraceBuilder::SUB_CLK_IND_LOAD_D: + dest.avm_mem_ind_op_d = 1; + break; default: break; } 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 42e931cbdf3..9939736ec3c 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp @@ -41,9 +41,11 @@ #include "barretenberg/relations/generated/avm/perm_main_mem_a.hpp" #include "barretenberg/relations/generated/avm/perm_main_mem_b.hpp" #include "barretenberg/relations/generated/avm/perm_main_mem_c.hpp" +#include "barretenberg/relations/generated/avm/perm_main_mem_d.hpp" #include "barretenberg/relations/generated/avm/perm_main_mem_ind_a.hpp" #include "barretenberg/relations/generated/avm/perm_main_mem_ind_b.hpp" #include "barretenberg/relations/generated/avm/perm_main_mem_ind_c.hpp" +#include "barretenberg/relations/generated/avm/perm_main_mem_ind_d.hpp" #include "barretenberg/vm/generated/avm_flavor.hpp" namespace bb { @@ -134,27 +136,33 @@ template struct AvmFullRow { FF avm_main_ia{}; FF avm_main_ib{}; FF avm_main_ic{}; + FF avm_main_id{}; FF avm_main_ind_a{}; FF avm_main_ind_b{}; FF avm_main_ind_c{}; + FF avm_main_ind_d{}; FF avm_main_ind_op_a{}; FF avm_main_ind_op_b{}; FF avm_main_ind_op_c{}; + FF avm_main_ind_op_d{}; FF avm_main_internal_return_ptr{}; FF avm_main_inv{}; FF avm_main_last{}; FF avm_main_mem_idx_a{}; FF avm_main_mem_idx_b{}; FF avm_main_mem_idx_c{}; + FF avm_main_mem_idx_d{}; FF avm_main_mem_op_a{}; FF avm_main_mem_op_b{}; FF avm_main_mem_op_c{}; + FF avm_main_mem_op_d{}; FF avm_main_op_err{}; FF avm_main_pc{}; FF avm_main_r_in_tag{}; FF avm_main_rwa{}; FF avm_main_rwb{}; FF avm_main_rwc{}; + FF avm_main_rwd{}; FF avm_main_sel_halt{}; FF avm_main_sel_internal_call{}; FF avm_main_sel_internal_return{}; @@ -180,12 +188,14 @@ template struct AvmFullRow { 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_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_rw{}; FF avm_mem_sel_mov{}; @@ -199,9 +209,11 @@ template struct AvmFullRow { FF perm_main_mem_a{}; FF perm_main_mem_b{}; FF perm_main_mem_c{}; + FF perm_main_mem_d{}; FF perm_main_mem_ind_a{}; FF perm_main_mem_ind_b{}; FF perm_main_mem_ind_c{}; + FF perm_main_mem_ind_d{}; FF lookup_byte_lengths{}; FF lookup_byte_operations{}; FF incl_main_tag_err{}; @@ -285,8 +297,13 @@ class AvmCircuitBuilder { using Polynomial = Flavor::Polynomial; using ProverPolynomials = Flavor::ProverPolynomials; +<<<<<<< HEAD static constexpr size_t num_fixed_columns = 224; static constexpr size_t num_polys = 195; +======= + static constexpr size_t num_fixed_columns = 169; + static constexpr size_t num_polys = 150; +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) std::vector rows; void set_trace(std::vector&& trace) { rows = std::move(trace); } @@ -387,27 +404,33 @@ class AvmCircuitBuilder { polys.avm_main_ia[i] = rows[i].avm_main_ia; polys.avm_main_ib[i] = rows[i].avm_main_ib; polys.avm_main_ic[i] = rows[i].avm_main_ic; + polys.avm_main_id[i] = rows[i].avm_main_id; polys.avm_main_ind_a[i] = rows[i].avm_main_ind_a; polys.avm_main_ind_b[i] = rows[i].avm_main_ind_b; polys.avm_main_ind_c[i] = rows[i].avm_main_ind_c; + polys.avm_main_ind_d[i] = rows[i].avm_main_ind_d; polys.avm_main_ind_op_a[i] = rows[i].avm_main_ind_op_a; polys.avm_main_ind_op_b[i] = rows[i].avm_main_ind_op_b; polys.avm_main_ind_op_c[i] = rows[i].avm_main_ind_op_c; + polys.avm_main_ind_op_d[i] = rows[i].avm_main_ind_op_d; polys.avm_main_internal_return_ptr[i] = rows[i].avm_main_internal_return_ptr; polys.avm_main_inv[i] = rows[i].avm_main_inv; polys.avm_main_last[i] = rows[i].avm_main_last; polys.avm_main_mem_idx_a[i] = rows[i].avm_main_mem_idx_a; polys.avm_main_mem_idx_b[i] = rows[i].avm_main_mem_idx_b; polys.avm_main_mem_idx_c[i] = rows[i].avm_main_mem_idx_c; + polys.avm_main_mem_idx_d[i] = rows[i].avm_main_mem_idx_d; polys.avm_main_mem_op_a[i] = rows[i].avm_main_mem_op_a; polys.avm_main_mem_op_b[i] = rows[i].avm_main_mem_op_b; polys.avm_main_mem_op_c[i] = rows[i].avm_main_mem_op_c; + polys.avm_main_mem_op_d[i] = rows[i].avm_main_mem_op_d; polys.avm_main_op_err[i] = rows[i].avm_main_op_err; polys.avm_main_pc[i] = rows[i].avm_main_pc; polys.avm_main_r_in_tag[i] = rows[i].avm_main_r_in_tag; polys.avm_main_rwa[i] = rows[i].avm_main_rwa; polys.avm_main_rwb[i] = rows[i].avm_main_rwb; polys.avm_main_rwc[i] = rows[i].avm_main_rwc; + polys.avm_main_rwd[i] = rows[i].avm_main_rwd; 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; @@ -433,12 +456,14 @@ class AvmCircuitBuilder { polys.avm_mem_ind_op_a[i] = rows[i].avm_mem_ind_op_a; polys.avm_mem_ind_op_b[i] = rows[i].avm_mem_ind_op_b; polys.avm_mem_ind_op_c[i] = rows[i].avm_mem_ind_op_c; + polys.avm_mem_ind_op_d[i] = rows[i].avm_mem_ind_op_d; polys.avm_mem_last[i] = rows[i].avm_mem_last; polys.avm_mem_lastAccess[i] = rows[i].avm_mem_lastAccess; polys.avm_mem_one_min_inv[i] = rows[i].avm_mem_one_min_inv; polys.avm_mem_op_a[i] = rows[i].avm_mem_op_a; polys.avm_mem_op_b[i] = rows[i].avm_mem_op_b; polys.avm_mem_op_c[i] = rows[i].avm_mem_op_c; + polys.avm_mem_op_d[i] = rows[i].avm_mem_op_d; polys.avm_mem_r_in_tag[i] = rows[i].avm_mem_r_in_tag; polys.avm_mem_rw[i] = rows[i].avm_mem_rw; polys.avm_mem_sel_mov[i] = rows[i].avm_mem_sel_mov; @@ -447,6 +472,27 @@ class AvmCircuitBuilder { polys.avm_mem_tag_err[i] = rows[i].avm_mem_tag_err; polys.avm_mem_val[i] = rows[i].avm_mem_val; polys.avm_mem_w_in_tag[i] = rows[i].avm_mem_w_in_tag; +<<<<<<< HEAD +======= + polys.perm_main_alu[i] = rows[i].perm_main_alu; +<<<<<<< HEAD + +======= + polys.perm_main_bin[i] = rows[i].perm_main_bin; + polys.perm_main_mem_a[i] = rows[i].perm_main_mem_a; + polys.perm_main_mem_b[i] = rows[i].perm_main_mem_b; + polys.perm_main_mem_c[i] = rows[i].perm_main_mem_c; + polys.perm_main_mem_d[i] = rows[i].perm_main_mem_d; + polys.perm_main_mem_ind_a[i] = rows[i].perm_main_mem_ind_a; + polys.perm_main_mem_ind_b[i] = rows[i].perm_main_mem_ind_b; + polys.perm_main_mem_ind_c[i] = rows[i].perm_main_mem_ind_c; + polys.perm_main_mem_ind_d[i] = rows[i].perm_main_mem_ind_d; + polys.lookup_byte_lengths[i] = rows[i].lookup_byte_lengths; + polys.lookup_byte_operations[i] = rows[i].lookup_byte_operations; + polys.incl_main_tag_err[i] = rows[i].incl_main_tag_err; + polys.incl_mem_tag_err[i] = rows[i].incl_mem_tag_err; +>>>>>>> 7c841655b (5557: Add an additional intermediate register id) +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) polys.lookup_byte_lengths_counts[i] = rows[i].lookup_byte_lengths_counts; polys.lookup_byte_operations_counts[i] = rows[i].lookup_byte_operations_counts; polys.incl_main_tag_err_counts[i] = rows[i].incl_main_tag_err_counts; @@ -602,6 +648,9 @@ class AvmCircuitBuilder { if (!evaluate_logderivative.template operator()>("PERM_MAIN_MEM_C")) { return false; } + if (!evaluate_logderivative.template operator()>("PERM_MAIN_MEM_D")) { + return false; + } if (!evaluate_logderivative.template operator()>("PERM_MAIN_MEM_IND_A")) { return false; } @@ -611,6 +660,9 @@ class AvmCircuitBuilder { if (!evaluate_logderivative.template operator()>("PERM_MAIN_MEM_IND_C")) { return false; } + if (!evaluate_logderivative.template operator()>("PERM_MAIN_MEM_IND_D")) { + return false; + } if (!evaluate_logderivative.template operator()>("LOOKUP_BYTE_LENGTHS")) { return false; } diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp index 353ee278c6f..80b3bbba5fc 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp @@ -43,9 +43,11 @@ #include "barretenberg/relations/generated/avm/perm_main_mem_a.hpp" #include "barretenberg/relations/generated/avm/perm_main_mem_b.hpp" #include "barretenberg/relations/generated/avm/perm_main_mem_c.hpp" +#include "barretenberg/relations/generated/avm/perm_main_mem_d.hpp" #include "barretenberg/relations/generated/avm/perm_main_mem_ind_a.hpp" #include "barretenberg/relations/generated/avm/perm_main_mem_ind_b.hpp" #include "barretenberg/relations/generated/avm/perm_main_mem_ind_c.hpp" +#include "barretenberg/relations/generated/avm/perm_main_mem_ind_d.hpp" #include "barretenberg/transcript/transcript.hpp" namespace bb { @@ -67,11 +69,19 @@ class AvmFlavor { using RelationSeparator = FF; static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 2; +<<<<<<< HEAD static constexpr size_t NUM_WITNESS_ENTITIES = 193; 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 = 224; +======= + static constexpr size_t NUM_WITNESS_ENTITIES = 148; + 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 = 169; +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) using GrandProductRelations = std::tuple, perm_main_bin_relation, @@ -112,9 +122,11 @@ class AvmFlavor { perm_main_mem_a_relation, perm_main_mem_b_relation, perm_main_mem_c_relation, + perm_main_mem_d_relation, perm_main_mem_ind_a_relation, perm_main_mem_ind_b_relation, perm_main_mem_ind_c_relation, +<<<<<<< HEAD lookup_byte_lengths_relation, lookup_byte_operations_relation, incl_main_tag_err_relation, @@ -136,6 +148,16 @@ class AvmFlavor { lookup_u16_12_relation, lookup_u16_13_relation, lookup_u16_14_relation>; +======= +<<<<<<< HEAD + incl_main_tag_err_relation, + incl_mem_tag_err_relation, + lookup_byte_lengths_relation, + lookup_byte_operations_relation>; +======= + perm_main_mem_ind_d_relation>; +>>>>>>> 7c841655b (5557: Add an additional intermediate register id) +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = compute_max_partial_relation_length(); @@ -252,27 +274,33 @@ class AvmFlavor { avm_main_ia, avm_main_ib, avm_main_ic, + avm_main_id, avm_main_ind_a, avm_main_ind_b, avm_main_ind_c, + avm_main_ind_d, avm_main_ind_op_a, avm_main_ind_op_b, avm_main_ind_op_c, + avm_main_ind_op_d, avm_main_internal_return_ptr, avm_main_inv, avm_main_last, avm_main_mem_idx_a, avm_main_mem_idx_b, avm_main_mem_idx_c, + avm_main_mem_idx_d, avm_main_mem_op_a, avm_main_mem_op_b, avm_main_mem_op_c, + avm_main_mem_op_d, avm_main_op_err, avm_main_pc, avm_main_r_in_tag, avm_main_rwa, avm_main_rwb, avm_main_rwc, + avm_main_rwd, avm_main_sel_halt, avm_main_sel_internal_call, avm_main_sel_internal_return, @@ -298,12 +326,14 @@ class AvmFlavor { avm_mem_ind_op_a, avm_mem_ind_op_b, avm_mem_ind_op_c, + avm_mem_ind_op_d, avm_mem_last, avm_mem_lastAccess, avm_mem_one_min_inv, avm_mem_op_a, avm_mem_op_b, avm_mem_op_c, + avm_mem_op_d, avm_mem_r_in_tag, avm_mem_rw, avm_mem_sel_mov, @@ -317,9 +347,11 @@ class AvmFlavor { perm_main_mem_a, perm_main_mem_b, perm_main_mem_c, + perm_main_mem_d, perm_main_mem_ind_a, perm_main_mem_ind_b, perm_main_mem_ind_c, + perm_main_mem_ind_d, lookup_byte_lengths, lookup_byte_operations, incl_main_tag_err, @@ -448,27 +480,33 @@ class AvmFlavor { avm_main_ia, avm_main_ib, avm_main_ic, + avm_main_id, avm_main_ind_a, avm_main_ind_b, avm_main_ind_c, + avm_main_ind_d, avm_main_ind_op_a, avm_main_ind_op_b, avm_main_ind_op_c, + avm_main_ind_op_d, avm_main_internal_return_ptr, avm_main_inv, avm_main_last, avm_main_mem_idx_a, avm_main_mem_idx_b, avm_main_mem_idx_c, + avm_main_mem_idx_d, avm_main_mem_op_a, avm_main_mem_op_b, avm_main_mem_op_c, + avm_main_mem_op_d, avm_main_op_err, avm_main_pc, avm_main_r_in_tag, avm_main_rwa, avm_main_rwb, avm_main_rwc, + avm_main_rwd, avm_main_sel_halt, avm_main_sel_internal_call, avm_main_sel_internal_return, @@ -494,12 +532,14 @@ class AvmFlavor { avm_mem_ind_op_a, avm_mem_ind_op_b, avm_mem_ind_op_c, + avm_mem_ind_op_d, avm_mem_last, avm_mem_lastAccess, avm_mem_one_min_inv, avm_mem_op_a, avm_mem_op_b, avm_mem_op_c, + avm_mem_op_d, avm_mem_r_in_tag, avm_mem_rw, avm_mem_sel_mov, @@ -513,9 +553,11 @@ class AvmFlavor { perm_main_mem_a, perm_main_mem_b, perm_main_mem_c, + perm_main_mem_d, perm_main_mem_ind_a, perm_main_mem_ind_b, perm_main_mem_ind_c, + perm_main_mem_ind_d, lookup_byte_lengths, lookup_byte_operations, incl_main_tag_err, @@ -649,27 +691,33 @@ class AvmFlavor { avm_main_ia, avm_main_ib, avm_main_ic, + avm_main_id, avm_main_ind_a, avm_main_ind_b, avm_main_ind_c, + avm_main_ind_d, avm_main_ind_op_a, avm_main_ind_op_b, avm_main_ind_op_c, + avm_main_ind_op_d, avm_main_internal_return_ptr, avm_main_inv, avm_main_last, avm_main_mem_idx_a, avm_main_mem_idx_b, avm_main_mem_idx_c, + avm_main_mem_idx_d, avm_main_mem_op_a, avm_main_mem_op_b, avm_main_mem_op_c, + avm_main_mem_op_d, avm_main_op_err, avm_main_pc, avm_main_r_in_tag, avm_main_rwa, avm_main_rwb, avm_main_rwc, + avm_main_rwd, avm_main_sel_halt, avm_main_sel_internal_call, avm_main_sel_internal_return, @@ -695,12 +743,14 @@ class AvmFlavor { avm_mem_ind_op_a, avm_mem_ind_op_b, avm_mem_ind_op_c, + avm_mem_ind_op_d, avm_mem_last, avm_mem_lastAccess, avm_mem_one_min_inv, avm_mem_op_a, avm_mem_op_b, avm_mem_op_c, + avm_mem_op_d, avm_mem_r_in_tag, avm_mem_rw, avm_mem_sel_mov, @@ -714,9 +764,11 @@ class AvmFlavor { perm_main_mem_a, perm_main_mem_b, perm_main_mem_c, + perm_main_mem_d, perm_main_mem_ind_a, perm_main_mem_ind_b, perm_main_mem_ind_c, + perm_main_mem_ind_d, lookup_byte_lengths, lookup_byte_operations, incl_main_tag_err, @@ -876,27 +928,33 @@ class AvmFlavor { avm_main_ia, avm_main_ib, avm_main_ic, + avm_main_id, avm_main_ind_a, avm_main_ind_b, avm_main_ind_c, + avm_main_ind_d, avm_main_ind_op_a, avm_main_ind_op_b, avm_main_ind_op_c, + avm_main_ind_op_d, avm_main_internal_return_ptr, avm_main_inv, avm_main_last, avm_main_mem_idx_a, avm_main_mem_idx_b, avm_main_mem_idx_c, + avm_main_mem_idx_d, avm_main_mem_op_a, avm_main_mem_op_b, avm_main_mem_op_c, + avm_main_mem_op_d, avm_main_op_err, avm_main_pc, avm_main_r_in_tag, avm_main_rwa, avm_main_rwb, avm_main_rwc, + avm_main_rwd, avm_main_sel_halt, avm_main_sel_internal_call, avm_main_sel_internal_return, @@ -922,12 +980,14 @@ class AvmFlavor { avm_mem_ind_op_a, avm_mem_ind_op_b, avm_mem_ind_op_c, + avm_mem_ind_op_d, avm_mem_last, avm_mem_lastAccess, avm_mem_one_min_inv, avm_mem_op_a, avm_mem_op_b, avm_mem_op_c, + avm_mem_op_d, avm_mem_r_in_tag, avm_mem_rw, avm_mem_sel_mov, @@ -941,9 +1001,11 @@ class AvmFlavor { perm_main_mem_a, perm_main_mem_b, perm_main_mem_c, + perm_main_mem_d, perm_main_mem_ind_a, perm_main_mem_ind_b, perm_main_mem_ind_c, + perm_main_mem_ind_d, lookup_byte_lengths, lookup_byte_operations, incl_main_tag_err, @@ -1103,27 +1165,33 @@ class AvmFlavor { avm_main_ia, avm_main_ib, avm_main_ic, + avm_main_id, avm_main_ind_a, avm_main_ind_b, avm_main_ind_c, + avm_main_ind_d, avm_main_ind_op_a, avm_main_ind_op_b, avm_main_ind_op_c, + avm_main_ind_op_d, avm_main_internal_return_ptr, avm_main_inv, avm_main_last, avm_main_mem_idx_a, avm_main_mem_idx_b, avm_main_mem_idx_c, + avm_main_mem_idx_d, avm_main_mem_op_a, avm_main_mem_op_b, avm_main_mem_op_c, + avm_main_mem_op_d, avm_main_op_err, avm_main_pc, avm_main_r_in_tag, avm_main_rwa, avm_main_rwb, avm_main_rwc, + avm_main_rwd, avm_main_sel_halt, avm_main_sel_internal_call, avm_main_sel_internal_return, @@ -1149,12 +1217,14 @@ class AvmFlavor { avm_mem_ind_op_a, avm_mem_ind_op_b, avm_mem_ind_op_c, + avm_mem_ind_op_d, avm_mem_last, avm_mem_lastAccess, avm_mem_one_min_inv, avm_mem_op_a, avm_mem_op_b, avm_mem_op_c, + avm_mem_op_d, avm_mem_r_in_tag, avm_mem_rw, avm_mem_sel_mov, @@ -1168,9 +1238,11 @@ class AvmFlavor { perm_main_mem_a, perm_main_mem_b, perm_main_mem_c, + perm_main_mem_d, perm_main_mem_ind_a, perm_main_mem_ind_b, perm_main_mem_ind_c, + perm_main_mem_ind_d, lookup_byte_lengths, lookup_byte_operations, incl_main_tag_err, @@ -1503,27 +1575,33 @@ class AvmFlavor { Base::avm_main_ia = "AVM_MAIN_IA"; Base::avm_main_ib = "AVM_MAIN_IB"; Base::avm_main_ic = "AVM_MAIN_IC"; + Base::avm_main_id = "AVM_MAIN_ID"; Base::avm_main_ind_a = "AVM_MAIN_IND_A"; Base::avm_main_ind_b = "AVM_MAIN_IND_B"; Base::avm_main_ind_c = "AVM_MAIN_IND_C"; + Base::avm_main_ind_d = "AVM_MAIN_IND_D"; Base::avm_main_ind_op_a = "AVM_MAIN_IND_OP_A"; Base::avm_main_ind_op_b = "AVM_MAIN_IND_OP_B"; Base::avm_main_ind_op_c = "AVM_MAIN_IND_OP_C"; + Base::avm_main_ind_op_d = "AVM_MAIN_IND_OP_D"; Base::avm_main_internal_return_ptr = "AVM_MAIN_INTERNAL_RETURN_PTR"; Base::avm_main_inv = "AVM_MAIN_INV"; Base::avm_main_last = "AVM_MAIN_LAST"; Base::avm_main_mem_idx_a = "AVM_MAIN_MEM_IDX_A"; Base::avm_main_mem_idx_b = "AVM_MAIN_MEM_IDX_B"; Base::avm_main_mem_idx_c = "AVM_MAIN_MEM_IDX_C"; + Base::avm_main_mem_idx_d = "AVM_MAIN_MEM_IDX_D"; Base::avm_main_mem_op_a = "AVM_MAIN_MEM_OP_A"; Base::avm_main_mem_op_b = "AVM_MAIN_MEM_OP_B"; Base::avm_main_mem_op_c = "AVM_MAIN_MEM_OP_C"; + Base::avm_main_mem_op_d = "AVM_MAIN_MEM_OP_D"; Base::avm_main_op_err = "AVM_MAIN_OP_ERR"; Base::avm_main_pc = "AVM_MAIN_PC"; Base::avm_main_r_in_tag = "AVM_MAIN_R_IN_TAG"; Base::avm_main_rwa = "AVM_MAIN_RWA"; Base::avm_main_rwb = "AVM_MAIN_RWB"; Base::avm_main_rwc = "AVM_MAIN_RWC"; + Base::avm_main_rwd = "AVM_MAIN_RWD"; 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"; @@ -1549,12 +1627,14 @@ class AvmFlavor { Base::avm_mem_ind_op_a = "AVM_MEM_IND_OP_A"; Base::avm_mem_ind_op_b = "AVM_MEM_IND_OP_B"; Base::avm_mem_ind_op_c = "AVM_MEM_IND_OP_C"; + Base::avm_mem_ind_op_d = "AVM_MEM_IND_OP_D"; Base::avm_mem_last = "AVM_MEM_LAST"; Base::avm_mem_lastAccess = "AVM_MEM_LASTACCESS"; Base::avm_mem_one_min_inv = "AVM_MEM_ONE_MIN_INV"; Base::avm_mem_op_a = "AVM_MEM_OP_A"; Base::avm_mem_op_b = "AVM_MEM_OP_B"; Base::avm_mem_op_c = "AVM_MEM_OP_C"; + Base::avm_mem_op_d = "AVM_MEM_OP_D"; Base::avm_mem_r_in_tag = "AVM_MEM_R_IN_TAG"; Base::avm_mem_rw = "AVM_MEM_RW"; Base::avm_mem_sel_mov = "AVM_MEM_SEL_MOV"; @@ -1568,9 +1648,11 @@ class AvmFlavor { Base::perm_main_mem_a = "PERM_MAIN_MEM_A"; Base::perm_main_mem_b = "PERM_MAIN_MEM_B"; Base::perm_main_mem_c = "PERM_MAIN_MEM_C"; + Base::perm_main_mem_d = "PERM_MAIN_MEM_D"; Base::perm_main_mem_ind_a = "PERM_MAIN_MEM_IND_A"; Base::perm_main_mem_ind_b = "PERM_MAIN_MEM_IND_B"; Base::perm_main_mem_ind_c = "PERM_MAIN_MEM_IND_C"; + Base::perm_main_mem_ind_d = "PERM_MAIN_MEM_IND_D"; Base::lookup_byte_lengths = "LOOKUP_BYTE_LENGTHS"; Base::lookup_byte_operations = "LOOKUP_BYTE_OPERATIONS"; Base::incl_main_tag_err = "INCL_MAIN_TAG_ERR"; @@ -1715,27 +1797,33 @@ class AvmFlavor { Commitment avm_main_ia; Commitment avm_main_ib; Commitment avm_main_ic; + Commitment avm_main_id; Commitment avm_main_ind_a; Commitment avm_main_ind_b; Commitment avm_main_ind_c; + Commitment avm_main_ind_d; Commitment avm_main_ind_op_a; Commitment avm_main_ind_op_b; Commitment avm_main_ind_op_c; + Commitment avm_main_ind_op_d; Commitment avm_main_internal_return_ptr; Commitment avm_main_inv; Commitment avm_main_last; Commitment avm_main_mem_idx_a; Commitment avm_main_mem_idx_b; Commitment avm_main_mem_idx_c; + Commitment avm_main_mem_idx_d; Commitment avm_main_mem_op_a; Commitment avm_main_mem_op_b; Commitment avm_main_mem_op_c; + Commitment avm_main_mem_op_d; Commitment avm_main_op_err; Commitment avm_main_pc; Commitment avm_main_r_in_tag; Commitment avm_main_rwa; Commitment avm_main_rwb; Commitment avm_main_rwc; + Commitment avm_main_rwd; Commitment avm_main_sel_halt; Commitment avm_main_sel_internal_call; Commitment avm_main_sel_internal_return; @@ -1761,12 +1849,14 @@ class AvmFlavor { Commitment avm_mem_ind_op_a; Commitment avm_mem_ind_op_b; Commitment avm_mem_ind_op_c; + Commitment avm_mem_ind_op_d; Commitment avm_mem_last; Commitment avm_mem_lastAccess; Commitment avm_mem_one_min_inv; Commitment avm_mem_op_a; Commitment avm_mem_op_b; Commitment avm_mem_op_c; + Commitment avm_mem_op_d; Commitment avm_mem_r_in_tag; Commitment avm_mem_rw; Commitment avm_mem_sel_mov; @@ -1780,9 +1870,18 @@ class AvmFlavor { Commitment perm_main_mem_a; Commitment perm_main_mem_b; Commitment perm_main_mem_c; + Commitment perm_main_mem_d; Commitment perm_main_mem_ind_a; Commitment perm_main_mem_ind_b; Commitment perm_main_mem_ind_c; +<<<<<<< HEAD +======= +<<<<<<< HEAD + // Lookup inverses +======= + Commitment perm_main_mem_ind_d; +>>>>>>> 7c841655b (5557: Add an additional intermediate register id) +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) Commitment lookup_byte_lengths; Commitment lookup_byte_operations; Commitment incl_main_tag_err; @@ -1928,27 +2027,33 @@ class AvmFlavor { avm_main_ia = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_ib = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_ic = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_id = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_ind_a = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_ind_b = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_ind_c = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_ind_d = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_ind_op_a = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_ind_op_b = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_ind_op_c = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_ind_op_d = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_internal_return_ptr = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_inv = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_last = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_mem_idx_a = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_mem_idx_b = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_mem_idx_c = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_mem_idx_d = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_mem_op_a = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_mem_op_b = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_mem_op_c = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_mem_op_d = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_op_err = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_pc = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_r_in_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_rwa = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_rwb = deserialize_from_buffer(Transcript::proof_data, num_frs_read); 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_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); @@ -1974,12 +2079,14 @@ class AvmFlavor { avm_mem_ind_op_a = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_mem_ind_op_b = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_mem_ind_op_c = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_mem_ind_op_d = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_mem_last = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_mem_lastAccess = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_mem_one_min_inv = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_mem_op_a = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_mem_op_b = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_mem_op_c = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_mem_op_d = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_mem_r_in_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_mem_rw = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_mem_sel_mov = deserialize_from_buffer(Transcript::proof_data, num_frs_read); @@ -1993,9 +2100,11 @@ class AvmFlavor { perm_main_mem_a = deserialize_from_buffer(Transcript::proof_data, num_frs_read); perm_main_mem_b = deserialize_from_buffer(Transcript::proof_data, num_frs_read); perm_main_mem_c = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + perm_main_mem_d = deserialize_from_buffer(Transcript::proof_data, num_frs_read); perm_main_mem_ind_a = deserialize_from_buffer(Transcript::proof_data, num_frs_read); perm_main_mem_ind_b = deserialize_from_buffer(Transcript::proof_data, num_frs_read); perm_main_mem_ind_c = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + perm_main_mem_ind_d = deserialize_from_buffer(Transcript::proof_data, num_frs_read); lookup_byte_lengths = deserialize_from_buffer(Transcript::proof_data, num_frs_read); lookup_byte_operations = deserialize_from_buffer(Transcript::proof_data, num_frs_read); incl_main_tag_err = deserialize_from_buffer(Transcript::proof_data, num_frs_read); @@ -2144,27 +2253,33 @@ class AvmFlavor { serialize_to_buffer(avm_main_ia, Transcript::proof_data); serialize_to_buffer(avm_main_ib, Transcript::proof_data); serialize_to_buffer(avm_main_ic, Transcript::proof_data); + serialize_to_buffer(avm_main_id, Transcript::proof_data); serialize_to_buffer(avm_main_ind_a, Transcript::proof_data); serialize_to_buffer(avm_main_ind_b, Transcript::proof_data); serialize_to_buffer(avm_main_ind_c, Transcript::proof_data); + serialize_to_buffer(avm_main_ind_d, Transcript::proof_data); serialize_to_buffer(avm_main_ind_op_a, Transcript::proof_data); serialize_to_buffer(avm_main_ind_op_b, Transcript::proof_data); serialize_to_buffer(avm_main_ind_op_c, Transcript::proof_data); + serialize_to_buffer(avm_main_ind_op_d, Transcript::proof_data); serialize_to_buffer(avm_main_internal_return_ptr, Transcript::proof_data); serialize_to_buffer(avm_main_inv, Transcript::proof_data); serialize_to_buffer(avm_main_last, Transcript::proof_data); serialize_to_buffer(avm_main_mem_idx_a, Transcript::proof_data); serialize_to_buffer(avm_main_mem_idx_b, Transcript::proof_data); serialize_to_buffer(avm_main_mem_idx_c, Transcript::proof_data); + serialize_to_buffer(avm_main_mem_idx_d, Transcript::proof_data); serialize_to_buffer(avm_main_mem_op_a, Transcript::proof_data); serialize_to_buffer(avm_main_mem_op_b, Transcript::proof_data); serialize_to_buffer(avm_main_mem_op_c, Transcript::proof_data); + serialize_to_buffer(avm_main_mem_op_d, Transcript::proof_data); serialize_to_buffer(avm_main_op_err, Transcript::proof_data); serialize_to_buffer(avm_main_pc, Transcript::proof_data); serialize_to_buffer(avm_main_r_in_tag, Transcript::proof_data); serialize_to_buffer(avm_main_rwa, Transcript::proof_data); serialize_to_buffer(avm_main_rwb, Transcript::proof_data); serialize_to_buffer(avm_main_rwc, Transcript::proof_data); + serialize_to_buffer(avm_main_rwd, 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); @@ -2190,12 +2305,14 @@ class AvmFlavor { serialize_to_buffer(avm_mem_ind_op_a, Transcript::proof_data); serialize_to_buffer(avm_mem_ind_op_b, Transcript::proof_data); serialize_to_buffer(avm_mem_ind_op_c, Transcript::proof_data); + serialize_to_buffer(avm_mem_ind_op_d, Transcript::proof_data); serialize_to_buffer(avm_mem_last, Transcript::proof_data); serialize_to_buffer(avm_mem_lastAccess, Transcript::proof_data); serialize_to_buffer(avm_mem_one_min_inv, Transcript::proof_data); serialize_to_buffer(avm_mem_op_a, Transcript::proof_data); serialize_to_buffer(avm_mem_op_b, Transcript::proof_data); serialize_to_buffer(avm_mem_op_c, Transcript::proof_data); + serialize_to_buffer(avm_mem_op_d, Transcript::proof_data); serialize_to_buffer(avm_mem_r_in_tag, Transcript::proof_data); serialize_to_buffer(avm_mem_rw, Transcript::proof_data); serialize_to_buffer(avm_mem_sel_mov, Transcript::proof_data); @@ -2209,9 +2326,11 @@ class AvmFlavor { serialize_to_buffer(perm_main_mem_a, Transcript::proof_data); serialize_to_buffer(perm_main_mem_b, Transcript::proof_data); serialize_to_buffer(perm_main_mem_c, Transcript::proof_data); + serialize_to_buffer(perm_main_mem_d, Transcript::proof_data); serialize_to_buffer(perm_main_mem_ind_a, Transcript::proof_data); serialize_to_buffer(perm_main_mem_ind_b, Transcript::proof_data); serialize_to_buffer(perm_main_mem_ind_c, Transcript::proof_data); + serialize_to_buffer(perm_main_mem_ind_d, Transcript::proof_data); serialize_to_buffer(lookup_byte_lengths, Transcript::proof_data); serialize_to_buffer(lookup_byte_operations, Transcript::proof_data); serialize_to_buffer(incl_main_tag_err, Transcript::proof_data); diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp index aabdf2c2d6b..c82c6c928a5 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp @@ -177,15 +177,19 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) commitments.avm_main_ia = transcript->template receive_from_prover(commitment_labels.avm_main_ia); commitments.avm_main_ib = transcript->template receive_from_prover(commitment_labels.avm_main_ib); commitments.avm_main_ic = transcript->template receive_from_prover(commitment_labels.avm_main_ic); + commitments.avm_main_id = transcript->template receive_from_prover(commitment_labels.avm_main_id); commitments.avm_main_ind_a = transcript->template receive_from_prover(commitment_labels.avm_main_ind_a); commitments.avm_main_ind_b = transcript->template receive_from_prover(commitment_labels.avm_main_ind_b); commitments.avm_main_ind_c = transcript->template receive_from_prover(commitment_labels.avm_main_ind_c); + commitments.avm_main_ind_d = transcript->template receive_from_prover(commitment_labels.avm_main_ind_d); commitments.avm_main_ind_op_a = transcript->template receive_from_prover(commitment_labels.avm_main_ind_op_a); commitments.avm_main_ind_op_b = transcript->template receive_from_prover(commitment_labels.avm_main_ind_op_b); commitments.avm_main_ind_op_c = transcript->template receive_from_prover(commitment_labels.avm_main_ind_op_c); + commitments.avm_main_ind_op_d = + transcript->template receive_from_prover(commitment_labels.avm_main_ind_op_d); commitments.avm_main_internal_return_ptr = transcript->template receive_from_prover(commitment_labels.avm_main_internal_return_ptr); commitments.avm_main_inv = transcript->template receive_from_prover(commitment_labels.avm_main_inv); @@ -196,12 +200,16 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) transcript->template receive_from_prover(commitment_labels.avm_main_mem_idx_b); commitments.avm_main_mem_idx_c = transcript->template receive_from_prover(commitment_labels.avm_main_mem_idx_c); + commitments.avm_main_mem_idx_d = + transcript->template receive_from_prover(commitment_labels.avm_main_mem_idx_d); commitments.avm_main_mem_op_a = transcript->template receive_from_prover(commitment_labels.avm_main_mem_op_a); commitments.avm_main_mem_op_b = transcript->template receive_from_prover(commitment_labels.avm_main_mem_op_b); commitments.avm_main_mem_op_c = transcript->template receive_from_prover(commitment_labels.avm_main_mem_op_c); + commitments.avm_main_mem_op_d = + transcript->template receive_from_prover(commitment_labels.avm_main_mem_op_d); commitments.avm_main_op_err = transcript->template receive_from_prover(commitment_labels.avm_main_op_err); commitments.avm_main_pc = transcript->template receive_from_prover(commitment_labels.avm_main_pc); @@ -210,6 +218,7 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) commitments.avm_main_rwa = transcript->template receive_from_prover(commitment_labels.avm_main_rwa); commitments.avm_main_rwb = transcript->template receive_from_prover(commitment_labels.avm_main_rwb); commitments.avm_main_rwc = transcript->template receive_from_prover(commitment_labels.avm_main_rwc); + commitments.avm_main_rwd = transcript->template receive_from_prover(commitment_labels.avm_main_rwd); commitments.avm_main_sel_halt = transcript->template receive_from_prover(commitment_labels.avm_main_sel_halt); commitments.avm_main_sel_internal_call = @@ -258,6 +267,8 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) transcript->template receive_from_prover(commitment_labels.avm_mem_ind_op_b); commitments.avm_mem_ind_op_c = transcript->template receive_from_prover(commitment_labels.avm_mem_ind_op_c); + commitments.avm_mem_ind_op_d = + transcript->template receive_from_prover(commitment_labels.avm_mem_ind_op_d); commitments.avm_mem_last = transcript->template receive_from_prover(commitment_labels.avm_mem_last); commitments.avm_mem_lastAccess = transcript->template receive_from_prover(commitment_labels.avm_mem_lastAccess); @@ -266,6 +277,7 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) commitments.avm_mem_op_a = transcript->template receive_from_prover(commitment_labels.avm_mem_op_a); commitments.avm_mem_op_b = transcript->template receive_from_prover(commitment_labels.avm_mem_op_b); commitments.avm_mem_op_c = transcript->template receive_from_prover(commitment_labels.avm_mem_op_c); + commitments.avm_mem_op_d = transcript->template receive_from_prover(commitment_labels.avm_mem_op_d); commitments.avm_mem_r_in_tag = transcript->template receive_from_prover(commitment_labels.avm_mem_r_in_tag); commitments.avm_mem_rw = transcript->template receive_from_prover(commitment_labels.avm_mem_rw); @@ -335,12 +347,24 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) transcript->template receive_from_prover(commitment_labels.perm_main_mem_b); commitments.perm_main_mem_c = transcript->template receive_from_prover(commitment_labels.perm_main_mem_c); + commitments.perm_main_mem_d = + transcript->template receive_from_prover(commitment_labels.perm_main_mem_d); commitments.perm_main_mem_ind_a = transcript->template receive_from_prover(commitment_labels.perm_main_mem_ind_a); commitments.perm_main_mem_ind_b = transcript->template receive_from_prover(commitment_labels.perm_main_mem_ind_b); commitments.perm_main_mem_ind_c = transcript->template receive_from_prover(commitment_labels.perm_main_mem_ind_c); +<<<<<<< HEAD +======= +<<<<<<< HEAD + + // Lookups +======= + commitments.perm_main_mem_ind_d = + transcript->template receive_from_prover(commitment_labels.perm_main_mem_ind_d); +>>>>>>> 7c841655b (5557: Add an additional intermediate register id) +>>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) commitments.lookup_byte_lengths = transcript->template receive_from_prover(commitment_labels.lookup_byte_lengths); commitments.lookup_byte_operations = From ce1eaa3dccd83179ba6bcf974c89f8b05648cd48 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Thu, 4 Apr 2024 16:05:01 +0000 Subject: [PATCH 2/9] 5557: PIL relations for CMOV opcode --- barretenberg/cpp/pil/avm/avm_main.pil | 44 +++- barretenberg/cpp/pil/avm/avm_mem.pil | 15 +- .../relations/generated/avm/avm_main.hpp | 218 +++--------------- .../relations/generated/avm/avm_mem.hpp | 5 +- .../relations/generated/avm/declare_views.hpp | 7 +- .../generated/avm/perm_main_mem_a.hpp | 8 +- .../generated/avm/perm_main_mem_b.hpp | 10 +- .../vm/avm_trace/avm_mem_trace.cpp | 2 +- .../vm/avm_trace/avm_mem_trace.hpp | 2 +- .../barretenberg/vm/avm_trace/avm_trace.cpp | 3 +- .../vm/generated/avm_circuit_builder.hpp | 19 +- .../barretenberg/vm/generated/avm_flavor.hpp | 71 +++++- .../vm/generated/avm_verifier.cpp | 14 +- .../vm/tests/avm_mem_opcodes.test.cpp | 12 +- 14 files changed, 198 insertions(+), 232 deletions(-) diff --git a/barretenberg/cpp/pil/avm/avm_main.pil b/barretenberg/cpp/pil/avm/avm_main.pil index 15ec9398016..ad54ff61140 100644 --- a/barretenberg/cpp/pil/avm/avm_main.pil +++ b/barretenberg/cpp/pil/avm/avm_main.pil @@ -30,6 +30,7 @@ namespace avm_main(256); //===== MEMORY OPCODES ========================================================== pol commit sel_mov; + pol commit sel_cmov; //===== TABLE SUBOP-TR ======================================================== // Boolean selectors for (sub-)operations. Only one operation is activated at @@ -75,6 +76,7 @@ namespace avm_main(256); // A helper witness being the inverse of some value // to show a non-zero equality pol commit inv; + pol commit id_zero; // Boolean telling whether id is zero (cmov opcode) // Intermediate register values pol commit ia; @@ -139,9 +141,11 @@ namespace avm_main(256); // Might be removed if derived from opcode based on a lookup of constants sel_mov * ( 1 - sel_mov) = 0; + sel_cmov * ( 1 - sel_cmov) = 0; op_err * (1 - op_err) = 0; tag_err * (1 - tag_err) = 0; // Potential optimization (boolean constraint derivation from equivalence check to avm_mem)? + id_zero * (1 - id_zero) = 0; // Might be removed if derived from opcode based on a lookup of constants mem_op_a * (1 - mem_op_a) = 0; @@ -252,10 +256,36 @@ namespace avm_main(256); // TODO: we want to set an initial number for the reserved memory of the jump pointer //====== MEMORY OPCODES CONSTRAINTS ========================================= - #[MOV_SAME_VALUE] - sel_mov * (ia - ic) = 0; // Ensure that the correct value is moved/copied. + + // TODO: consolidate with zero division error handling + + // When sel_cmov == 1, we need id == 0 <==> id_zero == 0 + // This can be achieved with the 2 following relations. + // inv is an extra witness to show that we can invert id, i.e., inv = id^(-1) + // If id == 0, we have to set inv = 1 to satisfy the second relation, + // because id_zero == 1 from the first relation. + #[CMOV_CONDITION_RES_1] + sel_cmov * (id * inv - 1 + id_zero) = 0; + #[CMOV_CONDITION_RES_2] + sel_cmov * id_zero * (1 - inv) = 0; + + // Boolean selectors telling whether we move ia to ic or ib to ic. + // Boolean constraints and mutual exclusivity are derived from their + // respective definitions based on sel_mov, sel_cmov, and id_zero. + pol commit sel_mov_a; + pol commit sel_mov_b; + + // For MOV, we copy ia to ic. + // For CMOV, we copy ia to ic if id is NOT zero, otherwise we copy ib to ic. + sel_mov_a = sel_mov + sel_cmov * (1 - id_zero); + sel_mov_b = sel_cmov * id_zero; + + #[MOV_SAME_VALUE_A] + sel_mov_a * (ia - ic) = 0; // Ensure that the correct value is moved/copied. + #[MOV_SAME_VALUE_B] + sel_mov_b * (ib - ic) = 0; // Ensure that the correct value is moved/copied. #[MOV_MAIN_SAME_TAG] - sel_mov * (r_in_tag - w_in_tag) = 0; + (sel_mov + sel_cmov) * (r_in_tag - w_in_tag) = 0; //====== Inter-table Constraints ============================================ #[INCL_MAIN_TAG_ERR] @@ -295,14 +325,14 @@ namespace avm_main(256); avm_binary.start {avm_binary.clk, avm_binary.acc_ia, avm_binary.acc_ib, avm_binary.acc_ic, avm_binary.op_id, avm_binary.in_tag}; #[PERM_MAIN_MEM_A] - mem_op_a {clk, mem_idx_a, ia, rwa, r_in_tag, w_in_tag, sel_mov} + mem_op_a {clk, mem_idx_a, ia, rwa, r_in_tag, w_in_tag, sel_mov_a} is - avm_mem.op_a {avm_mem.clk, avm_mem.addr, avm_mem.val, avm_mem.rw, avm_mem.r_in_tag, avm_mem.w_in_tag, avm_mem.sel_mov}; + avm_mem.op_a {avm_mem.clk, avm_mem.addr, avm_mem.val, avm_mem.rw, avm_mem.r_in_tag, avm_mem.w_in_tag, avm_mem.sel_mov_a}; #[PERM_MAIN_MEM_B] - mem_op_b {clk, mem_idx_b, ib, rwb, r_in_tag, w_in_tag} + mem_op_b {clk, mem_idx_b, ib, rwb, r_in_tag, w_in_tag, sel_mov_b} is - avm_mem.op_b {avm_mem.clk, avm_mem.addr, avm_mem.val, avm_mem.rw, avm_mem.r_in_tag, avm_mem.w_in_tag}; + avm_mem.op_b {avm_mem.clk, avm_mem.addr, avm_mem.val, avm_mem.rw, avm_mem.r_in_tag, avm_mem.w_in_tag, avm_mem.sel_mov_b}; #[PERM_MAIN_MEM_C] mem_op_c {clk, mem_idx_c, ic, rwc, r_in_tag, w_in_tag} diff --git a/barretenberg/cpp/pil/avm/avm_mem.pil b/barretenberg/cpp/pil/avm/avm_mem.pil index ddcdee3e9f3..d2d780b91e5 100644 --- a/barretenberg/cpp/pil/avm/avm_mem.pil +++ b/barretenberg/cpp/pil/avm/avm_mem.pil @@ -28,9 +28,10 @@ namespace avm_mem(256); pol commit ind_op_c; pol commit ind_op_d; - // Selector for MOV opcode (copied from main trace for loading operation on intermediated register ia) + // Selectors for MOV/CMOV opcodes (copied from main trace for loading operation on intermediated register ia/ib) // Boolean constraint is performed in main trace. - pol commit sel_mov; + pol commit sel_mov_a; + pol commit sel_mov_b; // Error columns pol commit tag_err; // Boolean (1 if r_in_tag != tag is detected) @@ -152,12 +153,12 @@ namespace avm_mem(256); ind_op_c * rw = 0; ind_op_d * rw = 0; - //====== MOV Opcode Tag Constraint ===================================== + //====== MOV/CMOV Opcode Tag Constraint ===================================== // The following constraint ensures that the r_in_tag is set to tag for - // the load operation pertaining to Ia. - // The permutation check #[PERM_MAIN_MEM_A] guarantees that the r_in_tag - // value load operation for Ia is copied back in the main trace. + // the load operation pertaining to Ia resp. Ib. + // The permutation check #[PERM_MAIN_MEM_A/B] guarantees that the r_in_tag + // value load operation for Ia/Ib is copied back in the main trace. // Constraint #[MOV_MAIN_SAME_TAG] copies r_in_tag to w_in_tag in the main // trace. Then, #[PERM_MAIN_MEM_C] copies w_in_tag for store operation from Ic. #[MOV_SAME_TAG] - sel_mov * tag_err = 0; // Equivalent to sel_mov * (r_in_tag - tag) = 0 \ No newline at end of file + (sel_mov_a + sel_mov_b) * tag_err = 0; // Equivalent to (sel_mov_a + sel_mov_b) * (r_in_tag - tag) = 0 \ 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 7b6b7460974..dffbb6e62b9 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_main.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_main.hpp @@ -14,6 +14,8 @@ template struct Avm_mainRow { FF avm_main_ia{}; FF avm_main_ib{}; FF avm_main_ic{}; + FF avm_main_id{}; + FF avm_main_id_zero{}; FF avm_main_ind_op_a{}; FF avm_main_ind_op_b{}; FF avm_main_ind_op_c{}; @@ -35,11 +37,14 @@ template struct Avm_mainRow { FF avm_main_rwb{}; FF avm_main_rwc{}; FF avm_main_rwd{}; + FF avm_main_sel_cmov{}; FF avm_main_sel_halt{}; FF avm_main_sel_internal_call{}; FF avm_main_sel_internal_return{}; FF avm_main_sel_jump{}; FF avm_main_sel_mov{}; + FF avm_main_sel_mov_a{}; + FF avm_main_sel_mov_b{}; FF avm_main_sel_op_add{}; FF avm_main_sel_op_and{}; FF avm_main_sel_op_div{}; @@ -58,83 +63,52 @@ template struct Avm_mainRow { inline std::string get_relation_label_avm_main(int index) { switch (index) { -<<<<<<< HEAD - case 27: - return "OUTPUT_U8"; - case 28: + return "EQ_OUTPUT_U8"; + + case 31: return "SUBOP_DIVISION_FF"; - case 29: + case 32: return "SUBOP_DIVISION_ZERO_ERR1"; - case 30: + case 33: return "SUBOP_DIVISION_ZERO_ERR2"; - case 31: + case 34: return "SUBOP_ERROR_RELEVANT_OP"; - case 33: + case 36: return "RETURN_POINTER_INCREMENT"; - case 39: + case 42: return "RETURN_POINTER_DECREMENT"; - case 44: + case 47: return "PC_INCREMENT"; - case 45: + case 48: return "INTERNAL_RETURN_POINTER_CONSISTENCY"; - case 46: - return "MOV_SAME_VALUE"; - - case 47: - return "MOV_MAIN_SAME_TAG"; - case 49: - return "BIN_SEL_1"; + return "CMOV_CONDITION_RES_1"; case 50: -======= - case 28: - return "EQ_OUTPUT_U8"; + return "CMOV_CONDITION_RES_2"; - case 29: - return "SUBOP_DIVISION_FF"; + case 53: + return "MOV_SAME_VALUE_A"; - case 30: - return "SUBOP_DIVISION_ZERO_ERR1"; + case 54: + return "MOV_SAME_VALUE_B"; - case 31: - return "SUBOP_DIVISION_ZERO_ERR2"; - - case 32: - return "SUBOP_ERROR_RELEVANT_OP"; - - case 34: - return "RETURN_POINTER_INCREMENT"; - - case 40: - return "RETURN_POINTER_DECREMENT"; - - case 45: - return "PC_INCREMENT"; - - case 46: - return "INTERNAL_RETURN_POINTER_CONSISTENCY"; - - case 47: - return "MOV_SAME_VALUE"; - - case 48: + case 55: return "MOV_MAIN_SAME_TAG"; - case 50: + case 57: return "BIN_SEL_1"; case 51: ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) return "BIN_SEL_2"; } return std::to_string(index); @@ -144,15 +118,9 @@ template class avm_mainImpl { public: using FF = FF_; -<<<<<<< HEAD - 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, 5, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 3, 3, 3, 3, 2, -======= 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, 5, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 3, 3, 3, 3, 2, ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) }; template @@ -278,7 +246,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(14); - auto tmp = (avm_main_sel_halt * (-avm_main_sel_halt + FF(1))); + auto tmp = (avm_main_op_err * (-avm_main_op_err + FF(1))); tmp *= scaling_factor; std::get<14>(evals) += tmp; } @@ -286,7 +254,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(15); - auto tmp = (avm_main_sel_mov * (-avm_main_sel_mov + FF(1))); + auto tmp = (avm_main_tag_err * (-avm_main_tag_err + FF(1))); tmp *= scaling_factor; std::get<15>(evals) += tmp; } @@ -294,7 +262,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(16); - auto tmp = (avm_main_op_err * (-avm_main_op_err + FF(1))); + auto tmp = (avm_main_mem_op_a * (-avm_main_mem_op_a + FF(1))); tmp *= scaling_factor; std::get<16>(evals) += tmp; } @@ -302,7 +270,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(17); - auto tmp = (avm_main_tag_err * (-avm_main_tag_err + FF(1))); + auto tmp = (avm_main_mem_op_b * (-avm_main_mem_op_b + FF(1))); tmp *= scaling_factor; std::get<17>(evals) += tmp; } @@ -318,11 +286,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(19); -<<<<<<< HEAD - auto tmp = (avm_main_mem_op_b * (-avm_main_mem_op_b + FF(1))); -======= auto tmp = (avm_main_mem_op_d * (-avm_main_mem_op_d + FF(1))); ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<19>(evals) += tmp; } @@ -330,11 +294,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(20); -<<<<<<< HEAD - auto tmp = (avm_main_mem_op_c * (-avm_main_mem_op_c + FF(1))); -======= auto tmp = (avm_main_rwa * (-avm_main_rwa + FF(1))); ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<20>(evals) += tmp; } @@ -342,11 +302,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(21); -<<<<<<< HEAD - auto tmp = (avm_main_rwa * (-avm_main_rwa + FF(1))); -======= auto tmp = (avm_main_rwb * (-avm_main_rwb + FF(1))); ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<21>(evals) += tmp; } @@ -354,11 +310,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(22); -<<<<<<< HEAD - auto tmp = (avm_main_rwb * (-avm_main_rwb + FF(1))); -======= auto tmp = (avm_main_rwc * (-avm_main_rwc + FF(1))); ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<22>(evals) += tmp; } @@ -366,11 +318,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(23); -<<<<<<< HEAD - auto tmp = (avm_main_rwc * (-avm_main_rwc + FF(1))); -======= auto tmp = (avm_main_rwd * (-avm_main_rwd + FF(1))); ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<23>(evals) += tmp; } @@ -378,7 +326,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(24); - auto tmp = (avm_main_ind_op_a * (-avm_main_ind_op_a + FF(1))); + auto tmp = (avm_main_rwc * (-avm_main_rwc + FF(1))); tmp *= scaling_factor; std::get<24>(evals) += tmp; } @@ -386,7 +334,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(25); - auto tmp = (avm_main_ind_op_b * (-avm_main_ind_op_b + FF(1))); + auto tmp = (avm_main_rwd * (-avm_main_rwd + FF(1))); tmp *= scaling_factor; std::get<25>(evals) += tmp; } @@ -394,7 +342,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(26); - auto tmp = (avm_main_ind_op_c * (-avm_main_ind_op_c + FF(1))); + auto tmp = (avm_main_ind_op_a * (-avm_main_ind_op_a + FF(1))); tmp *= scaling_factor; std::get<26>(evals) += tmp; } @@ -402,12 +350,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(27); -<<<<<<< HEAD - 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))); ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<27>(evals) += tmp; } @@ -415,12 +358,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(28); -<<<<<<< HEAD - auto tmp = - ((avm_main_sel_op_div * (-avm_main_op_err + FF(1))) * ((avm_main_ic * avm_main_ib) - avm_main_ia)); -======= auto tmp = (avm_main_sel_op_eq * (avm_main_w_in_tag - FF(1))); ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<28>(evals) += tmp; } @@ -428,12 +366,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(29); -<<<<<<< HEAD - auto tmp = (avm_main_sel_op_div * (((avm_main_ib * avm_main_inv) - FF(1)) + avm_main_op_err)); -======= auto tmp = ((avm_main_sel_op_div * (-avm_main_op_err + FF(1))) * ((avm_main_ic * avm_main_ib) - avm_main_ia)); ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<29>(evals) += tmp; } @@ -441,11 +375,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(30); -<<<<<<< HEAD - auto tmp = ((avm_main_sel_op_div * avm_main_op_err) * (-avm_main_inv + FF(1))); -======= auto tmp = (avm_main_sel_op_div * (((avm_main_ib * avm_main_inv) - FF(1)) + avm_main_op_err)); ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<30>(evals) += tmp; } @@ -453,11 +383,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(31); -<<<<<<< HEAD - auto tmp = (avm_main_op_err * (avm_main_sel_op_div - FF(1))); -======= auto tmp = ((avm_main_sel_op_div * avm_main_op_err) * (-avm_main_inv + FF(1))); ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<31>(evals) += tmp; } @@ -465,11 +391,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(32); -<<<<<<< HEAD - auto tmp = (avm_main_sel_jump * (avm_main_pc_shift - avm_main_ia)); -======= auto tmp = (avm_main_op_err * (avm_main_sel_op_div - FF(1))); ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<32>(evals) += tmp; } @@ -477,12 +399,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(33); -<<<<<<< HEAD - 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_jump * (avm_main_pc_shift - avm_main_ia)); ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<33>(evals) += tmp; } @@ -490,12 +407,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(34); -<<<<<<< HEAD - 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)))); ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<34>(evals) += tmp; } @@ -503,11 +416,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(35); -<<<<<<< HEAD - 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)); ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<35>(evals) += tmp; } @@ -515,11 +424,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(36); -<<<<<<< HEAD - 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)); ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<36>(evals) += tmp; } @@ -527,11 +432,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(37); -<<<<<<< HEAD - 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)); ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<37>(evals) += tmp; } @@ -539,11 +440,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(38); -<<<<<<< HEAD - 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))); ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<38>(evals) += tmp; } @@ -551,12 +448,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(39); -<<<<<<< HEAD - 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))); ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<39>(evals) += tmp; } @@ -564,12 +456,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(40); -<<<<<<< HEAD - 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)))); ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<40>(evals) += tmp; } @@ -577,11 +465,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(41); -<<<<<<< HEAD - 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)); ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<41>(evals) += tmp; } @@ -589,11 +473,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(42); -<<<<<<< HEAD - auto tmp = (avm_main_sel_internal_return * avm_main_rwa); -======= auto tmp = (avm_main_sel_internal_return * (avm_main_pc_shift - avm_main_ia)); ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<42>(evals) += tmp; } @@ -601,11 +481,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(43); -<<<<<<< HEAD - auto tmp = (avm_main_sel_internal_return * (avm_main_mem_op_a - FF(1))); -======= auto tmp = (avm_main_sel_internal_return * avm_main_rwa); ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<43>(evals) += tmp; } @@ -613,8 +489,6 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(44); -<<<<<<< HEAD -======= auto tmp = (avm_main_sel_internal_return * (avm_main_mem_op_a - FF(1))); tmp *= scaling_factor; std::get<44>(evals) += tmp; @@ -623,7 +497,6 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(45); ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) auto tmp = ((((-avm_main_first + FF(1)) * (-avm_main_sel_halt + FF(1))) * ((((((((avm_main_sel_op_add + avm_main_sel_op_sub) + avm_main_sel_op_div) + avm_main_sel_op_mul) + @@ -654,14 +527,10 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(46); -<<<<<<< HEAD - auto tmp = (avm_main_sel_mov * (avm_main_ia - avm_main_ic)); -======= 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)); ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<46>(evals) += tmp; } @@ -669,11 +538,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(47); -<<<<<<< HEAD - auto tmp = (avm_main_sel_mov * (avm_main_r_in_tag - avm_main_w_in_tag)); -======= auto tmp = (avm_main_sel_mov * (avm_main_ia - avm_main_ic)); ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<47>(evals) += tmp; } @@ -681,17 +546,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(48); -<<<<<<< HEAD - 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_not) + - avm_main_sel_op_eq) + - avm_main_sel_op_lt) + - avm_main_sel_op_lte) * - (-avm_main_tag_err + FF(1)))); -======= auto tmp = (avm_main_sel_mov * (avm_main_r_in_tag - avm_main_w_in_tag)); ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<48>(evals) += tmp; } @@ -699,14 +554,10 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(49); -<<<<<<< HEAD - auto tmp = (avm_main_bin_op_id - (avm_main_sel_op_or + (avm_main_sel_op_xor * FF(2)))); -======= 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_not) + avm_main_sel_op_eq) * (-avm_main_tag_err + FF(1)))); ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) tmp *= scaling_factor; std::get<49>(evals) += tmp; } @@ -714,12 +565,6 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(50); -<<<<<<< HEAD - 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<50>(evals) += tmp; - } -======= auto tmp = (avm_main_bin_op_id - (avm_main_sel_op_or + (avm_main_sel_op_xor * FF(2)))); tmp *= scaling_factor; std::get<50>(evals) += tmp; @@ -728,11 +573,10 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(51); - auto tmp = (avm_main_bin_sel - ((avm_main_sel_op_and + avm_main_sel_op_or) + avm_main_sel_op_xor)); + 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<51>(evals) += tmp; } ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) } }; 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 833cb65faba..dfcf10ce470 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_mem.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_mem.hpp @@ -23,7 +23,8 @@ template struct Avm_memRow { FF avm_mem_r_in_tag{}; FF avm_mem_rw{}; FF avm_mem_rw_shift{}; - FF avm_mem_sel_mov{}; + FF avm_mem_sel_mov_a{}; + FF avm_mem_sel_mov_b{}; FF avm_mem_sub_clk{}; FF avm_mem_tag{}; FF avm_mem_tag_err{}; @@ -342,7 +343,7 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(30); - auto tmp = (avm_mem_sel_mov * avm_mem_tag_err); + auto tmp = ((avm_mem_sel_mov_a + avm_mem_sel_mov_b) * avm_mem_tag_err); tmp *= scaling_factor; std::get<30>(evals) += tmp; } 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 bf017cbff19..dda9cad3d47 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/declare_views.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/declare_views.hpp @@ -88,6 +88,7 @@ [[maybe_unused]] auto avm_main_ib = View(new_term.avm_main_ib); \ [[maybe_unused]] auto avm_main_ic = View(new_term.avm_main_ic); \ [[maybe_unused]] auto avm_main_id = View(new_term.avm_main_id); \ + [[maybe_unused]] auto avm_main_id_zero = View(new_term.avm_main_id_zero); \ [[maybe_unused]] auto avm_main_ind_a = View(new_term.avm_main_ind_a); \ [[maybe_unused]] auto avm_main_ind_b = View(new_term.avm_main_ind_b); \ [[maybe_unused]] auto avm_main_ind_c = View(new_term.avm_main_ind_c); \ @@ -114,11 +115,14 @@ [[maybe_unused]] auto avm_main_rwb = View(new_term.avm_main_rwb); \ [[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_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); \ [[maybe_unused]] auto avm_main_sel_jump = View(new_term.avm_main_sel_jump); \ [[maybe_unused]] auto avm_main_sel_mov = View(new_term.avm_main_sel_mov); \ + [[maybe_unused]] auto avm_main_sel_mov_a = View(new_term.avm_main_sel_mov_a); \ + [[maybe_unused]] auto avm_main_sel_mov_b = View(new_term.avm_main_sel_mov_b); \ [[maybe_unused]] auto avm_main_sel_op_add = View(new_term.avm_main_sel_op_add); \ [[maybe_unused]] auto avm_main_sel_op_and = View(new_term.avm_main_sel_op_and); \ [[maybe_unused]] auto avm_main_sel_op_div = View(new_term.avm_main_sel_op_div); \ @@ -149,7 +153,8 @@ [[maybe_unused]] auto avm_mem_op_d = View(new_term.avm_mem_op_d); \ [[maybe_unused]] auto avm_mem_r_in_tag = View(new_term.avm_mem_r_in_tag); \ [[maybe_unused]] auto avm_mem_rw = View(new_term.avm_mem_rw); \ - [[maybe_unused]] auto avm_mem_sel_mov = View(new_term.avm_mem_sel_mov); \ + [[maybe_unused]] auto avm_mem_sel_mov_a = View(new_term.avm_mem_sel_mov_a); \ + [[maybe_unused]] auto avm_mem_sel_mov_b = View(new_term.avm_mem_sel_mov_b); \ [[maybe_unused]] auto avm_mem_sub_clk = View(new_term.avm_mem_sub_clk); \ [[maybe_unused]] auto avm_mem_tag = View(new_term.avm_mem_tag); \ [[maybe_unused]] auto avm_mem_tag_err = View(new_term.avm_mem_tag_err); \ 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 62e4f48c289..960d2e8d31e 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 @@ -56,14 +56,14 @@ class perm_main_mem_a_permutation_settings { in.avm_main_rwa, in.avm_main_r_in_tag, in.avm_main_w_in_tag, - in.avm_main_sel_mov, + in.avm_main_sel_mov_a, in.avm_mem_clk, 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); + in.avm_mem_sel_mov_a); } /** @@ -96,14 +96,14 @@ class perm_main_mem_a_permutation_settings { in.avm_main_rwa, in.avm_main_r_in_tag, in.avm_main_w_in_tag, - in.avm_main_sel_mov, + in.avm_main_sel_mov_a, in.avm_mem_clk, 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); + in.avm_mem_sel_mov_a); } }; 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 4da414817f1..776578f0c5c 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 @@ -12,7 +12,7 @@ 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 = 6; + 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 @@ -56,12 +56,14 @@ class perm_main_mem_b_permutation_settings { in.avm_main_rwb, in.avm_main_r_in_tag, in.avm_main_w_in_tag, + in.avm_main_sel_mov_b, in.avm_mem_clk, 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_w_in_tag, + in.avm_mem_sel_mov_b); } /** @@ -94,12 +96,14 @@ class perm_main_mem_b_permutation_settings { in.avm_main_rwb, in.avm_main_r_in_tag, in.avm_main_w_in_tag, + in.avm_main_sel_mov_b, in.avm_mem_clk, 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_w_in_tag, + in.avm_mem_sel_mov_b); } }; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.cpp index bc073320d46..23e8dbd06ce 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.cpp @@ -200,7 +200,7 @@ AvmMemTraceBuilder::MemEntry AvmMemTraceBuilder::read_and_load_mov_opcode(uint32 .m_tag = memEntry.tag, .r_in_tag = memEntry.tag, .w_in_tag = memEntry.tag, - .m_sel_mov = true, + .m_sel_mov_a = true, }); return memEntry; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.hpp index 1b7f461179e..75ea930f386 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.hpp @@ -36,7 +36,7 @@ class AvmMemTraceBuilder { bool m_rw = false; bool m_tag_err = false; FF m_one_min_inv{}; - bool m_sel_mov = false; + bool m_sel_mov_a = false; bool m_tag_err_count_relevant = false; /** 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 5615c406d23..db1b6a5cdc0 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp @@ -832,6 +832,7 @@ void AvmTraceBuilder::op_mov(uint8_t indirect, uint32_t src_offset, uint32_t dst .avm_main_r_in_tag = static_cast(tag), .avm_main_rwc = 1, .avm_main_sel_mov = 1, + .avm_main_sel_mov_a = 1, .avm_main_tag_err = static_cast(!tag_match), .avm_main_w_in_tag = static_cast(tag), }); @@ -1267,7 +1268,7 @@ std::vector AvmTraceBuilder::finalize() dest.avm_mem_tag = FF(static_cast(src.m_tag)); dest.avm_mem_tag_err = FF(static_cast(src.m_tag_err)); dest.avm_mem_one_min_inv = src.m_one_min_inv; - dest.avm_mem_sel_mov = FF(static_cast(src.m_sel_mov)); + dest.avm_mem_sel_mov_a = FF(static_cast(src.m_sel_mov_a)); dest.incl_mem_tag_err_counts = FF(static_cast(src.m_tag_err_count_relevant)); 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 9939736ec3c..0c1a1378978 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp @@ -137,6 +137,7 @@ template struct AvmFullRow { FF avm_main_ib{}; FF avm_main_ic{}; FF avm_main_id{}; + FF avm_main_id_zero{}; FF avm_main_ind_a{}; FF avm_main_ind_b{}; FF avm_main_ind_c{}; @@ -163,11 +164,14 @@ template struct AvmFullRow { FF avm_main_rwb{}; FF avm_main_rwc{}; FF avm_main_rwd{}; + FF avm_main_sel_cmov{}; FF avm_main_sel_halt{}; FF avm_main_sel_internal_call{}; FF avm_main_sel_internal_return{}; FF avm_main_sel_jump{}; FF avm_main_sel_mov{}; + FF avm_main_sel_mov_a{}; + FF avm_main_sel_mov_b{}; FF avm_main_sel_op_add{}; FF avm_main_sel_op_and{}; FF avm_main_sel_op_div{}; @@ -198,7 +202,8 @@ template struct AvmFullRow { FF avm_mem_op_d{}; FF avm_mem_r_in_tag{}; FF avm_mem_rw{}; - FF avm_mem_sel_mov{}; + FF avm_mem_sel_mov_a{}; + FF avm_mem_sel_mov_b{}; FF avm_mem_sub_clk{}; FF avm_mem_tag{}; FF avm_mem_tag_err{}; @@ -297,6 +302,7 @@ class AvmCircuitBuilder { using Polynomial = Flavor::Polynomial; using ProverPolynomials = Flavor::ProverPolynomials; +<<<<<<< HEAD <<<<<<< HEAD static constexpr size_t num_fixed_columns = 224; static constexpr size_t num_polys = 195; @@ -304,6 +310,10 @@ class AvmCircuitBuilder { static constexpr size_t num_fixed_columns = 169; static constexpr size_t num_polys = 150; >>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) +======= + static constexpr size_t num_fixed_columns = 174; + static constexpr size_t num_polys = 155; +>>>>>>> 220457275 (5557: PIL relations for CMOV opcode) std::vector rows; void set_trace(std::vector&& trace) { rows = std::move(trace); } @@ -405,6 +415,7 @@ class AvmCircuitBuilder { polys.avm_main_ib[i] = rows[i].avm_main_ib; polys.avm_main_ic[i] = rows[i].avm_main_ic; polys.avm_main_id[i] = rows[i].avm_main_id; + polys.avm_main_id_zero[i] = rows[i].avm_main_id_zero; polys.avm_main_ind_a[i] = rows[i].avm_main_ind_a; polys.avm_main_ind_b[i] = rows[i].avm_main_ind_b; polys.avm_main_ind_c[i] = rows[i].avm_main_ind_c; @@ -431,11 +442,14 @@ class AvmCircuitBuilder { polys.avm_main_rwb[i] = rows[i].avm_main_rwb; 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_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; polys.avm_main_sel_jump[i] = rows[i].avm_main_sel_jump; polys.avm_main_sel_mov[i] = rows[i].avm_main_sel_mov; + polys.avm_main_sel_mov_a[i] = rows[i].avm_main_sel_mov_a; + polys.avm_main_sel_mov_b[i] = rows[i].avm_main_sel_mov_b; polys.avm_main_sel_op_add[i] = rows[i].avm_main_sel_op_add; polys.avm_main_sel_op_and[i] = rows[i].avm_main_sel_op_and; polys.avm_main_sel_op_div[i] = rows[i].avm_main_sel_op_div; @@ -466,7 +480,8 @@ class AvmCircuitBuilder { polys.avm_mem_op_d[i] = rows[i].avm_mem_op_d; polys.avm_mem_r_in_tag[i] = rows[i].avm_mem_r_in_tag; polys.avm_mem_rw[i] = rows[i].avm_mem_rw; - polys.avm_mem_sel_mov[i] = rows[i].avm_mem_sel_mov; + polys.avm_mem_sel_mov_a[i] = rows[i].avm_mem_sel_mov_a; + polys.avm_mem_sel_mov_b[i] = rows[i].avm_mem_sel_mov_b; polys.avm_mem_sub_clk[i] = rows[i].avm_mem_sub_clk; polys.avm_mem_tag[i] = rows[i].avm_mem_tag; polys.avm_mem_tag_err[i] = rows[i].avm_mem_tag_err; diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp index 80b3bbba5fc..de3e7b95af2 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp @@ -69,6 +69,7 @@ class AvmFlavor { using RelationSeparator = FF; static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 2; +<<<<<<< HEAD <<<<<<< HEAD static constexpr size_t NUM_WITNESS_ENTITIES = 193; static constexpr size_t NUM_WIRES = NUM_WITNESS_ENTITIES + NUM_PRECOMPUTED_ENTITIES; @@ -82,6 +83,13 @@ class AvmFlavor { // the unshifted and one for the shifted static constexpr size_t NUM_ALL_ENTITIES = 169; >>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) +======= + static constexpr size_t NUM_WITNESS_ENTITIES = 153; + 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 = 174; +>>>>>>> 220457275 (5557: PIL relations for CMOV opcode) using GrandProductRelations = std::tuple, perm_main_bin_relation, @@ -275,6 +283,7 @@ class AvmFlavor { avm_main_ib, avm_main_ic, avm_main_id, + avm_main_id_zero, avm_main_ind_a, avm_main_ind_b, avm_main_ind_c, @@ -301,11 +310,14 @@ class AvmFlavor { avm_main_rwb, avm_main_rwc, avm_main_rwd, + avm_main_sel_cmov, avm_main_sel_halt, avm_main_sel_internal_call, avm_main_sel_internal_return, avm_main_sel_jump, avm_main_sel_mov, + avm_main_sel_mov_a, + avm_main_sel_mov_b, avm_main_sel_op_add, avm_main_sel_op_and, avm_main_sel_op_div, @@ -336,7 +348,8 @@ class AvmFlavor { avm_mem_op_d, avm_mem_r_in_tag, avm_mem_rw, - avm_mem_sel_mov, + avm_mem_sel_mov_a, + avm_mem_sel_mov_b, avm_mem_sub_clk, avm_mem_tag, avm_mem_tag_err, @@ -481,6 +494,7 @@ class AvmFlavor { avm_main_ib, avm_main_ic, avm_main_id, + avm_main_id_zero, avm_main_ind_a, avm_main_ind_b, avm_main_ind_c, @@ -507,11 +521,14 @@ class AvmFlavor { avm_main_rwb, avm_main_rwc, avm_main_rwd, + avm_main_sel_cmov, avm_main_sel_halt, avm_main_sel_internal_call, avm_main_sel_internal_return, avm_main_sel_jump, avm_main_sel_mov, + avm_main_sel_mov_a, + avm_main_sel_mov_b, avm_main_sel_op_add, avm_main_sel_op_and, avm_main_sel_op_div, @@ -542,7 +559,8 @@ class AvmFlavor { avm_mem_op_d, avm_mem_r_in_tag, avm_mem_rw, - avm_mem_sel_mov, + avm_mem_sel_mov_a, + avm_mem_sel_mov_b, avm_mem_sub_clk, avm_mem_tag, avm_mem_tag_err, @@ -692,6 +710,7 @@ class AvmFlavor { avm_main_ib, avm_main_ic, avm_main_id, + avm_main_id_zero, avm_main_ind_a, avm_main_ind_b, avm_main_ind_c, @@ -718,11 +737,14 @@ class AvmFlavor { avm_main_rwb, avm_main_rwc, avm_main_rwd, + avm_main_sel_cmov, avm_main_sel_halt, avm_main_sel_internal_call, avm_main_sel_internal_return, avm_main_sel_jump, avm_main_sel_mov, + avm_main_sel_mov_a, + avm_main_sel_mov_b, avm_main_sel_op_add, avm_main_sel_op_and, avm_main_sel_op_div, @@ -753,7 +775,8 @@ class AvmFlavor { avm_mem_op_d, avm_mem_r_in_tag, avm_mem_rw, - avm_mem_sel_mov, + avm_mem_sel_mov_a, + avm_mem_sel_mov_b, avm_mem_sub_clk, avm_mem_tag, avm_mem_tag_err, @@ -929,6 +952,7 @@ class AvmFlavor { avm_main_ib, avm_main_ic, avm_main_id, + avm_main_id_zero, avm_main_ind_a, avm_main_ind_b, avm_main_ind_c, @@ -955,11 +979,14 @@ class AvmFlavor { avm_main_rwb, avm_main_rwc, avm_main_rwd, + avm_main_sel_cmov, avm_main_sel_halt, avm_main_sel_internal_call, avm_main_sel_internal_return, avm_main_sel_jump, avm_main_sel_mov, + avm_main_sel_mov_a, + avm_main_sel_mov_b, avm_main_sel_op_add, avm_main_sel_op_and, avm_main_sel_op_div, @@ -990,7 +1017,8 @@ class AvmFlavor { avm_mem_op_d, avm_mem_r_in_tag, avm_mem_rw, - avm_mem_sel_mov, + avm_mem_sel_mov_a, + avm_mem_sel_mov_b, avm_mem_sub_clk, avm_mem_tag, avm_mem_tag_err, @@ -1166,6 +1194,7 @@ class AvmFlavor { avm_main_ib, avm_main_ic, avm_main_id, + avm_main_id_zero, avm_main_ind_a, avm_main_ind_b, avm_main_ind_c, @@ -1192,11 +1221,14 @@ class AvmFlavor { avm_main_rwb, avm_main_rwc, avm_main_rwd, + avm_main_sel_cmov, avm_main_sel_halt, avm_main_sel_internal_call, avm_main_sel_internal_return, avm_main_sel_jump, avm_main_sel_mov, + avm_main_sel_mov_a, + avm_main_sel_mov_b, avm_main_sel_op_add, avm_main_sel_op_and, avm_main_sel_op_div, @@ -1227,7 +1259,8 @@ class AvmFlavor { avm_mem_op_d, avm_mem_r_in_tag, avm_mem_rw, - avm_mem_sel_mov, + avm_mem_sel_mov_a, + avm_mem_sel_mov_b, avm_mem_sub_clk, avm_mem_tag, avm_mem_tag_err, @@ -1576,6 +1609,7 @@ class AvmFlavor { Base::avm_main_ib = "AVM_MAIN_IB"; Base::avm_main_ic = "AVM_MAIN_IC"; Base::avm_main_id = "AVM_MAIN_ID"; + Base::avm_main_id_zero = "AVM_MAIN_ID_ZERO"; Base::avm_main_ind_a = "AVM_MAIN_IND_A"; Base::avm_main_ind_b = "AVM_MAIN_IND_B"; Base::avm_main_ind_c = "AVM_MAIN_IND_C"; @@ -1602,11 +1636,14 @@ class AvmFlavor { Base::avm_main_rwb = "AVM_MAIN_RWB"; 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_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"; Base::avm_main_sel_jump = "AVM_MAIN_SEL_JUMP"; Base::avm_main_sel_mov = "AVM_MAIN_SEL_MOV"; + Base::avm_main_sel_mov_a = "AVM_MAIN_SEL_MOV_A"; + Base::avm_main_sel_mov_b = "AVM_MAIN_SEL_MOV_B"; Base::avm_main_sel_op_add = "AVM_MAIN_SEL_OP_ADD"; Base::avm_main_sel_op_and = "AVM_MAIN_SEL_OP_AND"; Base::avm_main_sel_op_div = "AVM_MAIN_SEL_OP_DIV"; @@ -1637,7 +1674,8 @@ class AvmFlavor { Base::avm_mem_op_d = "AVM_MEM_OP_D"; Base::avm_mem_r_in_tag = "AVM_MEM_R_IN_TAG"; Base::avm_mem_rw = "AVM_MEM_RW"; - Base::avm_mem_sel_mov = "AVM_MEM_SEL_MOV"; + Base::avm_mem_sel_mov_a = "AVM_MEM_SEL_MOV_A"; + Base::avm_mem_sel_mov_b = "AVM_MEM_SEL_MOV_B"; Base::avm_mem_sub_clk = "AVM_MEM_SUB_CLK"; Base::avm_mem_tag = "AVM_MEM_TAG"; Base::avm_mem_tag_err = "AVM_MEM_TAG_ERR"; @@ -1798,6 +1836,7 @@ class AvmFlavor { Commitment avm_main_ib; Commitment avm_main_ic; Commitment avm_main_id; + Commitment avm_main_id_zero; Commitment avm_main_ind_a; Commitment avm_main_ind_b; Commitment avm_main_ind_c; @@ -1824,11 +1863,14 @@ class AvmFlavor { Commitment avm_main_rwb; Commitment avm_main_rwc; Commitment avm_main_rwd; + Commitment avm_main_sel_cmov; Commitment avm_main_sel_halt; Commitment avm_main_sel_internal_call; Commitment avm_main_sel_internal_return; Commitment avm_main_sel_jump; Commitment avm_main_sel_mov; + Commitment avm_main_sel_mov_a; + Commitment avm_main_sel_mov_b; Commitment avm_main_sel_op_add; Commitment avm_main_sel_op_and; Commitment avm_main_sel_op_div; @@ -1859,7 +1901,8 @@ class AvmFlavor { Commitment avm_mem_op_d; Commitment avm_mem_r_in_tag; Commitment avm_mem_rw; - Commitment avm_mem_sel_mov; + Commitment avm_mem_sel_mov_a; + Commitment avm_mem_sel_mov_b; Commitment avm_mem_sub_clk; Commitment avm_mem_tag; Commitment avm_mem_tag_err; @@ -2028,6 +2071,7 @@ class AvmFlavor { avm_main_ib = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_ic = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_id = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_id_zero = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_ind_a = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_ind_b = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_ind_c = deserialize_from_buffer(Transcript::proof_data, num_frs_read); @@ -2054,11 +2098,14 @@ class AvmFlavor { avm_main_rwb = deserialize_from_buffer(Transcript::proof_data, num_frs_read); 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_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); avm_main_sel_jump = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_sel_mov = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_mov_a = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_mov_b = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_sel_op_add = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_sel_op_and = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_sel_op_div = deserialize_from_buffer(Transcript::proof_data, num_frs_read); @@ -2089,7 +2136,8 @@ class AvmFlavor { avm_mem_op_d = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_mem_r_in_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_mem_rw = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_mem_sel_mov = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_mem_sel_mov_a = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_mem_sel_mov_b = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_mem_sub_clk = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_mem_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_mem_tag_err = deserialize_from_buffer(Transcript::proof_data, num_frs_read); @@ -2254,6 +2302,7 @@ class AvmFlavor { serialize_to_buffer(avm_main_ib, Transcript::proof_data); serialize_to_buffer(avm_main_ic, Transcript::proof_data); serialize_to_buffer(avm_main_id, Transcript::proof_data); + serialize_to_buffer(avm_main_id_zero, Transcript::proof_data); serialize_to_buffer(avm_main_ind_a, Transcript::proof_data); serialize_to_buffer(avm_main_ind_b, Transcript::proof_data); serialize_to_buffer(avm_main_ind_c, Transcript::proof_data); @@ -2280,11 +2329,14 @@ class AvmFlavor { serialize_to_buffer(avm_main_rwb, Transcript::proof_data); 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_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); serialize_to_buffer(avm_main_sel_jump, Transcript::proof_data); serialize_to_buffer(avm_main_sel_mov, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_mov_a, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_mov_b, Transcript::proof_data); serialize_to_buffer(avm_main_sel_op_add, Transcript::proof_data); serialize_to_buffer(avm_main_sel_op_and, Transcript::proof_data); serialize_to_buffer(avm_main_sel_op_div, Transcript::proof_data); @@ -2315,7 +2367,8 @@ class AvmFlavor { serialize_to_buffer(avm_mem_op_d, Transcript::proof_data); serialize_to_buffer(avm_mem_r_in_tag, Transcript::proof_data); serialize_to_buffer(avm_mem_rw, Transcript::proof_data); - serialize_to_buffer(avm_mem_sel_mov, Transcript::proof_data); + serialize_to_buffer(avm_mem_sel_mov_a, Transcript::proof_data); + serialize_to_buffer(avm_mem_sel_mov_b, Transcript::proof_data); serialize_to_buffer(avm_mem_sub_clk, Transcript::proof_data); serialize_to_buffer(avm_mem_tag, Transcript::proof_data); serialize_to_buffer(avm_mem_tag_err, Transcript::proof_data); diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp index c82c6c928a5..b938622b8be 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp @@ -178,6 +178,8 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) commitments.avm_main_ib = transcript->template receive_from_prover(commitment_labels.avm_main_ib); commitments.avm_main_ic = transcript->template receive_from_prover(commitment_labels.avm_main_ic); commitments.avm_main_id = transcript->template receive_from_prover(commitment_labels.avm_main_id); + commitments.avm_main_id_zero = + transcript->template receive_from_prover(commitment_labels.avm_main_id_zero); commitments.avm_main_ind_a = transcript->template receive_from_prover(commitment_labels.avm_main_ind_a); commitments.avm_main_ind_b = transcript->template receive_from_prover(commitment_labels.avm_main_ind_b); commitments.avm_main_ind_c = transcript->template receive_from_prover(commitment_labels.avm_main_ind_c); @@ -219,6 +221,8 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) commitments.avm_main_rwb = transcript->template receive_from_prover(commitment_labels.avm_main_rwb); commitments.avm_main_rwc = transcript->template receive_from_prover(commitment_labels.avm_main_rwc); commitments.avm_main_rwd = transcript->template 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_halt = transcript->template receive_from_prover(commitment_labels.avm_main_sel_halt); commitments.avm_main_sel_internal_call = @@ -229,6 +233,10 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) transcript->template receive_from_prover(commitment_labels.avm_main_sel_jump); commitments.avm_main_sel_mov = transcript->template receive_from_prover(commitment_labels.avm_main_sel_mov); + commitments.avm_main_sel_mov_a = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_mov_a); + commitments.avm_main_sel_mov_b = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_mov_b); commitments.avm_main_sel_op_add = transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_add); commitments.avm_main_sel_op_and = @@ -281,8 +289,10 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) commitments.avm_mem_r_in_tag = transcript->template receive_from_prover(commitment_labels.avm_mem_r_in_tag); commitments.avm_mem_rw = transcript->template receive_from_prover(commitment_labels.avm_mem_rw); - commitments.avm_mem_sel_mov = - transcript->template receive_from_prover(commitment_labels.avm_mem_sel_mov); + commitments.avm_mem_sel_mov_a = + transcript->template receive_from_prover(commitment_labels.avm_mem_sel_mov_a); + commitments.avm_mem_sel_mov_b = + transcript->template receive_from_prover(commitment_labels.avm_mem_sel_mov_b); commitments.avm_mem_sub_clk = transcript->template receive_from_prover(commitment_labels.avm_mem_sub_clk); commitments.avm_mem_tag = transcript->template receive_from_prover(commitment_labels.avm_mem_tag); diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_mem_opcodes.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_mem_opcodes.test.cpp index 1e7d9a4530b..2d89a8ab429 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_mem_opcodes.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_mem_opcodes.test.cpp @@ -111,7 +111,9 @@ class AvmMemOpcodeTests : public ::testing::Test { Field(&Row::avm_main_mem_idx_c, dir_dst_offset))); } EXPECT_THAT(main_row, - AllOf(Field(&Row::avm_main_ia, val_ff), + AllOf(Field(&Row::avm_main_sel_mov, 1), + Field(&Row::avm_main_sel_mov_a, 1), + Field(&Row::avm_main_ia, val_ff), Field(&Row::avm_main_ib, 0), Field(&Row::avm_main_ic, val_ff), Field(&Row::avm_main_r_in_tag, static_cast(tag)), @@ -123,7 +125,7 @@ class AvmMemOpcodeTests : public ::testing::Test { AllOf(Field(&Row::avm_mem_tag_err, 0), Field(&Row::avm_mem_r_in_tag, static_cast(tag)), Field(&Row::avm_mem_tag, static_cast(tag)), - Field(&Row::avm_mem_sel_mov, 1), + Field(&Row::avm_mem_sel_mov_a, 1), Field(&Row::avm_mem_addr, indirect ? dir_src_offset : src_offset), Field(&Row::avm_mem_val, val_ff), Field(&Row::avm_mem_rw, 0), @@ -351,7 +353,7 @@ TEST_F(AvmMemOpcodeNegativeTests, movWrongOutputValue) compute_mov_indices(false); trace.at(main_idx).avm_main_ic = 233; - EXPECT_THROW_WITH_MESSAGE(validate_trace_check_circuit(std::move(trace)), "MOV_SAME_VALUE"); + EXPECT_THROW_WITH_MESSAGE(validate_trace_check_circuit(std::move(trace)), "MOV_SAME_VALUE_A"); } TEST_F(AvmMemOpcodeNegativeTests, indMovWrongOutputValue) @@ -360,7 +362,7 @@ TEST_F(AvmMemOpcodeNegativeTests, indMovWrongOutputValue) compute_mov_indices(true); trace.at(main_idx).avm_main_ic = 8733; - EXPECT_THROW_WITH_MESSAGE(validate_trace_check_circuit(std::move(trace)), "MOV_SAME_VALUE"); + EXPECT_THROW_WITH_MESSAGE(validate_trace_check_circuit(std::move(trace)), "MOV_SAME_VALUE_A"); } // We want to test that the output tag for MOV cannot be altered. @@ -405,7 +407,7 @@ TEST_F(AvmMemOpcodeNegativeTests, movWrongOutputTagDisabledSelector) trace.at(mem_a_idx).avm_mem_w_in_tag = tag_u64; trace.at(mem_a_idx).avm_mem_tag_err = 1; trace.at(mem_a_idx).avm_mem_one_min_inv = one_min_inverse_diff; - trace.at(mem_a_idx).avm_mem_sel_mov = 0; + trace.at(mem_a_idx).avm_mem_sel_mov_a = 0; trace.at(mem_c_idx).avm_mem_tag = tag_u64; trace.at(mem_c_idx).avm_mem_r_in_tag = tag_u64; trace.at(mem_c_idx).avm_mem_w_in_tag = tag_u64; From cee06e6fe3c17163f2b7f5321544cff098b438b3 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Thu, 4 Apr 2024 18:04:50 +0000 Subject: [PATCH 3/9] 5557: witness generation for CMOV opcode --- .../vm/avm_trace/avm_mem_trace.cpp | 58 ++++++- .../vm/avm_trace/avm_mem_trace.hpp | 5 + .../barretenberg/vm/avm_trace/avm_trace.cpp | 161 ++++++++++++++---- .../barretenberg/vm/avm_trace/avm_trace.hpp | 8 +- 4 files changed, 192 insertions(+), 40 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.cpp index 23e8dbd06ce..4a2a622e6b1 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.cpp @@ -190,20 +190,66 @@ void AvmMemTraceBuilder::store_in_mem_trace( */ AvmMemTraceBuilder::MemEntry AvmMemTraceBuilder::read_and_load_mov_opcode(uint32_t const clk, uint32_t const addr) { - MemEntry memEntry = memory.contains(addr) ? memory.at(addr) : MemEntry{}; + MemEntry mem_entry = memory.contains(addr) ? memory.at(addr) : MemEntry{}; mem_trace.emplace_back(MemoryTraceEntry{ .m_clk = clk, .m_sub_clk = SUB_CLK_LOAD_A, .m_addr = addr, - .m_val = memEntry.val, - .m_tag = memEntry.tag, - .r_in_tag = memEntry.tag, - .w_in_tag = memEntry.tag, + .m_val = mem_entry.val, + .m_tag = mem_entry.tag, + .r_in_tag = mem_entry.tag, + .w_in_tag = mem_entry.tag, .m_sel_mov_a = true, }); - return memEntry; + return mem_entry; +} + +std::array AvmMemTraceBuilder::read_and_load_cmov_opcode(uint32_t clk, + uint32_t a_addr, + uint32_t b_addr, + uint32_t cond_addr) +{ + MemEntry a_mem_entry = memory.contains(a_addr) ? memory.at(a_addr) : MemEntry{}; + MemEntry b_mem_entry = memory.contains(b_addr) ? memory.at(b_addr) : MemEntry{}; + MemEntry cond_mem_entry = memory.contains(cond_addr) ? memory.at(cond_addr) : MemEntry{}; + + bool mov_b = cond_mem_entry.val == 0; + + mem_trace.emplace_back(MemoryTraceEntry{ + .m_clk = clk, + .m_sub_clk = SUB_CLK_LOAD_A, + .m_addr = a_addr, + .m_val = a_mem_entry.val, + .m_tag = a_mem_entry.tag, + .r_in_tag = a_mem_entry.tag, + .w_in_tag = a_mem_entry.tag, + .m_sel_mov_a = !mov_b, + }); + + mem_trace.emplace_back(MemoryTraceEntry{ + .m_clk = clk, + .m_sub_clk = SUB_CLK_LOAD_B, + .m_addr = b_addr, + .m_val = b_mem_entry.val, + .m_tag = b_mem_entry.tag, + .r_in_tag = b_mem_entry.tag, + .w_in_tag = b_mem_entry.tag, + .m_sel_mov_b = mov_b, + }); + + mem_trace.emplace_back(MemoryTraceEntry{ + .m_clk = clk, + .m_sub_clk = SUB_CLK_LOAD_C, + .m_addr = cond_addr, + .m_val = cond_mem_entry.val, + .m_tag = cond_mem_entry.tag, + .r_in_tag = cond_mem_entry.tag, + .w_in_tag = cond_mem_entry.tag, + }); + + return { a_mem_entry, b_mem_entry, cond_mem_entry }; } /** diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.hpp index 75ea930f386..6f5624935d4 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.hpp @@ -37,6 +37,7 @@ class AvmMemTraceBuilder { bool m_tag_err = false; FF m_one_min_inv{}; bool m_sel_mov_a = false; + bool m_sel_mov_b = false; bool m_tag_err_count_relevant = false; /** @@ -86,6 +87,10 @@ class AvmMemTraceBuilder { std::vector finalize(); MemEntry read_and_load_mov_opcode(uint32_t clk, uint32_t addr); + std::array read_and_load_cmov_opcode(uint32_t clk, + uint32_t a_addr, + uint32_t b_addr, + uint32_t cond_addr); MemRead read_and_load_from_memory( uint32_t clk, IntermRegister interm_reg, uint32_t addr, AvmMemoryTag r_in_tag, AvmMemoryTag w_in_tag); MemRead indirect_read_and_load_from_memory(uint32_t clk, IndirectRegister ind_reg, uint32_t addr); 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 db1b6a5cdc0..74e7f17958a 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp @@ -39,7 +39,7 @@ void AvmTraceBuilder::reset() } AvmTraceBuilder::IndirectThreeResolution AvmTraceBuilder::resolve_ind_three( - uint32_t clk, uint8_t indirect, uint32_t a_offset, uint32_t b_offset, uint32_t dst_offset) + uint32_t clk, uint8_t indirect, uint32_t a_offset, uint32_t b_offset, uint32_t c_offset) { bool indirect_flag_a = is_operand_indirect(indirect, 0); bool indirect_flag_b = is_operand_indirect(indirect, 1); @@ -47,7 +47,7 @@ AvmTraceBuilder::IndirectThreeResolution AvmTraceBuilder::resolve_ind_three( uint32_t direct_a_offset = a_offset; uint32_t direct_b_offset = b_offset; - uint32_t direct_dst_offset = dst_offset; + uint32_t direct_c_offset = c_offset; bool tag_match = true; @@ -64,9 +64,8 @@ AvmTraceBuilder::IndirectThreeResolution AvmTraceBuilder::resolve_ind_three( } if (indirect_flag_c) { - auto read_ind_c = - mem_trace_builder.indirect_read_and_load_from_memory(clk, IndirectRegister::IND_C, dst_offset); - direct_dst_offset = uint32_t(read_ind_c.val); + auto read_ind_c = mem_trace_builder.indirect_read_and_load_from_memory(clk, IndirectRegister::IND_C, c_offset); + direct_c_offset = uint32_t(read_ind_c.val); tag_match = tag_match && read_ind_c.tag_match; } @@ -74,7 +73,7 @@ AvmTraceBuilder::IndirectThreeResolution AvmTraceBuilder::resolve_ind_three( .tag_match = tag_match, .direct_a_offset = direct_a_offset, .direct_b_offset = direct_b_offset, - .direct_dst_offset = direct_dst_offset, + .direct_c_offset = direct_c_offset, .indirect_flag_a = indirect_flag_a, .indirect_flag_b = indirect_flag_b, .indirect_flag_c = indirect_flag_c, @@ -115,7 +114,7 @@ void AvmTraceBuilder::op_add( FF c = tag_match ? alu_trace_builder.op_add(a, b, in_tag, clk) : FF(0); // Write into memory value c from intermediate register ic. - mem_trace_builder.write_into_memory(clk, IntermRegister::IC, res.direct_dst_offset, c, in_tag, in_tag); + mem_trace_builder.write_into_memory(clk, IntermRegister::IC, res.direct_c_offset, c, in_tag, in_tag); main_trace.push_back(Row{ .avm_main_clk = clk, @@ -131,7 +130,7 @@ void AvmTraceBuilder::op_add( .avm_main_internal_return_ptr = FF(internal_return_ptr), .avm_main_mem_idx_a = FF(res.direct_a_offset), .avm_main_mem_idx_b = FF(res.direct_b_offset), - .avm_main_mem_idx_c = FF(res.direct_dst_offset), + .avm_main_mem_idx_c = FF(res.direct_c_offset), .avm_main_mem_op_a = FF(1), .avm_main_mem_op_b = FF(1), .avm_main_mem_op_c = FF(1), @@ -178,7 +177,7 @@ void AvmTraceBuilder::op_sub( FF c = tag_match ? alu_trace_builder.op_sub(a, b, in_tag, clk) : FF(0); // Write into memory value c from intermediate register ic. - mem_trace_builder.write_into_memory(clk, IntermRegister::IC, res.direct_dst_offset, c, in_tag, in_tag); + mem_trace_builder.write_into_memory(clk, IntermRegister::IC, res.direct_c_offset, c, in_tag, in_tag); main_trace.push_back(Row{ .avm_main_clk = clk, @@ -194,7 +193,7 @@ void AvmTraceBuilder::op_sub( .avm_main_internal_return_ptr = FF(internal_return_ptr), .avm_main_mem_idx_a = FF(res.direct_a_offset), .avm_main_mem_idx_b = FF(res.direct_b_offset), - .avm_main_mem_idx_c = FF(res.direct_dst_offset), + .avm_main_mem_idx_c = FF(res.direct_c_offset), .avm_main_mem_op_a = FF(1), .avm_main_mem_op_b = FF(1), .avm_main_mem_op_c = FF(1), @@ -241,7 +240,7 @@ void AvmTraceBuilder::op_mul( FF c = tag_match ? alu_trace_builder.op_mul(a, b, in_tag, clk) : FF(0); // Write into memory value c from intermediate register ic. - mem_trace_builder.write_into_memory(clk, IntermRegister::IC, res.direct_dst_offset, c, in_tag, in_tag); + mem_trace_builder.write_into_memory(clk, IntermRegister::IC, res.direct_c_offset, c, in_tag, in_tag); main_trace.push_back(Row{ .avm_main_clk = clk, @@ -257,7 +256,7 @@ void AvmTraceBuilder::op_mul( .avm_main_internal_return_ptr = FF(internal_return_ptr), .avm_main_mem_idx_a = FF(res.direct_a_offset), .avm_main_mem_idx_b = FF(res.direct_b_offset), - .avm_main_mem_idx_c = FF(res.direct_dst_offset), + .avm_main_mem_idx_c = FF(res.direct_c_offset), .avm_main_mem_op_a = FF(1), .avm_main_mem_op_b = FF(1), .avm_main_mem_op_c = FF(1), @@ -313,7 +312,7 @@ void AvmTraceBuilder::op_div( } // Write into memory value c from intermediate register ic. - mem_trace_builder.write_into_memory(clk, IntermRegister::IC, res.direct_dst_offset, c, in_tag, in_tag); + mem_trace_builder.write_into_memory(clk, IntermRegister::IC, res.direct_c_offset, c, in_tag, in_tag); main_trace.push_back(Row{ .avm_main_clk = clk, @@ -330,7 +329,7 @@ void AvmTraceBuilder::op_div( .avm_main_inv = tag_match ? inv : FF(1), .avm_main_mem_idx_a = FF(res.direct_a_offset), .avm_main_mem_idx_b = FF(res.direct_b_offset), - .avm_main_mem_idx_c = FF(res.direct_dst_offset), + .avm_main_mem_idx_c = FF(res.direct_c_offset), .avm_main_mem_op_a = FF(1), .avm_main_mem_op_b = FF(1), .avm_main_mem_op_c = FF(1), @@ -444,7 +443,7 @@ void AvmTraceBuilder::op_eq( FF c = tag_match ? alu_trace_builder.op_eq(a, b, in_tag, clk) : FF(0); // Write into memory value c from intermediate register ic. - mem_trace_builder.write_into_memory(clk, IntermRegister::IC, res.direct_dst_offset, c, in_tag, AvmMemoryTag::U8); + mem_trace_builder.write_into_memory(clk, IntermRegister::IC, res.direct_c_offset, c, in_tag, AvmMemoryTag::U8); main_trace.push_back(Row{ .avm_main_clk = clk, @@ -460,7 +459,7 @@ void AvmTraceBuilder::op_eq( .avm_main_internal_return_ptr = FF(internal_return_ptr), .avm_main_mem_idx_a = FF(res.direct_a_offset), .avm_main_mem_idx_b = FF(res.direct_b_offset), - .avm_main_mem_idx_c = FF(res.direct_dst_offset), + .avm_main_mem_idx_c = FF(res.direct_c_offset), .avm_main_mem_op_a = FF(1), .avm_main_mem_op_b = FF(1), .avm_main_mem_op_c = FF(1), @@ -494,7 +493,7 @@ void AvmTraceBuilder::op_and( FF c = tag_match ? bin_trace_builder.op_and(a, b, in_tag, clk) : FF(0); // Write into memory value c from intermediate register ic. - mem_trace_builder.write_into_memory(clk, IntermRegister::IC, res.direct_dst_offset, c, in_tag, in_tag); + mem_trace_builder.write_into_memory(clk, IntermRegister::IC, res.direct_c_offset, c, in_tag, in_tag); main_trace.push_back(Row{ .avm_main_clk = clk, @@ -512,7 +511,7 @@ void AvmTraceBuilder::op_and( .avm_main_internal_return_ptr = FF(internal_return_ptr), .avm_main_mem_idx_a = FF(res.direct_a_offset), .avm_main_mem_idx_b = FF(res.direct_b_offset), - .avm_main_mem_idx_c = FF(res.direct_dst_offset), + .avm_main_mem_idx_c = FF(res.direct_c_offset), .avm_main_mem_op_a = FF(1), .avm_main_mem_op_b = FF(1), .avm_main_mem_op_c = FF(1), @@ -546,7 +545,7 @@ void AvmTraceBuilder::op_or( FF c = tag_match ? bin_trace_builder.op_or(a, b, in_tag, clk) : FF(0); // Write into memory value c from intermediate register ic. - mem_trace_builder.write_into_memory(clk, IntermRegister::IC, res.direct_dst_offset, c, in_tag, in_tag); + mem_trace_builder.write_into_memory(clk, IntermRegister::IC, res.direct_c_offset, c, in_tag, in_tag); main_trace.push_back(Row{ .avm_main_clk = clk, @@ -564,7 +563,7 @@ void AvmTraceBuilder::op_or( .avm_main_internal_return_ptr = FF(internal_return_ptr), .avm_main_mem_idx_a = FF(res.direct_a_offset), .avm_main_mem_idx_b = FF(res.direct_b_offset), - .avm_main_mem_idx_c = FF(res.direct_dst_offset), + .avm_main_mem_idx_c = FF(res.direct_c_offset), .avm_main_mem_op_a = FF(1), .avm_main_mem_op_b = FF(1), .avm_main_mem_op_c = FF(1), @@ -598,7 +597,7 @@ void AvmTraceBuilder::op_xor( FF c = tag_match ? bin_trace_builder.op_xor(a, b, in_tag, clk) : FF(0); // Write into memory value c from intermediate register ic. - mem_trace_builder.write_into_memory(clk, IntermRegister::IC, res.direct_dst_offset, c, in_tag, in_tag); + mem_trace_builder.write_into_memory(clk, IntermRegister::IC, res.direct_c_offset, c, in_tag, in_tag); main_trace.push_back(Row{ .avm_main_clk = clk, @@ -616,7 +615,7 @@ void AvmTraceBuilder::op_xor( .avm_main_internal_return_ptr = FF(internal_return_ptr), .avm_main_mem_idx_a = FF(res.direct_a_offset), .avm_main_mem_idx_b = FF(res.direct_b_offset), - .avm_main_mem_idx_c = FF(res.direct_dst_offset), + .avm_main_mem_idx_c = FF(res.direct_c_offset), .avm_main_mem_op_a = FF(1), .avm_main_mem_op_b = FF(1), .avm_main_mem_op_c = FF(1), @@ -838,6 +837,113 @@ void AvmTraceBuilder::op_mov(uint8_t indirect, uint32_t src_offset, uint32_t dst }); } +/** + * @brief Copy value and tag from a memory cell at position src_offset to the + * memory cell at position dst_offset. src_offset is a_offset if the value + * defined by cond_offset is non-zero. Otherwise, src_offset is b_offset. + * + * @param indirect A byte encoding information about indirect/direct memory access. + * @param a_offset Offset of first candidate source memory cell + * @param b_offset Offset of second candidate source memory cell + * @param cond_offset Offset of the condition determining the source offset (a_offset or b_offset) + * @param dst_offset Offset of destination memory cell + */ +void AvmTraceBuilder::op_cmov( + uint8_t indirect, uint32_t a_offset, uint32_t b_offset, uint32_t cond_offset, uint32_t dst_offset) +{ + auto const clk = static_cast(main_trace.size()); + bool tag_match = true; + uint32_t direct_a_offset = a_offset; + uint32_t direct_b_offset = b_offset; + uint32_t direct_cond_offset = cond_offset; + uint32_t direct_dst_offset = dst_offset; + + bool indirect_a_flag = is_operand_indirect(indirect, 0); + bool indirect_b_flag = is_operand_indirect(indirect, 1); + bool indirect_cond_flag = is_operand_indirect(indirect, 2); + bool indirect_dst_flag = is_operand_indirect(indirect, 3); + + if (indirect_a_flag) { + auto read_ind_a = mem_trace_builder.indirect_read_and_load_from_memory(clk, IndirectRegister::IND_A, a_offset); + direct_a_offset = uint32_t(read_ind_a.val); + tag_match = tag_match && read_ind_a.tag_match; + } + + if (indirect_b_flag) { + auto read_ind_b = mem_trace_builder.indirect_read_and_load_from_memory(clk, IndirectRegister::IND_B, b_offset); + direct_b_offset = uint32_t(read_ind_b.val); + tag_match = tag_match && read_ind_b.tag_match; + } + + if (indirect_cond_flag) { + auto read_ind_c = + mem_trace_builder.indirect_read_and_load_from_memory(clk, IndirectRegister::IND_C, cond_offset); + direct_cond_offset = uint32_t(read_ind_c.val); + tag_match = tag_match && read_ind_c.tag_match; + } + + if (indirect_dst_flag) { + auto read_ind_c = + mem_trace_builder.indirect_read_and_load_from_memory(clk, IndirectRegister::IND_C, dst_offset); + direct_dst_offset = uint32_t(read_ind_c.val); + tag_match = tag_match && read_ind_c.tag_match; + } + + // Reading from memory and loading into ia or ib without tag check. We also load the conditional value + // in ic without any tag check. + std::array const cmov_res = + mem_trace_builder.read_and_load_cmov_opcode(clk, direct_a_offset, direct_b_offset, direct_cond_offset); + + AvmMemTraceBuilder::MemEntry const& a_mem_entry = cmov_res.at(0); + AvmMemTraceBuilder::MemEntry const& b_mem_entry = cmov_res.at(1); + AvmMemTraceBuilder::MemEntry const& cond_mem_entry = cmov_res.at(2); + + const bool id_zero = cond_mem_entry.val == 0; + + auto const& val = id_zero ? b_mem_entry.val : a_mem_entry.val; + auto const& tag = id_zero ? b_mem_entry.tag : a_mem_entry.tag; + + // Write into memory from intermediate register ic. + mem_trace_builder.write_into_memory(clk, IntermRegister::IC, direct_dst_offset, val, tag, tag); + + FF const inv = !id_zero ? cond_mem_entry.val.invert() : 1; + + main_trace.push_back(Row{ + .avm_main_clk = clk, + .avm_main_ia = a_mem_entry.val, + .avm_main_ib = b_mem_entry.val, + .avm_main_ic = val, + .avm_main_id = cond_mem_entry.val, + .avm_main_id_zero = static_cast(id_zero), + .avm_main_ind_a = indirect_a_flag ? a_offset : 0, + .avm_main_ind_b = indirect_b_flag ? b_offset : 0, + .avm_main_ind_c = indirect_dst_flag ? dst_offset : 0, + .avm_main_ind_d = indirect_cond_flag ? cond_offset : 0, + .avm_main_ind_op_a = static_cast(indirect_a_flag), + .avm_main_ind_op_b = static_cast(indirect_b_flag), + .avm_main_ind_op_c = static_cast(indirect_dst_flag), + .avm_main_ind_op_d = static_cast(indirect_cond_flag), + .avm_main_internal_return_ptr = internal_return_ptr, + .avm_main_inv = inv, + .avm_main_mem_idx_a = direct_a_offset, + .avm_main_mem_idx_b = direct_b_offset, + .avm_main_mem_idx_c = direct_dst_offset, + .avm_main_mem_idx_d = direct_cond_offset, + .avm_main_mem_op_a = 1, + .avm_main_mem_op_b = 1, + .avm_main_mem_op_c = 1, + .avm_main_mem_op_d = 1, + .avm_main_pc = pc++, + .avm_main_r_in_tag = static_cast(tag), + .avm_main_rwc = 1, + .avm_main_sel_mov = 1, + .avm_main_sel_mov_a = static_cast(!id_zero), + .avm_main_sel_mov_b = static_cast(id_zero), + .avm_main_tag_err = static_cast(!tag_match), + .avm_main_w_in_tag = static_cast(tag), + }); +} + /** * @brief CALLDATACOPY opcode with direct or indirect memory access, i.e., * direct: M[dst_offset:dst_offset+copy_size] = calldata[cd_offset:cd_offset+copy_size] @@ -1269,6 +1375,7 @@ std::vector AvmTraceBuilder::finalize() dest.avm_mem_tag_err = FF(static_cast(src.m_tag_err)); dest.avm_mem_one_min_inv = src.m_one_min_inv; dest.avm_mem_sel_mov_a = FF(static_cast(src.m_sel_mov_a)); + dest.avm_mem_sel_mov_b = FF(static_cast(src.m_sel_mov_b)); dest.incl_mem_tag_err_counts = FF(static_cast(src.m_tag_err_count_relevant)); @@ -1437,16 +1544,6 @@ std::vector AvmTraceBuilder::finalize() } } - // Deriving redundant selectors/tags for the main trace. - for (Row& r : main_trace) { - if ((r.avm_main_sel_op_add == FF(1) || r.avm_main_sel_op_sub == FF(1) || r.avm_main_sel_op_mul == FF(1) || - r.avm_main_sel_op_eq == FF(1) || r.avm_main_sel_op_not == FF(1) || r.avm_main_sel_op_lt || - r.avm_main_sel_op_lte) && - r.avm_main_tag_err == FF(0)) { - r.avm_main_alu_sel = FF(1); - } - } - // Add Binary Trace table for (size_t i = 0; i < bin_trace_size; i++) { auto const& src = bin_trace.at(i); 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 4d65afdc45c..c4e72a0c3ff 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp @@ -68,6 +68,10 @@ class AvmTraceBuilder { // Move (copy) the value and tag of a memory cell to another one. void op_mov(uint8_t indirect, uint32_t src_offset, uint32_t dst_offset); + // Move (copy) the value and tag of a memory cell to another one whereby the source + // is determined conditionally based on a conditional value determined by cond_offset. + void op_cmov(uint8_t indirect, uint32_t a_offset, uint32_t b_offset, uint32_t cond_offset, uint32_t dst_offset); + // Jump to a given program counter. void jump(uint32_t jmp_dest); @@ -101,7 +105,7 @@ class AvmTraceBuilder { bool tag_match = false; uint32_t direct_a_offset; uint32_t direct_b_offset; - uint32_t direct_dst_offset; + uint32_t direct_c_offset; bool indirect_flag_a = false; bool indirect_flag_b = false; @@ -118,7 +122,7 @@ class AvmTraceBuilder { void finalise_mem_trace_lookup_counts(); IndirectThreeResolution resolve_ind_three( - uint32_t clk, uint8_t indirect, uint32_t a_offset, uint32_t b_offset, uint32_t dst_offset); + uint32_t clk, uint8_t indirect, uint32_t a_offset, uint32_t b_offset, uint32_t c_offset); uint32_t pc = 0; uint32_t internal_return_ptr = CALLSTACK_OFFSET; From 089f200da24246ecbf7ea4c4d97a492fa09420f1 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Fri, 5 Apr 2024 11:38:37 +0000 Subject: [PATCH 4/9] 5557: several bug fixes for CMOV opcode and first unit test --- barretenberg/cpp/pil/avm/avm_main.pil | 18 ++++-- barretenberg/cpp/pil/avm/avm_mem.pil | 13 +++- .../relations/generated/avm/avm_mem.hpp | 61 +++++++++++++------ .../relations/generated/avm/declare_views.hpp | 2 + .../generated/avm/perm_main_mem_a.hpp | 10 ++- .../generated/avm/perm_main_mem_b.hpp | 10 ++- .../generated/avm/perm_main_mem_d.hpp | 10 ++- .../barretenberg/vm/avm_trace/avm_common.hpp | 4 +- .../vm/avm_trace/avm_mem_trace.cpp | 28 ++++++--- .../vm/avm_trace/avm_mem_trace.hpp | 1 + .../barretenberg/vm/avm_trace/avm_trace.cpp | 18 ++++-- .../vm/generated/avm_circuit_builder.hpp | 9 +++ .../barretenberg/vm/generated/avm_flavor.hpp | 26 ++++++++ .../vm/generated/avm_verifier.cpp | 4 ++ .../vm/tests/avm_mem_opcodes.test.cpp | 26 ++++++++ 15 files changed, 189 insertions(+), 51 deletions(-) diff --git a/barretenberg/cpp/pil/avm/avm_main.pil b/barretenberg/cpp/pil/avm/avm_main.pil index ad54ff61140..d491662c0fb 100644 --- a/barretenberg/cpp/pil/avm/avm_main.pil +++ b/barretenberg/cpp/pil/avm/avm_main.pil @@ -325,14 +325,18 @@ namespace avm_main(256); avm_binary.start {avm_binary.clk, avm_binary.acc_ia, avm_binary.acc_ib, avm_binary.acc_ic, avm_binary.op_id, avm_binary.in_tag}; #[PERM_MAIN_MEM_A] - mem_op_a {clk, mem_idx_a, ia, rwa, r_in_tag, w_in_tag, sel_mov_a} + mem_op_a {clk, mem_idx_a, ia, rwa + , r_in_tag, w_in_tag, sel_mov_a, sel_cmov} is - avm_mem.op_a {avm_mem.clk, avm_mem.addr, avm_mem.val, avm_mem.rw, avm_mem.r_in_tag, avm_mem.w_in_tag, avm_mem.sel_mov_a}; + avm_mem.op_a {avm_mem.clk, avm_mem.addr, avm_mem.val, avm_mem.rw + , avm_mem.r_in_tag, avm_mem.w_in_tag, avm_mem.sel_mov_a, avm_mem.sel_cmov}; #[PERM_MAIN_MEM_B] - mem_op_b {clk, mem_idx_b, ib, rwb, r_in_tag, w_in_tag, sel_mov_b} + mem_op_b {clk, mem_idx_b, ib, rwb + , r_in_tag, w_in_tag, sel_mov_b, sel_cmov} is - avm_mem.op_b {avm_mem.clk, avm_mem.addr, avm_mem.val, avm_mem.rw, avm_mem.r_in_tag, avm_mem.w_in_tag, avm_mem.sel_mov_b}; + avm_mem.op_b {avm_mem.clk, avm_mem.addr, avm_mem.val, avm_mem.rw + , avm_mem.r_in_tag, avm_mem.w_in_tag, avm_mem.sel_mov_b, avm_mem.sel_cmov}; #[PERM_MAIN_MEM_C] mem_op_c {clk, mem_idx_c, ic, rwc, r_in_tag, w_in_tag} @@ -340,9 +344,11 @@ namespace avm_main(256); avm_mem.op_c {avm_mem.clk, avm_mem.addr, avm_mem.val, avm_mem.rw, avm_mem.r_in_tag, avm_mem.w_in_tag}; #[PERM_MAIN_MEM_D] - mem_op_d {clk, mem_idx_d, id, rwd, r_in_tag, w_in_tag} + mem_op_d {clk, mem_idx_d, id, rwd + , r_in_tag, w_in_tag, sel_cmov} is - avm_mem.op_d {avm_mem.clk, avm_mem.addr, avm_mem.val, avm_mem.rw, avm_mem.r_in_tag, avm_mem.w_in_tag}; + avm_mem.op_d {avm_mem.clk, avm_mem.addr, avm_mem.val, avm_mem.rw + , avm_mem.r_in_tag, avm_mem.w_in_tag, avm_mem.sel_cmov}; #[PERM_MAIN_MEM_IND_A] ind_op_a {clk, ind_a, mem_idx_a} is avm_mem.ind_op_a {avm_mem.clk, avm_mem.addr, avm_mem.val}; diff --git a/barretenberg/cpp/pil/avm/avm_mem.pil b/barretenberg/cpp/pil/avm/avm_mem.pil index d2d780b91e5..50151a5e4b3 100644 --- a/barretenberg/cpp/pil/avm/avm_mem.pil +++ b/barretenberg/cpp/pil/avm/avm_mem.pil @@ -15,6 +15,8 @@ namespace avm_mem(256); pol commit r_in_tag; // Instruction memory tag ("foreign key" pointing to avm_main.r_in_tag) pol commit w_in_tag; // Instruction memory tag ("foreign key" pointing to avm_main.w_in_tag) + pol commit skip_check_tag; // A boolean value which relaxes the consistency check in memory + // trace between tag and r_in_tag. Required for CMOV opcode. // Indicator of the intermediate register pertaining to the memory operation (foreign key to avm_main.mem_op_XXX) pol commit op_a; @@ -28,10 +30,11 @@ namespace avm_mem(256); pol commit ind_op_c; pol commit ind_op_d; - // Selectors for MOV/CMOV opcodes (copied from main trace for loading operation on intermediated register ia/ib) + // Selectors related to MOV/CMOV opcodes (copied from main trace for loading operation on intermediated register ia/ib) // Boolean constraint is performed in main trace. pol commit sel_mov_a; pol commit sel_mov_b; + pol commit sel_cmov; // Error columns pol commit tag_err; // Boolean (1 if r_in_tag != tag is detected) @@ -111,6 +114,9 @@ namespace avm_mem(256); #[MEM_ZERO_INIT] lastAccess * (1 - rw') * val' = 0; + // Skip check tag + skip_check_tag = sel_cmov * (op_d + op_a * (1-sel_mov_a) + op_b * (1-sel_mov_b)); + // Memory tag consistency check for load operations, i.e., rw == 0. // We want to prove that r_in_tag == tag <==> tag_err == 0 // We want to show that we can invert (r_in_tag - tag) when tag_err == 1, @@ -125,10 +131,13 @@ namespace avm_mem(256); // The new column one_min_inv is set to 1 - (r_in_tag - tag)^(-1) when tag_err == 1 // but must be set to 0 when tags are matching and tag_err = 0 #[MEM_IN_TAG_CONSISTENCY_1] - (1 - rw) * ((r_in_tag - tag) * (1 - one_min_inv) - tag_err) = 0; + (1 - skip_check_tag) * (1 - rw) * ((r_in_tag - tag) * (1 - one_min_inv) - tag_err) = 0; #[MEM_IN_TAG_CONSISTENCY_2] (1 - tag_err) * one_min_inv = 0; + #[NO_TAG_ERR_WRITE_OR_SKIP] + (skip_check_tag + rw) * tag_err = 0; + // Correctness of two above checks MEM_IN_TAG_CONSISTENCY_1/2 (assuming rw == 0): // r_in_tag == tag ==> tag_err == 0 (first relation) // tag_err == 0 ==> one_min_inv == 0 by second relation. First relation ==> r_in_tag - tag == 0 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 dfcf10ce470..ac4bea88629 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_mem.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_mem.hpp @@ -23,8 +23,10 @@ template struct Avm_memRow { FF avm_mem_r_in_tag{}; 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_sub_clk{}; FF avm_mem_tag{}; FF avm_mem_tag_err{}; @@ -49,16 +51,19 @@ inline std::string get_relation_label_avm_mem(int index) case 17: return "MEM_ZERO_INIT"; - case 18: + case 19: return "MEM_IN_TAG_CONSISTENCY_1"; - case 19: + case 20: return "MEM_IN_TAG_CONSISTENCY_2"; case 21: + return "NO_TAG_ERR_WRITE_OR_SKIP"; + + case 23: return "NO_TAG_ERR_WRITE"; - case 30: + case 32: return "MOV_SAME_TAG"; } return std::to_string(index); @@ -68,8 +73,8 @@ 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, 3, 4, 3, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 4, 4, 4, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, }; template @@ -246,8 +251,9 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(18); - auto tmp = ((-avm_mem_rw + FF(1)) * - (((avm_mem_r_in_tag - avm_mem_tag) * (-avm_mem_one_min_inv + FF(1))) - avm_mem_tag_err)); + 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<18>(evals) += tmp; } @@ -255,7 +261,8 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(19); - auto tmp = ((-avm_mem_tag_err + FF(1)) * avm_mem_one_min_inv); + 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<19>(evals) += tmp; } @@ -263,7 +270,7 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(20); - auto tmp = (avm_mem_rw * (avm_mem_w_in_tag - avm_mem_tag)); + auto tmp = ((-avm_mem_tag_err + FF(1)) * avm_mem_one_min_inv); tmp *= scaling_factor; std::get<20>(evals) += tmp; } @@ -271,7 +278,7 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(21); - auto tmp = (avm_mem_rw * avm_mem_tag_err); + auto tmp = ((avm_mem_skip_check_tag + avm_mem_rw) * avm_mem_tag_err); tmp *= scaling_factor; std::get<21>(evals) += tmp; } @@ -279,7 +286,7 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(22); - auto tmp = (avm_mem_ind_op_a * (avm_mem_r_in_tag - FF(3))); + auto tmp = (avm_mem_rw * (avm_mem_w_in_tag - avm_mem_tag)); tmp *= scaling_factor; std::get<22>(evals) += tmp; } @@ -287,7 +294,7 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(23); - auto tmp = (avm_mem_ind_op_b * (avm_mem_r_in_tag - FF(3))); + auto tmp = (avm_mem_rw * avm_mem_tag_err); tmp *= scaling_factor; std::get<23>(evals) += tmp; } @@ -295,7 +302,7 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(24); - auto tmp = (avm_mem_ind_op_c * (avm_mem_r_in_tag - FF(3))); + auto tmp = (avm_mem_ind_op_a * (avm_mem_r_in_tag - FF(3))); tmp *= scaling_factor; std::get<24>(evals) += tmp; } @@ -303,7 +310,7 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(25); - auto tmp = (avm_mem_ind_op_d * (avm_mem_r_in_tag - FF(3))); + auto tmp = (avm_mem_ind_op_b * (avm_mem_r_in_tag - FF(3))); tmp *= scaling_factor; std::get<25>(evals) += tmp; } @@ -311,7 +318,7 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(26); - auto tmp = (avm_mem_ind_op_a * avm_mem_rw); + auto tmp = (avm_mem_ind_op_c * (avm_mem_r_in_tag - FF(3))); tmp *= scaling_factor; std::get<26>(evals) += tmp; } @@ -319,7 +326,7 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(27); - auto tmp = (avm_mem_ind_op_b * avm_mem_rw); + auto tmp = (avm_mem_ind_op_d * (avm_mem_r_in_tag - FF(3))); tmp *= scaling_factor; std::get<27>(evals) += tmp; } @@ -327,7 +334,7 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(28); - auto tmp = (avm_mem_ind_op_c * avm_mem_rw); + auto tmp = (avm_mem_ind_op_a * avm_mem_rw); tmp *= scaling_factor; std::get<28>(evals) += tmp; } @@ -335,7 +342,7 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(29); - auto tmp = (avm_mem_ind_op_d * avm_mem_rw); + auto tmp = (avm_mem_ind_op_b * avm_mem_rw); tmp *= scaling_factor; std::get<29>(evals) += tmp; } @@ -343,10 +350,26 @@ template class avm_memImpl { { Avm_DECLARE_VIEWS(30); - auto tmp = ((avm_mem_sel_mov_a + avm_mem_sel_mov_b) * avm_mem_tag_err); + auto tmp = (avm_mem_ind_op_c * avm_mem_rw); tmp *= scaling_factor; std::get<30>(evals) += tmp; } + // Contribution 31 + { + Avm_DECLARE_VIEWS(31); + + auto tmp = (avm_mem_ind_op_d * avm_mem_rw); + tmp *= scaling_factor; + std::get<31>(evals) += tmp; + } + // Contribution 32 + { + Avm_DECLARE_VIEWS(32); + + auto tmp = ((avm_mem_sel_mov_a + avm_mem_sel_mov_b) * avm_mem_tag_err); + tmp *= scaling_factor; + std::get<32>(evals) += tmp; + } } }; 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 dda9cad3d47..168d0b96d07 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/declare_views.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/declare_views.hpp @@ -153,8 +153,10 @@ [[maybe_unused]] auto avm_mem_op_d = View(new_term.avm_mem_op_d); \ [[maybe_unused]] auto avm_mem_r_in_tag = View(new_term.avm_mem_r_in_tag); \ [[maybe_unused]] auto avm_mem_rw = View(new_term.avm_mem_rw); \ + [[maybe_unused]] auto avm_mem_sel_cmov = View(new_term.avm_mem_sel_cmov); \ [[maybe_unused]] auto avm_mem_sel_mov_a = View(new_term.avm_mem_sel_mov_a); \ [[maybe_unused]] auto avm_mem_sel_mov_b = View(new_term.avm_mem_sel_mov_b); \ + [[maybe_unused]] auto avm_mem_skip_check_tag = View(new_term.avm_mem_skip_check_tag); \ [[maybe_unused]] auto avm_mem_sub_clk = View(new_term.avm_mem_sub_clk); \ [[maybe_unused]] auto avm_mem_tag = View(new_term.avm_mem_tag); \ [[maybe_unused]] auto avm_mem_tag_err = View(new_term.avm_mem_tag_err); \ 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 960d2e8d31e..fb2a35e3ce0 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 @@ -12,7 +12,7 @@ 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 = 7; + 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 @@ -57,13 +57,15 @@ class perm_main_mem_a_permutation_settings { 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_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_mov_a, + in.avm_mem_sel_cmov); } /** @@ -97,13 +99,15 @@ class perm_main_mem_a_permutation_settings { 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_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_mov_a, + in.avm_mem_sel_cmov); } }; 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 776578f0c5c..0cedcf27b6c 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 @@ -12,7 +12,7 @@ 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 = 7; + 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 @@ -57,13 +57,15 @@ class perm_main_mem_b_permutation_settings { 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_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_mov_b, + in.avm_mem_sel_cmov); } /** @@ -97,13 +99,15 @@ class perm_main_mem_b_permutation_settings { 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_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_mov_b, + in.avm_mem_sel_cmov); } }; 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 309221775d6..389b6f2d880 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 @@ -12,7 +12,7 @@ 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 = 6; + 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 @@ -56,12 +56,14 @@ class perm_main_mem_d_permutation_settings { 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_addr, in.avm_mem_val, in.avm_mem_rw, in.avm_mem_r_in_tag, - in.avm_mem_w_in_tag); + in.avm_mem_w_in_tag, + in.avm_mem_sel_cmov); } /** @@ -94,12 +96,14 @@ class perm_main_mem_d_permutation_settings { 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_addr, in.avm_mem_val, in.avm_mem_rw, in.avm_mem_r_in_tag, - in.avm_mem_w_in_tag); + in.avm_mem_w_in_tag, + in.avm_mem_sel_cmov); } }; 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 04ed5dc05d6..a0261419281 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_common.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_common.hpp @@ -13,8 +13,8 @@ using Row = bb::AvmFullRow; // Number of rows static const size_t AVM_TRACE_SIZE = 1 << 18; -enum class IntermRegister : uint32_t { IA = 0, IB = 1, IC = 2 }; -enum class IndirectRegister : uint32_t { IND_A = 0, IND_B = 1, IND_C = 2 }; +enum class IntermRegister : uint32_t { IA = 0, IB = 1, IC = 2, ID = 3 }; +enum class IndirectRegister : uint32_t { IND_A = 0, IND_B = 1, IND_C = 2, IND_D = 3 }; // Keep following enum in sync with MAX_NEM_TAG below enum class AvmMemoryTag : uint32_t { U0 = 0, U8 = 1, U16 = 2, U32 = 3, U64 = 4, U128 = 5, FF = 6 }; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.cpp index 4a2a622e6b1..00b7b0bc1a6 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.cpp @@ -170,6 +170,9 @@ void AvmMemTraceBuilder::store_in_mem_trace( case IntermRegister::IC: sub_clk = SUB_CLK_STORE_C; break; + case IntermRegister::ID: + sub_clk = SUB_CLK_STORE_D; + break; } insert_in_mem_trace(clk, sub_clk, addr, val, w_in_tag, r_in_tag, w_in_tag, true); @@ -217,15 +220,18 @@ std::array AvmMemTraceBuilder::read_and_load_cm bool mov_b = cond_mem_entry.val == 0; + AvmMemoryTag r_w_in_tag = mov_b ? b_mem_entry.tag : a_mem_entry.tag; + mem_trace.emplace_back(MemoryTraceEntry{ .m_clk = clk, .m_sub_clk = SUB_CLK_LOAD_A, .m_addr = a_addr, .m_val = a_mem_entry.val, .m_tag = a_mem_entry.tag, - .r_in_tag = a_mem_entry.tag, - .w_in_tag = a_mem_entry.tag, + .r_in_tag = r_w_in_tag, + .w_in_tag = r_w_in_tag, .m_sel_mov_a = !mov_b, + .m_sel_cmov = true, }); mem_trace.emplace_back(MemoryTraceEntry{ @@ -234,19 +240,21 @@ std::array AvmMemTraceBuilder::read_and_load_cm .m_addr = b_addr, .m_val = b_mem_entry.val, .m_tag = b_mem_entry.tag, - .r_in_tag = b_mem_entry.tag, - .w_in_tag = b_mem_entry.tag, + .r_in_tag = r_w_in_tag, + .w_in_tag = r_w_in_tag, .m_sel_mov_b = mov_b, + .m_sel_cmov = true, }); mem_trace.emplace_back(MemoryTraceEntry{ .m_clk = clk, - .m_sub_clk = SUB_CLK_LOAD_C, + .m_sub_clk = SUB_CLK_LOAD_D, .m_addr = cond_addr, .m_val = cond_mem_entry.val, .m_tag = cond_mem_entry.tag, - .r_in_tag = cond_mem_entry.tag, - .w_in_tag = cond_mem_entry.tag, + .r_in_tag = r_w_in_tag, + .w_in_tag = r_w_in_tag, + .m_sel_cmov = true, }); return { a_mem_entry, b_mem_entry, cond_mem_entry }; @@ -283,6 +291,9 @@ AvmMemTraceBuilder::MemRead AvmMemTraceBuilder::read_and_load_from_memory(uint32 case IntermRegister::IC: sub_clk = SUB_CLK_LOAD_C; break; + case IntermRegister::ID: + sub_clk = SUB_CLK_LOAD_D; + break; } FF val = memory.contains(addr) ? memory.at(addr).val : 0; @@ -309,6 +320,9 @@ AvmMemTraceBuilder::MemRead AvmMemTraceBuilder::indirect_read_and_load_from_memo case IndirectRegister::IND_C: sub_clk = SUB_CLK_IND_LOAD_C; break; + case IndirectRegister::IND_D: + sub_clk = SUB_CLK_IND_LOAD_D; + break; } FF val = memory.contains(addr) ? memory.at(addr).val : 0; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.hpp index 6f5624935d4..31bc2e4b915 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_mem_trace.hpp @@ -38,6 +38,7 @@ class AvmMemTraceBuilder { FF m_one_min_inv{}; bool m_sel_mov_a = false; bool m_sel_mov_b = false; + bool m_sel_cmov = false; bool m_tag_err_count_relevant = false; /** 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 74e7f17958a..5dded97a92d 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp @@ -876,10 +876,10 @@ void AvmTraceBuilder::op_cmov( } if (indirect_cond_flag) { - auto read_ind_c = - mem_trace_builder.indirect_read_and_load_from_memory(clk, IndirectRegister::IND_C, cond_offset); - direct_cond_offset = uint32_t(read_ind_c.val); - tag_match = tag_match && read_ind_c.tag_match; + auto read_ind_d = + mem_trace_builder.indirect_read_and_load_from_memory(clk, IndirectRegister::IND_D, cond_offset); + direct_cond_offset = uint32_t(read_ind_d.val); + tag_match = tag_match && read_ind_d.tag_match; } if (indirect_dst_flag) { @@ -890,7 +890,7 @@ void AvmTraceBuilder::op_cmov( } // Reading from memory and loading into ia or ib without tag check. We also load the conditional value - // in ic without any tag check. + // in id without any tag check. std::array const cmov_res = mem_trace_builder.read_and_load_cmov_opcode(clk, direct_a_offset, direct_b_offset, direct_cond_offset); @@ -936,7 +936,7 @@ void AvmTraceBuilder::op_cmov( .avm_main_pc = pc++, .avm_main_r_in_tag = static_cast(tag), .avm_main_rwc = 1, - .avm_main_sel_mov = 1, + .avm_main_sel_cmov = 1, .avm_main_sel_mov_a = static_cast(!id_zero), .avm_main_sel_mov_b = static_cast(id_zero), .avm_main_tag_err = static_cast(!tag_match), @@ -1376,6 +1376,7 @@ std::vector AvmTraceBuilder::finalize() dest.avm_mem_one_min_inv = src.m_one_min_inv; dest.avm_mem_sel_mov_a = FF(static_cast(src.m_sel_mov_a)); dest.avm_mem_sel_mov_b = FF(static_cast(src.m_sel_mov_b)); + dest.avm_mem_sel_cmov = FF(static_cast(src.m_sel_cmov)); dest.incl_mem_tag_err_counts = FF(static_cast(src.m_tag_err_count_relevant)); @@ -1412,6 +1413,11 @@ std::vector AvmTraceBuilder::finalize() break; } + if (src.m_sel_cmov) { + dest.avm_mem_skip_check_tag = dest.avm_mem_op_d + dest.avm_mem_op_a * (-dest.avm_mem_sel_mov_a + 1) + + dest.avm_mem_op_b * (-dest.avm_mem_sel_mov_b + 1); + } + if (i + 1 < mem_trace_size) { auto const& next = mem_trace.at(i + 1); dest.avm_mem_lastAccess = FF(static_cast(src.m_addr != next.m_addr)); 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 0c1a1378978..4fa1f9c6e78 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp @@ -202,8 +202,10 @@ template struct AvmFullRow { FF avm_mem_op_d{}; FF avm_mem_r_in_tag{}; FF avm_mem_rw{}; + 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_sub_clk{}; FF avm_mem_tag{}; FF avm_mem_tag_err{}; @@ -302,6 +304,7 @@ class AvmCircuitBuilder { using Polynomial = Flavor::Polynomial; using ProverPolynomials = Flavor::ProverPolynomials; +<<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD static constexpr size_t num_fixed_columns = 224; @@ -314,6 +317,10 @@ class AvmCircuitBuilder { static constexpr size_t num_fixed_columns = 174; static constexpr size_t num_polys = 155; >>>>>>> 220457275 (5557: PIL relations for CMOV opcode) +======= + static constexpr size_t num_fixed_columns = 176; + static constexpr size_t num_polys = 157; +>>>>>>> bdc8f5a57 (5557: several bug fixes for CMOV opcode and first unit test) std::vector rows; void set_trace(std::vector&& trace) { rows = std::move(trace); } @@ -480,8 +487,10 @@ class AvmCircuitBuilder { polys.avm_mem_op_d[i] = rows[i].avm_mem_op_d; polys.avm_mem_r_in_tag[i] = rows[i].avm_mem_r_in_tag; polys.avm_mem_rw[i] = rows[i].avm_mem_rw; + polys.avm_mem_sel_cmov[i] = rows[i].avm_mem_sel_cmov; polys.avm_mem_sel_mov_a[i] = rows[i].avm_mem_sel_mov_a; polys.avm_mem_sel_mov_b[i] = rows[i].avm_mem_sel_mov_b; + polys.avm_mem_skip_check_tag[i] = rows[i].avm_mem_skip_check_tag; polys.avm_mem_sub_clk[i] = rows[i].avm_mem_sub_clk; polys.avm_mem_tag[i] = rows[i].avm_mem_tag; polys.avm_mem_tag_err[i] = rows[i].avm_mem_tag_err; diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp index de3e7b95af2..4df9111ecc9 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp @@ -70,6 +70,7 @@ class AvmFlavor { static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 2; <<<<<<< HEAD +<<<<<<< HEAD <<<<<<< HEAD static constexpr size_t NUM_WITNESS_ENTITIES = 193; static constexpr size_t NUM_WIRES = NUM_WITNESS_ENTITIES + NUM_PRECOMPUTED_ENTITIES; @@ -90,6 +91,13 @@ class AvmFlavor { // the unshifted and one for the shifted static constexpr size_t NUM_ALL_ENTITIES = 174; >>>>>>> 220457275 (5557: PIL relations for CMOV opcode) +======= + static constexpr size_t NUM_WITNESS_ENTITIES = 155; + 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 = 176; +>>>>>>> bdc8f5a57 (5557: several bug fixes for CMOV opcode and first unit test) using GrandProductRelations = std::tuple, perm_main_bin_relation, @@ -348,8 +356,10 @@ class AvmFlavor { avm_mem_op_d, avm_mem_r_in_tag, avm_mem_rw, + avm_mem_sel_cmov, avm_mem_sel_mov_a, avm_mem_sel_mov_b, + avm_mem_skip_check_tag, avm_mem_sub_clk, avm_mem_tag, avm_mem_tag_err, @@ -559,8 +569,10 @@ class AvmFlavor { avm_mem_op_d, avm_mem_r_in_tag, avm_mem_rw, + avm_mem_sel_cmov, avm_mem_sel_mov_a, avm_mem_sel_mov_b, + avm_mem_skip_check_tag, avm_mem_sub_clk, avm_mem_tag, avm_mem_tag_err, @@ -775,8 +787,10 @@ class AvmFlavor { avm_mem_op_d, avm_mem_r_in_tag, avm_mem_rw, + avm_mem_sel_cmov, avm_mem_sel_mov_a, avm_mem_sel_mov_b, + avm_mem_skip_check_tag, avm_mem_sub_clk, avm_mem_tag, avm_mem_tag_err, @@ -1017,8 +1031,10 @@ class AvmFlavor { avm_mem_op_d, avm_mem_r_in_tag, avm_mem_rw, + avm_mem_sel_cmov, avm_mem_sel_mov_a, avm_mem_sel_mov_b, + avm_mem_skip_check_tag, avm_mem_sub_clk, avm_mem_tag, avm_mem_tag_err, @@ -1259,8 +1275,10 @@ class AvmFlavor { avm_mem_op_d, avm_mem_r_in_tag, avm_mem_rw, + avm_mem_sel_cmov, avm_mem_sel_mov_a, avm_mem_sel_mov_b, + avm_mem_skip_check_tag, avm_mem_sub_clk, avm_mem_tag, avm_mem_tag_err, @@ -1674,8 +1692,10 @@ class AvmFlavor { Base::avm_mem_op_d = "AVM_MEM_OP_D"; Base::avm_mem_r_in_tag = "AVM_MEM_R_IN_TAG"; Base::avm_mem_rw = "AVM_MEM_RW"; + Base::avm_mem_sel_cmov = "AVM_MEM_SEL_CMOV"; Base::avm_mem_sel_mov_a = "AVM_MEM_SEL_MOV_A"; Base::avm_mem_sel_mov_b = "AVM_MEM_SEL_MOV_B"; + Base::avm_mem_skip_check_tag = "AVM_MEM_SKIP_CHECK_TAG"; Base::avm_mem_sub_clk = "AVM_MEM_SUB_CLK"; Base::avm_mem_tag = "AVM_MEM_TAG"; Base::avm_mem_tag_err = "AVM_MEM_TAG_ERR"; @@ -1901,8 +1921,10 @@ class AvmFlavor { Commitment avm_mem_op_d; Commitment avm_mem_r_in_tag; Commitment avm_mem_rw; + Commitment avm_mem_sel_cmov; Commitment avm_mem_sel_mov_a; Commitment avm_mem_sel_mov_b; + Commitment avm_mem_skip_check_tag; Commitment avm_mem_sub_clk; Commitment avm_mem_tag; Commitment avm_mem_tag_err; @@ -2136,8 +2158,10 @@ class AvmFlavor { avm_mem_op_d = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_mem_r_in_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_mem_rw = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_mem_sel_cmov = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_mem_sel_mov_a = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_mem_sel_mov_b = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_mem_skip_check_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_mem_sub_clk = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_mem_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_mem_tag_err = deserialize_from_buffer(Transcript::proof_data, num_frs_read); @@ -2367,8 +2391,10 @@ class AvmFlavor { serialize_to_buffer(avm_mem_op_d, Transcript::proof_data); serialize_to_buffer(avm_mem_r_in_tag, Transcript::proof_data); serialize_to_buffer(avm_mem_rw, Transcript::proof_data); + serialize_to_buffer(avm_mem_sel_cmov, Transcript::proof_data); serialize_to_buffer(avm_mem_sel_mov_a, Transcript::proof_data); serialize_to_buffer(avm_mem_sel_mov_b, Transcript::proof_data); + serialize_to_buffer(avm_mem_skip_check_tag, Transcript::proof_data); serialize_to_buffer(avm_mem_sub_clk, Transcript::proof_data); serialize_to_buffer(avm_mem_tag, Transcript::proof_data); serialize_to_buffer(avm_mem_tag_err, Transcript::proof_data); diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp index b938622b8be..af8ca4217c8 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp @@ -289,10 +289,14 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) commitments.avm_mem_r_in_tag = transcript->template receive_from_prover(commitment_labels.avm_mem_r_in_tag); commitments.avm_mem_rw = transcript->template receive_from_prover(commitment_labels.avm_mem_rw); + commitments.avm_mem_sel_cmov = + transcript->template receive_from_prover(commitment_labels.avm_mem_sel_cmov); commitments.avm_mem_sel_mov_a = transcript->template receive_from_prover(commitment_labels.avm_mem_sel_mov_a); commitments.avm_mem_sel_mov_b = transcript->template receive_from_prover(commitment_labels.avm_mem_sel_mov_b); + commitments.avm_mem_skip_check_tag = + transcript->template receive_from_prover(commitment_labels.avm_mem_skip_check_tag); commitments.avm_mem_sub_clk = transcript->template receive_from_prover(commitment_labels.avm_mem_sub_clk); commitments.avm_mem_tag = transcript->template receive_from_prover(commitment_labels.avm_mem_tag); diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_mem_opcodes.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_mem_opcodes.test.cpp index 2d89a8ab429..986aa607818 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_mem_opcodes.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_mem_opcodes.test.cpp @@ -173,6 +173,10 @@ class AvmMemOpcodeNegativeTests : public AvmMemOpcodeTests {}; * ******************************************************************************/ +/****************************************************************************** + * MOV Opcode + ******************************************************************************/ + TEST_F(AvmMemOpcodeTests, basicMov) { build_mov_trace(false, 42, 9, 13, AvmMemoryTag::U64); @@ -235,6 +239,28 @@ TEST_F(AvmMemOpcodeTests, indirectMovInvalidAddressTag) validate_trace(std::move(trace)); } +/****************************************************************************** + * CMOV Opcode + ******************************************************************************/ + +TEST_F(AvmMemOpcodeTests, allDirectCMovA) +{ + trace_builder.op_set(0, 1979, 10, AvmMemoryTag::U16); // a + trace_builder.op_set(0, 1980, 11, AvmMemoryTag::U128); // b + trace_builder.op_set(0, 987162, 20, AvmMemoryTag::U64); // Non-zero condition value + trace_builder.op_set(0, 8, 12, AvmMemoryTag::U32); // Target, should be overwritten + + trace_builder.op_cmov(0, 10, 11, 20, 12); + trace_builder.return_op(0, 0, 0); + trace = trace_builder.finalize(); + + validate_trace_proof(std::move(trace)); +} + +/****************************************************************************** + * SET Opcode + ******************************************************************************/ + TEST_F(AvmMemOpcodeTests, directSet) { trace_builder.op_set(0, 5683, 99, AvmMemoryTag::U128); From c1989674d11df507790a5d28c349e938670d4d68 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Tue, 9 Apr 2024 07:47:02 +0000 Subject: [PATCH 5/9] 5557: Positive unit tests for CMOV --- .../vm/tests/avm_mem_opcodes.test.cpp | 259 +++++++++++++++++- 1 file changed, 246 insertions(+), 13 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_mem_opcodes.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_mem_opcodes.test.cpp index 986aa607818..1091a9ab6de 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_mem_opcodes.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_mem_opcodes.test.cpp @@ -19,9 +19,13 @@ class AvmMemOpcodeTests : public ::testing::Test { std::vector trace; size_t main_idx; size_t mem_a_idx; + size_t mem_b_idx; size_t mem_c_idx; + size_t mem_d_idx; size_t mem_ind_a_idx; + size_t mem_ind_b_idx; size_t mem_ind_c_idx; + size_t mem_ind_d_idx; // TODO(640): The Standard Honk on Grumpkin test suite fails unless the SRS is initialised for every test. void SetUp() override { srs::init_crs_factory("../srs_db/ignition"); }; @@ -51,7 +55,24 @@ class AvmMemOpcodeTests : public ::testing::Test { return [clk, sub_clk](Row r) { return r.avm_mem_clk == clk && r.avm_mem_sub_clk == sub_clk; }; }; - void compute_common_indices(FF clk, bool indirect) + void compute_index_a(FF clk, bool indirect) + { + // Find the memory trace position corresponding to the load sub-operation of register ia. + auto row = + std::ranges::find_if(trace.begin(), trace.end(), gen_matcher(clk, AvmMemTraceBuilder::SUB_CLK_LOAD_A)); + ASSERT_TRUE(row != trace.end()); + mem_a_idx = static_cast(row - trace.begin()); + + // Find the memory trace position of the indirect load for register ia. + if (indirect) { + row = std::ranges::find_if( + trace.begin(), trace.end(), gen_matcher(clk, AvmMemTraceBuilder::SUB_CLK_IND_LOAD_A)); + ASSERT_TRUE(row != trace.end()); + mem_ind_a_idx = static_cast(row - trace.begin()); + } + } + + void compute_index_c(FF clk, bool indirect) { // Find the memory trace position corresponding to the write sub-operation of register ic. auto row = @@ -77,20 +98,46 @@ class AvmMemOpcodeTests : public ::testing::Test { auto clk = row->avm_main_clk; - // Find the memory trace position corresponding to the load sub-operation of register ia. - row = std::ranges::find_if(trace.begin(), trace.end(), gen_matcher(clk, AvmMemTraceBuilder::SUB_CLK_LOAD_A)); + compute_index_a(clk, indirect); + compute_index_c(clk, indirect); + } + + void compute_cmov_indices(uint8_t indirect) + { + // Find the first row enabling the CMOV selector + auto row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_cmov == FF(1); }); ASSERT_TRUE(row != trace.end()); - mem_a_idx = static_cast(row - trace.begin()); + main_idx = static_cast(row - trace.begin()); - // Find the memory trace position of the indirect load for register ia. - if (indirect) { + auto clk = row->avm_main_clk; + compute_index_a(clk, is_operand_indirect(indirect, 0)); + compute_index_c(clk, is_operand_indirect(indirect, 2)); + + // Find the memory trace position corresponding to the load sub-operation of register ib. + row = std::ranges::find_if(trace.begin(), trace.end(), gen_matcher(clk, AvmMemTraceBuilder::SUB_CLK_LOAD_B)); + ASSERT_TRUE(row != trace.end()); + mem_b_idx = static_cast(row - trace.begin()); + + // Find the memory trace position of the indirect load for register ib. + if (is_operand_indirect(indirect, 1)) { row = std::ranges::find_if( - trace.begin(), trace.end(), gen_matcher(clk, AvmMemTraceBuilder::SUB_CLK_IND_LOAD_A)); + trace.begin(), trace.end(), gen_matcher(clk, AvmMemTraceBuilder::SUB_CLK_IND_LOAD_B)); ASSERT_TRUE(row != trace.end()); - mem_ind_a_idx = static_cast(row - trace.begin()); + mem_ind_b_idx = static_cast(row - trace.begin()); } - compute_common_indices(clk, indirect); + // Find the memory trace position corresponding to the load sub-operation of register id. + row = std::ranges::find_if(trace.begin(), trace.end(), gen_matcher(clk, AvmMemTraceBuilder::SUB_CLK_LOAD_D)); + ASSERT_TRUE(row != trace.end()); + mem_d_idx = static_cast(row - trace.begin()); + + // Find the memory trace position of the indirect load for register id. + if (is_operand_indirect(indirect, 3)) { + row = std::ranges::find_if( + trace.begin(), trace.end(), gen_matcher(clk, AvmMemTraceBuilder::SUB_CLK_IND_LOAD_D)); + ASSERT_TRUE(row != trace.end()); + mem_ind_d_idx = static_cast(row - trace.begin()); + } } void validate_mov_trace(bool indirect, @@ -163,6 +210,101 @@ class AvmMemOpcodeTests : public ::testing::Test { validate_trace(std::move(trace)); } + + void common_cmov_trace_validate(bool indirect, + FF const& a, + FF const& b, + FF const& d, + uint32_t addr_a, + uint32_t addr_b, + uint32_t addr_c, + uint32_t addr_d, + AvmMemoryTag tag_a, + AvmMemoryTag tag_b, + AvmMemoryTag tag_d) + { + bool const mov_a = d != 0; + AvmMemoryTag const mov_tag = mov_a ? tag_a : tag_b; + FF const& mov_val = mov_a ? a : b; + FF const inv = mov_a ? d.invert() : 1; + + EXPECT_THAT(trace.at(main_idx), + AllOf(Field("ia", &Row::avm_main_ia, a), + Field("ib", &Row::avm_main_ib, b), + Field("ic", &Row::avm_main_ic, mov_val), + Field("id", &Row::avm_main_id, d), + Field("op_a", &Row::avm_main_mem_op_a, 1), + Field("op_b", &Row::avm_main_mem_op_b, 1), + Field("op_c", &Row::avm_main_mem_op_c, 1), + Field("op_d", &Row::avm_main_mem_op_d, 1), + Field("rwa", &Row::avm_main_rwa, 0), + Field("rwb", &Row::avm_main_rwb, 0), + Field("rwc", &Row::avm_main_rwc, 1), + Field("rwd", &Row::avm_main_rwd, 0), + Field("mem_idx_a", &Row::avm_main_mem_idx_a, addr_a), + Field("mem_idx_b", &Row::avm_main_mem_idx_b, addr_b), + Field("mem_idx_c", &Row::avm_main_mem_idx_c, addr_c), + Field("mem_idx_d", &Row::avm_main_mem_idx_d, addr_d), + Field("ind_op_a", &Row::avm_main_ind_op_a, static_cast(indirect)), + Field("ind_op_b", &Row::avm_main_ind_op_b, static_cast(indirect)), + Field("ind_op_c", &Row::avm_main_ind_op_c, static_cast(indirect)), + Field("ind_op_d", &Row::avm_main_ind_op_d, static_cast(indirect)), + Field("sel_cmov", &Row::avm_main_sel_cmov, 1), + Field("sel_mov_a", &Row::avm_main_sel_mov_a, mov_a), + Field("sel_mov_b", &Row::avm_main_sel_mov_b, !mov_a), + Field("r_in_tag", &Row::avm_main_r_in_tag, static_cast(mov_tag)), + Field("w_in_tag", &Row::avm_main_w_in_tag, static_cast(mov_tag)), + Field("inv", &Row::avm_main_inv, inv))); + + EXPECT_THAT(trace.at(mem_a_idx), + AllOf(Field("r_in_tag", &Row::avm_mem_r_in_tag, static_cast(mov_tag)), + Field("w_in_tag", &Row::avm_mem_w_in_tag, static_cast(mov_tag)), + Field("tag", &Row::avm_mem_tag, static_cast(tag_a)), + Field("sel_mov_a", &Row::avm_mem_sel_mov_a, mov_a), + Field("mem_addr", &Row::avm_mem_addr, addr_a), + Field("val", &Row::avm_mem_val, a), + Field("rw", &Row::avm_mem_rw, 0), + Field("skip_check_tag", &Row::avm_mem_skip_check_tag, mov_a ? 0 : 1), + Field("op_a", &Row::avm_mem_op_a, 1), + Field("ind_op_a", &Row::avm_mem_ind_op_a, 0))); + + EXPECT_THAT(trace.at(mem_b_idx), + AllOf(Field("r_in_tag", &Row::avm_mem_r_in_tag, static_cast(mov_tag)), + Field("w_in_tag", &Row::avm_mem_w_in_tag, static_cast(mov_tag)), + Field("tag", &Row::avm_mem_tag, static_cast(tag_b)), + Field("tag_err", &Row::avm_mem_tag_err, 0), + Field("sel_mov_b", &Row::avm_mem_sel_mov_b, !mov_a), + Field("mem_addr", &Row::avm_mem_addr, addr_b), + Field("val", &Row::avm_mem_val, b), + Field("rw", &Row::avm_mem_rw, 0), + Field("skip_check_tag", &Row::avm_mem_skip_check_tag, mov_a ? 1 : 0), + Field("op_b", &Row::avm_mem_op_b, 1), + Field("ind_op_b", &Row::avm_mem_ind_op_b, 0))); + + EXPECT_THAT(trace.at(mem_c_idx), + AllOf(Field("r_in_tag", &Row::avm_mem_r_in_tag, static_cast(mov_tag)), + Field("w_in_tag", &Row::avm_mem_w_in_tag, static_cast(mov_tag)), + Field("tag", &Row::avm_mem_tag, static_cast(mov_tag)), + Field("tag_err", &Row::avm_mem_tag_err, 0), + Field("mem_addr", &Row::avm_mem_addr, addr_c), + Field("val", &Row::avm_mem_val, mov_a ? a : b), + Field("rw", &Row::avm_mem_rw, 1), + Field("skip_check_tag", &Row::avm_mem_skip_check_tag, 0), + Field("op_c", &Row::avm_mem_op_c, 1), + Field("ind_op_c", &Row::avm_mem_ind_op_c, 0))); + + EXPECT_THAT(trace.at(mem_d_idx), + AllOf(Field("r_in_tag", &Row::avm_mem_r_in_tag, static_cast(mov_tag)), + Field("w_in_tag", &Row::avm_mem_w_in_tag, static_cast(mov_tag)), + Field("tag", &Row::avm_mem_tag, static_cast(tag_d)), + Field("tag_err", &Row::avm_mem_tag_err, 0), + Field("mem_addr", &Row::avm_mem_addr, addr_d), + Field("val", &Row::avm_mem_val, d), + Field("rw", &Row::avm_mem_rw, 0), + Field("skip_check_tag", &Row::avm_mem_skip_check_tag, 1), + Field("op_d", &Row::avm_mem_op_d, 1), + Field("ind_op_d", &Row::avm_mem_ind_op_d, 0))); + } }; class AvmMemOpcodeNegativeTests : public AvmMemOpcodeTests {}; @@ -247,13 +389,104 @@ TEST_F(AvmMemOpcodeTests, allDirectCMovA) { trace_builder.op_set(0, 1979, 10, AvmMemoryTag::U16); // a trace_builder.op_set(0, 1980, 11, AvmMemoryTag::U128); // b - trace_builder.op_set(0, 987162, 20, AvmMemoryTag::U64); // Non-zero condition value + trace_builder.op_set(0, 987162, 20, AvmMemoryTag::U64); // Non-zero condition value (we move a) trace_builder.op_set(0, 8, 12, AvmMemoryTag::U32); // Target, should be overwritten trace_builder.op_cmov(0, 10, 11, 20, 12); trace_builder.return_op(0, 0, 0); trace = trace_builder.finalize(); + compute_cmov_indices(0); + common_cmov_trace_validate( + false, 1979, 1980, 987162, 10, 11, 12, 20, AvmMemoryTag::U16, AvmMemoryTag::U128, AvmMemoryTag::U64); + validate_trace_proof(std::move(trace)); +} + +TEST_F(AvmMemOpcodeTests, allDirectCMovB) +{ + trace_builder.op_set(0, 1979, 10, AvmMemoryTag::U8); // a + trace_builder.op_set(0, 1980, 11, AvmMemoryTag::U8); // b + trace_builder.op_set(0, 0, 20, AvmMemoryTag::U64); // Zero condition value (we move b) + trace_builder.op_set(0, 8, 12, AvmMemoryTag::U32); // Target, should be overwritten + + trace_builder.op_cmov(0, 10, 11, 20, 12); + trace_builder.return_op(0, 0, 0); + trace = trace_builder.finalize(); + + compute_cmov_indices(0); + common_cmov_trace_validate( + false, 1979, 1980, 0, 10, 11, 12, 20, AvmMemoryTag::U8, AvmMemoryTag::U8, AvmMemoryTag::U64); + validate_trace_proof(std::move(trace)); +} + +TEST_F(AvmMemOpcodeTests, allDirectCMovConditionUninitialized) +{ + trace_builder.op_set(0, 1979, 10, AvmMemoryTag::U8); // a + trace_builder.op_set(0, 1980, 11, AvmMemoryTag::U8); // b + // Address 20 is unitialized and we use it as the condition + // value. It will be therefore zero. (we move b) + + trace_builder.op_cmov(0, 10, 11, 20, 12); + trace_builder.return_op(0, 0, 0); + trace = trace_builder.finalize(); + + compute_cmov_indices(0); + common_cmov_trace_validate( + false, 1979, 1980, 0, 10, 11, 12, 20, AvmMemoryTag::U8, AvmMemoryTag::U8, AvmMemoryTag::U0); + validate_trace_proof(std::move(trace)); +} + +TEST_F(AvmMemOpcodeTests, allDirectCMovOverwriteA) +{ + trace_builder.op_set(0, 1979, 10, AvmMemoryTag::U8); // a + trace_builder.op_set(0, 1980, 11, AvmMemoryTag::U8); // b + trace_builder.op_set(0, 0, 20, AvmMemoryTag::U64); // Zero condition value (we move b) + + trace_builder.op_cmov(0, 10, 11, 20, 10); + trace_builder.return_op(0, 0, 0); + trace = trace_builder.finalize(); + + compute_cmov_indices(0); + common_cmov_trace_validate( + false, 1979, 1980, 0, 10, 11, 10, 20, AvmMemoryTag::U8, AvmMemoryTag::U8, AvmMemoryTag::U64); + validate_trace_proof(std::move(trace)); +} + +TEST_F(AvmMemOpcodeTests, allIndirectCMovA) +{ + // a b c d + // Val 1979 1980 1979 987162 + // Dir Addr 10 11 12 20 + // Ind Addr 110 111 112 120 + + trace_builder.op_set(0, 10, 110, AvmMemoryTag::U32); + trace_builder.op_set(0, 11, 111, AvmMemoryTag::U32); + trace_builder.op_set(0, 12, 112, AvmMemoryTag::U32); + trace_builder.op_set(0, 20, 120, AvmMemoryTag::U32); + + trace_builder.op_set(0, 1979, 10, AvmMemoryTag::U16); // a + trace_builder.op_set(0, 1980, 11, AvmMemoryTag::U128); // b + trace_builder.op_set(0, 987162, 20, AvmMemoryTag::U64); // Non-zero condition value (we move a) + trace_builder.op_set(0, 8, 12, AvmMemoryTag::U32); // Target, should be overwritten + + trace_builder.op_cmov(15, 110, 111, 120, 112); + trace_builder.return_op(0, 0, 0); + trace = trace_builder.finalize(); + + compute_cmov_indices(15); + common_cmov_trace_validate( + true, 1979, 1980, 987162, 10, 11, 12, 20, AvmMemoryTag::U16, AvmMemoryTag::U128, AvmMemoryTag::U64); + validate_trace_proof(std::move(trace)); +} + +TEST_F(AvmMemOpcodeTests, allIndirectCMovAllUnitialized) +{ + trace_builder.op_cmov(15, 10, 11, 20, 10); + trace_builder.return_op(0, 0, 0); + trace = trace_builder.finalize(); + + compute_cmov_indices(15); + common_cmov_trace_validate(true, 0, 0, 0, 0, 0, 0, 0, AvmMemoryTag::U0, AvmMemoryTag::U0, AvmMemoryTag::U0); validate_trace_proof(std::move(trace)); } @@ -267,7 +500,7 @@ TEST_F(AvmMemOpcodeTests, directSet) trace_builder.return_op(0, 0, 0); trace = trace_builder.finalize(); - compute_common_indices(0, false); + compute_index_c(0, false); auto const& row = trace.at(1); EXPECT_THAT(row, @@ -295,7 +528,7 @@ TEST_F(AvmMemOpcodeTests, indirectSet) trace_builder.return_op(0, 0, 0); trace = trace_builder.finalize(); - compute_common_indices(1, true); + compute_index_c(1, true); auto const& row = trace.at(2); EXPECT_THAT(row, @@ -335,7 +568,7 @@ TEST_F(AvmMemOpcodeTests, indirectSetWrongTag) trace_builder.return_op(0, 0, 0); trace = trace_builder.finalize(); - compute_common_indices(1, true); + compute_index_c(1, true); auto const& row = trace.at(2); EXPECT_THAT(row, From 55316e9c5a4958abdb1a1ce0ccc2aa42147df1bf Mon Sep 17 00:00:00 2001 From: jeanmon Date: Tue, 9 Apr 2024 11:39:26 +0000 Subject: [PATCH 6/9] 5557: fixes after master rebase --- .../vm/generated/avm_circuit_builder.hpp | 3 - .../barretenberg/vm/generated/avm_flavor.hpp | 34 ++++++ .../barretenberg/vm/generated/avm_prover.cpp | 102 +++++++++++++++++- .../vm/generated/avm_verifier.cpp | 5 + .../vm/tests/avm_mem_opcodes.test.cpp | 12 +-- 5 files changed, 146 insertions(+), 10 deletions(-) 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 4fa1f9c6e78..cbd04d1d75f 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp @@ -496,8 +496,6 @@ class AvmCircuitBuilder { polys.avm_mem_tag_err[i] = rows[i].avm_mem_tag_err; polys.avm_mem_val[i] = rows[i].avm_mem_val; polys.avm_mem_w_in_tag[i] = rows[i].avm_mem_w_in_tag; -<<<<<<< HEAD -======= polys.perm_main_alu[i] = rows[i].perm_main_alu; <<<<<<< HEAD @@ -516,7 +514,6 @@ class AvmCircuitBuilder { polys.incl_main_tag_err[i] = rows[i].incl_main_tag_err; polys.incl_mem_tag_err[i] = rows[i].incl_mem_tag_err; >>>>>>> 7c841655b (5557: Add an additional intermediate register id) ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) polys.lookup_byte_lengths_counts[i] = rows[i].lookup_byte_lengths_counts; polys.lookup_byte_operations_counts[i] = rows[i].lookup_byte_operations_counts; polys.incl_main_tag_err_counts[i] = rows[i].incl_main_tag_err_counts; diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp index 4df9111ecc9..d778d062e42 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp @@ -104,9 +104,11 @@ class AvmFlavor { perm_main_mem_a_relation, perm_main_mem_b_relation, perm_main_mem_c_relation, + perm_main_mem_d_relation, perm_main_mem_ind_a_relation, perm_main_mem_ind_b_relation, perm_main_mem_ind_c_relation, +<<<<<<< HEAD lookup_byte_lengths_relation, lookup_byte_operations_relation, incl_main_tag_err_relation, @@ -128,6 +130,13 @@ class AvmFlavor { lookup_u16_12_relation, lookup_u16_13_relation, lookup_u16_14_relation>; +======= + perm_main_mem_ind_d_relation, + lookup_byte_lengths_relation, + lookup_byte_operations_relation, + incl_main_tag_err_relation, + incl_mem_tag_err_relation>; +>>>>>>> e353f6a7d (5557: fixes after master rebase) using Relations = std::tuple, Avm_vm::avm_binary, @@ -142,6 +151,7 @@ class AvmFlavor { perm_main_mem_ind_a_relation, perm_main_mem_ind_b_relation, perm_main_mem_ind_c_relation, +<<<<<<< HEAD <<<<<<< HEAD lookup_byte_lengths_relation, lookup_byte_operations_relation, @@ -174,6 +184,13 @@ class AvmFlavor { perm_main_mem_ind_d_relation>; >>>>>>> 7c841655b (5557: Add an additional intermediate register id) >>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) +======= + perm_main_mem_ind_d_relation, + lookup_byte_lengths_relation, + lookup_byte_operations_relation, + incl_main_tag_err_relation, + incl_mem_tag_err_relation>; +>>>>>>> e353f6a7d (5557: fixes after master rebase) static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = compute_max_partial_relation_length(); @@ -1401,12 +1418,19 @@ class AvmFlavor { prover_polynomials, relation_parameters, this->circuit_size); bb::compute_logderivative_inverse>( prover_polynomials, relation_parameters, this->circuit_size); + bb::compute_logderivative_inverse>( + prover_polynomials, relation_parameters, this->circuit_size); bb::compute_logderivative_inverse>( prover_polynomials, relation_parameters, this->circuit_size); bb::compute_logderivative_inverse>( prover_polynomials, relation_parameters, this->circuit_size); bb::compute_logderivative_inverse>( prover_polynomials, relation_parameters, this->circuit_size); +<<<<<<< HEAD +======= + bb::compute_logderivative_inverse>( + prover_polynomials, relation_parameters, this->circuit_size); +>>>>>>> e353f6a7d (5557: fixes after master rebase) bb::compute_logderivative_inverse>( prover_polynomials, relation_parameters, this->circuit_size); bb::compute_logderivative_inverse>( @@ -1415,6 +1439,7 @@ class AvmFlavor { prover_polynomials, relation_parameters, this->circuit_size); bb::compute_logderivative_inverse>( prover_polynomials, relation_parameters, this->circuit_size); +<<<<<<< HEAD bb::compute_logderivative_inverse>( prover_polynomials, relation_parameters, this->circuit_size); bb::compute_logderivative_inverse>( @@ -1449,6 +1474,8 @@ class AvmFlavor { prover_polynomials, relation_parameters, this->circuit_size); bb::compute_logderivative_inverse>( prover_polynomials, relation_parameters, this->circuit_size); +======= +>>>>>>> e353f6a7d (5557: fixes after master rebase) } }; @@ -1940,6 +1967,7 @@ class AvmFlavor { Commitment perm_main_mem_ind_b; Commitment perm_main_mem_ind_c; <<<<<<< HEAD +<<<<<<< HEAD ======= <<<<<<< HEAD // Lookup inverses @@ -1947,10 +1975,14 @@ class AvmFlavor { Commitment perm_main_mem_ind_d; >>>>>>> 7c841655b (5557: Add an additional intermediate register id) >>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) +======= + Commitment perm_main_mem_ind_d; +>>>>>>> e353f6a7d (5557: fixes after master rebase) Commitment lookup_byte_lengths; Commitment lookup_byte_operations; Commitment incl_main_tag_err; Commitment incl_mem_tag_err; +<<<<<<< HEAD Commitment lookup_u8_0; Commitment lookup_u8_1; Commitment lookup_u16_0; @@ -1968,6 +2000,8 @@ class AvmFlavor { Commitment lookup_u16_12; Commitment lookup_u16_13; Commitment lookup_u16_14; +======= +>>>>>>> e353f6a7d (5557: fixes after master rebase) Commitment lookup_byte_lengths_counts; Commitment lookup_byte_operations_counts; Commitment incl_main_tag_err_counts; diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp index 6d1bacc8d97..2617809c13f 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp @@ -59,8 +59,11 @@ void AvmProver::execute_wire_commitments_round() // Commit to all polynomials (apart from logderivative inverse polynomials, which are committed to in the later // logderivative phase) +<<<<<<< HEAD witness_commitments.avm_alu_a_hi = commitment_key->commit(key->avm_alu_a_hi); witness_commitments.avm_alu_a_lo = commitment_key->commit(key->avm_alu_a_lo); +======= +>>>>>>> e353f6a7d (5557: fixes after master rebase) witness_commitments.avm_alu_alu_sel = commitment_key->commit(key->avm_alu_alu_sel); witness_commitments.avm_alu_b_hi = commitment_key->commit(key->avm_alu_b_hi); witness_commitments.avm_alu_b_lo = commitment_key->commit(key->avm_alu_b_lo); @@ -143,32 +146,42 @@ void AvmProver::execute_wire_commitments_round() witness_commitments.avm_main_ia = commitment_key->commit(key->avm_main_ia); witness_commitments.avm_main_ib = commitment_key->commit(key->avm_main_ib); witness_commitments.avm_main_ic = commitment_key->commit(key->avm_main_ic); + witness_commitments.avm_main_id = commitment_key->commit(key->avm_main_id); + witness_commitments.avm_main_id_zero = commitment_key->commit(key->avm_main_id_zero); witness_commitments.avm_main_ind_a = commitment_key->commit(key->avm_main_ind_a); witness_commitments.avm_main_ind_b = commitment_key->commit(key->avm_main_ind_b); witness_commitments.avm_main_ind_c = commitment_key->commit(key->avm_main_ind_c); + witness_commitments.avm_main_ind_d = commitment_key->commit(key->avm_main_ind_d); witness_commitments.avm_main_ind_op_a = commitment_key->commit(key->avm_main_ind_op_a); witness_commitments.avm_main_ind_op_b = commitment_key->commit(key->avm_main_ind_op_b); witness_commitments.avm_main_ind_op_c = commitment_key->commit(key->avm_main_ind_op_c); + witness_commitments.avm_main_ind_op_d = commitment_key->commit(key->avm_main_ind_op_d); witness_commitments.avm_main_internal_return_ptr = commitment_key->commit(key->avm_main_internal_return_ptr); witness_commitments.avm_main_inv = commitment_key->commit(key->avm_main_inv); witness_commitments.avm_main_last = commitment_key->commit(key->avm_main_last); witness_commitments.avm_main_mem_idx_a = commitment_key->commit(key->avm_main_mem_idx_a); witness_commitments.avm_main_mem_idx_b = commitment_key->commit(key->avm_main_mem_idx_b); witness_commitments.avm_main_mem_idx_c = commitment_key->commit(key->avm_main_mem_idx_c); + witness_commitments.avm_main_mem_idx_d = commitment_key->commit(key->avm_main_mem_idx_d); witness_commitments.avm_main_mem_op_a = commitment_key->commit(key->avm_main_mem_op_a); witness_commitments.avm_main_mem_op_b = commitment_key->commit(key->avm_main_mem_op_b); witness_commitments.avm_main_mem_op_c = commitment_key->commit(key->avm_main_mem_op_c); + witness_commitments.avm_main_mem_op_d = commitment_key->commit(key->avm_main_mem_op_d); witness_commitments.avm_main_op_err = commitment_key->commit(key->avm_main_op_err); witness_commitments.avm_main_pc = commitment_key->commit(key->avm_main_pc); witness_commitments.avm_main_r_in_tag = commitment_key->commit(key->avm_main_r_in_tag); witness_commitments.avm_main_rwa = commitment_key->commit(key->avm_main_rwa); witness_commitments.avm_main_rwb = commitment_key->commit(key->avm_main_rwb); 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_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); witness_commitments.avm_main_sel_jump = commitment_key->commit(key->avm_main_sel_jump); witness_commitments.avm_main_sel_mov = commitment_key->commit(key->avm_main_sel_mov); + witness_commitments.avm_main_sel_mov_a = commitment_key->commit(key->avm_main_sel_mov_a); + witness_commitments.avm_main_sel_mov_b = commitment_key->commit(key->avm_main_sel_mov_b); witness_commitments.avm_main_sel_op_add = commitment_key->commit(key->avm_main_sel_op_add); witness_commitments.avm_main_sel_op_and = commitment_key->commit(key->avm_main_sel_op_and); witness_commitments.avm_main_sel_op_div = commitment_key->commit(key->avm_main_sel_op_div); @@ -189,15 +202,20 @@ void AvmProver::execute_wire_commitments_round() witness_commitments.avm_mem_ind_op_a = commitment_key->commit(key->avm_mem_ind_op_a); witness_commitments.avm_mem_ind_op_b = commitment_key->commit(key->avm_mem_ind_op_b); witness_commitments.avm_mem_ind_op_c = commitment_key->commit(key->avm_mem_ind_op_c); + witness_commitments.avm_mem_ind_op_d = commitment_key->commit(key->avm_mem_ind_op_d); witness_commitments.avm_mem_last = commitment_key->commit(key->avm_mem_last); witness_commitments.avm_mem_lastAccess = commitment_key->commit(key->avm_mem_lastAccess); witness_commitments.avm_mem_one_min_inv = commitment_key->commit(key->avm_mem_one_min_inv); witness_commitments.avm_mem_op_a = commitment_key->commit(key->avm_mem_op_a); witness_commitments.avm_mem_op_b = commitment_key->commit(key->avm_mem_op_b); witness_commitments.avm_mem_op_c = commitment_key->commit(key->avm_mem_op_c); + witness_commitments.avm_mem_op_d = commitment_key->commit(key->avm_mem_op_d); witness_commitments.avm_mem_r_in_tag = commitment_key->commit(key->avm_mem_r_in_tag); witness_commitments.avm_mem_rw = commitment_key->commit(key->avm_mem_rw); - witness_commitments.avm_mem_sel_mov = commitment_key->commit(key->avm_mem_sel_mov); + witness_commitments.avm_mem_sel_cmov = commitment_key->commit(key->avm_mem_sel_cmov); + witness_commitments.avm_mem_sel_mov_a = commitment_key->commit(key->avm_mem_sel_mov_a); + witness_commitments.avm_mem_sel_mov_b = commitment_key->commit(key->avm_mem_sel_mov_b); + witness_commitments.avm_mem_skip_check_tag = commitment_key->commit(key->avm_mem_skip_check_tag); witness_commitments.avm_mem_sub_clk = commitment_key->commit(key->avm_mem_sub_clk); witness_commitments.avm_mem_tag = commitment_key->commit(key->avm_mem_tag); witness_commitments.avm_mem_tag_err = commitment_key->commit(key->avm_mem_tag_err); @@ -226,6 +244,7 @@ void AvmProver::execute_wire_commitments_round() witness_commitments.lookup_u16_14_counts = commitment_key->commit(key->lookup_u16_14_counts); // Send all commitments to the verifier +<<<<<<< HEAD transcript->send_to_verifier(commitment_labels.avm_alu_a_hi, witness_commitments.avm_alu_a_hi); transcript->send_to_verifier(commitment_labels.avm_alu_a_lo, witness_commitments.avm_alu_a_lo); transcript->send_to_verifier(commitment_labels.avm_alu_alu_sel, witness_commitments.avm_alu_alu_sel); @@ -236,6 +255,11 @@ void AvmProver::execute_wire_commitments_round() transcript->send_to_verifier(commitment_labels.avm_alu_clk, witness_commitments.avm_alu_clk); transcript->send_to_verifier(commitment_labels.avm_alu_cmp_rng_ctr, witness_commitments.avm_alu_cmp_rng_ctr); transcript->send_to_verifier(commitment_labels.avm_alu_cmp_sel, witness_commitments.avm_alu_cmp_sel); +======= + transcript->send_to_verifier(commitment_labels.avm_alu_alu_sel, witness_commitments.avm_alu_alu_sel); + transcript->send_to_verifier(commitment_labels.avm_alu_cf, witness_commitments.avm_alu_cf); + transcript->send_to_verifier(commitment_labels.avm_alu_clk, witness_commitments.avm_alu_clk); +>>>>>>> e353f6a7d (5557: fixes after master rebase) transcript->send_to_verifier(commitment_labels.avm_alu_ff_tag, witness_commitments.avm_alu_ff_tag); transcript->send_to_verifier(commitment_labels.avm_alu_ia, witness_commitments.avm_alu_ia); transcript->send_to_verifier(commitment_labels.avm_alu_ib, witness_commitments.avm_alu_ib); @@ -245,6 +269,7 @@ void AvmProver::execute_wire_commitments_round() transcript->send_to_verifier(commitment_labels.avm_alu_op_div, witness_commitments.avm_alu_op_div); transcript->send_to_verifier(commitment_labels.avm_alu_op_eq, witness_commitments.avm_alu_op_eq); transcript->send_to_verifier(commitment_labels.avm_alu_op_eq_diff_inv, witness_commitments.avm_alu_op_eq_diff_inv); +<<<<<<< HEAD transcript->send_to_verifier(commitment_labels.avm_alu_op_lt, witness_commitments.avm_alu_op_lt); transcript->send_to_verifier(commitment_labels.avm_alu_op_lte, witness_commitments.avm_alu_op_lte); transcript->send_to_verifier(commitment_labels.avm_alu_op_mul, witness_commitments.avm_alu_op_mul); @@ -261,6 +286,11 @@ void AvmProver::execute_wire_commitments_round() transcript->send_to_verifier(commitment_labels.avm_alu_rng_chk_lookup_selector, witness_commitments.avm_alu_rng_chk_lookup_selector); transcript->send_to_verifier(commitment_labels.avm_alu_rng_chk_sel, witness_commitments.avm_alu_rng_chk_sel); +======= + transcript->send_to_verifier(commitment_labels.avm_alu_op_mul, witness_commitments.avm_alu_op_mul); + transcript->send_to_verifier(commitment_labels.avm_alu_op_not, witness_commitments.avm_alu_op_not); + transcript->send_to_verifier(commitment_labels.avm_alu_op_sub, witness_commitments.avm_alu_op_sub); +>>>>>>> e353f6a7d (5557: fixes after master rebase) transcript->send_to_verifier(commitment_labels.avm_alu_u128_tag, witness_commitments.avm_alu_u128_tag); transcript->send_to_verifier(commitment_labels.avm_alu_u16_r0, witness_commitments.avm_alu_u16_r0); transcript->send_to_verifier(commitment_labels.avm_alu_u16_r1, witness_commitments.avm_alu_u16_r1); @@ -318,12 +348,25 @@ void AvmProver::execute_wire_commitments_round() transcript->send_to_verifier(commitment_labels.avm_main_ia, witness_commitments.avm_main_ia); transcript->send_to_verifier(commitment_labels.avm_main_ib, witness_commitments.avm_main_ib); transcript->send_to_verifier(commitment_labels.avm_main_ic, witness_commitments.avm_main_ic); +<<<<<<< HEAD + transcript->send_to_verifier(commitment_labels.avm_main_ind_a, witness_commitments.avm_main_ind_a); + transcript->send_to_verifier(commitment_labels.avm_main_ind_b, witness_commitments.avm_main_ind_b); + transcript->send_to_verifier(commitment_labels.avm_main_ind_c, witness_commitments.avm_main_ind_c); + transcript->send_to_verifier(commitment_labels.avm_main_ind_op_a, witness_commitments.avm_main_ind_op_a); + transcript->send_to_verifier(commitment_labels.avm_main_ind_op_b, witness_commitments.avm_main_ind_op_b); + transcript->send_to_verifier(commitment_labels.avm_main_ind_op_c, witness_commitments.avm_main_ind_op_c); +======= + transcript->send_to_verifier(commitment_labels.avm_main_id, witness_commitments.avm_main_id); + transcript->send_to_verifier(commitment_labels.avm_main_id_zero, witness_commitments.avm_main_id_zero); transcript->send_to_verifier(commitment_labels.avm_main_ind_a, witness_commitments.avm_main_ind_a); transcript->send_to_verifier(commitment_labels.avm_main_ind_b, witness_commitments.avm_main_ind_b); transcript->send_to_verifier(commitment_labels.avm_main_ind_c, witness_commitments.avm_main_ind_c); + transcript->send_to_verifier(commitment_labels.avm_main_ind_d, witness_commitments.avm_main_ind_d); transcript->send_to_verifier(commitment_labels.avm_main_ind_op_a, witness_commitments.avm_main_ind_op_a); transcript->send_to_verifier(commitment_labels.avm_main_ind_op_b, witness_commitments.avm_main_ind_op_b); transcript->send_to_verifier(commitment_labels.avm_main_ind_op_c, witness_commitments.avm_main_ind_op_c); + transcript->send_to_verifier(commitment_labels.avm_main_ind_op_d, witness_commitments.avm_main_ind_op_d); +>>>>>>> e353f6a7d (5557: fixes after master rebase) transcript->send_to_verifier(commitment_labels.avm_main_internal_return_ptr, witness_commitments.avm_main_internal_return_ptr); transcript->send_to_verifier(commitment_labels.avm_main_inv, witness_commitments.avm_main_inv); @@ -331,15 +374,28 @@ void AvmProver::execute_wire_commitments_round() transcript->send_to_verifier(commitment_labels.avm_main_mem_idx_a, witness_commitments.avm_main_mem_idx_a); transcript->send_to_verifier(commitment_labels.avm_main_mem_idx_b, witness_commitments.avm_main_mem_idx_b); transcript->send_to_verifier(commitment_labels.avm_main_mem_idx_c, witness_commitments.avm_main_mem_idx_c); +<<<<<<< HEAD + transcript->send_to_verifier(commitment_labels.avm_main_mem_op_a, witness_commitments.avm_main_mem_op_a); + transcript->send_to_verifier(commitment_labels.avm_main_mem_op_b, witness_commitments.avm_main_mem_op_b); + transcript->send_to_verifier(commitment_labels.avm_main_mem_op_c, witness_commitments.avm_main_mem_op_c); +======= + transcript->send_to_verifier(commitment_labels.avm_main_mem_idx_d, witness_commitments.avm_main_mem_idx_d); transcript->send_to_verifier(commitment_labels.avm_main_mem_op_a, witness_commitments.avm_main_mem_op_a); transcript->send_to_verifier(commitment_labels.avm_main_mem_op_b, witness_commitments.avm_main_mem_op_b); transcript->send_to_verifier(commitment_labels.avm_main_mem_op_c, witness_commitments.avm_main_mem_op_c); + transcript->send_to_verifier(commitment_labels.avm_main_mem_op_d, witness_commitments.avm_main_mem_op_d); +>>>>>>> e353f6a7d (5557: fixes after master rebase) transcript->send_to_verifier(commitment_labels.avm_main_op_err, witness_commitments.avm_main_op_err); transcript->send_to_verifier(commitment_labels.avm_main_pc, witness_commitments.avm_main_pc); transcript->send_to_verifier(commitment_labels.avm_main_r_in_tag, witness_commitments.avm_main_r_in_tag); transcript->send_to_verifier(commitment_labels.avm_main_rwa, witness_commitments.avm_main_rwa); transcript->send_to_verifier(commitment_labels.avm_main_rwb, witness_commitments.avm_main_rwb); transcript->send_to_verifier(commitment_labels.avm_main_rwc, witness_commitments.avm_main_rwc); +<<<<<<< HEAD +======= + 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); +>>>>>>> e353f6a7d (5557: fixes after master rebase) 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); @@ -347,12 +403,20 @@ void AvmProver::execute_wire_commitments_round() witness_commitments.avm_main_sel_internal_return); transcript->send_to_verifier(commitment_labels.avm_main_sel_jump, witness_commitments.avm_main_sel_jump); transcript->send_to_verifier(commitment_labels.avm_main_sel_mov, witness_commitments.avm_main_sel_mov); +<<<<<<< HEAD +======= + transcript->send_to_verifier(commitment_labels.avm_main_sel_mov_a, witness_commitments.avm_main_sel_mov_a); + transcript->send_to_verifier(commitment_labels.avm_main_sel_mov_b, witness_commitments.avm_main_sel_mov_b); +>>>>>>> e353f6a7d (5557: fixes after master rebase) transcript->send_to_verifier(commitment_labels.avm_main_sel_op_add, witness_commitments.avm_main_sel_op_add); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_and, witness_commitments.avm_main_sel_op_and); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_div, witness_commitments.avm_main_sel_op_div); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_eq, witness_commitments.avm_main_sel_op_eq); +<<<<<<< HEAD transcript->send_to_verifier(commitment_labels.avm_main_sel_op_lt, witness_commitments.avm_main_sel_op_lt); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_lte, witness_commitments.avm_main_sel_op_lte); +======= +>>>>>>> e353f6a7d (5557: fixes after master rebase) transcript->send_to_verifier(commitment_labels.avm_main_sel_op_mul, witness_commitments.avm_main_sel_op_mul); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_not, witness_commitments.avm_main_sel_op_not); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_or, witness_commitments.avm_main_sel_op_or); @@ -367,15 +431,29 @@ void AvmProver::execute_wire_commitments_round() transcript->send_to_verifier(commitment_labels.avm_mem_ind_op_a, witness_commitments.avm_mem_ind_op_a); transcript->send_to_verifier(commitment_labels.avm_mem_ind_op_b, witness_commitments.avm_mem_ind_op_b); transcript->send_to_verifier(commitment_labels.avm_mem_ind_op_c, witness_commitments.avm_mem_ind_op_c); +<<<<<<< HEAD +======= + transcript->send_to_verifier(commitment_labels.avm_mem_ind_op_d, witness_commitments.avm_mem_ind_op_d); +>>>>>>> e353f6a7d (5557: fixes after master rebase) transcript->send_to_verifier(commitment_labels.avm_mem_last, witness_commitments.avm_mem_last); transcript->send_to_verifier(commitment_labels.avm_mem_lastAccess, witness_commitments.avm_mem_lastAccess); transcript->send_to_verifier(commitment_labels.avm_mem_one_min_inv, witness_commitments.avm_mem_one_min_inv); transcript->send_to_verifier(commitment_labels.avm_mem_op_a, witness_commitments.avm_mem_op_a); transcript->send_to_verifier(commitment_labels.avm_mem_op_b, witness_commitments.avm_mem_op_b); transcript->send_to_verifier(commitment_labels.avm_mem_op_c, witness_commitments.avm_mem_op_c); +<<<<<<< HEAD transcript->send_to_verifier(commitment_labels.avm_mem_r_in_tag, witness_commitments.avm_mem_r_in_tag); transcript->send_to_verifier(commitment_labels.avm_mem_rw, witness_commitments.avm_mem_rw); transcript->send_to_verifier(commitment_labels.avm_mem_sel_mov, witness_commitments.avm_mem_sel_mov); +======= + transcript->send_to_verifier(commitment_labels.avm_mem_op_d, witness_commitments.avm_mem_op_d); + transcript->send_to_verifier(commitment_labels.avm_mem_r_in_tag, witness_commitments.avm_mem_r_in_tag); + transcript->send_to_verifier(commitment_labels.avm_mem_rw, witness_commitments.avm_mem_rw); + transcript->send_to_verifier(commitment_labels.avm_mem_sel_cmov, witness_commitments.avm_mem_sel_cmov); + transcript->send_to_verifier(commitment_labels.avm_mem_sel_mov_a, witness_commitments.avm_mem_sel_mov_a); + transcript->send_to_verifier(commitment_labels.avm_mem_sel_mov_b, witness_commitments.avm_mem_sel_mov_b); + transcript->send_to_verifier(commitment_labels.avm_mem_skip_check_tag, witness_commitments.avm_mem_skip_check_tag); +>>>>>>> e353f6a7d (5557: fixes after master rebase) transcript->send_to_verifier(commitment_labels.avm_mem_sub_clk, witness_commitments.avm_mem_sub_clk); transcript->send_to_verifier(commitment_labels.avm_mem_tag, witness_commitments.avm_mem_tag); transcript->send_to_verifier(commitment_labels.avm_mem_tag_err, witness_commitments.avm_mem_tag_err); @@ -389,6 +467,7 @@ void AvmProver::execute_wire_commitments_round() witness_commitments.incl_main_tag_err_counts); transcript->send_to_verifier(commitment_labels.incl_mem_tag_err_counts, witness_commitments.incl_mem_tag_err_counts); +<<<<<<< HEAD transcript->send_to_verifier(commitment_labels.lookup_u8_0_counts, witness_commitments.lookup_u8_0_counts); transcript->send_to_verifier(commitment_labels.lookup_u8_1_counts, witness_commitments.lookup_u8_1_counts); transcript->send_to_verifier(commitment_labels.lookup_u16_0_counts, witness_commitments.lookup_u16_0_counts); @@ -406,6 +485,8 @@ void AvmProver::execute_wire_commitments_round() transcript->send_to_verifier(commitment_labels.lookup_u16_12_counts, witness_commitments.lookup_u16_12_counts); transcript->send_to_verifier(commitment_labels.lookup_u16_13_counts, witness_commitments.lookup_u16_13_counts); transcript->send_to_verifier(commitment_labels.lookup_u16_14_counts, witness_commitments.lookup_u16_14_counts); +======= +>>>>>>> e353f6a7d (5557: fixes after master rebase) } void AvmProver::execute_log_derivative_inverse_round() @@ -423,13 +504,19 @@ void AvmProver::execute_log_derivative_inverse_round() witness_commitments.perm_main_mem_a = commitment_key->commit(key->perm_main_mem_a); witness_commitments.perm_main_mem_b = commitment_key->commit(key->perm_main_mem_b); witness_commitments.perm_main_mem_c = commitment_key->commit(key->perm_main_mem_c); + witness_commitments.perm_main_mem_d = commitment_key->commit(key->perm_main_mem_d); witness_commitments.perm_main_mem_ind_a = commitment_key->commit(key->perm_main_mem_ind_a); witness_commitments.perm_main_mem_ind_b = commitment_key->commit(key->perm_main_mem_ind_b); witness_commitments.perm_main_mem_ind_c = commitment_key->commit(key->perm_main_mem_ind_c); +<<<<<<< HEAD +======= + witness_commitments.perm_main_mem_ind_d = commitment_key->commit(key->perm_main_mem_ind_d); +>>>>>>> e353f6a7d (5557: fixes after master rebase) witness_commitments.lookup_byte_lengths = commitment_key->commit(key->lookup_byte_lengths); witness_commitments.lookup_byte_operations = commitment_key->commit(key->lookup_byte_operations); witness_commitments.incl_main_tag_err = commitment_key->commit(key->incl_main_tag_err); witness_commitments.incl_mem_tag_err = commitment_key->commit(key->incl_mem_tag_err); +<<<<<<< HEAD witness_commitments.lookup_u8_0 = commitment_key->commit(key->lookup_u8_0); witness_commitments.lookup_u8_1 = commitment_key->commit(key->lookup_u8_1); witness_commitments.lookup_u16_0 = commitment_key->commit(key->lookup_u16_0); @@ -447,6 +534,8 @@ void AvmProver::execute_log_derivative_inverse_round() witness_commitments.lookup_u16_12 = commitment_key->commit(key->lookup_u16_12); witness_commitments.lookup_u16_13 = commitment_key->commit(key->lookup_u16_13); witness_commitments.lookup_u16_14 = commitment_key->commit(key->lookup_u16_14); +======= +>>>>>>> e353f6a7d (5557: fixes after master rebase) // Send all commitments to the verifier transcript->send_to_verifier(commitment_labels.perm_main_alu, witness_commitments.perm_main_alu); @@ -454,13 +543,22 @@ void AvmProver::execute_log_derivative_inverse_round() transcript->send_to_verifier(commitment_labels.perm_main_mem_a, witness_commitments.perm_main_mem_a); transcript->send_to_verifier(commitment_labels.perm_main_mem_b, witness_commitments.perm_main_mem_b); transcript->send_to_verifier(commitment_labels.perm_main_mem_c, witness_commitments.perm_main_mem_c); +<<<<<<< HEAD + transcript->send_to_verifier(commitment_labels.perm_main_mem_ind_a, witness_commitments.perm_main_mem_ind_a); + transcript->send_to_verifier(commitment_labels.perm_main_mem_ind_b, witness_commitments.perm_main_mem_ind_b); + transcript->send_to_verifier(commitment_labels.perm_main_mem_ind_c, witness_commitments.perm_main_mem_ind_c); +======= + transcript->send_to_verifier(commitment_labels.perm_main_mem_d, witness_commitments.perm_main_mem_d); transcript->send_to_verifier(commitment_labels.perm_main_mem_ind_a, witness_commitments.perm_main_mem_ind_a); transcript->send_to_verifier(commitment_labels.perm_main_mem_ind_b, witness_commitments.perm_main_mem_ind_b); transcript->send_to_verifier(commitment_labels.perm_main_mem_ind_c, witness_commitments.perm_main_mem_ind_c); + transcript->send_to_verifier(commitment_labels.perm_main_mem_ind_d, witness_commitments.perm_main_mem_ind_d); +>>>>>>> e353f6a7d (5557: fixes after master rebase) transcript->send_to_verifier(commitment_labels.lookup_byte_lengths, witness_commitments.lookup_byte_lengths); transcript->send_to_verifier(commitment_labels.lookup_byte_operations, witness_commitments.lookup_byte_operations); transcript->send_to_verifier(commitment_labels.incl_main_tag_err, witness_commitments.incl_main_tag_err); transcript->send_to_verifier(commitment_labels.incl_mem_tag_err, witness_commitments.incl_mem_tag_err); +<<<<<<< HEAD transcript->send_to_verifier(commitment_labels.lookup_u8_0, witness_commitments.lookup_u8_0); transcript->send_to_verifier(commitment_labels.lookup_u8_1, witness_commitments.lookup_u8_1); transcript->send_to_verifier(commitment_labels.lookup_u16_0, witness_commitments.lookup_u16_0); @@ -478,6 +576,8 @@ void AvmProver::execute_log_derivative_inverse_round() transcript->send_to_verifier(commitment_labels.lookup_u16_12, witness_commitments.lookup_u16_12); transcript->send_to_verifier(commitment_labels.lookup_u16_13, witness_commitments.lookup_u16_13); transcript->send_to_verifier(commitment_labels.lookup_u16_14, witness_commitments.lookup_u16_14); +======= +>>>>>>> e353f6a7d (5557: fixes after master rebase) } /** diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp index af8ca4217c8..6584ac3943a 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp @@ -370,6 +370,7 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) commitments.perm_main_mem_ind_c = transcript->template receive_from_prover(commitment_labels.perm_main_mem_ind_c); <<<<<<< HEAD +<<<<<<< HEAD ======= <<<<<<< HEAD @@ -379,6 +380,10 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) transcript->template receive_from_prover(commitment_labels.perm_main_mem_ind_d); >>>>>>> 7c841655b (5557: Add an additional intermediate register id) >>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) +======= + commitments.perm_main_mem_ind_d = + transcript->template receive_from_prover(commitment_labels.perm_main_mem_ind_d); +>>>>>>> e353f6a7d (5557: fixes after master rebase) commitments.lookup_byte_lengths = transcript->template receive_from_prover(commitment_labels.lookup_byte_lengths); commitments.lookup_byte_operations = diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_mem_opcodes.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_mem_opcodes.test.cpp index 1091a9ab6de..102c0fc4eac 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_mem_opcodes.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_mem_opcodes.test.cpp @@ -399,7 +399,7 @@ TEST_F(AvmMemOpcodeTests, allDirectCMovA) compute_cmov_indices(0); common_cmov_trace_validate( false, 1979, 1980, 987162, 10, 11, 12, 20, AvmMemoryTag::U16, AvmMemoryTag::U128, AvmMemoryTag::U64); - validate_trace_proof(std::move(trace)); + validate_trace_check_circuit(std::move(trace)); } TEST_F(AvmMemOpcodeTests, allDirectCMovB) @@ -416,7 +416,7 @@ TEST_F(AvmMemOpcodeTests, allDirectCMovB) compute_cmov_indices(0); common_cmov_trace_validate( false, 1979, 1980, 0, 10, 11, 12, 20, AvmMemoryTag::U8, AvmMemoryTag::U8, AvmMemoryTag::U64); - validate_trace_proof(std::move(trace)); + validate_trace_check_circuit(std::move(trace)); } TEST_F(AvmMemOpcodeTests, allDirectCMovConditionUninitialized) @@ -433,7 +433,7 @@ TEST_F(AvmMemOpcodeTests, allDirectCMovConditionUninitialized) compute_cmov_indices(0); common_cmov_trace_validate( false, 1979, 1980, 0, 10, 11, 12, 20, AvmMemoryTag::U8, AvmMemoryTag::U8, AvmMemoryTag::U0); - validate_trace_proof(std::move(trace)); + validate_trace_check_circuit(std::move(trace)); } TEST_F(AvmMemOpcodeTests, allDirectCMovOverwriteA) @@ -449,7 +449,7 @@ TEST_F(AvmMemOpcodeTests, allDirectCMovOverwriteA) compute_cmov_indices(0); common_cmov_trace_validate( false, 1979, 1980, 0, 10, 11, 10, 20, AvmMemoryTag::U8, AvmMemoryTag::U8, AvmMemoryTag::U64); - validate_trace_proof(std::move(trace)); + validate_trace_check_circuit(std::move(trace)); } TEST_F(AvmMemOpcodeTests, allIndirectCMovA) @@ -476,7 +476,7 @@ TEST_F(AvmMemOpcodeTests, allIndirectCMovA) compute_cmov_indices(15); common_cmov_trace_validate( true, 1979, 1980, 987162, 10, 11, 12, 20, AvmMemoryTag::U16, AvmMemoryTag::U128, AvmMemoryTag::U64); - validate_trace_proof(std::move(trace)); + validate_trace_check_circuit(std::move(trace)); } TEST_F(AvmMemOpcodeTests, allIndirectCMovAllUnitialized) @@ -487,7 +487,7 @@ TEST_F(AvmMemOpcodeTests, allIndirectCMovAllUnitialized) compute_cmov_indices(15); common_cmov_trace_validate(true, 0, 0, 0, 0, 0, 0, 0, AvmMemoryTag::U0, AvmMemoryTag::U0, AvmMemoryTag::U0); - validate_trace_proof(std::move(trace)); + validate_trace_check_circuit(std::move(trace)); } /****************************************************************************** From 015575660636a2ff515baec4b46e3fb130dabc3c Mon Sep 17 00:00:00 2001 From: jeanmon Date: Tue, 9 Apr 2024 12:38:14 +0000 Subject: [PATCH 7/9] 5557: negative unit tests for CMOV opcode --- barretenberg/cpp/pil/avm/avm_mem.pil | 1 + .../relations/generated/avm/avm_mem.hpp | 3 + .../vm/tests/avm_mem_opcodes.test.cpp | 76 +++++++++++++++++++ 3 files changed, 80 insertions(+) diff --git a/barretenberg/cpp/pil/avm/avm_mem.pil b/barretenberg/cpp/pil/avm/avm_mem.pil index 50151a5e4b3..34834214487 100644 --- a/barretenberg/cpp/pil/avm/avm_mem.pil +++ b/barretenberg/cpp/pil/avm/avm_mem.pil @@ -115,6 +115,7 @@ namespace avm_mem(256); lastAccess * (1 - rw') * val' = 0; // Skip check tag + #[SKIP_CHECK_TAG] skip_check_tag = sel_cmov * (op_d + op_a * (1-sel_mov_a) + op_b * (1-sel_mov_b)); // Memory tag consistency check for load operations, i.e., rw == 0. 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 ac4bea88629..2de1a2fe5b0 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_mem.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_mem.hpp @@ -51,6 +51,9 @@ inline std::string get_relation_label_avm_mem(int index) case 17: return "MEM_ZERO_INIT"; + case 18: + return "SKIP_CHECK_TAG"; + case 19: return "MEM_IN_TAG_CONSISTENCY_1"; diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_mem_opcodes.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_mem_opcodes.test.cpp index 102c0fc4eac..b02ee50d2ec 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_mem_opcodes.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_mem_opcodes.test.cpp @@ -50,6 +50,19 @@ class AvmMemOpcodeTests : public ::testing::Test { trace = trace_builder.finalize(); } + void build_cmov_trace_neg_test(bool mov_a) + { + trace_builder.op_set(0, 1979, 10, AvmMemoryTag::U16); // a + trace_builder.op_set(0, 1980, 11, AvmMemoryTag::U16); // b + trace_builder.op_set(0, mov_a ? 9871 : 0, 20, AvmMemoryTag::U64); // Non-zero/zero condition value (we move a/b) + + trace_builder.op_cmov(0, 10, 11, 20, 12); + trace_builder.return_op(0, 0, 0); + trace = trace_builder.finalize(); + + compute_cmov_indices(0); + } + static std::function gen_matcher(FF clk, uint32_t sub_clk) { return [clk, sub_clk](Row r) { return r.avm_mem_clk == clk && r.avm_mem_sub_clk == sub_clk; }; @@ -597,6 +610,10 @@ TEST_F(AvmMemOpcodeTests, indirectSetWrongTag) * ******************************************************************************/ +/****************************************************************************** + * MOV Opcode + ******************************************************************************/ + TEST_F(AvmMemOpcodeNegativeTests, movWrongOutputErrorTag) { build_mov_trace(false, 234, 0, 1, AvmMemoryTag::U8); @@ -708,4 +725,63 @@ TEST_F(AvmMemOpcodeNegativeTests, movWrongOutputTagMainTraceRead) EXPECT_THROW_WITH_MESSAGE(validate_trace_check_circuit(std::move(trace)), "PERM_MAIN_MEM_C"); } +/****************************************************************************** + * CMOV Opcode + ******************************************************************************/ +TEST_F(AvmMemOpcodeNegativeTests, cmovBInsteadA) +{ + build_cmov_trace_neg_test(true); + + trace.at(main_idx).avm_main_ic = 1980; + EXPECT_THROW_WITH_MESSAGE(validate_trace_check_circuit(std::move(trace)), "MOV_SAME_VALUE_A"); +} + +TEST_F(AvmMemOpcodeNegativeTests, cmovAInsteadB) +{ + build_cmov_trace_neg_test(false); + + trace.at(main_idx).avm_main_ic = 1979; + EXPECT_THROW_WITH_MESSAGE(validate_trace_check_circuit(std::move(trace)), "MOV_SAME_VALUE_B"); +} + +TEST_F(AvmMemOpcodeNegativeTests, cmovAChangeTag) +{ + build_cmov_trace_neg_test(true); + + trace.at(mem_c_idx).avm_mem_tag = static_cast(AvmMemoryTag::U32); + trace.at(mem_c_idx).avm_mem_w_in_tag = static_cast(AvmMemoryTag::U32); + trace.at(main_idx).avm_main_w_in_tag = static_cast(AvmMemoryTag::U32); + + EXPECT_THROW_WITH_MESSAGE(validate_trace_check_circuit(std::move(trace)), "MOV_MAIN_SAME_TAG"); +} + +TEST_F(AvmMemOpcodeNegativeTests, cmovASkipCheckAbuse) +{ + build_cmov_trace_neg_test(true); + + trace.at(mem_a_idx).avm_mem_skip_check_tag = 1; + + EXPECT_THROW_WITH_MESSAGE(validate_trace_check_circuit(std::move(trace)), "SKIP_CHECK_TAG"); +} + +TEST_F(AvmMemOpcodeNegativeTests, cmovASkipCheckAbuseDisableSelMovA) +{ + build_cmov_trace_neg_test(true); + + trace.at(mem_a_idx).avm_mem_skip_check_tag = 1; + trace.at(mem_a_idx).avm_mem_sel_mov_a = 0; + + EXPECT_THROW_WITH_MESSAGE(validate_trace_check_circuit(std::move(trace)), "PERM_MAIN_MEM_A"); +} + +TEST_F(AvmMemOpcodeNegativeTests, cmovBSkipCheckAbuseDisableSelMovB) +{ + build_cmov_trace_neg_test(false); + + trace.at(mem_b_idx).avm_mem_skip_check_tag = 1; + trace.at(mem_b_idx).avm_mem_sel_mov_b = 0; + + EXPECT_THROW_WITH_MESSAGE(validate_trace_check_circuit(std::move(trace)), "PERM_MAIN_MEM_B"); +} + } // namespace tests_avm From 7e401cd537ed9a7d0c32dffda33930011b392cb0 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Tue, 9 Apr 2024 16:06:02 +0000 Subject: [PATCH 8/9] 5557: deserialization and execution layer for CMOV --- .../vm/avm_trace/avm_deserialization.cpp | 2 + .../vm/avm_trace/avm_execution.cpp | 7 +++ .../vm/tests/avm_execution.test.cpp | 56 +++++++++++++++++++ 3 files changed, 65 insertions(+) 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 03d4091ddef..2590e5e298a 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp @@ -44,6 +44,8 @@ const std::unordered_map> OPCODE_WIRE_FORMAT = // Machine State - Memory // OpCode::SET is handled differently { OpCode::MOV, { OperandType::INDIRECT, OperandType::UINT32, OperandType::UINT32 } }, + { OpCode::CMOV, + { OperandType::INDIRECT, OperandType::UINT32, OperandType::UINT32, OperandType::UINT32, OperandType::UINT32 } }, // Control Flow - Contract Calls { 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 753ce9eca13..1e018d647d6 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp @@ -232,6 +232,13 @@ std::vector Execution::gen_trace(std::vector const& instructio std::get(inst.operands.at(1)), std::get(inst.operands.at(2))); break; + case OpCode::CMOV: + trace_builder.op_cmov(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))); + break; // Control Flow - Contract Calls case OpCode::RETURN: trace_builder.return_op(std::get(inst.operands.at(0)), 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 0feab83b36e..f505eb16ce5 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_execution.test.cpp @@ -503,6 +503,62 @@ TEST_F(AvmExecutionTests, movOpcode) gen_proof_and_validate(bytecode, std::move(trace), {}); } +// Positive test with CMOV. +TEST_F(AvmExecutionTests, cmovOpcode) +{ + std::string bytecode_hex = to_hex(OpCode::SET) + // opcode SET + "00" // Indirect flag + "01" // U8 + "03" // val 3 + "00000010" // a_offset 16 + + to_hex(OpCode::SET) + // opcode SET + "00" // Indirect flag + "02" // U16 + "0004" // val 4 + "00000011" // b_offset 17 + + to_hex(OpCode::SET) + // opcode SET + "00" // Indirect flag + "03" // U32 + "00000005" // val 5 + "00000020" // cond_offset 32 + + to_hex(OpCode::CMOV) + // opcode CMOV + "00" // Indirect flag + "00000010" // a_offset 16 + "00000011" // b_offset 17 + "00000020" // cond_offset 32 + "00000012" // dst_offset 18 + + 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); + + ASSERT_THAT(instructions, SizeIs(5)); + + // CMOV + EXPECT_THAT(instructions.at(3), + AllOf(Field(&Instruction::op_code, OpCode::CMOV), + Field(&Instruction::operands, + ElementsAre(VariantWith(0), + VariantWith(16), + VariantWith(17), + VariantWith(32), + VariantWith(18))))); + + auto trace = Execution::gen_trace(instructions); + + // Find the first row enabling the CMOV selector + auto row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_cmov == 1; }); + EXPECT_EQ(row->avm_main_ia, 3); + EXPECT_EQ(row->avm_main_ib, 4); + EXPECT_EQ(row->avm_main_ic, 3); + EXPECT_EQ(row->avm_main_id, 5); + + gen_proof_and_validate(bytecode, std::move(trace), {}); +} + // Positive test with indirect MOV. TEST_F(AvmExecutionTests, indMovOpcode) { From 806cea410fab8e8352adeb1fc31022d59dd98b45 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Thu, 11 Apr 2024 06:43:25 +0000 Subject: [PATCH 9/9] 5557: rebase on master fixing conflicts --- .../relations/generated/avm/avm_alu.hpp | 33 +-- .../relations/generated/avm/avm_main.hpp | 240 +++++++++++------- .../barretenberg/vm/avm_trace/avm_trace.cpp | 8 +- .../vm/generated/avm_circuit_builder.hpp | 37 +-- .../barretenberg/vm/generated/avm_flavor.hpp | 77 +----- .../barretenberg/vm/generated/avm_prover.cpp | 66 ----- .../vm/generated/avm_verifier.cpp | 13 - 7 files changed, 167 insertions(+), 307 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 84612d3fe23..fc4fcff7998 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_alu.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_alu.hpp @@ -271,18 +271,10 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(9); - 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{ 0, 1, 0, 0 }))) + - (avm_alu_u16_r4 * FF(uint256_t{ 0, 65536, 0, 0 }))) + - (avm_alu_u16_r5 * FF(uint256_t{ 0, 4294967296, 0, 0 }))) + - (avm_alu_u16_r6 * FF(uint256_t{ 0, 281474976710656, 0, 0 }))) - - avm_alu_ia) + - (avm_alu_ff_tag * avm_alu_ic))) + - ((avm_alu_op_add - avm_alu_op_sub) * ((avm_alu_cf * FF(uint256_t{ 0, 0, 1, 0 })) - avm_alu_ib))); + 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<9>(evals) += tmp; } @@ -336,15 +328,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(12); - 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{ 0, 1, 0, 0 }))) + - (avm_alu_u16_r4 * FF(uint256_t{ 0, 65536, 0, 0 }))) + - (avm_alu_u16_r5 * FF(uint256_t{ 0, 4294967296, 0, 0 }))) + - (avm_alu_u16_r6 * FF(uint256_t{ 0, 281474976710656, 0, 0 }))) - - (avm_alu_ia * avm_alu_ib))); + auto tmp = ((avm_alu_ff_tag * avm_alu_op_mul) * ((avm_alu_ia * avm_alu_ib) - avm_alu_ic)); tmp *= scaling_factor; std::get<12>(evals) += tmp; } @@ -434,12 +418,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(18); - 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{ 0, 1, 0, 0 }))) + - (avm_alu_u128_tag * FF(uint256_t{ 0, 0, 1, 0 }))) - - FF(1)))); + auto tmp = (avm_alu_op_not * avm_alu_ff_tag); tmp *= scaling_factor; std::get<18>(evals) += tmp; } 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 dffbb6e62b9..74e611ac699 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_main.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_main.hpp @@ -63,52 +63,52 @@ template struct Avm_mainRow { inline std::string get_relation_label_avm_main(int index) { switch (index) { - case 28: - return "EQ_OUTPUT_U8"; + case 32: + return "OUTPUT_U8"; - case 31: + case 33: return "SUBOP_DIVISION_FF"; - case 32: + case 34: return "SUBOP_DIVISION_ZERO_ERR1"; - case 33: + case 35: return "SUBOP_DIVISION_ZERO_ERR2"; - case 34: + case 36: return "SUBOP_ERROR_RELEVANT_OP"; - case 36: + case 38: return "RETURN_POINTER_INCREMENT"; - case 42: + case 44: return "RETURN_POINTER_DECREMENT"; - case 47: + case 49: return "PC_INCREMENT"; - case 48: + case 50: return "INTERNAL_RETURN_POINTER_CONSISTENCY"; - case 49: + case 51: return "CMOV_CONDITION_RES_1"; - case 50: + case 52: return "CMOV_CONDITION_RES_2"; - case 53: + case 55: return "MOV_SAME_VALUE_A"; - case 54: + case 56: return "MOV_SAME_VALUE_B"; - case 55: + case 57: return "MOV_MAIN_SAME_TAG"; - case 57: + case 59: return "BIN_SEL_1"; - case 51: + case 60: return "BIN_SEL_2"; } return std::to_string(index); @@ -118,9 +118,9 @@ template class avm_mainImpl { public: using FF = FF_; - 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, 5, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 3, 3, 3, 3, 2, + 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, 5, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 4, 4, 3, 3, 3, 3, 3, 3, 3, 2, }; template @@ -246,7 +246,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(14); - auto tmp = (avm_main_op_err * (-avm_main_op_err + FF(1))); + auto tmp = (avm_main_sel_halt * (-avm_main_sel_halt + FF(1))); tmp *= scaling_factor; std::get<14>(evals) += tmp; } @@ -254,7 +254,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(15); - auto tmp = (avm_main_tag_err * (-avm_main_tag_err + FF(1))); + auto tmp = (avm_main_sel_mov * (-avm_main_sel_mov + FF(1))); tmp *= scaling_factor; std::get<15>(evals) += tmp; } @@ -262,7 +262,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(16); - auto tmp = (avm_main_mem_op_a * (-avm_main_mem_op_a + FF(1))); + auto tmp = (avm_main_sel_cmov * (-avm_main_sel_cmov + FF(1))); tmp *= scaling_factor; std::get<16>(evals) += tmp; } @@ -270,7 +270,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(17); - auto tmp = (avm_main_mem_op_b * (-avm_main_mem_op_b + FF(1))); + auto tmp = (avm_main_op_err * (-avm_main_op_err + FF(1))); tmp *= scaling_factor; std::get<17>(evals) += tmp; } @@ -278,7 +278,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(18); - auto tmp = (avm_main_mem_op_a * (-avm_main_mem_op_a + FF(1))); + auto tmp = (avm_main_tag_err * (-avm_main_tag_err + FF(1))); tmp *= scaling_factor; std::get<18>(evals) += tmp; } @@ -286,7 +286,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(19); - auto tmp = (avm_main_mem_op_d * (-avm_main_mem_op_d + FF(1))); + auto tmp = (avm_main_id_zero * (-avm_main_id_zero + FF(1))); tmp *= scaling_factor; std::get<19>(evals) += tmp; } @@ -294,7 +294,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(20); - auto tmp = (avm_main_rwa * (-avm_main_rwa + FF(1))); + auto tmp = (avm_main_mem_op_a * (-avm_main_mem_op_a + FF(1))); tmp *= scaling_factor; std::get<20>(evals) += tmp; } @@ -302,7 +302,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(21); - auto tmp = (avm_main_rwb * (-avm_main_rwb + FF(1))); + auto tmp = (avm_main_mem_op_b * (-avm_main_mem_op_b + FF(1))); tmp *= scaling_factor; std::get<21>(evals) += tmp; } @@ -310,7 +310,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(22); - auto tmp = (avm_main_rwc * (-avm_main_rwc + FF(1))); + auto tmp = (avm_main_mem_op_c * (-avm_main_mem_op_c + FF(1))); tmp *= scaling_factor; std::get<22>(evals) += tmp; } @@ -318,7 +318,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(23); - auto tmp = (avm_main_rwd * (-avm_main_rwd + FF(1))); + auto tmp = (avm_main_mem_op_d * (-avm_main_mem_op_d + FF(1))); tmp *= scaling_factor; std::get<23>(evals) += tmp; } @@ -326,7 +326,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(24); - auto tmp = (avm_main_rwc * (-avm_main_rwc + FF(1))); + auto tmp = (avm_main_rwa * (-avm_main_rwa + FF(1))); tmp *= scaling_factor; std::get<24>(evals) += tmp; } @@ -334,7 +334,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(25); - auto tmp = (avm_main_rwd * (-avm_main_rwd + FF(1))); + auto tmp = (avm_main_rwb * (-avm_main_rwb + FF(1))); tmp *= scaling_factor; std::get<25>(evals) += tmp; } @@ -342,7 +342,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(26); - auto tmp = (avm_main_ind_op_a * (-avm_main_ind_op_a + FF(1))); + auto tmp = (avm_main_rwc * (-avm_main_rwc + FF(1))); tmp *= scaling_factor; std::get<26>(evals) += tmp; } @@ -350,7 +350,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(27); - auto tmp = (avm_main_ind_op_d * (-avm_main_ind_op_d + FF(1))); + auto tmp = (avm_main_rwd * (-avm_main_rwd + FF(1))); tmp *= scaling_factor; std::get<27>(evals) += tmp; } @@ -358,7 +358,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(28); - auto tmp = (avm_main_sel_op_eq * (avm_main_w_in_tag - FF(1))); + auto tmp = (avm_main_ind_op_a * (-avm_main_ind_op_a + FF(1))); tmp *= scaling_factor; std::get<28>(evals) += tmp; } @@ -366,8 +366,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(29); - auto tmp = - ((avm_main_sel_op_div * (-avm_main_op_err + FF(1))) * ((avm_main_ic * avm_main_ib) - avm_main_ia)); + auto tmp = (avm_main_ind_op_b * (-avm_main_ind_op_b + FF(1))); tmp *= scaling_factor; std::get<29>(evals) += tmp; } @@ -375,7 +374,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(30); - auto tmp = (avm_main_sel_op_div * (((avm_main_ib * avm_main_inv) - FF(1)) + avm_main_op_err)); + auto tmp = (avm_main_ind_op_c * (-avm_main_ind_op_c + FF(1))); tmp *= scaling_factor; std::get<30>(evals) += tmp; } @@ -383,7 +382,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(31); - auto tmp = ((avm_main_sel_op_div * avm_main_op_err) * (-avm_main_inv + FF(1))); + auto tmp = (avm_main_ind_op_d * (-avm_main_ind_op_d + FF(1))); tmp *= scaling_factor; std::get<31>(evals) += tmp; } @@ -391,7 +390,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(32); - auto tmp = (avm_main_op_err * (avm_main_sel_op_div - FF(1))); + auto tmp = + (((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<32>(evals) += tmp; } @@ -399,7 +399,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(33); - auto tmp = (avm_main_sel_jump * (avm_main_pc_shift - avm_main_ia)); + auto tmp = + ((avm_main_sel_op_div * (-avm_main_op_err + FF(1))) * ((avm_main_ic * avm_main_ib) - avm_main_ia)); tmp *= scaling_factor; std::get<33>(evals) += tmp; } @@ -407,8 +408,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(34); - 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_op_div * (((avm_main_ib * avm_main_inv) - FF(1)) + avm_main_op_err)); tmp *= scaling_factor; std::get<34>(evals) += tmp; } @@ -416,7 +416,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(35); - auto tmp = (avm_main_sel_internal_call * (avm_main_internal_return_ptr - avm_main_mem_idx_b)); + auto tmp = ((avm_main_sel_op_div * avm_main_op_err) * (-avm_main_inv + FF(1))); tmp *= scaling_factor; std::get<35>(evals) += tmp; } @@ -424,7 +424,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(36); - auto tmp = (avm_main_sel_internal_call * (avm_main_pc_shift - avm_main_ia)); + auto tmp = (avm_main_op_err * (avm_main_sel_op_div - FF(1))); tmp *= scaling_factor; std::get<36>(evals) += tmp; } @@ -432,7 +432,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(37); - auto tmp = (avm_main_sel_internal_call * ((avm_main_pc + FF(1)) - avm_main_ib)); + auto tmp = (avm_main_sel_jump * (avm_main_pc_shift - avm_main_ia)); tmp *= scaling_factor; std::get<37>(evals) += tmp; } @@ -440,7 +440,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(38); - auto tmp = (avm_main_sel_internal_call * (avm_main_rwb - FF(1))); + 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<38>(evals) += tmp; } @@ -448,7 +449,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(39); - auto tmp = (avm_main_sel_internal_call * (avm_main_mem_op_b - FF(1))); + auto tmp = (avm_main_sel_internal_call * (avm_main_internal_return_ptr - avm_main_mem_idx_b)); tmp *= scaling_factor; std::get<39>(evals) += tmp; } @@ -456,8 +457,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(40); - 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_pc_shift - avm_main_ia)); tmp *= scaling_factor; std::get<40>(evals) += tmp; } @@ -465,7 +465,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(41); - 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_call * ((avm_main_pc + FF(1)) - avm_main_ib)); tmp *= scaling_factor; std::get<41>(evals) += tmp; } @@ -473,7 +473,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(42); - auto tmp = (avm_main_sel_internal_return * (avm_main_pc_shift - avm_main_ia)); + auto tmp = (avm_main_sel_internal_call * (avm_main_rwb - FF(1))); tmp *= scaling_factor; std::get<42>(evals) += tmp; } @@ -481,7 +481,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(43); - auto tmp = (avm_main_sel_internal_return * avm_main_rwa); + auto tmp = (avm_main_sel_internal_call * (avm_main_mem_op_b - FF(1))); tmp *= scaling_factor; std::get<43>(evals) += tmp; } @@ -489,48 +489,24 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(44); - auto tmp = (avm_main_sel_internal_return * (avm_main_mem_op_a - FF(1))); - tmp *= scaling_factor; - std::get<44>(evals) += tmp; - } - // Contribution 45 - { - Avm_DECLARE_VIEWS(45); - - auto tmp = - ((((-avm_main_first + FF(1)) * (-avm_main_sel_halt + FF(1))) * - ((((((((avm_main_sel_op_add + avm_main_sel_op_sub) + avm_main_sel_op_div) + avm_main_sel_op_mul) + - avm_main_sel_op_not) + - avm_main_sel_op_eq) + - avm_main_sel_op_and) + - avm_main_sel_op_or) + - avm_main_sel_op_xor)) * - (avm_main_pc_shift - (avm_main_pc + FF(1)))); + auto tmp = (avm_main_sel_internal_return * + (avm_main_internal_return_ptr_shift - (avm_main_internal_return_ptr - FF(1)))); tmp *= scaling_factor; -<<<<<<< HEAD std::get<44>(evals) += tmp; } // Contribution 45 { Avm_DECLARE_VIEWS(45); - 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)); + auto tmp = (avm_main_sel_internal_return * ((avm_main_internal_return_ptr - FF(1)) - avm_main_mem_idx_a)); tmp *= scaling_factor; -======= ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) std::get<45>(evals) += tmp; } // Contribution 46 { Avm_DECLARE_VIEWS(46); - 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)); + auto tmp = (avm_main_sel_internal_return * (avm_main_pc_shift - avm_main_ia)); tmp *= scaling_factor; std::get<46>(evals) += tmp; } @@ -538,7 +514,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(47); - auto tmp = (avm_main_sel_mov * (avm_main_ia - avm_main_ic)); + auto tmp = (avm_main_sel_internal_return * avm_main_rwa); tmp *= scaling_factor; std::get<47>(evals) += tmp; } @@ -546,7 +522,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(48); - auto tmp = (avm_main_sel_mov * (avm_main_r_in_tag - avm_main_w_in_tag)); + auto tmp = (avm_main_sel_internal_return * (avm_main_mem_op_a - FF(1))); tmp *= scaling_factor; std::get<48>(evals) += tmp; } @@ -554,10 +530,15 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(49); - 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_not) + - avm_main_sel_op_eq) * - (-avm_main_tag_err + FF(1)))); + auto tmp = + ((((-avm_main_first + FF(1)) * (-avm_main_sel_halt + FF(1))) * + ((((((((avm_main_sel_op_add + avm_main_sel_op_sub) + avm_main_sel_op_div) + avm_main_sel_op_mul) + + avm_main_sel_op_not) + + avm_main_sel_op_eq) + + avm_main_sel_op_and) + + avm_main_sel_op_or) + + avm_main_sel_op_xor)) * + (avm_main_pc_shift - (avm_main_pc + FF(1)))); tmp *= scaling_factor; std::get<49>(evals) += tmp; } @@ -565,7 +546,10 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(50); - auto tmp = (avm_main_bin_op_id - (avm_main_sel_op_or + (avm_main_sel_op_xor * FF(2)))); + 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<50>(evals) += tmp; } @@ -573,10 +557,88 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(51); - 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_id * avm_main_inv) - FF(1)) + avm_main_id_zero)); tmp *= scaling_factor; std::get<51>(evals) += tmp; } + // Contribution 52 + { + Avm_DECLARE_VIEWS(52); + + auto tmp = ((avm_main_sel_cmov * avm_main_id_zero) * (-avm_main_inv + FF(1))); + tmp *= scaling_factor; + std::get<52>(evals) += tmp; + } + // Contribution 53 + { + Avm_DECLARE_VIEWS(53); + + 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<53>(evals) += tmp; + } + // Contribution 54 + { + Avm_DECLARE_VIEWS(54); + + auto tmp = (avm_main_sel_mov_b - (avm_main_sel_cmov * avm_main_id_zero)); + tmp *= scaling_factor; + std::get<54>(evals) += tmp; + } + // Contribution 55 + { + Avm_DECLARE_VIEWS(55); + + auto tmp = (avm_main_sel_mov_a * (avm_main_ia - avm_main_ic)); + tmp *= scaling_factor; + std::get<55>(evals) += tmp; + } + // Contribution 56 + { + Avm_DECLARE_VIEWS(56); + + auto tmp = (avm_main_sel_mov_b * (avm_main_ib - avm_main_ic)); + tmp *= scaling_factor; + std::get<56>(evals) += tmp; + } + // Contribution 57 + { + Avm_DECLARE_VIEWS(57); + + 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<57>(evals) += tmp; + } + // Contribution 58 + { + Avm_DECLARE_VIEWS(58); + + 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_not) + + avm_main_sel_op_eq) + + avm_main_sel_op_lt) + + avm_main_sel_op_lte) * + (-avm_main_tag_err + FF(1)))); + tmp *= scaling_factor; + std::get<58>(evals) += tmp; + } + // Contribution 59 + { + Avm_DECLARE_VIEWS(59); + + auto tmp = (avm_main_bin_op_id - (avm_main_sel_op_or + (avm_main_sel_op_xor * FF(2)))); + tmp *= scaling_factor; + std::get<59>(evals) += tmp; + } + // Contribution 60 + { + Avm_DECLARE_VIEWS(60); + + 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<60>(evals) += tmp; + } } }; 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 5dded97a92d..5c4a20515ad 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp @@ -650,7 +650,7 @@ void AvmTraceBuilder::op_lt( range_checked_required = true; // Write into memory value c from intermediate register ic. - mem_trace_builder.write_into_memory(clk, IntermRegister::IC, res.direct_dst_offset, c, in_tag, AvmMemoryTag::U8); + mem_trace_builder.write_into_memory(clk, IntermRegister::IC, res.direct_c_offset, c, in_tag, AvmMemoryTag::U8); main_trace.push_back(Row{ .avm_main_clk = clk, @@ -666,7 +666,7 @@ void AvmTraceBuilder::op_lt( .avm_main_internal_return_ptr = FF(internal_return_ptr), .avm_main_mem_idx_a = FF(res.direct_a_offset), .avm_main_mem_idx_b = FF(res.direct_b_offset), - .avm_main_mem_idx_c = FF(res.direct_dst_offset), + .avm_main_mem_idx_c = FF(res.direct_c_offset), .avm_main_mem_op_a = FF(1), .avm_main_mem_op_b = FF(1), .avm_main_mem_op_c = FF(1), @@ -701,7 +701,7 @@ void AvmTraceBuilder::op_lte( range_checked_required = true; // Write into memory value c from intermediate register ic. - mem_trace_builder.write_into_memory(clk, IntermRegister::IC, res.direct_dst_offset, c, in_tag, AvmMemoryTag::U8); + mem_trace_builder.write_into_memory(clk, IntermRegister::IC, res.direct_c_offset, c, in_tag, AvmMemoryTag::U8); main_trace.push_back(Row{ .avm_main_clk = clk, @@ -717,7 +717,7 @@ void AvmTraceBuilder::op_lte( .avm_main_internal_return_ptr = FF(internal_return_ptr), .avm_main_mem_idx_a = FF(res.direct_a_offset), .avm_main_mem_idx_b = FF(res.direct_b_offset), - .avm_main_mem_idx_c = FF(res.direct_dst_offset), + .avm_main_mem_idx_c = FF(res.direct_c_offset), .avm_main_mem_op_a = FF(1), .avm_main_mem_op_b = FF(1), .avm_main_mem_op_c = FF(1), 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 cbd04d1d75f..fe2b81f0e34 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp @@ -304,23 +304,8 @@ class AvmCircuitBuilder { using Polynomial = Flavor::Polynomial; using ProverPolynomials = Flavor::ProverPolynomials; -<<<<<<< HEAD -<<<<<<< HEAD -<<<<<<< HEAD - static constexpr size_t num_fixed_columns = 224; - static constexpr size_t num_polys = 195; -======= - static constexpr size_t num_fixed_columns = 169; - static constexpr size_t num_polys = 150; ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) -======= - static constexpr size_t num_fixed_columns = 174; - static constexpr size_t num_polys = 155; ->>>>>>> 220457275 (5557: PIL relations for CMOV opcode) -======= - static constexpr size_t num_fixed_columns = 176; - static constexpr size_t num_polys = 157; ->>>>>>> bdc8f5a57 (5557: several bug fixes for CMOV opcode and first unit test) + static constexpr size_t num_fixed_columns = 241; + static constexpr size_t num_polys = 212; std::vector rows; void set_trace(std::vector&& trace) { rows = std::move(trace); } @@ -496,24 +481,6 @@ class AvmCircuitBuilder { polys.avm_mem_tag_err[i] = rows[i].avm_mem_tag_err; polys.avm_mem_val[i] = rows[i].avm_mem_val; polys.avm_mem_w_in_tag[i] = rows[i].avm_mem_w_in_tag; - polys.perm_main_alu[i] = rows[i].perm_main_alu; -<<<<<<< HEAD - -======= - polys.perm_main_bin[i] = rows[i].perm_main_bin; - polys.perm_main_mem_a[i] = rows[i].perm_main_mem_a; - polys.perm_main_mem_b[i] = rows[i].perm_main_mem_b; - polys.perm_main_mem_c[i] = rows[i].perm_main_mem_c; - polys.perm_main_mem_d[i] = rows[i].perm_main_mem_d; - polys.perm_main_mem_ind_a[i] = rows[i].perm_main_mem_ind_a; - polys.perm_main_mem_ind_b[i] = rows[i].perm_main_mem_ind_b; - polys.perm_main_mem_ind_c[i] = rows[i].perm_main_mem_ind_c; - polys.perm_main_mem_ind_d[i] = rows[i].perm_main_mem_ind_d; - polys.lookup_byte_lengths[i] = rows[i].lookup_byte_lengths; - polys.lookup_byte_operations[i] = rows[i].lookup_byte_operations; - polys.incl_main_tag_err[i] = rows[i].incl_main_tag_err; - polys.incl_mem_tag_err[i] = rows[i].incl_mem_tag_err; ->>>>>>> 7c841655b (5557: Add an additional intermediate register id) polys.lookup_byte_lengths_counts[i] = rows[i].lookup_byte_lengths_counts; polys.lookup_byte_operations_counts[i] = rows[i].lookup_byte_operations_counts; polys.incl_main_tag_err_counts[i] = rows[i].incl_main_tag_err_counts; diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp index d778d062e42..0964aa33632 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp @@ -69,35 +69,11 @@ class AvmFlavor { using RelationSeparator = FF; static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 2; -<<<<<<< HEAD -<<<<<<< HEAD -<<<<<<< HEAD - static constexpr size_t NUM_WITNESS_ENTITIES = 193; + static constexpr size_t NUM_WITNESS_ENTITIES = 210; 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 = 224; -======= - static constexpr size_t NUM_WITNESS_ENTITIES = 148; - 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 = 169; ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) -======= - static constexpr size_t NUM_WITNESS_ENTITIES = 153; - 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 = 174; ->>>>>>> 220457275 (5557: PIL relations for CMOV opcode) -======= - static constexpr size_t NUM_WITNESS_ENTITIES = 155; - 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 = 176; ->>>>>>> bdc8f5a57 (5557: several bug fixes for CMOV opcode and first unit test) + static constexpr size_t NUM_ALL_ENTITIES = 241; using GrandProductRelations = std::tuple, perm_main_bin_relation, @@ -108,7 +84,7 @@ class AvmFlavor { perm_main_mem_ind_a_relation, perm_main_mem_ind_b_relation, perm_main_mem_ind_c_relation, -<<<<<<< HEAD + perm_main_mem_ind_d_relation, lookup_byte_lengths_relation, lookup_byte_operations_relation, incl_main_tag_err_relation, @@ -130,13 +106,6 @@ class AvmFlavor { lookup_u16_12_relation, lookup_u16_13_relation, lookup_u16_14_relation>; -======= - perm_main_mem_ind_d_relation, - lookup_byte_lengths_relation, - lookup_byte_operations_relation, - incl_main_tag_err_relation, - incl_mem_tag_err_relation>; ->>>>>>> e353f6a7d (5557: fixes after master rebase) using Relations = std::tuple, Avm_vm::avm_binary, @@ -151,8 +120,7 @@ class AvmFlavor { perm_main_mem_ind_a_relation, perm_main_mem_ind_b_relation, perm_main_mem_ind_c_relation, -<<<<<<< HEAD -<<<<<<< HEAD + perm_main_mem_ind_d_relation, lookup_byte_lengths_relation, lookup_byte_operations_relation, incl_main_tag_err_relation, @@ -174,23 +142,6 @@ class AvmFlavor { lookup_u16_12_relation, lookup_u16_13_relation, lookup_u16_14_relation>; -======= -<<<<<<< HEAD - incl_main_tag_err_relation, - incl_mem_tag_err_relation, - lookup_byte_lengths_relation, - lookup_byte_operations_relation>; -======= - perm_main_mem_ind_d_relation>; ->>>>>>> 7c841655b (5557: Add an additional intermediate register id) ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) -======= - perm_main_mem_ind_d_relation, - lookup_byte_lengths_relation, - lookup_byte_operations_relation, - incl_main_tag_err_relation, - incl_mem_tag_err_relation>; ->>>>>>> e353f6a7d (5557: fixes after master rebase) static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = compute_max_partial_relation_length(); @@ -1426,11 +1377,8 @@ class AvmFlavor { prover_polynomials, relation_parameters, this->circuit_size); bb::compute_logderivative_inverse>( prover_polynomials, relation_parameters, this->circuit_size); -<<<<<<< HEAD -======= bb::compute_logderivative_inverse>( prover_polynomials, relation_parameters, this->circuit_size); ->>>>>>> e353f6a7d (5557: fixes after master rebase) bb::compute_logderivative_inverse>( prover_polynomials, relation_parameters, this->circuit_size); bb::compute_logderivative_inverse>( @@ -1439,7 +1387,6 @@ class AvmFlavor { prover_polynomials, relation_parameters, this->circuit_size); bb::compute_logderivative_inverse>( prover_polynomials, relation_parameters, this->circuit_size); -<<<<<<< HEAD bb::compute_logderivative_inverse>( prover_polynomials, relation_parameters, this->circuit_size); bb::compute_logderivative_inverse>( @@ -1474,8 +1421,6 @@ class AvmFlavor { prover_polynomials, relation_parameters, this->circuit_size); bb::compute_logderivative_inverse>( prover_polynomials, relation_parameters, this->circuit_size); -======= ->>>>>>> e353f6a7d (5557: fixes after master rebase) } }; @@ -1966,23 +1911,11 @@ class AvmFlavor { Commitment perm_main_mem_ind_a; Commitment perm_main_mem_ind_b; Commitment perm_main_mem_ind_c; -<<<<<<< HEAD -<<<<<<< HEAD -======= -<<<<<<< HEAD - // Lookup inverses -======= - Commitment perm_main_mem_ind_d; ->>>>>>> 7c841655b (5557: Add an additional intermediate register id) ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) -======= Commitment perm_main_mem_ind_d; ->>>>>>> e353f6a7d (5557: fixes after master rebase) Commitment lookup_byte_lengths; Commitment lookup_byte_operations; Commitment incl_main_tag_err; Commitment incl_mem_tag_err; -<<<<<<< HEAD Commitment lookup_u8_0; Commitment lookup_u8_1; Commitment lookup_u16_0; @@ -2000,8 +1933,6 @@ class AvmFlavor { Commitment lookup_u16_12; Commitment lookup_u16_13; Commitment lookup_u16_14; -======= ->>>>>>> e353f6a7d (5557: fixes after master rebase) Commitment lookup_byte_lengths_counts; Commitment lookup_byte_operations_counts; Commitment incl_main_tag_err_counts; diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp index 2617809c13f..f204511330f 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp @@ -59,11 +59,8 @@ void AvmProver::execute_wire_commitments_round() // Commit to all polynomials (apart from logderivative inverse polynomials, which are committed to in the later // logderivative phase) -<<<<<<< HEAD witness_commitments.avm_alu_a_hi = commitment_key->commit(key->avm_alu_a_hi); witness_commitments.avm_alu_a_lo = commitment_key->commit(key->avm_alu_a_lo); -======= ->>>>>>> e353f6a7d (5557: fixes after master rebase) witness_commitments.avm_alu_alu_sel = commitment_key->commit(key->avm_alu_alu_sel); witness_commitments.avm_alu_b_hi = commitment_key->commit(key->avm_alu_b_hi); witness_commitments.avm_alu_b_lo = commitment_key->commit(key->avm_alu_b_lo); @@ -244,7 +241,6 @@ void AvmProver::execute_wire_commitments_round() witness_commitments.lookup_u16_14_counts = commitment_key->commit(key->lookup_u16_14_counts); // Send all commitments to the verifier -<<<<<<< HEAD transcript->send_to_verifier(commitment_labels.avm_alu_a_hi, witness_commitments.avm_alu_a_hi); transcript->send_to_verifier(commitment_labels.avm_alu_a_lo, witness_commitments.avm_alu_a_lo); transcript->send_to_verifier(commitment_labels.avm_alu_alu_sel, witness_commitments.avm_alu_alu_sel); @@ -255,11 +251,6 @@ void AvmProver::execute_wire_commitments_round() transcript->send_to_verifier(commitment_labels.avm_alu_clk, witness_commitments.avm_alu_clk); transcript->send_to_verifier(commitment_labels.avm_alu_cmp_rng_ctr, witness_commitments.avm_alu_cmp_rng_ctr); transcript->send_to_verifier(commitment_labels.avm_alu_cmp_sel, witness_commitments.avm_alu_cmp_sel); -======= - transcript->send_to_verifier(commitment_labels.avm_alu_alu_sel, witness_commitments.avm_alu_alu_sel); - transcript->send_to_verifier(commitment_labels.avm_alu_cf, witness_commitments.avm_alu_cf); - transcript->send_to_verifier(commitment_labels.avm_alu_clk, witness_commitments.avm_alu_clk); ->>>>>>> e353f6a7d (5557: fixes after master rebase) transcript->send_to_verifier(commitment_labels.avm_alu_ff_tag, witness_commitments.avm_alu_ff_tag); transcript->send_to_verifier(commitment_labels.avm_alu_ia, witness_commitments.avm_alu_ia); transcript->send_to_verifier(commitment_labels.avm_alu_ib, witness_commitments.avm_alu_ib); @@ -269,7 +260,6 @@ void AvmProver::execute_wire_commitments_round() transcript->send_to_verifier(commitment_labels.avm_alu_op_div, witness_commitments.avm_alu_op_div); transcript->send_to_verifier(commitment_labels.avm_alu_op_eq, witness_commitments.avm_alu_op_eq); transcript->send_to_verifier(commitment_labels.avm_alu_op_eq_diff_inv, witness_commitments.avm_alu_op_eq_diff_inv); -<<<<<<< HEAD transcript->send_to_verifier(commitment_labels.avm_alu_op_lt, witness_commitments.avm_alu_op_lt); transcript->send_to_verifier(commitment_labels.avm_alu_op_lte, witness_commitments.avm_alu_op_lte); transcript->send_to_verifier(commitment_labels.avm_alu_op_mul, witness_commitments.avm_alu_op_mul); @@ -286,11 +276,6 @@ void AvmProver::execute_wire_commitments_round() transcript->send_to_verifier(commitment_labels.avm_alu_rng_chk_lookup_selector, witness_commitments.avm_alu_rng_chk_lookup_selector); transcript->send_to_verifier(commitment_labels.avm_alu_rng_chk_sel, witness_commitments.avm_alu_rng_chk_sel); -======= - transcript->send_to_verifier(commitment_labels.avm_alu_op_mul, witness_commitments.avm_alu_op_mul); - transcript->send_to_verifier(commitment_labels.avm_alu_op_not, witness_commitments.avm_alu_op_not); - transcript->send_to_verifier(commitment_labels.avm_alu_op_sub, witness_commitments.avm_alu_op_sub); ->>>>>>> e353f6a7d (5557: fixes after master rebase) transcript->send_to_verifier(commitment_labels.avm_alu_u128_tag, witness_commitments.avm_alu_u128_tag); transcript->send_to_verifier(commitment_labels.avm_alu_u16_r0, witness_commitments.avm_alu_u16_r0); transcript->send_to_verifier(commitment_labels.avm_alu_u16_r1, witness_commitments.avm_alu_u16_r1); @@ -348,14 +333,6 @@ void AvmProver::execute_wire_commitments_round() transcript->send_to_verifier(commitment_labels.avm_main_ia, witness_commitments.avm_main_ia); transcript->send_to_verifier(commitment_labels.avm_main_ib, witness_commitments.avm_main_ib); transcript->send_to_verifier(commitment_labels.avm_main_ic, witness_commitments.avm_main_ic); -<<<<<<< HEAD - transcript->send_to_verifier(commitment_labels.avm_main_ind_a, witness_commitments.avm_main_ind_a); - transcript->send_to_verifier(commitment_labels.avm_main_ind_b, witness_commitments.avm_main_ind_b); - transcript->send_to_verifier(commitment_labels.avm_main_ind_c, witness_commitments.avm_main_ind_c); - transcript->send_to_verifier(commitment_labels.avm_main_ind_op_a, witness_commitments.avm_main_ind_op_a); - transcript->send_to_verifier(commitment_labels.avm_main_ind_op_b, witness_commitments.avm_main_ind_op_b); - transcript->send_to_verifier(commitment_labels.avm_main_ind_op_c, witness_commitments.avm_main_ind_op_c); -======= transcript->send_to_verifier(commitment_labels.avm_main_id, witness_commitments.avm_main_id); transcript->send_to_verifier(commitment_labels.avm_main_id_zero, witness_commitments.avm_main_id_zero); transcript->send_to_verifier(commitment_labels.avm_main_ind_a, witness_commitments.avm_main_ind_a); @@ -366,7 +343,6 @@ void AvmProver::execute_wire_commitments_round() transcript->send_to_verifier(commitment_labels.avm_main_ind_op_b, witness_commitments.avm_main_ind_op_b); transcript->send_to_verifier(commitment_labels.avm_main_ind_op_c, witness_commitments.avm_main_ind_op_c); transcript->send_to_verifier(commitment_labels.avm_main_ind_op_d, witness_commitments.avm_main_ind_op_d); ->>>>>>> e353f6a7d (5557: fixes after master rebase) transcript->send_to_verifier(commitment_labels.avm_main_internal_return_ptr, witness_commitments.avm_main_internal_return_ptr); transcript->send_to_verifier(commitment_labels.avm_main_inv, witness_commitments.avm_main_inv); @@ -374,28 +350,19 @@ void AvmProver::execute_wire_commitments_round() transcript->send_to_verifier(commitment_labels.avm_main_mem_idx_a, witness_commitments.avm_main_mem_idx_a); transcript->send_to_verifier(commitment_labels.avm_main_mem_idx_b, witness_commitments.avm_main_mem_idx_b); transcript->send_to_verifier(commitment_labels.avm_main_mem_idx_c, witness_commitments.avm_main_mem_idx_c); -<<<<<<< HEAD - transcript->send_to_verifier(commitment_labels.avm_main_mem_op_a, witness_commitments.avm_main_mem_op_a); - transcript->send_to_verifier(commitment_labels.avm_main_mem_op_b, witness_commitments.avm_main_mem_op_b); - transcript->send_to_verifier(commitment_labels.avm_main_mem_op_c, witness_commitments.avm_main_mem_op_c); -======= transcript->send_to_verifier(commitment_labels.avm_main_mem_idx_d, witness_commitments.avm_main_mem_idx_d); transcript->send_to_verifier(commitment_labels.avm_main_mem_op_a, witness_commitments.avm_main_mem_op_a); transcript->send_to_verifier(commitment_labels.avm_main_mem_op_b, witness_commitments.avm_main_mem_op_b); transcript->send_to_verifier(commitment_labels.avm_main_mem_op_c, witness_commitments.avm_main_mem_op_c); transcript->send_to_verifier(commitment_labels.avm_main_mem_op_d, witness_commitments.avm_main_mem_op_d); ->>>>>>> e353f6a7d (5557: fixes after master rebase) transcript->send_to_verifier(commitment_labels.avm_main_op_err, witness_commitments.avm_main_op_err); transcript->send_to_verifier(commitment_labels.avm_main_pc, witness_commitments.avm_main_pc); transcript->send_to_verifier(commitment_labels.avm_main_r_in_tag, witness_commitments.avm_main_r_in_tag); transcript->send_to_verifier(commitment_labels.avm_main_rwa, witness_commitments.avm_main_rwa); transcript->send_to_verifier(commitment_labels.avm_main_rwb, witness_commitments.avm_main_rwb); transcript->send_to_verifier(commitment_labels.avm_main_rwc, witness_commitments.avm_main_rwc); -<<<<<<< HEAD -======= 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); ->>>>>>> e353f6a7d (5557: fixes after master rebase) 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); @@ -403,20 +370,14 @@ void AvmProver::execute_wire_commitments_round() witness_commitments.avm_main_sel_internal_return); transcript->send_to_verifier(commitment_labels.avm_main_sel_jump, witness_commitments.avm_main_sel_jump); transcript->send_to_verifier(commitment_labels.avm_main_sel_mov, witness_commitments.avm_main_sel_mov); -<<<<<<< HEAD -======= transcript->send_to_verifier(commitment_labels.avm_main_sel_mov_a, witness_commitments.avm_main_sel_mov_a); transcript->send_to_verifier(commitment_labels.avm_main_sel_mov_b, witness_commitments.avm_main_sel_mov_b); ->>>>>>> e353f6a7d (5557: fixes after master rebase) transcript->send_to_verifier(commitment_labels.avm_main_sel_op_add, witness_commitments.avm_main_sel_op_add); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_and, witness_commitments.avm_main_sel_op_and); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_div, witness_commitments.avm_main_sel_op_div); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_eq, witness_commitments.avm_main_sel_op_eq); -<<<<<<< HEAD transcript->send_to_verifier(commitment_labels.avm_main_sel_op_lt, witness_commitments.avm_main_sel_op_lt); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_lte, witness_commitments.avm_main_sel_op_lte); -======= ->>>>>>> e353f6a7d (5557: fixes after master rebase) transcript->send_to_verifier(commitment_labels.avm_main_sel_op_mul, witness_commitments.avm_main_sel_op_mul); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_not, witness_commitments.avm_main_sel_op_not); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_or, witness_commitments.avm_main_sel_op_or); @@ -431,21 +392,13 @@ void AvmProver::execute_wire_commitments_round() transcript->send_to_verifier(commitment_labels.avm_mem_ind_op_a, witness_commitments.avm_mem_ind_op_a); transcript->send_to_verifier(commitment_labels.avm_mem_ind_op_b, witness_commitments.avm_mem_ind_op_b); transcript->send_to_verifier(commitment_labels.avm_mem_ind_op_c, witness_commitments.avm_mem_ind_op_c); -<<<<<<< HEAD -======= transcript->send_to_verifier(commitment_labels.avm_mem_ind_op_d, witness_commitments.avm_mem_ind_op_d); ->>>>>>> e353f6a7d (5557: fixes after master rebase) transcript->send_to_verifier(commitment_labels.avm_mem_last, witness_commitments.avm_mem_last); transcript->send_to_verifier(commitment_labels.avm_mem_lastAccess, witness_commitments.avm_mem_lastAccess); transcript->send_to_verifier(commitment_labels.avm_mem_one_min_inv, witness_commitments.avm_mem_one_min_inv); transcript->send_to_verifier(commitment_labels.avm_mem_op_a, witness_commitments.avm_mem_op_a); transcript->send_to_verifier(commitment_labels.avm_mem_op_b, witness_commitments.avm_mem_op_b); transcript->send_to_verifier(commitment_labels.avm_mem_op_c, witness_commitments.avm_mem_op_c); -<<<<<<< HEAD - transcript->send_to_verifier(commitment_labels.avm_mem_r_in_tag, witness_commitments.avm_mem_r_in_tag); - transcript->send_to_verifier(commitment_labels.avm_mem_rw, witness_commitments.avm_mem_rw); - transcript->send_to_verifier(commitment_labels.avm_mem_sel_mov, witness_commitments.avm_mem_sel_mov); -======= transcript->send_to_verifier(commitment_labels.avm_mem_op_d, witness_commitments.avm_mem_op_d); transcript->send_to_verifier(commitment_labels.avm_mem_r_in_tag, witness_commitments.avm_mem_r_in_tag); transcript->send_to_verifier(commitment_labels.avm_mem_rw, witness_commitments.avm_mem_rw); @@ -453,7 +406,6 @@ void AvmProver::execute_wire_commitments_round() transcript->send_to_verifier(commitment_labels.avm_mem_sel_mov_a, witness_commitments.avm_mem_sel_mov_a); transcript->send_to_verifier(commitment_labels.avm_mem_sel_mov_b, witness_commitments.avm_mem_sel_mov_b); transcript->send_to_verifier(commitment_labels.avm_mem_skip_check_tag, witness_commitments.avm_mem_skip_check_tag); ->>>>>>> e353f6a7d (5557: fixes after master rebase) transcript->send_to_verifier(commitment_labels.avm_mem_sub_clk, witness_commitments.avm_mem_sub_clk); transcript->send_to_verifier(commitment_labels.avm_mem_tag, witness_commitments.avm_mem_tag); transcript->send_to_verifier(commitment_labels.avm_mem_tag_err, witness_commitments.avm_mem_tag_err); @@ -467,7 +419,6 @@ void AvmProver::execute_wire_commitments_round() witness_commitments.incl_main_tag_err_counts); transcript->send_to_verifier(commitment_labels.incl_mem_tag_err_counts, witness_commitments.incl_mem_tag_err_counts); -<<<<<<< HEAD transcript->send_to_verifier(commitment_labels.lookup_u8_0_counts, witness_commitments.lookup_u8_0_counts); transcript->send_to_verifier(commitment_labels.lookup_u8_1_counts, witness_commitments.lookup_u8_1_counts); transcript->send_to_verifier(commitment_labels.lookup_u16_0_counts, witness_commitments.lookup_u16_0_counts); @@ -485,8 +436,6 @@ void AvmProver::execute_wire_commitments_round() transcript->send_to_verifier(commitment_labels.lookup_u16_12_counts, witness_commitments.lookup_u16_12_counts); transcript->send_to_verifier(commitment_labels.lookup_u16_13_counts, witness_commitments.lookup_u16_13_counts); transcript->send_to_verifier(commitment_labels.lookup_u16_14_counts, witness_commitments.lookup_u16_14_counts); -======= ->>>>>>> e353f6a7d (5557: fixes after master rebase) } void AvmProver::execute_log_derivative_inverse_round() @@ -508,15 +457,11 @@ void AvmProver::execute_log_derivative_inverse_round() witness_commitments.perm_main_mem_ind_a = commitment_key->commit(key->perm_main_mem_ind_a); witness_commitments.perm_main_mem_ind_b = commitment_key->commit(key->perm_main_mem_ind_b); witness_commitments.perm_main_mem_ind_c = commitment_key->commit(key->perm_main_mem_ind_c); -<<<<<<< HEAD -======= witness_commitments.perm_main_mem_ind_d = commitment_key->commit(key->perm_main_mem_ind_d); ->>>>>>> e353f6a7d (5557: fixes after master rebase) witness_commitments.lookup_byte_lengths = commitment_key->commit(key->lookup_byte_lengths); witness_commitments.lookup_byte_operations = commitment_key->commit(key->lookup_byte_operations); witness_commitments.incl_main_tag_err = commitment_key->commit(key->incl_main_tag_err); witness_commitments.incl_mem_tag_err = commitment_key->commit(key->incl_mem_tag_err); -<<<<<<< HEAD witness_commitments.lookup_u8_0 = commitment_key->commit(key->lookup_u8_0); witness_commitments.lookup_u8_1 = commitment_key->commit(key->lookup_u8_1); witness_commitments.lookup_u16_0 = commitment_key->commit(key->lookup_u16_0); @@ -534,8 +479,6 @@ void AvmProver::execute_log_derivative_inverse_round() witness_commitments.lookup_u16_12 = commitment_key->commit(key->lookup_u16_12); witness_commitments.lookup_u16_13 = commitment_key->commit(key->lookup_u16_13); witness_commitments.lookup_u16_14 = commitment_key->commit(key->lookup_u16_14); -======= ->>>>>>> e353f6a7d (5557: fixes after master rebase) // Send all commitments to the verifier transcript->send_to_verifier(commitment_labels.perm_main_alu, witness_commitments.perm_main_alu); @@ -543,22 +486,15 @@ void AvmProver::execute_log_derivative_inverse_round() transcript->send_to_verifier(commitment_labels.perm_main_mem_a, witness_commitments.perm_main_mem_a); transcript->send_to_verifier(commitment_labels.perm_main_mem_b, witness_commitments.perm_main_mem_b); transcript->send_to_verifier(commitment_labels.perm_main_mem_c, witness_commitments.perm_main_mem_c); -<<<<<<< HEAD - transcript->send_to_verifier(commitment_labels.perm_main_mem_ind_a, witness_commitments.perm_main_mem_ind_a); - transcript->send_to_verifier(commitment_labels.perm_main_mem_ind_b, witness_commitments.perm_main_mem_ind_b); - transcript->send_to_verifier(commitment_labels.perm_main_mem_ind_c, witness_commitments.perm_main_mem_ind_c); -======= transcript->send_to_verifier(commitment_labels.perm_main_mem_d, witness_commitments.perm_main_mem_d); transcript->send_to_verifier(commitment_labels.perm_main_mem_ind_a, witness_commitments.perm_main_mem_ind_a); transcript->send_to_verifier(commitment_labels.perm_main_mem_ind_b, witness_commitments.perm_main_mem_ind_b); transcript->send_to_verifier(commitment_labels.perm_main_mem_ind_c, witness_commitments.perm_main_mem_ind_c); transcript->send_to_verifier(commitment_labels.perm_main_mem_ind_d, witness_commitments.perm_main_mem_ind_d); ->>>>>>> e353f6a7d (5557: fixes after master rebase) transcript->send_to_verifier(commitment_labels.lookup_byte_lengths, witness_commitments.lookup_byte_lengths); transcript->send_to_verifier(commitment_labels.lookup_byte_operations, witness_commitments.lookup_byte_operations); transcript->send_to_verifier(commitment_labels.incl_main_tag_err, witness_commitments.incl_main_tag_err); transcript->send_to_verifier(commitment_labels.incl_mem_tag_err, witness_commitments.incl_mem_tag_err); -<<<<<<< HEAD transcript->send_to_verifier(commitment_labels.lookup_u8_0, witness_commitments.lookup_u8_0); transcript->send_to_verifier(commitment_labels.lookup_u8_1, witness_commitments.lookup_u8_1); transcript->send_to_verifier(commitment_labels.lookup_u16_0, witness_commitments.lookup_u16_0); @@ -576,8 +512,6 @@ void AvmProver::execute_log_derivative_inverse_round() transcript->send_to_verifier(commitment_labels.lookup_u16_12, witness_commitments.lookup_u16_12); transcript->send_to_verifier(commitment_labels.lookup_u16_13, witness_commitments.lookup_u16_13); transcript->send_to_verifier(commitment_labels.lookup_u16_14, witness_commitments.lookup_u16_14); -======= ->>>>>>> e353f6a7d (5557: fixes after master rebase) } /** diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp index 6584ac3943a..e195267791b 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp @@ -369,21 +369,8 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) transcript->template receive_from_prover(commitment_labels.perm_main_mem_ind_b); commitments.perm_main_mem_ind_c = transcript->template receive_from_prover(commitment_labels.perm_main_mem_ind_c); -<<<<<<< HEAD -<<<<<<< HEAD -======= -<<<<<<< HEAD - - // Lookups -======= - commitments.perm_main_mem_ind_d = - transcript->template receive_from_prover(commitment_labels.perm_main_mem_ind_d); ->>>>>>> 7c841655b (5557: Add an additional intermediate register id) ->>>>>>> d0b1584f6 (5557: Add an additional intermediate register id) -======= commitments.perm_main_mem_ind_d = transcript->template receive_from_prover(commitment_labels.perm_main_mem_ind_d); ->>>>>>> e353f6a7d (5557: fixes after master rebase) commitments.lookup_byte_lengths = transcript->template receive_from_prover(commitment_labels.lookup_byte_lengths); commitments.lookup_byte_operations =