From 4a38481abb7dbd5fc59bf9f6128a602bb82b7ba8 Mon Sep 17 00:00:00 2001 From: IlyasRidhuan Date: Tue, 2 Apr 2024 11:19:41 +0000 Subject: [PATCH 01/18] feat: init avm cmp --- barretenberg/cpp/pil/avm/avm_cmp.pil | 120 ++ barretenberg/cpp/pil/avm/avm_main.pil | 21 +- .../relations/generated/avm/avm_alu.hpp | 84 +- .../relations/generated/avm/avm_binary.hpp | 34 +- .../relations/generated/avm/avm_cmp.hpp | 198 ++ .../relations/generated/avm/avm_main.hpp | 256 ++- .../relations/generated/avm/avm_mem.hpp | 52 +- .../relations/generated/avm/declare_views.hpp | 213 +- .../relations/generated/avm/perm_main_cmp.hpp | 98 + .../vm/generated/avm_circuit_builder.hpp | 457 ++-- .../barretenberg/vm/generated/avm_flavor.hpp | 1829 ++++++++++------- .../vm/generated/avm_verifier.cpp | 238 ++- 12 files changed, 2323 insertions(+), 1277 deletions(-) create mode 100644 barretenberg/cpp/pil/avm/avm_cmp.pil create mode 100644 barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_cmp.hpp create mode 100644 barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_cmp.hpp diff --git a/barretenberg/cpp/pil/avm/avm_cmp.pil b/barretenberg/cpp/pil/avm/avm_cmp.pil new file mode 100644 index 000000000000..219f99da0c42 --- /dev/null +++ b/barretenberg/cpp/pil/avm/avm_cmp.pil @@ -0,0 +1,120 @@ + +namespace avm_cmp(256); + + pol commit cmp_clk; + + // Copied from main trace + pol commit ia; + pol commit ib; + pol commit ic; //should be boolean + ic * (1 - ic) = 0; + + // Selectors for LT or LTE + pol commit lt_sel; + pol commit lte_sel; + pol commit cmp_sel; // Used for perm check to main + cmp_sel = lt_sel + lte_sel; + + // Both are restricted to booleans + lt_sel * (1 - lt_sel) = 0; + lte_sel * (1 - lte_sel) = 0; + + // NAND check for selectors + lt_sel * lte_sel = 0; + + + // There are two routines that we utilise as part of this LT/LTE check + // (1) Decomposition into two 128-bit limbs, lo and hi respectively and a borrow (1 or 0); + // (2) 128 bit range checks when checking an arithmetic operations has not overflowed the field. + + // ========= COMPARISON OPERATION - EXPLANATIONS ================================================= + // To simplify the comparison circuit, we implement a GreaterThan(GT) circuit. This is ideal since + // if we need a LT operation, we just swap the inputs and if we need the LTE operation, we just NOT the query + // Given the inputs x, y and q where x & y are inputs and q is the boolean result to the query (x > y). Then there are two scenarios + // (x > y) -> x - y - 1 = result, where 0 <= result < p. In our case result should not overflow the field. + // OR + // !(x > y) -> !(x - y - 1) = (p - 1) - (x - y -1) = y - x = result, where the same applies as above. + // These conditions can be combined with the query, q (that x > y) as follows: + // (x - y - 1) * q + (y - x) (1 - q) = result + + pol commit input_ia; + pol commit input_ib; + + //If LT, then swap ia and ib else keep the same + input_ia = lt_sel * ib + lte_sel * ia; + input_ib = lt_sel * ia + lte_sel * ib; + + pol commit a_lo; + pol commit a_hi; + pol commit b_lo; + pol commit b_hi; + pol commit borrow; + + // Lo 128-bits of the field modulus: 53438638232309528389504892708671455233 + pol commit p_lo; + // Hi 128-bits of the field modulus: 64323764613183177041862057485226039389 + pol commit p_hi; + + // Check inputs are well formed from lo and hi parts + input_ia = a_lo + 2 ** 128 * a_hi; + input_ib = b_lo + 2 ** 128 * b_hi; + + // TODO: Check that all inputs are valid ranges over the integers + // 128-bit Range check a_lo + // 128-bit Range check a_hi + // 128-bit Range check b_lo + // 128-bit Range check b_hi + + // Used to check 128-bit decomposition of input_ia does not overflow the field + pol commit p_sub_a_lo; // p_lo - a_lo + pol commit p_sub_a_hi; // p_hi - a_hi + pol commit p_a_borrow; + + // Check that (p > a) by checking (p_lo > a_lo && p_hi >= ahi) || (p_lo <= a_lo && p_hi > a_hi) + // First condition is if borrow = 0, second condition is if borrow = 1; + p_sub_a_lo = p_lo - a_lo + p_a_borrow * 2 ** 128; + p_sub_a_hi = p_hi - a_hi - p_a_borrow; + + // Used to check 128-bit decomposition of inpu_ib does not overflow the field + pol commit p_sub_b_lo; + pol commit p_sub_b_hi; + pol commit p_b_borrow; + + p_sub_b_lo = p_lo - b_lo + p_b_borrow * 2 ** 128; + p_sub_b_hi = p_hi - b_hi - p_b_borrow; + + // TODO More range checks + // 128-bit Range check p_sub_a_lo + // 128-bit Range check p_lo_sub_a_hi + // 128-bit Range check p_sub_b_lo + // 2**128 == 2^128 + // 128-bit Range check p_lo_sub_b_hi + + + // Calculate the combined relation: (a - b - 1) * q + (b -a ) * (1-q) + + // Check that (a > b) by checking (a_lo > b_lo && a_hi >= bhi) || (alo <= b_lo && a_hi > b_hi) + // First condition is if borrow = 0, second condition is if borrow = 1; + pol A_SUB_B_LO = a_lo - b_lo - 1 + borrow * 2 ** 128; + pol A_SUB_B_HI = a_hi - b_hi - borrow; + + // Check that (a <= b) by checking (b_lo >= a_lo && b_hi >= a_hi) || (b_lo > a_lo && b_hi >= a_hi) + // First condition is if borrow = 0, second condition is if borrow = 1; + pol B_SUB_A_LO = b_lo - a_lo + borrow * 2 ** 128; + pol B_SUB_A_HI = b_hi - a_hi - borrow; + + pol commit res_lo; + pol commit res_hi; + pol commit lt_query; + + // If LT_SEL, we would have already swapped the input so the boolean in ic is still correct + // If LTE_SEL, we did not swap the input and we want to NOT the value of ic. + lt_query = lt_sel * ic + (1 - ic) * lte_sel; + + res_lo = A_SUB_B_LO * lt_query + B_SUB_A_LO * (1 - lt_query); + res_hi = A_SUB_B_HI * lt_query + B_SUB_A_HI * (1 - lt_query); + + // 128-bit Range check res_lo + // 128-bit Range check res_hi + + diff --git a/barretenberg/cpp/pil/avm/avm_main.pil b/barretenberg/cpp/pil/avm/avm_main.pil index 5e0b27d6a30c..9d704ab6ac6a 100644 --- a/barretenberg/cpp/pil/avm/avm_main.pil +++ b/barretenberg/cpp/pil/avm/avm_main.pil @@ -2,6 +2,7 @@ include "avm_mem.pil"; include "avm_alu.pil"; include "avm_binary.pil"; +include "avm_cmp.pil"; namespace avm_main(256); @@ -53,6 +54,10 @@ namespace avm_main(256); pol commit sel_op_or; // XOR pol commit sel_op_xor; + // LT + pol commit sel_op_lt; + // LTE + pol commit sel_op_lte; // Helper selector to characterize an ALU chiplet selector pol commit alu_sel; @@ -60,6 +65,9 @@ namespace avm_main(256); // Helper selector to characterize a Binary chiplet selector pol commit bin_sel; + // Helper selector to characterize a Cmp chiplet selector + pol commit cmp_sel; + // Instruction memory tags read/write (1: u8, 2: u16, 3: u32, 4: u64, 5: u128, 6: field) pol commit r_in_tag; pol commit w_in_tag; @@ -121,6 +129,8 @@ namespace avm_main(256); sel_op_and * (1 - sel_op_and) = 0; sel_op_or * (1 - sel_op_or) = 0; sel_op_xor * (1 - sel_op_xor) = 0; + sel_op_lt * (1 - sel_op_lt) = 0; + sel_op_lte * (1 - sel_op_lte) = 0; sel_internal_call * (1 - sel_internal_call) = 0; sel_internal_return * (1 - sel_internal_return) = 0; @@ -275,12 +285,21 @@ namespace avm_main(256); // the operation decomposition step during bytecode unpacking. #[BIN_SEL_2] bin_sel = sel_op_and + sel_op_or + sel_op_xor; + + // Only 1 of these cmp selectors should be set + #[CMP_SEL] + cmp_sel = sel_op_lt + sel_op_lte; #[PERM_MAIN_BIN] bin_sel {ia, ib, ic, bin_op_id, r_in_tag} is avm_binary.start {avm_binary.acc_ia, avm_binary.acc_ib, avm_binary.acc_ic, avm_binary.op_id, avm_binary.in_tag}; + #[PERM_MAIN_CMP] + cmp_sel {ia, ib, ic} + is + avm_cmp.cmp_sel {avm_cmp.ia, avm_cmp.ib, avm_cmp.ic}; + #[PERM_MAIN_MEM_A] mem_op_a {clk, mem_idx_a, ia, rwa, r_in_tag, w_in_tag, sel_mov} is @@ -303,4 +322,4 @@ namespace avm_main(256); ind_op_b {clk, ind_b, mem_idx_b} is avm_mem.ind_op_b {avm_mem.clk, avm_mem.addr, avm_mem.val}; #[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}; \ No newline at end of file + ind_op_c {clk, ind_c, mem_idx_c} is avm_mem.ind_op_c {avm_mem.clk, avm_mem.addr, avm_mem.val}; 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 ef98385518f6..9ba9c19961a1 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_alu.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_alu.hpp @@ -7,77 +7,77 @@ namespace bb::Avm_vm { template struct Avm_aluRow { - FF avm_alu_alu_sel{}; - FF avm_alu_cf{}; - FF avm_alu_ff_tag{}; - FF avm_alu_ia{}; - FF avm_alu_ib{}; - FF avm_alu_ic{}; - FF avm_alu_in_tag{}; - FF avm_alu_op_add{}; - FF avm_alu_op_eq{}; - FF avm_alu_op_eq_diff_inv{}; - FF avm_alu_op_mul{}; - FF avm_alu_op_not{}; - FF avm_alu_op_sub{}; - FF avm_alu_u128_tag{}; FF avm_alu_u16_r0{}; FF avm_alu_u16_r0_shift{}; - FF avm_alu_u16_r1{}; - FF avm_alu_u16_r1_shift{}; - FF avm_alu_u16_r2{}; - FF avm_alu_u16_r2_shift{}; + FF avm_alu_u8_r1{}; + FF avm_alu_u32_tag{}; + FF avm_alu_u16_r7{}; + FF avm_alu_op_add{}; FF avm_alu_u16_r3{}; FF avm_alu_u16_r3_shift{}; - FF avm_alu_u16_r4{}; FF avm_alu_u16_r4_shift{}; - FF avm_alu_u16_r5{}; - FF avm_alu_u16_r5_shift{}; - FF avm_alu_u16_r6{}; - FF avm_alu_u16_r6_shift{}; - FF avm_alu_u16_r7{}; + FF avm_alu_u64_r0{}; FF avm_alu_u16_r7_shift{}; FF avm_alu_u16_tag{}; - FF avm_alu_u32_tag{}; - FF avm_alu_u64_r0{}; + FF avm_alu_cf{}; + FF avm_alu_in_tag{}; + FF avm_alu_u16_r6_shift{}; + FF avm_alu_op_sub{}; + FF avm_alu_ff_tag{}; FF avm_alu_u64_tag{}; + FF avm_alu_alu_sel{}; + FF avm_alu_op_eq_diff_inv{}; + FF avm_alu_u16_r1{}; + FF avm_alu_u16_r2_shift{}; + FF avm_alu_u16_r5_shift{}; + FF avm_alu_ia{}; + FF avm_alu_op_eq{}; + FF avm_alu_u16_r1_shift{}; FF avm_alu_u8_r0{}; - FF avm_alu_u8_r1{}; + FF avm_alu_u16_r2{}; + FF avm_alu_u16_r5{}; + FF avm_alu_ic{}; + FF avm_alu_op_mul{}; + FF avm_alu_u16_r6{}; + FF avm_alu_u16_r4{}; FF avm_alu_u8_tag{}; + FF avm_alu_op_not{}; + FF avm_alu_u128_tag{}; + FF avm_alu_ib{}; }; inline std::string get_relation_label_avm_alu(int index) { switch (index) { + case 11: + return "ALU_MULTIPLICATION_FF"; + + case 16: + return "ALU_MULTIPLICATION_OUT_U128"; + + case 19: + return "ALU_RES_IS_BOOL"; + case 9: return "ALU_ADD_SUB_1"; case 10: return "ALU_ADD_SUB_2"; - case 11: - return "ALU_MULTIPLICATION_FF"; - case 12: return "ALU_MUL_COMMON_1"; - case 13: - return "ALU_MUL_COMMON_2"; - - case 16: - return "ALU_MULTIPLICATION_OUT_U128"; - - case 17: - return "ALU_FF_NOT_XOR"; - case 18: return "ALU_OP_NOT"; - case 19: - return "ALU_RES_IS_BOOL"; - case 20: return "ALU_OP_EQ"; + + case 13: + return "ALU_MUL_COMMON_2"; + + case 17: + return "ALU_FF_NOT_XOR"; } return std::to_string(index); } diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_binary.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_binary.hpp index e58112cbfd7c..6ddb6b13f59f 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_binary.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_binary.hpp @@ -7,43 +7,43 @@ namespace bb::Avm_vm { template struct Avm_binaryRow { - FF avm_binary_acc_ia{}; - FF avm_binary_acc_ia_shift{}; - FF avm_binary_acc_ib{}; - FF avm_binary_acc_ib_shift{}; - FF avm_binary_acc_ic{}; FF avm_binary_acc_ic_shift{}; FF avm_binary_bin_sel{}; + FF avm_binary_op_id{}; FF avm_binary_ia_bytes{}; - FF avm_binary_ib_bytes{}; - FF avm_binary_ic_bytes{}; - FF avm_binary_mem_tag_ctr{}; + FF avm_binary_acc_ia{}; + FF avm_binary_acc_ic{}; + FF avm_binary_op_id_shift{}; FF avm_binary_mem_tag_ctr_inv{}; FF avm_binary_mem_tag_ctr_shift{}; - FF avm_binary_op_id{}; - FF avm_binary_op_id_shift{}; + FF avm_binary_ic_bytes{}; + FF avm_binary_acc_ib{}; + FF avm_binary_acc_ia_shift{}; + FF avm_binary_ib_bytes{}; + FF avm_binary_acc_ib_shift{}; + FF avm_binary_mem_tag_ctr{}; }; inline std::string get_relation_label_avm_binary(int index) { switch (index) { - case 1: - return "OP_ID_REL"; + case 9: + return "ACC_REL_C"; + + case 3: + return "BIN_SEL_CTR_REL"; case 2: return "MEM_TAG_REL"; - case 3: - return "BIN_SEL_CTR_REL"; + case 1: + return "OP_ID_REL"; case 7: return "ACC_REL_A"; case 8: return "ACC_REL_B"; - - case 9: - return "ACC_REL_C"; } return std::to_string(index); } diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_cmp.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_cmp.hpp new file mode 100644 index 000000000000..b12ac1c2e1cd --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_cmp.hpp @@ -0,0 +1,198 @@ + +#pragma once +#include "../../relation_parameters.hpp" +#include "../../relation_types.hpp" +#include "./declare_views.hpp" + +namespace bb::Avm_vm { + +template struct Avm_cmpRow { + FF avm_cmp_p_sub_a_hi{}; + FF avm_cmp_a_hi{}; + FF avm_cmp_lt_query{}; + FF avm_cmp_b_lo{}; + FF avm_cmp_p_sub_a_lo{}; + FF avm_cmp_res_lo{}; + FF avm_cmp_borrow{}; + FF avm_cmp_input_ia{}; + FF avm_cmp_p_sub_b_hi{}; + FF avm_cmp_lte_sel{}; + FF avm_cmp_ic{}; + FF avm_cmp_ib{}; + FF avm_cmp_cmp_sel{}; + FF avm_cmp_a_lo{}; + FF avm_cmp_p_hi{}; + FF avm_cmp_p_lo{}; + FF avm_cmp_input_ib{}; + FF avm_cmp_p_b_borrow{}; + FF avm_cmp_p_a_borrow{}; + FF avm_cmp_res_hi{}; + FF avm_cmp_lt_sel{}; + FF avm_cmp_ia{}; + FF avm_cmp_p_sub_b_lo{}; + FF avm_cmp_b_hi{}; +}; + +inline std::string get_relation_label_avm_cmp(int index) +{ + switch (index) {} + return std::to_string(index); +} + +template class avm_cmpImpl { + public: + using FF = FF_; + + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 2, 3, 4, 3, + }; + + template + void static accumulate(ContainerOverSubrelations& evals, + const AllEntities& new_term, + [[maybe_unused]] const RelationParameters&, + [[maybe_unused]] const FF& scaling_factor) + { + + // Contribution 0 + { + Avm_DECLARE_VIEWS(0); + + auto tmp = (avm_cmp_ic * (-avm_cmp_ic + FF(1))); + tmp *= scaling_factor; + std::get<0>(evals) += tmp; + } + // Contribution 1 + { + Avm_DECLARE_VIEWS(1); + + auto tmp = (avm_cmp_cmp_sel - (avm_cmp_lt_sel + avm_cmp_lte_sel)); + tmp *= scaling_factor; + std::get<1>(evals) += tmp; + } + // Contribution 2 + { + Avm_DECLARE_VIEWS(2); + + auto tmp = (avm_cmp_lt_sel * (-avm_cmp_lt_sel + FF(1))); + tmp *= scaling_factor; + std::get<2>(evals) += tmp; + } + // Contribution 3 + { + Avm_DECLARE_VIEWS(3); + + auto tmp = (avm_cmp_lte_sel * (-avm_cmp_lte_sel + FF(1))); + tmp *= scaling_factor; + std::get<3>(evals) += tmp; + } + // Contribution 4 + { + Avm_DECLARE_VIEWS(4); + + auto tmp = (avm_cmp_lt_sel * avm_cmp_lte_sel); + tmp *= scaling_factor; + std::get<4>(evals) += tmp; + } + // Contribution 5 + { + Avm_DECLARE_VIEWS(5); + + auto tmp = (avm_cmp_input_ia - ((avm_cmp_lt_sel * avm_cmp_ib) + (avm_cmp_lte_sel * avm_cmp_ia))); + tmp *= scaling_factor; + std::get<5>(evals) += tmp; + } + // Contribution 6 + { + Avm_DECLARE_VIEWS(6); + + auto tmp = (avm_cmp_input_ib - ((avm_cmp_lt_sel * avm_cmp_ia) + (avm_cmp_lte_sel * avm_cmp_ib))); + tmp *= scaling_factor; + std::get<6>(evals) += tmp; + } + // Contribution 7 + { + Avm_DECLARE_VIEWS(7); + + auto tmp = (avm_cmp_input_ia - (avm_cmp_a_lo + (avm_cmp_a_hi * FF(uint256_t{ 0, 0, 1, 0 })))); + tmp *= scaling_factor; + std::get<7>(evals) += tmp; + } + // Contribution 8 + { + Avm_DECLARE_VIEWS(8); + + auto tmp = (avm_cmp_input_ib - (avm_cmp_b_lo + (avm_cmp_b_hi * FF(uint256_t{ 0, 0, 1, 0 })))); + tmp *= scaling_factor; + std::get<8>(evals) += tmp; + } + // Contribution 9 + { + Avm_DECLARE_VIEWS(9); + + auto tmp = (avm_cmp_p_sub_a_lo - + ((avm_cmp_p_lo - avm_cmp_a_lo) + (avm_cmp_p_a_borrow * FF(uint256_t{ 0, 0, 1, 0 })))); + tmp *= scaling_factor; + std::get<9>(evals) += tmp; + } + // Contribution 10 + { + Avm_DECLARE_VIEWS(10); + + auto tmp = (avm_cmp_p_sub_a_hi - ((avm_cmp_p_hi - avm_cmp_a_hi) - avm_cmp_p_a_borrow)); + tmp *= scaling_factor; + std::get<10>(evals) += tmp; + } + // Contribution 11 + { + Avm_DECLARE_VIEWS(11); + + auto tmp = (avm_cmp_p_sub_b_lo - + ((avm_cmp_p_lo - avm_cmp_b_lo) + (avm_cmp_p_b_borrow * FF(uint256_t{ 0, 0, 1, 0 })))); + tmp *= scaling_factor; + std::get<11>(evals) += tmp; + } + // Contribution 12 + { + Avm_DECLARE_VIEWS(12); + + auto tmp = (avm_cmp_p_sub_b_hi - ((avm_cmp_p_hi - avm_cmp_b_hi) - avm_cmp_p_b_borrow)); + tmp *= scaling_factor; + std::get<12>(evals) += tmp; + } + // Contribution 13 + { + Avm_DECLARE_VIEWS(13); + + auto tmp = (avm_cmp_lt_query - ((avm_cmp_lt_sel * avm_cmp_ic) + ((-avm_cmp_ic + FF(1)) * avm_cmp_lte_sel))); + tmp *= scaling_factor; + std::get<13>(evals) += tmp; + } + // Contribution 14 + { + Avm_DECLARE_VIEWS(14); + + auto tmp = (avm_cmp_res_lo - + (((((avm_cmp_a_lo - avm_cmp_b_lo) - FF(1)) + (avm_cmp_borrow * FF(uint256_t{ 0, 0, 1, 0 }))) * + avm_cmp_lt_query) + + (((avm_cmp_b_lo - avm_cmp_a_lo) + (avm_cmp_borrow * FF(uint256_t{ 0, 0, 1, 0 }))) * + (-avm_cmp_lt_query + FF(1))))); + tmp *= scaling_factor; + std::get<14>(evals) += tmp; + } + // Contribution 15 + { + Avm_DECLARE_VIEWS(15); + + auto tmp = + (avm_cmp_res_hi - ((((avm_cmp_a_hi - avm_cmp_b_hi) - avm_cmp_borrow) * avm_cmp_lt_query) + + (((avm_cmp_b_hi - avm_cmp_a_hi) - avm_cmp_borrow) * (-avm_cmp_lt_query + FF(1))))); + tmp *= scaling_factor; + std::get<15>(evals) += tmp; + } + } +}; + +template using avm_cmp = Relation>; + +} // namespace bb::Avm_vm \ 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 c6cb110f1f95..1a826303cc09 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_main.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_main.hpp @@ -7,90 +7,96 @@ namespace bb::Avm_vm { template struct Avm_mainRow { - FF avm_main_alu_sel{}; - FF avm_main_bin_op_id{}; - FF avm_main_bin_sel{}; - FF avm_main_first{}; - FF avm_main_ia{}; - FF avm_main_ib{}; - FF avm_main_ic{}; + FF avm_main_mem_idx_b{}; + FF avm_main_pc_shift{}; + FF avm_main_sel_op_and{}; + FF avm_main_tag_err{}; + FF avm_main_sel_op_xor{}; + FF avm_main_sel_mov{}; + FF avm_main_sel_op_lt{}; + FF avm_main_sel_op_add{}; + FF avm_main_sel_jump{}; + FF avm_main_sel_internal_return{}; FF avm_main_ind_op_a{}; - FF avm_main_ind_op_b{}; - FF avm_main_ind_op_c{}; + FF avm_main_sel_op_sub{}; + FF avm_main_ia{}; FF avm_main_internal_return_ptr{}; - FF avm_main_internal_return_ptr_shift{}; FF avm_main_inv{}; - FF avm_main_mem_idx_a{}; - FF avm_main_mem_idx_b{}; - FF avm_main_mem_op_a{}; + FF avm_main_sel_op_eq{}; FF avm_main_mem_op_b{}; - FF avm_main_mem_op_c{}; - FF avm_main_op_err{}; - FF avm_main_pc{}; - FF avm_main_pc_shift{}; - FF avm_main_r_in_tag{}; + FF avm_main_sel_op_lte{}; FF avm_main_rwa{}; - FF avm_main_rwb{}; + FF avm_main_ind_op_c{}; FF avm_main_rwc{}; + FF avm_main_ib{}; + FF avm_main_rwb{}; + FF avm_main_pc{}; + FF avm_main_ic{}; + FF avm_main_sel_op_div{}; FF avm_main_sel_halt{}; + FF avm_main_ind_op_b{}; + FF avm_main_first{}; + FF avm_main_r_in_tag{}; + FF avm_main_alu_sel{}; + FF avm_main_w_in_tag{}; + FF avm_main_bin_op_id{}; 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_op_add{}; - FF avm_main_sel_op_and{}; - FF avm_main_sel_op_div{}; - FF avm_main_sel_op_eq{}; - FF avm_main_sel_op_mul{}; + FF avm_main_op_err{}; + FF avm_main_bin_sel{}; + FF avm_main_internal_return_ptr_shift{}; FF avm_main_sel_op_not{}; + FF avm_main_mem_op_a{}; + FF avm_main_sel_op_mul{}; + FF avm_main_mem_op_c{}; + FF avm_main_mem_idx_a{}; FF avm_main_sel_op_or{}; - FF avm_main_sel_op_sub{}; - FF avm_main_sel_op_xor{}; - FF avm_main_tag_err{}; - FF avm_main_w_in_tag{}; + FF avm_main_cmp_sel{}; }; inline std::string get_relation_label_avm_main(int index) { switch (index) { - case 25: - return "EQ_OUTPUT_U8"; - - case 26: - return "SUBOP_DIVISION_FF"; - - case 27: + case 29: return "SUBOP_DIVISION_ZERO_ERR1"; - case 28: - return "SUBOP_DIVISION_ZERO_ERR2"; + case 39: + return "RETURN_POINTER_DECREMENT"; - case 29: - return "SUBOP_ERROR_RELEVANT_OP"; + case 46: + return "MOV_SAME_VALUE"; - case 31: - return "RETURN_POINTER_INCREMENT"; + case 27: + return "EQ_OUTPUT_U8"; - case 37: - return "RETURN_POINTER_DECREMENT"; + case 50: + return "BIN_SEL_2"; - case 42: + case 44: return "PC_INCREMENT"; - case 43: - return "INTERNAL_RETURN_POINTER_CONSISTENCY"; + case 51: + return "CMP_SEL"; - case 44: - return "MOV_SAME_VALUE"; + case 28: + return "SUBOP_DIVISION_FF"; - case 45: + case 47: return "MOV_MAIN_SAME_TAG"; - case 47: + case 45: + return "INTERNAL_RETURN_POINTER_CONSISTENCY"; + + case 49: return "BIN_SEL_1"; - case 48: - return "BIN_SEL_2"; + case 33: + return "RETURN_POINTER_INCREMENT"; + + case 31: + return "SUBOP_ERROR_RELEVANT_OP"; + + case 30: + return "SUBOP_DIVISION_ZERO_ERR2"; } return std::to_string(index); } @@ -99,9 +105,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, 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, 5, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 3, 3, 3, 3, 2, 2, }; template @@ -187,7 +193,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(9); - auto tmp = (avm_main_sel_internal_call * (-avm_main_sel_internal_call + FF(1))); + auto tmp = (avm_main_sel_op_lt * (-avm_main_sel_op_lt + FF(1))); tmp *= scaling_factor; std::get<9>(evals) += tmp; } @@ -195,7 +201,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(10); - auto tmp = (avm_main_sel_internal_return * (-avm_main_sel_internal_return + FF(1))); + auto tmp = (avm_main_sel_op_lte * (-avm_main_sel_op_lte + FF(1))); tmp *= scaling_factor; std::get<10>(evals) += tmp; } @@ -203,7 +209,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(11); - auto tmp = (avm_main_sel_jump * (-avm_main_sel_jump + FF(1))); + auto tmp = (avm_main_sel_internal_call * (-avm_main_sel_internal_call + FF(1))); tmp *= scaling_factor; std::get<11>(evals) += tmp; } @@ -211,7 +217,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(12); - auto tmp = (avm_main_sel_halt * (-avm_main_sel_halt + FF(1))); + auto tmp = (avm_main_sel_internal_return * (-avm_main_sel_internal_return + FF(1))); tmp *= scaling_factor; std::get<12>(evals) += tmp; } @@ -219,7 +225,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(13); - auto tmp = (avm_main_sel_mov * (-avm_main_sel_mov + FF(1))); + auto tmp = (avm_main_sel_jump * (-avm_main_sel_jump + FF(1))); tmp *= scaling_factor; std::get<13>(evals) += tmp; } @@ -227,7 +233,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; } @@ -235,7 +241,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; } @@ -243,7 +249,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_op_err * (-avm_main_op_err + FF(1))); tmp *= scaling_factor; std::get<16>(evals) += tmp; } @@ -251,7 +257,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_tag_err * (-avm_main_tag_err + FF(1))); tmp *= scaling_factor; std::get<17>(evals) += tmp; } @@ -259,7 +265,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(18); - auto tmp = (avm_main_mem_op_c * (-avm_main_mem_op_c + FF(1))); + auto tmp = (avm_main_mem_op_a * (-avm_main_mem_op_a + FF(1))); tmp *= scaling_factor; std::get<18>(evals) += tmp; } @@ -267,7 +273,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(19); - auto tmp = (avm_main_rwa * (-avm_main_rwa + FF(1))); + auto tmp = (avm_main_mem_op_b * (-avm_main_mem_op_b + FF(1))); tmp *= scaling_factor; std::get<19>(evals) += tmp; } @@ -275,7 +281,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(20); - auto tmp = (avm_main_rwb * (-avm_main_rwb + FF(1))); + auto tmp = (avm_main_mem_op_c * (-avm_main_mem_op_c + FF(1))); tmp *= scaling_factor; std::get<20>(evals) += tmp; } @@ -283,7 +289,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(21); - 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<21>(evals) += tmp; } @@ -291,7 +297,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(22); - auto tmp = (avm_main_ind_op_a * (-avm_main_ind_op_a + FF(1))); + auto tmp = (avm_main_rwb * (-avm_main_rwb + FF(1))); tmp *= scaling_factor; std::get<22>(evals) += tmp; } @@ -299,7 +305,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(23); - auto tmp = (avm_main_ind_op_b * (-avm_main_ind_op_b + FF(1))); + auto tmp = (avm_main_rwc * (-avm_main_rwc + FF(1))); tmp *= scaling_factor; std::get<23>(evals) += tmp; } @@ -307,7 +313,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(24); - 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<24>(evals) += tmp; } @@ -315,7 +321,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(25); - auto tmp = (avm_main_sel_op_eq * (avm_main_w_in_tag - FF(1))); + auto tmp = (avm_main_ind_op_b * (-avm_main_ind_op_b + FF(1))); tmp *= scaling_factor; std::get<25>(evals) += tmp; } @@ -323,8 +329,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(26); - 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_c * (-avm_main_ind_op_c + FF(1))); tmp *= scaling_factor; std::get<26>(evals) += tmp; } @@ -332,7 +337,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(27); - 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_eq * (avm_main_w_in_tag - FF(1))); tmp *= scaling_factor; std::get<27>(evals) += tmp; } @@ -340,7 +345,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(28); - 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_op_err + FF(1))) * ((avm_main_ic * avm_main_ib) - avm_main_ia)); tmp *= scaling_factor; std::get<28>(evals) += tmp; } @@ -348,7 +354,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(29); - auto tmp = (avm_main_op_err * (avm_main_sel_op_div - 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<29>(evals) += tmp; } @@ -356,7 +362,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(30); - auto tmp = (avm_main_sel_jump * (avm_main_pc_shift - avm_main_ia)); + auto tmp = ((avm_main_sel_op_div * avm_main_op_err) * (-avm_main_inv + FF(1))); tmp *= scaling_factor; std::get<30>(evals) += tmp; } @@ -364,8 +370,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(31); - auto tmp = (avm_main_sel_internal_call * - (avm_main_internal_return_ptr_shift - (avm_main_internal_return_ptr + FF(1)))); + auto tmp = (avm_main_op_err * (avm_main_sel_op_div - FF(1))); tmp *= scaling_factor; std::get<31>(evals) += tmp; } @@ -373,7 +378,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(32); - auto tmp = (avm_main_sel_internal_call * (avm_main_internal_return_ptr - avm_main_mem_idx_b)); + auto tmp = (avm_main_sel_jump * (avm_main_pc_shift - avm_main_ia)); tmp *= scaling_factor; std::get<32>(evals) += tmp; } @@ -381,7 +386,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(33); - 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_shift - (avm_main_internal_return_ptr + FF(1)))); tmp *= scaling_factor; std::get<33>(evals) += tmp; } @@ -389,7 +395,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(34); - auto tmp = (avm_main_sel_internal_call * ((avm_main_pc + FF(1)) - avm_main_ib)); + auto tmp = (avm_main_sel_internal_call * (avm_main_internal_return_ptr - avm_main_mem_idx_b)); tmp *= scaling_factor; std::get<34>(evals) += tmp; } @@ -397,7 +403,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(35); - auto tmp = (avm_main_sel_internal_call * (avm_main_rwb - FF(1))); + auto tmp = (avm_main_sel_internal_call * (avm_main_pc_shift - avm_main_ia)); tmp *= scaling_factor; std::get<35>(evals) += tmp; } @@ -405,7 +411,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(36); - auto tmp = (avm_main_sel_internal_call * (avm_main_mem_op_b - FF(1))); + auto tmp = (avm_main_sel_internal_call * ((avm_main_pc + FF(1)) - avm_main_ib)); tmp *= scaling_factor; std::get<36>(evals) += tmp; } @@ -413,8 +419,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(37); - 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_rwb - FF(1))); tmp *= scaling_factor; std::get<37>(evals) += tmp; } @@ -422,7 +427,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(38); - 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_mem_op_b - FF(1))); tmp *= scaling_factor; std::get<38>(evals) += tmp; } @@ -430,7 +435,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(39); - 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_shift - (avm_main_internal_return_ptr - FF(1)))); tmp *= scaling_factor; std::get<39>(evals) += tmp; } @@ -438,7 +444,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(40); - auto tmp = (avm_main_sel_internal_return * avm_main_rwa); + auto tmp = (avm_main_sel_internal_return * ((avm_main_internal_return_ptr - FF(1)) - avm_main_mem_idx_a)); tmp *= scaling_factor; std::get<40>(evals) += tmp; } @@ -446,7 +452,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(41); - auto tmp = (avm_main_sel_internal_return * (avm_main_mem_op_a - FF(1))); + auto tmp = (avm_main_sel_internal_return * (avm_main_pc_shift - avm_main_ia)); tmp *= scaling_factor; std::get<41>(evals) += tmp; } @@ -454,6 +460,22 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(42); + auto tmp = (avm_main_sel_internal_return * avm_main_rwa); + tmp *= scaling_factor; + std::get<42>(evals) += tmp; + } + // Contribution 43 + { + Avm_DECLARE_VIEWS(43); + + auto tmp = (avm_main_sel_internal_return * (avm_main_mem_op_a - FF(1))); + tmp *= scaling_factor; + std::get<43>(evals) += tmp; + } + // Contribution 44 + { + Avm_DECLARE_VIEWS(44); + 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) + @@ -464,61 +486,69 @@ template class avm_mainImpl { avm_main_sel_op_xor)) * (avm_main_pc_shift - (avm_main_pc + FF(1)))); tmp *= scaling_factor; - std::get<42>(evals) += tmp; + std::get<44>(evals) += tmp; } - // Contribution 43 + // Contribution 45 { - Avm_DECLARE_VIEWS(43); + 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)); tmp *= scaling_factor; - std::get<43>(evals) += tmp; + std::get<45>(evals) += tmp; } - // Contribution 44 + // Contribution 46 { - Avm_DECLARE_VIEWS(44); + Avm_DECLARE_VIEWS(46); auto tmp = (avm_main_sel_mov * (avm_main_ia - avm_main_ic)); tmp *= scaling_factor; - std::get<44>(evals) += tmp; + std::get<46>(evals) += tmp; } - // Contribution 45 + // Contribution 47 { - Avm_DECLARE_VIEWS(45); + Avm_DECLARE_VIEWS(47); auto tmp = (avm_main_sel_mov * (avm_main_r_in_tag - avm_main_w_in_tag)); tmp *= scaling_factor; - std::get<45>(evals) += tmp; + std::get<47>(evals) += tmp; } - // Contribution 46 + // Contribution 48 { - Avm_DECLARE_VIEWS(46); + Avm_DECLARE_VIEWS(48); 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)))); tmp *= scaling_factor; - std::get<46>(evals) += tmp; + std::get<48>(evals) += tmp; } - // Contribution 47 + // Contribution 49 { - Avm_DECLARE_VIEWS(47); + Avm_DECLARE_VIEWS(49); auto tmp = (avm_main_bin_op_id - (avm_main_sel_op_or + (avm_main_sel_op_xor * FF(2)))); tmp *= scaling_factor; - std::get<47>(evals) += tmp; + std::get<49>(evals) += tmp; } - // Contribution 48 + // Contribution 50 { - Avm_DECLARE_VIEWS(48); + Avm_DECLARE_VIEWS(50); 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<48>(evals) += tmp; + std::get<50>(evals) += tmp; + } + // Contribution 51 + { + Avm_DECLARE_VIEWS(51); + + auto tmp = (avm_main_cmp_sel - (avm_main_sel_op_lt + avm_main_sel_op_lte)); + tmp *= scaling_factor; + std::get<51>(evals) += tmp; } } }; diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_mem.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_mem.hpp index 7ab7905c9b8d..3a32f727d0c4 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_mem.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_mem.hpp @@ -7,33 +7,45 @@ namespace bb::Avm_vm { template struct Avm_memRow { - FF avm_mem_addr{}; - FF avm_mem_addr_shift{}; + FF avm_mem_lastAccess{}; + FF avm_mem_val{}; FF avm_mem_ind_op_a{}; FF avm_mem_ind_op_b{}; + FF avm_mem_tag_shift{}; + FF avm_mem_w_in_tag{}; + FF avm_mem_addr{}; + FF avm_mem_r_in_tag{}; FF avm_mem_ind_op_c{}; + FF avm_mem_addr_shift{}; 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_r_in_tag{}; FF avm_mem_rw{}; - FF avm_mem_rw_shift{}; + FF avm_mem_tag_err{}; + FF avm_mem_op_c{}; + FF avm_mem_val_shift{}; + FF avm_mem_one_min_inv{}; FF avm_mem_sel_mov{}; FF avm_mem_sub_clk{}; + FF avm_mem_op_a{}; + FF avm_mem_op_b{}; FF avm_mem_tag{}; - FF avm_mem_tag_err{}; - FF avm_mem_tag_shift{}; - FF avm_mem_val{}; - FF avm_mem_val_shift{}; - FF avm_mem_w_in_tag{}; + FF avm_mem_rw_shift{}; }; inline std::string get_relation_label_avm_mem(int index) { switch (index) { + case 26: + return "MOV_SAME_TAG"; + + case 15: + return "MEM_ZERO_INIT"; + + case 17: + return "MEM_IN_TAG_CONSISTENCY_2"; + + case 16: + return "MEM_IN_TAG_CONSISTENCY_1"; + case 12: return "MEM_LAST_ACCESS_DELIMITER"; @@ -43,20 +55,8 @@ inline std::string get_relation_label_avm_mem(int index) case 14: return "MEM_READ_WRITE_TAG_CONSISTENCY"; - case 15: - return "MEM_ZERO_INIT"; - - case 16: - return "MEM_IN_TAG_CONSISTENCY_1"; - - case 17: - return "MEM_IN_TAG_CONSISTENCY_2"; - case 19: return "NO_TAG_ERR_WRITE"; - - case 26: - return "MOV_SAME_TAG"; } return std::to_string(index); } 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 7dc659afa365..cf7faa63ed1b 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/declare_views.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/declare_views.hpp @@ -4,29 +4,47 @@ using View = typename Accumulator::View; \ [[maybe_unused]] auto avm_main_clk = View(new_term.avm_main_clk); \ [[maybe_unused]] auto avm_main_first = View(new_term.avm_main_first); \ - [[maybe_unused]] auto avm_alu_alu_sel = View(new_term.avm_alu_alu_sel); \ - [[maybe_unused]] auto avm_alu_cf = View(new_term.avm_alu_cf); \ + [[maybe_unused]] auto avm_mem_clk = View(new_term.avm_mem_clk); \ + [[maybe_unused]] auto avm_mem_sub_clk = View(new_term.avm_mem_sub_clk); \ + [[maybe_unused]] auto avm_mem_addr = View(new_term.avm_mem_addr); \ + [[maybe_unused]] auto avm_mem_tag = View(new_term.avm_mem_tag); \ + [[maybe_unused]] auto avm_mem_val = View(new_term.avm_mem_val); \ + [[maybe_unused]] auto avm_mem_lastAccess = View(new_term.avm_mem_lastAccess); \ + [[maybe_unused]] auto avm_mem_last = View(new_term.avm_mem_last); \ + [[maybe_unused]] auto avm_mem_rw = View(new_term.avm_mem_rw); \ + [[maybe_unused]] auto avm_mem_r_in_tag = View(new_term.avm_mem_r_in_tag); \ + [[maybe_unused]] auto avm_mem_w_in_tag = View(new_term.avm_mem_w_in_tag); \ + [[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_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_sel_mov = View(new_term.avm_mem_sel_mov); \ + [[maybe_unused]] auto avm_mem_tag_err = View(new_term.avm_mem_tag_err); \ + [[maybe_unused]] auto avm_mem_one_min_inv = View(new_term.avm_mem_one_min_inv); \ [[maybe_unused]] auto avm_alu_clk = View(new_term.avm_alu_clk); \ - [[maybe_unused]] auto avm_alu_ff_tag = View(new_term.avm_alu_ff_tag); \ [[maybe_unused]] auto avm_alu_ia = View(new_term.avm_alu_ia); \ [[maybe_unused]] auto avm_alu_ib = View(new_term.avm_alu_ib); \ [[maybe_unused]] auto avm_alu_ic = View(new_term.avm_alu_ic); \ - [[maybe_unused]] auto avm_alu_in_tag = View(new_term.avm_alu_in_tag); \ [[maybe_unused]] auto avm_alu_op_add = View(new_term.avm_alu_op_add); \ - [[maybe_unused]] auto avm_alu_op_div = View(new_term.avm_alu_op_div); \ - [[maybe_unused]] auto avm_alu_op_eq = View(new_term.avm_alu_op_eq); \ - [[maybe_unused]] auto avm_alu_op_eq_diff_inv = View(new_term.avm_alu_op_eq_diff_inv); \ + [[maybe_unused]] auto avm_alu_op_sub = View(new_term.avm_alu_op_sub); \ [[maybe_unused]] auto avm_alu_op_mul = View(new_term.avm_alu_op_mul); \ + [[maybe_unused]] auto avm_alu_op_div = View(new_term.avm_alu_op_div); \ [[maybe_unused]] auto avm_alu_op_not = View(new_term.avm_alu_op_not); \ - [[maybe_unused]] auto avm_alu_op_sub = View(new_term.avm_alu_op_sub); \ + [[maybe_unused]] auto avm_alu_op_eq = View(new_term.avm_alu_op_eq); \ + [[maybe_unused]] auto avm_alu_alu_sel = View(new_term.avm_alu_alu_sel); \ + [[maybe_unused]] auto avm_alu_in_tag = View(new_term.avm_alu_in_tag); \ + [[maybe_unused]] auto avm_alu_ff_tag = View(new_term.avm_alu_ff_tag); \ + [[maybe_unused]] auto avm_alu_u8_tag = View(new_term.avm_alu_u8_tag); \ + [[maybe_unused]] auto avm_alu_u16_tag = View(new_term.avm_alu_u16_tag); \ + [[maybe_unused]] auto avm_alu_u32_tag = View(new_term.avm_alu_u32_tag); \ + [[maybe_unused]] auto avm_alu_u64_tag = View(new_term.avm_alu_u64_tag); \ [[maybe_unused]] auto avm_alu_u128_tag = View(new_term.avm_alu_u128_tag); \ + [[maybe_unused]] auto avm_alu_u8_r0 = View(new_term.avm_alu_u8_r0); \ + [[maybe_unused]] auto avm_alu_u8_r1 = View(new_term.avm_alu_u8_r1); \ [[maybe_unused]] auto avm_alu_u16_r0 = View(new_term.avm_alu_u16_r0); \ [[maybe_unused]] auto avm_alu_u16_r1 = View(new_term.avm_alu_u16_r1); \ - [[maybe_unused]] auto avm_alu_u16_r10 = View(new_term.avm_alu_u16_r10); \ - [[maybe_unused]] auto avm_alu_u16_r11 = View(new_term.avm_alu_u16_r11); \ - [[maybe_unused]] auto avm_alu_u16_r12 = View(new_term.avm_alu_u16_r12); \ - [[maybe_unused]] auto avm_alu_u16_r13 = View(new_term.avm_alu_u16_r13); \ - [[maybe_unused]] auto avm_alu_u16_r14 = View(new_term.avm_alu_u16_r14); \ [[maybe_unused]] auto avm_alu_u16_r2 = View(new_term.avm_alu_u16_r2); \ [[maybe_unused]] auto avm_alu_u16_r3 = View(new_term.avm_alu_u16_r3); \ [[maybe_unused]] auto avm_alu_u16_r4 = View(new_term.avm_alu_u16_r4); \ @@ -35,99 +53,110 @@ [[maybe_unused]] auto avm_alu_u16_r7 = View(new_term.avm_alu_u16_r7); \ [[maybe_unused]] auto avm_alu_u16_r8 = View(new_term.avm_alu_u16_r8); \ [[maybe_unused]] auto avm_alu_u16_r9 = View(new_term.avm_alu_u16_r9); \ - [[maybe_unused]] auto avm_alu_u16_tag = View(new_term.avm_alu_u16_tag); \ - [[maybe_unused]] auto avm_alu_u32_tag = View(new_term.avm_alu_u32_tag); \ + [[maybe_unused]] auto avm_alu_u16_r10 = View(new_term.avm_alu_u16_r10); \ + [[maybe_unused]] auto avm_alu_u16_r11 = View(new_term.avm_alu_u16_r11); \ + [[maybe_unused]] auto avm_alu_u16_r12 = View(new_term.avm_alu_u16_r12); \ + [[maybe_unused]] auto avm_alu_u16_r13 = View(new_term.avm_alu_u16_r13); \ + [[maybe_unused]] auto avm_alu_u16_r14 = View(new_term.avm_alu_u16_r14); \ [[maybe_unused]] auto avm_alu_u64_r0 = View(new_term.avm_alu_u64_r0); \ - [[maybe_unused]] auto avm_alu_u64_tag = View(new_term.avm_alu_u64_tag); \ - [[maybe_unused]] auto avm_alu_u8_r0 = View(new_term.avm_alu_u8_r0); \ - [[maybe_unused]] auto avm_alu_u8_r1 = View(new_term.avm_alu_u8_r1); \ - [[maybe_unused]] auto avm_alu_u8_tag = View(new_term.avm_alu_u8_tag); \ + [[maybe_unused]] auto avm_alu_cf = View(new_term.avm_alu_cf); \ + [[maybe_unused]] auto avm_alu_op_eq_diff_inv = View(new_term.avm_alu_op_eq_diff_inv); \ + [[maybe_unused]] auto avm_byte_lookup_table_op_id = View(new_term.avm_byte_lookup_table_op_id); \ + [[maybe_unused]] auto avm_byte_lookup_table_input_a = View(new_term.avm_byte_lookup_table_input_a); \ + [[maybe_unused]] auto avm_byte_lookup_table_input_b = View(new_term.avm_byte_lookup_table_input_b); \ + [[maybe_unused]] auto avm_byte_lookup_table_output = View(new_term.avm_byte_lookup_table_output); \ + [[maybe_unused]] auto avm_byte_lookup_bin_sel = View(new_term.avm_byte_lookup_bin_sel); \ + [[maybe_unused]] auto avm_byte_lookup_table_in_tags = View(new_term.avm_byte_lookup_table_in_tags); \ + [[maybe_unused]] auto avm_byte_lookup_table_byte_lengths = View(new_term.avm_byte_lookup_table_byte_lengths); \ + [[maybe_unused]] auto avm_binary_clk = View(new_term.avm_binary_clk); \ + [[maybe_unused]] auto avm_binary_bin_sel = View(new_term.avm_binary_bin_sel); \ [[maybe_unused]] auto avm_binary_acc_ia = View(new_term.avm_binary_acc_ia); \ [[maybe_unused]] auto avm_binary_acc_ib = View(new_term.avm_binary_acc_ib); \ [[maybe_unused]] auto avm_binary_acc_ic = View(new_term.avm_binary_acc_ic); \ - [[maybe_unused]] auto avm_binary_bin_sel = View(new_term.avm_binary_bin_sel); \ - [[maybe_unused]] auto avm_binary_clk = View(new_term.avm_binary_clk); \ + [[maybe_unused]] auto avm_binary_in_tag = View(new_term.avm_binary_in_tag); \ + [[maybe_unused]] auto avm_binary_op_id = View(new_term.avm_binary_op_id); \ [[maybe_unused]] auto avm_binary_ia_bytes = View(new_term.avm_binary_ia_bytes); \ [[maybe_unused]] auto avm_binary_ib_bytes = View(new_term.avm_binary_ib_bytes); \ [[maybe_unused]] auto avm_binary_ic_bytes = View(new_term.avm_binary_ic_bytes); \ - [[maybe_unused]] auto avm_binary_in_tag = View(new_term.avm_binary_in_tag); \ + [[maybe_unused]] auto avm_binary_start = View(new_term.avm_binary_start); \ [[maybe_unused]] auto avm_binary_mem_tag_ctr = View(new_term.avm_binary_mem_tag_ctr); \ [[maybe_unused]] auto avm_binary_mem_tag_ctr_inv = View(new_term.avm_binary_mem_tag_ctr_inv); \ - [[maybe_unused]] auto avm_binary_op_id = View(new_term.avm_binary_op_id); \ - [[maybe_unused]] auto avm_binary_start = View(new_term.avm_binary_start); \ - [[maybe_unused]] auto avm_byte_lookup_bin_sel = View(new_term.avm_byte_lookup_bin_sel); \ - [[maybe_unused]] auto avm_byte_lookup_table_byte_lengths = View(new_term.avm_byte_lookup_table_byte_lengths); \ - [[maybe_unused]] auto avm_byte_lookup_table_in_tags = View(new_term.avm_byte_lookup_table_in_tags); \ - [[maybe_unused]] auto avm_byte_lookup_table_input_a = View(new_term.avm_byte_lookup_table_input_a); \ - [[maybe_unused]] auto avm_byte_lookup_table_input_b = View(new_term.avm_byte_lookup_table_input_b); \ - [[maybe_unused]] auto avm_byte_lookup_table_op_id = View(new_term.avm_byte_lookup_table_op_id); \ - [[maybe_unused]] auto avm_byte_lookup_table_output = View(new_term.avm_byte_lookup_table_output); \ + [[maybe_unused]] auto avm_cmp_cmp_clk = View(new_term.avm_cmp_cmp_clk); \ + [[maybe_unused]] auto avm_cmp_ia = View(new_term.avm_cmp_ia); \ + [[maybe_unused]] auto avm_cmp_ib = View(new_term.avm_cmp_ib); \ + [[maybe_unused]] auto avm_cmp_ic = View(new_term.avm_cmp_ic); \ + [[maybe_unused]] auto avm_cmp_lt_sel = View(new_term.avm_cmp_lt_sel); \ + [[maybe_unused]] auto avm_cmp_lte_sel = View(new_term.avm_cmp_lte_sel); \ + [[maybe_unused]] auto avm_cmp_cmp_sel = View(new_term.avm_cmp_cmp_sel); \ + [[maybe_unused]] auto avm_cmp_input_ia = View(new_term.avm_cmp_input_ia); \ + [[maybe_unused]] auto avm_cmp_input_ib = View(new_term.avm_cmp_input_ib); \ + [[maybe_unused]] auto avm_cmp_a_lo = View(new_term.avm_cmp_a_lo); \ + [[maybe_unused]] auto avm_cmp_a_hi = View(new_term.avm_cmp_a_hi); \ + [[maybe_unused]] auto avm_cmp_b_lo = View(new_term.avm_cmp_b_lo); \ + [[maybe_unused]] auto avm_cmp_b_hi = View(new_term.avm_cmp_b_hi); \ + [[maybe_unused]] auto avm_cmp_borrow = View(new_term.avm_cmp_borrow); \ + [[maybe_unused]] auto avm_cmp_p_lo = View(new_term.avm_cmp_p_lo); \ + [[maybe_unused]] auto avm_cmp_p_hi = View(new_term.avm_cmp_p_hi); \ + [[maybe_unused]] auto avm_cmp_p_sub_a_lo = View(new_term.avm_cmp_p_sub_a_lo); \ + [[maybe_unused]] auto avm_cmp_p_sub_a_hi = View(new_term.avm_cmp_p_sub_a_hi); \ + [[maybe_unused]] auto avm_cmp_p_a_borrow = View(new_term.avm_cmp_p_a_borrow); \ + [[maybe_unused]] auto avm_cmp_p_sub_b_lo = View(new_term.avm_cmp_p_sub_b_lo); \ + [[maybe_unused]] auto avm_cmp_p_sub_b_hi = View(new_term.avm_cmp_p_sub_b_hi); \ + [[maybe_unused]] auto avm_cmp_p_b_borrow = View(new_term.avm_cmp_p_b_borrow); \ + [[maybe_unused]] auto avm_cmp_res_lo = View(new_term.avm_cmp_res_lo); \ + [[maybe_unused]] auto avm_cmp_res_hi = View(new_term.avm_cmp_res_hi); \ + [[maybe_unused]] auto avm_cmp_lt_query = View(new_term.avm_cmp_lt_query); \ + [[maybe_unused]] auto avm_main_sel_rng_8 = View(new_term.avm_main_sel_rng_8); \ + [[maybe_unused]] auto avm_main_sel_rng_16 = View(new_term.avm_main_sel_rng_16); \ + [[maybe_unused]] auto avm_main_pc = View(new_term.avm_main_pc); \ + [[maybe_unused]] auto avm_main_internal_return_ptr = View(new_term.avm_main_internal_return_ptr); \ + [[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_halt = View(new_term.avm_main_sel_halt); \ + [[maybe_unused]] auto avm_main_sel_mov = View(new_term.avm_main_sel_mov); \ + [[maybe_unused]] auto avm_main_sel_op_add = View(new_term.avm_main_sel_op_add); \ + [[maybe_unused]] auto avm_main_sel_op_sub = View(new_term.avm_main_sel_op_sub); \ + [[maybe_unused]] auto avm_main_sel_op_mul = View(new_term.avm_main_sel_op_mul); \ + [[maybe_unused]] auto avm_main_sel_op_div = View(new_term.avm_main_sel_op_div); \ + [[maybe_unused]] auto avm_main_sel_op_not = View(new_term.avm_main_sel_op_not); \ + [[maybe_unused]] auto avm_main_sel_op_eq = View(new_term.avm_main_sel_op_eq); \ + [[maybe_unused]] auto avm_main_sel_op_and = View(new_term.avm_main_sel_op_and); \ + [[maybe_unused]] auto avm_main_sel_op_or = View(new_term.avm_main_sel_op_or); \ + [[maybe_unused]] auto avm_main_sel_op_xor = View(new_term.avm_main_sel_op_xor); \ + [[maybe_unused]] auto avm_main_sel_op_lt = View(new_term.avm_main_sel_op_lt); \ + [[maybe_unused]] auto avm_main_sel_op_lte = View(new_term.avm_main_sel_op_lte); \ [[maybe_unused]] auto avm_main_alu_sel = View(new_term.avm_main_alu_sel); \ - [[maybe_unused]] auto avm_main_bin_op_id = View(new_term.avm_main_bin_op_id); \ [[maybe_unused]] auto avm_main_bin_sel = View(new_term.avm_main_bin_sel); \ + [[maybe_unused]] auto avm_main_cmp_sel = View(new_term.avm_main_cmp_sel); \ + [[maybe_unused]] auto avm_main_r_in_tag = View(new_term.avm_main_r_in_tag); \ + [[maybe_unused]] auto avm_main_w_in_tag = View(new_term.avm_main_w_in_tag); \ + [[maybe_unused]] auto avm_main_op_err = View(new_term.avm_main_op_err); \ + [[maybe_unused]] auto avm_main_tag_err = View(new_term.avm_main_tag_err); \ + [[maybe_unused]] auto avm_main_inv = View(new_term.avm_main_inv); \ [[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_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_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_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_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_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_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_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_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_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); \ - [[maybe_unused]] auto avm_main_sel_op_eq = View(new_term.avm_main_sel_op_eq); \ - [[maybe_unused]] auto avm_main_sel_op_mul = View(new_term.avm_main_sel_op_mul); \ - [[maybe_unused]] auto avm_main_sel_op_not = View(new_term.avm_main_sel_op_not); \ - [[maybe_unused]] auto avm_main_sel_op_or = View(new_term.avm_main_sel_op_or); \ - [[maybe_unused]] auto avm_main_sel_op_sub = View(new_term.avm_main_sel_op_sub); \ - [[maybe_unused]] auto avm_main_sel_op_xor = View(new_term.avm_main_sel_op_xor); \ - [[maybe_unused]] auto avm_main_sel_rng_16 = View(new_term.avm_main_sel_rng_16); \ - [[maybe_unused]] auto avm_main_sel_rng_8 = View(new_term.avm_main_sel_rng_8); \ - [[maybe_unused]] auto avm_main_tag_err = View(new_term.avm_main_tag_err); \ - [[maybe_unused]] auto avm_main_w_in_tag = View(new_term.avm_main_w_in_tag); \ - [[maybe_unused]] auto avm_mem_addr = View(new_term.avm_mem_addr); \ - [[maybe_unused]] auto avm_mem_clk = View(new_term.avm_mem_clk); \ - [[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_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_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_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); \ - [[maybe_unused]] auto avm_mem_val = View(new_term.avm_mem_val); \ - [[maybe_unused]] auto avm_mem_w_in_tag = View(new_term.avm_mem_w_in_tag); \ + [[maybe_unused]] auto avm_main_last = View(new_term.avm_main_last); \ + [[maybe_unused]] auto avm_main_bin_op_id = View(new_term.avm_main_bin_op_id); \ [[maybe_unused]] auto perm_main_alu = View(new_term.perm_main_alu); \ [[maybe_unused]] auto perm_main_bin = View(new_term.perm_main_bin); \ + [[maybe_unused]] auto perm_main_cmp = View(new_term.perm_main_cmp); \ [[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); \ @@ -143,21 +172,21 @@ [[maybe_unused]] auto incl_main_tag_err_counts = View(new_term.incl_main_tag_err_counts); \ [[maybe_unused]] auto incl_mem_tag_err_counts = View(new_term.incl_mem_tag_err_counts); \ [[maybe_unused]] auto avm_alu_u16_r0_shift = View(new_term.avm_alu_u16_r0_shift); \ - [[maybe_unused]] auto avm_alu_u16_r1_shift = View(new_term.avm_alu_u16_r1_shift); \ - [[maybe_unused]] auto avm_alu_u16_r2_shift = View(new_term.avm_alu_u16_r2_shift); \ [[maybe_unused]] auto avm_alu_u16_r3_shift = View(new_term.avm_alu_u16_r3_shift); \ [[maybe_unused]] auto avm_alu_u16_r4_shift = View(new_term.avm_alu_u16_r4_shift); \ - [[maybe_unused]] auto avm_alu_u16_r5_shift = View(new_term.avm_alu_u16_r5_shift); \ - [[maybe_unused]] auto avm_alu_u16_r6_shift = View(new_term.avm_alu_u16_r6_shift); \ [[maybe_unused]] auto avm_alu_u16_r7_shift = View(new_term.avm_alu_u16_r7_shift); \ - [[maybe_unused]] auto avm_binary_acc_ia_shift = View(new_term.avm_binary_acc_ia_shift); \ - [[maybe_unused]] auto avm_binary_acc_ib_shift = View(new_term.avm_binary_acc_ib_shift); \ + [[maybe_unused]] auto avm_alu_u16_r6_shift = View(new_term.avm_alu_u16_r6_shift); \ + [[maybe_unused]] auto avm_alu_u16_r2_shift = View(new_term.avm_alu_u16_r2_shift); \ + [[maybe_unused]] auto avm_alu_u16_r5_shift = View(new_term.avm_alu_u16_r5_shift); \ + [[maybe_unused]] auto avm_alu_u16_r1_shift = View(new_term.avm_alu_u16_r1_shift); \ [[maybe_unused]] auto avm_binary_acc_ic_shift = View(new_term.avm_binary_acc_ic_shift); \ - [[maybe_unused]] auto avm_binary_mem_tag_ctr_shift = View(new_term.avm_binary_mem_tag_ctr_shift); \ [[maybe_unused]] auto avm_binary_op_id_shift = View(new_term.avm_binary_op_id_shift); \ - [[maybe_unused]] auto avm_main_internal_return_ptr_shift = View(new_term.avm_main_internal_return_ptr_shift); \ - [[maybe_unused]] auto avm_main_pc_shift = View(new_term.avm_main_pc_shift); \ + [[maybe_unused]] auto avm_binary_mem_tag_ctr_shift = View(new_term.avm_binary_mem_tag_ctr_shift); \ + [[maybe_unused]] auto avm_binary_acc_ia_shift = View(new_term.avm_binary_acc_ia_shift); \ + [[maybe_unused]] auto avm_binary_acc_ib_shift = View(new_term.avm_binary_acc_ib_shift); \ + [[maybe_unused]] auto avm_mem_tag_shift = View(new_term.avm_mem_tag_shift); \ [[maybe_unused]] auto avm_mem_addr_shift = View(new_term.avm_mem_addr_shift); \ + [[maybe_unused]] auto avm_mem_val_shift = View(new_term.avm_mem_val_shift); \ [[maybe_unused]] auto avm_mem_rw_shift = View(new_term.avm_mem_rw_shift); \ - [[maybe_unused]] auto avm_mem_tag_shift = View(new_term.avm_mem_tag_shift); \ - [[maybe_unused]] auto avm_mem_val_shift = View(new_term.avm_mem_val_shift); + [[maybe_unused]] auto avm_main_pc_shift = View(new_term.avm_main_pc_shift); \ + [[maybe_unused]] auto avm_main_internal_return_ptr_shift = View(new_term.avm_main_internal_return_ptr_shift); diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_cmp.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_cmp.hpp new file mode 100644 index 000000000000..4ef873ea226d --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_cmp.hpp @@ -0,0 +1,98 @@ + + +#pragma once + +#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + +#include +#include + +namespace bb { + +class perm_main_cmp_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_cmp_sel == 1 || in.avm_cmp_cmp_sel == 1); + } + + /** + * @brief Get all the entities for the permutation when we don't need to update them + * + * @details The entities are returned as a tuple of references in the following order: + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that switches on the subrelation of the permutation relation that ensures correctness of + * the inverse polynomial + * - The entity/polynomial that enables adding a tuple-generated value from the first set to the logderivative sum + * subrelation + * - The entity/polynomial that enables adding a tuple-generated value from the second set to the logderivative sum + * subrelation + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the first set (N.B. ORDER IS IMPORTANT!) + * - A sequence of COLUMNS_PER_SET entities/polynomials that represent the second set (N.B. ORDER IS IMPORTANT!) + * + * @return All the entities needed for the permutation + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.perm_main_cmp, + in.avm_main_cmp_sel, + in.avm_main_cmp_sel, + in.avm_cmp_cmp_sel, + in.avm_main_ia, + in.avm_main_ib, + in.avm_main_ic, + in.avm_cmp_ia, + in.avm_cmp_ib, + in.avm_cmp_ic); + } + + /** + * @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_cmp, + in.avm_main_cmp_sel, + in.avm_main_cmp_sel, + in.avm_cmp_cmp_sel, + in.avm_main_ia, + in.avm_main_ib, + in.avm_main_ic, + in.avm_cmp_ia, + in.avm_cmp_ib, + in.avm_cmp_ic); + } +}; + +template +using perm_main_cmp_relation = GenericPermutationRelation; +template using perm_main_cmp = GenericPermutation; + +} // namespace bb 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 2498a6906545..4849b6620947 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp @@ -13,6 +13,7 @@ #include "barretenberg/relations/generated/avm/avm_alu.hpp" #include "barretenberg/relations/generated/avm/avm_binary.hpp" +#include "barretenberg/relations/generated/avm/avm_cmp.hpp" #include "barretenberg/relations/generated/avm/avm_main.hpp" #include "barretenberg/relations/generated/avm/avm_mem.hpp" #include "barretenberg/relations/generated/avm/incl_main_tag_err.hpp" @@ -21,6 +22,7 @@ #include "barretenberg/relations/generated/avm/lookup_byte_operations.hpp" #include "barretenberg/relations/generated/avm/perm_main_alu.hpp" #include "barretenberg/relations/generated/avm/perm_main_bin.hpp" +#include "barretenberg/relations/generated/avm/perm_main_cmp.hpp" #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" @@ -34,29 +36,47 @@ namespace bb { template struct AvmFullRow { FF avm_main_clk{}; FF avm_main_first{}; - FF avm_alu_alu_sel{}; - FF avm_alu_cf{}; + FF avm_mem_clk{}; + FF avm_mem_sub_clk{}; + FF avm_mem_addr{}; + FF avm_mem_tag{}; + FF avm_mem_val{}; + FF avm_mem_lastAccess{}; + FF avm_mem_last{}; + FF avm_mem_rw{}; + FF avm_mem_r_in_tag{}; + FF avm_mem_w_in_tag{}; + FF avm_mem_op_a{}; + FF avm_mem_op_b{}; + FF avm_mem_op_c{}; + FF avm_mem_ind_op_a{}; + FF avm_mem_ind_op_b{}; + FF avm_mem_ind_op_c{}; + FF avm_mem_sel_mov{}; + FF avm_mem_tag_err{}; + FF avm_mem_one_min_inv{}; FF avm_alu_clk{}; - FF avm_alu_ff_tag{}; FF avm_alu_ia{}; FF avm_alu_ib{}; FF avm_alu_ic{}; - FF avm_alu_in_tag{}; FF avm_alu_op_add{}; - FF avm_alu_op_div{}; - FF avm_alu_op_eq{}; - FF avm_alu_op_eq_diff_inv{}; + FF avm_alu_op_sub{}; FF avm_alu_op_mul{}; + FF avm_alu_op_div{}; FF avm_alu_op_not{}; - FF avm_alu_op_sub{}; + FF avm_alu_op_eq{}; + FF avm_alu_alu_sel{}; + FF avm_alu_in_tag{}; + FF avm_alu_ff_tag{}; + FF avm_alu_u8_tag{}; + FF avm_alu_u16_tag{}; + FF avm_alu_u32_tag{}; + FF avm_alu_u64_tag{}; FF avm_alu_u128_tag{}; + FF avm_alu_u8_r0{}; + FF avm_alu_u8_r1{}; FF avm_alu_u16_r0{}; FF avm_alu_u16_r1{}; - FF avm_alu_u16_r10{}; - FF avm_alu_u16_r11{}; - FF avm_alu_u16_r12{}; - FF avm_alu_u16_r13{}; - FF avm_alu_u16_r14{}; FF avm_alu_u16_r2{}; FF avm_alu_u16_r3{}; FF avm_alu_u16_r4{}; @@ -65,99 +85,110 @@ template struct AvmFullRow { FF avm_alu_u16_r7{}; FF avm_alu_u16_r8{}; FF avm_alu_u16_r9{}; - FF avm_alu_u16_tag{}; - FF avm_alu_u32_tag{}; + FF avm_alu_u16_r10{}; + FF avm_alu_u16_r11{}; + FF avm_alu_u16_r12{}; + FF avm_alu_u16_r13{}; + FF avm_alu_u16_r14{}; FF avm_alu_u64_r0{}; - FF avm_alu_u64_tag{}; - FF avm_alu_u8_r0{}; - FF avm_alu_u8_r1{}; - FF avm_alu_u8_tag{}; + FF avm_alu_cf{}; + FF avm_alu_op_eq_diff_inv{}; + FF avm_byte_lookup_table_op_id{}; + FF avm_byte_lookup_table_input_a{}; + FF avm_byte_lookup_table_input_b{}; + FF avm_byte_lookup_table_output{}; + FF avm_byte_lookup_bin_sel{}; + FF avm_byte_lookup_table_in_tags{}; + FF avm_byte_lookup_table_byte_lengths{}; + FF avm_binary_clk{}; + FF avm_binary_bin_sel{}; FF avm_binary_acc_ia{}; FF avm_binary_acc_ib{}; FF avm_binary_acc_ic{}; - FF avm_binary_bin_sel{}; - FF avm_binary_clk{}; + FF avm_binary_in_tag{}; + FF avm_binary_op_id{}; FF avm_binary_ia_bytes{}; FF avm_binary_ib_bytes{}; FF avm_binary_ic_bytes{}; - FF avm_binary_in_tag{}; + FF avm_binary_start{}; FF avm_binary_mem_tag_ctr{}; FF avm_binary_mem_tag_ctr_inv{}; - FF avm_binary_op_id{}; - FF avm_binary_start{}; - FF avm_byte_lookup_bin_sel{}; - FF avm_byte_lookup_table_byte_lengths{}; - FF avm_byte_lookup_table_in_tags{}; - FF avm_byte_lookup_table_input_a{}; - FF avm_byte_lookup_table_input_b{}; - FF avm_byte_lookup_table_op_id{}; - FF avm_byte_lookup_table_output{}; + FF avm_cmp_cmp_clk{}; + FF avm_cmp_ia{}; + FF avm_cmp_ib{}; + FF avm_cmp_ic{}; + FF avm_cmp_lt_sel{}; + FF avm_cmp_lte_sel{}; + FF avm_cmp_cmp_sel{}; + FF avm_cmp_input_ia{}; + FF avm_cmp_input_ib{}; + FF avm_cmp_a_lo{}; + FF avm_cmp_a_hi{}; + FF avm_cmp_b_lo{}; + FF avm_cmp_b_hi{}; + FF avm_cmp_borrow{}; + FF avm_cmp_p_lo{}; + FF avm_cmp_p_hi{}; + FF avm_cmp_p_sub_a_lo{}; + FF avm_cmp_p_sub_a_hi{}; + FF avm_cmp_p_a_borrow{}; + FF avm_cmp_p_sub_b_lo{}; + FF avm_cmp_p_sub_b_hi{}; + FF avm_cmp_p_b_borrow{}; + FF avm_cmp_res_lo{}; + FF avm_cmp_res_hi{}; + FF avm_cmp_lt_query{}; + FF avm_main_sel_rng_8{}; + FF avm_main_sel_rng_16{}; + FF avm_main_pc{}; + FF avm_main_internal_return_ptr{}; + FF avm_main_sel_internal_call{}; + FF avm_main_sel_internal_return{}; + FF avm_main_sel_jump{}; + FF avm_main_sel_halt{}; + FF avm_main_sel_mov{}; + FF avm_main_sel_op_add{}; + FF avm_main_sel_op_sub{}; + FF avm_main_sel_op_mul{}; + FF avm_main_sel_op_div{}; + FF avm_main_sel_op_not{}; + FF avm_main_sel_op_eq{}; + FF avm_main_sel_op_and{}; + FF avm_main_sel_op_or{}; + FF avm_main_sel_op_xor{}; + FF avm_main_sel_op_lt{}; + FF avm_main_sel_op_lte{}; FF avm_main_alu_sel{}; - FF avm_main_bin_op_id{}; FF avm_main_bin_sel{}; + FF avm_main_cmp_sel{}; + FF avm_main_r_in_tag{}; + FF avm_main_w_in_tag{}; + FF avm_main_op_err{}; + FF avm_main_tag_err{}; + FF avm_main_inv{}; FF avm_main_ia{}; FF avm_main_ib{}; FF avm_main_ic{}; + FF avm_main_mem_op_a{}; + FF avm_main_mem_op_b{}; + FF avm_main_mem_op_c{}; + FF avm_main_rwa{}; + FF avm_main_rwb{}; + FF avm_main_rwc{}; FF avm_main_ind_a{}; FF avm_main_ind_b{}; FF avm_main_ind_c{}; FF avm_main_ind_op_a{}; FF avm_main_ind_op_b{}; FF avm_main_ind_op_c{}; - 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_op_a{}; - FF avm_main_mem_op_b{}; - FF avm_main_mem_op_c{}; - 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_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_op_add{}; - FF avm_main_sel_op_and{}; - FF avm_main_sel_op_div{}; - FF avm_main_sel_op_eq{}; - FF avm_main_sel_op_mul{}; - FF avm_main_sel_op_not{}; - FF avm_main_sel_op_or{}; - FF avm_main_sel_op_sub{}; - FF avm_main_sel_op_xor{}; - FF avm_main_sel_rng_16{}; - FF avm_main_sel_rng_8{}; - FF avm_main_tag_err{}; - FF avm_main_w_in_tag{}; - FF avm_mem_addr{}; - FF avm_mem_clk{}; - FF avm_mem_ind_op_a{}; - FF avm_mem_ind_op_b{}; - FF avm_mem_ind_op_c{}; - 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_r_in_tag{}; - FF avm_mem_rw{}; - FF avm_mem_sel_mov{}; - FF avm_mem_sub_clk{}; - FF avm_mem_tag{}; - FF avm_mem_tag_err{}; - FF avm_mem_val{}; - FF avm_mem_w_in_tag{}; + FF avm_main_last{}; + FF avm_main_bin_op_id{}; FF perm_main_alu{}; FF perm_main_bin{}; + FF perm_main_cmp{}; FF perm_main_mem_a{}; FF perm_main_mem_b{}; FF perm_main_mem_c{}; @@ -173,24 +204,24 @@ template struct AvmFullRow { FF incl_main_tag_err_counts{}; FF incl_mem_tag_err_counts{}; FF avm_alu_u16_r0_shift{}; - FF avm_alu_u16_r1_shift{}; - FF avm_alu_u16_r2_shift{}; FF avm_alu_u16_r3_shift{}; FF avm_alu_u16_r4_shift{}; - FF avm_alu_u16_r5_shift{}; - FF avm_alu_u16_r6_shift{}; FF avm_alu_u16_r7_shift{}; - FF avm_binary_acc_ia_shift{}; - FF avm_binary_acc_ib_shift{}; + FF avm_alu_u16_r6_shift{}; + FF avm_alu_u16_r2_shift{}; + FF avm_alu_u16_r5_shift{}; + FF avm_alu_u16_r1_shift{}; FF avm_binary_acc_ic_shift{}; - FF avm_binary_mem_tag_ctr_shift{}; FF avm_binary_op_id_shift{}; - FF avm_main_internal_return_ptr_shift{}; - FF avm_main_pc_shift{}; - FF avm_mem_addr_shift{}; - FF avm_mem_rw_shift{}; + FF avm_binary_mem_tag_ctr_shift{}; + FF avm_binary_acc_ia_shift{}; + FF avm_binary_acc_ib_shift{}; FF avm_mem_tag_shift{}; + FF avm_mem_addr_shift{}; FF avm_mem_val_shift{}; + FF avm_mem_rw_shift{}; + FF avm_main_pc_shift{}; + FF avm_main_internal_return_ptr_shift{}; }; class AvmCircuitBuilder { @@ -203,8 +234,8 @@ class AvmCircuitBuilder { using Polynomial = Flavor::Polynomial; using ProverPolynomials = Flavor::ProverPolynomials; - static constexpr size_t num_fixed_columns = 159; - static constexpr size_t num_polys = 140; + static constexpr size_t num_fixed_columns = 188; + static constexpr size_t num_polys = 169; std::vector rows; void set_trace(std::vector&& trace) { rows = std::move(trace); } @@ -222,29 +253,47 @@ class AvmCircuitBuilder { for (size_t i = 0; i < rows.size(); i++) { polys.avm_main_clk[i] = rows[i].avm_main_clk; polys.avm_main_first[i] = rows[i].avm_main_first; - polys.avm_alu_alu_sel[i] = rows[i].avm_alu_alu_sel; - polys.avm_alu_cf[i] = rows[i].avm_alu_cf; + polys.avm_mem_clk[i] = rows[i].avm_mem_clk; + polys.avm_mem_sub_clk[i] = rows[i].avm_mem_sub_clk; + polys.avm_mem_addr[i] = rows[i].avm_mem_addr; + polys.avm_mem_tag[i] = rows[i].avm_mem_tag; + polys.avm_mem_val[i] = rows[i].avm_mem_val; + polys.avm_mem_lastAccess[i] = rows[i].avm_mem_lastAccess; + polys.avm_mem_last[i] = rows[i].avm_mem_last; + polys.avm_mem_rw[i] = rows[i].avm_mem_rw; + polys.avm_mem_r_in_tag[i] = rows[i].avm_mem_r_in_tag; + polys.avm_mem_w_in_tag[i] = rows[i].avm_mem_w_in_tag; + 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_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_sel_mov[i] = rows[i].avm_mem_sel_mov; + polys.avm_mem_tag_err[i] = rows[i].avm_mem_tag_err; + polys.avm_mem_one_min_inv[i] = rows[i].avm_mem_one_min_inv; polys.avm_alu_clk[i] = rows[i].avm_alu_clk; - polys.avm_alu_ff_tag[i] = rows[i].avm_alu_ff_tag; polys.avm_alu_ia[i] = rows[i].avm_alu_ia; polys.avm_alu_ib[i] = rows[i].avm_alu_ib; polys.avm_alu_ic[i] = rows[i].avm_alu_ic; - polys.avm_alu_in_tag[i] = rows[i].avm_alu_in_tag; polys.avm_alu_op_add[i] = rows[i].avm_alu_op_add; - polys.avm_alu_op_div[i] = rows[i].avm_alu_op_div; - polys.avm_alu_op_eq[i] = rows[i].avm_alu_op_eq; - polys.avm_alu_op_eq_diff_inv[i] = rows[i].avm_alu_op_eq_diff_inv; + polys.avm_alu_op_sub[i] = rows[i].avm_alu_op_sub; polys.avm_alu_op_mul[i] = rows[i].avm_alu_op_mul; + polys.avm_alu_op_div[i] = rows[i].avm_alu_op_div; polys.avm_alu_op_not[i] = rows[i].avm_alu_op_not; - polys.avm_alu_op_sub[i] = rows[i].avm_alu_op_sub; + polys.avm_alu_op_eq[i] = rows[i].avm_alu_op_eq; + polys.avm_alu_alu_sel[i] = rows[i].avm_alu_alu_sel; + polys.avm_alu_in_tag[i] = rows[i].avm_alu_in_tag; + polys.avm_alu_ff_tag[i] = rows[i].avm_alu_ff_tag; + polys.avm_alu_u8_tag[i] = rows[i].avm_alu_u8_tag; + polys.avm_alu_u16_tag[i] = rows[i].avm_alu_u16_tag; + polys.avm_alu_u32_tag[i] = rows[i].avm_alu_u32_tag; + polys.avm_alu_u64_tag[i] = rows[i].avm_alu_u64_tag; polys.avm_alu_u128_tag[i] = rows[i].avm_alu_u128_tag; + polys.avm_alu_u8_r0[i] = rows[i].avm_alu_u8_r0; + polys.avm_alu_u8_r1[i] = rows[i].avm_alu_u8_r1; polys.avm_alu_u16_r0[i] = rows[i].avm_alu_u16_r0; polys.avm_alu_u16_r1[i] = rows[i].avm_alu_u16_r1; - polys.avm_alu_u16_r10[i] = rows[i].avm_alu_u16_r10; - polys.avm_alu_u16_r11[i] = rows[i].avm_alu_u16_r11; - polys.avm_alu_u16_r12[i] = rows[i].avm_alu_u16_r12; - polys.avm_alu_u16_r13[i] = rows[i].avm_alu_u16_r13; - polys.avm_alu_u16_r14[i] = rows[i].avm_alu_u16_r14; polys.avm_alu_u16_r2[i] = rows[i].avm_alu_u16_r2; polys.avm_alu_u16_r3[i] = rows[i].avm_alu_u16_r3; polys.avm_alu_u16_r4[i] = rows[i].avm_alu_u16_r4; @@ -253,99 +302,124 @@ class AvmCircuitBuilder { polys.avm_alu_u16_r7[i] = rows[i].avm_alu_u16_r7; polys.avm_alu_u16_r8[i] = rows[i].avm_alu_u16_r8; polys.avm_alu_u16_r9[i] = rows[i].avm_alu_u16_r9; - polys.avm_alu_u16_tag[i] = rows[i].avm_alu_u16_tag; - polys.avm_alu_u32_tag[i] = rows[i].avm_alu_u32_tag; + polys.avm_alu_u16_r10[i] = rows[i].avm_alu_u16_r10; + polys.avm_alu_u16_r11[i] = rows[i].avm_alu_u16_r11; + polys.avm_alu_u16_r12[i] = rows[i].avm_alu_u16_r12; + polys.avm_alu_u16_r13[i] = rows[i].avm_alu_u16_r13; + polys.avm_alu_u16_r14[i] = rows[i].avm_alu_u16_r14; polys.avm_alu_u64_r0[i] = rows[i].avm_alu_u64_r0; - polys.avm_alu_u64_tag[i] = rows[i].avm_alu_u64_tag; - polys.avm_alu_u8_r0[i] = rows[i].avm_alu_u8_r0; - polys.avm_alu_u8_r1[i] = rows[i].avm_alu_u8_r1; - polys.avm_alu_u8_tag[i] = rows[i].avm_alu_u8_tag; + polys.avm_alu_cf[i] = rows[i].avm_alu_cf; + polys.avm_alu_op_eq_diff_inv[i] = rows[i].avm_alu_op_eq_diff_inv; + polys.avm_byte_lookup_table_op_id[i] = rows[i].avm_byte_lookup_table_op_id; + polys.avm_byte_lookup_table_input_a[i] = rows[i].avm_byte_lookup_table_input_a; + polys.avm_byte_lookup_table_input_b[i] = rows[i].avm_byte_lookup_table_input_b; + polys.avm_byte_lookup_table_output[i] = rows[i].avm_byte_lookup_table_output; + polys.avm_byte_lookup_bin_sel[i] = rows[i].avm_byte_lookup_bin_sel; + polys.avm_byte_lookup_table_in_tags[i] = rows[i].avm_byte_lookup_table_in_tags; + polys.avm_byte_lookup_table_byte_lengths[i] = rows[i].avm_byte_lookup_table_byte_lengths; + polys.avm_binary_clk[i] = rows[i].avm_binary_clk; + polys.avm_binary_bin_sel[i] = rows[i].avm_binary_bin_sel; polys.avm_binary_acc_ia[i] = rows[i].avm_binary_acc_ia; polys.avm_binary_acc_ib[i] = rows[i].avm_binary_acc_ib; polys.avm_binary_acc_ic[i] = rows[i].avm_binary_acc_ic; - polys.avm_binary_bin_sel[i] = rows[i].avm_binary_bin_sel; - polys.avm_binary_clk[i] = rows[i].avm_binary_clk; + polys.avm_binary_in_tag[i] = rows[i].avm_binary_in_tag; + polys.avm_binary_op_id[i] = rows[i].avm_binary_op_id; polys.avm_binary_ia_bytes[i] = rows[i].avm_binary_ia_bytes; polys.avm_binary_ib_bytes[i] = rows[i].avm_binary_ib_bytes; polys.avm_binary_ic_bytes[i] = rows[i].avm_binary_ic_bytes; - polys.avm_binary_in_tag[i] = rows[i].avm_binary_in_tag; + polys.avm_binary_start[i] = rows[i].avm_binary_start; polys.avm_binary_mem_tag_ctr[i] = rows[i].avm_binary_mem_tag_ctr; polys.avm_binary_mem_tag_ctr_inv[i] = rows[i].avm_binary_mem_tag_ctr_inv; - polys.avm_binary_op_id[i] = rows[i].avm_binary_op_id; - polys.avm_binary_start[i] = rows[i].avm_binary_start; - polys.avm_byte_lookup_bin_sel[i] = rows[i].avm_byte_lookup_bin_sel; - polys.avm_byte_lookup_table_byte_lengths[i] = rows[i].avm_byte_lookup_table_byte_lengths; - polys.avm_byte_lookup_table_in_tags[i] = rows[i].avm_byte_lookup_table_in_tags; - polys.avm_byte_lookup_table_input_a[i] = rows[i].avm_byte_lookup_table_input_a; - polys.avm_byte_lookup_table_input_b[i] = rows[i].avm_byte_lookup_table_input_b; - polys.avm_byte_lookup_table_op_id[i] = rows[i].avm_byte_lookup_table_op_id; - polys.avm_byte_lookup_table_output[i] = rows[i].avm_byte_lookup_table_output; + polys.avm_cmp_cmp_clk[i] = rows[i].avm_cmp_cmp_clk; + polys.avm_cmp_ia[i] = rows[i].avm_cmp_ia; + polys.avm_cmp_ib[i] = rows[i].avm_cmp_ib; + polys.avm_cmp_ic[i] = rows[i].avm_cmp_ic; + polys.avm_cmp_lt_sel[i] = rows[i].avm_cmp_lt_sel; + polys.avm_cmp_lte_sel[i] = rows[i].avm_cmp_lte_sel; + polys.avm_cmp_cmp_sel[i] = rows[i].avm_cmp_cmp_sel; + polys.avm_cmp_input_ia[i] = rows[i].avm_cmp_input_ia; + polys.avm_cmp_input_ib[i] = rows[i].avm_cmp_input_ib; + polys.avm_cmp_a_lo[i] = rows[i].avm_cmp_a_lo; + polys.avm_cmp_a_hi[i] = rows[i].avm_cmp_a_hi; + polys.avm_cmp_b_lo[i] = rows[i].avm_cmp_b_lo; + polys.avm_cmp_b_hi[i] = rows[i].avm_cmp_b_hi; + polys.avm_cmp_borrow[i] = rows[i].avm_cmp_borrow; + polys.avm_cmp_p_lo[i] = rows[i].avm_cmp_p_lo; + polys.avm_cmp_p_hi[i] = rows[i].avm_cmp_p_hi; + polys.avm_cmp_p_sub_a_lo[i] = rows[i].avm_cmp_p_sub_a_lo; + polys.avm_cmp_p_sub_a_hi[i] = rows[i].avm_cmp_p_sub_a_hi; + polys.avm_cmp_p_a_borrow[i] = rows[i].avm_cmp_p_a_borrow; + polys.avm_cmp_p_sub_b_lo[i] = rows[i].avm_cmp_p_sub_b_lo; + polys.avm_cmp_p_sub_b_hi[i] = rows[i].avm_cmp_p_sub_b_hi; + polys.avm_cmp_p_b_borrow[i] = rows[i].avm_cmp_p_b_borrow; + polys.avm_cmp_res_lo[i] = rows[i].avm_cmp_res_lo; + polys.avm_cmp_res_hi[i] = rows[i].avm_cmp_res_hi; + polys.avm_cmp_lt_query[i] = rows[i].avm_cmp_lt_query; + polys.avm_main_sel_rng_8[i] = rows[i].avm_main_sel_rng_8; + polys.avm_main_sel_rng_16[i] = rows[i].avm_main_sel_rng_16; + polys.avm_main_pc[i] = rows[i].avm_main_pc; + polys.avm_main_internal_return_ptr[i] = rows[i].avm_main_internal_return_ptr; + 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_halt[i] = rows[i].avm_main_sel_halt; + polys.avm_main_sel_mov[i] = rows[i].avm_main_sel_mov; + polys.avm_main_sel_op_add[i] = rows[i].avm_main_sel_op_add; + polys.avm_main_sel_op_sub[i] = rows[i].avm_main_sel_op_sub; + polys.avm_main_sel_op_mul[i] = rows[i].avm_main_sel_op_mul; + polys.avm_main_sel_op_div[i] = rows[i].avm_main_sel_op_div; + polys.avm_main_sel_op_not[i] = rows[i].avm_main_sel_op_not; + polys.avm_main_sel_op_eq[i] = rows[i].avm_main_sel_op_eq; + polys.avm_main_sel_op_and[i] = rows[i].avm_main_sel_op_and; + polys.avm_main_sel_op_or[i] = rows[i].avm_main_sel_op_or; + polys.avm_main_sel_op_xor[i] = rows[i].avm_main_sel_op_xor; + polys.avm_main_sel_op_lt[i] = rows[i].avm_main_sel_op_lt; + polys.avm_main_sel_op_lte[i] = rows[i].avm_main_sel_op_lte; polys.avm_main_alu_sel[i] = rows[i].avm_main_alu_sel; - polys.avm_main_bin_op_id[i] = rows[i].avm_main_bin_op_id; polys.avm_main_bin_sel[i] = rows[i].avm_main_bin_sel; + polys.avm_main_cmp_sel[i] = rows[i].avm_main_cmp_sel; + polys.avm_main_r_in_tag[i] = rows[i].avm_main_r_in_tag; + polys.avm_main_w_in_tag[i] = rows[i].avm_main_w_in_tag; + polys.avm_main_op_err[i] = rows[i].avm_main_op_err; + polys.avm_main_tag_err[i] = rows[i].avm_main_tag_err; + polys.avm_main_inv[i] = rows[i].avm_main_inv; 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_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_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_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_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_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_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_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_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_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; - polys.avm_main_sel_op_eq[i] = rows[i].avm_main_sel_op_eq; - polys.avm_main_sel_op_mul[i] = rows[i].avm_main_sel_op_mul; - polys.avm_main_sel_op_not[i] = rows[i].avm_main_sel_op_not; - polys.avm_main_sel_op_or[i] = rows[i].avm_main_sel_op_or; - polys.avm_main_sel_op_sub[i] = rows[i].avm_main_sel_op_sub; - polys.avm_main_sel_op_xor[i] = rows[i].avm_main_sel_op_xor; - polys.avm_main_sel_rng_16[i] = rows[i].avm_main_sel_rng_16; - polys.avm_main_sel_rng_8[i] = rows[i].avm_main_sel_rng_8; - polys.avm_main_tag_err[i] = rows[i].avm_main_tag_err; - polys.avm_main_w_in_tag[i] = rows[i].avm_main_w_in_tag; - polys.avm_mem_addr[i] = rows[i].avm_mem_addr; - polys.avm_mem_clk[i] = rows[i].avm_mem_clk; - 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_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_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_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; - 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.avm_main_last[i] = rows[i].avm_main_last; + polys.avm_main_bin_op_id[i] = rows[i].avm_main_bin_op_id; polys.perm_main_alu[i] = rows[i].perm_main_alu; +<<<<<<< HEAD +======= + polys.perm_main_bin[i] = rows[i].perm_main_bin; + polys.perm_main_cmp[i] = rows[i].perm_main_cmp; + 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_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.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; +>>>>>>> 7a982d52c (feat: init avm cmp) 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; @@ -353,24 +427,24 @@ class AvmCircuitBuilder { } polys.avm_alu_u16_r0_shift = Polynomial(polys.avm_alu_u16_r0.shifted()); - polys.avm_alu_u16_r1_shift = Polynomial(polys.avm_alu_u16_r1.shifted()); - polys.avm_alu_u16_r2_shift = Polynomial(polys.avm_alu_u16_r2.shifted()); polys.avm_alu_u16_r3_shift = Polynomial(polys.avm_alu_u16_r3.shifted()); polys.avm_alu_u16_r4_shift = Polynomial(polys.avm_alu_u16_r4.shifted()); - polys.avm_alu_u16_r5_shift = Polynomial(polys.avm_alu_u16_r5.shifted()); - polys.avm_alu_u16_r6_shift = Polynomial(polys.avm_alu_u16_r6.shifted()); polys.avm_alu_u16_r7_shift = Polynomial(polys.avm_alu_u16_r7.shifted()); - polys.avm_binary_acc_ia_shift = Polynomial(polys.avm_binary_acc_ia.shifted()); - polys.avm_binary_acc_ib_shift = Polynomial(polys.avm_binary_acc_ib.shifted()); + polys.avm_alu_u16_r6_shift = Polynomial(polys.avm_alu_u16_r6.shifted()); + polys.avm_alu_u16_r2_shift = Polynomial(polys.avm_alu_u16_r2.shifted()); + polys.avm_alu_u16_r5_shift = Polynomial(polys.avm_alu_u16_r5.shifted()); + polys.avm_alu_u16_r1_shift = Polynomial(polys.avm_alu_u16_r1.shifted()); polys.avm_binary_acc_ic_shift = Polynomial(polys.avm_binary_acc_ic.shifted()); - polys.avm_binary_mem_tag_ctr_shift = Polynomial(polys.avm_binary_mem_tag_ctr.shifted()); polys.avm_binary_op_id_shift = Polynomial(polys.avm_binary_op_id.shifted()); - polys.avm_main_internal_return_ptr_shift = Polynomial(polys.avm_main_internal_return_ptr.shifted()); - polys.avm_main_pc_shift = Polynomial(polys.avm_main_pc.shifted()); - polys.avm_mem_addr_shift = Polynomial(polys.avm_mem_addr.shifted()); - polys.avm_mem_rw_shift = Polynomial(polys.avm_mem_rw.shifted()); + polys.avm_binary_mem_tag_ctr_shift = Polynomial(polys.avm_binary_mem_tag_ctr.shifted()); + polys.avm_binary_acc_ia_shift = Polynomial(polys.avm_binary_acc_ia.shifted()); + polys.avm_binary_acc_ib_shift = Polynomial(polys.avm_binary_acc_ib.shifted()); polys.avm_mem_tag_shift = Polynomial(polys.avm_mem_tag.shifted()); + polys.avm_mem_addr_shift = Polynomial(polys.avm_mem_addr.shifted()); polys.avm_mem_val_shift = Polynomial(polys.avm_mem_val.shifted()); + polys.avm_mem_rw_shift = Polynomial(polys.avm_mem_rw.shifted()); + polys.avm_main_pc_shift = Polynomial(polys.avm_main_pc.shifted()); + polys.avm_main_internal_return_ptr_shift = Polynomial(polys.avm_main_internal_return_ptr.shifted()); return polys; } @@ -450,14 +524,18 @@ class AvmCircuitBuilder { Avm_vm::get_relation_label_avm_binary)) { return false; } - if (!evaluate_relation.template operator()>("avm_main", - Avm_vm::get_relation_label_avm_main)) { + if (!evaluate_relation.template operator()>("avm_cmp", + Avm_vm::get_relation_label_avm_cmp)) { return false; } if (!evaluate_relation.template operator()>("avm_mem", Avm_vm::get_relation_label_avm_mem)) { return false; } + if (!evaluate_relation.template operator()>("avm_main", + Avm_vm::get_relation_label_avm_main)) { + return false; + } if (!evaluate_logderivative.template operator()>("PERM_MAIN_ALU")) { return false; @@ -465,6 +543,9 @@ class AvmCircuitBuilder { if (!evaluate_logderivative.template operator()>("PERM_MAIN_BIN")) { return false; } + if (!evaluate_logderivative.template operator()>("PERM_MAIN_CMP")) { + return false; + } if (!evaluate_logderivative.template operator()>("PERM_MAIN_MEM_A")) { 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 c2c664e1b4a1..4167070067e0 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp @@ -15,6 +15,7 @@ #include "barretenberg/polynomials/polynomial.hpp" #include "barretenberg/relations/generated/avm/avm_alu.hpp" #include "barretenberg/relations/generated/avm/avm_binary.hpp" +#include "barretenberg/relations/generated/avm/avm_cmp.hpp" #include "barretenberg/relations/generated/avm/avm_main.hpp" #include "barretenberg/relations/generated/avm/avm_mem.hpp" #include "barretenberg/relations/generated/avm/incl_main_tag_err.hpp" @@ -23,6 +24,7 @@ #include "barretenberg/relations/generated/avm/lookup_byte_operations.hpp" #include "barretenberg/relations/generated/avm/perm_main_alu.hpp" #include "barretenberg/relations/generated/avm/perm_main_bin.hpp" +#include "barretenberg/relations/generated/avm/perm_main_cmp.hpp" #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" @@ -50,11 +52,11 @@ class AvmFlavor { using RelationSeparator = FF; static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 2; - static constexpr size_t NUM_WITNESS_ENTITIES = 138; + static constexpr size_t NUM_WITNESS_ENTITIES = 167; 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 = 159; + static constexpr size_t NUM_ALL_ENTITIES = 188; using GrandProductRelations = std::tuple, perm_main_bin_relation, @@ -71,10 +73,12 @@ class AvmFlavor { using Relations = std::tuple, Avm_vm::avm_binary, - Avm_vm::avm_main, + Avm_vm::avm_cmp, Avm_vm::avm_mem, + Avm_vm::avm_main, perm_main_alu_relation, perm_main_bin_relation, + perm_main_cmp_relation, perm_main_mem_a_relation, perm_main_mem_b_relation, perm_main_mem_c_relation, @@ -118,29 +122,47 @@ class AvmFlavor { template class WitnessEntities { public: DEFINE_FLAVOR_MEMBERS(DataType, - avm_alu_alu_sel, - avm_alu_cf, + avm_mem_clk, + avm_mem_sub_clk, + avm_mem_addr, + avm_mem_tag, + avm_mem_val, + avm_mem_lastAccess, + avm_mem_last, + avm_mem_rw, + avm_mem_r_in_tag, + avm_mem_w_in_tag, + 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_sel_mov, + avm_mem_tag_err, + avm_mem_one_min_inv, avm_alu_clk, - avm_alu_ff_tag, avm_alu_ia, avm_alu_ib, avm_alu_ic, - avm_alu_in_tag, avm_alu_op_add, - avm_alu_op_div, - avm_alu_op_eq, - avm_alu_op_eq_diff_inv, + avm_alu_op_sub, avm_alu_op_mul, + avm_alu_op_div, avm_alu_op_not, - avm_alu_op_sub, + avm_alu_op_eq, + avm_alu_alu_sel, + avm_alu_in_tag, + avm_alu_ff_tag, + avm_alu_u8_tag, + avm_alu_u16_tag, + avm_alu_u32_tag, + avm_alu_u64_tag, avm_alu_u128_tag, + avm_alu_u8_r0, + avm_alu_u8_r1, avm_alu_u16_r0, avm_alu_u16_r1, - avm_alu_u16_r10, - avm_alu_u16_r11, - avm_alu_u16_r12, - avm_alu_u16_r13, - avm_alu_u16_r14, avm_alu_u16_r2, avm_alu_u16_r3, avm_alu_u16_r4, @@ -149,99 +171,110 @@ class AvmFlavor { avm_alu_u16_r7, avm_alu_u16_r8, avm_alu_u16_r9, - avm_alu_u16_tag, - avm_alu_u32_tag, + avm_alu_u16_r10, + avm_alu_u16_r11, + avm_alu_u16_r12, + avm_alu_u16_r13, + avm_alu_u16_r14, avm_alu_u64_r0, - avm_alu_u64_tag, - avm_alu_u8_r0, - avm_alu_u8_r1, - avm_alu_u8_tag, + avm_alu_cf, + avm_alu_op_eq_diff_inv, + avm_byte_lookup_table_op_id, + avm_byte_lookup_table_input_a, + avm_byte_lookup_table_input_b, + avm_byte_lookup_table_output, + avm_byte_lookup_bin_sel, + avm_byte_lookup_table_in_tags, + avm_byte_lookup_table_byte_lengths, + avm_binary_clk, + avm_binary_bin_sel, avm_binary_acc_ia, avm_binary_acc_ib, avm_binary_acc_ic, - avm_binary_bin_sel, - avm_binary_clk, + avm_binary_in_tag, + avm_binary_op_id, avm_binary_ia_bytes, avm_binary_ib_bytes, avm_binary_ic_bytes, - avm_binary_in_tag, + avm_binary_start, avm_binary_mem_tag_ctr, avm_binary_mem_tag_ctr_inv, - avm_binary_op_id, - avm_binary_start, - avm_byte_lookup_bin_sel, - avm_byte_lookup_table_byte_lengths, - avm_byte_lookup_table_in_tags, - avm_byte_lookup_table_input_a, - avm_byte_lookup_table_input_b, - avm_byte_lookup_table_op_id, - avm_byte_lookup_table_output, + avm_cmp_cmp_clk, + avm_cmp_ia, + avm_cmp_ib, + avm_cmp_ic, + avm_cmp_lt_sel, + avm_cmp_lte_sel, + avm_cmp_cmp_sel, + avm_cmp_input_ia, + avm_cmp_input_ib, + avm_cmp_a_lo, + avm_cmp_a_hi, + avm_cmp_b_lo, + avm_cmp_b_hi, + avm_cmp_borrow, + avm_cmp_p_lo, + avm_cmp_p_hi, + avm_cmp_p_sub_a_lo, + avm_cmp_p_sub_a_hi, + avm_cmp_p_a_borrow, + avm_cmp_p_sub_b_lo, + avm_cmp_p_sub_b_hi, + avm_cmp_p_b_borrow, + avm_cmp_res_lo, + avm_cmp_res_hi, + avm_cmp_lt_query, + avm_main_sel_rng_8, + avm_main_sel_rng_16, + avm_main_pc, + avm_main_internal_return_ptr, + avm_main_sel_internal_call, + avm_main_sel_internal_return, + avm_main_sel_jump, + avm_main_sel_halt, + avm_main_sel_mov, + avm_main_sel_op_add, + avm_main_sel_op_sub, + avm_main_sel_op_mul, + avm_main_sel_op_div, + 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_sel_op_lt, + avm_main_sel_op_lte, avm_main_alu_sel, - avm_main_bin_op_id, avm_main_bin_sel, + avm_main_cmp_sel, + avm_main_r_in_tag, + avm_main_w_in_tag, + avm_main_op_err, + avm_main_tag_err, + avm_main_inv, avm_main_ia, avm_main_ib, avm_main_ic, + avm_main_mem_op_a, + avm_main_mem_op_b, + avm_main_mem_op_c, + avm_main_rwa, + avm_main_rwb, + avm_main_rwc, avm_main_ind_a, avm_main_ind_b, avm_main_ind_c, avm_main_ind_op_a, avm_main_ind_op_b, avm_main_ind_op_c, - 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_op_a, - avm_main_mem_op_b, - avm_main_mem_op_c, - avm_main_op_err, - avm_main_pc, - avm_main_r_in_tag, - avm_main_rwa, - avm_main_rwb, - avm_main_rwc, - 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_op_add, - avm_main_sel_op_and, - avm_main_sel_op_div, - avm_main_sel_op_eq, - avm_main_sel_op_mul, - avm_main_sel_op_not, - avm_main_sel_op_or, - avm_main_sel_op_sub, - avm_main_sel_op_xor, - avm_main_sel_rng_16, - avm_main_sel_rng_8, - avm_main_tag_err, - avm_main_w_in_tag, - avm_mem_addr, - avm_mem_clk, - avm_mem_ind_op_a, - avm_mem_ind_op_b, - avm_mem_ind_op_c, - 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_r_in_tag, - avm_mem_rw, - avm_mem_sel_mov, - avm_mem_sub_clk, - avm_mem_tag, - avm_mem_tag_err, - avm_mem_val, - avm_mem_w_in_tag, + avm_main_last, + avm_main_bin_op_id, perm_main_alu, perm_main_bin, + perm_main_cmp, perm_main_mem_a, perm_main_mem_b, perm_main_mem_c, @@ -259,29 +292,47 @@ class AvmFlavor { RefVector get_wires() { - return { avm_alu_alu_sel, - avm_alu_cf, + return { avm_mem_clk, + avm_mem_sub_clk, + avm_mem_addr, + avm_mem_tag, + avm_mem_val, + avm_mem_lastAccess, + avm_mem_last, + avm_mem_rw, + avm_mem_r_in_tag, + avm_mem_w_in_tag, + 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_sel_mov, + avm_mem_tag_err, + avm_mem_one_min_inv, avm_alu_clk, - avm_alu_ff_tag, avm_alu_ia, avm_alu_ib, avm_alu_ic, - avm_alu_in_tag, avm_alu_op_add, - avm_alu_op_div, - avm_alu_op_eq, - avm_alu_op_eq_diff_inv, + avm_alu_op_sub, avm_alu_op_mul, + avm_alu_op_div, avm_alu_op_not, - avm_alu_op_sub, + avm_alu_op_eq, + avm_alu_alu_sel, + avm_alu_in_tag, + avm_alu_ff_tag, + avm_alu_u8_tag, + avm_alu_u16_tag, + avm_alu_u32_tag, + avm_alu_u64_tag, avm_alu_u128_tag, + avm_alu_u8_r0, + avm_alu_u8_r1, avm_alu_u16_r0, avm_alu_u16_r1, - avm_alu_u16_r10, - avm_alu_u16_r11, - avm_alu_u16_r12, - avm_alu_u16_r13, - avm_alu_u16_r14, avm_alu_u16_r2, avm_alu_u16_r3, avm_alu_u16_r4, @@ -290,99 +341,110 @@ class AvmFlavor { avm_alu_u16_r7, avm_alu_u16_r8, avm_alu_u16_r9, - avm_alu_u16_tag, - avm_alu_u32_tag, + avm_alu_u16_r10, + avm_alu_u16_r11, + avm_alu_u16_r12, + avm_alu_u16_r13, + avm_alu_u16_r14, avm_alu_u64_r0, - avm_alu_u64_tag, - avm_alu_u8_r0, - avm_alu_u8_r1, - avm_alu_u8_tag, + avm_alu_cf, + avm_alu_op_eq_diff_inv, + avm_byte_lookup_table_op_id, + avm_byte_lookup_table_input_a, + avm_byte_lookup_table_input_b, + avm_byte_lookup_table_output, + avm_byte_lookup_bin_sel, + avm_byte_lookup_table_in_tags, + avm_byte_lookup_table_byte_lengths, + avm_binary_clk, + avm_binary_bin_sel, avm_binary_acc_ia, avm_binary_acc_ib, avm_binary_acc_ic, - avm_binary_bin_sel, - avm_binary_clk, + avm_binary_in_tag, + avm_binary_op_id, avm_binary_ia_bytes, avm_binary_ib_bytes, avm_binary_ic_bytes, - avm_binary_in_tag, + avm_binary_start, avm_binary_mem_tag_ctr, avm_binary_mem_tag_ctr_inv, - avm_binary_op_id, - avm_binary_start, - avm_byte_lookup_bin_sel, - avm_byte_lookup_table_byte_lengths, - avm_byte_lookup_table_in_tags, - avm_byte_lookup_table_input_a, - avm_byte_lookup_table_input_b, - avm_byte_lookup_table_op_id, - avm_byte_lookup_table_output, - avm_main_alu_sel, - avm_main_bin_op_id, - avm_main_bin_sel, - avm_main_ia, - avm_main_ib, - avm_main_ic, - avm_main_ind_a, - avm_main_ind_b, - avm_main_ind_c, - avm_main_ind_op_a, - avm_main_ind_op_b, - avm_main_ind_op_c, - 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_op_a, - avm_main_mem_op_b, - avm_main_mem_op_c, - avm_main_op_err, + avm_cmp_cmp_clk, + avm_cmp_ia, + avm_cmp_ib, + avm_cmp_ic, + avm_cmp_lt_sel, + avm_cmp_lte_sel, + avm_cmp_cmp_sel, + avm_cmp_input_ia, + avm_cmp_input_ib, + avm_cmp_a_lo, + avm_cmp_a_hi, + avm_cmp_b_lo, + avm_cmp_b_hi, + avm_cmp_borrow, + avm_cmp_p_lo, + avm_cmp_p_hi, + avm_cmp_p_sub_a_lo, + avm_cmp_p_sub_a_hi, + avm_cmp_p_a_borrow, + avm_cmp_p_sub_b_lo, + avm_cmp_p_sub_b_hi, + avm_cmp_p_b_borrow, + avm_cmp_res_lo, + avm_cmp_res_hi, + avm_cmp_lt_query, + avm_main_sel_rng_8, + avm_main_sel_rng_16, avm_main_pc, - avm_main_r_in_tag, - avm_main_rwa, - avm_main_rwb, - avm_main_rwc, - avm_main_sel_halt, + avm_main_internal_return_ptr, avm_main_sel_internal_call, avm_main_sel_internal_return, avm_main_sel_jump, + avm_main_sel_halt, avm_main_sel_mov, avm_main_sel_op_add, - avm_main_sel_op_and, - avm_main_sel_op_div, - avm_main_sel_op_eq, + avm_main_sel_op_sub, avm_main_sel_op_mul, + avm_main_sel_op_div, avm_main_sel_op_not, + avm_main_sel_op_eq, + avm_main_sel_op_and, avm_main_sel_op_or, - avm_main_sel_op_sub, avm_main_sel_op_xor, - avm_main_sel_rng_16, - avm_main_sel_rng_8, - avm_main_tag_err, + avm_main_sel_op_lt, + avm_main_sel_op_lte, + avm_main_alu_sel, + avm_main_bin_sel, + avm_main_cmp_sel, + avm_main_r_in_tag, avm_main_w_in_tag, - avm_mem_addr, - avm_mem_clk, - avm_mem_ind_op_a, - avm_mem_ind_op_b, - avm_mem_ind_op_c, - 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_r_in_tag, - avm_mem_rw, - avm_mem_sel_mov, - avm_mem_sub_clk, - avm_mem_tag, - avm_mem_tag_err, - avm_mem_val, - avm_mem_w_in_tag, + avm_main_op_err, + avm_main_tag_err, + avm_main_inv, + avm_main_ia, + avm_main_ib, + avm_main_ic, + avm_main_mem_op_a, + avm_main_mem_op_b, + avm_main_mem_op_c, + avm_main_rwa, + avm_main_rwb, + avm_main_rwc, + avm_main_ind_a, + avm_main_ind_b, + avm_main_ind_c, + avm_main_ind_op_a, + avm_main_ind_op_b, + avm_main_ind_op_c, + avm_main_mem_idx_a, + avm_main_mem_idx_b, + avm_main_mem_idx_c, + avm_main_last, + avm_main_bin_op_id, perm_main_alu, perm_main_bin, + perm_main_cmp, perm_main_mem_a, perm_main_mem_b, perm_main_mem_c, @@ -405,29 +467,47 @@ class AvmFlavor { DEFINE_FLAVOR_MEMBERS(DataType, avm_main_clk, avm_main_first, - avm_alu_alu_sel, - avm_alu_cf, + avm_mem_clk, + avm_mem_sub_clk, + avm_mem_addr, + avm_mem_tag, + avm_mem_val, + avm_mem_lastAccess, + avm_mem_last, + avm_mem_rw, + avm_mem_r_in_tag, + avm_mem_w_in_tag, + 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_sel_mov, + avm_mem_tag_err, + avm_mem_one_min_inv, avm_alu_clk, - avm_alu_ff_tag, avm_alu_ia, avm_alu_ib, avm_alu_ic, - avm_alu_in_tag, avm_alu_op_add, - avm_alu_op_div, - avm_alu_op_eq, - avm_alu_op_eq_diff_inv, + avm_alu_op_sub, avm_alu_op_mul, + avm_alu_op_div, avm_alu_op_not, - avm_alu_op_sub, + avm_alu_op_eq, + avm_alu_alu_sel, + avm_alu_in_tag, + avm_alu_ff_tag, + avm_alu_u8_tag, + avm_alu_u16_tag, + avm_alu_u32_tag, + avm_alu_u64_tag, avm_alu_u128_tag, + avm_alu_u8_r0, + avm_alu_u8_r1, avm_alu_u16_r0, avm_alu_u16_r1, - avm_alu_u16_r10, - avm_alu_u16_r11, - avm_alu_u16_r12, - avm_alu_u16_r13, - avm_alu_u16_r14, avm_alu_u16_r2, avm_alu_u16_r3, avm_alu_u16_r4, @@ -436,99 +516,110 @@ class AvmFlavor { avm_alu_u16_r7, avm_alu_u16_r8, avm_alu_u16_r9, - avm_alu_u16_tag, - avm_alu_u32_tag, + avm_alu_u16_r10, + avm_alu_u16_r11, + avm_alu_u16_r12, + avm_alu_u16_r13, + avm_alu_u16_r14, avm_alu_u64_r0, - avm_alu_u64_tag, - avm_alu_u8_r0, - avm_alu_u8_r1, - avm_alu_u8_tag, + avm_alu_cf, + avm_alu_op_eq_diff_inv, + avm_byte_lookup_table_op_id, + avm_byte_lookup_table_input_a, + avm_byte_lookup_table_input_b, + avm_byte_lookup_table_output, + avm_byte_lookup_bin_sel, + avm_byte_lookup_table_in_tags, + avm_byte_lookup_table_byte_lengths, + avm_binary_clk, + avm_binary_bin_sel, avm_binary_acc_ia, avm_binary_acc_ib, avm_binary_acc_ic, - avm_binary_bin_sel, - avm_binary_clk, + avm_binary_in_tag, + avm_binary_op_id, avm_binary_ia_bytes, avm_binary_ib_bytes, avm_binary_ic_bytes, - avm_binary_in_tag, + avm_binary_start, avm_binary_mem_tag_ctr, avm_binary_mem_tag_ctr_inv, - avm_binary_op_id, - avm_binary_start, - avm_byte_lookup_bin_sel, - avm_byte_lookup_table_byte_lengths, - avm_byte_lookup_table_in_tags, - avm_byte_lookup_table_input_a, - avm_byte_lookup_table_input_b, - avm_byte_lookup_table_op_id, - avm_byte_lookup_table_output, + avm_cmp_cmp_clk, + avm_cmp_ia, + avm_cmp_ib, + avm_cmp_ic, + avm_cmp_lt_sel, + avm_cmp_lte_sel, + avm_cmp_cmp_sel, + avm_cmp_input_ia, + avm_cmp_input_ib, + avm_cmp_a_lo, + avm_cmp_a_hi, + avm_cmp_b_lo, + avm_cmp_b_hi, + avm_cmp_borrow, + avm_cmp_p_lo, + avm_cmp_p_hi, + avm_cmp_p_sub_a_lo, + avm_cmp_p_sub_a_hi, + avm_cmp_p_a_borrow, + avm_cmp_p_sub_b_lo, + avm_cmp_p_sub_b_hi, + avm_cmp_p_b_borrow, + avm_cmp_res_lo, + avm_cmp_res_hi, + avm_cmp_lt_query, + avm_main_sel_rng_8, + avm_main_sel_rng_16, + avm_main_pc, + avm_main_internal_return_ptr, + avm_main_sel_internal_call, + avm_main_sel_internal_return, + avm_main_sel_jump, + avm_main_sel_halt, + avm_main_sel_mov, + avm_main_sel_op_add, + avm_main_sel_op_sub, + avm_main_sel_op_mul, + avm_main_sel_op_div, + 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_sel_op_lt, + avm_main_sel_op_lte, avm_main_alu_sel, - avm_main_bin_op_id, avm_main_bin_sel, + avm_main_cmp_sel, + avm_main_r_in_tag, + avm_main_w_in_tag, + avm_main_op_err, + avm_main_tag_err, + avm_main_inv, avm_main_ia, avm_main_ib, avm_main_ic, + avm_main_mem_op_a, + avm_main_mem_op_b, + avm_main_mem_op_c, + avm_main_rwa, + avm_main_rwb, + avm_main_rwc, avm_main_ind_a, avm_main_ind_b, avm_main_ind_c, avm_main_ind_op_a, avm_main_ind_op_b, avm_main_ind_op_c, - 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_op_a, - avm_main_mem_op_b, - avm_main_mem_op_c, - avm_main_op_err, - avm_main_pc, - avm_main_r_in_tag, - avm_main_rwa, - avm_main_rwb, - avm_main_rwc, - 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_op_add, - avm_main_sel_op_and, - avm_main_sel_op_div, - avm_main_sel_op_eq, - avm_main_sel_op_mul, - avm_main_sel_op_not, - avm_main_sel_op_or, - avm_main_sel_op_sub, - avm_main_sel_op_xor, - avm_main_sel_rng_16, - avm_main_sel_rng_8, - avm_main_tag_err, - avm_main_w_in_tag, - avm_mem_addr, - avm_mem_clk, - avm_mem_ind_op_a, - avm_mem_ind_op_b, - avm_mem_ind_op_c, - 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_r_in_tag, - avm_mem_rw, - avm_mem_sel_mov, - avm_mem_sub_clk, - avm_mem_tag, - avm_mem_tag_err, - avm_mem_val, - avm_mem_w_in_tag, + avm_main_last, + avm_main_bin_op_id, perm_main_alu, perm_main_bin, + perm_main_cmp, perm_main_mem_a, perm_main_mem_b, perm_main_mem_c, @@ -544,52 +635,70 @@ class AvmFlavor { incl_main_tag_err_counts, incl_mem_tag_err_counts, avm_alu_u16_r0_shift, - avm_alu_u16_r1_shift, - avm_alu_u16_r2_shift, avm_alu_u16_r3_shift, avm_alu_u16_r4_shift, - avm_alu_u16_r5_shift, - avm_alu_u16_r6_shift, avm_alu_u16_r7_shift, - avm_binary_acc_ia_shift, - avm_binary_acc_ib_shift, + avm_alu_u16_r6_shift, + avm_alu_u16_r2_shift, + avm_alu_u16_r5_shift, + avm_alu_u16_r1_shift, avm_binary_acc_ic_shift, - avm_binary_mem_tag_ctr_shift, avm_binary_op_id_shift, - avm_main_internal_return_ptr_shift, - avm_main_pc_shift, + avm_binary_mem_tag_ctr_shift, + avm_binary_acc_ia_shift, + avm_binary_acc_ib_shift, + avm_mem_tag_shift, avm_mem_addr_shift, + avm_mem_val_shift, avm_mem_rw_shift, - avm_mem_tag_shift, - avm_mem_val_shift) + avm_main_pc_shift, + avm_main_internal_return_ptr_shift) RefVector get_wires() { return { avm_main_clk, avm_main_first, - avm_alu_alu_sel, - avm_alu_cf, + avm_mem_clk, + avm_mem_sub_clk, + avm_mem_addr, + avm_mem_tag, + avm_mem_val, + avm_mem_lastAccess, + avm_mem_last, + avm_mem_rw, + avm_mem_r_in_tag, + avm_mem_w_in_tag, + 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_sel_mov, + avm_mem_tag_err, + avm_mem_one_min_inv, avm_alu_clk, - avm_alu_ff_tag, avm_alu_ia, avm_alu_ib, avm_alu_ic, - avm_alu_in_tag, avm_alu_op_add, - avm_alu_op_div, - avm_alu_op_eq, - avm_alu_op_eq_diff_inv, + avm_alu_op_sub, avm_alu_op_mul, + avm_alu_op_div, avm_alu_op_not, - avm_alu_op_sub, + avm_alu_op_eq, + avm_alu_alu_sel, + avm_alu_in_tag, + avm_alu_ff_tag, + avm_alu_u8_tag, + avm_alu_u16_tag, + avm_alu_u32_tag, + avm_alu_u64_tag, avm_alu_u128_tag, + avm_alu_u8_r0, + avm_alu_u8_r1, avm_alu_u16_r0, avm_alu_u16_r1, - avm_alu_u16_r10, - avm_alu_u16_r11, - avm_alu_u16_r12, - avm_alu_u16_r13, - avm_alu_u16_r14, avm_alu_u16_r2, avm_alu_u16_r3, avm_alu_u16_r4, @@ -598,99 +707,110 @@ class AvmFlavor { avm_alu_u16_r7, avm_alu_u16_r8, avm_alu_u16_r9, - avm_alu_u16_tag, - avm_alu_u32_tag, + avm_alu_u16_r10, + avm_alu_u16_r11, + avm_alu_u16_r12, + avm_alu_u16_r13, + avm_alu_u16_r14, avm_alu_u64_r0, - avm_alu_u64_tag, - avm_alu_u8_r0, - avm_alu_u8_r1, - avm_alu_u8_tag, + avm_alu_cf, + avm_alu_op_eq_diff_inv, + avm_byte_lookup_table_op_id, + avm_byte_lookup_table_input_a, + avm_byte_lookup_table_input_b, + avm_byte_lookup_table_output, + avm_byte_lookup_bin_sel, + avm_byte_lookup_table_in_tags, + avm_byte_lookup_table_byte_lengths, + avm_binary_clk, + avm_binary_bin_sel, avm_binary_acc_ia, avm_binary_acc_ib, avm_binary_acc_ic, - avm_binary_bin_sel, - avm_binary_clk, + avm_binary_in_tag, + avm_binary_op_id, avm_binary_ia_bytes, avm_binary_ib_bytes, avm_binary_ic_bytes, - avm_binary_in_tag, + avm_binary_start, avm_binary_mem_tag_ctr, avm_binary_mem_tag_ctr_inv, - avm_binary_op_id, - avm_binary_start, - avm_byte_lookup_bin_sel, - avm_byte_lookup_table_byte_lengths, - avm_byte_lookup_table_in_tags, - avm_byte_lookup_table_input_a, - avm_byte_lookup_table_input_b, - avm_byte_lookup_table_op_id, - avm_byte_lookup_table_output, + avm_cmp_cmp_clk, + avm_cmp_ia, + avm_cmp_ib, + avm_cmp_ic, + avm_cmp_lt_sel, + avm_cmp_lte_sel, + avm_cmp_cmp_sel, + avm_cmp_input_ia, + avm_cmp_input_ib, + avm_cmp_a_lo, + avm_cmp_a_hi, + avm_cmp_b_lo, + avm_cmp_b_hi, + avm_cmp_borrow, + avm_cmp_p_lo, + avm_cmp_p_hi, + avm_cmp_p_sub_a_lo, + avm_cmp_p_sub_a_hi, + avm_cmp_p_a_borrow, + avm_cmp_p_sub_b_lo, + avm_cmp_p_sub_b_hi, + avm_cmp_p_b_borrow, + avm_cmp_res_lo, + avm_cmp_res_hi, + avm_cmp_lt_query, + avm_main_sel_rng_8, + avm_main_sel_rng_16, + avm_main_pc, + avm_main_internal_return_ptr, + avm_main_sel_internal_call, + avm_main_sel_internal_return, + avm_main_sel_jump, + avm_main_sel_halt, + avm_main_sel_mov, + avm_main_sel_op_add, + avm_main_sel_op_sub, + avm_main_sel_op_mul, + avm_main_sel_op_div, + 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_sel_op_lt, + avm_main_sel_op_lte, avm_main_alu_sel, - avm_main_bin_op_id, avm_main_bin_sel, + avm_main_cmp_sel, + avm_main_r_in_tag, + avm_main_w_in_tag, + avm_main_op_err, + avm_main_tag_err, + avm_main_inv, avm_main_ia, avm_main_ib, avm_main_ic, + avm_main_mem_op_a, + avm_main_mem_op_b, + avm_main_mem_op_c, + avm_main_rwa, + avm_main_rwb, + avm_main_rwc, avm_main_ind_a, avm_main_ind_b, avm_main_ind_c, avm_main_ind_op_a, avm_main_ind_op_b, avm_main_ind_op_c, - 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_op_a, - avm_main_mem_op_b, - avm_main_mem_op_c, - avm_main_op_err, - avm_main_pc, - avm_main_r_in_tag, - avm_main_rwa, - avm_main_rwb, - avm_main_rwc, - 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_op_add, - avm_main_sel_op_and, - avm_main_sel_op_div, - avm_main_sel_op_eq, - avm_main_sel_op_mul, - avm_main_sel_op_not, - avm_main_sel_op_or, - avm_main_sel_op_sub, - avm_main_sel_op_xor, - avm_main_sel_rng_16, - avm_main_sel_rng_8, - avm_main_tag_err, - avm_main_w_in_tag, - avm_mem_addr, - avm_mem_clk, - avm_mem_ind_op_a, - avm_mem_ind_op_b, - avm_mem_ind_op_c, - 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_r_in_tag, - avm_mem_rw, - avm_mem_sel_mov, - avm_mem_sub_clk, - avm_mem_tag, - avm_mem_tag_err, - avm_mem_val, - avm_mem_w_in_tag, + avm_main_last, + avm_main_bin_op_id, perm_main_alu, perm_main_bin, + perm_main_cmp, perm_main_mem_a, perm_main_mem_b, perm_main_mem_c, @@ -706,52 +826,70 @@ class AvmFlavor { incl_main_tag_err_counts, incl_mem_tag_err_counts, avm_alu_u16_r0_shift, - avm_alu_u16_r1_shift, - avm_alu_u16_r2_shift, avm_alu_u16_r3_shift, avm_alu_u16_r4_shift, - avm_alu_u16_r5_shift, - avm_alu_u16_r6_shift, avm_alu_u16_r7_shift, - avm_binary_acc_ia_shift, - avm_binary_acc_ib_shift, + avm_alu_u16_r6_shift, + avm_alu_u16_r2_shift, + avm_alu_u16_r5_shift, + avm_alu_u16_r1_shift, avm_binary_acc_ic_shift, - avm_binary_mem_tag_ctr_shift, avm_binary_op_id_shift, - avm_main_internal_return_ptr_shift, - avm_main_pc_shift, + avm_binary_mem_tag_ctr_shift, + avm_binary_acc_ia_shift, + avm_binary_acc_ib_shift, + avm_mem_tag_shift, avm_mem_addr_shift, + avm_mem_val_shift, avm_mem_rw_shift, - avm_mem_tag_shift, - avm_mem_val_shift }; + avm_main_pc_shift, + avm_main_internal_return_ptr_shift }; }; RefVector get_unshifted() { return { avm_main_clk, avm_main_first, - avm_alu_alu_sel, - avm_alu_cf, + avm_mem_clk, + avm_mem_sub_clk, + avm_mem_addr, + avm_mem_tag, + avm_mem_val, + avm_mem_lastAccess, + avm_mem_last, + avm_mem_rw, + avm_mem_r_in_tag, + avm_mem_w_in_tag, + 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_sel_mov, + avm_mem_tag_err, + avm_mem_one_min_inv, avm_alu_clk, - avm_alu_ff_tag, avm_alu_ia, avm_alu_ib, avm_alu_ic, - avm_alu_in_tag, avm_alu_op_add, - avm_alu_op_div, - avm_alu_op_eq, - avm_alu_op_eq_diff_inv, + avm_alu_op_sub, avm_alu_op_mul, + avm_alu_op_div, avm_alu_op_not, - avm_alu_op_sub, + avm_alu_op_eq, + avm_alu_alu_sel, + avm_alu_in_tag, + avm_alu_ff_tag, + avm_alu_u8_tag, + avm_alu_u16_tag, + avm_alu_u32_tag, + avm_alu_u64_tag, avm_alu_u128_tag, + avm_alu_u8_r0, + avm_alu_u8_r1, avm_alu_u16_r0, avm_alu_u16_r1, - avm_alu_u16_r10, - avm_alu_u16_r11, - avm_alu_u16_r12, - avm_alu_u16_r13, - avm_alu_u16_r14, avm_alu_u16_r2, avm_alu_u16_r3, avm_alu_u16_r4, @@ -760,99 +898,110 @@ class AvmFlavor { avm_alu_u16_r7, avm_alu_u16_r8, avm_alu_u16_r9, - avm_alu_u16_tag, - avm_alu_u32_tag, + avm_alu_u16_r10, + avm_alu_u16_r11, + avm_alu_u16_r12, + avm_alu_u16_r13, + avm_alu_u16_r14, avm_alu_u64_r0, - avm_alu_u64_tag, - avm_alu_u8_r0, - avm_alu_u8_r1, - avm_alu_u8_tag, + avm_alu_cf, + avm_alu_op_eq_diff_inv, + avm_byte_lookup_table_op_id, + avm_byte_lookup_table_input_a, + avm_byte_lookup_table_input_b, + avm_byte_lookup_table_output, + avm_byte_lookup_bin_sel, + avm_byte_lookup_table_in_tags, + avm_byte_lookup_table_byte_lengths, + avm_binary_clk, + avm_binary_bin_sel, avm_binary_acc_ia, avm_binary_acc_ib, avm_binary_acc_ic, - avm_binary_bin_sel, - avm_binary_clk, + avm_binary_in_tag, + avm_binary_op_id, avm_binary_ia_bytes, avm_binary_ib_bytes, avm_binary_ic_bytes, - avm_binary_in_tag, + avm_binary_start, avm_binary_mem_tag_ctr, avm_binary_mem_tag_ctr_inv, - avm_binary_op_id, - avm_binary_start, - avm_byte_lookup_bin_sel, - avm_byte_lookup_table_byte_lengths, - avm_byte_lookup_table_in_tags, - avm_byte_lookup_table_input_a, - avm_byte_lookup_table_input_b, - avm_byte_lookup_table_op_id, - avm_byte_lookup_table_output, + avm_cmp_cmp_clk, + avm_cmp_ia, + avm_cmp_ib, + avm_cmp_ic, + avm_cmp_lt_sel, + avm_cmp_lte_sel, + avm_cmp_cmp_sel, + avm_cmp_input_ia, + avm_cmp_input_ib, + avm_cmp_a_lo, + avm_cmp_a_hi, + avm_cmp_b_lo, + avm_cmp_b_hi, + avm_cmp_borrow, + avm_cmp_p_lo, + avm_cmp_p_hi, + avm_cmp_p_sub_a_lo, + avm_cmp_p_sub_a_hi, + avm_cmp_p_a_borrow, + avm_cmp_p_sub_b_lo, + avm_cmp_p_sub_b_hi, + avm_cmp_p_b_borrow, + avm_cmp_res_lo, + avm_cmp_res_hi, + avm_cmp_lt_query, + avm_main_sel_rng_8, + avm_main_sel_rng_16, + avm_main_pc, + avm_main_internal_return_ptr, + avm_main_sel_internal_call, + avm_main_sel_internal_return, + avm_main_sel_jump, + avm_main_sel_halt, + avm_main_sel_mov, + avm_main_sel_op_add, + avm_main_sel_op_sub, + avm_main_sel_op_mul, + avm_main_sel_op_div, + 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_sel_op_lt, + avm_main_sel_op_lte, avm_main_alu_sel, - avm_main_bin_op_id, avm_main_bin_sel, + avm_main_cmp_sel, + avm_main_r_in_tag, + avm_main_w_in_tag, + avm_main_op_err, + avm_main_tag_err, + avm_main_inv, avm_main_ia, avm_main_ib, avm_main_ic, + avm_main_mem_op_a, + avm_main_mem_op_b, + avm_main_mem_op_c, + avm_main_rwa, + avm_main_rwb, + avm_main_rwc, avm_main_ind_a, avm_main_ind_b, avm_main_ind_c, avm_main_ind_op_a, avm_main_ind_op_b, avm_main_ind_op_c, - 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_op_a, - avm_main_mem_op_b, - avm_main_mem_op_c, - avm_main_op_err, - avm_main_pc, - avm_main_r_in_tag, - avm_main_rwa, - avm_main_rwb, - avm_main_rwc, - 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_op_add, - avm_main_sel_op_and, - avm_main_sel_op_div, - avm_main_sel_op_eq, - avm_main_sel_op_mul, - avm_main_sel_op_not, - avm_main_sel_op_or, - avm_main_sel_op_sub, - avm_main_sel_op_xor, - avm_main_sel_rng_16, - avm_main_sel_rng_8, - avm_main_tag_err, - avm_main_w_in_tag, - avm_mem_addr, - avm_mem_clk, - avm_mem_ind_op_a, - avm_mem_ind_op_b, - avm_mem_ind_op_c, - 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_r_in_tag, - avm_mem_rw, - avm_mem_sel_mov, - avm_mem_sub_clk, - avm_mem_tag, - avm_mem_tag_err, - avm_mem_val, - avm_mem_w_in_tag, + avm_main_last, + avm_main_bin_op_id, perm_main_alu, perm_main_bin, + perm_main_cmp, perm_main_mem_a, perm_main_mem_b, perm_main_mem_c, @@ -870,29 +1019,47 @@ class AvmFlavor { }; RefVector get_to_be_shifted() { - return { avm_alu_u16_r0, avm_alu_u16_r1, - avm_alu_u16_r2, avm_alu_u16_r3, - avm_alu_u16_r4, avm_alu_u16_r5, - avm_alu_u16_r6, avm_alu_u16_r7, - avm_binary_acc_ia, avm_binary_acc_ib, - avm_binary_acc_ic, avm_binary_mem_tag_ctr, - avm_binary_op_id, avm_main_internal_return_ptr, - avm_main_pc, avm_mem_addr, - avm_mem_rw, avm_mem_tag, - avm_mem_val }; + return { avm_alu_u16_r0, + avm_alu_u16_r3, + avm_alu_u16_r4, + avm_alu_u16_r7, + avm_alu_u16_r6, + avm_alu_u16_r2, + avm_alu_u16_r5, + avm_alu_u16_r1, + avm_binary_acc_ic, + avm_binary_op_id, + avm_binary_mem_tag_ctr, + avm_binary_acc_ia, + avm_binary_acc_ib, + avm_mem_tag, + avm_mem_addr, + avm_mem_val, + avm_mem_rw, + avm_main_pc, + avm_main_internal_return_ptr }; }; RefVector get_shifted() { - return { avm_alu_u16_r0_shift, avm_alu_u16_r1_shift, - avm_alu_u16_r2_shift, avm_alu_u16_r3_shift, - avm_alu_u16_r4_shift, avm_alu_u16_r5_shift, - avm_alu_u16_r6_shift, avm_alu_u16_r7_shift, - avm_binary_acc_ia_shift, avm_binary_acc_ib_shift, - avm_binary_acc_ic_shift, avm_binary_mem_tag_ctr_shift, - avm_binary_op_id_shift, avm_main_internal_return_ptr_shift, - avm_main_pc_shift, avm_mem_addr_shift, - avm_mem_rw_shift, avm_mem_tag_shift, - avm_mem_val_shift }; + return { avm_alu_u16_r0_shift, + avm_alu_u16_r3_shift, + avm_alu_u16_r4_shift, + avm_alu_u16_r7_shift, + avm_alu_u16_r6_shift, + avm_alu_u16_r2_shift, + avm_alu_u16_r5_shift, + avm_alu_u16_r1_shift, + avm_binary_acc_ic_shift, + avm_binary_op_id_shift, + avm_binary_mem_tag_ctr_shift, + avm_binary_acc_ia_shift, + avm_binary_acc_ib_shift, + avm_mem_tag_shift, + avm_mem_addr_shift, + avm_mem_val_shift, + avm_mem_rw_shift, + avm_main_pc_shift, + avm_main_internal_return_ptr_shift }; }; }; @@ -905,16 +1072,25 @@ class AvmFlavor { RefVector get_to_be_shifted() { - return { avm_alu_u16_r0, avm_alu_u16_r1, - avm_alu_u16_r2, avm_alu_u16_r3, - avm_alu_u16_r4, avm_alu_u16_r5, - avm_alu_u16_r6, avm_alu_u16_r7, - avm_binary_acc_ia, avm_binary_acc_ib, - avm_binary_acc_ic, avm_binary_mem_tag_ctr, - avm_binary_op_id, avm_main_internal_return_ptr, - avm_main_pc, avm_mem_addr, - avm_mem_rw, avm_mem_tag, - avm_mem_val }; + return { avm_alu_u16_r0, + avm_alu_u16_r3, + avm_alu_u16_r4, + avm_alu_u16_r7, + avm_alu_u16_r6, + avm_alu_u16_r2, + avm_alu_u16_r5, + avm_alu_u16_r1, + avm_binary_acc_ic, + avm_binary_op_id, + avm_binary_mem_tag_ctr, + avm_binary_acc_ia, + avm_binary_acc_ib, + avm_mem_tag, + avm_mem_addr, + avm_mem_val, + avm_mem_rw, + avm_main_pc, + avm_main_internal_return_ptr }; }; // The plookup wires that store plookup read data. @@ -990,6 +1166,7 @@ class AvmFlavor { ProverPolynomials(ProverPolynomials&& o) noexcept = default; ProverPolynomials& operator=(ProverPolynomials&& o) noexcept = default; ~ProverPolynomials() = default; +<<<<<<< HEAD // NOTE: copied from goblin ultra ProverPolynomials(ProvingKey& proving_key) @@ -1005,6 +1182,9 @@ class AvmFlavor { } [[nodiscard]] size_t get_polynomial_size() const { return avm_alu_alu_sel.size(); } +======= + [[nodiscard]] size_t get_polynomial_size() const { return avm_mem_clk.size(); } +>>>>>>> 7a982d52c (feat: init avm cmp) /** * @brief Returns the evaluations of all prover polynomials at one point on the boolean hypercube, which * represents one row in the execution trace. @@ -1060,29 +1240,47 @@ class AvmFlavor { { Base::avm_main_clk = "AVM_MAIN_CLK"; Base::avm_main_first = "AVM_MAIN_FIRST"; - Base::avm_alu_alu_sel = "AVM_ALU_ALU_SEL"; - Base::avm_alu_cf = "AVM_ALU_CF"; + Base::avm_mem_clk = "AVM_MEM_CLK"; + Base::avm_mem_sub_clk = "AVM_MEM_SUB_CLK"; + Base::avm_mem_addr = "AVM_MEM_ADDR"; + Base::avm_mem_tag = "AVM_MEM_TAG"; + Base::avm_mem_val = "AVM_MEM_VAL"; + Base::avm_mem_lastAccess = "AVM_MEM_LASTACCESS"; + Base::avm_mem_last = "AVM_MEM_LAST"; + Base::avm_mem_rw = "AVM_MEM_RW"; + Base::avm_mem_r_in_tag = "AVM_MEM_R_IN_TAG"; + Base::avm_mem_w_in_tag = "AVM_MEM_W_IN_TAG"; + 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_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_sel_mov = "AVM_MEM_SEL_MOV"; + Base::avm_mem_tag_err = "AVM_MEM_TAG_ERR"; + Base::avm_mem_one_min_inv = "AVM_MEM_ONE_MIN_INV"; Base::avm_alu_clk = "AVM_ALU_CLK"; - Base::avm_alu_ff_tag = "AVM_ALU_FF_TAG"; Base::avm_alu_ia = "AVM_ALU_IA"; Base::avm_alu_ib = "AVM_ALU_IB"; Base::avm_alu_ic = "AVM_ALU_IC"; - Base::avm_alu_in_tag = "AVM_ALU_IN_TAG"; Base::avm_alu_op_add = "AVM_ALU_OP_ADD"; - Base::avm_alu_op_div = "AVM_ALU_OP_DIV"; - Base::avm_alu_op_eq = "AVM_ALU_OP_EQ"; - Base::avm_alu_op_eq_diff_inv = "AVM_ALU_OP_EQ_DIFF_INV"; + Base::avm_alu_op_sub = "AVM_ALU_OP_SUB"; Base::avm_alu_op_mul = "AVM_ALU_OP_MUL"; + Base::avm_alu_op_div = "AVM_ALU_OP_DIV"; Base::avm_alu_op_not = "AVM_ALU_OP_NOT"; - Base::avm_alu_op_sub = "AVM_ALU_OP_SUB"; + Base::avm_alu_op_eq = "AVM_ALU_OP_EQ"; + Base::avm_alu_alu_sel = "AVM_ALU_ALU_SEL"; + Base::avm_alu_in_tag = "AVM_ALU_IN_TAG"; + Base::avm_alu_ff_tag = "AVM_ALU_FF_TAG"; + Base::avm_alu_u8_tag = "AVM_ALU_U8_TAG"; + Base::avm_alu_u16_tag = "AVM_ALU_U16_TAG"; + Base::avm_alu_u32_tag = "AVM_ALU_U32_TAG"; + Base::avm_alu_u64_tag = "AVM_ALU_U64_TAG"; Base::avm_alu_u128_tag = "AVM_ALU_U128_TAG"; + Base::avm_alu_u8_r0 = "AVM_ALU_U8_R0"; + Base::avm_alu_u8_r1 = "AVM_ALU_U8_R1"; Base::avm_alu_u16_r0 = "AVM_ALU_U16_R0"; Base::avm_alu_u16_r1 = "AVM_ALU_U16_R1"; - Base::avm_alu_u16_r10 = "AVM_ALU_U16_R10"; - Base::avm_alu_u16_r11 = "AVM_ALU_U16_R11"; - Base::avm_alu_u16_r12 = "AVM_ALU_U16_R12"; - Base::avm_alu_u16_r13 = "AVM_ALU_U16_R13"; - Base::avm_alu_u16_r14 = "AVM_ALU_U16_R14"; Base::avm_alu_u16_r2 = "AVM_ALU_U16_R2"; Base::avm_alu_u16_r3 = "AVM_ALU_U16_R3"; Base::avm_alu_u16_r4 = "AVM_ALU_U16_R4"; @@ -1091,99 +1289,110 @@ class AvmFlavor { Base::avm_alu_u16_r7 = "AVM_ALU_U16_R7"; Base::avm_alu_u16_r8 = "AVM_ALU_U16_R8"; Base::avm_alu_u16_r9 = "AVM_ALU_U16_R9"; - Base::avm_alu_u16_tag = "AVM_ALU_U16_TAG"; - Base::avm_alu_u32_tag = "AVM_ALU_U32_TAG"; + Base::avm_alu_u16_r10 = "AVM_ALU_U16_R10"; + Base::avm_alu_u16_r11 = "AVM_ALU_U16_R11"; + Base::avm_alu_u16_r12 = "AVM_ALU_U16_R12"; + Base::avm_alu_u16_r13 = "AVM_ALU_U16_R13"; + Base::avm_alu_u16_r14 = "AVM_ALU_U16_R14"; Base::avm_alu_u64_r0 = "AVM_ALU_U64_R0"; - Base::avm_alu_u64_tag = "AVM_ALU_U64_TAG"; - Base::avm_alu_u8_r0 = "AVM_ALU_U8_R0"; - Base::avm_alu_u8_r1 = "AVM_ALU_U8_R1"; - Base::avm_alu_u8_tag = "AVM_ALU_U8_TAG"; + Base::avm_alu_cf = "AVM_ALU_CF"; + Base::avm_alu_op_eq_diff_inv = "AVM_ALU_OP_EQ_DIFF_INV"; + Base::avm_byte_lookup_table_op_id = "AVM_BYTE_LOOKUP_TABLE_OP_ID"; + Base::avm_byte_lookup_table_input_a = "AVM_BYTE_LOOKUP_TABLE_INPUT_A"; + Base::avm_byte_lookup_table_input_b = "AVM_BYTE_LOOKUP_TABLE_INPUT_B"; + Base::avm_byte_lookup_table_output = "AVM_BYTE_LOOKUP_TABLE_OUTPUT"; + Base::avm_byte_lookup_bin_sel = "AVM_BYTE_LOOKUP_BIN_SEL"; + Base::avm_byte_lookup_table_in_tags = "AVM_BYTE_LOOKUP_TABLE_IN_TAGS"; + Base::avm_byte_lookup_table_byte_lengths = "AVM_BYTE_LOOKUP_TABLE_BYTE_LENGTHS"; + Base::avm_binary_clk = "AVM_BINARY_CLK"; + Base::avm_binary_bin_sel = "AVM_BINARY_BIN_SEL"; Base::avm_binary_acc_ia = "AVM_BINARY_ACC_IA"; Base::avm_binary_acc_ib = "AVM_BINARY_ACC_IB"; Base::avm_binary_acc_ic = "AVM_BINARY_ACC_IC"; - Base::avm_binary_bin_sel = "AVM_BINARY_BIN_SEL"; - Base::avm_binary_clk = "AVM_BINARY_CLK"; + Base::avm_binary_in_tag = "AVM_BINARY_IN_TAG"; + Base::avm_binary_op_id = "AVM_BINARY_OP_ID"; Base::avm_binary_ia_bytes = "AVM_BINARY_IA_BYTES"; Base::avm_binary_ib_bytes = "AVM_BINARY_IB_BYTES"; Base::avm_binary_ic_bytes = "AVM_BINARY_IC_BYTES"; - Base::avm_binary_in_tag = "AVM_BINARY_IN_TAG"; + Base::avm_binary_start = "AVM_BINARY_START"; Base::avm_binary_mem_tag_ctr = "AVM_BINARY_MEM_TAG_CTR"; Base::avm_binary_mem_tag_ctr_inv = "AVM_BINARY_MEM_TAG_CTR_INV"; - Base::avm_binary_op_id = "AVM_BINARY_OP_ID"; - Base::avm_binary_start = "AVM_BINARY_START"; - Base::avm_byte_lookup_bin_sel = "AVM_BYTE_LOOKUP_BIN_SEL"; - Base::avm_byte_lookup_table_byte_lengths = "AVM_BYTE_LOOKUP_TABLE_BYTE_LENGTHS"; - Base::avm_byte_lookup_table_in_tags = "AVM_BYTE_LOOKUP_TABLE_IN_TAGS"; - Base::avm_byte_lookup_table_input_a = "AVM_BYTE_LOOKUP_TABLE_INPUT_A"; - Base::avm_byte_lookup_table_input_b = "AVM_BYTE_LOOKUP_TABLE_INPUT_B"; - Base::avm_byte_lookup_table_op_id = "AVM_BYTE_LOOKUP_TABLE_OP_ID"; - Base::avm_byte_lookup_table_output = "AVM_BYTE_LOOKUP_TABLE_OUTPUT"; + Base::avm_cmp_cmp_clk = "AVM_CMP_CMP_CLK"; + Base::avm_cmp_ia = "AVM_CMP_IA"; + Base::avm_cmp_ib = "AVM_CMP_IB"; + Base::avm_cmp_ic = "AVM_CMP_IC"; + Base::avm_cmp_lt_sel = "AVM_CMP_LT_SEL"; + Base::avm_cmp_lte_sel = "AVM_CMP_LTE_SEL"; + Base::avm_cmp_cmp_sel = "AVM_CMP_CMP_SEL"; + Base::avm_cmp_input_ia = "AVM_CMP_INPUT_IA"; + Base::avm_cmp_input_ib = "AVM_CMP_INPUT_IB"; + Base::avm_cmp_a_lo = "AVM_CMP_A_LO"; + Base::avm_cmp_a_hi = "AVM_CMP_A_HI"; + Base::avm_cmp_b_lo = "AVM_CMP_B_LO"; + Base::avm_cmp_b_hi = "AVM_CMP_B_HI"; + Base::avm_cmp_borrow = "AVM_CMP_BORROW"; + Base::avm_cmp_p_lo = "AVM_CMP_P_LO"; + Base::avm_cmp_p_hi = "AVM_CMP_P_HI"; + Base::avm_cmp_p_sub_a_lo = "AVM_CMP_P_SUB_A_LO"; + Base::avm_cmp_p_sub_a_hi = "AVM_CMP_P_SUB_A_HI"; + Base::avm_cmp_p_a_borrow = "AVM_CMP_P_A_BORROW"; + Base::avm_cmp_p_sub_b_lo = "AVM_CMP_P_SUB_B_LO"; + Base::avm_cmp_p_sub_b_hi = "AVM_CMP_P_SUB_B_HI"; + Base::avm_cmp_p_b_borrow = "AVM_CMP_P_B_BORROW"; + Base::avm_cmp_res_lo = "AVM_CMP_RES_LO"; + Base::avm_cmp_res_hi = "AVM_CMP_RES_HI"; + Base::avm_cmp_lt_query = "AVM_CMP_LT_QUERY"; + Base::avm_main_sel_rng_8 = "AVM_MAIN_SEL_RNG_8"; + Base::avm_main_sel_rng_16 = "AVM_MAIN_SEL_RNG_16"; + Base::avm_main_pc = "AVM_MAIN_PC"; + Base::avm_main_internal_return_ptr = "AVM_MAIN_INTERNAL_RETURN_PTR"; + 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_halt = "AVM_MAIN_SEL_HALT"; + Base::avm_main_sel_mov = "AVM_MAIN_SEL_MOV"; + Base::avm_main_sel_op_add = "AVM_MAIN_SEL_OP_ADD"; + Base::avm_main_sel_op_sub = "AVM_MAIN_SEL_OP_SUB"; + Base::avm_main_sel_op_mul = "AVM_MAIN_SEL_OP_MUL"; + Base::avm_main_sel_op_div = "AVM_MAIN_SEL_OP_DIV"; + Base::avm_main_sel_op_not = "AVM_MAIN_SEL_OP_NOT"; + Base::avm_main_sel_op_eq = "AVM_MAIN_SEL_OP_EQ"; + Base::avm_main_sel_op_and = "AVM_MAIN_SEL_OP_AND"; + Base::avm_main_sel_op_or = "AVM_MAIN_SEL_OP_OR"; + Base::avm_main_sel_op_xor = "AVM_MAIN_SEL_OP_XOR"; + Base::avm_main_sel_op_lt = "AVM_MAIN_SEL_OP_LT"; + Base::avm_main_sel_op_lte = "AVM_MAIN_SEL_OP_LTE"; Base::avm_main_alu_sel = "AVM_MAIN_ALU_SEL"; - Base::avm_main_bin_op_id = "AVM_MAIN_BIN_OP_ID"; Base::avm_main_bin_sel = "AVM_MAIN_BIN_SEL"; + Base::avm_main_cmp_sel = "AVM_MAIN_CMP_SEL"; + Base::avm_main_r_in_tag = "AVM_MAIN_R_IN_TAG"; + Base::avm_main_w_in_tag = "AVM_MAIN_W_IN_TAG"; + Base::avm_main_op_err = "AVM_MAIN_OP_ERR"; + Base::avm_main_tag_err = "AVM_MAIN_TAG_ERR"; + Base::avm_main_inv = "AVM_MAIN_INV"; Base::avm_main_ia = "AVM_MAIN_IA"; Base::avm_main_ib = "AVM_MAIN_IB"; Base::avm_main_ic = "AVM_MAIN_IC"; + 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_rwa = "AVM_MAIN_RWA"; + Base::avm_main_rwb = "AVM_MAIN_RWB"; + Base::avm_main_rwc = "AVM_MAIN_RWC"; 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_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_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_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_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_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_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"; - Base::avm_main_sel_op_eq = "AVM_MAIN_SEL_OP_EQ"; - Base::avm_main_sel_op_mul = "AVM_MAIN_SEL_OP_MUL"; - Base::avm_main_sel_op_not = "AVM_MAIN_SEL_OP_NOT"; - Base::avm_main_sel_op_or = "AVM_MAIN_SEL_OP_OR"; - Base::avm_main_sel_op_sub = "AVM_MAIN_SEL_OP_SUB"; - Base::avm_main_sel_op_xor = "AVM_MAIN_SEL_OP_XOR"; - Base::avm_main_sel_rng_16 = "AVM_MAIN_SEL_RNG_16"; - Base::avm_main_sel_rng_8 = "AVM_MAIN_SEL_RNG_8"; - Base::avm_main_tag_err = "AVM_MAIN_TAG_ERR"; - Base::avm_main_w_in_tag = "AVM_MAIN_W_IN_TAG"; - Base::avm_mem_addr = "AVM_MEM_ADDR"; - Base::avm_mem_clk = "AVM_MEM_CLK"; - 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_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_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_sub_clk = "AVM_MEM_SUB_CLK"; - Base::avm_mem_tag = "AVM_MEM_TAG"; - Base::avm_mem_tag_err = "AVM_MEM_TAG_ERR"; - Base::avm_mem_val = "AVM_MEM_VAL"; - Base::avm_mem_w_in_tag = "AVM_MEM_W_IN_TAG"; + Base::avm_main_last = "AVM_MAIN_LAST"; + Base::avm_main_bin_op_id = "AVM_MAIN_BIN_OP_ID"; Base::perm_main_alu = "PERM_MAIN_ALU"; Base::perm_main_bin = "PERM_MAIN_BIN"; + Base::perm_main_cmp = "PERM_MAIN_CMP"; 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"; @@ -1217,29 +1426,47 @@ class AvmFlavor { public: uint32_t circuit_size; - Commitment avm_alu_alu_sel; - Commitment avm_alu_cf; + Commitment avm_mem_clk; + Commitment avm_mem_sub_clk; + Commitment avm_mem_addr; + Commitment avm_mem_tag; + Commitment avm_mem_val; + Commitment avm_mem_lastAccess; + Commitment avm_mem_last; + Commitment avm_mem_rw; + Commitment avm_mem_r_in_tag; + Commitment avm_mem_w_in_tag; + Commitment avm_mem_op_a; + Commitment avm_mem_op_b; + Commitment avm_mem_op_c; + Commitment avm_mem_ind_op_a; + Commitment avm_mem_ind_op_b; + Commitment avm_mem_ind_op_c; + Commitment avm_mem_sel_mov; + Commitment avm_mem_tag_err; + Commitment avm_mem_one_min_inv; Commitment avm_alu_clk; - Commitment avm_alu_ff_tag; Commitment avm_alu_ia; Commitment avm_alu_ib; Commitment avm_alu_ic; - Commitment avm_alu_in_tag; Commitment avm_alu_op_add; - Commitment avm_alu_op_div; - Commitment avm_alu_op_eq; - Commitment avm_alu_op_eq_diff_inv; + Commitment avm_alu_op_sub; Commitment avm_alu_op_mul; + Commitment avm_alu_op_div; Commitment avm_alu_op_not; - Commitment avm_alu_op_sub; + Commitment avm_alu_op_eq; + Commitment avm_alu_alu_sel; + Commitment avm_alu_in_tag; + Commitment avm_alu_ff_tag; + Commitment avm_alu_u8_tag; + Commitment avm_alu_u16_tag; + Commitment avm_alu_u32_tag; + Commitment avm_alu_u64_tag; Commitment avm_alu_u128_tag; + Commitment avm_alu_u8_r0; + Commitment avm_alu_u8_r1; Commitment avm_alu_u16_r0; Commitment avm_alu_u16_r1; - Commitment avm_alu_u16_r10; - Commitment avm_alu_u16_r11; - Commitment avm_alu_u16_r12; - Commitment avm_alu_u16_r13; - Commitment avm_alu_u16_r14; Commitment avm_alu_u16_r2; Commitment avm_alu_u16_r3; Commitment avm_alu_u16_r4; @@ -1248,51 +1475,106 @@ class AvmFlavor { Commitment avm_alu_u16_r7; Commitment avm_alu_u16_r8; Commitment avm_alu_u16_r9; - Commitment avm_alu_u16_tag; - Commitment avm_alu_u32_tag; + Commitment avm_alu_u16_r10; + Commitment avm_alu_u16_r11; + Commitment avm_alu_u16_r12; + Commitment avm_alu_u16_r13; + Commitment avm_alu_u16_r14; Commitment avm_alu_u64_r0; - Commitment avm_alu_u64_tag; - Commitment avm_alu_u8_r0; - Commitment avm_alu_u8_r1; - Commitment avm_alu_u8_tag; + Commitment avm_alu_cf; + Commitment avm_alu_op_eq_diff_inv; + Commitment avm_byte_lookup_table_op_id; + Commitment avm_byte_lookup_table_input_a; + Commitment avm_byte_lookup_table_input_b; + Commitment avm_byte_lookup_table_output; + Commitment avm_byte_lookup_bin_sel; + Commitment avm_byte_lookup_table_in_tags; + Commitment avm_byte_lookup_table_byte_lengths; + Commitment avm_binary_clk; + Commitment avm_binary_bin_sel; Commitment avm_binary_acc_ia; Commitment avm_binary_acc_ib; Commitment avm_binary_acc_ic; - Commitment avm_binary_bin_sel; - Commitment avm_binary_clk; + Commitment avm_binary_in_tag; + Commitment avm_binary_op_id; Commitment avm_binary_ia_bytes; Commitment avm_binary_ib_bytes; Commitment avm_binary_ic_bytes; - Commitment avm_binary_in_tag; + Commitment avm_binary_start; Commitment avm_binary_mem_tag_ctr; Commitment avm_binary_mem_tag_ctr_inv; - Commitment avm_binary_op_id; - Commitment avm_binary_start; - Commitment avm_byte_lookup_bin_sel; - Commitment avm_byte_lookup_table_byte_lengths; - Commitment avm_byte_lookup_table_in_tags; - Commitment avm_byte_lookup_table_input_a; - Commitment avm_byte_lookup_table_input_b; - Commitment avm_byte_lookup_table_op_id; - Commitment avm_byte_lookup_table_output; + Commitment avm_cmp_cmp_clk; + Commitment avm_cmp_ia; + Commitment avm_cmp_ib; + Commitment avm_cmp_ic; + Commitment avm_cmp_lt_sel; + Commitment avm_cmp_lte_sel; + Commitment avm_cmp_cmp_sel; + Commitment avm_cmp_input_ia; + Commitment avm_cmp_input_ib; + Commitment avm_cmp_a_lo; + Commitment avm_cmp_a_hi; + Commitment avm_cmp_b_lo; + Commitment avm_cmp_b_hi; + Commitment avm_cmp_borrow; + Commitment avm_cmp_p_lo; + Commitment avm_cmp_p_hi; + Commitment avm_cmp_p_sub_a_lo; + Commitment avm_cmp_p_sub_a_hi; + Commitment avm_cmp_p_a_borrow; + Commitment avm_cmp_p_sub_b_lo; + Commitment avm_cmp_p_sub_b_hi; + Commitment avm_cmp_p_b_borrow; + Commitment avm_cmp_res_lo; + Commitment avm_cmp_res_hi; + Commitment avm_cmp_lt_query; + Commitment avm_main_sel_rng_8; + Commitment avm_main_sel_rng_16; + Commitment avm_main_pc; + Commitment avm_main_internal_return_ptr; + Commitment avm_main_sel_internal_call; + Commitment avm_main_sel_internal_return; + Commitment avm_main_sel_jump; + Commitment avm_main_sel_halt; + Commitment avm_main_sel_mov; + Commitment avm_main_sel_op_add; + Commitment avm_main_sel_op_sub; + Commitment avm_main_sel_op_mul; + Commitment avm_main_sel_op_div; + Commitment avm_main_sel_op_not; + Commitment avm_main_sel_op_eq; + Commitment avm_main_sel_op_and; + Commitment avm_main_sel_op_or; + Commitment avm_main_sel_op_xor; + Commitment avm_main_sel_op_lt; + Commitment avm_main_sel_op_lte; Commitment avm_main_alu_sel; - Commitment avm_main_bin_op_id; Commitment avm_main_bin_sel; + Commitment avm_main_cmp_sel; + Commitment avm_main_r_in_tag; + Commitment avm_main_w_in_tag; + Commitment avm_main_op_err; + Commitment avm_main_tag_err; + Commitment avm_main_inv; Commitment avm_main_ia; Commitment avm_main_ib; Commitment avm_main_ic; + Commitment avm_main_mem_op_a; + Commitment avm_main_mem_op_b; + Commitment avm_main_mem_op_c; + Commitment avm_main_rwa; + Commitment avm_main_rwb; + Commitment avm_main_rwc; Commitment avm_main_ind_a; Commitment avm_main_ind_b; Commitment avm_main_ind_c; Commitment avm_main_ind_op_a; Commitment avm_main_ind_op_b; Commitment avm_main_ind_op_c; - 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; +<<<<<<< HEAD Commitment avm_main_mem_op_a; Commitment avm_main_mem_op_b; Commitment avm_main_mem_op_c; @@ -1341,8 +1623,13 @@ class AvmFlavor { Commitment avm_mem_w_in_tag; // Perm inverses +======= + Commitment avm_main_last; + Commitment avm_main_bin_op_id; +>>>>>>> 7a982d52c (feat: init avm cmp) Commitment perm_main_alu; Commitment perm_main_bin; + Commitment perm_main_cmp; Commitment perm_main_mem_a; Commitment perm_main_mem_b; Commitment perm_main_mem_c; @@ -1379,29 +1666,47 @@ class AvmFlavor { circuit_size = deserialize_from_buffer(proof_data, num_frs_read); size_t log_n = numeric::get_msb(circuit_size); - avm_alu_alu_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_cf = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_mem_clk = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_mem_sub_clk = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_mem_addr = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_mem_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_mem_val = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_mem_lastAccess = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_mem_last = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_mem_rw = 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_w_in_tag = 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_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_sel_mov = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_mem_tag_err = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_mem_one_min_inv = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_clk = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_ff_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_ia = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_ib = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_ic = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_in_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_op_add = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_op_div = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_op_eq = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_op_eq_diff_inv = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_op_sub = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_op_mul = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_op_div = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_op_not = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_op_sub = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_op_eq = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_alu_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_in_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_ff_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_u8_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_u16_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_u32_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_u64_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_u128_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_u8_r0 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_u8_r1 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_u16_r0 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_u16_r1 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_u16_r10 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_u16_r11 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_u16_r12 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_u16_r13 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_u16_r14 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_u16_r2 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_u16_r3 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_u16_r4 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); @@ -1410,100 +1715,111 @@ class AvmFlavor { avm_alu_u16_r7 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_u16_r8 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_u16_r9 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_u16_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_u32_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_u16_r10 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_u16_r11 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_u16_r12 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_u16_r13 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_u16_r14 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_u64_r0 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_u64_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_u8_r0 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_u8_r1 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_u8_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_cf = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_op_eq_diff_inv = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_byte_lookup_table_op_id = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_byte_lookup_table_input_a = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_byte_lookup_table_input_b = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_byte_lookup_table_output = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_byte_lookup_bin_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_byte_lookup_table_in_tags = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_byte_lookup_table_byte_lengths = + deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_binary_clk = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_binary_bin_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_binary_acc_ia = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_binary_acc_ib = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_binary_acc_ic = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_binary_bin_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_binary_clk = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_binary_in_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_binary_op_id = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_binary_ia_bytes = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_binary_ib_bytes = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_binary_ic_bytes = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_binary_in_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_binary_start = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_binary_mem_tag_ctr = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_binary_mem_tag_ctr_inv = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_binary_op_id = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_binary_start = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_byte_lookup_bin_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_byte_lookup_table_byte_lengths = - deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_byte_lookup_table_in_tags = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_byte_lookup_table_input_a = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_byte_lookup_table_input_b = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_byte_lookup_table_op_id = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_byte_lookup_table_output = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_cmp_cmp_clk = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_cmp_ia = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_cmp_ib = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_cmp_ic = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_cmp_lt_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_cmp_lte_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_cmp_cmp_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_cmp_input_ia = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_cmp_input_ib = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_cmp_a_lo = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_cmp_a_hi = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_cmp_b_lo = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_cmp_b_hi = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_cmp_borrow = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_cmp_p_lo = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_cmp_p_hi = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_cmp_p_sub_a_lo = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_cmp_p_sub_a_hi = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_cmp_p_a_borrow = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_cmp_p_sub_b_lo = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_cmp_p_sub_b_hi = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_cmp_p_b_borrow = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_cmp_res_lo = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_cmp_res_hi = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_cmp_lt_query = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_rng_8 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_rng_16 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_pc = 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_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_halt = 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_op_add = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_op_sub = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_op_mul = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_op_div = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_op_not = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_op_eq = 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_or = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_op_xor = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_op_lt = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_op_lte = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_alu_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_main_bin_op_id = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_bin_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_cmp_sel = 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_w_in_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_op_err = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_tag_err = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_inv = deserialize_from_buffer(Transcript::proof_data, num_frs_read); 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_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_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_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_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_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_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_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_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_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); - avm_main_sel_op_eq = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_main_sel_op_mul = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_main_sel_op_not = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_main_sel_op_or = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_main_sel_op_sub = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_main_sel_op_xor = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_main_sel_rng_16 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_main_sel_rng_8 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_main_tag_err = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_main_w_in_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_mem_addr = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_mem_clk = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - 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_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_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_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); - avm_mem_val = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_mem_w_in_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_last = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_bin_op_id = deserialize_from_buffer(Transcript::proof_data, num_frs_read); perm_main_alu = deserialize_from_buffer(Transcript::proof_data, num_frs_read); perm_main_bin = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + perm_main_cmp = deserialize_from_buffer(Transcript::proof_data, num_frs_read); 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); @@ -1541,29 +1857,47 @@ class AvmFlavor { serialize_to_buffer(circuit_size, Transcript::proof_data); - serialize_to_buffer(avm_alu_alu_sel, Transcript::proof_data); - serialize_to_buffer(avm_alu_cf, Transcript::proof_data); + serialize_to_buffer(avm_mem_clk, Transcript::proof_data); + serialize_to_buffer(avm_mem_sub_clk, Transcript::proof_data); + serialize_to_buffer(avm_mem_addr, Transcript::proof_data); + serialize_to_buffer(avm_mem_tag, Transcript::proof_data); + serialize_to_buffer(avm_mem_val, Transcript::proof_data); + serialize_to_buffer(avm_mem_lastAccess, Transcript::proof_data); + serialize_to_buffer(avm_mem_last, Transcript::proof_data); + serialize_to_buffer(avm_mem_rw, Transcript::proof_data); + serialize_to_buffer(avm_mem_r_in_tag, Transcript::proof_data); + serialize_to_buffer(avm_mem_w_in_tag, 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_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_sel_mov, Transcript::proof_data); + serialize_to_buffer(avm_mem_tag_err, Transcript::proof_data); + serialize_to_buffer(avm_mem_one_min_inv, Transcript::proof_data); serialize_to_buffer(avm_alu_clk, Transcript::proof_data); - serialize_to_buffer(avm_alu_ff_tag, Transcript::proof_data); serialize_to_buffer(avm_alu_ia, Transcript::proof_data); serialize_to_buffer(avm_alu_ib, Transcript::proof_data); serialize_to_buffer(avm_alu_ic, Transcript::proof_data); - serialize_to_buffer(avm_alu_in_tag, Transcript::proof_data); serialize_to_buffer(avm_alu_op_add, Transcript::proof_data); - serialize_to_buffer(avm_alu_op_div, Transcript::proof_data); - serialize_to_buffer(avm_alu_op_eq, Transcript::proof_data); - serialize_to_buffer(avm_alu_op_eq_diff_inv, Transcript::proof_data); + serialize_to_buffer(avm_alu_op_sub, Transcript::proof_data); serialize_to_buffer(avm_alu_op_mul, Transcript::proof_data); + serialize_to_buffer(avm_alu_op_div, Transcript::proof_data); serialize_to_buffer(avm_alu_op_not, Transcript::proof_data); - serialize_to_buffer(avm_alu_op_sub, Transcript::proof_data); + serialize_to_buffer(avm_alu_op_eq, Transcript::proof_data); + serialize_to_buffer(avm_alu_alu_sel, Transcript::proof_data); + serialize_to_buffer(avm_alu_in_tag, Transcript::proof_data); + serialize_to_buffer(avm_alu_ff_tag, Transcript::proof_data); + serialize_to_buffer(avm_alu_u8_tag, Transcript::proof_data); + serialize_to_buffer(avm_alu_u16_tag, Transcript::proof_data); + serialize_to_buffer(avm_alu_u32_tag, Transcript::proof_data); + serialize_to_buffer(avm_alu_u64_tag, Transcript::proof_data); serialize_to_buffer(avm_alu_u128_tag, Transcript::proof_data); + serialize_to_buffer(avm_alu_u8_r0, Transcript::proof_data); + serialize_to_buffer(avm_alu_u8_r1, Transcript::proof_data); serialize_to_buffer(avm_alu_u16_r0, Transcript::proof_data); serialize_to_buffer(avm_alu_u16_r1, Transcript::proof_data); - serialize_to_buffer(avm_alu_u16_r10, Transcript::proof_data); - serialize_to_buffer(avm_alu_u16_r11, Transcript::proof_data); - serialize_to_buffer(avm_alu_u16_r12, Transcript::proof_data); - serialize_to_buffer(avm_alu_u16_r13, Transcript::proof_data); - serialize_to_buffer(avm_alu_u16_r14, Transcript::proof_data); serialize_to_buffer(avm_alu_u16_r2, Transcript::proof_data); serialize_to_buffer(avm_alu_u16_r3, Transcript::proof_data); serialize_to_buffer(avm_alu_u16_r4, Transcript::proof_data); @@ -1572,99 +1906,110 @@ class AvmFlavor { serialize_to_buffer(avm_alu_u16_r7, Transcript::proof_data); serialize_to_buffer(avm_alu_u16_r8, Transcript::proof_data); serialize_to_buffer(avm_alu_u16_r9, Transcript::proof_data); - serialize_to_buffer(avm_alu_u16_tag, Transcript::proof_data); - serialize_to_buffer(avm_alu_u32_tag, Transcript::proof_data); + serialize_to_buffer(avm_alu_u16_r10, Transcript::proof_data); + serialize_to_buffer(avm_alu_u16_r11, Transcript::proof_data); + serialize_to_buffer(avm_alu_u16_r12, Transcript::proof_data); + serialize_to_buffer(avm_alu_u16_r13, Transcript::proof_data); + serialize_to_buffer(avm_alu_u16_r14, Transcript::proof_data); serialize_to_buffer(avm_alu_u64_r0, Transcript::proof_data); - serialize_to_buffer(avm_alu_u64_tag, Transcript::proof_data); - serialize_to_buffer(avm_alu_u8_r0, Transcript::proof_data); - serialize_to_buffer(avm_alu_u8_r1, Transcript::proof_data); - serialize_to_buffer(avm_alu_u8_tag, Transcript::proof_data); + serialize_to_buffer(avm_alu_cf, Transcript::proof_data); + serialize_to_buffer(avm_alu_op_eq_diff_inv, Transcript::proof_data); + serialize_to_buffer(avm_byte_lookup_table_op_id, Transcript::proof_data); + serialize_to_buffer(avm_byte_lookup_table_input_a, Transcript::proof_data); + serialize_to_buffer(avm_byte_lookup_table_input_b, Transcript::proof_data); + serialize_to_buffer(avm_byte_lookup_table_output, Transcript::proof_data); + serialize_to_buffer(avm_byte_lookup_bin_sel, Transcript::proof_data); + serialize_to_buffer(avm_byte_lookup_table_in_tags, Transcript::proof_data); + serialize_to_buffer(avm_byte_lookup_table_byte_lengths, Transcript::proof_data); + serialize_to_buffer(avm_binary_clk, Transcript::proof_data); + serialize_to_buffer(avm_binary_bin_sel, Transcript::proof_data); serialize_to_buffer(avm_binary_acc_ia, Transcript::proof_data); serialize_to_buffer(avm_binary_acc_ib, Transcript::proof_data); serialize_to_buffer(avm_binary_acc_ic, Transcript::proof_data); - serialize_to_buffer(avm_binary_bin_sel, Transcript::proof_data); - serialize_to_buffer(avm_binary_clk, Transcript::proof_data); + serialize_to_buffer(avm_binary_in_tag, Transcript::proof_data); + serialize_to_buffer(avm_binary_op_id, Transcript::proof_data); serialize_to_buffer(avm_binary_ia_bytes, Transcript::proof_data); serialize_to_buffer(avm_binary_ib_bytes, Transcript::proof_data); serialize_to_buffer(avm_binary_ic_bytes, Transcript::proof_data); - serialize_to_buffer(avm_binary_in_tag, Transcript::proof_data); + serialize_to_buffer(avm_binary_start, Transcript::proof_data); serialize_to_buffer(avm_binary_mem_tag_ctr, Transcript::proof_data); serialize_to_buffer(avm_binary_mem_tag_ctr_inv, Transcript::proof_data); - serialize_to_buffer(avm_binary_op_id, Transcript::proof_data); - serialize_to_buffer(avm_binary_start, Transcript::proof_data); - serialize_to_buffer(avm_byte_lookup_bin_sel, Transcript::proof_data); - serialize_to_buffer(avm_byte_lookup_table_byte_lengths, Transcript::proof_data); - serialize_to_buffer(avm_byte_lookup_table_in_tags, Transcript::proof_data); - serialize_to_buffer(avm_byte_lookup_table_input_a, Transcript::proof_data); - serialize_to_buffer(avm_byte_lookup_table_input_b, Transcript::proof_data); - serialize_to_buffer(avm_byte_lookup_table_op_id, Transcript::proof_data); - serialize_to_buffer(avm_byte_lookup_table_output, Transcript::proof_data); + serialize_to_buffer(avm_cmp_cmp_clk, Transcript::proof_data); + serialize_to_buffer(avm_cmp_ia, Transcript::proof_data); + serialize_to_buffer(avm_cmp_ib, Transcript::proof_data); + serialize_to_buffer(avm_cmp_ic, Transcript::proof_data); + serialize_to_buffer(avm_cmp_lt_sel, Transcript::proof_data); + serialize_to_buffer(avm_cmp_lte_sel, Transcript::proof_data); + serialize_to_buffer(avm_cmp_cmp_sel, Transcript::proof_data); + serialize_to_buffer(avm_cmp_input_ia, Transcript::proof_data); + serialize_to_buffer(avm_cmp_input_ib, Transcript::proof_data); + serialize_to_buffer(avm_cmp_a_lo, Transcript::proof_data); + serialize_to_buffer(avm_cmp_a_hi, Transcript::proof_data); + serialize_to_buffer(avm_cmp_b_lo, Transcript::proof_data); + serialize_to_buffer(avm_cmp_b_hi, Transcript::proof_data); + serialize_to_buffer(avm_cmp_borrow, Transcript::proof_data); + serialize_to_buffer(avm_cmp_p_lo, Transcript::proof_data); + serialize_to_buffer(avm_cmp_p_hi, Transcript::proof_data); + serialize_to_buffer(avm_cmp_p_sub_a_lo, Transcript::proof_data); + serialize_to_buffer(avm_cmp_p_sub_a_hi, Transcript::proof_data); + serialize_to_buffer(avm_cmp_p_a_borrow, Transcript::proof_data); + serialize_to_buffer(avm_cmp_p_sub_b_lo, Transcript::proof_data); + serialize_to_buffer(avm_cmp_p_sub_b_hi, Transcript::proof_data); + serialize_to_buffer(avm_cmp_p_b_borrow, Transcript::proof_data); + serialize_to_buffer(avm_cmp_res_lo, Transcript::proof_data); + serialize_to_buffer(avm_cmp_res_hi, Transcript::proof_data); + serialize_to_buffer(avm_cmp_lt_query, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_rng_8, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_rng_16, Transcript::proof_data); + serialize_to_buffer(avm_main_pc, Transcript::proof_data); + serialize_to_buffer(avm_main_internal_return_ptr, 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_halt, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_mov, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_op_add, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_op_sub, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_op_mul, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_op_div, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_op_not, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_op_eq, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_op_and, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_op_or, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_op_xor, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_op_lt, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_op_lte, Transcript::proof_data); serialize_to_buffer(avm_main_alu_sel, Transcript::proof_data); - serialize_to_buffer(avm_main_bin_op_id, Transcript::proof_data); serialize_to_buffer(avm_main_bin_sel, Transcript::proof_data); + serialize_to_buffer(avm_main_cmp_sel, Transcript::proof_data); + serialize_to_buffer(avm_main_r_in_tag, Transcript::proof_data); + serialize_to_buffer(avm_main_w_in_tag, Transcript::proof_data); + serialize_to_buffer(avm_main_op_err, Transcript::proof_data); + serialize_to_buffer(avm_main_tag_err, Transcript::proof_data); + serialize_to_buffer(avm_main_inv, Transcript::proof_data); 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_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_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_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_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_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_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_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_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_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); - serialize_to_buffer(avm_main_sel_op_eq, Transcript::proof_data); - serialize_to_buffer(avm_main_sel_op_mul, Transcript::proof_data); - serialize_to_buffer(avm_main_sel_op_not, Transcript::proof_data); - serialize_to_buffer(avm_main_sel_op_or, Transcript::proof_data); - serialize_to_buffer(avm_main_sel_op_sub, Transcript::proof_data); - serialize_to_buffer(avm_main_sel_op_xor, Transcript::proof_data); - serialize_to_buffer(avm_main_sel_rng_16, Transcript::proof_data); - serialize_to_buffer(avm_main_sel_rng_8, Transcript::proof_data); - serialize_to_buffer(avm_main_tag_err, Transcript::proof_data); - serialize_to_buffer(avm_main_w_in_tag, Transcript::proof_data); - serialize_to_buffer(avm_mem_addr, Transcript::proof_data); - serialize_to_buffer(avm_mem_clk, Transcript::proof_data); - 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_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_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_sub_clk, Transcript::proof_data); - serialize_to_buffer(avm_mem_tag, Transcript::proof_data); - serialize_to_buffer(avm_mem_tag_err, Transcript::proof_data); - serialize_to_buffer(avm_mem_val, Transcript::proof_data); - serialize_to_buffer(avm_mem_w_in_tag, Transcript::proof_data); + serialize_to_buffer(avm_main_last, Transcript::proof_data); + serialize_to_buffer(avm_main_bin_op_id, Transcript::proof_data); serialize_to_buffer(perm_main_alu, Transcript::proof_data); serialize_to_buffer(perm_main_bin, Transcript::proof_data); + serialize_to_buffer(perm_main_cmp, Transcript::proof_data); 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); diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp index 75b85125615d..01dbe920a926 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp @@ -51,27 +51,70 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) } // Get commitments to VM wires - commitments.avm_alu_alu_sel = - transcript->template receive_from_prover(commitment_labels.avm_alu_alu_sel); - commitments.avm_alu_cf = transcript->template receive_from_prover(commitment_labels.avm_alu_cf); + commitments.avm_mem_clk = transcript->template receive_from_prover(commitment_labels.avm_mem_clk); + commitments.avm_mem_sub_clk = + transcript->template receive_from_prover(commitment_labels.avm_mem_sub_clk); + commitments.avm_mem_addr = transcript->template receive_from_prover(commitment_labels.avm_mem_addr); + commitments.avm_mem_tag = transcript->template receive_from_prover(commitment_labels.avm_mem_tag); + commitments.avm_mem_val = transcript->template receive_from_prover(commitment_labels.avm_mem_val); + commitments.avm_mem_lastAccess = + transcript->template receive_from_prover(commitment_labels.avm_mem_lastAccess); + commitments.avm_mem_last = transcript->template receive_from_prover(commitment_labels.avm_mem_last); + commitments.avm_mem_rw = transcript->template receive_from_prover(commitment_labels.avm_mem_rw); + commitments.avm_mem_r_in_tag = + transcript->template receive_from_prover(commitment_labels.avm_mem_r_in_tag); + commitments.avm_mem_w_in_tag = + transcript->template receive_from_prover(commitment_labels.avm_mem_w_in_tag); + 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_ind_op_a = + transcript->template receive_from_prover(commitment_labels.avm_mem_ind_op_a); + commitments.avm_mem_ind_op_b = + 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_sel_mov = + transcript->template receive_from_prover(commitment_labels.avm_mem_sel_mov); + commitments.avm_mem_tag_err = + transcript->template receive_from_prover(commitment_labels.avm_mem_tag_err); + commitments.avm_mem_one_min_inv = + transcript->template receive_from_prover(commitment_labels.avm_mem_one_min_inv); commitments.avm_alu_clk = transcript->template receive_from_prover(commitment_labels.avm_alu_clk); - commitments.avm_alu_ff_tag = transcript->template receive_from_prover(commitment_labels.avm_alu_ff_tag); commitments.avm_alu_ia = transcript->template receive_from_prover(commitment_labels.avm_alu_ia); commitments.avm_alu_ib = transcript->template receive_from_prover(commitment_labels.avm_alu_ib); commitments.avm_alu_ic = transcript->template receive_from_prover(commitment_labels.avm_alu_ic); - commitments.avm_alu_in_tag = transcript->template receive_from_prover(commitment_labels.avm_alu_in_tag); commitments.avm_alu_op_add = transcript->template receive_from_prover(commitment_labels.avm_alu_op_add); - commitments.avm_alu_op_div = transcript->template receive_from_prover(commitment_labels.avm_alu_op_div); - commitments.avm_alu_op_eq = transcript->template receive_from_prover(commitment_labels.avm_alu_op_eq); - commitments.avm_alu_op_eq_diff_inv = - transcript->template receive_from_prover(commitment_labels.avm_alu_op_eq_diff_inv); + commitments.avm_alu_op_sub = transcript->template receive_from_prover(commitment_labels.avm_alu_op_sub); commitments.avm_alu_op_mul = transcript->template receive_from_prover(commitment_labels.avm_alu_op_mul); + commitments.avm_alu_op_div = transcript->template receive_from_prover(commitment_labels.avm_alu_op_div); commitments.avm_alu_op_not = transcript->template receive_from_prover(commitment_labels.avm_alu_op_not); - commitments.avm_alu_op_sub = transcript->template receive_from_prover(commitment_labels.avm_alu_op_sub); + commitments.avm_alu_op_eq = transcript->template receive_from_prover(commitment_labels.avm_alu_op_eq); + commitments.avm_alu_alu_sel = + transcript->template receive_from_prover(commitment_labels.avm_alu_alu_sel); + commitments.avm_alu_in_tag = transcript->template receive_from_prover(commitment_labels.avm_alu_in_tag); + commitments.avm_alu_ff_tag = transcript->template receive_from_prover(commitment_labels.avm_alu_ff_tag); + commitments.avm_alu_u8_tag = transcript->template receive_from_prover(commitment_labels.avm_alu_u8_tag); + commitments.avm_alu_u16_tag = + transcript->template receive_from_prover(commitment_labels.avm_alu_u16_tag); + commitments.avm_alu_u32_tag = + transcript->template receive_from_prover(commitment_labels.avm_alu_u32_tag); + commitments.avm_alu_u64_tag = + transcript->template receive_from_prover(commitment_labels.avm_alu_u64_tag); commitments.avm_alu_u128_tag = transcript->template receive_from_prover(commitment_labels.avm_alu_u128_tag); + commitments.avm_alu_u8_r0 = transcript->template receive_from_prover(commitment_labels.avm_alu_u8_r0); + commitments.avm_alu_u8_r1 = transcript->template receive_from_prover(commitment_labels.avm_alu_u8_r1); commitments.avm_alu_u16_r0 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r0); commitments.avm_alu_u16_r1 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r1); + commitments.avm_alu_u16_r2 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r2); + commitments.avm_alu_u16_r3 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r3); + commitments.avm_alu_u16_r4 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r4); + commitments.avm_alu_u16_r5 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r5); + commitments.avm_alu_u16_r6 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r6); + commitments.avm_alu_u16_r7 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r7); + commitments.avm_alu_u16_r8 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r8); + commitments.avm_alu_u16_r9 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r9); commitments.avm_alu_u16_r10 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r10); commitments.avm_alu_u16_r11 = @@ -82,72 +125,152 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r13); commitments.avm_alu_u16_r14 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r14); - commitments.avm_alu_u16_r2 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r2); - commitments.avm_alu_u16_r3 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r3); - commitments.avm_alu_u16_r4 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r4); - commitments.avm_alu_u16_r5 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r5); - commitments.avm_alu_u16_r6 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r6); - commitments.avm_alu_u16_r7 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r7); - commitments.avm_alu_u16_r8 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r8); - commitments.avm_alu_u16_r9 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r9); - commitments.avm_alu_u16_tag = - transcript->template receive_from_prover(commitment_labels.avm_alu_u16_tag); - commitments.avm_alu_u32_tag = - transcript->template receive_from_prover(commitment_labels.avm_alu_u32_tag); commitments.avm_alu_u64_r0 = transcript->template receive_from_prover(commitment_labels.avm_alu_u64_r0); - commitments.avm_alu_u64_tag = - transcript->template receive_from_prover(commitment_labels.avm_alu_u64_tag); - commitments.avm_alu_u8_r0 = transcript->template receive_from_prover(commitment_labels.avm_alu_u8_r0); - commitments.avm_alu_u8_r1 = transcript->template receive_from_prover(commitment_labels.avm_alu_u8_r1); - commitments.avm_alu_u8_tag = transcript->template receive_from_prover(commitment_labels.avm_alu_u8_tag); + commitments.avm_alu_cf = transcript->template receive_from_prover(commitment_labels.avm_alu_cf); + commitments.avm_alu_op_eq_diff_inv = + transcript->template receive_from_prover(commitment_labels.avm_alu_op_eq_diff_inv); + commitments.avm_byte_lookup_table_op_id = + transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_table_op_id); + commitments.avm_byte_lookup_table_input_a = + transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_table_input_a); + commitments.avm_byte_lookup_table_input_b = + transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_table_input_b); + commitments.avm_byte_lookup_table_output = + transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_table_output); + commitments.avm_byte_lookup_bin_sel = + transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_bin_sel); + commitments.avm_byte_lookup_table_in_tags = + transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_table_in_tags); + commitments.avm_byte_lookup_table_byte_lengths = + transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_table_byte_lengths); + commitments.avm_binary_clk = transcript->template receive_from_prover(commitment_labels.avm_binary_clk); + commitments.avm_binary_bin_sel = + transcript->template receive_from_prover(commitment_labels.avm_binary_bin_sel); commitments.avm_binary_acc_ia = transcript->template receive_from_prover(commitment_labels.avm_binary_acc_ia); commitments.avm_binary_acc_ib = transcript->template receive_from_prover(commitment_labels.avm_binary_acc_ib); commitments.avm_binary_acc_ic = transcript->template receive_from_prover(commitment_labels.avm_binary_acc_ic); - commitments.avm_binary_bin_sel = - transcript->template receive_from_prover(commitment_labels.avm_binary_bin_sel); - commitments.avm_binary_clk = transcript->template receive_from_prover(commitment_labels.avm_binary_clk); + commitments.avm_binary_in_tag = + transcript->template receive_from_prover(commitment_labels.avm_binary_in_tag); + commitments.avm_binary_op_id = + transcript->template receive_from_prover(commitment_labels.avm_binary_op_id); commitments.avm_binary_ia_bytes = transcript->template receive_from_prover(commitment_labels.avm_binary_ia_bytes); commitments.avm_binary_ib_bytes = transcript->template receive_from_prover(commitment_labels.avm_binary_ib_bytes); commitments.avm_binary_ic_bytes = transcript->template receive_from_prover(commitment_labels.avm_binary_ic_bytes); - commitments.avm_binary_in_tag = - transcript->template receive_from_prover(commitment_labels.avm_binary_in_tag); + commitments.avm_binary_start = + transcript->template receive_from_prover(commitment_labels.avm_binary_start); commitments.avm_binary_mem_tag_ctr = transcript->template receive_from_prover(commitment_labels.avm_binary_mem_tag_ctr); commitments.avm_binary_mem_tag_ctr_inv = transcript->template receive_from_prover(commitment_labels.avm_binary_mem_tag_ctr_inv); - commitments.avm_binary_op_id = - transcript->template receive_from_prover(commitment_labels.avm_binary_op_id); - commitments.avm_binary_start = - transcript->template receive_from_prover(commitment_labels.avm_binary_start); - commitments.avm_byte_lookup_bin_sel = - transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_bin_sel); - commitments.avm_byte_lookup_table_byte_lengths = - transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_table_byte_lengths); - commitments.avm_byte_lookup_table_in_tags = - transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_table_in_tags); - commitments.avm_byte_lookup_table_input_a = - transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_table_input_a); - commitments.avm_byte_lookup_table_input_b = - transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_table_input_b); - commitments.avm_byte_lookup_table_op_id = - transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_table_op_id); - commitments.avm_byte_lookup_table_output = - transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_table_output); + commitments.avm_cmp_cmp_clk = + transcript->template receive_from_prover(commitment_labels.avm_cmp_cmp_clk); + commitments.avm_cmp_ia = transcript->template receive_from_prover(commitment_labels.avm_cmp_ia); + commitments.avm_cmp_ib = transcript->template receive_from_prover(commitment_labels.avm_cmp_ib); + commitments.avm_cmp_ic = transcript->template receive_from_prover(commitment_labels.avm_cmp_ic); + commitments.avm_cmp_lt_sel = transcript->template receive_from_prover(commitment_labels.avm_cmp_lt_sel); + commitments.avm_cmp_lte_sel = + transcript->template receive_from_prover(commitment_labels.avm_cmp_lte_sel); + commitments.avm_cmp_cmp_sel = + transcript->template receive_from_prover(commitment_labels.avm_cmp_cmp_sel); + commitments.avm_cmp_input_ia = + transcript->template receive_from_prover(commitment_labels.avm_cmp_input_ia); + commitments.avm_cmp_input_ib = + transcript->template receive_from_prover(commitment_labels.avm_cmp_input_ib); + commitments.avm_cmp_a_lo = transcript->template receive_from_prover(commitment_labels.avm_cmp_a_lo); + commitments.avm_cmp_a_hi = transcript->template receive_from_prover(commitment_labels.avm_cmp_a_hi); + commitments.avm_cmp_b_lo = transcript->template receive_from_prover(commitment_labels.avm_cmp_b_lo); + commitments.avm_cmp_b_hi = transcript->template receive_from_prover(commitment_labels.avm_cmp_b_hi); + commitments.avm_cmp_borrow = transcript->template receive_from_prover(commitment_labels.avm_cmp_borrow); + commitments.avm_cmp_p_lo = transcript->template receive_from_prover(commitment_labels.avm_cmp_p_lo); + commitments.avm_cmp_p_hi = transcript->template receive_from_prover(commitment_labels.avm_cmp_p_hi); + commitments.avm_cmp_p_sub_a_lo = + transcript->template receive_from_prover(commitment_labels.avm_cmp_p_sub_a_lo); + commitments.avm_cmp_p_sub_a_hi = + transcript->template receive_from_prover(commitment_labels.avm_cmp_p_sub_a_hi); + commitments.avm_cmp_p_a_borrow = + transcript->template receive_from_prover(commitment_labels.avm_cmp_p_a_borrow); + commitments.avm_cmp_p_sub_b_lo = + transcript->template receive_from_prover(commitment_labels.avm_cmp_p_sub_b_lo); + commitments.avm_cmp_p_sub_b_hi = + transcript->template receive_from_prover(commitment_labels.avm_cmp_p_sub_b_hi); + commitments.avm_cmp_p_b_borrow = + transcript->template receive_from_prover(commitment_labels.avm_cmp_p_b_borrow); + commitments.avm_cmp_res_lo = transcript->template receive_from_prover(commitment_labels.avm_cmp_res_lo); + commitments.avm_cmp_res_hi = transcript->template receive_from_prover(commitment_labels.avm_cmp_res_hi); + commitments.avm_cmp_lt_query = + transcript->template receive_from_prover(commitment_labels.avm_cmp_lt_query); + commitments.avm_main_sel_rng_8 = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_rng_8); + commitments.avm_main_sel_rng_16 = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_rng_16); + commitments.avm_main_pc = transcript->template receive_from_prover(commitment_labels.avm_main_pc); + commitments.avm_main_internal_return_ptr = + transcript->template receive_from_prover(commitment_labels.avm_main_internal_return_ptr); + commitments.avm_main_sel_internal_call = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_internal_call); + commitments.avm_main_sel_internal_return = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_internal_return); + commitments.avm_main_sel_jump = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_jump); + commitments.avm_main_sel_halt = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_halt); + commitments.avm_main_sel_mov = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_mov); + commitments.avm_main_sel_op_add = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_add); + commitments.avm_main_sel_op_sub = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_sub); + commitments.avm_main_sel_op_mul = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_mul); + commitments.avm_main_sel_op_div = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_div); + commitments.avm_main_sel_op_not = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_not); + commitments.avm_main_sel_op_eq = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_eq); + commitments.avm_main_sel_op_and = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_and); + commitments.avm_main_sel_op_or = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_or); + commitments.avm_main_sel_op_xor = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_xor); + commitments.avm_main_sel_op_lt = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_lt); + commitments.avm_main_sel_op_lte = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_lte); commitments.avm_main_alu_sel = transcript->template receive_from_prover(commitment_labels.avm_main_alu_sel); - commitments.avm_main_bin_op_id = - transcript->template receive_from_prover(commitment_labels.avm_main_bin_op_id); commitments.avm_main_bin_sel = transcript->template receive_from_prover(commitment_labels.avm_main_bin_sel); + commitments.avm_main_cmp_sel = + transcript->template receive_from_prover(commitment_labels.avm_main_cmp_sel); + commitments.avm_main_r_in_tag = + transcript->template receive_from_prover(commitment_labels.avm_main_r_in_tag); + commitments.avm_main_w_in_tag = + transcript->template receive_from_prover(commitment_labels.avm_main_w_in_tag); + commitments.avm_main_op_err = + transcript->template receive_from_prover(commitment_labels.avm_main_op_err); + commitments.avm_main_tag_err = + transcript->template receive_from_prover(commitment_labels.avm_main_tag_err); + commitments.avm_main_inv = transcript->template receive_from_prover(commitment_labels.avm_main_inv); 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_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_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_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); @@ -157,16 +280,13 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) 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_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); - commitments.avm_main_last = transcript->template receive_from_prover(commitment_labels.avm_main_last); commitments.avm_main_mem_idx_a = transcript->template receive_from_prover(commitment_labels.avm_main_mem_idx_a); commitments.avm_main_mem_idx_b = 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); +<<<<<<< HEAD commitments.avm_main_mem_op_a = transcript->template receive_from_prover(commitment_labels.avm_main_mem_op_a); commitments.avm_main_mem_op_b = @@ -263,8 +383,14 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) relation_parameters.gamma = gamm; // Permutations +======= + commitments.avm_main_last = transcript->template receive_from_prover(commitment_labels.avm_main_last); + commitments.avm_main_bin_op_id = + transcript->template receive_from_prover(commitment_labels.avm_main_bin_op_id); +>>>>>>> 7a982d52c (feat: init avm cmp) commitments.perm_main_alu = transcript->template receive_from_prover(commitment_labels.perm_main_alu); commitments.perm_main_bin = transcript->template receive_from_prover(commitment_labels.perm_main_bin); + commitments.perm_main_cmp = transcript->template receive_from_prover(commitment_labels.perm_main_cmp); commitments.perm_main_mem_a = transcript->template receive_from_prover(commitment_labels.perm_main_mem_a); commitments.perm_main_mem_b = From d2da4d03245ec35b0a640b0be45f19b7b9d1cca7 Mon Sep 17 00:00:00 2001 From: IlyasRidhuan Date: Wed, 3 Apr 2024 12:59:25 +0000 Subject: [PATCH 02/18] feat: range_chk for cmp --- barretenberg/cpp/pil/avm/avm_alu.pil | 139 +- barretenberg/cpp/pil/avm/avm_cmp.pil | 120 - barretenberg/cpp/pil/avm/avm_main.pil | 9 +- .../relations/generated/avm/avm_alu.hpp | 409 +++- .../relations/generated/avm/avm_binary.hpp | 34 +- .../relations/generated/avm/avm_cmp.hpp | 32 +- .../relations/generated/avm/avm_main.hpp | 112 +- .../relations/generated/avm/avm_mem.hpp | 52 +- .../relations/generated/avm/declare_views.hpp | 243 +- .../relations/generated/avm/perm_main_bin.hpp | 6 +- .../relations/generated/avm/perm_main_cmp.hpp | 24 +- .../vm/avm_trace/avm_alu_trace.cpp | 41 + .../vm/avm_trace/avm_alu_trace.hpp | 25 + .../vm/generated/avm_circuit_builder.hpp | 499 ++-- .../barretenberg/vm/generated/avm_flavor.hpp | 2058 ++++++++--------- .../vm/generated/avm_verifier.cpp | 274 +-- 16 files changed, 2199 insertions(+), 1878 deletions(-) delete mode 100644 barretenberg/cpp/pil/avm/avm_cmp.pil diff --git a/barretenberg/cpp/pil/avm/avm_alu.pil b/barretenberg/cpp/pil/avm/avm_alu.pil index 974b4a03871a..782e3a5663f9 100644 --- a/barretenberg/cpp/pil/avm/avm_alu.pil +++ b/barretenberg/cpp/pil/avm/avm_alu.pil @@ -264,4 +264,141 @@ namespace avm_alu(256); #[ALU_OP_EQ] op_eq * (DIFF * (ic * (1 - op_eq_diff_inv) + op_eq_diff_inv) - 1 + ic) = 0; - + // ========= LT/LTE Operation Constraints =============================== + + pol commit lt_sel; + pol commit lte_sel; + // Both are restricted to booleans + lt_sel * (1 - lt_sel) = 0; + lte_sel * (1 - lte_sel) = 0; + + // Used for perm check to main, designates if a comparison operation is being used. + pol commit cmp_sel; + cmp_sel = lt_sel + lte_sel; + // NAND check for selectors + lt_sel * lte_sel = 0; + + // ic is restricted to be 1 or 0 if we are performing a comparison + cmp_sel * (ic * (1 - ic)) = 0; + + + + // There are two routines that we utilise as part of this LT/LTE check + // (1) Decomposition into two 128-bit limbs, lo and hi respectively and a borrow (1 or 0); + // (2) 128 bit range checks when checking an arithmetic operations has not overflowed the field. + + // ========= COMPARISON OPERATION - EXPLANATIONS ================================================= + // To simplify the comparison circuit, we implement a GreaterThan(GT) circuit. This is ideal since + // if we need a LT operation, we just swap the inputs and if we need the LTE operation, we just NOT the query + // Given the inputs x, y and q where x & y are inputs and q is the boolean result to the query (x > y). Then there are two scenarios + // (x > y) -> x - y - 1 = result, where 0 <= result < p. In our case result should not overflow the field. + // OR + // !(x > y) -> !(x - y - 1) = (p - 1) - (x - y -1) = y - x = result, where the same applies as above. + // These conditions can be combined with the query, q (that x > y) as follows: + // (x - y - 1) * q + (y - x) (1 - q) = result + pol commit input_ia; + pol commit input_ib; + pol commit borrow; + + //If LT, then swap ia and ib else keep the same + input_ia = lt_sel * ib + lte_sel * ia; + input_ib = lt_sel * ia + lte_sel * ib; + + pol commit a_lo; + pol commit a_hi; + // Check input_ia is well formed from its lo and hi limbs + input_ia = (a_lo + 2 ** 128 * a_hi) * cmp_sel; + + pol commit b_lo; + pol commit b_hi; + // Check input_ib is well formed from its lo and hi limbs + input_ib = (b_lo + 2 ** 128 * b_hi) * cmp_sel; + + pol commit p_sub_a_lo; // p_lo - a_lo + pol commit p_sub_a_hi; // p_hi - a_hi + pol commit p_a_borrow; + + // Check that (p > a) by checking (p_lo > a_lo && p_hi >= ahi) || (p_lo <= a_lo && p_hi > a_hi) + // First condition is if borrow = 0, second condition is if borrow = 1; + // (p - 1) lower 128 bits = 53438638232309528389504892708671455232 + // (p - 1) upper 128 bits = 64323764613183177041862057485226039389 + p_sub_a_lo = (53438638232309528389504892708671455232 - a_lo + p_a_borrow * 2 ** 128) * cmp_sel; + p_sub_a_hi = (64323764613183177041862057485226039389 - a_hi - p_a_borrow) * cmp_sel; + + pol commit p_sub_b_lo; + pol commit p_sub_b_hi; + pol commit p_b_borrow; + + // Check that (p > b) by checking (p_lo > b_lo && p_hi >= bhi) || (p_lo <= b_lo && p_hi > b_hi) + // First condition is if borrow = 0, second condition is if borrow = 1; + p_sub_b_lo = (53438638232309528389504892708671455232 - b_lo + p_b_borrow * 2 ** 128) * cmp_sel; + p_sub_b_hi = (64323764613183177041862057485226039389 - b_hi - p_b_borrow) * cmp_sel; + + + // Calculate the combined relation: (a - b - 1) * q + (b -a ) * (1-q) + // Check that (a > b) by checking (a_lo > b_lo && a_hi >= bhi) || (alo <= b_lo && a_hi > b_hi) + // First condition is if borrow = 0, second condition is if borrow = 1; + pol A_SUB_B_LO = a_lo - b_lo - 1 + borrow * 2 ** 128; + pol A_SUB_B_HI = a_hi - b_hi - borrow; + + // Check that (a <= b) by checking (b_lo >= a_lo && b_hi >= a_hi) || (b_lo > a_lo && b_hi >= a_hi) + // First condition is if borrow = 0, second condition is if borrow = 1; + pol B_SUB_A_LO = b_lo - a_lo + borrow * 2 ** 128; + pol B_SUB_A_HI = b_hi - a_hi - borrow; + + pol commit res_lo; + pol commit res_hi; + + // If this is a LT operation, we already swapped the inputs so the result of ic is still correct + // If this is a LTE operation, we invert the value of ic. + pol IS_GT = lt_sel * ic + (1 - ic) * lte_sel; + + res_lo = (A_SUB_B_LO * IS_GT + B_SUB_A_LO * (1 - IS_GT)) * cmp_sel; + res_hi = (A_SUB_B_HI * IS_GT + B_SUB_A_HI * (1 - IS_GT)) * cmp_sel; + + + // ========= RANGE OPERATIONS =============================== + // Each call to LT/LTE requires 5x 256-bit range checks. We keep track of how many are left here. + pol commit rng_chk_remaining; + + // TODO: combine into 1 equation, left separate for debugging + // the number of range checks must decrement by 1 until it is equal to 0; + (rng_chk_remaining' - rng_chk_remaining + 1) * rng_chk_remaining = 0; + // if this row is a comparison operation, the next range_check_remaining value is set to 4 + // it is not set to 5 since we do 1 as part of the comparison. + (rng_chk_remaining' - 4) * cmp_sel = 0; + + pol commit rng_chk_sel; // A boolean representing if we have range checks remaining + rng_chk_sel * (1 - rng_chk_sel); + rng_chk_sel * cmp_sel = 0; // If we have remaining range checks, we cannot have cmp_sel set + + // Needed for equality checking // reuse selector op_eq_diff_inv + // pol commit rng_chk_inv; + + // rng_chk_sel = 1 when rng_chk_remaining != 0 and rng_chk_sel = 0 when rng_chk_remaining = 0; + rng_chk_remaining * ((1 - rng_chk_sel) * (1 - op_eq_diff_inv) + op_eq_diff_inv) - rng_chk_sel = 0; + + // We perform a range check if we have some range checks remaining or we are performing a comparison op + pol RNG_CHK_OP = (rng_chk_sel + cmp_sel); + + // Perform 128-bit range check on lo part + a_lo = (u8_r0 + u8_r1 * 2**8 + u16_r0 * 2**16 + + u16_r1 * 2**32 + u16_r2 * 2**48 + + u16_r3 * 2**64 + u16_r4 * 2**80 + + u16_r5 * 2**96 + u16_r6 * 2**112) * (RNG_CHK_OP); + + // Perform 128-bit range check on hi part + a_hi = (u16_r7 + u16_r8 * 2**16 + + u16_r9 * 2**32 + u16_r10 * 2**48 + + u16_r11 * 2**64 + u16_r12 * 2**80 + + u16_r13 * 2**96 + u16_r14 * 2**112) * (RNG_CHK_OP); + + // Shift all elements "across" by 2 columns + a_lo' = b_lo * rng_chk_sel'; + a_hi' = b_hi * rng_chk_sel'; + b_lo' = p_sub_a_lo * rng_chk_sel'; + b_hi' = p_sub_a_hi * rng_chk_sel'; + p_sub_a_lo' = p_sub_b_lo * rng_chk_sel'; + p_sub_a_hi' = p_sub_b_hi * rng_chk_sel'; + p_sub_b_lo' = res_lo * rng_chk_sel'; + p_sub_b_hi' = res_hi * rng_chk_sel'; diff --git a/barretenberg/cpp/pil/avm/avm_cmp.pil b/barretenberg/cpp/pil/avm/avm_cmp.pil deleted file mode 100644 index 219f99da0c42..000000000000 --- a/barretenberg/cpp/pil/avm/avm_cmp.pil +++ /dev/null @@ -1,120 +0,0 @@ - -namespace avm_cmp(256); - - pol commit cmp_clk; - - // Copied from main trace - pol commit ia; - pol commit ib; - pol commit ic; //should be boolean - ic * (1 - ic) = 0; - - // Selectors for LT or LTE - pol commit lt_sel; - pol commit lte_sel; - pol commit cmp_sel; // Used for perm check to main - cmp_sel = lt_sel + lte_sel; - - // Both are restricted to booleans - lt_sel * (1 - lt_sel) = 0; - lte_sel * (1 - lte_sel) = 0; - - // NAND check for selectors - lt_sel * lte_sel = 0; - - - // There are two routines that we utilise as part of this LT/LTE check - // (1) Decomposition into two 128-bit limbs, lo and hi respectively and a borrow (1 or 0); - // (2) 128 bit range checks when checking an arithmetic operations has not overflowed the field. - - // ========= COMPARISON OPERATION - EXPLANATIONS ================================================= - // To simplify the comparison circuit, we implement a GreaterThan(GT) circuit. This is ideal since - // if we need a LT operation, we just swap the inputs and if we need the LTE operation, we just NOT the query - // Given the inputs x, y and q where x & y are inputs and q is the boolean result to the query (x > y). Then there are two scenarios - // (x > y) -> x - y - 1 = result, where 0 <= result < p. In our case result should not overflow the field. - // OR - // !(x > y) -> !(x - y - 1) = (p - 1) - (x - y -1) = y - x = result, where the same applies as above. - // These conditions can be combined with the query, q (that x > y) as follows: - // (x - y - 1) * q + (y - x) (1 - q) = result - - pol commit input_ia; - pol commit input_ib; - - //If LT, then swap ia and ib else keep the same - input_ia = lt_sel * ib + lte_sel * ia; - input_ib = lt_sel * ia + lte_sel * ib; - - pol commit a_lo; - pol commit a_hi; - pol commit b_lo; - pol commit b_hi; - pol commit borrow; - - // Lo 128-bits of the field modulus: 53438638232309528389504892708671455233 - pol commit p_lo; - // Hi 128-bits of the field modulus: 64323764613183177041862057485226039389 - pol commit p_hi; - - // Check inputs are well formed from lo and hi parts - input_ia = a_lo + 2 ** 128 * a_hi; - input_ib = b_lo + 2 ** 128 * b_hi; - - // TODO: Check that all inputs are valid ranges over the integers - // 128-bit Range check a_lo - // 128-bit Range check a_hi - // 128-bit Range check b_lo - // 128-bit Range check b_hi - - // Used to check 128-bit decomposition of input_ia does not overflow the field - pol commit p_sub_a_lo; // p_lo - a_lo - pol commit p_sub_a_hi; // p_hi - a_hi - pol commit p_a_borrow; - - // Check that (p > a) by checking (p_lo > a_lo && p_hi >= ahi) || (p_lo <= a_lo && p_hi > a_hi) - // First condition is if borrow = 0, second condition is if borrow = 1; - p_sub_a_lo = p_lo - a_lo + p_a_borrow * 2 ** 128; - p_sub_a_hi = p_hi - a_hi - p_a_borrow; - - // Used to check 128-bit decomposition of inpu_ib does not overflow the field - pol commit p_sub_b_lo; - pol commit p_sub_b_hi; - pol commit p_b_borrow; - - p_sub_b_lo = p_lo - b_lo + p_b_borrow * 2 ** 128; - p_sub_b_hi = p_hi - b_hi - p_b_borrow; - - // TODO More range checks - // 128-bit Range check p_sub_a_lo - // 128-bit Range check p_lo_sub_a_hi - // 128-bit Range check p_sub_b_lo - // 2**128 == 2^128 - // 128-bit Range check p_lo_sub_b_hi - - - // Calculate the combined relation: (a - b - 1) * q + (b -a ) * (1-q) - - // Check that (a > b) by checking (a_lo > b_lo && a_hi >= bhi) || (alo <= b_lo && a_hi > b_hi) - // First condition is if borrow = 0, second condition is if borrow = 1; - pol A_SUB_B_LO = a_lo - b_lo - 1 + borrow * 2 ** 128; - pol A_SUB_B_HI = a_hi - b_hi - borrow; - - // Check that (a <= b) by checking (b_lo >= a_lo && b_hi >= a_hi) || (b_lo > a_lo && b_hi >= a_hi) - // First condition is if borrow = 0, second condition is if borrow = 1; - pol B_SUB_A_LO = b_lo - a_lo + borrow * 2 ** 128; - pol B_SUB_A_HI = b_hi - a_hi - borrow; - - pol commit res_lo; - pol commit res_hi; - pol commit lt_query; - - // If LT_SEL, we would have already swapped the input so the boolean in ic is still correct - // If LTE_SEL, we did not swap the input and we want to NOT the value of ic. - lt_query = lt_sel * ic + (1 - ic) * lte_sel; - - res_lo = A_SUB_B_LO * lt_query + B_SUB_A_LO * (1 - lt_query); - res_hi = A_SUB_B_HI * lt_query + B_SUB_A_HI * (1 - lt_query); - - // 128-bit Range check res_lo - // 128-bit Range check res_hi - - diff --git a/barretenberg/cpp/pil/avm/avm_main.pil b/barretenberg/cpp/pil/avm/avm_main.pil index 9d704ab6ac6a..e0c6a7a18c28 100644 --- a/barretenberg/cpp/pil/avm/avm_main.pil +++ b/barretenberg/cpp/pil/avm/avm_main.pil @@ -2,7 +2,6 @@ include "avm_mem.pil"; include "avm_alu.pil"; include "avm_binary.pil"; -include "avm_cmp.pil"; namespace avm_main(256); @@ -291,14 +290,14 @@ namespace avm_main(256); cmp_sel = sel_op_lt + sel_op_lte; #[PERM_MAIN_BIN] - bin_sel {ia, ib, ic, bin_op_id, r_in_tag} + bin_sel {clk, ia, ib, ic, bin_op_id, r_in_tag} is - avm_binary.start {avm_binary.acc_ia, avm_binary.acc_ib, avm_binary.acc_ic, avm_binary.op_id, avm_binary.in_tag}; + 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_CMP] - cmp_sel {ia, ib, ic} + cmp_sel {clk, ia, ib, ic} is - avm_cmp.cmp_sel {avm_cmp.ia, avm_cmp.ib, avm_cmp.ic}; + avm_alu.cmp_sel {avm_alu.clk, avm_alu.ia, avm_alu.ib, avm_alu.ic}; #[PERM_MAIN_MEM_A] mem_op_a {clk, mem_idx_a, ia, rwa, r_in_tag, w_in_tag, sel_mov} 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 9ba9c19961a1..0c634c61ef81 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_alu.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_alu.hpp @@ -7,77 +7,114 @@ namespace bb::Avm_vm { template struct Avm_aluRow { + FF avm_alu_a_hi{}; + FF avm_alu_a_hi_shift{}; + FF avm_alu_a_lo{}; + FF avm_alu_a_lo_shift{}; + FF avm_alu_alu_sel{}; + FF avm_alu_b_hi{}; + FF avm_alu_b_hi_shift{}; + FF avm_alu_b_lo{}; + FF avm_alu_b_lo_shift{}; + FF avm_alu_borrow{}; + FF avm_alu_cf{}; + FF avm_alu_cmp_sel{}; + FF avm_alu_ff_tag{}; + FF avm_alu_ia{}; + FF avm_alu_ib{}; + FF avm_alu_ic{}; + FF avm_alu_in_tag{}; + FF avm_alu_input_ia{}; + FF avm_alu_input_ib{}; + FF avm_alu_lt_sel{}; + FF avm_alu_lte_sel{}; + FF avm_alu_op_add{}; + FF avm_alu_op_eq{}; + FF avm_alu_op_eq_diff_inv{}; + FF avm_alu_op_mul{}; + FF avm_alu_op_not{}; + FF avm_alu_op_sub{}; + FF avm_alu_p_a_borrow{}; + FF avm_alu_p_b_borrow{}; + FF avm_alu_p_sub_a_hi{}; + FF avm_alu_p_sub_a_hi_shift{}; + FF avm_alu_p_sub_a_lo{}; + FF avm_alu_p_sub_a_lo_shift{}; + FF avm_alu_p_sub_b_hi{}; + FF avm_alu_p_sub_b_hi_shift{}; + FF avm_alu_p_sub_b_lo{}; + FF avm_alu_p_sub_b_lo_shift{}; + FF avm_alu_res_hi{}; + FF avm_alu_res_lo{}; + FF avm_alu_rng_chk_remaining{}; + FF avm_alu_rng_chk_remaining_shift{}; + FF avm_alu_rng_chk_sel{}; + FF avm_alu_rng_chk_sel_shift{}; + FF avm_alu_u128_tag{}; FF avm_alu_u16_r0{}; FF avm_alu_u16_r0_shift{}; - FF avm_alu_u8_r1{}; - FF avm_alu_u32_tag{}; - FF avm_alu_u16_r7{}; - FF avm_alu_op_add{}; + FF avm_alu_u16_r1{}; + FF avm_alu_u16_r10{}; + FF avm_alu_u16_r11{}; + FF avm_alu_u16_r12{}; + FF avm_alu_u16_r13{}; + FF avm_alu_u16_r14{}; + FF avm_alu_u16_r1_shift{}; + FF avm_alu_u16_r2{}; + FF avm_alu_u16_r2_shift{}; FF avm_alu_u16_r3{}; FF avm_alu_u16_r3_shift{}; + FF avm_alu_u16_r4{}; FF avm_alu_u16_r4_shift{}; - FF avm_alu_u64_r0{}; + FF avm_alu_u16_r5{}; + FF avm_alu_u16_r5_shift{}; + FF avm_alu_u16_r6{}; + FF avm_alu_u16_r6_shift{}; + FF avm_alu_u16_r7{}; FF avm_alu_u16_r7_shift{}; + FF avm_alu_u16_r8{}; + FF avm_alu_u16_r9{}; FF avm_alu_u16_tag{}; - FF avm_alu_cf{}; - FF avm_alu_in_tag{}; - FF avm_alu_u16_r6_shift{}; - FF avm_alu_op_sub{}; - FF avm_alu_ff_tag{}; + FF avm_alu_u32_tag{}; + FF avm_alu_u64_r0{}; FF avm_alu_u64_tag{}; - FF avm_alu_alu_sel{}; - FF avm_alu_op_eq_diff_inv{}; - FF avm_alu_u16_r1{}; - FF avm_alu_u16_r2_shift{}; - FF avm_alu_u16_r5_shift{}; - FF avm_alu_ia{}; - FF avm_alu_op_eq{}; - FF avm_alu_u16_r1_shift{}; FF avm_alu_u8_r0{}; - FF avm_alu_u16_r2{}; - FF avm_alu_u16_r5{}; - FF avm_alu_ic{}; - FF avm_alu_op_mul{}; - FF avm_alu_u16_r6{}; - FF avm_alu_u16_r4{}; + FF avm_alu_u8_r1{}; FF avm_alu_u8_tag{}; - FF avm_alu_op_not{}; - FF avm_alu_u128_tag{}; - FF avm_alu_ib{}; }; inline std::string get_relation_label_avm_alu(int index) { switch (index) { - case 11: - return "ALU_MULTIPLICATION_FF"; - - case 16: - return "ALU_MULTIPLICATION_OUT_U128"; - - case 19: - return "ALU_RES_IS_BOOL"; - case 9: return "ALU_ADD_SUB_1"; case 10: return "ALU_ADD_SUB_2"; + case 11: + return "ALU_MULTIPLICATION_FF"; + case 12: return "ALU_MUL_COMMON_1"; - case 18: - return "ALU_OP_NOT"; - - case 20: - return "ALU_OP_EQ"; - case 13: return "ALU_MUL_COMMON_2"; + case 16: + return "ALU_MULTIPLICATION_OUT_U128"; + case 17: return "ALU_FF_NOT_XOR"; + + case 18: + return "ALU_OP_NOT"; + + case 19: + return "ALU_RES_IS_BOOL"; + + case 20: + return "ALU_OP_EQ"; } return std::to_string(index); } @@ -86,8 +123,9 @@ template class avm_aluImpl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 5, 5, 5, 6, 6, 8, 3, 4, 4, 5, + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 5, 5, 5, 6, 6, 8, 3, 4, 4, 5, 3, 3, 2, 3, 4, + 3, 3, 4, 4, 4, 3, 4, 3, 6, 5, 3, 3, 3, 3, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, }; template @@ -354,6 +392,289 @@ template class avm_aluImpl { tmp *= scaling_factor; std::get<20>(evals) += tmp; } + // Contribution 21 + { + Avm_DECLARE_VIEWS(21); + + auto tmp = (avm_alu_lt_sel * (-avm_alu_lt_sel + FF(1))); + tmp *= scaling_factor; + std::get<21>(evals) += tmp; + } + // Contribution 22 + { + Avm_DECLARE_VIEWS(22); + + auto tmp = (avm_alu_lte_sel * (-avm_alu_lte_sel + FF(1))); + tmp *= scaling_factor; + std::get<22>(evals) += tmp; + } + // Contribution 23 + { + Avm_DECLARE_VIEWS(23); + + auto tmp = (avm_alu_cmp_sel - (avm_alu_lt_sel + avm_alu_lte_sel)); + tmp *= scaling_factor; + std::get<23>(evals) += tmp; + } + // Contribution 24 + { + Avm_DECLARE_VIEWS(24); + + auto tmp = (avm_alu_lt_sel * avm_alu_lte_sel); + tmp *= scaling_factor; + std::get<24>(evals) += tmp; + } + // Contribution 25 + { + Avm_DECLARE_VIEWS(25); + + auto tmp = (avm_alu_cmp_sel * (avm_alu_ic * (-avm_alu_ic + FF(1)))); + tmp *= scaling_factor; + std::get<25>(evals) += tmp; + } + // Contribution 26 + { + Avm_DECLARE_VIEWS(26); + + auto tmp = (avm_alu_input_ia - ((avm_alu_lt_sel * avm_alu_ib) + (avm_alu_lte_sel * avm_alu_ia))); + tmp *= scaling_factor; + std::get<26>(evals) += tmp; + } + // Contribution 27 + { + Avm_DECLARE_VIEWS(27); + + auto tmp = (avm_alu_input_ib - ((avm_alu_lt_sel * avm_alu_ia) + (avm_alu_lte_sel * avm_alu_ib))); + tmp *= scaling_factor; + std::get<27>(evals) += tmp; + } + // Contribution 28 + { + Avm_DECLARE_VIEWS(28); + + auto tmp = + (avm_alu_input_ia - ((avm_alu_a_lo + (avm_alu_a_hi * FF(uint256_t{ 0, 0, 1, 0 }))) * avm_alu_cmp_sel)); + tmp *= scaling_factor; + std::get<28>(evals) += tmp; + } + // Contribution 29 + { + Avm_DECLARE_VIEWS(29); + + auto tmp = + (avm_alu_input_ib - ((avm_alu_b_lo + (avm_alu_b_hi * FF(uint256_t{ 0, 0, 1, 0 }))) * avm_alu_cmp_sel)); + tmp *= scaling_factor; + std::get<29>(evals) += tmp; + } + // Contribution 30 + { + Avm_DECLARE_VIEWS(30); + + auto tmp = (avm_alu_p_sub_a_lo - + (((-avm_alu_a_lo + FF(uint256_t{ 4891460686036598784, 2896914383306846353, 0, 0 })) + + (avm_alu_p_a_borrow * FF(uint256_t{ 0, 0, 1, 0 }))) * + avm_alu_cmp_sel)); + tmp *= scaling_factor; + std::get<30>(evals) += tmp; + } + // Contribution 31 + { + Avm_DECLARE_VIEWS(31); + + auto tmp = (avm_alu_p_sub_a_hi - + (((-avm_alu_a_hi + FF(uint256_t{ 13281191951274694749, 3486998266802970665, 0, 0 })) - + avm_alu_p_a_borrow) * + avm_alu_cmp_sel)); + tmp *= scaling_factor; + std::get<31>(evals) += tmp; + } + // Contribution 32 + { + Avm_DECLARE_VIEWS(32); + + auto tmp = (avm_alu_p_sub_b_lo - + (((-avm_alu_b_lo + FF(uint256_t{ 4891460686036598784, 2896914383306846353, 0, 0 })) + + (avm_alu_p_b_borrow * FF(uint256_t{ 0, 0, 1, 0 }))) * + avm_alu_cmp_sel)); + tmp *= scaling_factor; + std::get<32>(evals) += tmp; + } + // Contribution 33 + { + Avm_DECLARE_VIEWS(33); + + auto tmp = (avm_alu_p_sub_b_hi - + (((-avm_alu_b_hi + FF(uint256_t{ 13281191951274694749, 3486998266802970665, 0, 0 })) - + avm_alu_p_b_borrow) * + avm_alu_cmp_sel)); + tmp *= scaling_factor; + std::get<33>(evals) += tmp; + } + // Contribution 34 + { + Avm_DECLARE_VIEWS(34); + + auto tmp = (avm_alu_res_lo - + ((((((avm_alu_a_lo - avm_alu_b_lo) - FF(1)) + (avm_alu_borrow * FF(uint256_t{ 0, 0, 1, 0 }))) * + ((avm_alu_lt_sel * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_lte_sel))) + + (((avm_alu_b_lo - avm_alu_a_lo) + (avm_alu_borrow * FF(uint256_t{ 0, 0, 1, 0 }))) * + (-((avm_alu_lt_sel * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_lte_sel)) + FF(1)))) * + avm_alu_cmp_sel)); + tmp *= scaling_factor; + std::get<34>(evals) += tmp; + } + // Contribution 35 + { + Avm_DECLARE_VIEWS(35); + + auto tmp = (avm_alu_res_hi - + (((((avm_alu_a_hi - avm_alu_b_hi) - avm_alu_borrow) * + ((avm_alu_lt_sel * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_lte_sel))) + + (((avm_alu_b_hi - avm_alu_a_hi) - avm_alu_borrow) * + (-((avm_alu_lt_sel * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_lte_sel)) + FF(1)))) * + avm_alu_cmp_sel)); + tmp *= scaling_factor; + std::get<35>(evals) += tmp; + } + // Contribution 36 + { + Avm_DECLARE_VIEWS(36); + + auto tmp = + (((avm_alu_rng_chk_remaining_shift - avm_alu_rng_chk_remaining) + FF(1)) * avm_alu_rng_chk_remaining); + tmp *= scaling_factor; + std::get<36>(evals) += tmp; + } + // Contribution 37 + { + Avm_DECLARE_VIEWS(37); + + auto tmp = ((avm_alu_rng_chk_remaining_shift - FF(4)) * avm_alu_cmp_sel); + tmp *= scaling_factor; + std::get<37>(evals) += tmp; + } + // Contribution 38 + { + Avm_DECLARE_VIEWS(38); + + auto tmp = (avm_alu_rng_chk_sel * (-avm_alu_rng_chk_sel + FF(1))); + tmp *= scaling_factor; + std::get<38>(evals) += tmp; + } + // Contribution 39 + { + Avm_DECLARE_VIEWS(39); + + auto tmp = (avm_alu_rng_chk_sel * avm_alu_cmp_sel); + tmp *= scaling_factor; + std::get<39>(evals) += tmp; + } + // Contribution 40 + { + Avm_DECLARE_VIEWS(40); + + auto tmp = + ((avm_alu_rng_chk_remaining * + (((-avm_alu_rng_chk_sel + FF(1)) * (-avm_alu_op_eq_diff_inv + FF(1))) + avm_alu_op_eq_diff_inv)) - + avm_alu_rng_chk_sel); + tmp *= scaling_factor; + std::get<40>(evals) += tmp; + } + // Contribution 41 + { + Avm_DECLARE_VIEWS(41); + + auto tmp = + (avm_alu_a_lo - (((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + + (avm_alu_u16_r1 * FF(4294967296UL))) + + (avm_alu_u16_r2 * FF(281474976710656UL))) + + (avm_alu_u16_r3 * FF(uint256_t{ 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_rng_chk_sel + avm_alu_cmp_sel))); + tmp *= scaling_factor; + std::get<41>(evals) += tmp; + } + // Contribution 42 + { + Avm_DECLARE_VIEWS(42); + + auto tmp = (avm_alu_a_hi - + ((((((((avm_alu_u16_r7 + (avm_alu_u16_r8 * FF(65536))) + (avm_alu_u16_r9 * FF(4294967296UL))) + + (avm_alu_u16_r10 * FF(281474976710656UL))) + + (avm_alu_u16_r11 * FF(uint256_t{ 0, 1, 0, 0 }))) + + (avm_alu_u16_r12 * FF(uint256_t{ 0, 65536, 0, 0 }))) + + (avm_alu_u16_r13 * FF(uint256_t{ 0, 4294967296, 0, 0 }))) + + (avm_alu_u16_r14 * FF(uint256_t{ 0, 281474976710656, 0, 0 }))) * + (avm_alu_rng_chk_sel + avm_alu_cmp_sel))); + tmp *= scaling_factor; + std::get<42>(evals) += tmp; + } + // Contribution 43 + { + Avm_DECLARE_VIEWS(43); + + auto tmp = (avm_alu_a_lo_shift - (avm_alu_b_lo * avm_alu_rng_chk_sel_shift)); + tmp *= scaling_factor; + std::get<43>(evals) += tmp; + } + // Contribution 44 + { + Avm_DECLARE_VIEWS(44); + + auto tmp = (avm_alu_a_hi_shift - (avm_alu_b_hi * avm_alu_rng_chk_sel_shift)); + tmp *= scaling_factor; + std::get<44>(evals) += tmp; + } + // Contribution 45 + { + Avm_DECLARE_VIEWS(45); + + auto tmp = (avm_alu_b_lo_shift - (avm_alu_p_sub_a_lo * avm_alu_rng_chk_sel_shift)); + tmp *= scaling_factor; + std::get<45>(evals) += tmp; + } + // Contribution 46 + { + Avm_DECLARE_VIEWS(46); + + auto tmp = (avm_alu_b_hi_shift - (avm_alu_p_sub_a_hi * avm_alu_rng_chk_sel_shift)); + tmp *= scaling_factor; + std::get<46>(evals) += tmp; + } + // Contribution 47 + { + Avm_DECLARE_VIEWS(47); + + auto tmp = (avm_alu_p_sub_a_lo_shift - (avm_alu_p_sub_b_lo * avm_alu_rng_chk_sel_shift)); + tmp *= scaling_factor; + std::get<47>(evals) += tmp; + } + // Contribution 48 + { + Avm_DECLARE_VIEWS(48); + + auto tmp = (avm_alu_p_sub_a_hi_shift - (avm_alu_p_sub_b_hi * avm_alu_rng_chk_sel_shift)); + tmp *= scaling_factor; + std::get<48>(evals) += tmp; + } + // Contribution 49 + { + Avm_DECLARE_VIEWS(49); + + auto tmp = (avm_alu_p_sub_b_lo_shift - (avm_alu_res_lo * avm_alu_rng_chk_sel_shift)); + tmp *= scaling_factor; + std::get<49>(evals) += tmp; + } + // Contribution 50 + { + Avm_DECLARE_VIEWS(50); + + auto tmp = (avm_alu_p_sub_b_hi_shift - (avm_alu_res_hi * avm_alu_rng_chk_sel_shift)); + tmp *= scaling_factor; + std::get<50>(evals) += tmp; + } } }; diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_binary.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_binary.hpp index 6ddb6b13f59f..e58112cbfd7c 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_binary.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_binary.hpp @@ -7,43 +7,43 @@ namespace bb::Avm_vm { template struct Avm_binaryRow { + FF avm_binary_acc_ia{}; + FF avm_binary_acc_ia_shift{}; + FF avm_binary_acc_ib{}; + FF avm_binary_acc_ib_shift{}; + FF avm_binary_acc_ic{}; FF avm_binary_acc_ic_shift{}; FF avm_binary_bin_sel{}; - FF avm_binary_op_id{}; FF avm_binary_ia_bytes{}; - FF avm_binary_acc_ia{}; - FF avm_binary_acc_ic{}; - FF avm_binary_op_id_shift{}; - FF avm_binary_mem_tag_ctr_inv{}; - FF avm_binary_mem_tag_ctr_shift{}; - FF avm_binary_ic_bytes{}; - FF avm_binary_acc_ib{}; - FF avm_binary_acc_ia_shift{}; FF avm_binary_ib_bytes{}; - FF avm_binary_acc_ib_shift{}; + FF avm_binary_ic_bytes{}; FF avm_binary_mem_tag_ctr{}; + FF avm_binary_mem_tag_ctr_inv{}; + FF avm_binary_mem_tag_ctr_shift{}; + FF avm_binary_op_id{}; + FF avm_binary_op_id_shift{}; }; inline std::string get_relation_label_avm_binary(int index) { switch (index) { - case 9: - return "ACC_REL_C"; - - case 3: - return "BIN_SEL_CTR_REL"; + case 1: + return "OP_ID_REL"; case 2: return "MEM_TAG_REL"; - case 1: - return "OP_ID_REL"; + case 3: + return "BIN_SEL_CTR_REL"; case 7: return "ACC_REL_A"; case 8: return "ACC_REL_B"; + + case 9: + return "ACC_REL_C"; } return std::to_string(index); } diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_cmp.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_cmp.hpp index b12ac1c2e1cd..122d8df3abd9 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_cmp.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_cmp.hpp @@ -7,30 +7,30 @@ namespace bb::Avm_vm { template struct Avm_cmpRow { - FF avm_cmp_p_sub_a_hi{}; FF avm_cmp_a_hi{}; - FF avm_cmp_lt_query{}; + FF avm_cmp_a_lo{}; + FF avm_cmp_b_hi{}; FF avm_cmp_b_lo{}; - FF avm_cmp_p_sub_a_lo{}; - FF avm_cmp_res_lo{}; FF avm_cmp_borrow{}; + FF avm_cmp_cmp_sel{}; + FF avm_cmp_ia{}; + FF avm_cmp_ib{}; + FF avm_cmp_ic{}; FF avm_cmp_input_ia{}; - FF avm_cmp_p_sub_b_hi{}; + FF avm_cmp_input_ib{}; + FF avm_cmp_lt_query{}; + FF avm_cmp_lt_sel{}; FF avm_cmp_lte_sel{}; - FF avm_cmp_ic{}; - FF avm_cmp_ib{}; - FF avm_cmp_cmp_sel{}; - FF avm_cmp_a_lo{}; + FF avm_cmp_p_a_borrow{}; + FF avm_cmp_p_b_borrow{}; FF avm_cmp_p_hi{}; FF avm_cmp_p_lo{}; - FF avm_cmp_input_ib{}; - FF avm_cmp_p_b_borrow{}; - FF avm_cmp_p_a_borrow{}; - FF avm_cmp_res_hi{}; - FF avm_cmp_lt_sel{}; - FF avm_cmp_ia{}; + FF avm_cmp_p_sub_a_hi{}; + FF avm_cmp_p_sub_a_lo{}; + FF avm_cmp_p_sub_b_hi{}; FF avm_cmp_p_sub_b_lo{}; - FF avm_cmp_b_hi{}; + FF avm_cmp_res_hi{}; + FF avm_cmp_res_lo{}; }; inline std::string get_relation_label_avm_cmp(int index) 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 1a826303cc09..f264c265b6bf 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_main.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_main.hpp @@ -7,96 +7,96 @@ namespace bb::Avm_vm { template struct Avm_mainRow { - FF avm_main_mem_idx_b{}; - FF avm_main_pc_shift{}; - FF avm_main_sel_op_and{}; - FF avm_main_tag_err{}; - FF avm_main_sel_op_xor{}; - FF avm_main_sel_mov{}; - FF avm_main_sel_op_lt{}; - FF avm_main_sel_op_add{}; - FF avm_main_sel_jump{}; - FF avm_main_sel_internal_return{}; - FF avm_main_ind_op_a{}; - FF avm_main_sel_op_sub{}; + FF avm_main_alu_sel{}; + FF avm_main_bin_op_id{}; + FF avm_main_bin_sel{}; + FF avm_main_cmp_sel{}; + FF avm_main_first{}; FF avm_main_ia{}; + FF avm_main_ib{}; + FF avm_main_ic{}; + FF avm_main_ind_op_a{}; + FF avm_main_ind_op_b{}; + FF avm_main_ind_op_c{}; FF avm_main_internal_return_ptr{}; + FF avm_main_internal_return_ptr_shift{}; FF avm_main_inv{}; - FF avm_main_sel_op_eq{}; + FF avm_main_mem_idx_a{}; + FF avm_main_mem_idx_b{}; + FF avm_main_mem_op_a{}; FF avm_main_mem_op_b{}; - FF avm_main_sel_op_lte{}; + FF avm_main_mem_op_c{}; + FF avm_main_op_err{}; + FF avm_main_pc{}; + FF avm_main_pc_shift{}; + FF avm_main_r_in_tag{}; FF avm_main_rwa{}; - FF avm_main_ind_op_c{}; - FF avm_main_rwc{}; - FF avm_main_ib{}; FF avm_main_rwb{}; - FF avm_main_pc{}; - FF avm_main_ic{}; - FF avm_main_sel_op_div{}; + FF avm_main_rwc{}; FF avm_main_sel_halt{}; - FF avm_main_ind_op_b{}; - FF avm_main_first{}; - FF avm_main_r_in_tag{}; - FF avm_main_alu_sel{}; - FF avm_main_w_in_tag{}; - FF avm_main_bin_op_id{}; FF avm_main_sel_internal_call{}; - FF avm_main_op_err{}; - FF avm_main_bin_sel{}; - FF avm_main_internal_return_ptr_shift{}; - FF avm_main_sel_op_not{}; - FF avm_main_mem_op_a{}; + FF avm_main_sel_internal_return{}; + FF avm_main_sel_jump{}; + FF avm_main_sel_mov{}; + FF avm_main_sel_op_add{}; + FF avm_main_sel_op_and{}; + FF avm_main_sel_op_div{}; + FF avm_main_sel_op_eq{}; + FF avm_main_sel_op_lt{}; + FF avm_main_sel_op_lte{}; FF avm_main_sel_op_mul{}; - FF avm_main_mem_op_c{}; - FF avm_main_mem_idx_a{}; + FF avm_main_sel_op_not{}; FF avm_main_sel_op_or{}; - FF avm_main_cmp_sel{}; + FF avm_main_sel_op_sub{}; + FF avm_main_sel_op_xor{}; + FF avm_main_tag_err{}; + FF avm_main_w_in_tag{}; }; inline std::string get_relation_label_avm_main(int index) { switch (index) { + case 27: + return "EQ_OUTPUT_U8"; + + case 28: + return "SUBOP_DIVISION_FF"; + case 29: return "SUBOP_DIVISION_ZERO_ERR1"; - case 39: - return "RETURN_POINTER_DECREMENT"; + case 30: + return "SUBOP_DIVISION_ZERO_ERR2"; - case 46: - return "MOV_SAME_VALUE"; + case 31: + return "SUBOP_ERROR_RELEVANT_OP"; - case 27: - return "EQ_OUTPUT_U8"; + case 33: + return "RETURN_POINTER_INCREMENT"; - case 50: - return "BIN_SEL_2"; + case 39: + return "RETURN_POINTER_DECREMENT"; case 44: return "PC_INCREMENT"; - case 51: - return "CMP_SEL"; + case 45: + return "INTERNAL_RETURN_POINTER_CONSISTENCY"; - case 28: - return "SUBOP_DIVISION_FF"; + case 46: + return "MOV_SAME_VALUE"; case 47: return "MOV_MAIN_SAME_TAG"; - case 45: - return "INTERNAL_RETURN_POINTER_CONSISTENCY"; - case 49: return "BIN_SEL_1"; - case 33: - return "RETURN_POINTER_INCREMENT"; - - case 31: - return "SUBOP_ERROR_RELEVANT_OP"; + case 50: + return "BIN_SEL_2"; - case 30: - return "SUBOP_DIVISION_ZERO_ERR2"; + case 51: + return "CMP_SEL"; } return std::to_string(index); } 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 3a32f727d0c4..7ab7905c9b8d 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_mem.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_mem.hpp @@ -7,45 +7,33 @@ namespace bb::Avm_vm { template struct Avm_memRow { - FF avm_mem_lastAccess{}; - FF avm_mem_val{}; + FF avm_mem_addr{}; + FF avm_mem_addr_shift{}; FF avm_mem_ind_op_a{}; FF avm_mem_ind_op_b{}; - FF avm_mem_tag_shift{}; - FF avm_mem_w_in_tag{}; - FF avm_mem_addr{}; - FF avm_mem_r_in_tag{}; FF avm_mem_ind_op_c{}; - FF avm_mem_addr_shift{}; FF avm_mem_last{}; - FF avm_mem_rw{}; - FF avm_mem_tag_err{}; - FF avm_mem_op_c{}; - FF avm_mem_val_shift{}; + FF avm_mem_lastAccess{}; FF avm_mem_one_min_inv{}; - FF avm_mem_sel_mov{}; - FF avm_mem_sub_clk{}; FF avm_mem_op_a{}; FF avm_mem_op_b{}; - FF avm_mem_tag{}; + FF avm_mem_op_c{}; + FF avm_mem_r_in_tag{}; + FF avm_mem_rw{}; FF avm_mem_rw_shift{}; + FF avm_mem_sel_mov{}; + FF avm_mem_sub_clk{}; + FF avm_mem_tag{}; + FF avm_mem_tag_err{}; + FF avm_mem_tag_shift{}; + FF avm_mem_val{}; + FF avm_mem_val_shift{}; + FF avm_mem_w_in_tag{}; }; inline std::string get_relation_label_avm_mem(int index) { switch (index) { - case 26: - return "MOV_SAME_TAG"; - - case 15: - return "MEM_ZERO_INIT"; - - case 17: - return "MEM_IN_TAG_CONSISTENCY_2"; - - case 16: - return "MEM_IN_TAG_CONSISTENCY_1"; - case 12: return "MEM_LAST_ACCESS_DELIMITER"; @@ -55,8 +43,20 @@ inline std::string get_relation_label_avm_mem(int index) case 14: return "MEM_READ_WRITE_TAG_CONSISTENCY"; + case 15: + return "MEM_ZERO_INIT"; + + case 16: + return "MEM_IN_TAG_CONSISTENCY_1"; + + case 17: + return "MEM_IN_TAG_CONSISTENCY_2"; + case 19: return "NO_TAG_ERR_WRITE"; + + case 26: + return "MOV_SAME_TAG"; } return std::to_string(index); } 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 cf7faa63ed1b..19157aa8ff48 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/declare_views.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/declare_views.hpp @@ -4,47 +4,49 @@ using View = typename Accumulator::View; \ [[maybe_unused]] auto avm_main_clk = View(new_term.avm_main_clk); \ [[maybe_unused]] auto avm_main_first = View(new_term.avm_main_first); \ - [[maybe_unused]] auto avm_mem_clk = View(new_term.avm_mem_clk); \ - [[maybe_unused]] auto avm_mem_sub_clk = View(new_term.avm_mem_sub_clk); \ - [[maybe_unused]] auto avm_mem_addr = View(new_term.avm_mem_addr); \ - [[maybe_unused]] auto avm_mem_tag = View(new_term.avm_mem_tag); \ - [[maybe_unused]] auto avm_mem_val = View(new_term.avm_mem_val); \ - [[maybe_unused]] auto avm_mem_lastAccess = View(new_term.avm_mem_lastAccess); \ - [[maybe_unused]] auto avm_mem_last = View(new_term.avm_mem_last); \ - [[maybe_unused]] auto avm_mem_rw = View(new_term.avm_mem_rw); \ - [[maybe_unused]] auto avm_mem_r_in_tag = View(new_term.avm_mem_r_in_tag); \ - [[maybe_unused]] auto avm_mem_w_in_tag = View(new_term.avm_mem_w_in_tag); \ - [[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_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_sel_mov = View(new_term.avm_mem_sel_mov); \ - [[maybe_unused]] auto avm_mem_tag_err = View(new_term.avm_mem_tag_err); \ - [[maybe_unused]] auto avm_mem_one_min_inv = View(new_term.avm_mem_one_min_inv); \ + [[maybe_unused]] auto avm_alu_a_hi = View(new_term.avm_alu_a_hi); \ + [[maybe_unused]] auto avm_alu_a_lo = View(new_term.avm_alu_a_lo); \ + [[maybe_unused]] auto avm_alu_alu_sel = View(new_term.avm_alu_alu_sel); \ + [[maybe_unused]] auto avm_alu_b_hi = View(new_term.avm_alu_b_hi); \ + [[maybe_unused]] auto avm_alu_b_lo = View(new_term.avm_alu_b_lo); \ + [[maybe_unused]] auto avm_alu_borrow = View(new_term.avm_alu_borrow); \ + [[maybe_unused]] auto avm_alu_cf = View(new_term.avm_alu_cf); \ [[maybe_unused]] auto avm_alu_clk = View(new_term.avm_alu_clk); \ + [[maybe_unused]] auto avm_alu_cmp_sel = View(new_term.avm_alu_cmp_sel); \ + [[maybe_unused]] auto avm_alu_ff_tag = View(new_term.avm_alu_ff_tag); \ [[maybe_unused]] auto avm_alu_ia = View(new_term.avm_alu_ia); \ [[maybe_unused]] auto avm_alu_ib = View(new_term.avm_alu_ib); \ [[maybe_unused]] auto avm_alu_ic = View(new_term.avm_alu_ic); \ + [[maybe_unused]] auto avm_alu_in_tag = View(new_term.avm_alu_in_tag); \ + [[maybe_unused]] auto avm_alu_input_ia = View(new_term.avm_alu_input_ia); \ + [[maybe_unused]] auto avm_alu_input_ib = View(new_term.avm_alu_input_ib); \ + [[maybe_unused]] auto avm_alu_lt_sel = View(new_term.avm_alu_lt_sel); \ + [[maybe_unused]] auto avm_alu_lte_sel = View(new_term.avm_alu_lte_sel); \ [[maybe_unused]] auto avm_alu_op_add = View(new_term.avm_alu_op_add); \ - [[maybe_unused]] auto avm_alu_op_sub = View(new_term.avm_alu_op_sub); \ - [[maybe_unused]] auto avm_alu_op_mul = View(new_term.avm_alu_op_mul); \ [[maybe_unused]] auto avm_alu_op_div = View(new_term.avm_alu_op_div); \ - [[maybe_unused]] auto avm_alu_op_not = View(new_term.avm_alu_op_not); \ [[maybe_unused]] auto avm_alu_op_eq = View(new_term.avm_alu_op_eq); \ - [[maybe_unused]] auto avm_alu_alu_sel = View(new_term.avm_alu_alu_sel); \ - [[maybe_unused]] auto avm_alu_in_tag = View(new_term.avm_alu_in_tag); \ - [[maybe_unused]] auto avm_alu_ff_tag = View(new_term.avm_alu_ff_tag); \ - [[maybe_unused]] auto avm_alu_u8_tag = View(new_term.avm_alu_u8_tag); \ - [[maybe_unused]] auto avm_alu_u16_tag = View(new_term.avm_alu_u16_tag); \ - [[maybe_unused]] auto avm_alu_u32_tag = View(new_term.avm_alu_u32_tag); \ - [[maybe_unused]] auto avm_alu_u64_tag = View(new_term.avm_alu_u64_tag); \ + [[maybe_unused]] auto avm_alu_op_eq_diff_inv = View(new_term.avm_alu_op_eq_diff_inv); \ + [[maybe_unused]] auto avm_alu_op_mul = View(new_term.avm_alu_op_mul); \ + [[maybe_unused]] auto avm_alu_op_not = View(new_term.avm_alu_op_not); \ + [[maybe_unused]] auto avm_alu_op_sub = View(new_term.avm_alu_op_sub); \ + [[maybe_unused]] auto avm_alu_p_a_borrow = View(new_term.avm_alu_p_a_borrow); \ + [[maybe_unused]] auto avm_alu_p_b_borrow = View(new_term.avm_alu_p_b_borrow); \ + [[maybe_unused]] auto avm_alu_p_sub_a_hi = View(new_term.avm_alu_p_sub_a_hi); \ + [[maybe_unused]] auto avm_alu_p_sub_a_lo = View(new_term.avm_alu_p_sub_a_lo); \ + [[maybe_unused]] auto avm_alu_p_sub_b_hi = View(new_term.avm_alu_p_sub_b_hi); \ + [[maybe_unused]] auto avm_alu_p_sub_b_lo = View(new_term.avm_alu_p_sub_b_lo); \ + [[maybe_unused]] auto avm_alu_res_hi = View(new_term.avm_alu_res_hi); \ + [[maybe_unused]] auto avm_alu_res_lo = View(new_term.avm_alu_res_lo); \ + [[maybe_unused]] auto avm_alu_rng_chk_remaining = View(new_term.avm_alu_rng_chk_remaining); \ + [[maybe_unused]] auto avm_alu_rng_chk_sel = View(new_term.avm_alu_rng_chk_sel); \ [[maybe_unused]] auto avm_alu_u128_tag = View(new_term.avm_alu_u128_tag); \ - [[maybe_unused]] auto avm_alu_u8_r0 = View(new_term.avm_alu_u8_r0); \ - [[maybe_unused]] auto avm_alu_u8_r1 = View(new_term.avm_alu_u8_r1); \ [[maybe_unused]] auto avm_alu_u16_r0 = View(new_term.avm_alu_u16_r0); \ [[maybe_unused]] auto avm_alu_u16_r1 = View(new_term.avm_alu_u16_r1); \ + [[maybe_unused]] auto avm_alu_u16_r10 = View(new_term.avm_alu_u16_r10); \ + [[maybe_unused]] auto avm_alu_u16_r11 = View(new_term.avm_alu_u16_r11); \ + [[maybe_unused]] auto avm_alu_u16_r12 = View(new_term.avm_alu_u16_r12); \ + [[maybe_unused]] auto avm_alu_u16_r13 = View(new_term.avm_alu_u16_r13); \ + [[maybe_unused]] auto avm_alu_u16_r14 = View(new_term.avm_alu_u16_r14); \ [[maybe_unused]] auto avm_alu_u16_r2 = View(new_term.avm_alu_u16_r2); \ [[maybe_unused]] auto avm_alu_u16_r3 = View(new_term.avm_alu_u16_r3); \ [[maybe_unused]] auto avm_alu_u16_r4 = View(new_term.avm_alu_u16_r4); \ @@ -53,107 +55,100 @@ [[maybe_unused]] auto avm_alu_u16_r7 = View(new_term.avm_alu_u16_r7); \ [[maybe_unused]] auto avm_alu_u16_r8 = View(new_term.avm_alu_u16_r8); \ [[maybe_unused]] auto avm_alu_u16_r9 = View(new_term.avm_alu_u16_r9); \ - [[maybe_unused]] auto avm_alu_u16_r10 = View(new_term.avm_alu_u16_r10); \ - [[maybe_unused]] auto avm_alu_u16_r11 = View(new_term.avm_alu_u16_r11); \ - [[maybe_unused]] auto avm_alu_u16_r12 = View(new_term.avm_alu_u16_r12); \ - [[maybe_unused]] auto avm_alu_u16_r13 = View(new_term.avm_alu_u16_r13); \ - [[maybe_unused]] auto avm_alu_u16_r14 = View(new_term.avm_alu_u16_r14); \ + [[maybe_unused]] auto avm_alu_u16_tag = View(new_term.avm_alu_u16_tag); \ + [[maybe_unused]] auto avm_alu_u32_tag = View(new_term.avm_alu_u32_tag); \ [[maybe_unused]] auto avm_alu_u64_r0 = View(new_term.avm_alu_u64_r0); \ - [[maybe_unused]] auto avm_alu_cf = View(new_term.avm_alu_cf); \ - [[maybe_unused]] auto avm_alu_op_eq_diff_inv = View(new_term.avm_alu_op_eq_diff_inv); \ - [[maybe_unused]] auto avm_byte_lookup_table_op_id = View(new_term.avm_byte_lookup_table_op_id); \ - [[maybe_unused]] auto avm_byte_lookup_table_input_a = View(new_term.avm_byte_lookup_table_input_a); \ - [[maybe_unused]] auto avm_byte_lookup_table_input_b = View(new_term.avm_byte_lookup_table_input_b); \ - [[maybe_unused]] auto avm_byte_lookup_table_output = View(new_term.avm_byte_lookup_table_output); \ - [[maybe_unused]] auto avm_byte_lookup_bin_sel = View(new_term.avm_byte_lookup_bin_sel); \ - [[maybe_unused]] auto avm_byte_lookup_table_in_tags = View(new_term.avm_byte_lookup_table_in_tags); \ - [[maybe_unused]] auto avm_byte_lookup_table_byte_lengths = View(new_term.avm_byte_lookup_table_byte_lengths); \ - [[maybe_unused]] auto avm_binary_clk = View(new_term.avm_binary_clk); \ - [[maybe_unused]] auto avm_binary_bin_sel = View(new_term.avm_binary_bin_sel); \ + [[maybe_unused]] auto avm_alu_u64_tag = View(new_term.avm_alu_u64_tag); \ + [[maybe_unused]] auto avm_alu_u8_r0 = View(new_term.avm_alu_u8_r0); \ + [[maybe_unused]] auto avm_alu_u8_r1 = View(new_term.avm_alu_u8_r1); \ + [[maybe_unused]] auto avm_alu_u8_tag = View(new_term.avm_alu_u8_tag); \ [[maybe_unused]] auto avm_binary_acc_ia = View(new_term.avm_binary_acc_ia); \ [[maybe_unused]] auto avm_binary_acc_ib = View(new_term.avm_binary_acc_ib); \ [[maybe_unused]] auto avm_binary_acc_ic = View(new_term.avm_binary_acc_ic); \ - [[maybe_unused]] auto avm_binary_in_tag = View(new_term.avm_binary_in_tag); \ - [[maybe_unused]] auto avm_binary_op_id = View(new_term.avm_binary_op_id); \ + [[maybe_unused]] auto avm_binary_bin_sel = View(new_term.avm_binary_bin_sel); \ + [[maybe_unused]] auto avm_binary_clk = View(new_term.avm_binary_clk); \ [[maybe_unused]] auto avm_binary_ia_bytes = View(new_term.avm_binary_ia_bytes); \ [[maybe_unused]] auto avm_binary_ib_bytes = View(new_term.avm_binary_ib_bytes); \ [[maybe_unused]] auto avm_binary_ic_bytes = View(new_term.avm_binary_ic_bytes); \ - [[maybe_unused]] auto avm_binary_start = View(new_term.avm_binary_start); \ + [[maybe_unused]] auto avm_binary_in_tag = View(new_term.avm_binary_in_tag); \ [[maybe_unused]] auto avm_binary_mem_tag_ctr = View(new_term.avm_binary_mem_tag_ctr); \ [[maybe_unused]] auto avm_binary_mem_tag_ctr_inv = View(new_term.avm_binary_mem_tag_ctr_inv); \ - [[maybe_unused]] auto avm_cmp_cmp_clk = View(new_term.avm_cmp_cmp_clk); \ - [[maybe_unused]] auto avm_cmp_ia = View(new_term.avm_cmp_ia); \ - [[maybe_unused]] auto avm_cmp_ib = View(new_term.avm_cmp_ib); \ - [[maybe_unused]] auto avm_cmp_ic = View(new_term.avm_cmp_ic); \ - [[maybe_unused]] auto avm_cmp_lt_sel = View(new_term.avm_cmp_lt_sel); \ - [[maybe_unused]] auto avm_cmp_lte_sel = View(new_term.avm_cmp_lte_sel); \ - [[maybe_unused]] auto avm_cmp_cmp_sel = View(new_term.avm_cmp_cmp_sel); \ - [[maybe_unused]] auto avm_cmp_input_ia = View(new_term.avm_cmp_input_ia); \ - [[maybe_unused]] auto avm_cmp_input_ib = View(new_term.avm_cmp_input_ib); \ - [[maybe_unused]] auto avm_cmp_a_lo = View(new_term.avm_cmp_a_lo); \ - [[maybe_unused]] auto avm_cmp_a_hi = View(new_term.avm_cmp_a_hi); \ - [[maybe_unused]] auto avm_cmp_b_lo = View(new_term.avm_cmp_b_lo); \ - [[maybe_unused]] auto avm_cmp_b_hi = View(new_term.avm_cmp_b_hi); \ - [[maybe_unused]] auto avm_cmp_borrow = View(new_term.avm_cmp_borrow); \ - [[maybe_unused]] auto avm_cmp_p_lo = View(new_term.avm_cmp_p_lo); \ - [[maybe_unused]] auto avm_cmp_p_hi = View(new_term.avm_cmp_p_hi); \ - [[maybe_unused]] auto avm_cmp_p_sub_a_lo = View(new_term.avm_cmp_p_sub_a_lo); \ - [[maybe_unused]] auto avm_cmp_p_sub_a_hi = View(new_term.avm_cmp_p_sub_a_hi); \ - [[maybe_unused]] auto avm_cmp_p_a_borrow = View(new_term.avm_cmp_p_a_borrow); \ - [[maybe_unused]] auto avm_cmp_p_sub_b_lo = View(new_term.avm_cmp_p_sub_b_lo); \ - [[maybe_unused]] auto avm_cmp_p_sub_b_hi = View(new_term.avm_cmp_p_sub_b_hi); \ - [[maybe_unused]] auto avm_cmp_p_b_borrow = View(new_term.avm_cmp_p_b_borrow); \ - [[maybe_unused]] auto avm_cmp_res_lo = View(new_term.avm_cmp_res_lo); \ - [[maybe_unused]] auto avm_cmp_res_hi = View(new_term.avm_cmp_res_hi); \ - [[maybe_unused]] auto avm_cmp_lt_query = View(new_term.avm_cmp_lt_query); \ - [[maybe_unused]] auto avm_main_sel_rng_8 = View(new_term.avm_main_sel_rng_8); \ - [[maybe_unused]] auto avm_main_sel_rng_16 = View(new_term.avm_main_sel_rng_16); \ - [[maybe_unused]] auto avm_main_pc = View(new_term.avm_main_pc); \ - [[maybe_unused]] auto avm_main_internal_return_ptr = View(new_term.avm_main_internal_return_ptr); \ - [[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_halt = View(new_term.avm_main_sel_halt); \ - [[maybe_unused]] auto avm_main_sel_mov = View(new_term.avm_main_sel_mov); \ - [[maybe_unused]] auto avm_main_sel_op_add = View(new_term.avm_main_sel_op_add); \ - [[maybe_unused]] auto avm_main_sel_op_sub = View(new_term.avm_main_sel_op_sub); \ - [[maybe_unused]] auto avm_main_sel_op_mul = View(new_term.avm_main_sel_op_mul); \ - [[maybe_unused]] auto avm_main_sel_op_div = View(new_term.avm_main_sel_op_div); \ - [[maybe_unused]] auto avm_main_sel_op_not = View(new_term.avm_main_sel_op_not); \ - [[maybe_unused]] auto avm_main_sel_op_eq = View(new_term.avm_main_sel_op_eq); \ - [[maybe_unused]] auto avm_main_sel_op_and = View(new_term.avm_main_sel_op_and); \ - [[maybe_unused]] auto avm_main_sel_op_or = View(new_term.avm_main_sel_op_or); \ - [[maybe_unused]] auto avm_main_sel_op_xor = View(new_term.avm_main_sel_op_xor); \ - [[maybe_unused]] auto avm_main_sel_op_lt = View(new_term.avm_main_sel_op_lt); \ - [[maybe_unused]] auto avm_main_sel_op_lte = View(new_term.avm_main_sel_op_lte); \ + [[maybe_unused]] auto avm_binary_op_id = View(new_term.avm_binary_op_id); \ + [[maybe_unused]] auto avm_binary_start = View(new_term.avm_binary_start); \ + [[maybe_unused]] auto avm_byte_lookup_bin_sel = View(new_term.avm_byte_lookup_bin_sel); \ + [[maybe_unused]] auto avm_byte_lookup_table_byte_lengths = View(new_term.avm_byte_lookup_table_byte_lengths); \ + [[maybe_unused]] auto avm_byte_lookup_table_in_tags = View(new_term.avm_byte_lookup_table_in_tags); \ + [[maybe_unused]] auto avm_byte_lookup_table_input_a = View(new_term.avm_byte_lookup_table_input_a); \ + [[maybe_unused]] auto avm_byte_lookup_table_input_b = View(new_term.avm_byte_lookup_table_input_b); \ + [[maybe_unused]] auto avm_byte_lookup_table_op_id = View(new_term.avm_byte_lookup_table_op_id); \ + [[maybe_unused]] auto avm_byte_lookup_table_output = View(new_term.avm_byte_lookup_table_output); \ [[maybe_unused]] auto avm_main_alu_sel = View(new_term.avm_main_alu_sel); \ + [[maybe_unused]] auto avm_main_bin_op_id = View(new_term.avm_main_bin_op_id); \ [[maybe_unused]] auto avm_main_bin_sel = View(new_term.avm_main_bin_sel); \ [[maybe_unused]] auto avm_main_cmp_sel = View(new_term.avm_main_cmp_sel); \ - [[maybe_unused]] auto avm_main_r_in_tag = View(new_term.avm_main_r_in_tag); \ - [[maybe_unused]] auto avm_main_w_in_tag = View(new_term.avm_main_w_in_tag); \ - [[maybe_unused]] auto avm_main_op_err = View(new_term.avm_main_op_err); \ - [[maybe_unused]] auto avm_main_tag_err = View(new_term.avm_main_tag_err); \ - [[maybe_unused]] auto avm_main_inv = View(new_term.avm_main_inv); \ [[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_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_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_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_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_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_last = View(new_term.avm_main_last); \ - [[maybe_unused]] auto avm_main_bin_op_id = View(new_term.avm_main_bin_op_id); \ + [[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_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_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_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); \ + [[maybe_unused]] auto avm_main_sel_op_eq = View(new_term.avm_main_sel_op_eq); \ + [[maybe_unused]] auto avm_main_sel_op_lt = View(new_term.avm_main_sel_op_lt); \ + [[maybe_unused]] auto avm_main_sel_op_lte = View(new_term.avm_main_sel_op_lte); \ + [[maybe_unused]] auto avm_main_sel_op_mul = View(new_term.avm_main_sel_op_mul); \ + [[maybe_unused]] auto avm_main_sel_op_not = View(new_term.avm_main_sel_op_not); \ + [[maybe_unused]] auto avm_main_sel_op_or = View(new_term.avm_main_sel_op_or); \ + [[maybe_unused]] auto avm_main_sel_op_sub = View(new_term.avm_main_sel_op_sub); \ + [[maybe_unused]] auto avm_main_sel_op_xor = View(new_term.avm_main_sel_op_xor); \ + [[maybe_unused]] auto avm_main_sel_rng_16 = View(new_term.avm_main_sel_rng_16); \ + [[maybe_unused]] auto avm_main_sel_rng_8 = View(new_term.avm_main_sel_rng_8); \ + [[maybe_unused]] auto avm_main_tag_err = View(new_term.avm_main_tag_err); \ + [[maybe_unused]] auto avm_main_w_in_tag = View(new_term.avm_main_w_in_tag); \ + [[maybe_unused]] auto avm_mem_addr = View(new_term.avm_mem_addr); \ + [[maybe_unused]] auto avm_mem_clk = View(new_term.avm_mem_clk); \ + [[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_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_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_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); \ + [[maybe_unused]] auto avm_mem_val = View(new_term.avm_mem_val); \ + [[maybe_unused]] auto avm_mem_w_in_tag = View(new_term.avm_mem_w_in_tag); \ [[maybe_unused]] auto perm_main_alu = View(new_term.perm_main_alu); \ [[maybe_unused]] auto perm_main_bin = View(new_term.perm_main_bin); \ [[maybe_unused]] auto perm_main_cmp = View(new_term.perm_main_cmp); \ @@ -171,22 +166,32 @@ [[maybe_unused]] auto lookup_byte_operations_counts = View(new_term.lookup_byte_operations_counts); \ [[maybe_unused]] auto incl_main_tag_err_counts = View(new_term.incl_main_tag_err_counts); \ [[maybe_unused]] auto incl_mem_tag_err_counts = View(new_term.incl_mem_tag_err_counts); \ + [[maybe_unused]] auto avm_alu_a_hi_shift = View(new_term.avm_alu_a_hi_shift); \ + [[maybe_unused]] auto avm_alu_a_lo_shift = View(new_term.avm_alu_a_lo_shift); \ + [[maybe_unused]] auto avm_alu_b_hi_shift = View(new_term.avm_alu_b_hi_shift); \ + [[maybe_unused]] auto avm_alu_b_lo_shift = View(new_term.avm_alu_b_lo_shift); \ + [[maybe_unused]] auto avm_alu_p_sub_a_hi_shift = View(new_term.avm_alu_p_sub_a_hi_shift); \ + [[maybe_unused]] auto avm_alu_p_sub_a_lo_shift = View(new_term.avm_alu_p_sub_a_lo_shift); \ + [[maybe_unused]] auto avm_alu_p_sub_b_hi_shift = View(new_term.avm_alu_p_sub_b_hi_shift); \ + [[maybe_unused]] auto avm_alu_p_sub_b_lo_shift = View(new_term.avm_alu_p_sub_b_lo_shift); \ + [[maybe_unused]] auto avm_alu_rng_chk_remaining_shift = View(new_term.avm_alu_rng_chk_remaining_shift); \ + [[maybe_unused]] auto avm_alu_rng_chk_sel_shift = View(new_term.avm_alu_rng_chk_sel_shift); \ [[maybe_unused]] auto avm_alu_u16_r0_shift = View(new_term.avm_alu_u16_r0_shift); \ + [[maybe_unused]] auto avm_alu_u16_r1_shift = View(new_term.avm_alu_u16_r1_shift); \ + [[maybe_unused]] auto avm_alu_u16_r2_shift = View(new_term.avm_alu_u16_r2_shift); \ [[maybe_unused]] auto avm_alu_u16_r3_shift = View(new_term.avm_alu_u16_r3_shift); \ [[maybe_unused]] auto avm_alu_u16_r4_shift = View(new_term.avm_alu_u16_r4_shift); \ - [[maybe_unused]] auto avm_alu_u16_r7_shift = View(new_term.avm_alu_u16_r7_shift); \ - [[maybe_unused]] auto avm_alu_u16_r6_shift = View(new_term.avm_alu_u16_r6_shift); \ - [[maybe_unused]] auto avm_alu_u16_r2_shift = View(new_term.avm_alu_u16_r2_shift); \ [[maybe_unused]] auto avm_alu_u16_r5_shift = View(new_term.avm_alu_u16_r5_shift); \ - [[maybe_unused]] auto avm_alu_u16_r1_shift = View(new_term.avm_alu_u16_r1_shift); \ - [[maybe_unused]] auto avm_binary_acc_ic_shift = View(new_term.avm_binary_acc_ic_shift); \ - [[maybe_unused]] auto avm_binary_op_id_shift = View(new_term.avm_binary_op_id_shift); \ - [[maybe_unused]] auto avm_binary_mem_tag_ctr_shift = View(new_term.avm_binary_mem_tag_ctr_shift); \ + [[maybe_unused]] auto avm_alu_u16_r6_shift = View(new_term.avm_alu_u16_r6_shift); \ + [[maybe_unused]] auto avm_alu_u16_r7_shift = View(new_term.avm_alu_u16_r7_shift); \ [[maybe_unused]] auto avm_binary_acc_ia_shift = View(new_term.avm_binary_acc_ia_shift); \ [[maybe_unused]] auto avm_binary_acc_ib_shift = View(new_term.avm_binary_acc_ib_shift); \ - [[maybe_unused]] auto avm_mem_tag_shift = View(new_term.avm_mem_tag_shift); \ + [[maybe_unused]] auto avm_binary_acc_ic_shift = View(new_term.avm_binary_acc_ic_shift); \ + [[maybe_unused]] auto avm_binary_mem_tag_ctr_shift = View(new_term.avm_binary_mem_tag_ctr_shift); \ + [[maybe_unused]] auto avm_binary_op_id_shift = View(new_term.avm_binary_op_id_shift); \ + [[maybe_unused]] auto avm_main_internal_return_ptr_shift = View(new_term.avm_main_internal_return_ptr_shift); \ + [[maybe_unused]] auto avm_main_pc_shift = View(new_term.avm_main_pc_shift); \ [[maybe_unused]] auto avm_mem_addr_shift = View(new_term.avm_mem_addr_shift); \ - [[maybe_unused]] auto avm_mem_val_shift = View(new_term.avm_mem_val_shift); \ [[maybe_unused]] auto avm_mem_rw_shift = View(new_term.avm_mem_rw_shift); \ - [[maybe_unused]] auto avm_main_pc_shift = View(new_term.avm_main_pc_shift); \ - [[maybe_unused]] auto avm_main_internal_return_ptr_shift = View(new_term.avm_main_internal_return_ptr_shift); + [[maybe_unused]] auto avm_mem_tag_shift = View(new_term.avm_mem_tag_shift); \ + [[maybe_unused]] auto avm_mem_val_shift = View(new_term.avm_mem_val_shift); diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_bin.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_bin.hpp index 842f5812b4f6..0e3533051d15 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_bin.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_bin.hpp @@ -12,7 +12,7 @@ namespace bb { class perm_main_bin_permutation_settings { public: // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 5; + 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 @@ -50,11 +50,13 @@ class perm_main_bin_permutation_settings { in.avm_main_bin_sel, in.avm_main_bin_sel, in.avm_binary_start, + in.avm_main_clk, in.avm_main_ia, in.avm_main_ib, in.avm_main_ic, in.avm_main_bin_op_id, in.avm_main_r_in_tag, + in.avm_binary_clk, in.avm_binary_acc_ia, in.avm_binary_acc_ib, in.avm_binary_acc_ic, @@ -86,11 +88,13 @@ class perm_main_bin_permutation_settings { in.avm_main_bin_sel, in.avm_main_bin_sel, in.avm_binary_start, + in.avm_main_clk, in.avm_main_ia, in.avm_main_ib, in.avm_main_ic, in.avm_main_bin_op_id, in.avm_main_r_in_tag, + in.avm_binary_clk, in.avm_binary_acc_ia, in.avm_binary_acc_ib, in.avm_binary_acc_ic, diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_cmp.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_cmp.hpp index 4ef873ea226d..362f4321566c 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_cmp.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_cmp.hpp @@ -12,7 +12,7 @@ namespace bb { class perm_main_cmp_permutation_settings { public: // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 3; + constexpr static size_t COLUMNS_PER_SET = 4; /** * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the @@ -23,7 +23,7 @@ class perm_main_cmp_permutation_settings { template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { - return (in.avm_main_cmp_sel == 1 || in.avm_cmp_cmp_sel == 1); + return (in.avm_main_cmp_sel == 1 || in.avm_alu_cmp_sel == 1); } /** @@ -49,13 +49,15 @@ class perm_main_cmp_permutation_settings { return std::forward_as_tuple(in.perm_main_cmp, in.avm_main_cmp_sel, in.avm_main_cmp_sel, - in.avm_cmp_cmp_sel, + in.avm_alu_cmp_sel, + in.avm_main_clk, in.avm_main_ia, in.avm_main_ib, in.avm_main_ic, - in.avm_cmp_ia, - in.avm_cmp_ib, - in.avm_cmp_ic); + in.avm_alu_clk, + in.avm_alu_ia, + in.avm_alu_ib, + in.avm_alu_ic); } /** @@ -81,13 +83,15 @@ class perm_main_cmp_permutation_settings { return std::forward_as_tuple(in.perm_main_cmp, in.avm_main_cmp_sel, in.avm_main_cmp_sel, - in.avm_cmp_cmp_sel, + in.avm_alu_cmp_sel, + in.avm_main_clk, in.avm_main_ia, in.avm_main_ib, in.avm_main_ic, - in.avm_cmp_ia, - in.avm_cmp_ib, - in.avm_cmp_ic); + in.avm_alu_clk, + in.avm_alu_ia, + in.avm_alu_ib, + in.avm_alu_ic); } }; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.cpp index 42668cabb8d3..0c544738d9ed 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.cpp @@ -1,4 +1,5 @@ #include "avm_alu_trace.hpp" +#include namespace bb::avm_trace { @@ -431,4 +432,44 @@ FF AvmAluTraceBuilder::op_eq(FF const& a, FF const& b, AvmMemoryTag in_tag, uint return res; } +/** + * @brief Build Alu trace and return a boolean based on equality of operands of type defined by in_tag. + * + * @param a Left operand of the equality + * @param b Right operand of the equality + * @param in_tag Instruction tag defining the number of bits for equality + * @param clk Clock referring to the operation in the main trace. + * + * @return FF The boolean result of equality casted to a finite field element + */ + +FF AvmAluTraceBuilder::op_lt(FF const& a, FF const& b, AvmMemoryTag in_tag, uint32_t const clk) +{ + FF c = a < b ? FF ::one() : FF::zero(); + + alu_trace.push_back(AvmAluTraceBuilder::AluTraceEntry { + .alu_clk = clk, .alu_op_eq = true, .alu_ff_tag = in_tag == AvmMemoryTag::FF, + .alu_u8_tag = in_tag == AvmMemoryTag::U8, .alu_u16_tag = in_tag == AvmMemoryTag::U16, + .alu_u32_tag = in_tag == AvmMemoryTag::U32, .alu_u64_tag = in_tag == AvmMemoryTag::U64, + .alu_u128_tag = in_tag == AvmMemoryTag::U128, .alu_ia = a, .alu_ib = b, .alu_ic = res, + .alu_op_eq_diff_inv = inv_c, .input_ia = b, .input_ib = a, bool borrow, + + uint128_t a_lo; + uint128_t a_hi; + uint128_t b_lo; + uint128_t b_hi; + + uint128_t p_sub_a_lo; + uint128_t p_sub_a_hi; + bool p_a_borrow; + uint128_t p_sub_b_lo; + uint128_t p_sub_b_hi; + bool p_b_borrow; + + uint128_t res_lo; + uint128_t res_hi; + }); + + return res; +} } // namespace bb::avm_trace diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.hpp index 736a1896c1df..ec9e53d4b97d 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.hpp @@ -1,6 +1,7 @@ #pragma once #include "avm_common.hpp" +#include "barretenberg/numeric/uint128/uint128.hpp" namespace bb::avm_trace { @@ -15,6 +16,8 @@ class AvmAluTraceBuilder { bool alu_op_mul = false; bool alu_op_not = false; bool alu_op_eq = false; + bool alu_op_lt = false; + bool alu_op_lte = false; bool alu_ff_tag = false; bool alu_u8_tag = false; @@ -37,6 +40,26 @@ class AvmAluTraceBuilder { uint64_t alu_u64_r0{}; FF alu_op_eq_diff_inv{}; + + // Comparison check + FF input_ia; + FF input_ib; + bool borrow; + + uint128_t a_lo; + uint128_t a_hi; + uint128_t b_lo; + uint128_t b_hi; + + uint128_t p_sub_a_lo; + uint128_t p_sub_a_hi; + bool p_a_borrow; + uint128_t p_sub_b_lo; + uint128_t p_sub_b_hi; + bool p_b_borrow; + + uint128_t res_lo; + uint128_t res_hi; }; AvmAluTraceBuilder(); @@ -48,6 +71,8 @@ class AvmAluTraceBuilder { FF op_mul(FF const& a, FF const& b, AvmMemoryTag in_tag, uint32_t clk); FF op_not(FF const& a, AvmMemoryTag in_tag, uint32_t clk); FF op_eq(FF const& a, FF const& b, AvmMemoryTag in_tag, uint32_t clk); + FF op_lt(FF const& a, FF const& b, AvmMemoryTag in_tag, uint32_t clk); + FF op_lte(FF const& a, FF const& b, AvmMemoryTag in_tag, uint32_t clk); private: std::vector alu_trace; 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 4849b6620947..8697cb8d2a45 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp @@ -13,7 +13,6 @@ #include "barretenberg/relations/generated/avm/avm_alu.hpp" #include "barretenberg/relations/generated/avm/avm_binary.hpp" -#include "barretenberg/relations/generated/avm/avm_cmp.hpp" #include "barretenberg/relations/generated/avm/avm_main.hpp" #include "barretenberg/relations/generated/avm/avm_mem.hpp" #include "barretenberg/relations/generated/avm/incl_main_tag_err.hpp" @@ -36,47 +35,49 @@ namespace bb { template struct AvmFullRow { FF avm_main_clk{}; FF avm_main_first{}; - FF avm_mem_clk{}; - FF avm_mem_sub_clk{}; - FF avm_mem_addr{}; - FF avm_mem_tag{}; - FF avm_mem_val{}; - FF avm_mem_lastAccess{}; - FF avm_mem_last{}; - FF avm_mem_rw{}; - FF avm_mem_r_in_tag{}; - FF avm_mem_w_in_tag{}; - FF avm_mem_op_a{}; - FF avm_mem_op_b{}; - FF avm_mem_op_c{}; - FF avm_mem_ind_op_a{}; - FF avm_mem_ind_op_b{}; - FF avm_mem_ind_op_c{}; - FF avm_mem_sel_mov{}; - FF avm_mem_tag_err{}; - FF avm_mem_one_min_inv{}; + FF avm_alu_a_hi{}; + FF avm_alu_a_lo{}; + FF avm_alu_alu_sel{}; + FF avm_alu_b_hi{}; + FF avm_alu_b_lo{}; + FF avm_alu_borrow{}; + FF avm_alu_cf{}; FF avm_alu_clk{}; + FF avm_alu_cmp_sel{}; + FF avm_alu_ff_tag{}; FF avm_alu_ia{}; FF avm_alu_ib{}; FF avm_alu_ic{}; + FF avm_alu_in_tag{}; + FF avm_alu_input_ia{}; + FF avm_alu_input_ib{}; + FF avm_alu_lt_sel{}; + FF avm_alu_lte_sel{}; FF avm_alu_op_add{}; - FF avm_alu_op_sub{}; - FF avm_alu_op_mul{}; FF avm_alu_op_div{}; - FF avm_alu_op_not{}; FF avm_alu_op_eq{}; - FF avm_alu_alu_sel{}; - FF avm_alu_in_tag{}; - FF avm_alu_ff_tag{}; - FF avm_alu_u8_tag{}; - FF avm_alu_u16_tag{}; - FF avm_alu_u32_tag{}; - FF avm_alu_u64_tag{}; + FF avm_alu_op_eq_diff_inv{}; + FF avm_alu_op_mul{}; + FF avm_alu_op_not{}; + FF avm_alu_op_sub{}; + FF avm_alu_p_a_borrow{}; + FF avm_alu_p_b_borrow{}; + FF avm_alu_p_sub_a_hi{}; + FF avm_alu_p_sub_a_lo{}; + FF avm_alu_p_sub_b_hi{}; + FF avm_alu_p_sub_b_lo{}; + FF avm_alu_res_hi{}; + FF avm_alu_res_lo{}; + FF avm_alu_rng_chk_remaining{}; + FF avm_alu_rng_chk_sel{}; FF avm_alu_u128_tag{}; - FF avm_alu_u8_r0{}; - FF avm_alu_u8_r1{}; FF avm_alu_u16_r0{}; FF avm_alu_u16_r1{}; + FF avm_alu_u16_r10{}; + FF avm_alu_u16_r11{}; + FF avm_alu_u16_r12{}; + FF avm_alu_u16_r13{}; + FF avm_alu_u16_r14{}; FF avm_alu_u16_r2{}; FF avm_alu_u16_r3{}; FF avm_alu_u16_r4{}; @@ -85,107 +86,100 @@ template struct AvmFullRow { FF avm_alu_u16_r7{}; FF avm_alu_u16_r8{}; FF avm_alu_u16_r9{}; - FF avm_alu_u16_r10{}; - FF avm_alu_u16_r11{}; - FF avm_alu_u16_r12{}; - FF avm_alu_u16_r13{}; - FF avm_alu_u16_r14{}; + FF avm_alu_u16_tag{}; + FF avm_alu_u32_tag{}; FF avm_alu_u64_r0{}; - FF avm_alu_cf{}; - FF avm_alu_op_eq_diff_inv{}; - FF avm_byte_lookup_table_op_id{}; - FF avm_byte_lookup_table_input_a{}; - FF avm_byte_lookup_table_input_b{}; - FF avm_byte_lookup_table_output{}; - FF avm_byte_lookup_bin_sel{}; - FF avm_byte_lookup_table_in_tags{}; - FF avm_byte_lookup_table_byte_lengths{}; - FF avm_binary_clk{}; - FF avm_binary_bin_sel{}; + FF avm_alu_u64_tag{}; + FF avm_alu_u8_r0{}; + FF avm_alu_u8_r1{}; + FF avm_alu_u8_tag{}; FF avm_binary_acc_ia{}; FF avm_binary_acc_ib{}; FF avm_binary_acc_ic{}; - FF avm_binary_in_tag{}; - FF avm_binary_op_id{}; + FF avm_binary_bin_sel{}; + FF avm_binary_clk{}; FF avm_binary_ia_bytes{}; FF avm_binary_ib_bytes{}; FF avm_binary_ic_bytes{}; - FF avm_binary_start{}; + FF avm_binary_in_tag{}; FF avm_binary_mem_tag_ctr{}; FF avm_binary_mem_tag_ctr_inv{}; - FF avm_cmp_cmp_clk{}; - FF avm_cmp_ia{}; - FF avm_cmp_ib{}; - FF avm_cmp_ic{}; - FF avm_cmp_lt_sel{}; - FF avm_cmp_lte_sel{}; - FF avm_cmp_cmp_sel{}; - FF avm_cmp_input_ia{}; - FF avm_cmp_input_ib{}; - FF avm_cmp_a_lo{}; - FF avm_cmp_a_hi{}; - FF avm_cmp_b_lo{}; - FF avm_cmp_b_hi{}; - FF avm_cmp_borrow{}; - FF avm_cmp_p_lo{}; - FF avm_cmp_p_hi{}; - FF avm_cmp_p_sub_a_lo{}; - FF avm_cmp_p_sub_a_hi{}; - FF avm_cmp_p_a_borrow{}; - FF avm_cmp_p_sub_b_lo{}; - FF avm_cmp_p_sub_b_hi{}; - FF avm_cmp_p_b_borrow{}; - FF avm_cmp_res_lo{}; - FF avm_cmp_res_hi{}; - FF avm_cmp_lt_query{}; - FF avm_main_sel_rng_8{}; - FF avm_main_sel_rng_16{}; - FF avm_main_pc{}; - FF avm_main_internal_return_ptr{}; - FF avm_main_sel_internal_call{}; - FF avm_main_sel_internal_return{}; - FF avm_main_sel_jump{}; - FF avm_main_sel_halt{}; - FF avm_main_sel_mov{}; - FF avm_main_sel_op_add{}; - FF avm_main_sel_op_sub{}; - FF avm_main_sel_op_mul{}; - FF avm_main_sel_op_div{}; - FF avm_main_sel_op_not{}; - FF avm_main_sel_op_eq{}; - FF avm_main_sel_op_and{}; - FF avm_main_sel_op_or{}; - FF avm_main_sel_op_xor{}; - FF avm_main_sel_op_lt{}; - FF avm_main_sel_op_lte{}; + FF avm_binary_op_id{}; + FF avm_binary_start{}; + FF avm_byte_lookup_bin_sel{}; + FF avm_byte_lookup_table_byte_lengths{}; + FF avm_byte_lookup_table_in_tags{}; + FF avm_byte_lookup_table_input_a{}; + FF avm_byte_lookup_table_input_b{}; + FF avm_byte_lookup_table_op_id{}; + FF avm_byte_lookup_table_output{}; FF avm_main_alu_sel{}; + FF avm_main_bin_op_id{}; FF avm_main_bin_sel{}; FF avm_main_cmp_sel{}; - FF avm_main_r_in_tag{}; - FF avm_main_w_in_tag{}; - FF avm_main_op_err{}; - FF avm_main_tag_err{}; - FF avm_main_inv{}; FF avm_main_ia{}; FF avm_main_ib{}; FF avm_main_ic{}; - FF avm_main_mem_op_a{}; - FF avm_main_mem_op_b{}; - FF avm_main_mem_op_c{}; - FF avm_main_rwa{}; - FF avm_main_rwb{}; - FF avm_main_rwc{}; FF avm_main_ind_a{}; FF avm_main_ind_b{}; FF avm_main_ind_c{}; FF avm_main_ind_op_a{}; FF avm_main_ind_op_b{}; FF avm_main_ind_op_c{}; + 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_last{}; - FF avm_main_bin_op_id{}; + FF avm_main_mem_op_a{}; + FF avm_main_mem_op_b{}; + FF avm_main_mem_op_c{}; + 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_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_op_add{}; + FF avm_main_sel_op_and{}; + FF avm_main_sel_op_div{}; + FF avm_main_sel_op_eq{}; + FF avm_main_sel_op_lt{}; + FF avm_main_sel_op_lte{}; + FF avm_main_sel_op_mul{}; + FF avm_main_sel_op_not{}; + FF avm_main_sel_op_or{}; + FF avm_main_sel_op_sub{}; + FF avm_main_sel_op_xor{}; + FF avm_main_sel_rng_16{}; + FF avm_main_sel_rng_8{}; + FF avm_main_tag_err{}; + FF avm_main_w_in_tag{}; + FF avm_mem_addr{}; + FF avm_mem_clk{}; + FF avm_mem_ind_op_a{}; + FF avm_mem_ind_op_b{}; + FF avm_mem_ind_op_c{}; + 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_r_in_tag{}; + FF avm_mem_rw{}; + FF avm_mem_sel_mov{}; + FF avm_mem_sub_clk{}; + FF avm_mem_tag{}; + FF avm_mem_tag_err{}; + FF avm_mem_val{}; + FF avm_mem_w_in_tag{}; FF perm_main_alu{}; FF perm_main_bin{}; FF perm_main_cmp{}; @@ -203,25 +197,35 @@ template struct AvmFullRow { FF lookup_byte_operations_counts{}; FF incl_main_tag_err_counts{}; FF incl_mem_tag_err_counts{}; + FF avm_alu_a_hi_shift{}; + FF avm_alu_a_lo_shift{}; + FF avm_alu_b_hi_shift{}; + FF avm_alu_b_lo_shift{}; + FF avm_alu_p_sub_a_hi_shift{}; + FF avm_alu_p_sub_a_lo_shift{}; + FF avm_alu_p_sub_b_hi_shift{}; + FF avm_alu_p_sub_b_lo_shift{}; + FF avm_alu_rng_chk_remaining_shift{}; + FF avm_alu_rng_chk_sel_shift{}; FF avm_alu_u16_r0_shift{}; + FF avm_alu_u16_r1_shift{}; + FF avm_alu_u16_r2_shift{}; FF avm_alu_u16_r3_shift{}; FF avm_alu_u16_r4_shift{}; - FF avm_alu_u16_r7_shift{}; - FF avm_alu_u16_r6_shift{}; - FF avm_alu_u16_r2_shift{}; FF avm_alu_u16_r5_shift{}; - FF avm_alu_u16_r1_shift{}; - FF avm_binary_acc_ic_shift{}; - FF avm_binary_op_id_shift{}; - FF avm_binary_mem_tag_ctr_shift{}; + FF avm_alu_u16_r6_shift{}; + FF avm_alu_u16_r7_shift{}; FF avm_binary_acc_ia_shift{}; FF avm_binary_acc_ib_shift{}; - FF avm_mem_tag_shift{}; + FF avm_binary_acc_ic_shift{}; + FF avm_binary_mem_tag_ctr_shift{}; + FF avm_binary_op_id_shift{}; + FF avm_main_internal_return_ptr_shift{}; + FF avm_main_pc_shift{}; FF avm_mem_addr_shift{}; - FF avm_mem_val_shift{}; FF avm_mem_rw_shift{}; - FF avm_main_pc_shift{}; - FF avm_main_internal_return_ptr_shift{}; + FF avm_mem_tag_shift{}; + FF avm_mem_val_shift{}; }; class AvmCircuitBuilder { @@ -234,8 +238,8 @@ class AvmCircuitBuilder { using Polynomial = Flavor::Polynomial; using ProverPolynomials = Flavor::ProverPolynomials; - static constexpr size_t num_fixed_columns = 188; - static constexpr size_t num_polys = 169; + static constexpr size_t num_fixed_columns = 193; + static constexpr size_t num_polys = 164; std::vector rows; void set_trace(std::vector&& trace) { rows = std::move(trace); } @@ -253,47 +257,49 @@ class AvmCircuitBuilder { for (size_t i = 0; i < rows.size(); i++) { polys.avm_main_clk[i] = rows[i].avm_main_clk; polys.avm_main_first[i] = rows[i].avm_main_first; - polys.avm_mem_clk[i] = rows[i].avm_mem_clk; - polys.avm_mem_sub_clk[i] = rows[i].avm_mem_sub_clk; - polys.avm_mem_addr[i] = rows[i].avm_mem_addr; - polys.avm_mem_tag[i] = rows[i].avm_mem_tag; - polys.avm_mem_val[i] = rows[i].avm_mem_val; - polys.avm_mem_lastAccess[i] = rows[i].avm_mem_lastAccess; - polys.avm_mem_last[i] = rows[i].avm_mem_last; - polys.avm_mem_rw[i] = rows[i].avm_mem_rw; - polys.avm_mem_r_in_tag[i] = rows[i].avm_mem_r_in_tag; - polys.avm_mem_w_in_tag[i] = rows[i].avm_mem_w_in_tag; - 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_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_sel_mov[i] = rows[i].avm_mem_sel_mov; - polys.avm_mem_tag_err[i] = rows[i].avm_mem_tag_err; - polys.avm_mem_one_min_inv[i] = rows[i].avm_mem_one_min_inv; + polys.avm_alu_a_hi[i] = rows[i].avm_alu_a_hi; + polys.avm_alu_a_lo[i] = rows[i].avm_alu_a_lo; + polys.avm_alu_alu_sel[i] = rows[i].avm_alu_alu_sel; + polys.avm_alu_b_hi[i] = rows[i].avm_alu_b_hi; + polys.avm_alu_b_lo[i] = rows[i].avm_alu_b_lo; + polys.avm_alu_borrow[i] = rows[i].avm_alu_borrow; + polys.avm_alu_cf[i] = rows[i].avm_alu_cf; polys.avm_alu_clk[i] = rows[i].avm_alu_clk; + polys.avm_alu_cmp_sel[i] = rows[i].avm_alu_cmp_sel; + polys.avm_alu_ff_tag[i] = rows[i].avm_alu_ff_tag; polys.avm_alu_ia[i] = rows[i].avm_alu_ia; polys.avm_alu_ib[i] = rows[i].avm_alu_ib; polys.avm_alu_ic[i] = rows[i].avm_alu_ic; + polys.avm_alu_in_tag[i] = rows[i].avm_alu_in_tag; + polys.avm_alu_input_ia[i] = rows[i].avm_alu_input_ia; + polys.avm_alu_input_ib[i] = rows[i].avm_alu_input_ib; + polys.avm_alu_lt_sel[i] = rows[i].avm_alu_lt_sel; + polys.avm_alu_lte_sel[i] = rows[i].avm_alu_lte_sel; polys.avm_alu_op_add[i] = rows[i].avm_alu_op_add; - polys.avm_alu_op_sub[i] = rows[i].avm_alu_op_sub; - polys.avm_alu_op_mul[i] = rows[i].avm_alu_op_mul; polys.avm_alu_op_div[i] = rows[i].avm_alu_op_div; - polys.avm_alu_op_not[i] = rows[i].avm_alu_op_not; polys.avm_alu_op_eq[i] = rows[i].avm_alu_op_eq; - polys.avm_alu_alu_sel[i] = rows[i].avm_alu_alu_sel; - polys.avm_alu_in_tag[i] = rows[i].avm_alu_in_tag; - polys.avm_alu_ff_tag[i] = rows[i].avm_alu_ff_tag; - polys.avm_alu_u8_tag[i] = rows[i].avm_alu_u8_tag; - polys.avm_alu_u16_tag[i] = rows[i].avm_alu_u16_tag; - polys.avm_alu_u32_tag[i] = rows[i].avm_alu_u32_tag; - polys.avm_alu_u64_tag[i] = rows[i].avm_alu_u64_tag; + polys.avm_alu_op_eq_diff_inv[i] = rows[i].avm_alu_op_eq_diff_inv; + polys.avm_alu_op_mul[i] = rows[i].avm_alu_op_mul; + polys.avm_alu_op_not[i] = rows[i].avm_alu_op_not; + polys.avm_alu_op_sub[i] = rows[i].avm_alu_op_sub; + polys.avm_alu_p_a_borrow[i] = rows[i].avm_alu_p_a_borrow; + polys.avm_alu_p_b_borrow[i] = rows[i].avm_alu_p_b_borrow; + polys.avm_alu_p_sub_a_hi[i] = rows[i].avm_alu_p_sub_a_hi; + polys.avm_alu_p_sub_a_lo[i] = rows[i].avm_alu_p_sub_a_lo; + polys.avm_alu_p_sub_b_hi[i] = rows[i].avm_alu_p_sub_b_hi; + polys.avm_alu_p_sub_b_lo[i] = rows[i].avm_alu_p_sub_b_lo; + polys.avm_alu_res_hi[i] = rows[i].avm_alu_res_hi; + polys.avm_alu_res_lo[i] = rows[i].avm_alu_res_lo; + polys.avm_alu_rng_chk_remaining[i] = rows[i].avm_alu_rng_chk_remaining; + polys.avm_alu_rng_chk_sel[i] = rows[i].avm_alu_rng_chk_sel; polys.avm_alu_u128_tag[i] = rows[i].avm_alu_u128_tag; - polys.avm_alu_u8_r0[i] = rows[i].avm_alu_u8_r0; - polys.avm_alu_u8_r1[i] = rows[i].avm_alu_u8_r1; polys.avm_alu_u16_r0[i] = rows[i].avm_alu_u16_r0; polys.avm_alu_u16_r1[i] = rows[i].avm_alu_u16_r1; + polys.avm_alu_u16_r10[i] = rows[i].avm_alu_u16_r10; + polys.avm_alu_u16_r11[i] = rows[i].avm_alu_u16_r11; + polys.avm_alu_u16_r12[i] = rows[i].avm_alu_u16_r12; + polys.avm_alu_u16_r13[i] = rows[i].avm_alu_u16_r13; + polys.avm_alu_u16_r14[i] = rows[i].avm_alu_u16_r14; polys.avm_alu_u16_r2[i] = rows[i].avm_alu_u16_r2; polys.avm_alu_u16_r3[i] = rows[i].avm_alu_u16_r3; polys.avm_alu_u16_r4[i] = rows[i].avm_alu_u16_r4; @@ -302,107 +308,100 @@ class AvmCircuitBuilder { polys.avm_alu_u16_r7[i] = rows[i].avm_alu_u16_r7; polys.avm_alu_u16_r8[i] = rows[i].avm_alu_u16_r8; polys.avm_alu_u16_r9[i] = rows[i].avm_alu_u16_r9; - polys.avm_alu_u16_r10[i] = rows[i].avm_alu_u16_r10; - polys.avm_alu_u16_r11[i] = rows[i].avm_alu_u16_r11; - polys.avm_alu_u16_r12[i] = rows[i].avm_alu_u16_r12; - polys.avm_alu_u16_r13[i] = rows[i].avm_alu_u16_r13; - polys.avm_alu_u16_r14[i] = rows[i].avm_alu_u16_r14; + polys.avm_alu_u16_tag[i] = rows[i].avm_alu_u16_tag; + polys.avm_alu_u32_tag[i] = rows[i].avm_alu_u32_tag; polys.avm_alu_u64_r0[i] = rows[i].avm_alu_u64_r0; - polys.avm_alu_cf[i] = rows[i].avm_alu_cf; - polys.avm_alu_op_eq_diff_inv[i] = rows[i].avm_alu_op_eq_diff_inv; - polys.avm_byte_lookup_table_op_id[i] = rows[i].avm_byte_lookup_table_op_id; - polys.avm_byte_lookup_table_input_a[i] = rows[i].avm_byte_lookup_table_input_a; - polys.avm_byte_lookup_table_input_b[i] = rows[i].avm_byte_lookup_table_input_b; - polys.avm_byte_lookup_table_output[i] = rows[i].avm_byte_lookup_table_output; - polys.avm_byte_lookup_bin_sel[i] = rows[i].avm_byte_lookup_bin_sel; - polys.avm_byte_lookup_table_in_tags[i] = rows[i].avm_byte_lookup_table_in_tags; - polys.avm_byte_lookup_table_byte_lengths[i] = rows[i].avm_byte_lookup_table_byte_lengths; - polys.avm_binary_clk[i] = rows[i].avm_binary_clk; - polys.avm_binary_bin_sel[i] = rows[i].avm_binary_bin_sel; + polys.avm_alu_u64_tag[i] = rows[i].avm_alu_u64_tag; + polys.avm_alu_u8_r0[i] = rows[i].avm_alu_u8_r0; + polys.avm_alu_u8_r1[i] = rows[i].avm_alu_u8_r1; + polys.avm_alu_u8_tag[i] = rows[i].avm_alu_u8_tag; polys.avm_binary_acc_ia[i] = rows[i].avm_binary_acc_ia; polys.avm_binary_acc_ib[i] = rows[i].avm_binary_acc_ib; polys.avm_binary_acc_ic[i] = rows[i].avm_binary_acc_ic; - polys.avm_binary_in_tag[i] = rows[i].avm_binary_in_tag; - polys.avm_binary_op_id[i] = rows[i].avm_binary_op_id; + polys.avm_binary_bin_sel[i] = rows[i].avm_binary_bin_sel; + polys.avm_binary_clk[i] = rows[i].avm_binary_clk; polys.avm_binary_ia_bytes[i] = rows[i].avm_binary_ia_bytes; polys.avm_binary_ib_bytes[i] = rows[i].avm_binary_ib_bytes; polys.avm_binary_ic_bytes[i] = rows[i].avm_binary_ic_bytes; - polys.avm_binary_start[i] = rows[i].avm_binary_start; + polys.avm_binary_in_tag[i] = rows[i].avm_binary_in_tag; polys.avm_binary_mem_tag_ctr[i] = rows[i].avm_binary_mem_tag_ctr; polys.avm_binary_mem_tag_ctr_inv[i] = rows[i].avm_binary_mem_tag_ctr_inv; - polys.avm_cmp_cmp_clk[i] = rows[i].avm_cmp_cmp_clk; - polys.avm_cmp_ia[i] = rows[i].avm_cmp_ia; - polys.avm_cmp_ib[i] = rows[i].avm_cmp_ib; - polys.avm_cmp_ic[i] = rows[i].avm_cmp_ic; - polys.avm_cmp_lt_sel[i] = rows[i].avm_cmp_lt_sel; - polys.avm_cmp_lte_sel[i] = rows[i].avm_cmp_lte_sel; - polys.avm_cmp_cmp_sel[i] = rows[i].avm_cmp_cmp_sel; - polys.avm_cmp_input_ia[i] = rows[i].avm_cmp_input_ia; - polys.avm_cmp_input_ib[i] = rows[i].avm_cmp_input_ib; - polys.avm_cmp_a_lo[i] = rows[i].avm_cmp_a_lo; - polys.avm_cmp_a_hi[i] = rows[i].avm_cmp_a_hi; - polys.avm_cmp_b_lo[i] = rows[i].avm_cmp_b_lo; - polys.avm_cmp_b_hi[i] = rows[i].avm_cmp_b_hi; - polys.avm_cmp_borrow[i] = rows[i].avm_cmp_borrow; - polys.avm_cmp_p_lo[i] = rows[i].avm_cmp_p_lo; - polys.avm_cmp_p_hi[i] = rows[i].avm_cmp_p_hi; - polys.avm_cmp_p_sub_a_lo[i] = rows[i].avm_cmp_p_sub_a_lo; - polys.avm_cmp_p_sub_a_hi[i] = rows[i].avm_cmp_p_sub_a_hi; - polys.avm_cmp_p_a_borrow[i] = rows[i].avm_cmp_p_a_borrow; - polys.avm_cmp_p_sub_b_lo[i] = rows[i].avm_cmp_p_sub_b_lo; - polys.avm_cmp_p_sub_b_hi[i] = rows[i].avm_cmp_p_sub_b_hi; - polys.avm_cmp_p_b_borrow[i] = rows[i].avm_cmp_p_b_borrow; - polys.avm_cmp_res_lo[i] = rows[i].avm_cmp_res_lo; - polys.avm_cmp_res_hi[i] = rows[i].avm_cmp_res_hi; - polys.avm_cmp_lt_query[i] = rows[i].avm_cmp_lt_query; - polys.avm_main_sel_rng_8[i] = rows[i].avm_main_sel_rng_8; - polys.avm_main_sel_rng_16[i] = rows[i].avm_main_sel_rng_16; - polys.avm_main_pc[i] = rows[i].avm_main_pc; - polys.avm_main_internal_return_ptr[i] = rows[i].avm_main_internal_return_ptr; - 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_halt[i] = rows[i].avm_main_sel_halt; - polys.avm_main_sel_mov[i] = rows[i].avm_main_sel_mov; - polys.avm_main_sel_op_add[i] = rows[i].avm_main_sel_op_add; - polys.avm_main_sel_op_sub[i] = rows[i].avm_main_sel_op_sub; - polys.avm_main_sel_op_mul[i] = rows[i].avm_main_sel_op_mul; - polys.avm_main_sel_op_div[i] = rows[i].avm_main_sel_op_div; - polys.avm_main_sel_op_not[i] = rows[i].avm_main_sel_op_not; - polys.avm_main_sel_op_eq[i] = rows[i].avm_main_sel_op_eq; - polys.avm_main_sel_op_and[i] = rows[i].avm_main_sel_op_and; - polys.avm_main_sel_op_or[i] = rows[i].avm_main_sel_op_or; - polys.avm_main_sel_op_xor[i] = rows[i].avm_main_sel_op_xor; - polys.avm_main_sel_op_lt[i] = rows[i].avm_main_sel_op_lt; - polys.avm_main_sel_op_lte[i] = rows[i].avm_main_sel_op_lte; + polys.avm_binary_op_id[i] = rows[i].avm_binary_op_id; + polys.avm_binary_start[i] = rows[i].avm_binary_start; + polys.avm_byte_lookup_bin_sel[i] = rows[i].avm_byte_lookup_bin_sel; + polys.avm_byte_lookup_table_byte_lengths[i] = rows[i].avm_byte_lookup_table_byte_lengths; + polys.avm_byte_lookup_table_in_tags[i] = rows[i].avm_byte_lookup_table_in_tags; + polys.avm_byte_lookup_table_input_a[i] = rows[i].avm_byte_lookup_table_input_a; + polys.avm_byte_lookup_table_input_b[i] = rows[i].avm_byte_lookup_table_input_b; + polys.avm_byte_lookup_table_op_id[i] = rows[i].avm_byte_lookup_table_op_id; + polys.avm_byte_lookup_table_output[i] = rows[i].avm_byte_lookup_table_output; polys.avm_main_alu_sel[i] = rows[i].avm_main_alu_sel; + polys.avm_main_bin_op_id[i] = rows[i].avm_main_bin_op_id; polys.avm_main_bin_sel[i] = rows[i].avm_main_bin_sel; polys.avm_main_cmp_sel[i] = rows[i].avm_main_cmp_sel; - polys.avm_main_r_in_tag[i] = rows[i].avm_main_r_in_tag; - polys.avm_main_w_in_tag[i] = rows[i].avm_main_w_in_tag; - polys.avm_main_op_err[i] = rows[i].avm_main_op_err; - polys.avm_main_tag_err[i] = rows[i].avm_main_tag_err; - polys.avm_main_inv[i] = rows[i].avm_main_inv; 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_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_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_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_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_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_last[i] = rows[i].avm_main_last; - polys.avm_main_bin_op_id[i] = rows[i].avm_main_bin_op_id; + 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_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_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_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; + polys.avm_main_sel_op_eq[i] = rows[i].avm_main_sel_op_eq; + polys.avm_main_sel_op_lt[i] = rows[i].avm_main_sel_op_lt; + polys.avm_main_sel_op_lte[i] = rows[i].avm_main_sel_op_lte; + polys.avm_main_sel_op_mul[i] = rows[i].avm_main_sel_op_mul; + polys.avm_main_sel_op_not[i] = rows[i].avm_main_sel_op_not; + polys.avm_main_sel_op_or[i] = rows[i].avm_main_sel_op_or; + polys.avm_main_sel_op_sub[i] = rows[i].avm_main_sel_op_sub; + polys.avm_main_sel_op_xor[i] = rows[i].avm_main_sel_op_xor; + polys.avm_main_sel_rng_16[i] = rows[i].avm_main_sel_rng_16; + polys.avm_main_sel_rng_8[i] = rows[i].avm_main_sel_rng_8; + polys.avm_main_tag_err[i] = rows[i].avm_main_tag_err; + polys.avm_main_w_in_tag[i] = rows[i].avm_main_w_in_tag; + polys.avm_mem_addr[i] = rows[i].avm_mem_addr; + polys.avm_mem_clk[i] = rows[i].avm_mem_clk; + 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_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_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_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; + 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 @@ -426,25 +425,35 @@ class AvmCircuitBuilder { polys.incl_mem_tag_err_counts[i] = rows[i].incl_mem_tag_err_counts; } + polys.avm_alu_a_hi_shift = Polynomial(polys.avm_alu_a_hi.shifted()); + polys.avm_alu_a_lo_shift = Polynomial(polys.avm_alu_a_lo.shifted()); + polys.avm_alu_b_hi_shift = Polynomial(polys.avm_alu_b_hi.shifted()); + polys.avm_alu_b_lo_shift = Polynomial(polys.avm_alu_b_lo.shifted()); + polys.avm_alu_p_sub_a_hi_shift = Polynomial(polys.avm_alu_p_sub_a_hi.shifted()); + polys.avm_alu_p_sub_a_lo_shift = Polynomial(polys.avm_alu_p_sub_a_lo.shifted()); + polys.avm_alu_p_sub_b_hi_shift = Polynomial(polys.avm_alu_p_sub_b_hi.shifted()); + polys.avm_alu_p_sub_b_lo_shift = Polynomial(polys.avm_alu_p_sub_b_lo.shifted()); + polys.avm_alu_rng_chk_remaining_shift = Polynomial(polys.avm_alu_rng_chk_remaining.shifted()); + polys.avm_alu_rng_chk_sel_shift = Polynomial(polys.avm_alu_rng_chk_sel.shifted()); polys.avm_alu_u16_r0_shift = Polynomial(polys.avm_alu_u16_r0.shifted()); + polys.avm_alu_u16_r1_shift = Polynomial(polys.avm_alu_u16_r1.shifted()); + polys.avm_alu_u16_r2_shift = Polynomial(polys.avm_alu_u16_r2.shifted()); polys.avm_alu_u16_r3_shift = Polynomial(polys.avm_alu_u16_r3.shifted()); polys.avm_alu_u16_r4_shift = Polynomial(polys.avm_alu_u16_r4.shifted()); - polys.avm_alu_u16_r7_shift = Polynomial(polys.avm_alu_u16_r7.shifted()); - polys.avm_alu_u16_r6_shift = Polynomial(polys.avm_alu_u16_r6.shifted()); - polys.avm_alu_u16_r2_shift = Polynomial(polys.avm_alu_u16_r2.shifted()); polys.avm_alu_u16_r5_shift = Polynomial(polys.avm_alu_u16_r5.shifted()); - polys.avm_alu_u16_r1_shift = Polynomial(polys.avm_alu_u16_r1.shifted()); - polys.avm_binary_acc_ic_shift = Polynomial(polys.avm_binary_acc_ic.shifted()); - polys.avm_binary_op_id_shift = Polynomial(polys.avm_binary_op_id.shifted()); - polys.avm_binary_mem_tag_ctr_shift = Polynomial(polys.avm_binary_mem_tag_ctr.shifted()); + polys.avm_alu_u16_r6_shift = Polynomial(polys.avm_alu_u16_r6.shifted()); + polys.avm_alu_u16_r7_shift = Polynomial(polys.avm_alu_u16_r7.shifted()); polys.avm_binary_acc_ia_shift = Polynomial(polys.avm_binary_acc_ia.shifted()); polys.avm_binary_acc_ib_shift = Polynomial(polys.avm_binary_acc_ib.shifted()); - polys.avm_mem_tag_shift = Polynomial(polys.avm_mem_tag.shifted()); + polys.avm_binary_acc_ic_shift = Polynomial(polys.avm_binary_acc_ic.shifted()); + polys.avm_binary_mem_tag_ctr_shift = Polynomial(polys.avm_binary_mem_tag_ctr.shifted()); + polys.avm_binary_op_id_shift = Polynomial(polys.avm_binary_op_id.shifted()); + polys.avm_main_internal_return_ptr_shift = Polynomial(polys.avm_main_internal_return_ptr.shifted()); + polys.avm_main_pc_shift = Polynomial(polys.avm_main_pc.shifted()); polys.avm_mem_addr_shift = Polynomial(polys.avm_mem_addr.shifted()); - polys.avm_mem_val_shift = Polynomial(polys.avm_mem_val.shifted()); polys.avm_mem_rw_shift = Polynomial(polys.avm_mem_rw.shifted()); - polys.avm_main_pc_shift = Polynomial(polys.avm_main_pc.shifted()); - polys.avm_main_internal_return_ptr_shift = Polynomial(polys.avm_main_internal_return_ptr.shifted()); + polys.avm_mem_tag_shift = Polynomial(polys.avm_mem_tag.shifted()); + polys.avm_mem_val_shift = Polynomial(polys.avm_mem_val.shifted()); return polys; } @@ -524,18 +533,14 @@ class AvmCircuitBuilder { Avm_vm::get_relation_label_avm_binary)) { return false; } - if (!evaluate_relation.template operator()>("avm_cmp", - Avm_vm::get_relation_label_avm_cmp)) { + if (!evaluate_relation.template operator()>("avm_main", + Avm_vm::get_relation_label_avm_main)) { return false; } if (!evaluate_relation.template operator()>("avm_mem", Avm_vm::get_relation_label_avm_mem)) { return false; } - if (!evaluate_relation.template operator()>("avm_main", - Avm_vm::get_relation_label_avm_main)) { - return false; - } if (!evaluate_logderivative.template operator()>("PERM_MAIN_ALU")) { 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 4167070067e0..8c6d08990a46 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp @@ -15,7 +15,6 @@ #include "barretenberg/polynomials/polynomial.hpp" #include "barretenberg/relations/generated/avm/avm_alu.hpp" #include "barretenberg/relations/generated/avm/avm_binary.hpp" -#include "barretenberg/relations/generated/avm/avm_cmp.hpp" #include "barretenberg/relations/generated/avm/avm_main.hpp" #include "barretenberg/relations/generated/avm/avm_mem.hpp" #include "barretenberg/relations/generated/avm/incl_main_tag_err.hpp" @@ -52,11 +51,11 @@ class AvmFlavor { using RelationSeparator = FF; static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 2; - static constexpr size_t NUM_WITNESS_ENTITIES = 167; + static constexpr size_t NUM_WITNESS_ENTITIES = 162; 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 = 188; + static constexpr size_t NUM_ALL_ENTITIES = 193; using GrandProductRelations = std::tuple, perm_main_bin_relation, @@ -73,9 +72,8 @@ class AvmFlavor { using Relations = std::tuple, Avm_vm::avm_binary, - Avm_vm::avm_cmp, - Avm_vm::avm_mem, Avm_vm::avm_main, + Avm_vm::avm_mem, perm_main_alu_relation, perm_main_bin_relation, perm_main_cmp_relation, @@ -122,47 +120,49 @@ class AvmFlavor { template class WitnessEntities { public: DEFINE_FLAVOR_MEMBERS(DataType, - avm_mem_clk, - avm_mem_sub_clk, - avm_mem_addr, - avm_mem_tag, - avm_mem_val, - avm_mem_lastAccess, - avm_mem_last, - avm_mem_rw, - avm_mem_r_in_tag, - avm_mem_w_in_tag, - 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_sel_mov, - avm_mem_tag_err, - avm_mem_one_min_inv, + avm_alu_a_hi, + avm_alu_a_lo, + avm_alu_alu_sel, + avm_alu_b_hi, + avm_alu_b_lo, + avm_alu_borrow, + avm_alu_cf, avm_alu_clk, + avm_alu_cmp_sel, + avm_alu_ff_tag, avm_alu_ia, avm_alu_ib, avm_alu_ic, + avm_alu_in_tag, + avm_alu_input_ia, + avm_alu_input_ib, + avm_alu_lt_sel, + avm_alu_lte_sel, avm_alu_op_add, - avm_alu_op_sub, - avm_alu_op_mul, avm_alu_op_div, - avm_alu_op_not, avm_alu_op_eq, - avm_alu_alu_sel, - avm_alu_in_tag, - avm_alu_ff_tag, - avm_alu_u8_tag, - avm_alu_u16_tag, - avm_alu_u32_tag, - avm_alu_u64_tag, + avm_alu_op_eq_diff_inv, + avm_alu_op_mul, + avm_alu_op_not, + avm_alu_op_sub, + avm_alu_p_a_borrow, + avm_alu_p_b_borrow, + avm_alu_p_sub_a_hi, + avm_alu_p_sub_a_lo, + avm_alu_p_sub_b_hi, + avm_alu_p_sub_b_lo, + avm_alu_res_hi, + avm_alu_res_lo, + avm_alu_rng_chk_remaining, + avm_alu_rng_chk_sel, avm_alu_u128_tag, - avm_alu_u8_r0, - avm_alu_u8_r1, avm_alu_u16_r0, avm_alu_u16_r1, + avm_alu_u16_r10, + avm_alu_u16_r11, + avm_alu_u16_r12, + avm_alu_u16_r13, + avm_alu_u16_r14, avm_alu_u16_r2, avm_alu_u16_r3, avm_alu_u16_r4, @@ -171,107 +171,100 @@ class AvmFlavor { avm_alu_u16_r7, avm_alu_u16_r8, avm_alu_u16_r9, - avm_alu_u16_r10, - avm_alu_u16_r11, - avm_alu_u16_r12, - avm_alu_u16_r13, - avm_alu_u16_r14, + avm_alu_u16_tag, + avm_alu_u32_tag, avm_alu_u64_r0, - avm_alu_cf, - avm_alu_op_eq_diff_inv, - avm_byte_lookup_table_op_id, - avm_byte_lookup_table_input_a, - avm_byte_lookup_table_input_b, - avm_byte_lookup_table_output, - avm_byte_lookup_bin_sel, - avm_byte_lookup_table_in_tags, - avm_byte_lookup_table_byte_lengths, - avm_binary_clk, - avm_binary_bin_sel, + avm_alu_u64_tag, + avm_alu_u8_r0, + avm_alu_u8_r1, + avm_alu_u8_tag, avm_binary_acc_ia, avm_binary_acc_ib, avm_binary_acc_ic, - avm_binary_in_tag, - avm_binary_op_id, + avm_binary_bin_sel, + avm_binary_clk, avm_binary_ia_bytes, avm_binary_ib_bytes, avm_binary_ic_bytes, - avm_binary_start, + avm_binary_in_tag, avm_binary_mem_tag_ctr, avm_binary_mem_tag_ctr_inv, - avm_cmp_cmp_clk, - avm_cmp_ia, - avm_cmp_ib, - avm_cmp_ic, - avm_cmp_lt_sel, - avm_cmp_lte_sel, - avm_cmp_cmp_sel, - avm_cmp_input_ia, - avm_cmp_input_ib, - avm_cmp_a_lo, - avm_cmp_a_hi, - avm_cmp_b_lo, - avm_cmp_b_hi, - avm_cmp_borrow, - avm_cmp_p_lo, - avm_cmp_p_hi, - avm_cmp_p_sub_a_lo, - avm_cmp_p_sub_a_hi, - avm_cmp_p_a_borrow, - avm_cmp_p_sub_b_lo, - avm_cmp_p_sub_b_hi, - avm_cmp_p_b_borrow, - avm_cmp_res_lo, - avm_cmp_res_hi, - avm_cmp_lt_query, - avm_main_sel_rng_8, - avm_main_sel_rng_16, - avm_main_pc, - avm_main_internal_return_ptr, - avm_main_sel_internal_call, - avm_main_sel_internal_return, - avm_main_sel_jump, - avm_main_sel_halt, - avm_main_sel_mov, - avm_main_sel_op_add, - avm_main_sel_op_sub, - avm_main_sel_op_mul, - avm_main_sel_op_div, - 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_sel_op_lt, - avm_main_sel_op_lte, + avm_binary_op_id, + avm_binary_start, + avm_byte_lookup_bin_sel, + avm_byte_lookup_table_byte_lengths, + avm_byte_lookup_table_in_tags, + avm_byte_lookup_table_input_a, + avm_byte_lookup_table_input_b, + avm_byte_lookup_table_op_id, + avm_byte_lookup_table_output, avm_main_alu_sel, + avm_main_bin_op_id, avm_main_bin_sel, avm_main_cmp_sel, - avm_main_r_in_tag, - avm_main_w_in_tag, - avm_main_op_err, - avm_main_tag_err, - avm_main_inv, avm_main_ia, avm_main_ib, avm_main_ic, - avm_main_mem_op_a, - avm_main_mem_op_b, - avm_main_mem_op_c, - avm_main_rwa, - avm_main_rwb, - avm_main_rwc, avm_main_ind_a, avm_main_ind_b, avm_main_ind_c, avm_main_ind_op_a, avm_main_ind_op_b, avm_main_ind_op_c, + 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_last, - avm_main_bin_op_id, + avm_main_mem_op_a, + avm_main_mem_op_b, + avm_main_mem_op_c, + avm_main_op_err, + avm_main_pc, + avm_main_r_in_tag, + avm_main_rwa, + avm_main_rwb, + avm_main_rwc, + 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_op_add, + avm_main_sel_op_and, + avm_main_sel_op_div, + avm_main_sel_op_eq, + avm_main_sel_op_lt, + avm_main_sel_op_lte, + avm_main_sel_op_mul, + avm_main_sel_op_not, + avm_main_sel_op_or, + avm_main_sel_op_sub, + avm_main_sel_op_xor, + avm_main_sel_rng_16, + avm_main_sel_rng_8, + avm_main_tag_err, + avm_main_w_in_tag, + avm_mem_addr, + avm_mem_clk, + avm_mem_ind_op_a, + avm_mem_ind_op_b, + avm_mem_ind_op_c, + 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_r_in_tag, + avm_mem_rw, + avm_mem_sel_mov, + avm_mem_sub_clk, + avm_mem_tag, + avm_mem_tag_err, + avm_mem_val, + avm_mem_w_in_tag, perm_main_alu, perm_main_bin, perm_main_cmp, @@ -292,47 +285,49 @@ class AvmFlavor { RefVector get_wires() { - return { avm_mem_clk, - avm_mem_sub_clk, - avm_mem_addr, - avm_mem_tag, - avm_mem_val, - avm_mem_lastAccess, - avm_mem_last, - avm_mem_rw, - avm_mem_r_in_tag, - avm_mem_w_in_tag, - 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_sel_mov, - avm_mem_tag_err, - avm_mem_one_min_inv, + return { avm_alu_a_hi, + avm_alu_a_lo, + avm_alu_alu_sel, + avm_alu_b_hi, + avm_alu_b_lo, + avm_alu_borrow, + avm_alu_cf, avm_alu_clk, + avm_alu_cmp_sel, + avm_alu_ff_tag, avm_alu_ia, avm_alu_ib, avm_alu_ic, + avm_alu_in_tag, + avm_alu_input_ia, + avm_alu_input_ib, + avm_alu_lt_sel, + avm_alu_lte_sel, avm_alu_op_add, - avm_alu_op_sub, - avm_alu_op_mul, avm_alu_op_div, - avm_alu_op_not, avm_alu_op_eq, - avm_alu_alu_sel, - avm_alu_in_tag, - avm_alu_ff_tag, - avm_alu_u8_tag, - avm_alu_u16_tag, - avm_alu_u32_tag, - avm_alu_u64_tag, + avm_alu_op_eq_diff_inv, + avm_alu_op_mul, + avm_alu_op_not, + avm_alu_op_sub, + avm_alu_p_a_borrow, + avm_alu_p_b_borrow, + avm_alu_p_sub_a_hi, + avm_alu_p_sub_a_lo, + avm_alu_p_sub_b_hi, + avm_alu_p_sub_b_lo, + avm_alu_res_hi, + avm_alu_res_lo, + avm_alu_rng_chk_remaining, + avm_alu_rng_chk_sel, avm_alu_u128_tag, - avm_alu_u8_r0, - avm_alu_u8_r1, avm_alu_u16_r0, avm_alu_u16_r1, + avm_alu_u16_r10, + avm_alu_u16_r11, + avm_alu_u16_r12, + avm_alu_u16_r13, + avm_alu_u16_r14, avm_alu_u16_r2, avm_alu_u16_r3, avm_alu_u16_r4, @@ -341,107 +336,100 @@ class AvmFlavor { avm_alu_u16_r7, avm_alu_u16_r8, avm_alu_u16_r9, - avm_alu_u16_r10, - avm_alu_u16_r11, - avm_alu_u16_r12, - avm_alu_u16_r13, - avm_alu_u16_r14, + avm_alu_u16_tag, + avm_alu_u32_tag, avm_alu_u64_r0, - avm_alu_cf, - avm_alu_op_eq_diff_inv, - avm_byte_lookup_table_op_id, - avm_byte_lookup_table_input_a, - avm_byte_lookup_table_input_b, - avm_byte_lookup_table_output, - avm_byte_lookup_bin_sel, - avm_byte_lookup_table_in_tags, - avm_byte_lookup_table_byte_lengths, - avm_binary_clk, - avm_binary_bin_sel, + avm_alu_u64_tag, + avm_alu_u8_r0, + avm_alu_u8_r1, + avm_alu_u8_tag, avm_binary_acc_ia, avm_binary_acc_ib, avm_binary_acc_ic, - avm_binary_in_tag, - avm_binary_op_id, + avm_binary_bin_sel, + avm_binary_clk, avm_binary_ia_bytes, avm_binary_ib_bytes, avm_binary_ic_bytes, - avm_binary_start, + avm_binary_in_tag, avm_binary_mem_tag_ctr, avm_binary_mem_tag_ctr_inv, - avm_cmp_cmp_clk, - avm_cmp_ia, - avm_cmp_ib, - avm_cmp_ic, - avm_cmp_lt_sel, - avm_cmp_lte_sel, - avm_cmp_cmp_sel, - avm_cmp_input_ia, - avm_cmp_input_ib, - avm_cmp_a_lo, - avm_cmp_a_hi, - avm_cmp_b_lo, - avm_cmp_b_hi, - avm_cmp_borrow, - avm_cmp_p_lo, - avm_cmp_p_hi, - avm_cmp_p_sub_a_lo, - avm_cmp_p_sub_a_hi, - avm_cmp_p_a_borrow, - avm_cmp_p_sub_b_lo, - avm_cmp_p_sub_b_hi, - avm_cmp_p_b_borrow, - avm_cmp_res_lo, - avm_cmp_res_hi, - avm_cmp_lt_query, - avm_main_sel_rng_8, - avm_main_sel_rng_16, - avm_main_pc, - avm_main_internal_return_ptr, - avm_main_sel_internal_call, - avm_main_sel_internal_return, - avm_main_sel_jump, - avm_main_sel_halt, - avm_main_sel_mov, - avm_main_sel_op_add, - avm_main_sel_op_sub, - avm_main_sel_op_mul, - avm_main_sel_op_div, - 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_sel_op_lt, - avm_main_sel_op_lte, + avm_binary_op_id, + avm_binary_start, + avm_byte_lookup_bin_sel, + avm_byte_lookup_table_byte_lengths, + avm_byte_lookup_table_in_tags, + avm_byte_lookup_table_input_a, + avm_byte_lookup_table_input_b, + avm_byte_lookup_table_op_id, + avm_byte_lookup_table_output, avm_main_alu_sel, + avm_main_bin_op_id, avm_main_bin_sel, avm_main_cmp_sel, - avm_main_r_in_tag, - avm_main_w_in_tag, - avm_main_op_err, - avm_main_tag_err, - avm_main_inv, avm_main_ia, avm_main_ib, avm_main_ic, - avm_main_mem_op_a, - avm_main_mem_op_b, - avm_main_mem_op_c, - avm_main_rwa, - avm_main_rwb, - avm_main_rwc, avm_main_ind_a, avm_main_ind_b, avm_main_ind_c, avm_main_ind_op_a, avm_main_ind_op_b, avm_main_ind_op_c, + 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_last, - avm_main_bin_op_id, + avm_main_mem_op_a, + avm_main_mem_op_b, + avm_main_mem_op_c, + avm_main_op_err, + avm_main_pc, + avm_main_r_in_tag, + avm_main_rwa, + avm_main_rwb, + avm_main_rwc, + 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_op_add, + avm_main_sel_op_and, + avm_main_sel_op_div, + avm_main_sel_op_eq, + avm_main_sel_op_lt, + avm_main_sel_op_lte, + avm_main_sel_op_mul, + avm_main_sel_op_not, + avm_main_sel_op_or, + avm_main_sel_op_sub, + avm_main_sel_op_xor, + avm_main_sel_rng_16, + avm_main_sel_rng_8, + avm_main_tag_err, + avm_main_w_in_tag, + avm_mem_addr, + avm_mem_clk, + avm_mem_ind_op_a, + avm_mem_ind_op_b, + avm_mem_ind_op_c, + 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_r_in_tag, + avm_mem_rw, + avm_mem_sel_mov, + avm_mem_sub_clk, + avm_mem_tag, + avm_mem_tag_err, + avm_mem_val, + avm_mem_w_in_tag, perm_main_alu, perm_main_bin, perm_main_cmp, @@ -467,47 +455,49 @@ class AvmFlavor { DEFINE_FLAVOR_MEMBERS(DataType, avm_main_clk, avm_main_first, - avm_mem_clk, - avm_mem_sub_clk, - avm_mem_addr, - avm_mem_tag, - avm_mem_val, - avm_mem_lastAccess, - avm_mem_last, - avm_mem_rw, - avm_mem_r_in_tag, - avm_mem_w_in_tag, - 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_sel_mov, - avm_mem_tag_err, - avm_mem_one_min_inv, + avm_alu_a_hi, + avm_alu_a_lo, + avm_alu_alu_sel, + avm_alu_b_hi, + avm_alu_b_lo, + avm_alu_borrow, + avm_alu_cf, avm_alu_clk, + avm_alu_cmp_sel, + avm_alu_ff_tag, avm_alu_ia, avm_alu_ib, avm_alu_ic, + avm_alu_in_tag, + avm_alu_input_ia, + avm_alu_input_ib, + avm_alu_lt_sel, + avm_alu_lte_sel, avm_alu_op_add, - avm_alu_op_sub, - avm_alu_op_mul, avm_alu_op_div, - avm_alu_op_not, avm_alu_op_eq, - avm_alu_alu_sel, - avm_alu_in_tag, - avm_alu_ff_tag, - avm_alu_u8_tag, - avm_alu_u16_tag, - avm_alu_u32_tag, - avm_alu_u64_tag, + avm_alu_op_eq_diff_inv, + avm_alu_op_mul, + avm_alu_op_not, + avm_alu_op_sub, + avm_alu_p_a_borrow, + avm_alu_p_b_borrow, + avm_alu_p_sub_a_hi, + avm_alu_p_sub_a_lo, + avm_alu_p_sub_b_hi, + avm_alu_p_sub_b_lo, + avm_alu_res_hi, + avm_alu_res_lo, + avm_alu_rng_chk_remaining, + avm_alu_rng_chk_sel, avm_alu_u128_tag, - avm_alu_u8_r0, - avm_alu_u8_r1, avm_alu_u16_r0, avm_alu_u16_r1, + avm_alu_u16_r10, + avm_alu_u16_r11, + avm_alu_u16_r12, + avm_alu_u16_r13, + avm_alu_u16_r14, avm_alu_u16_r2, avm_alu_u16_r3, avm_alu_u16_r4, @@ -516,107 +506,100 @@ class AvmFlavor { avm_alu_u16_r7, avm_alu_u16_r8, avm_alu_u16_r9, - avm_alu_u16_r10, - avm_alu_u16_r11, - avm_alu_u16_r12, - avm_alu_u16_r13, - avm_alu_u16_r14, + avm_alu_u16_tag, + avm_alu_u32_tag, avm_alu_u64_r0, - avm_alu_cf, - avm_alu_op_eq_diff_inv, - avm_byte_lookup_table_op_id, - avm_byte_lookup_table_input_a, - avm_byte_lookup_table_input_b, - avm_byte_lookup_table_output, - avm_byte_lookup_bin_sel, - avm_byte_lookup_table_in_tags, - avm_byte_lookup_table_byte_lengths, - avm_binary_clk, - avm_binary_bin_sel, + avm_alu_u64_tag, + avm_alu_u8_r0, + avm_alu_u8_r1, + avm_alu_u8_tag, avm_binary_acc_ia, avm_binary_acc_ib, avm_binary_acc_ic, - avm_binary_in_tag, - avm_binary_op_id, + avm_binary_bin_sel, + avm_binary_clk, avm_binary_ia_bytes, avm_binary_ib_bytes, avm_binary_ic_bytes, - avm_binary_start, + avm_binary_in_tag, avm_binary_mem_tag_ctr, avm_binary_mem_tag_ctr_inv, - avm_cmp_cmp_clk, - avm_cmp_ia, - avm_cmp_ib, - avm_cmp_ic, - avm_cmp_lt_sel, - avm_cmp_lte_sel, - avm_cmp_cmp_sel, - avm_cmp_input_ia, - avm_cmp_input_ib, - avm_cmp_a_lo, - avm_cmp_a_hi, - avm_cmp_b_lo, - avm_cmp_b_hi, - avm_cmp_borrow, - avm_cmp_p_lo, - avm_cmp_p_hi, - avm_cmp_p_sub_a_lo, - avm_cmp_p_sub_a_hi, - avm_cmp_p_a_borrow, - avm_cmp_p_sub_b_lo, - avm_cmp_p_sub_b_hi, - avm_cmp_p_b_borrow, - avm_cmp_res_lo, - avm_cmp_res_hi, - avm_cmp_lt_query, - avm_main_sel_rng_8, - avm_main_sel_rng_16, - avm_main_pc, - avm_main_internal_return_ptr, - avm_main_sel_internal_call, - avm_main_sel_internal_return, - avm_main_sel_jump, - avm_main_sel_halt, - avm_main_sel_mov, - avm_main_sel_op_add, - avm_main_sel_op_sub, - avm_main_sel_op_mul, - avm_main_sel_op_div, - 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_sel_op_lt, - avm_main_sel_op_lte, + avm_binary_op_id, + avm_binary_start, + avm_byte_lookup_bin_sel, + avm_byte_lookup_table_byte_lengths, + avm_byte_lookup_table_in_tags, + avm_byte_lookup_table_input_a, + avm_byte_lookup_table_input_b, + avm_byte_lookup_table_op_id, + avm_byte_lookup_table_output, avm_main_alu_sel, + avm_main_bin_op_id, avm_main_bin_sel, avm_main_cmp_sel, - avm_main_r_in_tag, - avm_main_w_in_tag, - avm_main_op_err, - avm_main_tag_err, - avm_main_inv, avm_main_ia, avm_main_ib, avm_main_ic, - avm_main_mem_op_a, - avm_main_mem_op_b, - avm_main_mem_op_c, - avm_main_rwa, - avm_main_rwb, - avm_main_rwc, avm_main_ind_a, avm_main_ind_b, avm_main_ind_c, avm_main_ind_op_a, avm_main_ind_op_b, avm_main_ind_op_c, + 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_last, - avm_main_bin_op_id, + avm_main_mem_op_a, + avm_main_mem_op_b, + avm_main_mem_op_c, + avm_main_op_err, + avm_main_pc, + avm_main_r_in_tag, + avm_main_rwa, + avm_main_rwb, + avm_main_rwc, + 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_op_add, + avm_main_sel_op_and, + avm_main_sel_op_div, + avm_main_sel_op_eq, + avm_main_sel_op_lt, + avm_main_sel_op_lte, + avm_main_sel_op_mul, + avm_main_sel_op_not, + avm_main_sel_op_or, + avm_main_sel_op_sub, + avm_main_sel_op_xor, + avm_main_sel_rng_16, + avm_main_sel_rng_8, + avm_main_tag_err, + avm_main_w_in_tag, + avm_mem_addr, + avm_mem_clk, + avm_mem_ind_op_a, + avm_mem_ind_op_b, + avm_mem_ind_op_c, + 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_r_in_tag, + avm_mem_rw, + avm_mem_sel_mov, + avm_mem_sub_clk, + avm_mem_tag, + avm_mem_tag_err, + avm_mem_val, + avm_mem_w_in_tag, perm_main_alu, perm_main_bin, perm_main_cmp, @@ -634,71 +617,83 @@ class AvmFlavor { lookup_byte_operations_counts, incl_main_tag_err_counts, incl_mem_tag_err_counts, + avm_alu_a_hi_shift, + avm_alu_a_lo_shift, + avm_alu_b_hi_shift, + avm_alu_b_lo_shift, + avm_alu_p_sub_a_hi_shift, + avm_alu_p_sub_a_lo_shift, + avm_alu_p_sub_b_hi_shift, + avm_alu_p_sub_b_lo_shift, + avm_alu_rng_chk_remaining_shift, + avm_alu_rng_chk_sel_shift, avm_alu_u16_r0_shift, + avm_alu_u16_r1_shift, + avm_alu_u16_r2_shift, avm_alu_u16_r3_shift, avm_alu_u16_r4_shift, - avm_alu_u16_r7_shift, - avm_alu_u16_r6_shift, - avm_alu_u16_r2_shift, avm_alu_u16_r5_shift, - avm_alu_u16_r1_shift, - avm_binary_acc_ic_shift, - avm_binary_op_id_shift, - avm_binary_mem_tag_ctr_shift, + avm_alu_u16_r6_shift, + avm_alu_u16_r7_shift, avm_binary_acc_ia_shift, avm_binary_acc_ib_shift, - avm_mem_tag_shift, - avm_mem_addr_shift, - avm_mem_val_shift, - avm_mem_rw_shift, + avm_binary_acc_ic_shift, + avm_binary_mem_tag_ctr_shift, + avm_binary_op_id_shift, + avm_main_internal_return_ptr_shift, avm_main_pc_shift, - avm_main_internal_return_ptr_shift) + avm_mem_addr_shift, + avm_mem_rw_shift, + avm_mem_tag_shift, + avm_mem_val_shift) RefVector get_wires() { return { avm_main_clk, avm_main_first, - avm_mem_clk, - avm_mem_sub_clk, - avm_mem_addr, - avm_mem_tag, - avm_mem_val, - avm_mem_lastAccess, - avm_mem_last, - avm_mem_rw, - avm_mem_r_in_tag, - avm_mem_w_in_tag, - 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_sel_mov, - avm_mem_tag_err, - avm_mem_one_min_inv, + avm_alu_a_hi, + avm_alu_a_lo, + avm_alu_alu_sel, + avm_alu_b_hi, + avm_alu_b_lo, + avm_alu_borrow, + avm_alu_cf, avm_alu_clk, + avm_alu_cmp_sel, + avm_alu_ff_tag, avm_alu_ia, avm_alu_ib, avm_alu_ic, + avm_alu_in_tag, + avm_alu_input_ia, + avm_alu_input_ib, + avm_alu_lt_sel, + avm_alu_lte_sel, avm_alu_op_add, - avm_alu_op_sub, - avm_alu_op_mul, avm_alu_op_div, - avm_alu_op_not, avm_alu_op_eq, - avm_alu_alu_sel, - avm_alu_in_tag, - avm_alu_ff_tag, - avm_alu_u8_tag, - avm_alu_u16_tag, - avm_alu_u32_tag, - avm_alu_u64_tag, + avm_alu_op_eq_diff_inv, + avm_alu_op_mul, + avm_alu_op_not, + avm_alu_op_sub, + avm_alu_p_a_borrow, + avm_alu_p_b_borrow, + avm_alu_p_sub_a_hi, + avm_alu_p_sub_a_lo, + avm_alu_p_sub_b_hi, + avm_alu_p_sub_b_lo, + avm_alu_res_hi, + avm_alu_res_lo, + avm_alu_rng_chk_remaining, + avm_alu_rng_chk_sel, avm_alu_u128_tag, - avm_alu_u8_r0, - avm_alu_u8_r1, avm_alu_u16_r0, avm_alu_u16_r1, + avm_alu_u16_r10, + avm_alu_u16_r11, + avm_alu_u16_r12, + avm_alu_u16_r13, + avm_alu_u16_r14, avm_alu_u16_r2, avm_alu_u16_r3, avm_alu_u16_r4, @@ -707,107 +702,100 @@ class AvmFlavor { avm_alu_u16_r7, avm_alu_u16_r8, avm_alu_u16_r9, - avm_alu_u16_r10, - avm_alu_u16_r11, - avm_alu_u16_r12, - avm_alu_u16_r13, - avm_alu_u16_r14, + avm_alu_u16_tag, + avm_alu_u32_tag, avm_alu_u64_r0, - avm_alu_cf, - avm_alu_op_eq_diff_inv, - avm_byte_lookup_table_op_id, - avm_byte_lookup_table_input_a, - avm_byte_lookup_table_input_b, - avm_byte_lookup_table_output, - avm_byte_lookup_bin_sel, - avm_byte_lookup_table_in_tags, - avm_byte_lookup_table_byte_lengths, - avm_binary_clk, - avm_binary_bin_sel, + avm_alu_u64_tag, + avm_alu_u8_r0, + avm_alu_u8_r1, + avm_alu_u8_tag, avm_binary_acc_ia, avm_binary_acc_ib, avm_binary_acc_ic, - avm_binary_in_tag, - avm_binary_op_id, + avm_binary_bin_sel, + avm_binary_clk, avm_binary_ia_bytes, avm_binary_ib_bytes, avm_binary_ic_bytes, - avm_binary_start, + avm_binary_in_tag, avm_binary_mem_tag_ctr, avm_binary_mem_tag_ctr_inv, - avm_cmp_cmp_clk, - avm_cmp_ia, - avm_cmp_ib, - avm_cmp_ic, - avm_cmp_lt_sel, - avm_cmp_lte_sel, - avm_cmp_cmp_sel, - avm_cmp_input_ia, - avm_cmp_input_ib, - avm_cmp_a_lo, - avm_cmp_a_hi, - avm_cmp_b_lo, - avm_cmp_b_hi, - avm_cmp_borrow, - avm_cmp_p_lo, - avm_cmp_p_hi, - avm_cmp_p_sub_a_lo, - avm_cmp_p_sub_a_hi, - avm_cmp_p_a_borrow, - avm_cmp_p_sub_b_lo, - avm_cmp_p_sub_b_hi, - avm_cmp_p_b_borrow, - avm_cmp_res_lo, - avm_cmp_res_hi, - avm_cmp_lt_query, - avm_main_sel_rng_8, - avm_main_sel_rng_16, - avm_main_pc, - avm_main_internal_return_ptr, - avm_main_sel_internal_call, - avm_main_sel_internal_return, - avm_main_sel_jump, - avm_main_sel_halt, - avm_main_sel_mov, - avm_main_sel_op_add, - avm_main_sel_op_sub, - avm_main_sel_op_mul, - avm_main_sel_op_div, - 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_sel_op_lt, - avm_main_sel_op_lte, + avm_binary_op_id, + avm_binary_start, + avm_byte_lookup_bin_sel, + avm_byte_lookup_table_byte_lengths, + avm_byte_lookup_table_in_tags, + avm_byte_lookup_table_input_a, + avm_byte_lookup_table_input_b, + avm_byte_lookup_table_op_id, + avm_byte_lookup_table_output, avm_main_alu_sel, + avm_main_bin_op_id, avm_main_bin_sel, avm_main_cmp_sel, - avm_main_r_in_tag, - avm_main_w_in_tag, - avm_main_op_err, - avm_main_tag_err, - avm_main_inv, avm_main_ia, avm_main_ib, avm_main_ic, - avm_main_mem_op_a, - avm_main_mem_op_b, - avm_main_mem_op_c, - avm_main_rwa, - avm_main_rwb, - avm_main_rwc, avm_main_ind_a, avm_main_ind_b, avm_main_ind_c, avm_main_ind_op_a, avm_main_ind_op_b, avm_main_ind_op_c, + 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_last, - avm_main_bin_op_id, + avm_main_mem_op_a, + avm_main_mem_op_b, + avm_main_mem_op_c, + avm_main_op_err, + avm_main_pc, + avm_main_r_in_tag, + avm_main_rwa, + avm_main_rwb, + avm_main_rwc, + 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_op_add, + avm_main_sel_op_and, + avm_main_sel_op_div, + avm_main_sel_op_eq, + avm_main_sel_op_lt, + avm_main_sel_op_lte, + avm_main_sel_op_mul, + avm_main_sel_op_not, + avm_main_sel_op_or, + avm_main_sel_op_sub, + avm_main_sel_op_xor, + avm_main_sel_rng_16, + avm_main_sel_rng_8, + avm_main_tag_err, + avm_main_w_in_tag, + avm_mem_addr, + avm_mem_clk, + avm_mem_ind_op_a, + avm_mem_ind_op_b, + avm_mem_ind_op_c, + 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_r_in_tag, + avm_mem_rw, + avm_mem_sel_mov, + avm_mem_sub_clk, + avm_mem_tag, + avm_mem_tag_err, + avm_mem_val, + avm_mem_w_in_tag, perm_main_alu, perm_main_bin, perm_main_cmp, @@ -825,71 +813,83 @@ class AvmFlavor { lookup_byte_operations_counts, incl_main_tag_err_counts, incl_mem_tag_err_counts, + avm_alu_a_hi_shift, + avm_alu_a_lo_shift, + avm_alu_b_hi_shift, + avm_alu_b_lo_shift, + avm_alu_p_sub_a_hi_shift, + avm_alu_p_sub_a_lo_shift, + avm_alu_p_sub_b_hi_shift, + avm_alu_p_sub_b_lo_shift, + avm_alu_rng_chk_remaining_shift, + avm_alu_rng_chk_sel_shift, avm_alu_u16_r0_shift, + avm_alu_u16_r1_shift, + avm_alu_u16_r2_shift, avm_alu_u16_r3_shift, avm_alu_u16_r4_shift, - avm_alu_u16_r7_shift, - avm_alu_u16_r6_shift, - avm_alu_u16_r2_shift, avm_alu_u16_r5_shift, - avm_alu_u16_r1_shift, - avm_binary_acc_ic_shift, - avm_binary_op_id_shift, - avm_binary_mem_tag_ctr_shift, + avm_alu_u16_r6_shift, + avm_alu_u16_r7_shift, avm_binary_acc_ia_shift, avm_binary_acc_ib_shift, - avm_mem_tag_shift, + avm_binary_acc_ic_shift, + avm_binary_mem_tag_ctr_shift, + avm_binary_op_id_shift, + avm_main_internal_return_ptr_shift, + avm_main_pc_shift, avm_mem_addr_shift, - avm_mem_val_shift, avm_mem_rw_shift, - avm_main_pc_shift, - avm_main_internal_return_ptr_shift }; + avm_mem_tag_shift, + avm_mem_val_shift }; }; RefVector get_unshifted() { return { avm_main_clk, avm_main_first, - avm_mem_clk, - avm_mem_sub_clk, - avm_mem_addr, - avm_mem_tag, - avm_mem_val, - avm_mem_lastAccess, - avm_mem_last, - avm_mem_rw, - avm_mem_r_in_tag, - avm_mem_w_in_tag, - 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_sel_mov, - avm_mem_tag_err, - avm_mem_one_min_inv, + avm_alu_a_hi, + avm_alu_a_lo, + avm_alu_alu_sel, + avm_alu_b_hi, + avm_alu_b_lo, + avm_alu_borrow, + avm_alu_cf, avm_alu_clk, + avm_alu_cmp_sel, + avm_alu_ff_tag, avm_alu_ia, avm_alu_ib, avm_alu_ic, + avm_alu_in_tag, + avm_alu_input_ia, + avm_alu_input_ib, + avm_alu_lt_sel, + avm_alu_lte_sel, avm_alu_op_add, - avm_alu_op_sub, - avm_alu_op_mul, avm_alu_op_div, - avm_alu_op_not, avm_alu_op_eq, - avm_alu_alu_sel, - avm_alu_in_tag, - avm_alu_ff_tag, - avm_alu_u8_tag, - avm_alu_u16_tag, - avm_alu_u32_tag, - avm_alu_u64_tag, + avm_alu_op_eq_diff_inv, + avm_alu_op_mul, + avm_alu_op_not, + avm_alu_op_sub, + avm_alu_p_a_borrow, + avm_alu_p_b_borrow, + avm_alu_p_sub_a_hi, + avm_alu_p_sub_a_lo, + avm_alu_p_sub_b_hi, + avm_alu_p_sub_b_lo, + avm_alu_res_hi, + avm_alu_res_lo, + avm_alu_rng_chk_remaining, + avm_alu_rng_chk_sel, avm_alu_u128_tag, - avm_alu_u8_r0, - avm_alu_u8_r1, avm_alu_u16_r0, avm_alu_u16_r1, + avm_alu_u16_r10, + avm_alu_u16_r11, + avm_alu_u16_r12, + avm_alu_u16_r13, + avm_alu_u16_r14, avm_alu_u16_r2, avm_alu_u16_r3, avm_alu_u16_r4, @@ -898,107 +898,100 @@ class AvmFlavor { avm_alu_u16_r7, avm_alu_u16_r8, avm_alu_u16_r9, - avm_alu_u16_r10, - avm_alu_u16_r11, - avm_alu_u16_r12, - avm_alu_u16_r13, - avm_alu_u16_r14, + avm_alu_u16_tag, + avm_alu_u32_tag, avm_alu_u64_r0, - avm_alu_cf, - avm_alu_op_eq_diff_inv, - avm_byte_lookup_table_op_id, - avm_byte_lookup_table_input_a, - avm_byte_lookup_table_input_b, - avm_byte_lookup_table_output, - avm_byte_lookup_bin_sel, - avm_byte_lookup_table_in_tags, - avm_byte_lookup_table_byte_lengths, - avm_binary_clk, - avm_binary_bin_sel, + avm_alu_u64_tag, + avm_alu_u8_r0, + avm_alu_u8_r1, + avm_alu_u8_tag, avm_binary_acc_ia, avm_binary_acc_ib, avm_binary_acc_ic, - avm_binary_in_tag, - avm_binary_op_id, + avm_binary_bin_sel, + avm_binary_clk, avm_binary_ia_bytes, avm_binary_ib_bytes, avm_binary_ic_bytes, - avm_binary_start, + avm_binary_in_tag, avm_binary_mem_tag_ctr, avm_binary_mem_tag_ctr_inv, - avm_cmp_cmp_clk, - avm_cmp_ia, - avm_cmp_ib, - avm_cmp_ic, - avm_cmp_lt_sel, - avm_cmp_lte_sel, - avm_cmp_cmp_sel, - avm_cmp_input_ia, - avm_cmp_input_ib, - avm_cmp_a_lo, - avm_cmp_a_hi, - avm_cmp_b_lo, - avm_cmp_b_hi, - avm_cmp_borrow, - avm_cmp_p_lo, - avm_cmp_p_hi, - avm_cmp_p_sub_a_lo, - avm_cmp_p_sub_a_hi, - avm_cmp_p_a_borrow, - avm_cmp_p_sub_b_lo, - avm_cmp_p_sub_b_hi, - avm_cmp_p_b_borrow, - avm_cmp_res_lo, - avm_cmp_res_hi, - avm_cmp_lt_query, - avm_main_sel_rng_8, - avm_main_sel_rng_16, - avm_main_pc, - avm_main_internal_return_ptr, - avm_main_sel_internal_call, - avm_main_sel_internal_return, - avm_main_sel_jump, - avm_main_sel_halt, - avm_main_sel_mov, - avm_main_sel_op_add, - avm_main_sel_op_sub, - avm_main_sel_op_mul, - avm_main_sel_op_div, - 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_sel_op_lt, - avm_main_sel_op_lte, + avm_binary_op_id, + avm_binary_start, + avm_byte_lookup_bin_sel, + avm_byte_lookup_table_byte_lengths, + avm_byte_lookup_table_in_tags, + avm_byte_lookup_table_input_a, + avm_byte_lookup_table_input_b, + avm_byte_lookup_table_op_id, + avm_byte_lookup_table_output, avm_main_alu_sel, + avm_main_bin_op_id, avm_main_bin_sel, avm_main_cmp_sel, - avm_main_r_in_tag, - avm_main_w_in_tag, - avm_main_op_err, - avm_main_tag_err, - avm_main_inv, avm_main_ia, avm_main_ib, avm_main_ic, - avm_main_mem_op_a, - avm_main_mem_op_b, - avm_main_mem_op_c, - avm_main_rwa, - avm_main_rwb, - avm_main_rwc, avm_main_ind_a, avm_main_ind_b, avm_main_ind_c, avm_main_ind_op_a, avm_main_ind_op_b, avm_main_ind_op_c, + 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_last, - avm_main_bin_op_id, + avm_main_mem_op_a, + avm_main_mem_op_b, + avm_main_mem_op_c, + avm_main_op_err, + avm_main_pc, + avm_main_r_in_tag, + avm_main_rwa, + avm_main_rwb, + avm_main_rwc, + 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_op_add, + avm_main_sel_op_and, + avm_main_sel_op_div, + avm_main_sel_op_eq, + avm_main_sel_op_lt, + avm_main_sel_op_lte, + avm_main_sel_op_mul, + avm_main_sel_op_not, + avm_main_sel_op_or, + avm_main_sel_op_sub, + avm_main_sel_op_xor, + avm_main_sel_rng_16, + avm_main_sel_rng_8, + avm_main_tag_err, + avm_main_w_in_tag, + avm_mem_addr, + avm_mem_clk, + avm_mem_ind_op_a, + avm_mem_ind_op_b, + avm_mem_ind_op_c, + 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_r_in_tag, + avm_mem_rw, + avm_mem_sel_mov, + avm_mem_sub_clk, + avm_mem_tag, + avm_mem_tag_err, + avm_mem_val, + avm_mem_w_in_tag, perm_main_alu, perm_main_bin, perm_main_cmp, @@ -1019,47 +1012,67 @@ class AvmFlavor { }; RefVector get_to_be_shifted() { - return { avm_alu_u16_r0, + return { avm_alu_a_hi, + avm_alu_a_lo, + avm_alu_b_hi, + avm_alu_b_lo, + avm_alu_p_sub_a_hi, + avm_alu_p_sub_a_lo, + avm_alu_p_sub_b_hi, + avm_alu_p_sub_b_lo, + avm_alu_rng_chk_remaining, + avm_alu_rng_chk_sel, + avm_alu_u16_r0, + avm_alu_u16_r1, + avm_alu_u16_r2, avm_alu_u16_r3, avm_alu_u16_r4, - avm_alu_u16_r7, - avm_alu_u16_r6, - avm_alu_u16_r2, avm_alu_u16_r5, - avm_alu_u16_r1, - avm_binary_acc_ic, - avm_binary_op_id, - avm_binary_mem_tag_ctr, + avm_alu_u16_r6, + avm_alu_u16_r7, avm_binary_acc_ia, avm_binary_acc_ib, - avm_mem_tag, + avm_binary_acc_ic, + avm_binary_mem_tag_ctr, + avm_binary_op_id, + avm_main_internal_return_ptr, + avm_main_pc, avm_mem_addr, - avm_mem_val, avm_mem_rw, - avm_main_pc, - avm_main_internal_return_ptr }; + avm_mem_tag, + avm_mem_val }; }; RefVector get_shifted() { - return { avm_alu_u16_r0_shift, + return { avm_alu_a_hi_shift, + avm_alu_a_lo_shift, + avm_alu_b_hi_shift, + avm_alu_b_lo_shift, + avm_alu_p_sub_a_hi_shift, + avm_alu_p_sub_a_lo_shift, + avm_alu_p_sub_b_hi_shift, + avm_alu_p_sub_b_lo_shift, + avm_alu_rng_chk_remaining_shift, + avm_alu_rng_chk_sel_shift, + avm_alu_u16_r0_shift, + avm_alu_u16_r1_shift, + avm_alu_u16_r2_shift, avm_alu_u16_r3_shift, avm_alu_u16_r4_shift, - avm_alu_u16_r7_shift, - avm_alu_u16_r6_shift, - avm_alu_u16_r2_shift, avm_alu_u16_r5_shift, - avm_alu_u16_r1_shift, - avm_binary_acc_ic_shift, - avm_binary_op_id_shift, - avm_binary_mem_tag_ctr_shift, + avm_alu_u16_r6_shift, + avm_alu_u16_r7_shift, avm_binary_acc_ia_shift, avm_binary_acc_ib_shift, - avm_mem_tag_shift, + avm_binary_acc_ic_shift, + avm_binary_mem_tag_ctr_shift, + avm_binary_op_id_shift, + avm_main_internal_return_ptr_shift, + avm_main_pc_shift, avm_mem_addr_shift, - avm_mem_val_shift, avm_mem_rw_shift, - avm_main_pc_shift, - avm_main_internal_return_ptr_shift }; + avm_mem_tag_shift, + avm_mem_val_shift }; }; }; @@ -1072,25 +1085,35 @@ class AvmFlavor { RefVector get_to_be_shifted() { - return { avm_alu_u16_r0, + return { avm_alu_a_hi, + avm_alu_a_lo, + avm_alu_b_hi, + avm_alu_b_lo, + avm_alu_p_sub_a_hi, + avm_alu_p_sub_a_lo, + avm_alu_p_sub_b_hi, + avm_alu_p_sub_b_lo, + avm_alu_rng_chk_remaining, + avm_alu_rng_chk_sel, + avm_alu_u16_r0, + avm_alu_u16_r1, + avm_alu_u16_r2, avm_alu_u16_r3, avm_alu_u16_r4, - avm_alu_u16_r7, - avm_alu_u16_r6, - avm_alu_u16_r2, avm_alu_u16_r5, - avm_alu_u16_r1, - avm_binary_acc_ic, - avm_binary_op_id, - avm_binary_mem_tag_ctr, + avm_alu_u16_r6, + avm_alu_u16_r7, avm_binary_acc_ia, avm_binary_acc_ib, - avm_mem_tag, + avm_binary_acc_ic, + avm_binary_mem_tag_ctr, + avm_binary_op_id, + avm_main_internal_return_ptr, + avm_main_pc, avm_mem_addr, - avm_mem_val, avm_mem_rw, - avm_main_pc, - avm_main_internal_return_ptr }; + avm_mem_tag, + avm_mem_val }; }; // The plookup wires that store plookup read data. @@ -1166,6 +1189,7 @@ class AvmFlavor { ProverPolynomials(ProverPolynomials&& o) noexcept = default; ProverPolynomials& operator=(ProverPolynomials&& o) noexcept = default; ~ProverPolynomials() = default; +<<<<<<< HEAD <<<<<<< HEAD // NOTE: copied from goblin ultra @@ -1185,6 +1209,9 @@ class AvmFlavor { ======= [[nodiscard]] size_t get_polynomial_size() const { return avm_mem_clk.size(); } >>>>>>> 7a982d52c (feat: init avm cmp) +======= + [[nodiscard]] size_t get_polynomial_size() const { return avm_alu_a_hi.size(); } +>>>>>>> a43e384f0 (feat: range_chk for cmp) /** * @brief Returns the evaluations of all prover polynomials at one point on the boolean hypercube, which * represents one row in the execution trace. @@ -1240,47 +1267,49 @@ class AvmFlavor { { Base::avm_main_clk = "AVM_MAIN_CLK"; Base::avm_main_first = "AVM_MAIN_FIRST"; - Base::avm_mem_clk = "AVM_MEM_CLK"; - Base::avm_mem_sub_clk = "AVM_MEM_SUB_CLK"; - Base::avm_mem_addr = "AVM_MEM_ADDR"; - Base::avm_mem_tag = "AVM_MEM_TAG"; - Base::avm_mem_val = "AVM_MEM_VAL"; - Base::avm_mem_lastAccess = "AVM_MEM_LASTACCESS"; - Base::avm_mem_last = "AVM_MEM_LAST"; - Base::avm_mem_rw = "AVM_MEM_RW"; - Base::avm_mem_r_in_tag = "AVM_MEM_R_IN_TAG"; - Base::avm_mem_w_in_tag = "AVM_MEM_W_IN_TAG"; - 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_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_sel_mov = "AVM_MEM_SEL_MOV"; - Base::avm_mem_tag_err = "AVM_MEM_TAG_ERR"; - Base::avm_mem_one_min_inv = "AVM_MEM_ONE_MIN_INV"; + Base::avm_alu_a_hi = "AVM_ALU_A_HI"; + Base::avm_alu_a_lo = "AVM_ALU_A_LO"; + Base::avm_alu_alu_sel = "AVM_ALU_ALU_SEL"; + Base::avm_alu_b_hi = "AVM_ALU_B_HI"; + Base::avm_alu_b_lo = "AVM_ALU_B_LO"; + Base::avm_alu_borrow = "AVM_ALU_BORROW"; + Base::avm_alu_cf = "AVM_ALU_CF"; Base::avm_alu_clk = "AVM_ALU_CLK"; + Base::avm_alu_cmp_sel = "AVM_ALU_CMP_SEL"; + Base::avm_alu_ff_tag = "AVM_ALU_FF_TAG"; Base::avm_alu_ia = "AVM_ALU_IA"; Base::avm_alu_ib = "AVM_ALU_IB"; Base::avm_alu_ic = "AVM_ALU_IC"; + Base::avm_alu_in_tag = "AVM_ALU_IN_TAG"; + Base::avm_alu_input_ia = "AVM_ALU_INPUT_IA"; + Base::avm_alu_input_ib = "AVM_ALU_INPUT_IB"; + Base::avm_alu_lt_sel = "AVM_ALU_LT_SEL"; + Base::avm_alu_lte_sel = "AVM_ALU_LTE_SEL"; Base::avm_alu_op_add = "AVM_ALU_OP_ADD"; - Base::avm_alu_op_sub = "AVM_ALU_OP_SUB"; - Base::avm_alu_op_mul = "AVM_ALU_OP_MUL"; Base::avm_alu_op_div = "AVM_ALU_OP_DIV"; - Base::avm_alu_op_not = "AVM_ALU_OP_NOT"; Base::avm_alu_op_eq = "AVM_ALU_OP_EQ"; - Base::avm_alu_alu_sel = "AVM_ALU_ALU_SEL"; - Base::avm_alu_in_tag = "AVM_ALU_IN_TAG"; - Base::avm_alu_ff_tag = "AVM_ALU_FF_TAG"; - Base::avm_alu_u8_tag = "AVM_ALU_U8_TAG"; - Base::avm_alu_u16_tag = "AVM_ALU_U16_TAG"; - Base::avm_alu_u32_tag = "AVM_ALU_U32_TAG"; - Base::avm_alu_u64_tag = "AVM_ALU_U64_TAG"; + Base::avm_alu_op_eq_diff_inv = "AVM_ALU_OP_EQ_DIFF_INV"; + Base::avm_alu_op_mul = "AVM_ALU_OP_MUL"; + Base::avm_alu_op_not = "AVM_ALU_OP_NOT"; + Base::avm_alu_op_sub = "AVM_ALU_OP_SUB"; + Base::avm_alu_p_a_borrow = "AVM_ALU_P_A_BORROW"; + Base::avm_alu_p_b_borrow = "AVM_ALU_P_B_BORROW"; + Base::avm_alu_p_sub_a_hi = "AVM_ALU_P_SUB_A_HI"; + Base::avm_alu_p_sub_a_lo = "AVM_ALU_P_SUB_A_LO"; + Base::avm_alu_p_sub_b_hi = "AVM_ALU_P_SUB_B_HI"; + Base::avm_alu_p_sub_b_lo = "AVM_ALU_P_SUB_B_LO"; + Base::avm_alu_res_hi = "AVM_ALU_RES_HI"; + Base::avm_alu_res_lo = "AVM_ALU_RES_LO"; + Base::avm_alu_rng_chk_remaining = "AVM_ALU_RNG_CHK_REMAINING"; + Base::avm_alu_rng_chk_sel = "AVM_ALU_RNG_CHK_SEL"; Base::avm_alu_u128_tag = "AVM_ALU_U128_TAG"; - Base::avm_alu_u8_r0 = "AVM_ALU_U8_R0"; - Base::avm_alu_u8_r1 = "AVM_ALU_U8_R1"; Base::avm_alu_u16_r0 = "AVM_ALU_U16_R0"; Base::avm_alu_u16_r1 = "AVM_ALU_U16_R1"; + Base::avm_alu_u16_r10 = "AVM_ALU_U16_R10"; + Base::avm_alu_u16_r11 = "AVM_ALU_U16_R11"; + Base::avm_alu_u16_r12 = "AVM_ALU_U16_R12"; + Base::avm_alu_u16_r13 = "AVM_ALU_U16_R13"; + Base::avm_alu_u16_r14 = "AVM_ALU_U16_R14"; Base::avm_alu_u16_r2 = "AVM_ALU_U16_R2"; Base::avm_alu_u16_r3 = "AVM_ALU_U16_R3"; Base::avm_alu_u16_r4 = "AVM_ALU_U16_R4"; @@ -1289,107 +1318,100 @@ class AvmFlavor { Base::avm_alu_u16_r7 = "AVM_ALU_U16_R7"; Base::avm_alu_u16_r8 = "AVM_ALU_U16_R8"; Base::avm_alu_u16_r9 = "AVM_ALU_U16_R9"; - Base::avm_alu_u16_r10 = "AVM_ALU_U16_R10"; - Base::avm_alu_u16_r11 = "AVM_ALU_U16_R11"; - Base::avm_alu_u16_r12 = "AVM_ALU_U16_R12"; - Base::avm_alu_u16_r13 = "AVM_ALU_U16_R13"; - Base::avm_alu_u16_r14 = "AVM_ALU_U16_R14"; + Base::avm_alu_u16_tag = "AVM_ALU_U16_TAG"; + Base::avm_alu_u32_tag = "AVM_ALU_U32_TAG"; Base::avm_alu_u64_r0 = "AVM_ALU_U64_R0"; - Base::avm_alu_cf = "AVM_ALU_CF"; - Base::avm_alu_op_eq_diff_inv = "AVM_ALU_OP_EQ_DIFF_INV"; - Base::avm_byte_lookup_table_op_id = "AVM_BYTE_LOOKUP_TABLE_OP_ID"; - Base::avm_byte_lookup_table_input_a = "AVM_BYTE_LOOKUP_TABLE_INPUT_A"; - Base::avm_byte_lookup_table_input_b = "AVM_BYTE_LOOKUP_TABLE_INPUT_B"; - Base::avm_byte_lookup_table_output = "AVM_BYTE_LOOKUP_TABLE_OUTPUT"; - Base::avm_byte_lookup_bin_sel = "AVM_BYTE_LOOKUP_BIN_SEL"; - Base::avm_byte_lookup_table_in_tags = "AVM_BYTE_LOOKUP_TABLE_IN_TAGS"; - Base::avm_byte_lookup_table_byte_lengths = "AVM_BYTE_LOOKUP_TABLE_BYTE_LENGTHS"; - Base::avm_binary_clk = "AVM_BINARY_CLK"; - Base::avm_binary_bin_sel = "AVM_BINARY_BIN_SEL"; + Base::avm_alu_u64_tag = "AVM_ALU_U64_TAG"; + Base::avm_alu_u8_r0 = "AVM_ALU_U8_R0"; + Base::avm_alu_u8_r1 = "AVM_ALU_U8_R1"; + Base::avm_alu_u8_tag = "AVM_ALU_U8_TAG"; Base::avm_binary_acc_ia = "AVM_BINARY_ACC_IA"; Base::avm_binary_acc_ib = "AVM_BINARY_ACC_IB"; Base::avm_binary_acc_ic = "AVM_BINARY_ACC_IC"; - Base::avm_binary_in_tag = "AVM_BINARY_IN_TAG"; - Base::avm_binary_op_id = "AVM_BINARY_OP_ID"; + Base::avm_binary_bin_sel = "AVM_BINARY_BIN_SEL"; + Base::avm_binary_clk = "AVM_BINARY_CLK"; Base::avm_binary_ia_bytes = "AVM_BINARY_IA_BYTES"; Base::avm_binary_ib_bytes = "AVM_BINARY_IB_BYTES"; Base::avm_binary_ic_bytes = "AVM_BINARY_IC_BYTES"; - Base::avm_binary_start = "AVM_BINARY_START"; + Base::avm_binary_in_tag = "AVM_BINARY_IN_TAG"; Base::avm_binary_mem_tag_ctr = "AVM_BINARY_MEM_TAG_CTR"; Base::avm_binary_mem_tag_ctr_inv = "AVM_BINARY_MEM_TAG_CTR_INV"; - Base::avm_cmp_cmp_clk = "AVM_CMP_CMP_CLK"; - Base::avm_cmp_ia = "AVM_CMP_IA"; - Base::avm_cmp_ib = "AVM_CMP_IB"; - Base::avm_cmp_ic = "AVM_CMP_IC"; - Base::avm_cmp_lt_sel = "AVM_CMP_LT_SEL"; - Base::avm_cmp_lte_sel = "AVM_CMP_LTE_SEL"; - Base::avm_cmp_cmp_sel = "AVM_CMP_CMP_SEL"; - Base::avm_cmp_input_ia = "AVM_CMP_INPUT_IA"; - Base::avm_cmp_input_ib = "AVM_CMP_INPUT_IB"; - Base::avm_cmp_a_lo = "AVM_CMP_A_LO"; - Base::avm_cmp_a_hi = "AVM_CMP_A_HI"; - Base::avm_cmp_b_lo = "AVM_CMP_B_LO"; - Base::avm_cmp_b_hi = "AVM_CMP_B_HI"; - Base::avm_cmp_borrow = "AVM_CMP_BORROW"; - Base::avm_cmp_p_lo = "AVM_CMP_P_LO"; - Base::avm_cmp_p_hi = "AVM_CMP_P_HI"; - Base::avm_cmp_p_sub_a_lo = "AVM_CMP_P_SUB_A_LO"; - Base::avm_cmp_p_sub_a_hi = "AVM_CMP_P_SUB_A_HI"; - Base::avm_cmp_p_a_borrow = "AVM_CMP_P_A_BORROW"; - Base::avm_cmp_p_sub_b_lo = "AVM_CMP_P_SUB_B_LO"; - Base::avm_cmp_p_sub_b_hi = "AVM_CMP_P_SUB_B_HI"; - Base::avm_cmp_p_b_borrow = "AVM_CMP_P_B_BORROW"; - Base::avm_cmp_res_lo = "AVM_CMP_RES_LO"; - Base::avm_cmp_res_hi = "AVM_CMP_RES_HI"; - Base::avm_cmp_lt_query = "AVM_CMP_LT_QUERY"; - Base::avm_main_sel_rng_8 = "AVM_MAIN_SEL_RNG_8"; - Base::avm_main_sel_rng_16 = "AVM_MAIN_SEL_RNG_16"; - Base::avm_main_pc = "AVM_MAIN_PC"; - Base::avm_main_internal_return_ptr = "AVM_MAIN_INTERNAL_RETURN_PTR"; - 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_halt = "AVM_MAIN_SEL_HALT"; - Base::avm_main_sel_mov = "AVM_MAIN_SEL_MOV"; - Base::avm_main_sel_op_add = "AVM_MAIN_SEL_OP_ADD"; - Base::avm_main_sel_op_sub = "AVM_MAIN_SEL_OP_SUB"; - Base::avm_main_sel_op_mul = "AVM_MAIN_SEL_OP_MUL"; - Base::avm_main_sel_op_div = "AVM_MAIN_SEL_OP_DIV"; - Base::avm_main_sel_op_not = "AVM_MAIN_SEL_OP_NOT"; - Base::avm_main_sel_op_eq = "AVM_MAIN_SEL_OP_EQ"; - Base::avm_main_sel_op_and = "AVM_MAIN_SEL_OP_AND"; - Base::avm_main_sel_op_or = "AVM_MAIN_SEL_OP_OR"; - Base::avm_main_sel_op_xor = "AVM_MAIN_SEL_OP_XOR"; - Base::avm_main_sel_op_lt = "AVM_MAIN_SEL_OP_LT"; - Base::avm_main_sel_op_lte = "AVM_MAIN_SEL_OP_LTE"; + Base::avm_binary_op_id = "AVM_BINARY_OP_ID"; + Base::avm_binary_start = "AVM_BINARY_START"; + Base::avm_byte_lookup_bin_sel = "AVM_BYTE_LOOKUP_BIN_SEL"; + Base::avm_byte_lookup_table_byte_lengths = "AVM_BYTE_LOOKUP_TABLE_BYTE_LENGTHS"; + Base::avm_byte_lookup_table_in_tags = "AVM_BYTE_LOOKUP_TABLE_IN_TAGS"; + Base::avm_byte_lookup_table_input_a = "AVM_BYTE_LOOKUP_TABLE_INPUT_A"; + Base::avm_byte_lookup_table_input_b = "AVM_BYTE_LOOKUP_TABLE_INPUT_B"; + Base::avm_byte_lookup_table_op_id = "AVM_BYTE_LOOKUP_TABLE_OP_ID"; + Base::avm_byte_lookup_table_output = "AVM_BYTE_LOOKUP_TABLE_OUTPUT"; Base::avm_main_alu_sel = "AVM_MAIN_ALU_SEL"; + Base::avm_main_bin_op_id = "AVM_MAIN_BIN_OP_ID"; Base::avm_main_bin_sel = "AVM_MAIN_BIN_SEL"; Base::avm_main_cmp_sel = "AVM_MAIN_CMP_SEL"; - Base::avm_main_r_in_tag = "AVM_MAIN_R_IN_TAG"; - Base::avm_main_w_in_tag = "AVM_MAIN_W_IN_TAG"; - Base::avm_main_op_err = "AVM_MAIN_OP_ERR"; - Base::avm_main_tag_err = "AVM_MAIN_TAG_ERR"; - Base::avm_main_inv = "AVM_MAIN_INV"; Base::avm_main_ia = "AVM_MAIN_IA"; Base::avm_main_ib = "AVM_MAIN_IB"; Base::avm_main_ic = "AVM_MAIN_IC"; - 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_rwa = "AVM_MAIN_RWA"; - Base::avm_main_rwb = "AVM_MAIN_RWB"; - Base::avm_main_rwc = "AVM_MAIN_RWC"; 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_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_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_last = "AVM_MAIN_LAST"; - Base::avm_main_bin_op_id = "AVM_MAIN_BIN_OP_ID"; + 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_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_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_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"; + Base::avm_main_sel_op_eq = "AVM_MAIN_SEL_OP_EQ"; + Base::avm_main_sel_op_lt = "AVM_MAIN_SEL_OP_LT"; + Base::avm_main_sel_op_lte = "AVM_MAIN_SEL_OP_LTE"; + Base::avm_main_sel_op_mul = "AVM_MAIN_SEL_OP_MUL"; + Base::avm_main_sel_op_not = "AVM_MAIN_SEL_OP_NOT"; + Base::avm_main_sel_op_or = "AVM_MAIN_SEL_OP_OR"; + Base::avm_main_sel_op_sub = "AVM_MAIN_SEL_OP_SUB"; + Base::avm_main_sel_op_xor = "AVM_MAIN_SEL_OP_XOR"; + Base::avm_main_sel_rng_16 = "AVM_MAIN_SEL_RNG_16"; + Base::avm_main_sel_rng_8 = "AVM_MAIN_SEL_RNG_8"; + Base::avm_main_tag_err = "AVM_MAIN_TAG_ERR"; + Base::avm_main_w_in_tag = "AVM_MAIN_W_IN_TAG"; + Base::avm_mem_addr = "AVM_MEM_ADDR"; + Base::avm_mem_clk = "AVM_MEM_CLK"; + 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_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_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_sub_clk = "AVM_MEM_SUB_CLK"; + Base::avm_mem_tag = "AVM_MEM_TAG"; + Base::avm_mem_tag_err = "AVM_MEM_TAG_ERR"; + Base::avm_mem_val = "AVM_MEM_VAL"; + Base::avm_mem_w_in_tag = "AVM_MEM_W_IN_TAG"; Base::perm_main_alu = "PERM_MAIN_ALU"; Base::perm_main_bin = "PERM_MAIN_BIN"; Base::perm_main_cmp = "PERM_MAIN_CMP"; @@ -1426,47 +1448,49 @@ class AvmFlavor { public: uint32_t circuit_size; - Commitment avm_mem_clk; - Commitment avm_mem_sub_clk; - Commitment avm_mem_addr; - Commitment avm_mem_tag; - Commitment avm_mem_val; - Commitment avm_mem_lastAccess; - Commitment avm_mem_last; - Commitment avm_mem_rw; - Commitment avm_mem_r_in_tag; - Commitment avm_mem_w_in_tag; - Commitment avm_mem_op_a; - Commitment avm_mem_op_b; - Commitment avm_mem_op_c; - Commitment avm_mem_ind_op_a; - Commitment avm_mem_ind_op_b; - Commitment avm_mem_ind_op_c; - Commitment avm_mem_sel_mov; - Commitment avm_mem_tag_err; - Commitment avm_mem_one_min_inv; + Commitment avm_alu_a_hi; + Commitment avm_alu_a_lo; + Commitment avm_alu_alu_sel; + Commitment avm_alu_b_hi; + Commitment avm_alu_b_lo; + Commitment avm_alu_borrow; + Commitment avm_alu_cf; Commitment avm_alu_clk; + Commitment avm_alu_cmp_sel; + Commitment avm_alu_ff_tag; Commitment avm_alu_ia; Commitment avm_alu_ib; Commitment avm_alu_ic; + Commitment avm_alu_in_tag; + Commitment avm_alu_input_ia; + Commitment avm_alu_input_ib; + Commitment avm_alu_lt_sel; + Commitment avm_alu_lte_sel; Commitment avm_alu_op_add; - Commitment avm_alu_op_sub; - Commitment avm_alu_op_mul; Commitment avm_alu_op_div; - Commitment avm_alu_op_not; Commitment avm_alu_op_eq; - Commitment avm_alu_alu_sel; - Commitment avm_alu_in_tag; - Commitment avm_alu_ff_tag; - Commitment avm_alu_u8_tag; - Commitment avm_alu_u16_tag; - Commitment avm_alu_u32_tag; - Commitment avm_alu_u64_tag; + Commitment avm_alu_op_eq_diff_inv; + Commitment avm_alu_op_mul; + Commitment avm_alu_op_not; + Commitment avm_alu_op_sub; + Commitment avm_alu_p_a_borrow; + Commitment avm_alu_p_b_borrow; + Commitment avm_alu_p_sub_a_hi; + Commitment avm_alu_p_sub_a_lo; + Commitment avm_alu_p_sub_b_hi; + Commitment avm_alu_p_sub_b_lo; + Commitment avm_alu_res_hi; + Commitment avm_alu_res_lo; + Commitment avm_alu_rng_chk_remaining; + Commitment avm_alu_rng_chk_sel; Commitment avm_alu_u128_tag; - Commitment avm_alu_u8_r0; - Commitment avm_alu_u8_r1; Commitment avm_alu_u16_r0; Commitment avm_alu_u16_r1; + Commitment avm_alu_u16_r10; + Commitment avm_alu_u16_r11; + Commitment avm_alu_u16_r12; + Commitment avm_alu_u16_r13; + Commitment avm_alu_u16_r14; Commitment avm_alu_u16_r2; Commitment avm_alu_u16_r3; Commitment avm_alu_u16_r4; @@ -1475,106 +1499,56 @@ class AvmFlavor { Commitment avm_alu_u16_r7; Commitment avm_alu_u16_r8; Commitment avm_alu_u16_r9; - Commitment avm_alu_u16_r10; - Commitment avm_alu_u16_r11; - Commitment avm_alu_u16_r12; - Commitment avm_alu_u16_r13; - Commitment avm_alu_u16_r14; + Commitment avm_alu_u16_tag; + Commitment avm_alu_u32_tag; Commitment avm_alu_u64_r0; - Commitment avm_alu_cf; - Commitment avm_alu_op_eq_diff_inv; - Commitment avm_byte_lookup_table_op_id; - Commitment avm_byte_lookup_table_input_a; - Commitment avm_byte_lookup_table_input_b; - Commitment avm_byte_lookup_table_output; - Commitment avm_byte_lookup_bin_sel; - Commitment avm_byte_lookup_table_in_tags; - Commitment avm_byte_lookup_table_byte_lengths; - Commitment avm_binary_clk; - Commitment avm_binary_bin_sel; + Commitment avm_alu_u64_tag; + Commitment avm_alu_u8_r0; + Commitment avm_alu_u8_r1; + Commitment avm_alu_u8_tag; Commitment avm_binary_acc_ia; Commitment avm_binary_acc_ib; Commitment avm_binary_acc_ic; - Commitment avm_binary_in_tag; - Commitment avm_binary_op_id; + Commitment avm_binary_bin_sel; + Commitment avm_binary_clk; Commitment avm_binary_ia_bytes; Commitment avm_binary_ib_bytes; Commitment avm_binary_ic_bytes; - Commitment avm_binary_start; + Commitment avm_binary_in_tag; Commitment avm_binary_mem_tag_ctr; Commitment avm_binary_mem_tag_ctr_inv; - Commitment avm_cmp_cmp_clk; - Commitment avm_cmp_ia; - Commitment avm_cmp_ib; - Commitment avm_cmp_ic; - Commitment avm_cmp_lt_sel; - Commitment avm_cmp_lte_sel; - Commitment avm_cmp_cmp_sel; - Commitment avm_cmp_input_ia; - Commitment avm_cmp_input_ib; - Commitment avm_cmp_a_lo; - Commitment avm_cmp_a_hi; - Commitment avm_cmp_b_lo; - Commitment avm_cmp_b_hi; - Commitment avm_cmp_borrow; - Commitment avm_cmp_p_lo; - Commitment avm_cmp_p_hi; - Commitment avm_cmp_p_sub_a_lo; - Commitment avm_cmp_p_sub_a_hi; - Commitment avm_cmp_p_a_borrow; - Commitment avm_cmp_p_sub_b_lo; - Commitment avm_cmp_p_sub_b_hi; - Commitment avm_cmp_p_b_borrow; - Commitment avm_cmp_res_lo; - Commitment avm_cmp_res_hi; - Commitment avm_cmp_lt_query; - Commitment avm_main_sel_rng_8; - Commitment avm_main_sel_rng_16; - Commitment avm_main_pc; - Commitment avm_main_internal_return_ptr; - Commitment avm_main_sel_internal_call; - Commitment avm_main_sel_internal_return; - Commitment avm_main_sel_jump; - Commitment avm_main_sel_halt; - Commitment avm_main_sel_mov; - Commitment avm_main_sel_op_add; - Commitment avm_main_sel_op_sub; - Commitment avm_main_sel_op_mul; - Commitment avm_main_sel_op_div; - Commitment avm_main_sel_op_not; - Commitment avm_main_sel_op_eq; - Commitment avm_main_sel_op_and; - Commitment avm_main_sel_op_or; - Commitment avm_main_sel_op_xor; - Commitment avm_main_sel_op_lt; - Commitment avm_main_sel_op_lte; + Commitment avm_binary_op_id; + Commitment avm_binary_start; + Commitment avm_byte_lookup_bin_sel; + Commitment avm_byte_lookup_table_byte_lengths; + Commitment avm_byte_lookup_table_in_tags; + Commitment avm_byte_lookup_table_input_a; + Commitment avm_byte_lookup_table_input_b; + Commitment avm_byte_lookup_table_op_id; + Commitment avm_byte_lookup_table_output; Commitment avm_main_alu_sel; + Commitment avm_main_bin_op_id; Commitment avm_main_bin_sel; Commitment avm_main_cmp_sel; - Commitment avm_main_r_in_tag; - Commitment avm_main_w_in_tag; - Commitment avm_main_op_err; - Commitment avm_main_tag_err; - Commitment avm_main_inv; Commitment avm_main_ia; Commitment avm_main_ib; Commitment avm_main_ic; - Commitment avm_main_mem_op_a; - Commitment avm_main_mem_op_b; - Commitment avm_main_mem_op_c; - Commitment avm_main_rwa; - Commitment avm_main_rwb; - Commitment avm_main_rwc; Commitment avm_main_ind_a; Commitment avm_main_ind_b; Commitment avm_main_ind_c; Commitment avm_main_ind_op_a; Commitment avm_main_ind_op_b; Commitment avm_main_ind_op_c; + 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; <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> a43e384f0 (feat: range_chk for cmp) Commitment avm_main_mem_op_a; Commitment avm_main_mem_op_b; Commitment avm_main_mem_op_c; @@ -1593,6 +1567,11 @@ class AvmFlavor { Commitment avm_main_sel_op_and; Commitment avm_main_sel_op_div; Commitment avm_main_sel_op_eq; +<<<<<<< HEAD +======= + Commitment avm_main_sel_op_lt; + Commitment avm_main_sel_op_lte; +>>>>>>> a43e384f0 (feat: range_chk for cmp) Commitment avm_main_sel_op_mul; Commitment avm_main_sel_op_not; Commitment avm_main_sel_op_or; @@ -1621,12 +1600,15 @@ class AvmFlavor { Commitment avm_mem_tag_err; Commitment avm_mem_val; Commitment avm_mem_w_in_tag; +<<<<<<< HEAD // Perm inverses ======= Commitment avm_main_last; Commitment avm_main_bin_op_id; >>>>>>> 7a982d52c (feat: init avm cmp) +======= +>>>>>>> a43e384f0 (feat: range_chk for cmp) Commitment perm_main_alu; Commitment perm_main_bin; Commitment perm_main_cmp; @@ -1666,47 +1648,49 @@ class AvmFlavor { circuit_size = deserialize_from_buffer(proof_data, num_frs_read); size_t log_n = numeric::get_msb(circuit_size); - avm_mem_clk = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_mem_sub_clk = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_mem_addr = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_mem_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_mem_val = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_mem_lastAccess = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_mem_last = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_mem_rw = 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_w_in_tag = 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_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_sel_mov = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_mem_tag_err = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_mem_one_min_inv = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_a_hi = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_a_lo = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_alu_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_b_hi = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_b_lo = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_borrow = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_cf = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_clk = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_cmp_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_ff_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_ia = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_ib = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_ic = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_in_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_input_ia = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_input_ib = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_lt_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_lte_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_op_add = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_op_sub = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_op_mul = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_op_div = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_op_not = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_op_eq = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_alu_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_in_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_ff_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_u8_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_u16_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_u32_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_u64_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_op_eq_diff_inv = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_op_mul = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_op_not = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_op_sub = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_p_a_borrow = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_p_b_borrow = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_p_sub_a_hi = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_p_sub_a_lo = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_p_sub_b_hi = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_p_sub_b_lo = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_res_hi = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_res_lo = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_rng_chk_remaining = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_rng_chk_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_u128_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_u8_r0 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_u8_r1 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_u16_r0 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_u16_r1 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_u16_r10 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_u16_r11 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_u16_r12 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_u16_r13 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_u16_r14 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_u16_r2 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_u16_r3 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_u16_r4 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); @@ -1715,108 +1699,101 @@ class AvmFlavor { avm_alu_u16_r7 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_u16_r8 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_u16_r9 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_u16_r10 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_u16_r11 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_u16_r12 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_u16_r13 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_u16_r14 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_u16_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_u32_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_u64_r0 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_cf = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_op_eq_diff_inv = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_byte_lookup_table_op_id = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_byte_lookup_table_input_a = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_byte_lookup_table_input_b = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_byte_lookup_table_output = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_byte_lookup_bin_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_byte_lookup_table_in_tags = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_byte_lookup_table_byte_lengths = - deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_binary_clk = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_binary_bin_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_binary_acc_ia = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_binary_acc_ib = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_binary_acc_ic = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_binary_in_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_binary_op_id = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_binary_ia_bytes = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_binary_ib_bytes = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_binary_ic_bytes = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_binary_start = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_binary_mem_tag_ctr = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_binary_mem_tag_ctr_inv = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_cmp_cmp_clk = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_cmp_ia = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_cmp_ib = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_cmp_ic = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_cmp_lt_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_cmp_lte_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_cmp_cmp_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_cmp_input_ia = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_cmp_input_ib = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_cmp_a_lo = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_cmp_a_hi = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_cmp_b_lo = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_cmp_b_hi = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_cmp_borrow = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_cmp_p_lo = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_cmp_p_hi = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_cmp_p_sub_a_lo = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_cmp_p_sub_a_hi = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_cmp_p_a_borrow = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_cmp_p_sub_b_lo = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_cmp_p_sub_b_hi = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_cmp_p_b_borrow = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_cmp_res_lo = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_cmp_res_hi = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_cmp_lt_query = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_main_sel_rng_8 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_main_sel_rng_16 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_main_pc = 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_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_halt = 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_op_add = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_main_sel_op_sub = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_main_sel_op_mul = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_main_sel_op_div = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_main_sel_op_not = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_main_sel_op_eq = 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_or = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_main_sel_op_xor = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_main_sel_op_lt = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_main_sel_op_lte = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_u64_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_u8_r0 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_u8_r1 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_u8_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_binary_acc_ia = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_binary_acc_ib = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_binary_acc_ic = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_binary_bin_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_binary_clk = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_binary_ia_bytes = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_binary_ib_bytes = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_binary_ic_bytes = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_binary_in_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_binary_mem_tag_ctr = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_binary_mem_tag_ctr_inv = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_binary_op_id = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_binary_start = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_byte_lookup_bin_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_byte_lookup_table_byte_lengths = + deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_byte_lookup_table_in_tags = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_byte_lookup_table_input_a = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_byte_lookup_table_input_b = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_byte_lookup_table_op_id = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_byte_lookup_table_output = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_alu_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_bin_op_id = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_bin_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_cmp_sel = 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_w_in_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_main_op_err = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_main_tag_err = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_main_inv = deserialize_from_buffer(Transcript::proof_data, num_frs_read); 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_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_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_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_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_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_last = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_main_bin_op_id = 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_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_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_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); + avm_main_sel_op_eq = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_op_lt = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_op_lte = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_op_mul = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_op_not = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_op_or = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_op_sub = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_op_xor = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_rng_16 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_rng_8 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_tag_err = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_w_in_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_mem_addr = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_mem_clk = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + 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_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_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_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); + avm_mem_val = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_mem_w_in_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); perm_main_alu = deserialize_from_buffer(Transcript::proof_data, num_frs_read); perm_main_bin = deserialize_from_buffer(Transcript::proof_data, num_frs_read); perm_main_cmp = deserialize_from_buffer(Transcript::proof_data, num_frs_read); @@ -1857,47 +1834,49 @@ class AvmFlavor { serialize_to_buffer(circuit_size, Transcript::proof_data); - serialize_to_buffer(avm_mem_clk, Transcript::proof_data); - serialize_to_buffer(avm_mem_sub_clk, Transcript::proof_data); - serialize_to_buffer(avm_mem_addr, Transcript::proof_data); - serialize_to_buffer(avm_mem_tag, Transcript::proof_data); - serialize_to_buffer(avm_mem_val, Transcript::proof_data); - serialize_to_buffer(avm_mem_lastAccess, Transcript::proof_data); - serialize_to_buffer(avm_mem_last, Transcript::proof_data); - serialize_to_buffer(avm_mem_rw, Transcript::proof_data); - serialize_to_buffer(avm_mem_r_in_tag, Transcript::proof_data); - serialize_to_buffer(avm_mem_w_in_tag, 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_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_sel_mov, Transcript::proof_data); - serialize_to_buffer(avm_mem_tag_err, Transcript::proof_data); - serialize_to_buffer(avm_mem_one_min_inv, Transcript::proof_data); + serialize_to_buffer(avm_alu_a_hi, Transcript::proof_data); + serialize_to_buffer(avm_alu_a_lo, Transcript::proof_data); + serialize_to_buffer(avm_alu_alu_sel, Transcript::proof_data); + serialize_to_buffer(avm_alu_b_hi, Transcript::proof_data); + serialize_to_buffer(avm_alu_b_lo, Transcript::proof_data); + serialize_to_buffer(avm_alu_borrow, Transcript::proof_data); + serialize_to_buffer(avm_alu_cf, Transcript::proof_data); serialize_to_buffer(avm_alu_clk, Transcript::proof_data); + serialize_to_buffer(avm_alu_cmp_sel, Transcript::proof_data); + serialize_to_buffer(avm_alu_ff_tag, Transcript::proof_data); serialize_to_buffer(avm_alu_ia, Transcript::proof_data); serialize_to_buffer(avm_alu_ib, Transcript::proof_data); serialize_to_buffer(avm_alu_ic, Transcript::proof_data); + serialize_to_buffer(avm_alu_in_tag, Transcript::proof_data); + serialize_to_buffer(avm_alu_input_ia, Transcript::proof_data); + serialize_to_buffer(avm_alu_input_ib, Transcript::proof_data); + serialize_to_buffer(avm_alu_lt_sel, Transcript::proof_data); + serialize_to_buffer(avm_alu_lte_sel, Transcript::proof_data); serialize_to_buffer(avm_alu_op_add, Transcript::proof_data); - serialize_to_buffer(avm_alu_op_sub, Transcript::proof_data); - serialize_to_buffer(avm_alu_op_mul, Transcript::proof_data); serialize_to_buffer(avm_alu_op_div, Transcript::proof_data); - serialize_to_buffer(avm_alu_op_not, Transcript::proof_data); serialize_to_buffer(avm_alu_op_eq, Transcript::proof_data); - serialize_to_buffer(avm_alu_alu_sel, Transcript::proof_data); - serialize_to_buffer(avm_alu_in_tag, Transcript::proof_data); - serialize_to_buffer(avm_alu_ff_tag, Transcript::proof_data); - serialize_to_buffer(avm_alu_u8_tag, Transcript::proof_data); - serialize_to_buffer(avm_alu_u16_tag, Transcript::proof_data); - serialize_to_buffer(avm_alu_u32_tag, Transcript::proof_data); - serialize_to_buffer(avm_alu_u64_tag, Transcript::proof_data); + serialize_to_buffer(avm_alu_op_eq_diff_inv, Transcript::proof_data); + serialize_to_buffer(avm_alu_op_mul, Transcript::proof_data); + serialize_to_buffer(avm_alu_op_not, Transcript::proof_data); + serialize_to_buffer(avm_alu_op_sub, Transcript::proof_data); + serialize_to_buffer(avm_alu_p_a_borrow, Transcript::proof_data); + serialize_to_buffer(avm_alu_p_b_borrow, Transcript::proof_data); + serialize_to_buffer(avm_alu_p_sub_a_hi, Transcript::proof_data); + serialize_to_buffer(avm_alu_p_sub_a_lo, Transcript::proof_data); + serialize_to_buffer(avm_alu_p_sub_b_hi, Transcript::proof_data); + serialize_to_buffer(avm_alu_p_sub_b_lo, Transcript::proof_data); + serialize_to_buffer(avm_alu_res_hi, Transcript::proof_data); + serialize_to_buffer(avm_alu_res_lo, Transcript::proof_data); + serialize_to_buffer(avm_alu_rng_chk_remaining, Transcript::proof_data); + serialize_to_buffer(avm_alu_rng_chk_sel, Transcript::proof_data); serialize_to_buffer(avm_alu_u128_tag, Transcript::proof_data); - serialize_to_buffer(avm_alu_u8_r0, Transcript::proof_data); - serialize_to_buffer(avm_alu_u8_r1, Transcript::proof_data); serialize_to_buffer(avm_alu_u16_r0, Transcript::proof_data); serialize_to_buffer(avm_alu_u16_r1, Transcript::proof_data); + serialize_to_buffer(avm_alu_u16_r10, Transcript::proof_data); + serialize_to_buffer(avm_alu_u16_r11, Transcript::proof_data); + serialize_to_buffer(avm_alu_u16_r12, Transcript::proof_data); + serialize_to_buffer(avm_alu_u16_r13, Transcript::proof_data); + serialize_to_buffer(avm_alu_u16_r14, Transcript::proof_data); serialize_to_buffer(avm_alu_u16_r2, Transcript::proof_data); serialize_to_buffer(avm_alu_u16_r3, Transcript::proof_data); serialize_to_buffer(avm_alu_u16_r4, Transcript::proof_data); @@ -1906,107 +1885,100 @@ class AvmFlavor { serialize_to_buffer(avm_alu_u16_r7, Transcript::proof_data); serialize_to_buffer(avm_alu_u16_r8, Transcript::proof_data); serialize_to_buffer(avm_alu_u16_r9, Transcript::proof_data); - serialize_to_buffer(avm_alu_u16_r10, Transcript::proof_data); - serialize_to_buffer(avm_alu_u16_r11, Transcript::proof_data); - serialize_to_buffer(avm_alu_u16_r12, Transcript::proof_data); - serialize_to_buffer(avm_alu_u16_r13, Transcript::proof_data); - serialize_to_buffer(avm_alu_u16_r14, Transcript::proof_data); + serialize_to_buffer(avm_alu_u16_tag, Transcript::proof_data); + serialize_to_buffer(avm_alu_u32_tag, Transcript::proof_data); serialize_to_buffer(avm_alu_u64_r0, Transcript::proof_data); - serialize_to_buffer(avm_alu_cf, Transcript::proof_data); - serialize_to_buffer(avm_alu_op_eq_diff_inv, Transcript::proof_data); - serialize_to_buffer(avm_byte_lookup_table_op_id, Transcript::proof_data); - serialize_to_buffer(avm_byte_lookup_table_input_a, Transcript::proof_data); - serialize_to_buffer(avm_byte_lookup_table_input_b, Transcript::proof_data); - serialize_to_buffer(avm_byte_lookup_table_output, Transcript::proof_data); - serialize_to_buffer(avm_byte_lookup_bin_sel, Transcript::proof_data); - serialize_to_buffer(avm_byte_lookup_table_in_tags, Transcript::proof_data); - serialize_to_buffer(avm_byte_lookup_table_byte_lengths, Transcript::proof_data); - serialize_to_buffer(avm_binary_clk, Transcript::proof_data); - serialize_to_buffer(avm_binary_bin_sel, Transcript::proof_data); + serialize_to_buffer(avm_alu_u64_tag, Transcript::proof_data); + serialize_to_buffer(avm_alu_u8_r0, Transcript::proof_data); + serialize_to_buffer(avm_alu_u8_r1, Transcript::proof_data); + serialize_to_buffer(avm_alu_u8_tag, Transcript::proof_data); serialize_to_buffer(avm_binary_acc_ia, Transcript::proof_data); serialize_to_buffer(avm_binary_acc_ib, Transcript::proof_data); serialize_to_buffer(avm_binary_acc_ic, Transcript::proof_data); - serialize_to_buffer(avm_binary_in_tag, Transcript::proof_data); - serialize_to_buffer(avm_binary_op_id, Transcript::proof_data); + serialize_to_buffer(avm_binary_bin_sel, Transcript::proof_data); + serialize_to_buffer(avm_binary_clk, Transcript::proof_data); serialize_to_buffer(avm_binary_ia_bytes, Transcript::proof_data); serialize_to_buffer(avm_binary_ib_bytes, Transcript::proof_data); serialize_to_buffer(avm_binary_ic_bytes, Transcript::proof_data); - serialize_to_buffer(avm_binary_start, Transcript::proof_data); + serialize_to_buffer(avm_binary_in_tag, Transcript::proof_data); serialize_to_buffer(avm_binary_mem_tag_ctr, Transcript::proof_data); serialize_to_buffer(avm_binary_mem_tag_ctr_inv, Transcript::proof_data); - serialize_to_buffer(avm_cmp_cmp_clk, Transcript::proof_data); - serialize_to_buffer(avm_cmp_ia, Transcript::proof_data); - serialize_to_buffer(avm_cmp_ib, Transcript::proof_data); - serialize_to_buffer(avm_cmp_ic, Transcript::proof_data); - serialize_to_buffer(avm_cmp_lt_sel, Transcript::proof_data); - serialize_to_buffer(avm_cmp_lte_sel, Transcript::proof_data); - serialize_to_buffer(avm_cmp_cmp_sel, Transcript::proof_data); - serialize_to_buffer(avm_cmp_input_ia, Transcript::proof_data); - serialize_to_buffer(avm_cmp_input_ib, Transcript::proof_data); - serialize_to_buffer(avm_cmp_a_lo, Transcript::proof_data); - serialize_to_buffer(avm_cmp_a_hi, Transcript::proof_data); - serialize_to_buffer(avm_cmp_b_lo, Transcript::proof_data); - serialize_to_buffer(avm_cmp_b_hi, Transcript::proof_data); - serialize_to_buffer(avm_cmp_borrow, Transcript::proof_data); - serialize_to_buffer(avm_cmp_p_lo, Transcript::proof_data); - serialize_to_buffer(avm_cmp_p_hi, Transcript::proof_data); - serialize_to_buffer(avm_cmp_p_sub_a_lo, Transcript::proof_data); - serialize_to_buffer(avm_cmp_p_sub_a_hi, Transcript::proof_data); - serialize_to_buffer(avm_cmp_p_a_borrow, Transcript::proof_data); - serialize_to_buffer(avm_cmp_p_sub_b_lo, Transcript::proof_data); - serialize_to_buffer(avm_cmp_p_sub_b_hi, Transcript::proof_data); - serialize_to_buffer(avm_cmp_p_b_borrow, Transcript::proof_data); - serialize_to_buffer(avm_cmp_res_lo, Transcript::proof_data); - serialize_to_buffer(avm_cmp_res_hi, Transcript::proof_data); - serialize_to_buffer(avm_cmp_lt_query, Transcript::proof_data); - serialize_to_buffer(avm_main_sel_rng_8, Transcript::proof_data); - serialize_to_buffer(avm_main_sel_rng_16, Transcript::proof_data); - serialize_to_buffer(avm_main_pc, Transcript::proof_data); - serialize_to_buffer(avm_main_internal_return_ptr, 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_halt, Transcript::proof_data); - serialize_to_buffer(avm_main_sel_mov, Transcript::proof_data); - serialize_to_buffer(avm_main_sel_op_add, Transcript::proof_data); - serialize_to_buffer(avm_main_sel_op_sub, Transcript::proof_data); - serialize_to_buffer(avm_main_sel_op_mul, Transcript::proof_data); - serialize_to_buffer(avm_main_sel_op_div, Transcript::proof_data); - serialize_to_buffer(avm_main_sel_op_not, Transcript::proof_data); - serialize_to_buffer(avm_main_sel_op_eq, Transcript::proof_data); - serialize_to_buffer(avm_main_sel_op_and, Transcript::proof_data); - serialize_to_buffer(avm_main_sel_op_or, Transcript::proof_data); - serialize_to_buffer(avm_main_sel_op_xor, Transcript::proof_data); - serialize_to_buffer(avm_main_sel_op_lt, Transcript::proof_data); - serialize_to_buffer(avm_main_sel_op_lte, Transcript::proof_data); + serialize_to_buffer(avm_binary_op_id, Transcript::proof_data); + serialize_to_buffer(avm_binary_start, Transcript::proof_data); + serialize_to_buffer(avm_byte_lookup_bin_sel, Transcript::proof_data); + serialize_to_buffer(avm_byte_lookup_table_byte_lengths, Transcript::proof_data); + serialize_to_buffer(avm_byte_lookup_table_in_tags, Transcript::proof_data); + serialize_to_buffer(avm_byte_lookup_table_input_a, Transcript::proof_data); + serialize_to_buffer(avm_byte_lookup_table_input_b, Transcript::proof_data); + serialize_to_buffer(avm_byte_lookup_table_op_id, Transcript::proof_data); + serialize_to_buffer(avm_byte_lookup_table_output, Transcript::proof_data); serialize_to_buffer(avm_main_alu_sel, Transcript::proof_data); + serialize_to_buffer(avm_main_bin_op_id, Transcript::proof_data); serialize_to_buffer(avm_main_bin_sel, Transcript::proof_data); serialize_to_buffer(avm_main_cmp_sel, Transcript::proof_data); - serialize_to_buffer(avm_main_r_in_tag, Transcript::proof_data); - serialize_to_buffer(avm_main_w_in_tag, Transcript::proof_data); - serialize_to_buffer(avm_main_op_err, Transcript::proof_data); - serialize_to_buffer(avm_main_tag_err, Transcript::proof_data); - serialize_to_buffer(avm_main_inv, Transcript::proof_data); 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_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_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_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_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_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_last, Transcript::proof_data); - serialize_to_buffer(avm_main_bin_op_id, 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_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_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_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); + serialize_to_buffer(avm_main_sel_op_eq, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_op_lt, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_op_lte, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_op_mul, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_op_not, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_op_or, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_op_sub, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_op_xor, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_rng_16, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_rng_8, Transcript::proof_data); + serialize_to_buffer(avm_main_tag_err, Transcript::proof_data); + serialize_to_buffer(avm_main_w_in_tag, Transcript::proof_data); + serialize_to_buffer(avm_mem_addr, Transcript::proof_data); + serialize_to_buffer(avm_mem_clk, Transcript::proof_data); + 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_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_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_sub_clk, Transcript::proof_data); + serialize_to_buffer(avm_mem_tag, Transcript::proof_data); + serialize_to_buffer(avm_mem_tag_err, Transcript::proof_data); + serialize_to_buffer(avm_mem_val, Transcript::proof_data); + serialize_to_buffer(avm_mem_w_in_tag, Transcript::proof_data); serialize_to_buffer(perm_main_alu, Transcript::proof_data); serialize_to_buffer(perm_main_bin, Transcript::proof_data); serialize_to_buffer(perm_main_cmp, 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 01dbe920a926..c89b58efd8d0 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp @@ -51,70 +51,59 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) } // Get commitments to VM wires - commitments.avm_mem_clk = transcript->template receive_from_prover(commitment_labels.avm_mem_clk); - commitments.avm_mem_sub_clk = - transcript->template receive_from_prover(commitment_labels.avm_mem_sub_clk); - commitments.avm_mem_addr = transcript->template receive_from_prover(commitment_labels.avm_mem_addr); - commitments.avm_mem_tag = transcript->template receive_from_prover(commitment_labels.avm_mem_tag); - commitments.avm_mem_val = transcript->template receive_from_prover(commitment_labels.avm_mem_val); - commitments.avm_mem_lastAccess = - transcript->template receive_from_prover(commitment_labels.avm_mem_lastAccess); - commitments.avm_mem_last = transcript->template receive_from_prover(commitment_labels.avm_mem_last); - commitments.avm_mem_rw = transcript->template receive_from_prover(commitment_labels.avm_mem_rw); - commitments.avm_mem_r_in_tag = - transcript->template receive_from_prover(commitment_labels.avm_mem_r_in_tag); - commitments.avm_mem_w_in_tag = - transcript->template receive_from_prover(commitment_labels.avm_mem_w_in_tag); - 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_ind_op_a = - transcript->template receive_from_prover(commitment_labels.avm_mem_ind_op_a); - commitments.avm_mem_ind_op_b = - 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_sel_mov = - transcript->template receive_from_prover(commitment_labels.avm_mem_sel_mov); - commitments.avm_mem_tag_err = - transcript->template receive_from_prover(commitment_labels.avm_mem_tag_err); - commitments.avm_mem_one_min_inv = - transcript->template receive_from_prover(commitment_labels.avm_mem_one_min_inv); + commitments.avm_alu_a_hi = transcript->template receive_from_prover(commitment_labels.avm_alu_a_hi); + commitments.avm_alu_a_lo = transcript->template receive_from_prover(commitment_labels.avm_alu_a_lo); + commitments.avm_alu_alu_sel = + transcript->template receive_from_prover(commitment_labels.avm_alu_alu_sel); + commitments.avm_alu_b_hi = transcript->template receive_from_prover(commitment_labels.avm_alu_b_hi); + commitments.avm_alu_b_lo = transcript->template receive_from_prover(commitment_labels.avm_alu_b_lo); + commitments.avm_alu_borrow = transcript->template receive_from_prover(commitment_labels.avm_alu_borrow); + commitments.avm_alu_cf = transcript->template receive_from_prover(commitment_labels.avm_alu_cf); commitments.avm_alu_clk = transcript->template receive_from_prover(commitment_labels.avm_alu_clk); + commitments.avm_alu_cmp_sel = + transcript->template receive_from_prover(commitment_labels.avm_alu_cmp_sel); + commitments.avm_alu_ff_tag = transcript->template receive_from_prover(commitment_labels.avm_alu_ff_tag); commitments.avm_alu_ia = transcript->template receive_from_prover(commitment_labels.avm_alu_ia); commitments.avm_alu_ib = transcript->template receive_from_prover(commitment_labels.avm_alu_ib); commitments.avm_alu_ic = transcript->template receive_from_prover(commitment_labels.avm_alu_ic); + commitments.avm_alu_in_tag = transcript->template receive_from_prover(commitment_labels.avm_alu_in_tag); + commitments.avm_alu_input_ia = + transcript->template receive_from_prover(commitment_labels.avm_alu_input_ia); + commitments.avm_alu_input_ib = + transcript->template receive_from_prover(commitment_labels.avm_alu_input_ib); + commitments.avm_alu_lt_sel = transcript->template receive_from_prover(commitment_labels.avm_alu_lt_sel); + commitments.avm_alu_lte_sel = + transcript->template receive_from_prover(commitment_labels.avm_alu_lte_sel); commitments.avm_alu_op_add = transcript->template receive_from_prover(commitment_labels.avm_alu_op_add); - commitments.avm_alu_op_sub = transcript->template receive_from_prover(commitment_labels.avm_alu_op_sub); - commitments.avm_alu_op_mul = transcript->template receive_from_prover(commitment_labels.avm_alu_op_mul); commitments.avm_alu_op_div = transcript->template receive_from_prover(commitment_labels.avm_alu_op_div); - commitments.avm_alu_op_not = transcript->template receive_from_prover(commitment_labels.avm_alu_op_not); commitments.avm_alu_op_eq = transcript->template receive_from_prover(commitment_labels.avm_alu_op_eq); - commitments.avm_alu_alu_sel = - transcript->template receive_from_prover(commitment_labels.avm_alu_alu_sel); - commitments.avm_alu_in_tag = transcript->template receive_from_prover(commitment_labels.avm_alu_in_tag); - commitments.avm_alu_ff_tag = transcript->template receive_from_prover(commitment_labels.avm_alu_ff_tag); - commitments.avm_alu_u8_tag = transcript->template receive_from_prover(commitment_labels.avm_alu_u8_tag); - commitments.avm_alu_u16_tag = - transcript->template receive_from_prover(commitment_labels.avm_alu_u16_tag); - commitments.avm_alu_u32_tag = - transcript->template receive_from_prover(commitment_labels.avm_alu_u32_tag); - commitments.avm_alu_u64_tag = - transcript->template receive_from_prover(commitment_labels.avm_alu_u64_tag); + commitments.avm_alu_op_eq_diff_inv = + transcript->template receive_from_prover(commitment_labels.avm_alu_op_eq_diff_inv); + commitments.avm_alu_op_mul = transcript->template receive_from_prover(commitment_labels.avm_alu_op_mul); + commitments.avm_alu_op_not = transcript->template receive_from_prover(commitment_labels.avm_alu_op_not); + commitments.avm_alu_op_sub = transcript->template receive_from_prover(commitment_labels.avm_alu_op_sub); + commitments.avm_alu_p_a_borrow = + transcript->template receive_from_prover(commitment_labels.avm_alu_p_a_borrow); + commitments.avm_alu_p_b_borrow = + transcript->template receive_from_prover(commitment_labels.avm_alu_p_b_borrow); + commitments.avm_alu_p_sub_a_hi = + transcript->template receive_from_prover(commitment_labels.avm_alu_p_sub_a_hi); + commitments.avm_alu_p_sub_a_lo = + transcript->template receive_from_prover(commitment_labels.avm_alu_p_sub_a_lo); + commitments.avm_alu_p_sub_b_hi = + transcript->template receive_from_prover(commitment_labels.avm_alu_p_sub_b_hi); + commitments.avm_alu_p_sub_b_lo = + transcript->template receive_from_prover(commitment_labels.avm_alu_p_sub_b_lo); + commitments.avm_alu_res_hi = transcript->template receive_from_prover(commitment_labels.avm_alu_res_hi); + commitments.avm_alu_res_lo = transcript->template receive_from_prover(commitment_labels.avm_alu_res_lo); + commitments.avm_alu_rng_chk_remaining = + transcript->template receive_from_prover(commitment_labels.avm_alu_rng_chk_remaining); + commitments.avm_alu_rng_chk_sel = + transcript->template receive_from_prover(commitment_labels.avm_alu_rng_chk_sel); commitments.avm_alu_u128_tag = transcript->template receive_from_prover(commitment_labels.avm_alu_u128_tag); - commitments.avm_alu_u8_r0 = transcript->template receive_from_prover(commitment_labels.avm_alu_u8_r0); - commitments.avm_alu_u8_r1 = transcript->template receive_from_prover(commitment_labels.avm_alu_u8_r1); commitments.avm_alu_u16_r0 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r0); commitments.avm_alu_u16_r1 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r1); - commitments.avm_alu_u16_r2 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r2); - commitments.avm_alu_u16_r3 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r3); - commitments.avm_alu_u16_r4 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r4); - commitments.avm_alu_u16_r5 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r5); - commitments.avm_alu_u16_r6 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r6); - commitments.avm_alu_u16_r7 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r7); - commitments.avm_alu_u16_r8 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r8); - commitments.avm_alu_u16_r9 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r9); commitments.avm_alu_u16_r10 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r10); commitments.avm_alu_u16_r11 = @@ -125,152 +114,74 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r13); commitments.avm_alu_u16_r14 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r14); + commitments.avm_alu_u16_r2 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r2); + commitments.avm_alu_u16_r3 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r3); + commitments.avm_alu_u16_r4 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r4); + commitments.avm_alu_u16_r5 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r5); + commitments.avm_alu_u16_r6 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r6); + commitments.avm_alu_u16_r7 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r7); + commitments.avm_alu_u16_r8 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r8); + commitments.avm_alu_u16_r9 = transcript->template receive_from_prover(commitment_labels.avm_alu_u16_r9); + commitments.avm_alu_u16_tag = + transcript->template receive_from_prover(commitment_labels.avm_alu_u16_tag); + commitments.avm_alu_u32_tag = + transcript->template receive_from_prover(commitment_labels.avm_alu_u32_tag); commitments.avm_alu_u64_r0 = transcript->template receive_from_prover(commitment_labels.avm_alu_u64_r0); - commitments.avm_alu_cf = transcript->template receive_from_prover(commitment_labels.avm_alu_cf); - commitments.avm_alu_op_eq_diff_inv = - transcript->template receive_from_prover(commitment_labels.avm_alu_op_eq_diff_inv); - commitments.avm_byte_lookup_table_op_id = - transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_table_op_id); - commitments.avm_byte_lookup_table_input_a = - transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_table_input_a); - commitments.avm_byte_lookup_table_input_b = - transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_table_input_b); - commitments.avm_byte_lookup_table_output = - transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_table_output); - commitments.avm_byte_lookup_bin_sel = - transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_bin_sel); - commitments.avm_byte_lookup_table_in_tags = - transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_table_in_tags); - commitments.avm_byte_lookup_table_byte_lengths = - transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_table_byte_lengths); - commitments.avm_binary_clk = transcript->template receive_from_prover(commitment_labels.avm_binary_clk); - commitments.avm_binary_bin_sel = - transcript->template receive_from_prover(commitment_labels.avm_binary_bin_sel); + commitments.avm_alu_u64_tag = + transcript->template receive_from_prover(commitment_labels.avm_alu_u64_tag); + commitments.avm_alu_u8_r0 = transcript->template receive_from_prover(commitment_labels.avm_alu_u8_r0); + commitments.avm_alu_u8_r1 = transcript->template receive_from_prover(commitment_labels.avm_alu_u8_r1); + commitments.avm_alu_u8_tag = transcript->template receive_from_prover(commitment_labels.avm_alu_u8_tag); commitments.avm_binary_acc_ia = transcript->template receive_from_prover(commitment_labels.avm_binary_acc_ia); commitments.avm_binary_acc_ib = transcript->template receive_from_prover(commitment_labels.avm_binary_acc_ib); commitments.avm_binary_acc_ic = transcript->template receive_from_prover(commitment_labels.avm_binary_acc_ic); - commitments.avm_binary_in_tag = - transcript->template receive_from_prover(commitment_labels.avm_binary_in_tag); - commitments.avm_binary_op_id = - transcript->template receive_from_prover(commitment_labels.avm_binary_op_id); + commitments.avm_binary_bin_sel = + transcript->template receive_from_prover(commitment_labels.avm_binary_bin_sel); + commitments.avm_binary_clk = transcript->template receive_from_prover(commitment_labels.avm_binary_clk); commitments.avm_binary_ia_bytes = transcript->template receive_from_prover(commitment_labels.avm_binary_ia_bytes); commitments.avm_binary_ib_bytes = transcript->template receive_from_prover(commitment_labels.avm_binary_ib_bytes); commitments.avm_binary_ic_bytes = transcript->template receive_from_prover(commitment_labels.avm_binary_ic_bytes); - commitments.avm_binary_start = - transcript->template receive_from_prover(commitment_labels.avm_binary_start); + commitments.avm_binary_in_tag = + transcript->template receive_from_prover(commitment_labels.avm_binary_in_tag); commitments.avm_binary_mem_tag_ctr = transcript->template receive_from_prover(commitment_labels.avm_binary_mem_tag_ctr); commitments.avm_binary_mem_tag_ctr_inv = transcript->template receive_from_prover(commitment_labels.avm_binary_mem_tag_ctr_inv); - commitments.avm_cmp_cmp_clk = - transcript->template receive_from_prover(commitment_labels.avm_cmp_cmp_clk); - commitments.avm_cmp_ia = transcript->template receive_from_prover(commitment_labels.avm_cmp_ia); - commitments.avm_cmp_ib = transcript->template receive_from_prover(commitment_labels.avm_cmp_ib); - commitments.avm_cmp_ic = transcript->template receive_from_prover(commitment_labels.avm_cmp_ic); - commitments.avm_cmp_lt_sel = transcript->template receive_from_prover(commitment_labels.avm_cmp_lt_sel); - commitments.avm_cmp_lte_sel = - transcript->template receive_from_prover(commitment_labels.avm_cmp_lte_sel); - commitments.avm_cmp_cmp_sel = - transcript->template receive_from_prover(commitment_labels.avm_cmp_cmp_sel); - commitments.avm_cmp_input_ia = - transcript->template receive_from_prover(commitment_labels.avm_cmp_input_ia); - commitments.avm_cmp_input_ib = - transcript->template receive_from_prover(commitment_labels.avm_cmp_input_ib); - commitments.avm_cmp_a_lo = transcript->template receive_from_prover(commitment_labels.avm_cmp_a_lo); - commitments.avm_cmp_a_hi = transcript->template receive_from_prover(commitment_labels.avm_cmp_a_hi); - commitments.avm_cmp_b_lo = transcript->template receive_from_prover(commitment_labels.avm_cmp_b_lo); - commitments.avm_cmp_b_hi = transcript->template receive_from_prover(commitment_labels.avm_cmp_b_hi); - commitments.avm_cmp_borrow = transcript->template receive_from_prover(commitment_labels.avm_cmp_borrow); - commitments.avm_cmp_p_lo = transcript->template receive_from_prover(commitment_labels.avm_cmp_p_lo); - commitments.avm_cmp_p_hi = transcript->template receive_from_prover(commitment_labels.avm_cmp_p_hi); - commitments.avm_cmp_p_sub_a_lo = - transcript->template receive_from_prover(commitment_labels.avm_cmp_p_sub_a_lo); - commitments.avm_cmp_p_sub_a_hi = - transcript->template receive_from_prover(commitment_labels.avm_cmp_p_sub_a_hi); - commitments.avm_cmp_p_a_borrow = - transcript->template receive_from_prover(commitment_labels.avm_cmp_p_a_borrow); - commitments.avm_cmp_p_sub_b_lo = - transcript->template receive_from_prover(commitment_labels.avm_cmp_p_sub_b_lo); - commitments.avm_cmp_p_sub_b_hi = - transcript->template receive_from_prover(commitment_labels.avm_cmp_p_sub_b_hi); - commitments.avm_cmp_p_b_borrow = - transcript->template receive_from_prover(commitment_labels.avm_cmp_p_b_borrow); - commitments.avm_cmp_res_lo = transcript->template receive_from_prover(commitment_labels.avm_cmp_res_lo); - commitments.avm_cmp_res_hi = transcript->template receive_from_prover(commitment_labels.avm_cmp_res_hi); - commitments.avm_cmp_lt_query = - transcript->template receive_from_prover(commitment_labels.avm_cmp_lt_query); - commitments.avm_main_sel_rng_8 = - transcript->template receive_from_prover(commitment_labels.avm_main_sel_rng_8); - commitments.avm_main_sel_rng_16 = - transcript->template receive_from_prover(commitment_labels.avm_main_sel_rng_16); - commitments.avm_main_pc = transcript->template receive_from_prover(commitment_labels.avm_main_pc); - commitments.avm_main_internal_return_ptr = - transcript->template receive_from_prover(commitment_labels.avm_main_internal_return_ptr); - commitments.avm_main_sel_internal_call = - transcript->template receive_from_prover(commitment_labels.avm_main_sel_internal_call); - commitments.avm_main_sel_internal_return = - transcript->template receive_from_prover(commitment_labels.avm_main_sel_internal_return); - commitments.avm_main_sel_jump = - transcript->template receive_from_prover(commitment_labels.avm_main_sel_jump); - commitments.avm_main_sel_halt = - transcript->template receive_from_prover(commitment_labels.avm_main_sel_halt); - commitments.avm_main_sel_mov = - transcript->template receive_from_prover(commitment_labels.avm_main_sel_mov); - commitments.avm_main_sel_op_add = - transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_add); - commitments.avm_main_sel_op_sub = - transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_sub); - commitments.avm_main_sel_op_mul = - transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_mul); - commitments.avm_main_sel_op_div = - transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_div); - commitments.avm_main_sel_op_not = - transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_not); - commitments.avm_main_sel_op_eq = - transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_eq); - commitments.avm_main_sel_op_and = - transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_and); - commitments.avm_main_sel_op_or = - transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_or); - commitments.avm_main_sel_op_xor = - transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_xor); - commitments.avm_main_sel_op_lt = - transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_lt); - commitments.avm_main_sel_op_lte = - transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_lte); + commitments.avm_binary_op_id = + transcript->template receive_from_prover(commitment_labels.avm_binary_op_id); + commitments.avm_binary_start = + transcript->template receive_from_prover(commitment_labels.avm_binary_start); + commitments.avm_byte_lookup_bin_sel = + transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_bin_sel); + commitments.avm_byte_lookup_table_byte_lengths = + transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_table_byte_lengths); + commitments.avm_byte_lookup_table_in_tags = + transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_table_in_tags); + commitments.avm_byte_lookup_table_input_a = + transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_table_input_a); + commitments.avm_byte_lookup_table_input_b = + transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_table_input_b); + commitments.avm_byte_lookup_table_op_id = + transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_table_op_id); + commitments.avm_byte_lookup_table_output = + transcript->template receive_from_prover(commitment_labels.avm_byte_lookup_table_output); commitments.avm_main_alu_sel = transcript->template receive_from_prover(commitment_labels.avm_main_alu_sel); + commitments.avm_main_bin_op_id = + transcript->template receive_from_prover(commitment_labels.avm_main_bin_op_id); commitments.avm_main_bin_sel = transcript->template receive_from_prover(commitment_labels.avm_main_bin_sel); commitments.avm_main_cmp_sel = transcript->template receive_from_prover(commitment_labels.avm_main_cmp_sel); - commitments.avm_main_r_in_tag = - transcript->template receive_from_prover(commitment_labels.avm_main_r_in_tag); - commitments.avm_main_w_in_tag = - transcript->template receive_from_prover(commitment_labels.avm_main_w_in_tag); - commitments.avm_main_op_err = - transcript->template receive_from_prover(commitment_labels.avm_main_op_err); - commitments.avm_main_tag_err = - transcript->template receive_from_prover(commitment_labels.avm_main_tag_err); - commitments.avm_main_inv = transcript->template receive_from_prover(commitment_labels.avm_main_inv); 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_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_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_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); @@ -280,6 +191,10 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) 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_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); + commitments.avm_main_last = transcript->template receive_from_prover(commitment_labels.avm_main_last); commitments.avm_main_mem_idx_a = transcript->template receive_from_prover(commitment_labels.avm_main_mem_idx_a); commitments.avm_main_mem_idx_b = @@ -287,6 +202,9 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) commitments.avm_main_mem_idx_c = transcript->template receive_from_prover(commitment_labels.avm_main_mem_idx_c); <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> a43e384f0 (feat: range_chk for cmp) commitments.avm_main_mem_op_a = transcript->template receive_from_prover(commitment_labels.avm_main_mem_op_a); commitments.avm_main_mem_op_b = @@ -319,6 +237,13 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_div); commitments.avm_main_sel_op_eq = transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_eq); +<<<<<<< HEAD +======= + commitments.avm_main_sel_op_lt = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_lt); + commitments.avm_main_sel_op_lte = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_lte); +>>>>>>> a43e384f0 (feat: range_chk for cmp) commitments.avm_main_sel_op_mul = transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_mul); commitments.avm_main_sel_op_not = @@ -366,6 +291,7 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) commitments.avm_mem_val = transcript->template receive_from_prover(commitment_labels.avm_mem_val); commitments.avm_mem_w_in_tag = transcript->template receive_from_prover(commitment_labels.avm_mem_w_in_tag); +<<<<<<< HEAD // Lookup counts commitments.lookup_byte_lengths_counts = @@ -388,6 +314,8 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) commitments.avm_main_bin_op_id = transcript->template receive_from_prover(commitment_labels.avm_main_bin_op_id); >>>>>>> 7a982d52c (feat: init avm cmp) +======= +>>>>>>> a43e384f0 (feat: range_chk for cmp) commitments.perm_main_alu = transcript->template receive_from_prover(commitment_labels.perm_main_alu); commitments.perm_main_bin = transcript->template receive_from_prover(commitment_labels.perm_main_bin); commitments.perm_main_cmp = transcript->template receive_from_prover(commitment_labels.perm_main_cmp); From 56b314eba35f82f5d4aec006f9a03dafb9f82bf1 Mon Sep 17 00:00:00 2001 From: IlyasRidhuan Date: Wed, 3 Apr 2024 16:48:33 +0000 Subject: [PATCH 03/18] fix:wip --- .../relations/generated/avm/avm_alu.hpp | 123 +++++++++--------- .../vm/avm_trace/avm_alu_trace.cpp | 53 ++++---- 2 files changed, 86 insertions(+), 90 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 0c634c61ef81..91ec44f46158 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_alu.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_alu.hpp @@ -219,18 +219,18 @@ 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_op_add + avm_alu_op_sub) * + ((((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + + (avm_alu_u16_r1 * FF(4294967296UL))) + + (avm_alu_u16_r2 * FF(281474976710656UL))) + + (avm_alu_u16_r3 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + + (avm_alu_u16_r4 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + + (avm_alu_u16_r5 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + + (avm_alu_u16_r6 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }))) - + avm_alu_ia) + + (avm_alu_ff_tag * avm_alu_ic))) + + ((avm_alu_op_add - avm_alu_op_sub) * + ((avm_alu_cf * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL })) - avm_alu_ib))); tmp *= scaling_factor; std::get<9>(evals) += tmp; } @@ -251,10 +251,10 @@ template class avm_aluImpl { ((((((((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_u16_r3 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + + (avm_alu_u16_r4 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + + (avm_alu_u16_r5 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + + (avm_alu_u16_r6 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }))))) + (avm_alu_ff_tag * avm_alu_ia)) - avm_alu_ic)) + ((avm_alu_ff_tag * (avm_alu_op_add - avm_alu_op_sub)) * avm_alu_ib)); @@ -277,10 +277,10 @@ template class avm_aluImpl { (((((((((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_u16_r3 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + + (avm_alu_u16_r4 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + + (avm_alu_u16_r5 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + + (avm_alu_u16_r6 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }))) - (avm_alu_ia * avm_alu_ib))); tmp *= scaling_factor; std::get<12>(evals) += tmp; @@ -310,7 +310,7 @@ template class avm_aluImpl { (avm_alu_u16_r3 * FF(281474976710656UL))) + ((((avm_alu_u16_r4 + (avm_alu_u16_r5 * FF(65536))) + (avm_alu_u16_r6 * FF(4294967296UL))) + (avm_alu_u16_r7 * FF(281474976710656UL))) * - FF(uint256_t{ 0, 1, 0, 0 }))) - + FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) - avm_alu_ia)); tmp *= scaling_factor; std::get<14>(evals) += tmp; @@ -326,7 +326,7 @@ template class avm_aluImpl { ((((avm_alu_u16_r4_shift + (avm_alu_u16_r5_shift * FF(65536))) + (avm_alu_u16_r6_shift * FF(4294967296UL))) + (avm_alu_u16_r7_shift * FF(281474976710656UL))) * - FF(uint256_t{ 0, 1, 0, 0 }))) - + FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) - avm_alu_ib)); tmp *= scaling_factor; std::get<15>(evals) += tmp; @@ -335,19 +335,19 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(16); - auto tmp = - ((avm_alu_u128_tag * avm_alu_op_mul) * - ((((avm_alu_ia * (((avm_alu_u16_r0_shift + (avm_alu_u16_r1_shift * FF(65536))) + - (avm_alu_u16_r2_shift * FF(4294967296UL))) + - (avm_alu_u16_r3_shift * FF(281474976710656UL)))) + - (((((avm_alu_u16_r0 + (avm_alu_u16_r1 * FF(65536))) + (avm_alu_u16_r2 * FF(4294967296UL))) + - (avm_alu_u16_r3 * FF(281474976710656UL))) * - (((avm_alu_u16_r4_shift + (avm_alu_u16_r5_shift * FF(65536))) + - (avm_alu_u16_r6_shift * FF(4294967296UL))) + - (avm_alu_u16_r7_shift * FF(281474976710656UL)))) * - FF(uint256_t{ 0, 1, 0, 0 }))) - - (((avm_alu_cf * FF(uint256_t{ 0, 1, 0, 0 })) + avm_alu_u64_r0) * FF(uint256_t{ 0, 0, 1, 0 }))) - - avm_alu_ic)); + auto tmp = ((avm_alu_u128_tag * avm_alu_op_mul) * + ((((avm_alu_ia * (((avm_alu_u16_r0_shift + (avm_alu_u16_r1_shift * FF(65536))) + + (avm_alu_u16_r2_shift * FF(4294967296UL))) + + (avm_alu_u16_r3_shift * FF(281474976710656UL)))) + + (((((avm_alu_u16_r0 + (avm_alu_u16_r1 * FF(65536))) + (avm_alu_u16_r2 * FF(4294967296UL))) + + (avm_alu_u16_r3 * FF(281474976710656UL))) * + (((avm_alu_u16_r4_shift + (avm_alu_u16_r5_shift * FF(65536))) + + (avm_alu_u16_r6_shift * FF(4294967296UL))) + + (avm_alu_u16_r7_shift * FF(281474976710656UL)))) * + FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) - + (((avm_alu_cf * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL })) + avm_alu_u64_r0) * + FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) - + avm_alu_ic)); tmp *= scaling_factor; std::get<16>(evals) += tmp; } @@ -366,8 +366,8 @@ template class avm_aluImpl { 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 }))) - + (avm_alu_u64_tag * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + + (avm_alu_u128_tag * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) - FF(1)))); tmp *= scaling_factor; std::get<18>(evals) += tmp; @@ -452,8 +452,8 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(28); - auto tmp = - (avm_alu_input_ia - ((avm_alu_a_lo + (avm_alu_a_hi * FF(uint256_t{ 0, 0, 1, 0 }))) * avm_alu_cmp_sel)); + auto tmp = (avm_alu_input_ia - + ((avm_alu_a_lo + (avm_alu_a_hi * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) * avm_alu_cmp_sel)); tmp *= scaling_factor; std::get<28>(evals) += tmp; } @@ -461,8 +461,8 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(29); - auto tmp = - (avm_alu_input_ib - ((avm_alu_b_lo + (avm_alu_b_hi * FF(uint256_t{ 0, 0, 1, 0 }))) * avm_alu_cmp_sel)); + auto tmp = (avm_alu_input_ib - + ((avm_alu_b_lo + (avm_alu_b_hi * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) * avm_alu_cmp_sel)); tmp *= scaling_factor; std::get<29>(evals) += tmp; } @@ -471,8 +471,8 @@ template class avm_aluImpl { Avm_DECLARE_VIEWS(30); auto tmp = (avm_alu_p_sub_a_lo - - (((-avm_alu_a_lo + FF(uint256_t{ 4891460686036598784, 2896914383306846353, 0, 0 })) + - (avm_alu_p_a_borrow * FF(uint256_t{ 0, 0, 1, 0 }))) * + (((-avm_alu_a_lo + FF(uint256_t{ 4891460686036598784UL, 2896914383306846353UL, 0UL, 0UL })) + + (avm_alu_p_a_borrow * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) * avm_alu_cmp_sel)); tmp *= scaling_factor; std::get<30>(evals) += tmp; @@ -482,7 +482,7 @@ template class avm_aluImpl { Avm_DECLARE_VIEWS(31); auto tmp = (avm_alu_p_sub_a_hi - - (((-avm_alu_a_hi + FF(uint256_t{ 13281191951274694749, 3486998266802970665, 0, 0 })) - + (((-avm_alu_a_hi + FF(uint256_t{ 13281191951274694749UL, 3486998266802970665UL, 0UL, 0UL })) - avm_alu_p_a_borrow) * avm_alu_cmp_sel)); tmp *= scaling_factor; @@ -493,8 +493,8 @@ template class avm_aluImpl { Avm_DECLARE_VIEWS(32); auto tmp = (avm_alu_p_sub_b_lo - - (((-avm_alu_b_lo + FF(uint256_t{ 4891460686036598784, 2896914383306846353, 0, 0 })) + - (avm_alu_p_b_borrow * FF(uint256_t{ 0, 0, 1, 0 }))) * + (((-avm_alu_b_lo + FF(uint256_t{ 4891460686036598784UL, 2896914383306846353UL, 0UL, 0UL })) + + (avm_alu_p_b_borrow * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) * avm_alu_cmp_sel)); tmp *= scaling_factor; std::get<32>(evals) += tmp; @@ -504,7 +504,7 @@ template class avm_aluImpl { Avm_DECLARE_VIEWS(33); auto tmp = (avm_alu_p_sub_b_hi - - (((-avm_alu_b_hi + FF(uint256_t{ 13281191951274694749, 3486998266802970665, 0, 0 })) - + (((-avm_alu_b_hi + FF(uint256_t{ 13281191951274694749UL, 3486998266802970665UL, 0UL, 0UL })) - avm_alu_p_b_borrow) * avm_alu_cmp_sel)); tmp *= scaling_factor; @@ -514,12 +514,13 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(34); - auto tmp = (avm_alu_res_lo - - ((((((avm_alu_a_lo - avm_alu_b_lo) - FF(1)) + (avm_alu_borrow * FF(uint256_t{ 0, 0, 1, 0 }))) * - ((avm_alu_lt_sel * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_lte_sel))) + - (((avm_alu_b_lo - avm_alu_a_lo) + (avm_alu_borrow * FF(uint256_t{ 0, 0, 1, 0 }))) * - (-((avm_alu_lt_sel * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_lte_sel)) + FF(1)))) * - avm_alu_cmp_sel)); + auto tmp = + (avm_alu_res_lo - + ((((((avm_alu_a_lo - avm_alu_b_lo) - FF(1)) + (avm_alu_borrow * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) * + ((avm_alu_lt_sel * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_lte_sel))) + + (((avm_alu_b_lo - avm_alu_a_lo) + (avm_alu_borrow * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) * + (-((avm_alu_lt_sel * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_lte_sel)) + FF(1)))) * + avm_alu_cmp_sel)); tmp *= scaling_factor; std::get<34>(evals) += tmp; } @@ -588,10 +589,10 @@ template class avm_aluImpl { (avm_alu_a_lo - (((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + (avm_alu_u16_r1 * FF(4294967296UL))) + (avm_alu_u16_r2 * FF(281474976710656UL))) + - (avm_alu_u16_r3 * FF(uint256_t{ 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_u16_r3 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + + (avm_alu_u16_r4 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + + (avm_alu_u16_r5 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + + (avm_alu_u16_r6 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }))) * (avm_alu_rng_chk_sel + avm_alu_cmp_sel))); tmp *= scaling_factor; std::get<41>(evals) += tmp; @@ -603,10 +604,10 @@ template class avm_aluImpl { auto tmp = (avm_alu_a_hi - ((((((((avm_alu_u16_r7 + (avm_alu_u16_r8 * FF(65536))) + (avm_alu_u16_r9 * FF(4294967296UL))) + (avm_alu_u16_r10 * FF(281474976710656UL))) + - (avm_alu_u16_r11 * FF(uint256_t{ 0, 1, 0, 0 }))) + - (avm_alu_u16_r12 * FF(uint256_t{ 0, 65536, 0, 0 }))) + - (avm_alu_u16_r13 * FF(uint256_t{ 0, 4294967296, 0, 0 }))) + - (avm_alu_u16_r14 * FF(uint256_t{ 0, 281474976710656, 0, 0 }))) * + (avm_alu_u16_r11 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + + (avm_alu_u16_r12 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + + (avm_alu_u16_r13 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + + (avm_alu_u16_r14 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }))) * (avm_alu_rng_chk_sel + avm_alu_cmp_sel))); tmp *= scaling_factor; std::get<42>(evals) += tmp; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.cpp index 0c544738d9ed..6552edca0ef4 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.cpp @@ -443,33 +443,28 @@ FF AvmAluTraceBuilder::op_eq(FF const& a, FF const& b, AvmMemoryTag in_tag, uint * @return FF The boolean result of equality casted to a finite field element */ -FF AvmAluTraceBuilder::op_lt(FF const& a, FF const& b, AvmMemoryTag in_tag, uint32_t const clk) -{ - FF c = a < b ? FF ::one() : FF::zero(); - - alu_trace.push_back(AvmAluTraceBuilder::AluTraceEntry { - .alu_clk = clk, .alu_op_eq = true, .alu_ff_tag = in_tag == AvmMemoryTag::FF, - .alu_u8_tag = in_tag == AvmMemoryTag::U8, .alu_u16_tag = in_tag == AvmMemoryTag::U16, - .alu_u32_tag = in_tag == AvmMemoryTag::U32, .alu_u64_tag = in_tag == AvmMemoryTag::U64, - .alu_u128_tag = in_tag == AvmMemoryTag::U128, .alu_ia = a, .alu_ib = b, .alu_ic = res, - .alu_op_eq_diff_inv = inv_c, .input_ia = b, .input_ib = a, bool borrow, - - uint128_t a_lo; - uint128_t a_hi; - uint128_t b_lo; - uint128_t b_hi; - - uint128_t p_sub_a_lo; - uint128_t p_sub_a_hi; - bool p_a_borrow; - uint128_t p_sub_b_lo; - uint128_t p_sub_b_hi; - bool p_b_borrow; - - uint128_t res_lo; - uint128_t res_hi; - }); - - return res; -} +// FF AvmAluTraceBuilder::op_lt(FF const& a, FF const& b, AvmMemoryTag in_tag, uint32_t const clk) +// { +// FF c = a < b ? FF ::one() : FF::zero(); +// +// alu_trace.push_back(AvmAluTraceBuilder::AluTraceEntry{ +// .alu_clk = clk, +// .alu_op_eq = true, +// .alu_ff_tag = in_tag == AvmMemoryTag::FF, +// .alu_u8_tag = in_tag == AvmMemoryTag::U8, +// .alu_u16_tag = in_tag == AvmMemoryTag::U16, +// .alu_u32_tag = in_tag == AvmMemoryTag::U32, +// .alu_u64_tag = in_tag == AvmMemoryTag::U64, +// .alu_u128_tag = in_tag == AvmMemoryTag::U128, +// .alu_ia = a, +// .alu_ib = b, +// .alu_ic = res, +// .alu_op_eq_diff_inv = inv_c, +// .input_ia = b, +// .input_ib = a, +// bool borrow, +// }); +// +// return res; +// } } // namespace bb::avm_trace From c6cca9096f03a3c873a56786ddb57b098139de2c Mon Sep 17 00:00:00 2001 From: IlyasRidhuan Date: Thu, 4 Apr 2024 21:13:08 +0000 Subject: [PATCH 04/18] fix: address initial comments --- barretenberg/cpp/pil/avm/avm_alu.pil | 43 +++++++++++---------------- barretenberg/cpp/pil/avm/avm_main.pil | 13 ++------ 2 files changed, 20 insertions(+), 36 deletions(-) diff --git a/barretenberg/cpp/pil/avm/avm_alu.pil b/barretenberg/cpp/pil/avm/avm_alu.pil index 782e3a5663f9..92062afd3c2b 100644 --- a/barretenberg/cpp/pil/avm/avm_alu.pil +++ b/barretenberg/cpp/pil/avm/avm_alu.pil @@ -266,17 +266,12 @@ namespace avm_alu(256); // ========= LT/LTE Operation Constraints =============================== - pol commit lt_sel; - pol commit lte_sel; - // Both are restricted to booleans - lt_sel * (1 - lt_sel) = 0; - lte_sel * (1 - lte_sel) = 0; + pol commit op_lt; + pol commit op_lte; // Used for perm check to main, designates if a comparison operation is being used. pol commit cmp_sel; - cmp_sel = lt_sel + lte_sel; - // NAND check for selectors - lt_sel * lte_sel = 0; + cmp_sel = op_lt + op_lte; // ic is restricted to be 1 or 0 if we are performing a comparison cmp_sel * (ic * (1 - ic)) = 0; @@ -285,11 +280,11 @@ namespace avm_alu(256); // There are two routines that we utilise as part of this LT/LTE check // (1) Decomposition into two 128-bit limbs, lo and hi respectively and a borrow (1 or 0); - // (2) 128 bit range checks when checking an arithmetic operations has not overflowed the field. + // (2) 128 bit-range checks when checking an arithmetic operation has not overflowed the field. // ========= COMPARISON OPERATION - EXPLANATIONS ================================================= // To simplify the comparison circuit, we implement a GreaterThan(GT) circuit. This is ideal since - // if we need a LT operation, we just swap the inputs and if we need the LTE operation, we just NOT the query + // if we need a LT operation, we just swap the inputs and if we need the LTE operation, we just NOT the GT constraint // Given the inputs x, y and q where x & y are inputs and q is the boolean result to the query (x > y). Then there are two scenarios // (x > y) -> x - y - 1 = result, where 0 <= result < p. In our case result should not overflow the field. // OR @@ -300,9 +295,9 @@ namespace avm_alu(256); pol commit input_ib; pol commit borrow; - //If LT, then swap ia and ib else keep the same - input_ia = lt_sel * ib + lte_sel * ia; - input_ib = lt_sel * ia + lte_sel * ib; + // If LT, then swap ia and ib else keep the same + input_ia = op_lt * ib + op_lte * ia; + input_ib = op_lt * ia + op_lte * ib; pol commit a_lo; pol commit a_hi; @@ -317,8 +312,10 @@ namespace avm_alu(256); pol commit p_sub_a_lo; // p_lo - a_lo pol commit p_sub_a_hi; // p_hi - a_hi pol commit p_a_borrow; + p_a_borrow * (1 - p_a_borrow) = 0; - // Check that (p > a) by checking (p_lo > a_lo && p_hi >= ahi) || (p_lo <= a_lo && p_hi > a_hi) + // Check that decomposition of a into lo and hi limbs do not overflow p. + // This is achieved by checking (p_lo > a_lo && p_hi >= ahi) || (p_lo <= a_lo && p_hi > a_hi) // First condition is if borrow = 0, second condition is if borrow = 1; // (p - 1) lower 128 bits = 53438638232309528389504892708671455232 // (p - 1) upper 128 bits = 64323764613183177041862057485226039389 @@ -328,8 +325,10 @@ namespace avm_alu(256); pol commit p_sub_b_lo; pol commit p_sub_b_hi; pol commit p_b_borrow; + p_b_borrow * (1 - p_b_borrow) = 0; - // Check that (p > b) by checking (p_lo > b_lo && p_hi >= bhi) || (p_lo <= b_lo && p_hi > b_hi) + // Check that decomposition of b into lo and hi limbs do not overflow p. + // This is achieved by checking (p_lo > b_lo && p_hi >= bhi) || (p_lo <= b_lo && p_hi > b_hi) // First condition is if borrow = 0, second condition is if borrow = 1; p_sub_b_lo = (53438638232309528389504892708671455232 - b_lo + p_b_borrow * 2 ** 128) * cmp_sel; p_sub_b_hi = (64323764613183177041862057485226039389 - b_hi - p_b_borrow) * cmp_sel; @@ -341,7 +340,7 @@ namespace avm_alu(256); pol A_SUB_B_LO = a_lo - b_lo - 1 + borrow * 2 ** 128; pol A_SUB_B_HI = a_hi - b_hi - borrow; - // Check that (a <= b) by checking (b_lo >= a_lo && b_hi >= a_hi) || (b_lo > a_lo && b_hi >= a_hi) + // Check that (a <= b) by checking (b_lo >= a_lo && b_hi >= a_hi) || (b_lo < a_lo && b_hi > a_hi) // First condition is if borrow = 0, second condition is if borrow = 1; pol B_SUB_A_LO = b_lo - a_lo + borrow * 2 ** 128; pol B_SUB_A_HI = b_hi - a_hi - borrow; @@ -351,7 +350,7 @@ namespace avm_alu(256); // If this is a LT operation, we already swapped the inputs so the result of ic is still correct // If this is a LTE operation, we invert the value of ic. - pol IS_GT = lt_sel * ic + (1 - ic) * lte_sel; + pol IS_GT = op_lt * ic + (1 - ic) * op_lte; res_lo = (A_SUB_B_LO * IS_GT + B_SUB_A_LO * (1 - IS_GT)) * cmp_sel; res_hi = (A_SUB_B_HI * IS_GT + B_SUB_A_HI * (1 - IS_GT)) * cmp_sel; @@ -369,12 +368,9 @@ namespace avm_alu(256); (rng_chk_remaining' - 4) * cmp_sel = 0; pol commit rng_chk_sel; // A boolean representing if we have range checks remaining - rng_chk_sel * (1 - rng_chk_sel); + rng_chk_sel * (1 - rng_chk_sel) = 0; rng_chk_sel * cmp_sel = 0; // If we have remaining range checks, we cannot have cmp_sel set - // Needed for equality checking // reuse selector op_eq_diff_inv - // pol commit rng_chk_inv; - // rng_chk_sel = 1 when rng_chk_remaining != 0 and rng_chk_sel = 0 when rng_chk_remaining = 0; rng_chk_remaining * ((1 - rng_chk_sel) * (1 - op_eq_diff_inv) + op_eq_diff_inv) - rng_chk_sel = 0; @@ -382,10 +378,7 @@ namespace avm_alu(256); pol RNG_CHK_OP = (rng_chk_sel + cmp_sel); // Perform 128-bit range check on lo part - a_lo = (u8_r0 + u8_r1 * 2**8 + u16_r0 * 2**16 + - u16_r1 * 2**32 + u16_r2 * 2**48 + - u16_r3 * 2**64 + u16_r4 * 2**80 + - u16_r5 * 2**96 + u16_r6 * 2**112) * (RNG_CHK_OP); + a_lo = SUM_128 * (RNG_CHK_OP); // Perform 128-bit range check on hi part a_hi = (u16_r7 + u16_r8 * 2**16 + diff --git a/barretenberg/cpp/pil/avm/avm_main.pil b/barretenberg/cpp/pil/avm/avm_main.pil index e0c6a7a18c28..69b75af0f05b 100644 --- a/barretenberg/cpp/pil/avm/avm_main.pil +++ b/barretenberg/cpp/pil/avm/avm_main.pil @@ -267,10 +267,10 @@ namespace avm_main(256); #[PERM_MAIN_ALU] alu_sel {clk, ia, ib, ic, sel_op_add, sel_op_sub, - sel_op_mul, sel_op_eq, sel_op_not, r_in_tag} + sel_op_mul, sel_op_eq, sel_op_not, sel_op_lt, sel_op_lte, r_in_tag} is avm_alu.alu_sel {avm_alu.clk, avm_alu.ia, avm_alu.ib, avm_alu.ic, avm_alu.op_add, avm_alu.op_sub, - avm_alu.op_mul, avm_alu.op_eq, avm_alu.op_not, avm_alu.in_tag}; + avm_alu.op_mul, avm_alu.op_eq, avm_alu.op_not, avm_alu.op_lt, avm_alu.op_lte, avm_alu.in_tag}; // Based on the boolean selectors, we derive the binary op id to lookup in the table; // TODO: Check if having 4 columns (op_id + 3 boolean selectors) is more optimal that just using the op_id @@ -285,20 +285,11 @@ namespace avm_main(256); #[BIN_SEL_2] bin_sel = sel_op_and + sel_op_or + sel_op_xor; - // Only 1 of these cmp selectors should be set - #[CMP_SEL] - cmp_sel = sel_op_lt + sel_op_lte; - #[PERM_MAIN_BIN] bin_sel {clk, ia, ib, ic, bin_op_id, r_in_tag} is 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_CMP] - cmp_sel {clk, ia, ib, ic} - is - avm_alu.cmp_sel {avm_alu.clk, avm_alu.ia, avm_alu.ib, avm_alu.ic}; - #[PERM_MAIN_MEM_A] mem_op_a {clk, mem_idx_a, ia, rwa, r_in_tag, w_in_tag, sel_mov} is From 52000ecfd3594ac99593124d1ff759d7caca36cd Mon Sep 17 00:00:00 2001 From: IlyasRidhuan Date: Fri, 5 Apr 2024 09:59:48 +0000 Subject: [PATCH 05/18] fix: address explainer --- barretenberg/cpp/pil/avm/avm_alu.pil | 89 +++++++++++++++++++++++----- 1 file changed, 75 insertions(+), 14 deletions(-) diff --git a/barretenberg/cpp/pil/avm/avm_alu.pil b/barretenberg/cpp/pil/avm/avm_alu.pil index 92062afd3c2b..5dc1fea0b4ca 100644 --- a/barretenberg/cpp/pil/avm/avm_alu.pil +++ b/barretenberg/cpp/pil/avm/avm_alu.pil @@ -285,11 +285,12 @@ namespace avm_alu(256); // ========= COMPARISON OPERATION - EXPLANATIONS ================================================= // To simplify the comparison circuit, we implement a GreaterThan(GT) circuit. This is ideal since // if we need a LT operation, we just swap the inputs and if we need the LTE operation, we just NOT the GT constraint - // Given the inputs x, y and q where x & y are inputs and q is the boolean result to the query (x > y). Then there are two scenarios - // (x > y) -> x - y - 1 = result, where 0 <= result < p. In our case result should not overflow the field. - // OR - // !(x > y) -> !(x - y - 1) = (p - 1) - (x - y -1) = y - x = result, where the same applies as above. - // These conditions can be combined with the query, q (that x > y) as follows: + // Given the inputs x, y and q where x & y are integers in the range [0,...,p-1] and q is the boolean result to the query (x > y). + // Then there are two scenarios: + // (1) (x > y) -> x - y - 1 = result, where 0 <= result. i.e. the result does not underflow the field. + // (2)!(x > y) -> (x <= y) = y - x = result, where the same applies as above. + + // These conditions can be combined with the GT constraint, q (that x > y) as follows: // (x - y - 1) * q + (y - x) (1 - q) = result pol commit input_ia; pol commit input_ib; @@ -314,11 +315,13 @@ namespace avm_alu(256); pol commit p_a_borrow; p_a_borrow * (1 - p_a_borrow) = 0; - // Check that decomposition of a into lo and hi limbs do not overflow p. - // This is achieved by checking (p_lo > a_lo && p_hi >= ahi) || (p_lo <= a_lo && p_hi > a_hi) - // First condition is if borrow = 0, second condition is if borrow = 1; // (p - 1) lower 128 bits = 53438638232309528389504892708671455232 // (p - 1) upper 128 bits = 64323764613183177041862057485226039389 + + // Check that decomposition of a into lo and hi limbs do not overflow p. + // This is achieved by checking a does not underflow p: (p_lo > a_lo && p_hi >= ahi) || (p_lo <= a_lo && p_hi > a_hi) + // First condition is if borrow = 0, second condition is if borrow = 1 + // This underflow check is done by the 128-bit check that is performed on each of these lo and hi limbs. p_sub_a_lo = (53438638232309528389504892708671455232 - a_lo + p_a_borrow * 2 ** 128) * cmp_sel; p_sub_a_hi = (64323764613183177041862057485226039389 - a_hi - p_a_borrow) * cmp_sel; @@ -352,27 +355,85 @@ namespace avm_alu(256); // If this is a LTE operation, we invert the value of ic. pol IS_GT = op_lt * ic + (1 - ic) * op_lte; + // When IS_GT = 1, we enforce the condition that a > b and thus a - b - 1 does not underflow. + // When IS_GT = 0, we enforce the condition that a <= b and thus b - a does not underflow. + // ========= Analysing res_lo and res_hi scenarios for x <= y =============================== + // (1) An honest prover claims that LTE(x,y,1). Therefore ia = x, ib = y and ic = 1. + // (a) We do not swap the operands, so a = x and b = y, + // (b) IS_GT = 1 - ic = 0 + // (c) res_lo = B_SUB_A_LO and res_hi = B_SUB_A_HI + // (d) res_lo = y_lo - x_lo + borrow * 2**128 and res_hi = y_hi - x_hi - borrow. + // (e) the only valid input here to ensure no underflow is + // (i) x == y && borrow = 0 or, + // (ii) x < y where x_lo < y_lo && x_hi <= y_hi && borrow = 0 or + // (iii) x < y where x_lo > y_lo && x_hi < y_hi && borrow = 1 + // + // (2) A malicious prover claims that LTE(x,y,0), i.e. y > x. Therefore ia = x, ib = y and ic = 0. + // (a) We do not swap the operands, so a = x and b = y, + // (b) IS_GT = 1 - ic = 1 + // (c) res_lo = A_SUB_B_LO and res_hi = A_SUB_B_HI + // (d) res_lo = x_lo - y_lo - 1 + borrow * 2**128 and res_hi = x_hi - y_hi - borrow. + // (e) Given that, in reality, x <= y. The following underflows happen + // (i) x == y && borrow = 0, res_lo = -1 and underflows. + // (ii) x == y && borrow = 1, res_hi = -1 and underflows. + // (iii) x < y where x_lo < y_lo && x_hi == y_hi && borrow = 0, res_lo < 0 and underflows + // (iv) x < y where x_lo < y_lo && x_hi == y_hi && borrow = 1, res_hi = -1 and underflows + // (v) x < y where x_lo < y_lo && x_hi < y_hi && borrow = 0, res_lo & res_hi < 0 both underflows + // (vi) x < y where x_lo < y_lo && x_hi < y_hi && borrow = 1, res_hi < 0 and underflows + // (vii) x < y where x_lo == y_lo && x_hi < y_hi && borrow = 0, res_lo = -1 && res_hi < 0 both underflows + // (viii) x < y where x_lo == y_lo && x_hi < y_hi && borrow = 1, res_hi < 0 and underflows + // (ix) x < y where x_lo > y_lo && x_hi < y_hi && borrow = 0, res_hi < 0 and underflows + // (x) x < y where x_lo > y_lo && x_hi < y_hi && borrow = 1, res_hi < 0 and underflows + + + // ========= Analysing res_lo and res_hi scenarios for x < y =============================== + // (1) An honest prover claims that LT(x,y,1). Therefore ia = x, ib = y and ic = 1. + // (a) We DO swap the operands, so a = y and b = x, + // (b) IS_GT = ic = 1 + // (c) res_lo = A_SUB_B_LO and res_hi = A_SUB_B_HI, **remember we have swapped inputs** + // (d) res_lo = y_lo - x_lo - 1 + borrow * 2**128 and res_hi = y_hi - x_hi - borrow. + // (e) the only valid input here to ensure no underflow is + // (i) x < y where x_lo < y_lo && x_hi <= y_hi && borrow = 0 or + // (ii) x < y where x_lo >= y_lo && x_hi < y_hi && borrow = 1 + // + // (2) A malicious prover claims that LT(x,y,0), i.e. !(x < y) -> (x >= y). Therefore ia = x, ib = y and ic = 0. + // (a) We DO swap the operands, so a = y and b = x, + // (b) IS_GT = ic = 0 + // (c) res_lo = B_SUB_A_LO and res_hi = B_SUB_A_HI, **remember we have swapped inputs** + // (d) res_lo = x_lo - y_lo + borrow * 2**128 and res_hi = x_hi - y_hi - borrow. + // (e) Given that, in reality, x < y. The following underflows happen + // (i) x < y where x_lo < y_lo && x_hi == y_hi && borrow = 0, res_lo < 0 and underflows + // (ii) x < y where x_lo < y_lo && x_hi == y_hi && borrow = 1, res_hi = -1 and underflows + // (iii) x < y where x_lo < y_lo && x_hi < y_hi && borrow = 0, res_lo && res_hi < 0 and underflows + // (iv) x < y where x_lo < y_lo && x_hi < y_hi && borrow = 1, res_hi < 0 and underflows + // (v) x < y where x_lo > y_lo && x_hi < y_hi && borrow = 0, res_hi < 0 and underflows + // (vi) x < y where x_lo > y_lo && x_hi < y_hi && borrow = 1, res_lo overflows && res_hi < 0 and underflows + res_lo = (A_SUB_B_LO * IS_GT + B_SUB_A_LO * (1 - IS_GT)) * cmp_sel; res_hi = (A_SUB_B_HI * IS_GT + B_SUB_A_HI * (1 - IS_GT)) * cmp_sel; // ========= RANGE OPERATIONS =============================== + // TODO: 8-bit and 16-bit range checks for the respective registers have not yet been implemented. + // Each call to LT/LTE requires 5x 256-bit range checks. We keep track of how many are left here. - pol commit rng_chk_remaining; + pol commit cmp_rng_ctr; // TODO: combine into 1 equation, left separate for debugging // the number of range checks must decrement by 1 until it is equal to 0; - (rng_chk_remaining' - rng_chk_remaining + 1) * rng_chk_remaining = 0; + (cmp_rng_ctr' - cmp_rng_ctr + 1) * cmp_rng_ctr = 0; // if this row is a comparison operation, the next range_check_remaining value is set to 4 // it is not set to 5 since we do 1 as part of the comparison. - (rng_chk_remaining' - 4) * cmp_sel = 0; + (cmp_rng_ctr' - 4) * cmp_sel = 0; pol commit rng_chk_sel; // A boolean representing if we have range checks remaining rng_chk_sel * (1 - rng_chk_sel) = 0; - rng_chk_sel * cmp_sel = 0; // If we have remaining range checks, we cannot have cmp_sel set + // If we have remaining range checks, we cannot have cmp_sel set. This prevents malicious truncating of the range + // checks by adding a new LT/LTE operation before all the range checks from the previous computation are complete. + rng_chk_sel * cmp_sel = 0; - // rng_chk_sel = 1 when rng_chk_remaining != 0 and rng_chk_sel = 0 when rng_chk_remaining = 0; - rng_chk_remaining * ((1 - rng_chk_sel) * (1 - op_eq_diff_inv) + op_eq_diff_inv) - rng_chk_sel = 0; + // rng_chk_sel = 1 when cmp_rng_ctr != 0 and rng_chk_sel = 0 when cmp_rng_ctr = 0; + cmp_rng_ctr * ((1 - rng_chk_sel) * (1 - op_eq_diff_inv) + op_eq_diff_inv) - rng_chk_sel = 0; // We perform a range check if we have some range checks remaining or we are performing a comparison op pol RNG_CHK_OP = (rng_chk_sel + cmp_sel); From cd194388aa80c7a0012c8bf8dde3d9fc1a9cf1df Mon Sep 17 00:00:00 2001 From: Jean M <132435771+jeanmon@users.noreply.github.com> Date: Fri, 5 Apr 2024 17:05:02 +0200 Subject: [PATCH 06/18] Modify comments in the security proofs (#5588) --- barretenberg/cpp/pil/avm/avm_alu.pil | 70 ++++++++++++++-------------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/barretenberg/cpp/pil/avm/avm_alu.pil b/barretenberg/cpp/pil/avm/avm_alu.pil index 5dc1fea0b4ca..403f40158cc9 100644 --- a/barretenberg/cpp/pil/avm/avm_alu.pil +++ b/barretenberg/cpp/pil/avm/avm_alu.pil @@ -357,62 +357,64 @@ namespace avm_alu(256); // When IS_GT = 1, we enforce the condition that a > b and thus a - b - 1 does not underflow. // When IS_GT = 0, we enforce the condition that a <= b and thus b - a does not underflow. - // ========= Analysing res_lo and res_hi scenarios for x <= y =============================== - // (1) An honest prover claims that LTE(x,y,1). Therefore ia = x, ib = y and ic = 1. + // ========= Analysing res_lo and res_hi scenarios for LTE ================================= + // (1) Assume a proof satisfies the constraints for LTE(x,y,1), i.e., x <= y + // Therefore ia = x, ib = y and ic = 1. // (a) We do not swap the operands, so a = x and b = y, // (b) IS_GT = 1 - ic = 0 // (c) res_lo = B_SUB_A_LO and res_hi = B_SUB_A_HI // (d) res_lo = y_lo - x_lo + borrow * 2**128 and res_hi = y_hi - x_hi - borrow. - // (e) the only valid input here to ensure no underflow is - // (i) x == y && borrow = 0 or, - // (ii) x < y where x_lo < y_lo && x_hi <= y_hi && borrow = 0 or - // (iii) x < y where x_lo > y_lo && x_hi < y_hi && borrow = 1 + // (e) Due to 128-bit range checks on res_lo, res_hi, y_lo, x_lo, y_hi, y_lo, we + // have the guarantee that res_lo >= 0 && res_hi >= 0. Furthermore, borrow is + // boolean and so we have two cases to consider: + // (i) borrow == 0 ==> y_lo >= x_lo && y_hi >= x_hi + // (ii) borrow == 1 ==> y_hi >= x_hi + 1 ==> y_hi > x_hi + // This concludes the proof as for both cases, we must have: y >= x // - // (2) A malicious prover claims that LTE(x,y,0), i.e. y > x. Therefore ia = x, ib = y and ic = 0. + // (2) Assume a proof satisfies the constraints for LTE(x,y,0), i.e. x > y. + Therefore ia = x, ib = y and ic = 0. // (a) We do not swap the operands, so a = x and b = y, // (b) IS_GT = 1 - ic = 1 // (c) res_lo = A_SUB_B_LO and res_hi = A_SUB_B_HI // (d) res_lo = x_lo - y_lo - 1 + borrow * 2**128 and res_hi = x_hi - y_hi - borrow. - // (e) Given that, in reality, x <= y. The following underflows happen - // (i) x == y && borrow = 0, res_lo = -1 and underflows. - // (ii) x == y && borrow = 1, res_hi = -1 and underflows. - // (iii) x < y where x_lo < y_lo && x_hi == y_hi && borrow = 0, res_lo < 0 and underflows - // (iv) x < y where x_lo < y_lo && x_hi == y_hi && borrow = 1, res_hi = -1 and underflows - // (v) x < y where x_lo < y_lo && x_hi < y_hi && borrow = 0, res_lo & res_hi < 0 both underflows - // (vi) x < y where x_lo < y_lo && x_hi < y_hi && borrow = 1, res_hi < 0 and underflows - // (vii) x < y where x_lo == y_lo && x_hi < y_hi && borrow = 0, res_lo = -1 && res_hi < 0 both underflows - // (viii) x < y where x_lo == y_lo && x_hi < y_hi && borrow = 1, res_hi < 0 and underflows - // (ix) x < y where x_lo > y_lo && x_hi < y_hi && borrow = 0, res_hi < 0 and underflows - // (x) x < y where x_lo > y_lo && x_hi < y_hi && borrow = 1, res_hi < 0 and underflows - - - // ========= Analysing res_lo and res_hi scenarios for x < y =============================== - // (1) An honest prover claims that LT(x,y,1). Therefore ia = x, ib = y and ic = 1. + // (e) Due to 128-bit range checks on res_lo, res_hi, y_lo, x_lo, y_hi, y_lo, we + // have the guarantee that res_lo >= 0 && res_hi >= 0. Furthermore, borrow is + // boolean and so we have two cases to consider: + // (i) borrow == 0 ==> x_lo > y_lo && x_hi >= y_hi + // (ii) borrow == 1 ==> x_hi > y_hi + // This concludes the proof as for both cases, we must have: x > y + // + + // ========= Analysing res_lo and res_hi scenarios for LT ================================== + // (1) Assume a proof satisfies the constraints for LT(x,y,1), i.e. x < y. + Therefore ia = x, ib = y and ic = 1. // (a) We DO swap the operands, so a = y and b = x, // (b) IS_GT = ic = 1 // (c) res_lo = A_SUB_B_LO and res_hi = A_SUB_B_HI, **remember we have swapped inputs** // (d) res_lo = y_lo - x_lo - 1 + borrow * 2**128 and res_hi = y_hi - x_hi - borrow. - // (e) the only valid input here to ensure no underflow is - // (i) x < y where x_lo < y_lo && x_hi <= y_hi && borrow = 0 or - // (ii) x < y where x_lo >= y_lo && x_hi < y_hi && borrow = 1 + // (e) Due to 128-bit range checks on res_lo, res_hi, y_lo, x_lo, y_hi, y_lo, we + // have the guarantee that res_lo >= 0 && res_hi >= 0. Furthermore, borrow is + // boolean and so we have two cases to consider: + // (i) borrow == 0 ==> y_lo > x_lo && y_hi >= x_hi + // (ii) borrow == 1 ==> y_hi > x_hi + // This concludes the proof as for both cases, we must have: x < y // - // (2) A malicious prover claims that LT(x,y,0), i.e. !(x < y) -> (x >= y). Therefore ia = x, ib = y and ic = 0. + // (2) Assume a proof satisfies the constraint for LT(x,y,0), i.e. x >= y. + Therefore ia = x, ib = y and ic = 0. // (a) We DO swap the operands, so a = y and b = x, // (b) IS_GT = ic = 0 // (c) res_lo = B_SUB_A_LO and res_hi = B_SUB_A_HI, **remember we have swapped inputs** // (d) res_lo = x_lo - y_lo + borrow * 2**128 and res_hi = x_hi - y_hi - borrow. - // (e) Given that, in reality, x < y. The following underflows happen - // (i) x < y where x_lo < y_lo && x_hi == y_hi && borrow = 0, res_lo < 0 and underflows - // (ii) x < y where x_lo < y_lo && x_hi == y_hi && borrow = 1, res_hi = -1 and underflows - // (iii) x < y where x_lo < y_lo && x_hi < y_hi && borrow = 0, res_lo && res_hi < 0 and underflows - // (iv) x < y where x_lo < y_lo && x_hi < y_hi && borrow = 1, res_hi < 0 and underflows - // (v) x < y where x_lo > y_lo && x_hi < y_hi && borrow = 0, res_hi < 0 and underflows - // (vi) x < y where x_lo > y_lo && x_hi < y_hi && borrow = 1, res_lo overflows && res_hi < 0 and underflows + // (e) Due to 128-bit range checks on res_lo, res_hi, y_lo, x_lo, y_hi, y_lo, we + // have the guarantee that res_lo >= 0 && res_hi >= 0. Furthermore, borrow is + // boolean and so we have two cases to consider: + // (i) borrow == 0 ==> x_lo >= y_lo && x_hi >= y_hi + // (ii) borrow == 1 ==> x_hi > y_hi + // This concludes the proof as for both cases, we must have: x >= y res_lo = (A_SUB_B_LO * IS_GT + B_SUB_A_LO * (1 - IS_GT)) * cmp_sel; res_hi = (A_SUB_B_HI * IS_GT + B_SUB_A_HI * (1 - IS_GT)) * cmp_sel; - // ========= RANGE OPERATIONS =============================== // TODO: 8-bit and 16-bit range checks for the respective registers have not yet been implemented. From 8f414b37faeae5cb6f2c572ee71c37f71a759e54 Mon Sep 17 00:00:00 2001 From: IlyasRidhuan Date: Fri, 5 Apr 2024 15:10:27 +0000 Subject: [PATCH 07/18] fix: more comments --- barretenberg/cpp/pil/avm/avm_alu.pil | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/barretenberg/cpp/pil/avm/avm_alu.pil b/barretenberg/cpp/pil/avm/avm_alu.pil index 403f40158cc9..75ee88322b1d 100644 --- a/barretenberg/cpp/pil/avm/avm_alu.pil +++ b/barretenberg/cpp/pil/avm/avm_alu.pil @@ -274,7 +274,7 @@ namespace avm_alu(256); cmp_sel = op_lt + op_lte; // ic is restricted to be 1 or 0 if we are performing a comparison - cmp_sel * (ic * (1 - ic)) = 0; + (cmp_sel + op_eq) * (ic * (1 - ic)) = 0; @@ -292,23 +292,21 @@ namespace avm_alu(256); // These conditions can be combined with the GT constraint, q (that x > y) as follows: // (x - y - 1) * q + (y - x) (1 - q) = result - pol commit input_ia; - pol commit input_ib; - pol commit borrow; // If LT, then swap ia and ib else keep the same - input_ia = op_lt * ib + op_lte * ia; - input_ib = op_lt * ia + op_lte * ib; + pol INPUT_IA = op_lt * ib + op_lte * ia; + pol INPUT_IB = op_lt * ia + op_lte * ib; + pol commit borrow; pol commit a_lo; pol commit a_hi; - // Check input_ia is well formed from its lo and hi limbs - input_ia = (a_lo + 2 ** 128 * a_hi) * cmp_sel; + // Check INPUT_IA is well formed from its lo and hi limbs + INPUT_IA = (a_lo + 2 ** 128 * a_hi) * cmp_sel; pol commit b_lo; pol commit b_hi; - // Check input_ib is well formed from its lo and hi limbs - input_ib = (b_lo + 2 ** 128 * b_hi) * cmp_sel; + // Check INPUT_IB is well formed from its lo and hi limbs + INPUT_IB = (b_lo + 2 ** 128 * b_hi) * cmp_sel; pol commit p_sub_a_lo; // p_lo - a_lo pol commit p_sub_a_hi; // p_hi - a_hi @@ -372,7 +370,7 @@ namespace avm_alu(256); // This concludes the proof as for both cases, we must have: y >= x // // (2) Assume a proof satisfies the constraints for LTE(x,y,0), i.e. x > y. - Therefore ia = x, ib = y and ic = 0. + // Therefore ia = x, ib = y and ic = 0. // (a) We do not swap the operands, so a = x and b = y, // (b) IS_GT = 1 - ic = 1 // (c) res_lo = A_SUB_B_LO and res_hi = A_SUB_B_HI @@ -387,7 +385,7 @@ namespace avm_alu(256); // ========= Analysing res_lo and res_hi scenarios for LT ================================== // (1) Assume a proof satisfies the constraints for LT(x,y,1), i.e. x < y. - Therefore ia = x, ib = y and ic = 1. + // Therefore ia = x, ib = y and ic = 1. // (a) We DO swap the operands, so a = y and b = x, // (b) IS_GT = ic = 1 // (c) res_lo = A_SUB_B_LO and res_hi = A_SUB_B_HI, **remember we have swapped inputs** @@ -400,7 +398,7 @@ namespace avm_alu(256); // This concludes the proof as for both cases, we must have: x < y // // (2) Assume a proof satisfies the constraint for LT(x,y,0), i.e. x >= y. - Therefore ia = x, ib = y and ic = 0. + // Therefore ia = x, ib = y and ic = 0. // (a) We DO swap the operands, so a = y and b = x, // (b) IS_GT = ic = 0 // (c) res_lo = B_SUB_A_LO and res_hi = B_SUB_A_HI, **remember we have swapped inputs** From df8bd5523cbdd0daa50967aecf6abdb348210400 Mon Sep 17 00:00:00 2001 From: IlyasRidhuan Date: Fri, 5 Apr 2024 15:17:09 +0000 Subject: [PATCH 08/18] fix: cmp_sel changes --- barretenberg/cpp/pil/avm/avm_alu.pil | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/barretenberg/cpp/pil/avm/avm_alu.pil b/barretenberg/cpp/pil/avm/avm_alu.pil index 75ee88322b1d..e12c24d9e255 100644 --- a/barretenberg/cpp/pil/avm/avm_alu.pil +++ b/barretenberg/cpp/pil/avm/avm_alu.pil @@ -18,6 +18,9 @@ namespace avm_alu(256); pol commit op_not; pol commit op_eq; pol commit alu_sel; // Predicate to activate the copy of intermediate registers to ALU table. + pol commit op_lt; + pol commit op_lte; + pol commit cmp_sel; // Predicate if LT or LTE is set // Instruction tag (1: u8, 2: u16, 3: u32, 4: u64, 5: u128, 6: field) copied from Main table pol commit in_tag; @@ -58,7 +61,9 @@ namespace avm_alu(256); pol commit cf; // Compute predicate telling whether there is a row entry in the ALU table. - alu_sel = op_add + op_sub + op_mul + op_not + op_eq; + alu_sel = op_add + op_sub + op_mul + op_not + op_eq + op_lt + op_lte; + + cmp_sel = op_lt + op_lte; // ========= Type Constraints ============================================= // TODO: Range constraints @@ -257,24 +262,15 @@ namespace avm_alu(256); // Need an additional helper that holds the inverse of the difference; pol commit op_eq_diff_inv; - // If EQ selector is set, ic needs to be boolean + // If EQ or CMP_SEL selector is set, ic needs to be boolean #[ALU_RES_IS_BOOL] - op_eq * (ic * (1 - ic)) = 0; + (cmp_sel + op_eq) * (ic * (1 - ic)) = 0; #[ALU_OP_EQ] op_eq * (DIFF * (ic * (1 - op_eq_diff_inv) + op_eq_diff_inv) - 1 + ic) = 0; // ========= LT/LTE Operation Constraints =============================== - pol commit op_lt; - pol commit op_lte; - - // Used for perm check to main, designates if a comparison operation is being used. - pol commit cmp_sel; - cmp_sel = op_lt + op_lte; - - // ic is restricted to be 1 or 0 if we are performing a comparison - (cmp_sel + op_eq) * (ic * (1 - ic)) = 0; From 9066ff0d507d3faba21fe00cc0293407f4811165 Mon Sep 17 00:00:00 2001 From: IlyasRidhuan Date: Thu, 4 Apr 2024 21:01:48 +0000 Subject: [PATCH 09/18] feat: some wip --- barretenberg/cpp/pil/avm/avm_alu.pil | 67 ++- barretenberg/cpp/pil/avm/avm_main.pil | 13 +- .../relations/generated/avm/avm_alu.hpp | 412 ++++++++++-------- .../relations/generated/avm/avm_cmp.hpp | 198 --------- .../relations/generated/avm/avm_main.hpp | 30 +- .../relations/generated/avm/declare_views.hpp | 17 +- .../relations/generated/avm/lookup_u8_0.hpp | 166 +++++++ .../relations/generated/avm/lookup_u8_1.hpp | 166 +++++++ .../relations/generated/avm/perm_main_alu.hpp | 10 +- .../generic_lookup_relation.hpp | 2 +- .../vm/avm_trace/avm_alu_trace.cpp | 253 +++++++++-- .../vm/avm_trace/avm_alu_trace.hpp | 36 +- .../vm/avm_trace/avm_deserialization.cpp | 2 + .../vm/avm_trace/avm_execution.cpp | 14 + .../barretenberg/vm/avm_trace/avm_helper.cpp | 11 + .../barretenberg/vm/avm_trace/avm_trace.cpp | 142 +++++- .../barretenberg/vm/avm_trace/avm_trace.hpp | 6 + .../vm/generated/avm_circuit_builder.hpp | 53 ++- .../barretenberg/vm/generated/avm_flavor.hpp | 266 +++++------ .../vm/generated/avm_verifier.cpp | 35 +- .../vm/tests/avm_comparison.test.cpp | 229 ++++++++++ 21 files changed, 1444 insertions(+), 684 deletions(-) delete mode 100644 barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_cmp.hpp create mode 100644 barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_0.hpp create mode 100644 barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_1.hpp create mode 100644 barretenberg/cpp/src/barretenberg/vm/tests/avm_comparison.test.cpp diff --git a/barretenberg/cpp/pil/avm/avm_alu.pil b/barretenberg/cpp/pil/avm/avm_alu.pil index e12c24d9e255..926c84f58bff 100644 --- a/barretenberg/cpp/pil/avm/avm_alu.pil +++ b/barretenberg/cpp/pil/avm/avm_alu.pil @@ -21,6 +21,7 @@ namespace avm_alu(256); pol commit op_lt; pol commit op_lte; pol commit cmp_sel; // Predicate if LT or LTE is set + pol commit rng_chk_sel; // Predicate representing a range check row. // Instruction tag (1: u8, 2: u16, 3: u32, 4: u64, 5: u128, 6: field) copied from Main table pol commit in_tag; @@ -61,8 +62,9 @@ namespace avm_alu(256); pol commit cf; // Compute predicate telling whether there is a row entry in the ALU table. + #[SELECTOR_REL] alu_sel = op_add + op_sub + op_mul + op_not + op_eq + op_lt + op_lte; - + #[SELECTOR_REL_2] cmp_sel = op_lt + op_lte; // ========= Type Constraints ============================================= @@ -134,6 +136,8 @@ namespace avm_alu(256); pol SUM_96 = SUM_64 + u16_r3 * 2**64 + u16_r4 * 2**80; pol SUM_128 = SUM_96 + u16_r5 * 2**96 + u16_r6 * 2**112; + + // ========= ADDITION/SUBTRACTION Operation Constraints =============================== // // Addition and subtraction relations are very similar and will be consolidated. @@ -270,10 +274,6 @@ namespace avm_alu(256); op_eq * (DIFF * (ic * (1 - op_eq_diff_inv) + op_eq_diff_inv) - 1 + ic) = 0; // ========= LT/LTE Operation Constraints =============================== - - - - // There are two routines that we utilise as part of this LT/LTE check // (1) Decomposition into two 128-bit limbs, lo and hi respectively and a borrow (1 or 0); // (2) 128 bit-range checks when checking an arithmetic operation has not overflowed the field. @@ -297,11 +297,13 @@ namespace avm_alu(256); pol commit a_lo; pol commit a_hi; // Check INPUT_IA is well formed from its lo and hi limbs + #[INPUT_DECOMP_1] INPUT_IA = (a_lo + 2 ** 128 * a_hi) * cmp_sel; pol commit b_lo; pol commit b_hi; // Check INPUT_IB is well formed from its lo and hi limbs + #[INPUT_DECOMP_2] INPUT_IB = (b_lo + 2 ** 128 * b_hi) * cmp_sel; pol commit p_sub_a_lo; // p_lo - a_lo @@ -316,8 +318,10 @@ namespace avm_alu(256); // This is achieved by checking a does not underflow p: (p_lo > a_lo && p_hi >= ahi) || (p_lo <= a_lo && p_hi > a_hi) // First condition is if borrow = 0, second condition is if borrow = 1 // This underflow check is done by the 128-bit check that is performed on each of these lo and hi limbs. - p_sub_a_lo = (53438638232309528389504892708671455232 - a_lo + p_a_borrow * 2 ** 128) * cmp_sel; - p_sub_a_hi = (64323764613183177041862057485226039389 - a_hi - p_a_borrow) * cmp_sel; + #[SUB_LO_1] + (p_sub_a_lo - (53438638232309528389504892708671455232 - a_lo + p_a_borrow * 2 ** 128)) * cmp_sel = 0; + #[SUB_HI_1] + (p_sub_a_hi - (64323764613183177041862057485226039389 - a_hi - p_a_borrow)) * cmp_sel = 0; pol commit p_sub_b_lo; pol commit p_sub_b_hi; @@ -327,9 +331,10 @@ namespace avm_alu(256); // Check that decomposition of b into lo and hi limbs do not overflow p. // This is achieved by checking (p_lo > b_lo && p_hi >= bhi) || (p_lo <= b_lo && p_hi > b_hi) // First condition is if borrow = 0, second condition is if borrow = 1; - p_sub_b_lo = (53438638232309528389504892708671455232 - b_lo + p_b_borrow * 2 ** 128) * cmp_sel; - p_sub_b_hi = (64323764613183177041862057485226039389 - b_hi - p_b_borrow) * cmp_sel; - + #[SUB_LO_2] + (p_sub_b_lo - (53438638232309528389504892708671455232 - b_lo + p_b_borrow * 2 ** 128)) * cmp_sel = 0; + #[SUB_HI_2] + (p_sub_b_hi - (64323764613183177041862057485226039389 - b_hi - p_b_borrow)) * cmp_sel = 0; // Calculate the combined relation: (a - b - 1) * q + (b -a ) * (1-q) // Check that (a > b) by checking (a_lo > b_lo && a_hi >= bhi) || (alo <= b_lo && a_hi > b_hi) @@ -342,8 +347,6 @@ namespace avm_alu(256); pol B_SUB_A_LO = b_lo - a_lo + borrow * 2 ** 128; pol B_SUB_A_HI = b_hi - a_hi - borrow; - pol commit res_lo; - pol commit res_hi; // If this is a LT operation, we already swapped the inputs so the result of ic is still correct // If this is a LTE operation, we invert the value of ic. @@ -406,8 +409,12 @@ namespace avm_alu(256); // (ii) borrow == 1 ==> x_hi > y_hi // This concludes the proof as for both cases, we must have: x >= y - res_lo = (A_SUB_B_LO * IS_GT + B_SUB_A_LO * (1 - IS_GT)) * cmp_sel; - res_hi = (A_SUB_B_HI * IS_GT + B_SUB_A_HI * (1 - IS_GT)) * cmp_sel; + pol commit res_lo; + pol commit res_hi; + #[RES_LO] + (res_lo - (A_SUB_B_LO * IS_GT + B_SUB_A_LO * (1 - IS_GT))) * cmp_sel = 0; + #[RES_HI] + (res_hi - (A_SUB_B_HI * IS_GT + B_SUB_A_HI * (1 - IS_GT))) * cmp_sel = 0; // ========= RANGE OPERATIONS =============================== // TODO: 8-bit and 16-bit range checks for the respective registers have not yet been implemented. @@ -417,38 +424,52 @@ namespace avm_alu(256); // TODO: combine into 1 equation, left separate for debugging // the number of range checks must decrement by 1 until it is equal to 0; + #[CMP_CTR_REL_1] (cmp_rng_ctr' - cmp_rng_ctr + 1) * cmp_rng_ctr = 0; // if this row is a comparison operation, the next range_check_remaining value is set to 4 // it is not set to 5 since we do 1 as part of the comparison. + #[CMP_CTR_REL_2] (cmp_rng_ctr' - 4) * cmp_sel = 0; - pol commit rng_chk_sel; // A boolean representing if we have range checks remaining rng_chk_sel * (1 - rng_chk_sel) = 0; // If we have remaining range checks, we cannot have cmp_sel set. This prevents malicious truncating of the range // checks by adding a new LT/LTE operation before all the range checks from the previous computation are complete. rng_chk_sel * cmp_sel = 0; // rng_chk_sel = 1 when cmp_rng_ctr != 0 and rng_chk_sel = 0 when cmp_rng_ctr = 0; + #[CTR_NON_ZERO_REL] cmp_rng_ctr * ((1 - rng_chk_sel) * (1 - op_eq_diff_inv) + op_eq_diff_inv) - rng_chk_sel = 0; // We perform a range check if we have some range checks remaining or we are performing a comparison op pol RNG_CHK_OP = (rng_chk_sel + cmp_sel); // Perform 128-bit range check on lo part + #[LOWER_CMP_RNG_CHK] a_lo = SUM_128 * (RNG_CHK_OP); + // Perform 128-bit range check on hi part + #[UPPER_CMP_RNG_CHK] a_hi = (u16_r7 + u16_r8 * 2**16 + u16_r9 * 2**32 + u16_r10 * 2**48 + u16_r11 * 2**64 + u16_r12 * 2**80 + u16_r13 * 2**96 + u16_r14 * 2**112) * (RNG_CHK_OP); // Shift all elements "across" by 2 columns - a_lo' = b_lo * rng_chk_sel'; - a_hi' = b_hi * rng_chk_sel'; - b_lo' = p_sub_a_lo * rng_chk_sel'; - b_hi' = p_sub_a_hi * rng_chk_sel'; - p_sub_a_lo' = p_sub_b_lo * rng_chk_sel'; - p_sub_a_hi' = p_sub_b_hi * rng_chk_sel'; - p_sub_b_lo' = res_lo * rng_chk_sel'; - p_sub_b_hi' = res_hi * rng_chk_sel'; + #[SHIFT_RELS] + (a_lo' - b_lo) * rng_chk_sel' = 0; + (a_hi' - b_hi) * rng_chk_sel' = 0; + #[SHIFT_RELS_1] + (b_lo' - p_sub_a_lo) * rng_chk_sel' = 0; + (b_hi' - p_sub_a_hi) * rng_chk_sel' = 0; + #[SHIFT_RELS_2] + (p_sub_a_lo' - p_sub_b_lo) * rng_chk_sel'= 0; + (p_sub_a_hi' - p_sub_b_hi) * rng_chk_sel'= 0; + #[SHIFT_RELS_3] + (p_sub_b_lo' - res_lo) * rng_chk_sel'= 0; + (p_sub_b_hi' - res_hi) * rng_chk_sel'= 0; + + // TODO: Investigate optimising these range checks. Handling non-FF elements should require less range checks. + pol commit rng_chk_lookup_selector; + #[RNG_CHK_LOOKUP_SELECTOR] + rng_chk_lookup_selector = cmp_sel + rng_chk_sel; diff --git a/barretenberg/cpp/pil/avm/avm_main.pil b/barretenberg/cpp/pil/avm/avm_main.pil index 69b75af0f05b..71930a395dbb 100644 --- a/barretenberg/cpp/pil/avm/avm_main.pil +++ b/barretenberg/cpp/pil/avm/avm_main.pil @@ -64,9 +64,6 @@ namespace avm_main(256); // Helper selector to characterize a Binary chiplet selector pol commit bin_sel; - // Helper selector to characterize a Cmp chiplet selector - pol commit cmp_sel; - // Instruction memory tags read/write (1: u8, 2: u16, 3: u32, 4: u64, 5: u128, 6: field) pol commit r_in_tag; pol commit w_in_tag; @@ -164,7 +161,7 @@ namespace avm_main(256); //====== COMPARATOR OPCODES CONSTRAINTS ===================================== // Enforce that the tag for the ouput of EQ opcode is u8 (i.e. equal to 1). #[EQ_OUTPUT_U8] - sel_op_eq * (w_in_tag - 1) = 0; + (sel_op_eq + sel_op_lte + sel_op_lt) * (w_in_tag - 1) = 0; // Relation for division over the finite field // If tag_err == 1 in a division, then ib == 0 and op_err == 1. @@ -263,7 +260,7 @@ namespace avm_main(256); // Predicate to activate the copy of intermediate registers to ALU table. If tag_err == 1, // the operation is not copied to the ALU table. // TODO: when division is moved to the alu, we will need to add the selector in the list below: - alu_sel = (sel_op_add + sel_op_sub + sel_op_mul + sel_op_not + sel_op_eq) * (1 - tag_err); + alu_sel = (sel_op_add + sel_op_sub + sel_op_mul + sel_op_not + sel_op_eq + sel_op_lt + sel_op_lte) * (1 - tag_err); #[PERM_MAIN_ALU] alu_sel {clk, ia, ib, ic, sel_op_add, sel_op_sub, @@ -313,3 +310,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}; + + #[LOOKUP_U8_0] + avm_alu.rng_chk_lookup_selector { avm_alu.u8_r0 } in sel_rng_8 { clk }; + + #[LOOKUP_U8_1] + avm_alu.rng_chk_lookup_selector { avm_alu.u8_r1 } in sel_rng_8 { clk }; 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 91ec44f46158..aabdb74b155a 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_alu.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_alu.hpp @@ -18,19 +18,19 @@ template struct Avm_aluRow { FF avm_alu_b_lo_shift{}; FF avm_alu_borrow{}; FF avm_alu_cf{}; + FF avm_alu_cmp_rng_ctr{}; + FF avm_alu_cmp_rng_ctr_shift{}; FF avm_alu_cmp_sel{}; FF avm_alu_ff_tag{}; FF avm_alu_ia{}; FF avm_alu_ib{}; FF avm_alu_ic{}; FF avm_alu_in_tag{}; - FF avm_alu_input_ia{}; - FF avm_alu_input_ib{}; - FF avm_alu_lt_sel{}; - FF avm_alu_lte_sel{}; FF avm_alu_op_add{}; FF avm_alu_op_eq{}; FF avm_alu_op_eq_diff_inv{}; + FF avm_alu_op_lt{}; + FF avm_alu_op_lte{}; FF avm_alu_op_mul{}; FF avm_alu_op_not{}; FF avm_alu_op_sub{}; @@ -46,8 +46,7 @@ template struct Avm_aluRow { FF avm_alu_p_sub_b_lo_shift{}; FF avm_alu_res_hi{}; FF avm_alu_res_lo{}; - FF avm_alu_rng_chk_remaining{}; - FF avm_alu_rng_chk_remaining_shift{}; + FF avm_alu_rng_chk_lookup_selector{}; FF avm_alu_rng_chk_sel{}; FF avm_alu_rng_chk_sel_shift{}; FF avm_alu_u128_tag{}; @@ -86,35 +85,95 @@ template struct Avm_aluRow { inline std::string get_relation_label_avm_alu(int index) { switch (index) { - case 9: - return "ALU_ADD_SUB_1"; + case 0: + return "SELECTOR_REL"; + + case 1: + return "SELECTOR_REL_2"; case 10: - return "ALU_ADD_SUB_2"; + return "ALU_ADD_SUB_1"; case 11: - return "ALU_MULTIPLICATION_FF"; + return "ALU_ADD_SUB_2"; case 12: - return "ALU_MUL_COMMON_1"; + return "ALU_MULTIPLICATION_FF"; case 13: + return "ALU_MUL_COMMON_1"; + + case 14: return "ALU_MUL_COMMON_2"; - case 16: + case 17: return "ALU_MULTIPLICATION_OUT_U128"; - case 17: + case 18: return "ALU_FF_NOT_XOR"; - case 18: + case 19: return "ALU_OP_NOT"; - case 19: + case 20: return "ALU_RES_IS_BOOL"; - case 20: + case 21: return "ALU_OP_EQ"; + + case 22: + return "INPUT_DECOMP_1"; + + case 23: + return "INPUT_DECOMP_2"; + + case 25: + return "SUB_LO_1"; + + case 26: + return "SUB_HI_1"; + + case 28: + return "SUB_LO_2"; + + case 29: + return "SUB_HI_2"; + + case 30: + return "RES_LO"; + + case 31: + return "RES_HI"; + + case 32: + return "CMP_CTR_REL_1"; + + case 33: + return "CMP_CTR_REL_2"; + + case 36: + return "CTR_NON_ZERO_REL"; + + case 37: + return "LOWER_CMP_RNG_CHK"; + + case 38: + return "UPPER_CMP_RNG_CHK"; + + case 39: + return "SHIFT_RELS"; + + case 41: + return "SHIFT_RELS_1"; + + case 43: + return "SHIFT_RELS_2"; + + case 45: + return "SHIFT_RELS_3"; + + case 47: + return "RNG_CHK_LOOKUP_SELECTOR"; } return std::to_string(index); } @@ -123,9 +182,9 @@ template class avm_aluImpl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 5, 5, 5, 6, 6, 8, 3, 4, 4, 5, 3, 3, 2, 3, 4, - 3, 3, 4, 4, 4, 3, 4, 3, 6, 5, 3, 3, 3, 3, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 5, 5, 5, 6, 6, 8, 3, 4, 4, 5, 4, 4, + 3, 4, 3, 3, 4, 3, 6, 5, 3, 3, 3, 3, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 2, }; template @@ -140,7 +199,9 @@ template class avm_aluImpl { Avm_DECLARE_VIEWS(0); auto tmp = (avm_alu_alu_sel - - ((((avm_alu_op_add + avm_alu_op_sub) + avm_alu_op_mul) + avm_alu_op_not) + avm_alu_op_eq)); + ((((((avm_alu_op_add + avm_alu_op_sub) + avm_alu_op_mul) + avm_alu_op_not) + avm_alu_op_eq) + + avm_alu_op_lt) + + avm_alu_op_lte)); tmp *= scaling_factor; std::get<0>(evals) += tmp; } @@ -148,7 +209,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(1); - auto tmp = (avm_alu_ff_tag * (-avm_alu_ff_tag + FF(1))); + auto tmp = (avm_alu_cmp_sel - (avm_alu_op_lt + avm_alu_op_lte)); tmp *= scaling_factor; std::get<1>(evals) += tmp; } @@ -156,7 +217,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(2); - auto tmp = (avm_alu_u8_tag * (-avm_alu_u8_tag + FF(1))); + auto tmp = (avm_alu_ff_tag * (-avm_alu_ff_tag + FF(1))); tmp *= scaling_factor; std::get<2>(evals) += tmp; } @@ -164,7 +225,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(3); - auto tmp = (avm_alu_u16_tag * (-avm_alu_u16_tag + FF(1))); + auto tmp = (avm_alu_u8_tag * (-avm_alu_u8_tag + FF(1))); tmp *= scaling_factor; std::get<3>(evals) += tmp; } @@ -172,7 +233,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(4); - auto tmp = (avm_alu_u32_tag * (-avm_alu_u32_tag + FF(1))); + auto tmp = (avm_alu_u16_tag * (-avm_alu_u16_tag + FF(1))); tmp *= scaling_factor; std::get<4>(evals) += tmp; } @@ -180,7 +241,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(5); - auto tmp = (avm_alu_u64_tag * (-avm_alu_u64_tag + FF(1))); + auto tmp = (avm_alu_u32_tag * (-avm_alu_u32_tag + FF(1))); tmp *= scaling_factor; std::get<5>(evals) += tmp; } @@ -188,7 +249,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(6); - auto tmp = (avm_alu_u128_tag * (-avm_alu_u128_tag + FF(1))); + auto tmp = (avm_alu_u64_tag * (-avm_alu_u64_tag + FF(1))); tmp *= scaling_factor; std::get<6>(evals) += tmp; } @@ -196,47 +257,55 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(7); + auto tmp = (avm_alu_u128_tag * (-avm_alu_u128_tag + FF(1))); + tmp *= scaling_factor; + std::get<7>(evals) += tmp; + } + // Contribution 8 + { + Avm_DECLARE_VIEWS(8); + auto tmp = (avm_alu_alu_sel * ((((((avm_alu_ff_tag + avm_alu_u8_tag) + avm_alu_u16_tag) + avm_alu_u32_tag) + avm_alu_u64_tag) + avm_alu_u128_tag) - FF(1))); tmp *= scaling_factor; - std::get<7>(evals) += tmp; + std::get<8>(evals) += tmp; } - // Contribution 8 + // Contribution 9 { - Avm_DECLARE_VIEWS(8); + 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)))); tmp *= scaling_factor; - std::get<8>(evals) += tmp; + std::get<9>(evals) += tmp; } - // Contribution 9 + // Contribution 10 { - Avm_DECLARE_VIEWS(9); + Avm_DECLARE_VIEWS(10); auto tmp = (((avm_alu_op_add + avm_alu_op_sub) * ((((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + (avm_alu_u16_r1 * FF(4294967296UL))) + (avm_alu_u16_r2 * FF(281474976710656UL))) + - (avm_alu_u16_r3 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + - (avm_alu_u16_r4 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + - (avm_alu_u16_r5 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + - (avm_alu_u16_r6 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }))) - + (avm_alu_u16_r3 * FF(uint256_t{ 0LLU, 1LLU, 0LLU, 0LLU }))) + + (avm_alu_u16_r4 * FF(uint256_t{ 0LLU, 65536LLU, 0LLU, 0LLU }))) + + (avm_alu_u16_r5 * FF(uint256_t{ 0LLU, 4294967296LLU, 0LLU, 0LLU }))) + + (avm_alu_u16_r6 * FF(uint256_t{ 0LLU, 281474976710656LLU, 0LLU, 0LLU }))) - avm_alu_ia) + (avm_alu_ff_tag * avm_alu_ic))) + ((avm_alu_op_add - avm_alu_op_sub) * - ((avm_alu_cf * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL })) - avm_alu_ib))); + ((avm_alu_cf * FF(uint256_t{ 0LLU, 0LLU, 1LLU, 0LLU })) - avm_alu_ib))); tmp *= scaling_factor; - std::get<9>(evals) += tmp; + std::get<10>(evals) += tmp; } - // Contribution 10 + // Contribution 11 { - Avm_DECLARE_VIEWS(10); + Avm_DECLARE_VIEWS(11); auto tmp = (((avm_alu_op_add + avm_alu_op_sub) * (((((((avm_alu_u8_tag * avm_alu_u8_r0) + @@ -251,43 +320,43 @@ template class avm_aluImpl { ((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + (avm_alu_u16_r1 * FF(4294967296UL))) + (avm_alu_u16_r2 * FF(281474976710656UL))) + - (avm_alu_u16_r3 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + - (avm_alu_u16_r4 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + - (avm_alu_u16_r5 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + - (avm_alu_u16_r6 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }))))) + + (avm_alu_u16_r3 * FF(uint256_t{ 0LLU, 1LLU, 0LLU, 0LLU }))) + + (avm_alu_u16_r4 * FF(uint256_t{ 0LLU, 65536LLU, 0LLU, 0LLU }))) + + (avm_alu_u16_r5 * FF(uint256_t{ 0LLU, 4294967296LLU, 0LLU, 0LLU }))) + + (avm_alu_u16_r6 * FF(uint256_t{ 0LLU, 281474976710656LLU, 0LLU, 0LLU }))))) + (avm_alu_ff_tag * avm_alu_ia)) - avm_alu_ic)) + ((avm_alu_ff_tag * (avm_alu_op_add - avm_alu_op_sub)) * avm_alu_ib)); tmp *= scaling_factor; - std::get<10>(evals) += tmp; + std::get<11>(evals) += tmp; } - // Contribution 11 + // Contribution 12 { - Avm_DECLARE_VIEWS(11); + Avm_DECLARE_VIEWS(12); auto tmp = ((avm_alu_ff_tag * avm_alu_op_mul) * ((avm_alu_ia * avm_alu_ib) - avm_alu_ic)); tmp *= scaling_factor; - std::get<11>(evals) += tmp; + std::get<12>(evals) += tmp; } - // Contribution 12 + // Contribution 13 { - Avm_DECLARE_VIEWS(12); + Avm_DECLARE_VIEWS(13); auto tmp = ((((-avm_alu_ff_tag + FF(1)) - avm_alu_u128_tag) * avm_alu_op_mul) * (((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + (avm_alu_u16_r1 * FF(4294967296UL))) + (avm_alu_u16_r2 * FF(281474976710656UL))) + - (avm_alu_u16_r3 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + - (avm_alu_u16_r4 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + - (avm_alu_u16_r5 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + - (avm_alu_u16_r6 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }))) - + (avm_alu_u16_r3 * FF(uint256_t{ 0LLU, 1LLU, 0LLU, 0LLU }))) + + (avm_alu_u16_r4 * FF(uint256_t{ 0LLU, 65536LLU, 0LLU, 0LLU }))) + + (avm_alu_u16_r5 * FF(uint256_t{ 0LLU, 4294967296LLU, 0LLU, 0LLU }))) + + (avm_alu_u16_r6 * FF(uint256_t{ 0LLU, 281474976710656LLU, 0LLU, 0LLU }))) - (avm_alu_ia * avm_alu_ib))); tmp *= scaling_factor; - std::get<12>(evals) += tmp; + std::get<13>(evals) += tmp; } - // Contribution 13 + // Contribution 14 { - Avm_DECLARE_VIEWS(13); + Avm_DECLARE_VIEWS(14); auto tmp = (avm_alu_op_mul * @@ -299,25 +368,25 @@ template class avm_aluImpl { (avm_alu_u16_r2 * FF(281474976710656UL))))) - (((-avm_alu_ff_tag + FF(1)) - avm_alu_u128_tag) * avm_alu_ic))); tmp *= scaling_factor; - std::get<13>(evals) += tmp; + std::get<14>(evals) += tmp; } - // Contribution 14 + // Contribution 15 { - Avm_DECLARE_VIEWS(14); + Avm_DECLARE_VIEWS(15); auto tmp = ((avm_alu_u128_tag * avm_alu_op_mul) * (((((avm_alu_u16_r0 + (avm_alu_u16_r1 * FF(65536))) + (avm_alu_u16_r2 * FF(4294967296UL))) + (avm_alu_u16_r3 * FF(281474976710656UL))) + ((((avm_alu_u16_r4 + (avm_alu_u16_r5 * FF(65536))) + (avm_alu_u16_r6 * FF(4294967296UL))) + (avm_alu_u16_r7 * FF(281474976710656UL))) * - FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) - + FF(uint256_t{ 0LLU, 1LLU, 0LLU, 0LLU }))) - avm_alu_ia)); tmp *= scaling_factor; - std::get<14>(evals) += tmp; + std::get<15>(evals) += tmp; } - // Contribution 15 + // Contribution 16 { - Avm_DECLARE_VIEWS(15); + Avm_DECLARE_VIEWS(16); auto tmp = ((avm_alu_u128_tag * avm_alu_op_mul) * (((((avm_alu_u16_r0_shift + (avm_alu_u16_r1_shift * FF(65536))) + @@ -326,14 +395,14 @@ template class avm_aluImpl { ((((avm_alu_u16_r4_shift + (avm_alu_u16_r5_shift * FF(65536))) + (avm_alu_u16_r6_shift * FF(4294967296UL))) + (avm_alu_u16_r7_shift * FF(281474976710656UL))) * - FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) - + FF(uint256_t{ 0LLU, 1LLU, 0LLU, 0LLU }))) - avm_alu_ib)); tmp *= scaling_factor; - std::get<15>(evals) += tmp; + std::get<16>(evals) += tmp; } - // Contribution 16 + // Contribution 17 { - Avm_DECLARE_VIEWS(16); + Avm_DECLARE_VIEWS(17); auto tmp = ((avm_alu_u128_tag * avm_alu_op_mul) * ((((avm_alu_ia * (((avm_alu_u16_r0_shift + (avm_alu_u16_r1_shift * FF(65536))) + @@ -344,31 +413,18 @@ template class avm_aluImpl { (((avm_alu_u16_r4_shift + (avm_alu_u16_r5_shift * FF(65536))) + (avm_alu_u16_r6_shift * FF(4294967296UL))) + (avm_alu_u16_r7_shift * FF(281474976710656UL)))) * - FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) - - (((avm_alu_cf * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL })) + avm_alu_u64_r0) * - FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) - + FF(uint256_t{ 0LLU, 1LLU, 0LLU, 0LLU }))) - + (((avm_alu_cf * FF(uint256_t{ 0LLU, 1LLU, 0LLU, 0LLU })) + avm_alu_u64_r0) * + FF(uint256_t{ 0LLU, 0LLU, 1LLU, 0LLU }))) - avm_alu_ic)); tmp *= scaling_factor; - std::get<16>(evals) += tmp; - } - // Contribution 17 - { - Avm_DECLARE_VIEWS(17); - - auto tmp = (avm_alu_op_not * avm_alu_ff_tag); - tmp *= scaling_factor; std::get<17>(evals) += tmp; } // Contribution 18 { 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{ 0UL, 1UL, 0UL, 0UL }))) + - (avm_alu_u128_tag * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) - - FF(1)))); + auto tmp = (avm_alu_op_not * avm_alu_ff_tag); tmp *= scaling_factor; std::get<18>(evals) += tmp; } @@ -376,7 +432,12 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(19); - auto tmp = (avm_alu_op_eq * (avm_alu_ic * (-avm_alu_ic + FF(1)))); + 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{ 0LLU, 1LLU, 0LLU, 0LLU }))) + + (avm_alu_u128_tag * FF(uint256_t{ 0LLU, 0LLU, 1LLU, 0LLU }))) - + FF(1)))); tmp *= scaling_factor; std::get<19>(evals) += tmp; } @@ -384,11 +445,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(20); - auto tmp = - (avm_alu_op_eq * ((((avm_alu_ia - avm_alu_ib) * - ((avm_alu_ic * (-avm_alu_op_eq_diff_inv + FF(1))) + avm_alu_op_eq_diff_inv)) - - FF(1)) + - avm_alu_ic)); + auto tmp = ((avm_alu_cmp_sel + avm_alu_op_eq) * (avm_alu_ic * (-avm_alu_ic + FF(1)))); tmp *= scaling_factor; std::get<20>(evals) += tmp; } @@ -396,7 +453,11 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(21); - auto tmp = (avm_alu_lt_sel * (-avm_alu_lt_sel + FF(1))); + auto tmp = + (avm_alu_op_eq * ((((avm_alu_ia - avm_alu_ib) * + ((avm_alu_ic * (-avm_alu_op_eq_diff_inv + FF(1))) + avm_alu_op_eq_diff_inv)) - + FF(1)) + + avm_alu_ic)); tmp *= scaling_factor; std::get<21>(evals) += tmp; } @@ -404,7 +465,8 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(22); - auto tmp = (avm_alu_lte_sel * (-avm_alu_lte_sel + FF(1))); + auto tmp = (((avm_alu_op_lt * avm_alu_ib) + (avm_alu_op_lte * avm_alu_ia)) - + ((avm_alu_a_lo + (avm_alu_a_hi * FF(uint256_t{ 0LLU, 0LLU, 1LLU, 0LLU }))) * avm_alu_cmp_sel)); tmp *= scaling_factor; std::get<22>(evals) += tmp; } @@ -412,7 +474,8 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(23); - auto tmp = (avm_alu_cmp_sel - (avm_alu_lt_sel + avm_alu_lte_sel)); + auto tmp = (((avm_alu_op_lt * avm_alu_ia) + (avm_alu_op_lte * avm_alu_ib)) - + ((avm_alu_b_lo + (avm_alu_b_hi * FF(uint256_t{ 0LLU, 0LLU, 1LLU, 0LLU }))) * avm_alu_cmp_sel)); tmp *= scaling_factor; std::get<23>(evals) += tmp; } @@ -420,7 +483,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(24); - auto tmp = (avm_alu_lt_sel * avm_alu_lte_sel); + auto tmp = (avm_alu_p_a_borrow * (-avm_alu_p_a_borrow + FF(1))); tmp *= scaling_factor; std::get<24>(evals) += tmp; } @@ -428,7 +491,11 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(25); - auto tmp = (avm_alu_cmp_sel * (avm_alu_ic * (-avm_alu_ic + FF(1)))); + auto tmp = + ((avm_alu_p_sub_a_lo - + ((-avm_alu_a_lo + FF(uint256_t{ 4891460686036598784LLU, 2896914383306846353LLU, 0LLU, 0LLU })) + + (avm_alu_p_a_borrow * FF(uint256_t{ 0LLU, 0LLU, 1LLU, 0LLU })))) * + avm_alu_cmp_sel); tmp *= scaling_factor; std::get<25>(evals) += tmp; } @@ -436,7 +503,11 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(26); - auto tmp = (avm_alu_input_ia - ((avm_alu_lt_sel * avm_alu_ib) + (avm_alu_lte_sel * avm_alu_ia))); + auto tmp = + ((avm_alu_p_sub_a_hi - + ((-avm_alu_a_hi + FF(uint256_t{ 13281191951274694749LLU, 3486998266802970665LLU, 0LLU, 0LLU })) - + avm_alu_p_a_borrow)) * + avm_alu_cmp_sel); tmp *= scaling_factor; std::get<26>(evals) += tmp; } @@ -444,7 +515,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(27); - auto tmp = (avm_alu_input_ib - ((avm_alu_lt_sel * avm_alu_ia) + (avm_alu_lte_sel * avm_alu_ib))); + auto tmp = (avm_alu_p_b_borrow * (-avm_alu_p_b_borrow + FF(1))); tmp *= scaling_factor; std::get<27>(evals) += tmp; } @@ -452,8 +523,11 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(28); - auto tmp = (avm_alu_input_ia - - ((avm_alu_a_lo + (avm_alu_a_hi * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) * avm_alu_cmp_sel)); + auto tmp = + ((avm_alu_p_sub_b_lo - + ((-avm_alu_b_lo + FF(uint256_t{ 4891460686036598784LLU, 2896914383306846353LLU, 0LLU, 0LLU })) + + (avm_alu_p_b_borrow * FF(uint256_t{ 0LLU, 0LLU, 1LLU, 0LLU })))) * + avm_alu_cmp_sel); tmp *= scaling_factor; std::get<28>(evals) += tmp; } @@ -461,8 +535,11 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(29); - auto tmp = (avm_alu_input_ib - - ((avm_alu_b_lo + (avm_alu_b_hi * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) * avm_alu_cmp_sel)); + auto tmp = + ((avm_alu_p_sub_b_hi - + ((-avm_alu_b_hi + FF(uint256_t{ 13281191951274694749LLU, 3486998266802970665LLU, 0LLU, 0LLU })) - + avm_alu_p_b_borrow)) * + avm_alu_cmp_sel); tmp *= scaling_factor; std::get<29>(evals) += tmp; } @@ -470,10 +547,14 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(30); - auto tmp = (avm_alu_p_sub_a_lo - - (((-avm_alu_a_lo + FF(uint256_t{ 4891460686036598784UL, 2896914383306846353UL, 0UL, 0UL })) + - (avm_alu_p_a_borrow * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) * - avm_alu_cmp_sel)); + auto tmp = + ((avm_alu_res_lo - + (((((avm_alu_a_lo - avm_alu_b_lo) - FF(1)) + + (avm_alu_borrow * FF(uint256_t{ 0LLU, 0LLU, 1LLU, 0LLU }))) * + ((avm_alu_op_lt * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_op_lte))) + + (((avm_alu_b_lo - avm_alu_a_lo) + (avm_alu_borrow * FF(uint256_t{ 0LLU, 0LLU, 1LLU, 0LLU }))) * + (-((avm_alu_op_lt * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_op_lte)) + FF(1))))) * + avm_alu_cmp_sel); tmp *= scaling_factor; std::get<30>(evals) += tmp; } @@ -481,10 +562,12 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(31); - auto tmp = (avm_alu_p_sub_a_hi - - (((-avm_alu_a_hi + FF(uint256_t{ 13281191951274694749UL, 3486998266802970665UL, 0UL, 0UL })) - - avm_alu_p_a_borrow) * - avm_alu_cmp_sel)); + auto tmp = ((avm_alu_res_hi - + ((((avm_alu_a_hi - avm_alu_b_hi) - avm_alu_borrow) * + ((avm_alu_op_lt * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_op_lte))) + + (((avm_alu_b_hi - avm_alu_a_hi) - avm_alu_borrow) * + (-((avm_alu_op_lt * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_op_lte)) + FF(1))))) * + avm_alu_cmp_sel); tmp *= scaling_factor; std::get<31>(evals) += tmp; } @@ -492,10 +575,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(32); - auto tmp = (avm_alu_p_sub_b_lo - - (((-avm_alu_b_lo + FF(uint256_t{ 4891460686036598784UL, 2896914383306846353UL, 0UL, 0UL })) + - (avm_alu_p_b_borrow * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) * - avm_alu_cmp_sel)); + auto tmp = (((avm_alu_cmp_rng_ctr_shift - avm_alu_cmp_rng_ctr) + FF(1)) * avm_alu_cmp_rng_ctr); tmp *= scaling_factor; std::get<32>(evals) += tmp; } @@ -503,10 +583,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(33); - auto tmp = (avm_alu_p_sub_b_hi - - (((-avm_alu_b_hi + FF(uint256_t{ 13281191951274694749UL, 3486998266802970665UL, 0UL, 0UL })) - - avm_alu_p_b_borrow) * - avm_alu_cmp_sel)); + auto tmp = ((avm_alu_cmp_rng_ctr_shift - FF(4)) * avm_alu_cmp_sel); tmp *= scaling_factor; std::get<33>(evals) += tmp; } @@ -514,13 +591,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(34); - auto tmp = - (avm_alu_res_lo - - ((((((avm_alu_a_lo - avm_alu_b_lo) - FF(1)) + (avm_alu_borrow * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) * - ((avm_alu_lt_sel * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_lte_sel))) + - (((avm_alu_b_lo - avm_alu_a_lo) + (avm_alu_borrow * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) * - (-((avm_alu_lt_sel * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_lte_sel)) + FF(1)))) * - avm_alu_cmp_sel)); + auto tmp = (avm_alu_rng_chk_sel * (-avm_alu_rng_chk_sel + FF(1))); tmp *= scaling_factor; std::get<34>(evals) += tmp; } @@ -528,12 +599,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(35); - auto tmp = (avm_alu_res_hi - - (((((avm_alu_a_hi - avm_alu_b_hi) - avm_alu_borrow) * - ((avm_alu_lt_sel * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_lte_sel))) + - (((avm_alu_b_hi - avm_alu_a_hi) - avm_alu_borrow) * - (-((avm_alu_lt_sel * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_lte_sel)) + FF(1)))) * - avm_alu_cmp_sel)); + auto tmp = (avm_alu_rng_chk_sel * avm_alu_cmp_sel); tmp *= scaling_factor; std::get<35>(evals) += tmp; } @@ -541,8 +607,9 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(36); - auto tmp = - (((avm_alu_rng_chk_remaining_shift - avm_alu_rng_chk_remaining) + FF(1)) * avm_alu_rng_chk_remaining); + auto tmp = ((avm_alu_cmp_rng_ctr * (((-avm_alu_rng_chk_sel + FF(1)) * (-avm_alu_op_eq_diff_inv + FF(1))) + + avm_alu_op_eq_diff_inv)) - + avm_alu_rng_chk_sel); tmp *= scaling_factor; std::get<36>(evals) += tmp; } @@ -550,7 +617,15 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(37); - auto tmp = ((avm_alu_rng_chk_remaining_shift - FF(4)) * avm_alu_cmp_sel); + auto tmp = + (avm_alu_a_lo - (((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + + (avm_alu_u16_r1 * FF(4294967296UL))) + + (avm_alu_u16_r2 * FF(281474976710656UL))) + + (avm_alu_u16_r3 * FF(uint256_t{ 0LLU, 1LLU, 0LLU, 0LLU }))) + + (avm_alu_u16_r4 * FF(uint256_t{ 0LLU, 65536LLU, 0LLU, 0LLU }))) + + (avm_alu_u16_r5 * FF(uint256_t{ 0LLU, 4294967296LLU, 0LLU, 0LLU }))) + + (avm_alu_u16_r6 * FF(uint256_t{ 0LLU, 281474976710656LLU, 0LLU, 0LLU }))) * + (avm_alu_rng_chk_sel + avm_alu_cmp_sel))); tmp *= scaling_factor; std::get<37>(evals) += tmp; } @@ -558,7 +633,14 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(38); - auto tmp = (avm_alu_rng_chk_sel * (-avm_alu_rng_chk_sel + FF(1))); + auto tmp = (avm_alu_a_hi - + ((((((((avm_alu_u16_r7 + (avm_alu_u16_r8 * FF(65536))) + (avm_alu_u16_r9 * FF(4294967296UL))) + + (avm_alu_u16_r10 * FF(281474976710656UL))) + + (avm_alu_u16_r11 * FF(uint256_t{ 0LLU, 1LLU, 0LLU, 0LLU }))) + + (avm_alu_u16_r12 * FF(uint256_t{ 0LLU, 65536LLU, 0LLU, 0LLU }))) + + (avm_alu_u16_r13 * FF(uint256_t{ 0LLU, 4294967296LLU, 0LLU, 0LLU }))) + + (avm_alu_u16_r14 * FF(uint256_t{ 0LLU, 281474976710656LLU, 0LLU, 0LLU }))) * + (avm_alu_rng_chk_sel + avm_alu_cmp_sel))); tmp *= scaling_factor; std::get<38>(evals) += tmp; } @@ -566,7 +648,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(39); - auto tmp = (avm_alu_rng_chk_sel * avm_alu_cmp_sel); + auto tmp = ((avm_alu_a_lo_shift - avm_alu_b_lo) * avm_alu_rng_chk_sel_shift); tmp *= scaling_factor; std::get<39>(evals) += tmp; } @@ -574,10 +656,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(40); - auto tmp = - ((avm_alu_rng_chk_remaining * - (((-avm_alu_rng_chk_sel + FF(1)) * (-avm_alu_op_eq_diff_inv + FF(1))) + avm_alu_op_eq_diff_inv)) - - avm_alu_rng_chk_sel); + auto tmp = ((avm_alu_a_hi_shift - avm_alu_b_hi) * avm_alu_rng_chk_sel_shift); tmp *= scaling_factor; std::get<40>(evals) += tmp; } @@ -585,15 +664,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(41); - auto tmp = - (avm_alu_a_lo - (((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + - (avm_alu_u16_r1 * FF(4294967296UL))) + - (avm_alu_u16_r2 * FF(281474976710656UL))) + - (avm_alu_u16_r3 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + - (avm_alu_u16_r4 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + - (avm_alu_u16_r5 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + - (avm_alu_u16_r6 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }))) * - (avm_alu_rng_chk_sel + avm_alu_cmp_sel))); + auto tmp = ((avm_alu_b_lo_shift - avm_alu_p_sub_a_lo) * avm_alu_rng_chk_sel_shift); tmp *= scaling_factor; std::get<41>(evals) += tmp; } @@ -601,14 +672,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(42); - auto tmp = (avm_alu_a_hi - - ((((((((avm_alu_u16_r7 + (avm_alu_u16_r8 * FF(65536))) + (avm_alu_u16_r9 * FF(4294967296UL))) + - (avm_alu_u16_r10 * FF(281474976710656UL))) + - (avm_alu_u16_r11 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + - (avm_alu_u16_r12 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + - (avm_alu_u16_r13 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + - (avm_alu_u16_r14 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }))) * - (avm_alu_rng_chk_sel + avm_alu_cmp_sel))); + auto tmp = ((avm_alu_b_hi_shift - avm_alu_p_sub_a_hi) * avm_alu_rng_chk_sel_shift); tmp *= scaling_factor; std::get<42>(evals) += tmp; } @@ -616,7 +680,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(43); - auto tmp = (avm_alu_a_lo_shift - (avm_alu_b_lo * avm_alu_rng_chk_sel_shift)); + auto tmp = ((avm_alu_p_sub_a_lo_shift - avm_alu_p_sub_b_lo) * avm_alu_rng_chk_sel_shift); tmp *= scaling_factor; std::get<43>(evals) += tmp; } @@ -624,7 +688,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(44); - auto tmp = (avm_alu_a_hi_shift - (avm_alu_b_hi * avm_alu_rng_chk_sel_shift)); + auto tmp = ((avm_alu_p_sub_a_hi_shift - avm_alu_p_sub_b_hi) * avm_alu_rng_chk_sel_shift); tmp *= scaling_factor; std::get<44>(evals) += tmp; } @@ -632,7 +696,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(45); - auto tmp = (avm_alu_b_lo_shift - (avm_alu_p_sub_a_lo * avm_alu_rng_chk_sel_shift)); + auto tmp = ((avm_alu_p_sub_b_lo_shift - avm_alu_res_lo) * avm_alu_rng_chk_sel_shift); tmp *= scaling_factor; std::get<45>(evals) += tmp; } @@ -640,7 +704,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(46); - auto tmp = (avm_alu_b_hi_shift - (avm_alu_p_sub_a_hi * avm_alu_rng_chk_sel_shift)); + auto tmp = ((avm_alu_p_sub_b_hi_shift - avm_alu_res_hi) * avm_alu_rng_chk_sel_shift); tmp *= scaling_factor; std::get<46>(evals) += tmp; } @@ -648,34 +712,10 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(47); - auto tmp = (avm_alu_p_sub_a_lo_shift - (avm_alu_p_sub_b_lo * avm_alu_rng_chk_sel_shift)); + auto tmp = (avm_alu_rng_chk_lookup_selector - (avm_alu_cmp_sel + avm_alu_rng_chk_sel)); tmp *= scaling_factor; std::get<47>(evals) += tmp; } - // Contribution 48 - { - Avm_DECLARE_VIEWS(48); - - auto tmp = (avm_alu_p_sub_a_hi_shift - (avm_alu_p_sub_b_hi * avm_alu_rng_chk_sel_shift)); - tmp *= scaling_factor; - std::get<48>(evals) += tmp; - } - // Contribution 49 - { - Avm_DECLARE_VIEWS(49); - - auto tmp = (avm_alu_p_sub_b_lo_shift - (avm_alu_res_lo * avm_alu_rng_chk_sel_shift)); - tmp *= scaling_factor; - std::get<49>(evals) += tmp; - } - // Contribution 50 - { - Avm_DECLARE_VIEWS(50); - - auto tmp = (avm_alu_p_sub_b_hi_shift - (avm_alu_res_hi * avm_alu_rng_chk_sel_shift)); - tmp *= scaling_factor; - std::get<50>(evals) += tmp; - } } }; diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_cmp.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_cmp.hpp deleted file mode 100644 index 122d8df3abd9..000000000000 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_cmp.hpp +++ /dev/null @@ -1,198 +0,0 @@ - -#pragma once -#include "../../relation_parameters.hpp" -#include "../../relation_types.hpp" -#include "./declare_views.hpp" - -namespace bb::Avm_vm { - -template struct Avm_cmpRow { - FF avm_cmp_a_hi{}; - FF avm_cmp_a_lo{}; - FF avm_cmp_b_hi{}; - FF avm_cmp_b_lo{}; - FF avm_cmp_borrow{}; - FF avm_cmp_cmp_sel{}; - FF avm_cmp_ia{}; - FF avm_cmp_ib{}; - FF avm_cmp_ic{}; - FF avm_cmp_input_ia{}; - FF avm_cmp_input_ib{}; - FF avm_cmp_lt_query{}; - FF avm_cmp_lt_sel{}; - FF avm_cmp_lte_sel{}; - FF avm_cmp_p_a_borrow{}; - FF avm_cmp_p_b_borrow{}; - FF avm_cmp_p_hi{}; - FF avm_cmp_p_lo{}; - FF avm_cmp_p_sub_a_hi{}; - FF avm_cmp_p_sub_a_lo{}; - FF avm_cmp_p_sub_b_hi{}; - FF avm_cmp_p_sub_b_lo{}; - FF avm_cmp_res_hi{}; - FF avm_cmp_res_lo{}; -}; - -inline std::string get_relation_label_avm_cmp(int index) -{ - switch (index) {} - return std::to_string(index); -} - -template class avm_cmpImpl { - public: - using FF = FF_; - - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 2, 3, 4, 3, - }; - - template - void static accumulate(ContainerOverSubrelations& evals, - const AllEntities& new_term, - [[maybe_unused]] const RelationParameters&, - [[maybe_unused]] const FF& scaling_factor) - { - - // Contribution 0 - { - Avm_DECLARE_VIEWS(0); - - auto tmp = (avm_cmp_ic * (-avm_cmp_ic + FF(1))); - tmp *= scaling_factor; - std::get<0>(evals) += tmp; - } - // Contribution 1 - { - Avm_DECLARE_VIEWS(1); - - auto tmp = (avm_cmp_cmp_sel - (avm_cmp_lt_sel + avm_cmp_lte_sel)); - tmp *= scaling_factor; - std::get<1>(evals) += tmp; - } - // Contribution 2 - { - Avm_DECLARE_VIEWS(2); - - auto tmp = (avm_cmp_lt_sel * (-avm_cmp_lt_sel + FF(1))); - tmp *= scaling_factor; - std::get<2>(evals) += tmp; - } - // Contribution 3 - { - Avm_DECLARE_VIEWS(3); - - auto tmp = (avm_cmp_lte_sel * (-avm_cmp_lte_sel + FF(1))); - tmp *= scaling_factor; - std::get<3>(evals) += tmp; - } - // Contribution 4 - { - Avm_DECLARE_VIEWS(4); - - auto tmp = (avm_cmp_lt_sel * avm_cmp_lte_sel); - tmp *= scaling_factor; - std::get<4>(evals) += tmp; - } - // Contribution 5 - { - Avm_DECLARE_VIEWS(5); - - auto tmp = (avm_cmp_input_ia - ((avm_cmp_lt_sel * avm_cmp_ib) + (avm_cmp_lte_sel * avm_cmp_ia))); - tmp *= scaling_factor; - std::get<5>(evals) += tmp; - } - // Contribution 6 - { - Avm_DECLARE_VIEWS(6); - - auto tmp = (avm_cmp_input_ib - ((avm_cmp_lt_sel * avm_cmp_ia) + (avm_cmp_lte_sel * avm_cmp_ib))); - tmp *= scaling_factor; - std::get<6>(evals) += tmp; - } - // Contribution 7 - { - Avm_DECLARE_VIEWS(7); - - auto tmp = (avm_cmp_input_ia - (avm_cmp_a_lo + (avm_cmp_a_hi * FF(uint256_t{ 0, 0, 1, 0 })))); - tmp *= scaling_factor; - std::get<7>(evals) += tmp; - } - // Contribution 8 - { - Avm_DECLARE_VIEWS(8); - - auto tmp = (avm_cmp_input_ib - (avm_cmp_b_lo + (avm_cmp_b_hi * FF(uint256_t{ 0, 0, 1, 0 })))); - tmp *= scaling_factor; - std::get<8>(evals) += tmp; - } - // Contribution 9 - { - Avm_DECLARE_VIEWS(9); - - auto tmp = (avm_cmp_p_sub_a_lo - - ((avm_cmp_p_lo - avm_cmp_a_lo) + (avm_cmp_p_a_borrow * FF(uint256_t{ 0, 0, 1, 0 })))); - tmp *= scaling_factor; - std::get<9>(evals) += tmp; - } - // Contribution 10 - { - Avm_DECLARE_VIEWS(10); - - auto tmp = (avm_cmp_p_sub_a_hi - ((avm_cmp_p_hi - avm_cmp_a_hi) - avm_cmp_p_a_borrow)); - tmp *= scaling_factor; - std::get<10>(evals) += tmp; - } - // Contribution 11 - { - Avm_DECLARE_VIEWS(11); - - auto tmp = (avm_cmp_p_sub_b_lo - - ((avm_cmp_p_lo - avm_cmp_b_lo) + (avm_cmp_p_b_borrow * FF(uint256_t{ 0, 0, 1, 0 })))); - tmp *= scaling_factor; - std::get<11>(evals) += tmp; - } - // Contribution 12 - { - Avm_DECLARE_VIEWS(12); - - auto tmp = (avm_cmp_p_sub_b_hi - ((avm_cmp_p_hi - avm_cmp_b_hi) - avm_cmp_p_b_borrow)); - tmp *= scaling_factor; - std::get<12>(evals) += tmp; - } - // Contribution 13 - { - Avm_DECLARE_VIEWS(13); - - auto tmp = (avm_cmp_lt_query - ((avm_cmp_lt_sel * avm_cmp_ic) + ((-avm_cmp_ic + FF(1)) * avm_cmp_lte_sel))); - tmp *= scaling_factor; - std::get<13>(evals) += tmp; - } - // Contribution 14 - { - Avm_DECLARE_VIEWS(14); - - auto tmp = (avm_cmp_res_lo - - (((((avm_cmp_a_lo - avm_cmp_b_lo) - FF(1)) + (avm_cmp_borrow * FF(uint256_t{ 0, 0, 1, 0 }))) * - avm_cmp_lt_query) + - (((avm_cmp_b_lo - avm_cmp_a_lo) + (avm_cmp_borrow * FF(uint256_t{ 0, 0, 1, 0 }))) * - (-avm_cmp_lt_query + FF(1))))); - tmp *= scaling_factor; - std::get<14>(evals) += tmp; - } - // Contribution 15 - { - Avm_DECLARE_VIEWS(15); - - auto tmp = - (avm_cmp_res_hi - ((((avm_cmp_a_hi - avm_cmp_b_hi) - avm_cmp_borrow) * avm_cmp_lt_query) + - (((avm_cmp_b_hi - avm_cmp_a_hi) - avm_cmp_borrow) * (-avm_cmp_lt_query + FF(1))))); - tmp *= scaling_factor; - std::get<15>(evals) += tmp; - } - } -}; - -template using avm_cmp = Relation>; - -} // namespace bb::Avm_vm \ 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 f264c265b6bf..e6fecbb3c1f4 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_main.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_main.hpp @@ -10,7 +10,6 @@ template struct Avm_mainRow { FF avm_main_alu_sel{}; FF avm_main_bin_op_id{}; FF avm_main_bin_sel{}; - FF avm_main_cmp_sel{}; FF avm_main_first{}; FF avm_main_ia{}; FF avm_main_ib{}; @@ -94,9 +93,6 @@ inline std::string get_relation_label_avm_main(int index) case 50: return "BIN_SEL_2"; - - case 51: - return "CMP_SEL"; } return std::to_string(index); } @@ -105,9 +101,9 @@ template class avm_mainImpl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 5, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 3, 3, 3, 3, 2, 2, + 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, }; template @@ -337,7 +333,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(27); - auto tmp = (avm_main_sel_op_eq * (avm_main_w_in_tag - 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<27>(evals) += tmp; } @@ -519,10 +516,13 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(48); - 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_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<48>(evals) += tmp; } @@ -542,14 +542,6 @@ template class avm_mainImpl { tmp *= scaling_factor; std::get<50>(evals) += tmp; } - // Contribution 51 - { - Avm_DECLARE_VIEWS(51); - - auto tmp = (avm_main_cmp_sel - (avm_main_sel_op_lt + avm_main_sel_op_lte)); - tmp *= scaling_factor; - std::get<51>(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 19157aa8ff48..ed16f7a8f00d 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/declare_views.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/declare_views.hpp @@ -12,20 +12,19 @@ [[maybe_unused]] auto avm_alu_borrow = View(new_term.avm_alu_borrow); \ [[maybe_unused]] auto avm_alu_cf = View(new_term.avm_alu_cf); \ [[maybe_unused]] auto avm_alu_clk = View(new_term.avm_alu_clk); \ + [[maybe_unused]] auto avm_alu_cmp_rng_ctr = View(new_term.avm_alu_cmp_rng_ctr); \ [[maybe_unused]] auto avm_alu_cmp_sel = View(new_term.avm_alu_cmp_sel); \ [[maybe_unused]] auto avm_alu_ff_tag = View(new_term.avm_alu_ff_tag); \ [[maybe_unused]] auto avm_alu_ia = View(new_term.avm_alu_ia); \ [[maybe_unused]] auto avm_alu_ib = View(new_term.avm_alu_ib); \ [[maybe_unused]] auto avm_alu_ic = View(new_term.avm_alu_ic); \ [[maybe_unused]] auto avm_alu_in_tag = View(new_term.avm_alu_in_tag); \ - [[maybe_unused]] auto avm_alu_input_ia = View(new_term.avm_alu_input_ia); \ - [[maybe_unused]] auto avm_alu_input_ib = View(new_term.avm_alu_input_ib); \ - [[maybe_unused]] auto avm_alu_lt_sel = View(new_term.avm_alu_lt_sel); \ - [[maybe_unused]] auto avm_alu_lte_sel = View(new_term.avm_alu_lte_sel); \ [[maybe_unused]] auto avm_alu_op_add = View(new_term.avm_alu_op_add); \ [[maybe_unused]] auto avm_alu_op_div = View(new_term.avm_alu_op_div); \ [[maybe_unused]] auto avm_alu_op_eq = View(new_term.avm_alu_op_eq); \ [[maybe_unused]] auto avm_alu_op_eq_diff_inv = View(new_term.avm_alu_op_eq_diff_inv); \ + [[maybe_unused]] auto avm_alu_op_lt = View(new_term.avm_alu_op_lt); \ + [[maybe_unused]] auto avm_alu_op_lte = View(new_term.avm_alu_op_lte); \ [[maybe_unused]] auto avm_alu_op_mul = View(new_term.avm_alu_op_mul); \ [[maybe_unused]] auto avm_alu_op_not = View(new_term.avm_alu_op_not); \ [[maybe_unused]] auto avm_alu_op_sub = View(new_term.avm_alu_op_sub); \ @@ -37,7 +36,7 @@ [[maybe_unused]] auto avm_alu_p_sub_b_lo = View(new_term.avm_alu_p_sub_b_lo); \ [[maybe_unused]] auto avm_alu_res_hi = View(new_term.avm_alu_res_hi); \ [[maybe_unused]] auto avm_alu_res_lo = View(new_term.avm_alu_res_lo); \ - [[maybe_unused]] auto avm_alu_rng_chk_remaining = View(new_term.avm_alu_rng_chk_remaining); \ + [[maybe_unused]] auto avm_alu_rng_chk_lookup_selector = View(new_term.avm_alu_rng_chk_lookup_selector); \ [[maybe_unused]] auto avm_alu_rng_chk_sel = View(new_term.avm_alu_rng_chk_sel); \ [[maybe_unused]] auto avm_alu_u128_tag = View(new_term.avm_alu_u128_tag); \ [[maybe_unused]] auto avm_alu_u16_r0 = View(new_term.avm_alu_u16_r0); \ @@ -85,7 +84,6 @@ [[maybe_unused]] auto avm_main_alu_sel = View(new_term.avm_main_alu_sel); \ [[maybe_unused]] auto avm_main_bin_op_id = View(new_term.avm_main_bin_op_id); \ [[maybe_unused]] auto avm_main_bin_sel = View(new_term.avm_main_bin_sel); \ - [[maybe_unused]] auto avm_main_cmp_sel = View(new_term.avm_main_cmp_sel); \ [[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); \ @@ -151,7 +149,6 @@ [[maybe_unused]] auto avm_mem_w_in_tag = View(new_term.avm_mem_w_in_tag); \ [[maybe_unused]] auto perm_main_alu = View(new_term.perm_main_alu); \ [[maybe_unused]] auto perm_main_bin = View(new_term.perm_main_bin); \ - [[maybe_unused]] auto perm_main_cmp = View(new_term.perm_main_cmp); \ [[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); \ @@ -162,19 +159,23 @@ [[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); \ [[maybe_unused]] auto incl_mem_tag_err = View(new_term.incl_mem_tag_err); \ + [[maybe_unused]] auto lookup_u8_0 = View(new_term.lookup_u8_0); \ + [[maybe_unused]] auto lookup_u8_1 = View(new_term.lookup_u8_1); \ [[maybe_unused]] auto lookup_byte_lengths_counts = View(new_term.lookup_byte_lengths_counts); \ [[maybe_unused]] auto lookup_byte_operations_counts = View(new_term.lookup_byte_operations_counts); \ [[maybe_unused]] auto incl_main_tag_err_counts = View(new_term.incl_main_tag_err_counts); \ [[maybe_unused]] auto incl_mem_tag_err_counts = View(new_term.incl_mem_tag_err_counts); \ + [[maybe_unused]] auto lookup_u8_0_counts = View(new_term.lookup_u8_0_counts); \ + [[maybe_unused]] auto lookup_u8_1_counts = View(new_term.lookup_u8_1_counts); \ [[maybe_unused]] auto avm_alu_a_hi_shift = View(new_term.avm_alu_a_hi_shift); \ [[maybe_unused]] auto avm_alu_a_lo_shift = View(new_term.avm_alu_a_lo_shift); \ [[maybe_unused]] auto avm_alu_b_hi_shift = View(new_term.avm_alu_b_hi_shift); \ [[maybe_unused]] auto avm_alu_b_lo_shift = View(new_term.avm_alu_b_lo_shift); \ + [[maybe_unused]] auto avm_alu_cmp_rng_ctr_shift = View(new_term.avm_alu_cmp_rng_ctr_shift); \ [[maybe_unused]] auto avm_alu_p_sub_a_hi_shift = View(new_term.avm_alu_p_sub_a_hi_shift); \ [[maybe_unused]] auto avm_alu_p_sub_a_lo_shift = View(new_term.avm_alu_p_sub_a_lo_shift); \ [[maybe_unused]] auto avm_alu_p_sub_b_hi_shift = View(new_term.avm_alu_p_sub_b_hi_shift); \ [[maybe_unused]] auto avm_alu_p_sub_b_lo_shift = View(new_term.avm_alu_p_sub_b_lo_shift); \ - [[maybe_unused]] auto avm_alu_rng_chk_remaining_shift = View(new_term.avm_alu_rng_chk_remaining_shift); \ [[maybe_unused]] auto avm_alu_rng_chk_sel_shift = View(new_term.avm_alu_rng_chk_sel_shift); \ [[maybe_unused]] auto avm_alu_u16_r0_shift = View(new_term.avm_alu_u16_r0_shift); \ [[maybe_unused]] auto avm_alu_u16_r1_shift = View(new_term.avm_alu_u16_r1_shift); \ diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_0.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_0.hpp new file mode 100644 index 000000000000..c903cd97ff80 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_0.hpp @@ -0,0 +1,166 @@ + + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u8_0_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_8 == 1); + } + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); + const auto is_table_entry = View(in.avm_main_sel_rng_8); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u8_0, + in.lookup_u8_0_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_8, + in.avm_alu_u8_r0, + in.avm_main_clk); + } + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u8_0, + in.lookup_u8_0_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_8, + in.avm_alu_u8_r0, + in.avm_main_clk); + } +}; + +template using lookup_u8_0_relation = GenericLookupRelation; +template using lookup_u8_0 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_1.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_1.hpp new file mode 100644 index 000000000000..525424166fa8 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_1.hpp @@ -0,0 +1,166 @@ + + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u8_1_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_8 == 1); + } + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); + const auto is_table_entry = View(in.avm_main_sel_rng_8); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u8_1, + in.lookup_u8_1_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_8, + in.avm_alu_u8_r1, + in.avm_main_clk); + } + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u8_1, + in.lookup_u8_1_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_8, + in.avm_alu_u8_r1, + in.avm_main_clk); + } +}; + +template using lookup_u8_1_relation = GenericLookupRelation; +template using lookup_u8_1 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_alu.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_alu.hpp index 8019768c54c5..0a45bb920d5d 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_alu.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/perm_main_alu.hpp @@ -12,7 +12,7 @@ namespace bb { class perm_main_alu_permutation_settings { public: // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 10; + constexpr static size_t COLUMNS_PER_SET = 12; /** * @brief If this method returns true on a row of values, then the inverse polynomial at this index. Otherwise the @@ -59,6 +59,8 @@ class perm_main_alu_permutation_settings { in.avm_main_sel_op_mul, in.avm_main_sel_op_eq, in.avm_main_sel_op_not, + in.avm_main_sel_op_lt, + in.avm_main_sel_op_lte, in.avm_main_r_in_tag, in.avm_alu_clk, in.avm_alu_ia, @@ -69,6 +71,8 @@ class perm_main_alu_permutation_settings { in.avm_alu_op_mul, in.avm_alu_op_eq, in.avm_alu_op_not, + in.avm_alu_op_lt, + in.avm_alu_op_lte, in.avm_alu_in_tag); } @@ -105,6 +109,8 @@ class perm_main_alu_permutation_settings { in.avm_main_sel_op_mul, in.avm_main_sel_op_eq, in.avm_main_sel_op_not, + in.avm_main_sel_op_lt, + in.avm_main_sel_op_lte, in.avm_main_r_in_tag, in.avm_alu_clk, in.avm_alu_ia, @@ -115,6 +121,8 @@ class perm_main_alu_permutation_settings { in.avm_alu_op_mul, in.avm_alu_op_eq, in.avm_alu_op_not, + in.avm_alu_op_lt, + in.avm_alu_op_lte, in.avm_alu_in_tag); } }; diff --git a/barretenberg/cpp/src/barretenberg/relations/generic_lookup/generic_lookup_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/generic_lookup/generic_lookup_relation.hpp index 18b9c872101c..2f388d0ddbde 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generic_lookup/generic_lookup_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generic_lookup/generic_lookup_relation.hpp @@ -478,4 +478,4 @@ using GenericLookupRelation = Relation>; template using GenericLookup = GenericLookupRelationImpl; -} // namespace bb \ No newline at end of file +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.cpp index 6552edca0ef4..2cf5c96e01e4 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.cpp @@ -1,5 +1,12 @@ #include "avm_alu_trace.hpp" +#include "barretenberg/common/serialize.hpp" +#include "barretenberg/numeric/uint128/uint128.hpp" +#include "barretenberg/numeric/uint256/uint256.hpp" +#include "barretenberg/relations/generated/avm/avm_alu.hpp" +#include #include +#include +#include namespace bb::avm_trace { @@ -433,38 +440,226 @@ FF AvmAluTraceBuilder::op_eq(FF const& a, FF const& b, AvmMemoryTag in_tag, uint } /** - * @brief Build Alu trace and return a boolean based on equality of operands of type defined by in_tag. + * @brief This is a helper function that decomposes the input into the various registers of the ALU. + * This additionally increments the counts for the corresponding range lookups entries. + * @return A triplet of + */ +template +std::tuple> AvmAluTraceBuilder::to_alu_slice_registers(T a) +{ + auto alu_u8_r0 = static_cast(a); + a >>= 8; + auto alu_u8_r1 = static_cast(a); + a >>= 8; + std::vector alu_u16_reg{}; + for (size_t i = 0; i < 15; i++) { + auto alu_u16 = static_cast(a); + u16_range_chk_counters[i][alu_u16]++; + alu_u16_reg.push_back(alu_u16); + a >>= 16; + } + u8_range_chk_counters[0][alu_u8_r0]++; + u8_range_chk_counters[1][alu_u8_r1]++; + return std::make_tuple(alu_u8_r0, alu_u8_r1, alu_u16_reg); +} + +/** + * @brief This is a helper function that is used to generate the range check entries for the comparison operation. + * This additionally increments the counts for the corresponding range lookups entries. + * @param row The initial row where the comparison operation was performed + * @param hi_lo_limbs The vector of 128-bit limbs hi and lo pairs of limbs that will be range checked. + * @return A vector of AluTraceEntry rows for the range checks for the comparison operation. + */ +std::vector AvmAluTraceBuilder::cmp_range_check_helper( + AvmAluTraceBuilder::AluTraceEntry row, std::vector hi_lo_limbs) +{ + // Assume each limb is 128 bits and since we can perform 256-bit range check per rows + // we need to have (limbs.size() / 2) range checks rows + size_t num_rows = hi_lo_limbs.size() / 2; + // The first row is the original comparison instruction (LT/LTE) + std::vector rows{ std::move(row) }; + rows.resize(num_rows, {}); + + // Now for each row, we need to unpack a pair from the hi_lo_limb array into the ALUs 8-bit and 16-bit registers + // The first row unpacks a_lo and a_hi, the second row unpacks b_lo and b_hi, and so on. + for (size_t j = 0; j < num_rows; j++) { + auto* r = &rows.at(j); + uint256_t lo_limb = hi_lo_limbs.at(2 * j); + uint256_t hi_limb = hi_lo_limbs.at(2 * j + 1); + uint256_t limb = lo_limb + (hi_limb << 128); + // Unpack lo limb and handle in the 8-bit registers + auto [alu_u8_r0, alu_u8_r1, alu_u16_reg] = AvmAluTraceBuilder::to_alu_slice_registers(limb); + r->alu_u8_r0 = alu_u8_r0; + r->alu_u8_r1 = alu_u8_r1; + std::copy(alu_u16_reg.begin(), alu_u16_reg.end(), r->alu_u16_reg.begin()); + + r->cmp_rng_ctr = j > 0 ? static_cast(num_rows - j) : 0; + r->rng_chk_sel = j > 0; + r->alu_op_eq_diff_inv = j > 0 ? FF(num_rows - j).invert() : 0; + + std::vector limb_arr = { hi_lo_limbs.begin() + static_cast(2 * j), hi_lo_limbs.end() }; + // Resizing here is probably suboptimal for performance, we can probably handle the shorter vectors and + // pad with zero during the finalise + limb_arr.resize(10, FF::zero()); + r->hi_lo_limbs = limb_arr; + } + return rows; +} + +/** + * Helper function to decompose a uint256_t into upper 128-bit and lower 128-bit tuple. + * The outputs are cast to uint256_t so they are easier to use in checks + */ + +std::tuple decompose(uint256_t const& a) +{ + uint256_t upper_bitmask = (uint256_t(1) << uint256_t(128)) - 1; + uint256_t a_lo = a & upper_bitmask; + uint256_t a_hi = a >> 128; + return std::make_tuple(a_lo, a_hi); +} + +// This creates a witness exclusively for the relation a > b +// This is useful when we want to enforce in certain checks that a must be greater than b +std::tuple gt_witness(uint256_t const& a, uint256_t const& b) +{ + uint256_t two_pow_128 = uint256_t(1) << uint256_t(128); + auto [a_lo, a_hi] = decompose(a); + auto [b_lo, b_hi] = decompose(b); + bool borrow = a_lo <= b_lo; + auto borrow_u256 = uint256_t(static_cast(borrow)); + uint256_t r_lo = a_lo - b_lo - 1 + borrow_u256 * two_pow_128; + uint256_t r_hi = a_hi - b_hi - borrow_u256; + return std::make_tuple(r_lo, r_hi, borrow); +} + +// This check is more flexible than gt_witness and is used when we want to generate the witness +// to the relation (a - b - 1) * q + (b - a) * (1 - q) +// where q = 1 if a > b and q = 0 if a <= b +std::tuple gt_or_lte_witness(uint256_t const& a, uint256_t const& b) +{ + uint256_t two_pow_128 = uint256_t(1) << uint256_t(128); + auto [a_lo, a_hi] = decompose(a); + auto [b_lo, b_hi] = decompose(b); + bool isGT = a > b; + if (isGT) { + return gt_witness(a, b); + } + bool borrow = b_lo < a_lo; + auto borrow_u256 = uint256_t(static_cast(borrow)); + uint256_t r_lo = b_lo - a_lo + borrow_u256 * two_pow_128; + uint256_t r_hi = b_hi - a_hi - borrow_u256; + return std::make_tuple(r_lo, r_hi, borrow); +} + +/** + * @brief Build Alu trace and compute the result of a LT operation on two operands. + * The tag type in_tag does not change the result of the operation. But we + * do need it for a relation check in the alu. * - * @param a Left operand of the equality - * @param b Right operand of the equality - * @param in_tag Instruction tag defining the number of bits for equality + * @param a Left operand of the LT + * @param b Right operand of the LT * @param clk Clock referring to the operation in the main trace. * - * @return FF The boolean result of equality casted to a finite field element + * @return FF The boolean result of LT casted to a finite field element */ -// FF AvmAluTraceBuilder::op_lt(FF const& a, FF const& b, AvmMemoryTag in_tag, uint32_t const clk) -// { -// FF c = a < b ? FF ::one() : FF::zero(); -// -// alu_trace.push_back(AvmAluTraceBuilder::AluTraceEntry{ -// .alu_clk = clk, -// .alu_op_eq = true, -// .alu_ff_tag = in_tag == AvmMemoryTag::FF, -// .alu_u8_tag = in_tag == AvmMemoryTag::U8, -// .alu_u16_tag = in_tag == AvmMemoryTag::U16, -// .alu_u32_tag = in_tag == AvmMemoryTag::U32, -// .alu_u64_tag = in_tag == AvmMemoryTag::U64, -// .alu_u128_tag = in_tag == AvmMemoryTag::U128, -// .alu_ia = a, -// .alu_ib = b, -// .alu_ic = res, -// .alu_op_eq_diff_inv = inv_c, -// .input_ia = b, -// .input_ib = a, -// bool borrow, -// }); -// -// return res; -// } +FF AvmAluTraceBuilder::op_lt(FF const& a, FF const& b, AvmMemoryTag in_tag, uint32_t const clk) +{ + bool c = uint256_t(a) < uint256_t(b); + + // Note: This is counter-intuitive, to show that a < b we actually show that b > a + // The subtlely is here that the circuit is designed as a GT(x,y) circuit, therefor we swap the inputs a & b + FF circuit_input_a = b; + FF circuit_input_b = a; + // Get the decomposition of b + auto [a_lo, a_hi] = decompose(b); + // Get the decomposition of a + auto [b_lo, b_hi] = decompose(a); + // Get the decomposition of p - a and p - b **remember that we swap the inputs** + // Note that a valid witness here is ONLY that p > a and p > b + auto [p_sub_a_lo, p_sub_a_hi, p_a_borrow] = gt_witness(FF::modulus, circuit_input_a); + auto [p_sub_b_lo, p_sub_b_hi, p_b_borrow] = gt_witness(FF::modulus, circuit_input_b); + // We either generate a witness that a <= b or a > b (its validity depends on the value of c) + auto [r_lo, r_hi, borrow] = gt_or_lte_witness(circuit_input_a, circuit_input_b); + + // The vector of limbs that are used in the GT circuit and that are range checked + std::vector hi_lo_limbs = { a_lo, a_hi, b_lo, b_hi, p_sub_a_lo, + p_sub_a_hi, p_sub_b_lo, p_sub_b_hi, r_lo, r_hi }; + + AvmAluTraceBuilder::AluTraceEntry row{ + .alu_clk = clk, + .alu_op_lt = true, + .alu_ff_tag = in_tag == AvmMemoryTag::FF, + .alu_u8_tag = in_tag == AvmMemoryTag::U8, + .alu_u16_tag = in_tag == AvmMemoryTag::U16, + .alu_u32_tag = in_tag == AvmMemoryTag::U32, + .alu_u64_tag = in_tag == AvmMemoryTag::U64, + .alu_u128_tag = in_tag == AvmMemoryTag::U128, + .alu_ia = a, + .alu_ib = b, + .alu_ic = FF(static_cast(c)), + .borrow = borrow, + .p_a_borrow = p_a_borrow, + .p_b_borrow = p_b_borrow, + }; + // Update the row and add new rows with the correct hi_lo limbs + std::vector rows = cmp_range_check_helper(row, hi_lo_limbs); + // Append the rows to the alu_trace + alu_trace.insert(alu_trace.end(), rows.begin(), rows.end()); + return { static_cast(c) }; +} + +/** + * @brief Build Alu trace and compute the result of a LTE operation on two operands. + * The tag type in_tag does not change the result of the operation. But we + * do need it for a relation check in the alu. + * + * @param a Left operand of the LTE + * @param b Right operand of the LTE + * @param clk Clock referring to the operation in the main trace. + * + * @return FF The boolean result of LTE casted to a finite field element + */ +FF AvmAluTraceBuilder::op_lte(FF const& a, FF const& b, AvmMemoryTag in_tag, uint32_t const clk) +{ + bool c = uint256_t(a) <= uint256_t(b); + + // Get the decomposition of a + auto [a_lo, a_hi] = decompose(a); + // Get the decomposition of b + auto [b_lo, b_hi] = decompose(b); + // Get the decomposition of p - a and p - b + // Note that a valid witness here is that p > a and p > b + auto [p_sub_a_lo, p_sub_a_hi, p_a_borrow] = gt_witness(FF::modulus, a); + auto [p_sub_b_lo, p_sub_b_hi, p_b_borrow] = gt_witness(FF::modulus, b); + // We either generate a witness that a <= b or a > b (its validity depends on the value of c) + auto [r_lo, r_hi, borrow] = gt_or_lte_witness(a, b); + + // The vector of limbs that are used in the GT circuit and that are range checked + std::vector hi_lo_limbs = { a_lo, a_hi, b_lo, b_hi, p_sub_a_lo, + p_sub_a_hi, p_sub_b_lo, p_sub_b_hi, r_lo, r_hi }; + + // Construct the row that performs the lte check + AvmAluTraceBuilder::AluTraceEntry row{ + .alu_clk = clk, + .alu_op_lte = true, + .alu_ff_tag = in_tag == AvmMemoryTag::FF, + .alu_u8_tag = in_tag == AvmMemoryTag::U8, + .alu_u16_tag = in_tag == AvmMemoryTag::U16, + .alu_u32_tag = in_tag == AvmMemoryTag::U32, + .alu_u64_tag = in_tag == AvmMemoryTag::U64, + .alu_u128_tag = in_tag == AvmMemoryTag::U128, + .alu_ia = a, + .alu_ib = b, + .alu_ic = FF(static_cast(c)), + .borrow = borrow, + .p_a_borrow = p_a_borrow, + .p_b_borrow = p_b_borrow, + }; + // Update the row and add new rows with the correct hi_lo limbs + std::vector rows = cmp_range_check_helper(row, hi_lo_limbs); + alu_trace.insert(alu_trace.end(), rows.begin(), rows.end()); + return { static_cast(c) }; +} } // namespace bb::avm_trace diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.hpp index ec9e53d4b97d..ccfd299a7b68 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.hpp @@ -2,6 +2,9 @@ #include "avm_common.hpp" #include "barretenberg/numeric/uint128/uint128.hpp" +#include "barretenberg/numeric/uint256/uint256.hpp" +#include +#include namespace bb::avm_trace { @@ -41,27 +44,19 @@ class AvmAluTraceBuilder { FF alu_op_eq_diff_inv{}; - // Comparison check - FF input_ia; - FF input_ib; - bool borrow; - - uint128_t a_lo; - uint128_t a_hi; - uint128_t b_lo; - uint128_t b_hi; - - uint128_t p_sub_a_lo; - uint128_t p_sub_a_hi; - bool p_a_borrow; - uint128_t p_sub_b_lo; - uint128_t p_sub_b_hi; - bool p_b_borrow; - - uint128_t res_lo; - uint128_t res_hi; + // Comparison Operation + bool borrow = false; + + std::vector hi_lo_limbs; + bool p_a_borrow = false; + bool p_b_borrow = false; + uint8_t cmp_rng_ctr = 0; + bool rng_chk_sel = false; }; + std::array, 2> u8_range_chk_counters; + std::array, 15> u16_range_chk_counters; + AvmAluTraceBuilder(); void reset(); std::vector finalize(); @@ -76,5 +71,8 @@ class AvmAluTraceBuilder { private: std::vector alu_trace; + template std::tuple> to_alu_slice_registers(T a); + std::vector cmp_range_check_helper(AluTraceEntry row, std::vector hi_lo_limbs); + void count_range_checks(AluTraceEntry const& entry); }; } // namespace bb::avm_trace diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp index 549f68dd408f..03d4091ddefd 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_deserialization.cpp @@ -28,6 +28,8 @@ const std::unordered_map> OPCODE_WIRE_FORMAT = { OpCode::DIV, three_operand_format }, // Compute - Comparators { OpCode::EQ, three_operand_format }, + { OpCode::LT, three_operand_format }, + { OpCode::LTE, three_operand_format }, // Compute - Bitwise { OpCode::NOT, { OperandType::INDIRECT, OperandType::TAG, OperandType::UINT32, OperandType::UINT32 } }, { OpCode::AND, three_operand_format }, diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp index 10e2ce6b15be..753ce9eca132 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp @@ -136,6 +136,20 @@ std::vector Execution::gen_trace(std::vector const& instructio std::get(inst.operands.at(4)), std::get(inst.operands.at(1))); break; + case OpCode::LT: + trace_builder.op_lt(std::get(inst.operands.at(0)), + std::get(inst.operands.at(2)), + std::get(inst.operands.at(3)), + std::get(inst.operands.at(4)), + std::get(inst.operands.at(1))); + break; + case OpCode::LTE: + trace_builder.op_lte(std::get(inst.operands.at(0)), + std::get(inst.operands.at(2)), + std::get(inst.operands.at(3)), + std::get(inst.operands.at(4)), + std::get(inst.operands.at(1))); + break; // Compute - Bitwise case OpCode::NOT: trace_builder.op_not(std::get(inst.operands.at(0)), diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp index 71bc1b292aea..fc74537965fb 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp @@ -45,9 +45,19 @@ void log_avm_trace(std::vector const& trace, size_t beg, size_t end, bool e info("alu_ia ", trace.at(i).avm_alu_ia); info("alu_ib ", trace.at(i).avm_alu_ib); info("alu_ic ", trace.at(i).avm_alu_ic); + info("alu_rng_CHECK ", trace.at(i).avm_alu_rng_chk_sel); + info("alu_rng_shift_CHECK ", trace.at(i).avm_alu_rng_chk_sel_shift); + info("alu_rng_REMAINING ", trace.at(i).avm_alu_cmp_rng_ctr); + info("alu_cmp_sel ", trace.at(i).avm_alu_cmp_sel); + info("alu_sel ", trace.at(i).avm_alu_alu_sel); + info("alu_a_lo ", trace.at(i).avm_alu_a_lo); + info("alu_a_hi ", trace.at(i).avm_alu_a_hi); + info("alu_u8_0 ", trace.at(i).avm_alu_u8_r0); + info("rng_chk_lookup_selector", trace.at(i).avm_alu_rng_chk_lookup_selector); info("=======MAIN TRACE===================================================================="); info("clk: ", trace.at(i).avm_main_clk); + info("Sel_rng_8: ", trace.at(i).avm_main_sel_rng_8); info("ia: ", trace.at(i).avm_main_ia); info("ib: ", trace.at(i).avm_main_ib); info("ic: ", trace.at(i).avm_main_ic); @@ -56,6 +66,7 @@ void log_avm_trace(std::vector const& trace, size_t beg, size_t end, bool e info("tag_err ", trace.at(i).avm_main_tag_err); info("first: ", trace.at(i).avm_main_first); info("last: ", trace.at(i).avm_main_last); + info("avm_alu_sel ", trace.at(i).avm_main_alu_sel); info("=======MEM_OP_A======================================================================"); info("mem_op_a: ", trace.at(i).avm_main_mem_op_a); 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 a66fcb4edf92..303faeea5b23 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp @@ -629,6 +629,108 @@ void AvmTraceBuilder::op_xor( }); } +void AvmTraceBuilder::op_lt( + uint8_t indirect, uint32_t a_offset, uint32_t b_offset, uint32_t dst_offset, AvmMemoryTag in_tag) +{ + auto clk = static_cast(main_trace.size()); + + auto const res = resolve_ind_three(clk, indirect, a_offset, b_offset, dst_offset); + bool tag_match = res.tag_match; + + // Reading from memory and loading into ia resp. ib. + auto read_a = mem_trace_builder.read_and_load_from_memory( + clk, IntermRegister::IA, res.direct_a_offset, in_tag, AvmMemoryTag::U8); + auto read_b = mem_trace_builder.read_and_load_from_memory( + clk, IntermRegister::IB, res.direct_b_offset, in_tag, AvmMemoryTag::U8); + tag_match = read_a.tag_match && read_b.tag_match; + + FF a = tag_match ? read_a.val : FF(0); + FF b = tag_match ? read_b.val : FF(0); + + FF c = tag_match ? alu_trace_builder.op_lt(a, b, in_tag, clk) : FF(0); + + 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); + + main_trace.push_back(Row{ + .avm_main_clk = clk, + .avm_main_ia = a, + .avm_main_ib = b, + .avm_main_ic = c, + .avm_main_ind_a = res.indirect_flag_a ? FF(a_offset) : FF(0), + .avm_main_ind_b = res.indirect_flag_b ? FF(b_offset) : FF(0), + .avm_main_ind_c = res.indirect_flag_c ? FF(dst_offset) : FF(0), + .avm_main_ind_op_a = FF(static_cast(res.indirect_flag_a)), + .avm_main_ind_op_b = FF(static_cast(res.indirect_flag_b)), + .avm_main_ind_op_c = FF(static_cast(res.indirect_flag_c)), + .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_op_a = FF(1), + .avm_main_mem_op_b = FF(1), + .avm_main_mem_op_c = FF(1), + .avm_main_pc = FF(pc++), + .avm_main_r_in_tag = FF(static_cast(in_tag)), + .avm_main_rwc = FF(1), + .avm_main_sel_op_lt = FF(1), + .avm_main_tag_err = FF(static_cast(!tag_match)), + .avm_main_w_in_tag = FF(static_cast(AvmMemoryTag::U8)), + }); +} + +void AvmTraceBuilder::op_lte( + uint8_t indirect, uint32_t a_offset, uint32_t b_offset, uint32_t dst_offset, AvmMemoryTag in_tag) +{ + auto clk = static_cast(main_trace.size()); + + auto const res = resolve_ind_three(clk, indirect, a_offset, b_offset, dst_offset); + bool tag_match = res.tag_match; + + // Reading from memory and loading into ia resp. ib. + auto read_a = mem_trace_builder.read_and_load_from_memory( + clk, IntermRegister::IA, res.direct_a_offset, in_tag, AvmMemoryTag::U8); + auto read_b = mem_trace_builder.read_and_load_from_memory( + clk, IntermRegister::IB, res.direct_b_offset, in_tag, AvmMemoryTag::U8); + tag_match = read_a.tag_match && read_b.tag_match; + + FF a = tag_match ? read_a.val : FF(0); + FF b = tag_match ? read_b.val : FF(0); + + FF c = tag_match ? alu_trace_builder.op_lte(a, b, in_tag, clk) : FF(0); + + 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); + + main_trace.push_back(Row{ + .avm_main_clk = clk, + .avm_main_ia = a, + .avm_main_ib = b, + .avm_main_ic = c, + .avm_main_ind_a = res.indirect_flag_a ? FF(a_offset) : FF(0), + .avm_main_ind_b = res.indirect_flag_b ? FF(b_offset) : FF(0), + .avm_main_ind_c = res.indirect_flag_c ? FF(dst_offset) : FF(0), + .avm_main_ind_op_a = FF(static_cast(res.indirect_flag_a)), + .avm_main_ind_op_b = FF(static_cast(res.indirect_flag_b)), + .avm_main_ind_op_c = FF(static_cast(res.indirect_flag_c)), + .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_op_a = FF(1), + .avm_main_mem_op_b = FF(1), + .avm_main_mem_op_c = FF(1), + .avm_main_pc = FF(pc++), + .avm_main_r_in_tag = FF(static_cast(in_tag)), + .avm_main_rwc = FF(1), + .avm_main_sel_op_lte = FF(1), + .avm_main_tag_err = FF(static_cast(!tag_match)), + .avm_main_w_in_tag = FF(static_cast(AvmMemoryTag::U8)), + }); +} + // TODO: Ensure that the bytecode validation and/or deserialization is // enforcing that val complies to the tag. /** @@ -1136,7 +1238,7 @@ std::vector AvmTraceBuilder::finalize() // If the bin_trace_size has entries, we need the main_trace to be as big as our byte lookup table (3 * 2**16 // long) size_t const lookup_table_size = bin_trace_size > 0 ? 3 * (1 << 16) : 0; - size_t const range_check_size = range_checked_required ? UINT16_MAX : 0; + size_t const range_check_size = range_checked_required ? UINT8_MAX + 1 : 0; std::vector trace_sizes = { mem_trace_size, main_trace_size, alu_trace_size, lookup_table_size, range_check_size }; @@ -1145,9 +1247,10 @@ std::vector AvmTraceBuilder::finalize() // We only need to pad with zeroes to the size to the largest trace here, pow_2 padding is handled in the // subgroup_size check in bb // Resize the main_trace to accomodate a potential lookup, filling with default empty rows. + main_trace_size = *trace_size; main_trace.resize(*trace_size, {}); - main_trace.at(main_trace_size - 1).avm_main_last = FF(1); + main_trace.at(*trace_size - 1).avm_main_last = FF(1); // Memory trace inclusion for (size_t i = 0; i < mem_trace_size; i++) { @@ -1215,6 +1318,10 @@ std::vector AvmTraceBuilder::finalize() dest.avm_alu_op_mul = FF(static_cast(src.alu_op_mul)); dest.avm_alu_op_not = FF(static_cast(src.alu_op_not)); dest.avm_alu_op_eq = FF(static_cast(src.alu_op_eq)); + dest.avm_alu_op_lt = FF(static_cast(src.alu_op_lt)); + dest.avm_alu_op_lte = FF(static_cast(src.alu_op_lte)); + dest.avm_alu_cmp_sel = FF(static_cast(src.alu_op_lt) + static_cast(src.alu_op_lte)); + dest.avm_alu_rng_chk_sel = FF(static_cast(src.rng_chk_sel)); dest.avm_alu_ff_tag = FF(static_cast(src.alu_ff_tag)); dest.avm_alu_u8_tag = FF(static_cast(src.alu_u8_tag)); @@ -1258,33 +1365,58 @@ std::vector AvmTraceBuilder::finalize() // Not all rows in ALU are enabled with a selector. For instance, // multiplication over u128 is taking two lines. if (dest.avm_alu_op_add == FF(1) || dest.avm_alu_op_sub == FF(1) || dest.avm_alu_op_mul == FF(1) || - dest.avm_alu_op_eq == FF(1) || dest.avm_alu_op_not == FF(1)) { + dest.avm_alu_op_eq == FF(1) || dest.avm_alu_op_not == FF(1) || dest.avm_alu_op_lt == FF(1) || + dest.avm_alu_op_lte == FF(1)) { dest.avm_alu_alu_sel = FF(1); } + if (dest.avm_alu_cmp_sel == FF(1) || dest.avm_alu_rng_chk_sel == FF(1)) { + dest.avm_alu_a_lo = FF(src.hi_lo_limbs.at(0)); + dest.avm_alu_a_hi = FF(src.hi_lo_limbs.at(1)); + dest.avm_alu_b_lo = FF(src.hi_lo_limbs.at(2)); + dest.avm_alu_b_hi = FF(src.hi_lo_limbs.at(3)); + dest.avm_alu_p_sub_a_lo = FF(src.hi_lo_limbs.at(4)); + dest.avm_alu_p_sub_a_hi = FF(src.hi_lo_limbs.at(5)); + dest.avm_alu_p_sub_b_lo = FF(src.hi_lo_limbs.at(6)); + dest.avm_alu_p_sub_b_hi = FF(src.hi_lo_limbs.at(7)); + dest.avm_alu_res_lo = FF(src.hi_lo_limbs.at(8)); + dest.avm_alu_res_hi = FF(src.hi_lo_limbs.at(9)); + dest.avm_alu_p_a_borrow = FF(static_cast(src.p_a_borrow)); + dest.avm_alu_p_b_borrow = FF(static_cast(src.p_b_borrow)); + dest.avm_alu_borrow = FF(static_cast(src.borrow)); + dest.avm_alu_rng_chk_sel = FF(static_cast(src.rng_chk_sel)); + dest.avm_alu_cmp_rng_ctr = FF(static_cast(src.cmp_rng_ctr)); + dest.avm_alu_rng_chk_lookup_selector = FF(1); + } } for (size_t i = 0; i < main_trace_size; i++) { auto& r = main_trace.at(i); 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_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); } if (i <= UINT8_MAX) { + r.lookup_u8_0_counts = alu_trace_builder.u8_range_chk_counters[0][static_cast(i)]; + r.lookup_u8_1_counts = alu_trace_builder.u8_range_chk_counters[1][static_cast(i)]; r.avm_main_sel_rng_8 = FF(1); + r.avm_main_clk = FF(static_cast(i)); } if (i <= UINT16_MAX) { r.avm_main_sel_rng_16 = FF(1); + r.avm_main_clk = FF(static_cast(i)); } } // 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_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); } 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 a68439da21af..4d65afdc45cf 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp @@ -56,6 +56,12 @@ class AvmTraceBuilder { // Bitwise xor with direct or indirect memory access. void op_xor(uint8_t indirect, uint32_t a_offset, uint32_t b_offset, uint32_t dst_offset, AvmMemoryTag in_tag); + // Less Than with direct or indirect memory access. + void op_lt(uint8_t indirect, uint32_t a_offset, uint32_t b_offset, uint32_t dst_offset, AvmMemoryTag in_tag); + + // Less Than or Equal to with direct or indirect memory access. + void op_lte(uint8_t indirect, uint32_t a_offset, uint32_t b_offset, uint32_t dst_offset, AvmMemoryTag in_tag); + // Set a constant from bytecode with direct or indirect memory access. void op_set(uint8_t indirect, uint128_t val, uint32_t dst_offset, AvmMemoryTag in_tag); 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 8697cb8d2a45..279a2a44b689 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp @@ -19,9 +19,10 @@ #include "barretenberg/relations/generated/avm/incl_mem_tag_err.hpp" #include "barretenberg/relations/generated/avm/lookup_byte_lengths.hpp" #include "barretenberg/relations/generated/avm/lookup_byte_operations.hpp" +#include "barretenberg/relations/generated/avm/lookup_u8_0.hpp" +#include "barretenberg/relations/generated/avm/lookup_u8_1.hpp" #include "barretenberg/relations/generated/avm/perm_main_alu.hpp" #include "barretenberg/relations/generated/avm/perm_main_bin.hpp" -#include "barretenberg/relations/generated/avm/perm_main_cmp.hpp" #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" @@ -43,20 +44,19 @@ template struct AvmFullRow { FF avm_alu_borrow{}; FF avm_alu_cf{}; FF avm_alu_clk{}; + FF avm_alu_cmp_rng_ctr{}; FF avm_alu_cmp_sel{}; FF avm_alu_ff_tag{}; FF avm_alu_ia{}; FF avm_alu_ib{}; FF avm_alu_ic{}; FF avm_alu_in_tag{}; - FF avm_alu_input_ia{}; - FF avm_alu_input_ib{}; - FF avm_alu_lt_sel{}; - FF avm_alu_lte_sel{}; FF avm_alu_op_add{}; FF avm_alu_op_div{}; FF avm_alu_op_eq{}; FF avm_alu_op_eq_diff_inv{}; + FF avm_alu_op_lt{}; + FF avm_alu_op_lte{}; FF avm_alu_op_mul{}; FF avm_alu_op_not{}; FF avm_alu_op_sub{}; @@ -68,7 +68,7 @@ template struct AvmFullRow { FF avm_alu_p_sub_b_lo{}; FF avm_alu_res_hi{}; FF avm_alu_res_lo{}; - FF avm_alu_rng_chk_remaining{}; + FF avm_alu_rng_chk_lookup_selector{}; FF avm_alu_rng_chk_sel{}; FF avm_alu_u128_tag{}; FF avm_alu_u16_r0{}; @@ -116,7 +116,6 @@ template struct AvmFullRow { FF avm_main_alu_sel{}; FF avm_main_bin_op_id{}; FF avm_main_bin_sel{}; - FF avm_main_cmp_sel{}; FF avm_main_ia{}; FF avm_main_ib{}; FF avm_main_ic{}; @@ -182,7 +181,6 @@ template struct AvmFullRow { FF avm_mem_w_in_tag{}; FF perm_main_alu{}; FF perm_main_bin{}; - FF perm_main_cmp{}; FF perm_main_mem_a{}; FF perm_main_mem_b{}; FF perm_main_mem_c{}; @@ -193,19 +191,23 @@ template struct AvmFullRow { FF lookup_byte_operations{}; FF incl_main_tag_err{}; FF incl_mem_tag_err{}; + FF lookup_u8_0{}; + FF lookup_u8_1{}; FF lookup_byte_lengths_counts{}; FF lookup_byte_operations_counts{}; FF incl_main_tag_err_counts{}; FF incl_mem_tag_err_counts{}; + FF lookup_u8_0_counts{}; + FF lookup_u8_1_counts{}; FF avm_alu_a_hi_shift{}; FF avm_alu_a_lo_shift{}; FF avm_alu_b_hi_shift{}; FF avm_alu_b_lo_shift{}; + FF avm_alu_cmp_rng_ctr_shift{}; FF avm_alu_p_sub_a_hi_shift{}; FF avm_alu_p_sub_a_lo_shift{}; FF avm_alu_p_sub_b_hi_shift{}; FF avm_alu_p_sub_b_lo_shift{}; - FF avm_alu_rng_chk_remaining_shift{}; FF avm_alu_rng_chk_sel_shift{}; FF avm_alu_u16_r0_shift{}; FF avm_alu_u16_r1_shift{}; @@ -238,8 +240,8 @@ class AvmCircuitBuilder { using Polynomial = Flavor::Polynomial; using ProverPolynomials = Flavor::ProverPolynomials; - static constexpr size_t num_fixed_columns = 193; - static constexpr size_t num_polys = 164; + static constexpr size_t num_fixed_columns = 194; + static constexpr size_t num_polys = 165; std::vector rows; void set_trace(std::vector&& trace) { rows = std::move(trace); } @@ -265,20 +267,19 @@ class AvmCircuitBuilder { polys.avm_alu_borrow[i] = rows[i].avm_alu_borrow; polys.avm_alu_cf[i] = rows[i].avm_alu_cf; polys.avm_alu_clk[i] = rows[i].avm_alu_clk; + polys.avm_alu_cmp_rng_ctr[i] = rows[i].avm_alu_cmp_rng_ctr; polys.avm_alu_cmp_sel[i] = rows[i].avm_alu_cmp_sel; polys.avm_alu_ff_tag[i] = rows[i].avm_alu_ff_tag; polys.avm_alu_ia[i] = rows[i].avm_alu_ia; polys.avm_alu_ib[i] = rows[i].avm_alu_ib; polys.avm_alu_ic[i] = rows[i].avm_alu_ic; polys.avm_alu_in_tag[i] = rows[i].avm_alu_in_tag; - polys.avm_alu_input_ia[i] = rows[i].avm_alu_input_ia; - polys.avm_alu_input_ib[i] = rows[i].avm_alu_input_ib; - polys.avm_alu_lt_sel[i] = rows[i].avm_alu_lt_sel; - polys.avm_alu_lte_sel[i] = rows[i].avm_alu_lte_sel; polys.avm_alu_op_add[i] = rows[i].avm_alu_op_add; polys.avm_alu_op_div[i] = rows[i].avm_alu_op_div; polys.avm_alu_op_eq[i] = rows[i].avm_alu_op_eq; polys.avm_alu_op_eq_diff_inv[i] = rows[i].avm_alu_op_eq_diff_inv; + polys.avm_alu_op_lt[i] = rows[i].avm_alu_op_lt; + polys.avm_alu_op_lte[i] = rows[i].avm_alu_op_lte; polys.avm_alu_op_mul[i] = rows[i].avm_alu_op_mul; polys.avm_alu_op_not[i] = rows[i].avm_alu_op_not; polys.avm_alu_op_sub[i] = rows[i].avm_alu_op_sub; @@ -290,7 +291,7 @@ class AvmCircuitBuilder { polys.avm_alu_p_sub_b_lo[i] = rows[i].avm_alu_p_sub_b_lo; polys.avm_alu_res_hi[i] = rows[i].avm_alu_res_hi; polys.avm_alu_res_lo[i] = rows[i].avm_alu_res_lo; - polys.avm_alu_rng_chk_remaining[i] = rows[i].avm_alu_rng_chk_remaining; + polys.avm_alu_rng_chk_lookup_selector[i] = rows[i].avm_alu_rng_chk_lookup_selector; polys.avm_alu_rng_chk_sel[i] = rows[i].avm_alu_rng_chk_sel; polys.avm_alu_u128_tag[i] = rows[i].avm_alu_u128_tag; polys.avm_alu_u16_r0[i] = rows[i].avm_alu_u16_r0; @@ -338,7 +339,6 @@ class AvmCircuitBuilder { polys.avm_main_alu_sel[i] = rows[i].avm_main_alu_sel; polys.avm_main_bin_op_id[i] = rows[i].avm_main_bin_op_id; polys.avm_main_bin_sel[i] = rows[i].avm_main_bin_sel; - polys.avm_main_cmp_sel[i] = rows[i].avm_main_cmp_sel; 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; @@ -407,7 +407,6 @@ class AvmCircuitBuilder { ======= polys.perm_main_bin[i] = rows[i].perm_main_bin; - polys.perm_main_cmp[i] = rows[i].perm_main_cmp; 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; @@ -418,22 +417,29 @@ class AvmCircuitBuilder { 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; +<<<<<<< HEAD >>>>>>> 7a982d52c (feat: init avm cmp) +======= + polys.lookup_u8_0[i] = rows[i].lookup_u8_0; + polys.lookup_u8_1[i] = rows[i].lookup_u8_1; +>>>>>>> 8d38899c9 (feat: some wip) 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; polys.incl_mem_tag_err_counts[i] = rows[i].incl_mem_tag_err_counts; + polys.lookup_u8_0_counts[i] = rows[i].lookup_u8_0_counts; + polys.lookup_u8_1_counts[i] = rows[i].lookup_u8_1_counts; } polys.avm_alu_a_hi_shift = Polynomial(polys.avm_alu_a_hi.shifted()); polys.avm_alu_a_lo_shift = Polynomial(polys.avm_alu_a_lo.shifted()); polys.avm_alu_b_hi_shift = Polynomial(polys.avm_alu_b_hi.shifted()); polys.avm_alu_b_lo_shift = Polynomial(polys.avm_alu_b_lo.shifted()); + polys.avm_alu_cmp_rng_ctr_shift = Polynomial(polys.avm_alu_cmp_rng_ctr.shifted()); polys.avm_alu_p_sub_a_hi_shift = Polynomial(polys.avm_alu_p_sub_a_hi.shifted()); polys.avm_alu_p_sub_a_lo_shift = Polynomial(polys.avm_alu_p_sub_a_lo.shifted()); polys.avm_alu_p_sub_b_hi_shift = Polynomial(polys.avm_alu_p_sub_b_hi.shifted()); polys.avm_alu_p_sub_b_lo_shift = Polynomial(polys.avm_alu_p_sub_b_lo.shifted()); - polys.avm_alu_rng_chk_remaining_shift = Polynomial(polys.avm_alu_rng_chk_remaining.shifted()); polys.avm_alu_rng_chk_sel_shift = Polynomial(polys.avm_alu_rng_chk_sel.shifted()); polys.avm_alu_u16_r0_shift = Polynomial(polys.avm_alu_u16_r0.shifted()); polys.avm_alu_u16_r1_shift = Polynomial(polys.avm_alu_u16_r1.shifted()); @@ -548,9 +554,6 @@ class AvmCircuitBuilder { if (!evaluate_logderivative.template operator()>("PERM_MAIN_BIN")) { return false; } - if (!evaluate_logderivative.template operator()>("PERM_MAIN_CMP")) { - return false; - } if (!evaluate_logderivative.template operator()>("PERM_MAIN_MEM_A")) { return false; } @@ -582,6 +585,12 @@ class AvmCircuitBuilder { if (!evaluate_logderivative.template operator()>("INCL_MEM_TAG_ERR")) { return false; } + if (!evaluate_logderivative.template operator()>("LOOKUP_U8_0")) { + return false; + } + if (!evaluate_logderivative.template operator()>("LOOKUP_U8_1")) { + return false; + } return true; } diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp index 8c6d08990a46..d425d79d574b 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp @@ -23,7 +23,6 @@ #include "barretenberg/relations/generated/avm/lookup_byte_operations.hpp" #include "barretenberg/relations/generated/avm/perm_main_alu.hpp" #include "barretenberg/relations/generated/avm/perm_main_bin.hpp" -#include "barretenberg/relations/generated/avm/perm_main_cmp.hpp" #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" @@ -51,11 +50,11 @@ class AvmFlavor { using RelationSeparator = FF; static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 2; - static constexpr size_t NUM_WITNESS_ENTITIES = 162; + static constexpr size_t NUM_WITNESS_ENTITIES = 163; 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 = 193; + static constexpr size_t NUM_ALL_ENTITIES = 194; using GrandProductRelations = std::tuple, perm_main_bin_relation, @@ -76,7 +75,6 @@ class AvmFlavor { Avm_vm::avm_mem, perm_main_alu_relation, perm_main_bin_relation, - perm_main_cmp_relation, perm_main_mem_a_relation, perm_main_mem_b_relation, perm_main_mem_c_relation, @@ -128,20 +126,19 @@ class AvmFlavor { avm_alu_borrow, avm_alu_cf, avm_alu_clk, + avm_alu_cmp_rng_ctr, avm_alu_cmp_sel, avm_alu_ff_tag, avm_alu_ia, avm_alu_ib, avm_alu_ic, avm_alu_in_tag, - avm_alu_input_ia, - avm_alu_input_ib, - avm_alu_lt_sel, - avm_alu_lte_sel, avm_alu_op_add, avm_alu_op_div, avm_alu_op_eq, avm_alu_op_eq_diff_inv, + avm_alu_op_lt, + avm_alu_op_lte, avm_alu_op_mul, avm_alu_op_not, avm_alu_op_sub, @@ -153,7 +150,7 @@ class AvmFlavor { avm_alu_p_sub_b_lo, avm_alu_res_hi, avm_alu_res_lo, - avm_alu_rng_chk_remaining, + avm_alu_rng_chk_lookup_selector, avm_alu_rng_chk_sel, avm_alu_u128_tag, avm_alu_u16_r0, @@ -201,7 +198,6 @@ class AvmFlavor { avm_main_alu_sel, avm_main_bin_op_id, avm_main_bin_sel, - avm_main_cmp_sel, avm_main_ia, avm_main_ib, avm_main_ic, @@ -267,7 +263,6 @@ class AvmFlavor { avm_mem_w_in_tag, perm_main_alu, perm_main_bin, - perm_main_cmp, perm_main_mem_a, perm_main_mem_b, perm_main_mem_c, @@ -278,10 +273,14 @@ class AvmFlavor { lookup_byte_operations, incl_main_tag_err, incl_mem_tag_err, + lookup_u8_0, + lookup_u8_1, lookup_byte_lengths_counts, lookup_byte_operations_counts, incl_main_tag_err_counts, - incl_mem_tag_err_counts) + incl_mem_tag_err_counts, + lookup_u8_0_counts, + lookup_u8_1_counts) RefVector get_wires() { @@ -293,20 +292,19 @@ class AvmFlavor { avm_alu_borrow, avm_alu_cf, avm_alu_clk, + avm_alu_cmp_rng_ctr, avm_alu_cmp_sel, avm_alu_ff_tag, avm_alu_ia, avm_alu_ib, avm_alu_ic, avm_alu_in_tag, - avm_alu_input_ia, - avm_alu_input_ib, - avm_alu_lt_sel, - avm_alu_lte_sel, avm_alu_op_add, avm_alu_op_div, avm_alu_op_eq, avm_alu_op_eq_diff_inv, + avm_alu_op_lt, + avm_alu_op_lte, avm_alu_op_mul, avm_alu_op_not, avm_alu_op_sub, @@ -318,7 +316,7 @@ class AvmFlavor { avm_alu_p_sub_b_lo, avm_alu_res_hi, avm_alu_res_lo, - avm_alu_rng_chk_remaining, + avm_alu_rng_chk_lookup_selector, avm_alu_rng_chk_sel, avm_alu_u128_tag, avm_alu_u16_r0, @@ -366,7 +364,6 @@ class AvmFlavor { avm_main_alu_sel, avm_main_bin_op_id, avm_main_bin_sel, - avm_main_cmp_sel, avm_main_ia, avm_main_ib, avm_main_ic, @@ -432,7 +429,6 @@ class AvmFlavor { avm_mem_w_in_tag, perm_main_alu, perm_main_bin, - perm_main_cmp, perm_main_mem_a, perm_main_mem_b, perm_main_mem_c, @@ -443,10 +439,14 @@ class AvmFlavor { lookup_byte_operations, incl_main_tag_err, incl_mem_tag_err, + lookup_u8_0, + lookup_u8_1, lookup_byte_lengths_counts, lookup_byte_operations_counts, incl_main_tag_err_counts, - incl_mem_tag_err_counts }; + incl_mem_tag_err_counts, + lookup_u8_0_counts, + lookup_u8_1_counts }; }; }; @@ -463,20 +463,19 @@ class AvmFlavor { avm_alu_borrow, avm_alu_cf, avm_alu_clk, + avm_alu_cmp_rng_ctr, avm_alu_cmp_sel, avm_alu_ff_tag, avm_alu_ia, avm_alu_ib, avm_alu_ic, avm_alu_in_tag, - avm_alu_input_ia, - avm_alu_input_ib, - avm_alu_lt_sel, - avm_alu_lte_sel, avm_alu_op_add, avm_alu_op_div, avm_alu_op_eq, avm_alu_op_eq_diff_inv, + avm_alu_op_lt, + avm_alu_op_lte, avm_alu_op_mul, avm_alu_op_not, avm_alu_op_sub, @@ -488,7 +487,7 @@ class AvmFlavor { avm_alu_p_sub_b_lo, avm_alu_res_hi, avm_alu_res_lo, - avm_alu_rng_chk_remaining, + avm_alu_rng_chk_lookup_selector, avm_alu_rng_chk_sel, avm_alu_u128_tag, avm_alu_u16_r0, @@ -536,7 +535,6 @@ class AvmFlavor { avm_main_alu_sel, avm_main_bin_op_id, avm_main_bin_sel, - avm_main_cmp_sel, avm_main_ia, avm_main_ib, avm_main_ic, @@ -602,7 +600,6 @@ class AvmFlavor { avm_mem_w_in_tag, perm_main_alu, perm_main_bin, - perm_main_cmp, perm_main_mem_a, perm_main_mem_b, perm_main_mem_c, @@ -613,19 +610,23 @@ class AvmFlavor { lookup_byte_operations, incl_main_tag_err, incl_mem_tag_err, + lookup_u8_0, + lookup_u8_1, lookup_byte_lengths_counts, lookup_byte_operations_counts, incl_main_tag_err_counts, incl_mem_tag_err_counts, + lookup_u8_0_counts, + lookup_u8_1_counts, avm_alu_a_hi_shift, avm_alu_a_lo_shift, avm_alu_b_hi_shift, avm_alu_b_lo_shift, + avm_alu_cmp_rng_ctr_shift, avm_alu_p_sub_a_hi_shift, avm_alu_p_sub_a_lo_shift, avm_alu_p_sub_b_hi_shift, avm_alu_p_sub_b_lo_shift, - avm_alu_rng_chk_remaining_shift, avm_alu_rng_chk_sel_shift, avm_alu_u16_r0_shift, avm_alu_u16_r1_shift, @@ -659,20 +660,19 @@ class AvmFlavor { avm_alu_borrow, avm_alu_cf, avm_alu_clk, + avm_alu_cmp_rng_ctr, avm_alu_cmp_sel, avm_alu_ff_tag, avm_alu_ia, avm_alu_ib, avm_alu_ic, avm_alu_in_tag, - avm_alu_input_ia, - avm_alu_input_ib, - avm_alu_lt_sel, - avm_alu_lte_sel, avm_alu_op_add, avm_alu_op_div, avm_alu_op_eq, avm_alu_op_eq_diff_inv, + avm_alu_op_lt, + avm_alu_op_lte, avm_alu_op_mul, avm_alu_op_not, avm_alu_op_sub, @@ -684,7 +684,7 @@ class AvmFlavor { avm_alu_p_sub_b_lo, avm_alu_res_hi, avm_alu_res_lo, - avm_alu_rng_chk_remaining, + avm_alu_rng_chk_lookup_selector, avm_alu_rng_chk_sel, avm_alu_u128_tag, avm_alu_u16_r0, @@ -732,7 +732,6 @@ class AvmFlavor { avm_main_alu_sel, avm_main_bin_op_id, avm_main_bin_sel, - avm_main_cmp_sel, avm_main_ia, avm_main_ib, avm_main_ic, @@ -798,7 +797,6 @@ class AvmFlavor { avm_mem_w_in_tag, perm_main_alu, perm_main_bin, - perm_main_cmp, perm_main_mem_a, perm_main_mem_b, perm_main_mem_c, @@ -809,19 +807,23 @@ class AvmFlavor { lookup_byte_operations, incl_main_tag_err, incl_mem_tag_err, + lookup_u8_0, + lookup_u8_1, lookup_byte_lengths_counts, lookup_byte_operations_counts, incl_main_tag_err_counts, incl_mem_tag_err_counts, + lookup_u8_0_counts, + lookup_u8_1_counts, avm_alu_a_hi_shift, avm_alu_a_lo_shift, avm_alu_b_hi_shift, avm_alu_b_lo_shift, + avm_alu_cmp_rng_ctr_shift, avm_alu_p_sub_a_hi_shift, avm_alu_p_sub_a_lo_shift, avm_alu_p_sub_b_hi_shift, avm_alu_p_sub_b_lo_shift, - avm_alu_rng_chk_remaining_shift, avm_alu_rng_chk_sel_shift, avm_alu_u16_r0_shift, avm_alu_u16_r1_shift, @@ -855,20 +857,19 @@ class AvmFlavor { avm_alu_borrow, avm_alu_cf, avm_alu_clk, + avm_alu_cmp_rng_ctr, avm_alu_cmp_sel, avm_alu_ff_tag, avm_alu_ia, avm_alu_ib, avm_alu_ic, avm_alu_in_tag, - avm_alu_input_ia, - avm_alu_input_ib, - avm_alu_lt_sel, - avm_alu_lte_sel, avm_alu_op_add, avm_alu_op_div, avm_alu_op_eq, avm_alu_op_eq_diff_inv, + avm_alu_op_lt, + avm_alu_op_lte, avm_alu_op_mul, avm_alu_op_not, avm_alu_op_sub, @@ -880,7 +881,7 @@ class AvmFlavor { avm_alu_p_sub_b_lo, avm_alu_res_hi, avm_alu_res_lo, - avm_alu_rng_chk_remaining, + avm_alu_rng_chk_lookup_selector, avm_alu_rng_chk_sel, avm_alu_u128_tag, avm_alu_u16_r0, @@ -928,7 +929,6 @@ class AvmFlavor { avm_main_alu_sel, avm_main_bin_op_id, avm_main_bin_sel, - avm_main_cmp_sel, avm_main_ia, avm_main_ib, avm_main_ic, @@ -994,7 +994,6 @@ class AvmFlavor { avm_mem_w_in_tag, perm_main_alu, perm_main_bin, - perm_main_cmp, perm_main_mem_a, perm_main_mem_b, perm_main_mem_c, @@ -1005,73 +1004,42 @@ class AvmFlavor { lookup_byte_operations, incl_main_tag_err, incl_mem_tag_err, + lookup_u8_0, + lookup_u8_1, lookup_byte_lengths_counts, lookup_byte_operations_counts, incl_main_tag_err_counts, - incl_mem_tag_err_counts }; + incl_mem_tag_err_counts, + lookup_u8_0_counts, + lookup_u8_1_counts }; }; RefVector get_to_be_shifted() { - return { avm_alu_a_hi, - avm_alu_a_lo, - avm_alu_b_hi, - avm_alu_b_lo, - avm_alu_p_sub_a_hi, - avm_alu_p_sub_a_lo, - avm_alu_p_sub_b_hi, - avm_alu_p_sub_b_lo, - avm_alu_rng_chk_remaining, - avm_alu_rng_chk_sel, - avm_alu_u16_r0, - avm_alu_u16_r1, - avm_alu_u16_r2, - avm_alu_u16_r3, - avm_alu_u16_r4, - avm_alu_u16_r5, - avm_alu_u16_r6, - avm_alu_u16_r7, - avm_binary_acc_ia, - avm_binary_acc_ib, - avm_binary_acc_ic, - avm_binary_mem_tag_ctr, - avm_binary_op_id, - avm_main_internal_return_ptr, - avm_main_pc, - avm_mem_addr, - avm_mem_rw, - avm_mem_tag, + return { avm_alu_a_hi, avm_alu_a_lo, avm_alu_b_hi, avm_alu_b_lo, + avm_alu_cmp_rng_ctr, avm_alu_p_sub_a_hi, avm_alu_p_sub_a_lo, avm_alu_p_sub_b_hi, + avm_alu_p_sub_b_lo, avm_alu_rng_chk_sel, avm_alu_u16_r0, avm_alu_u16_r1, + avm_alu_u16_r2, avm_alu_u16_r3, avm_alu_u16_r4, avm_alu_u16_r5, + avm_alu_u16_r6, avm_alu_u16_r7, avm_binary_acc_ia, avm_binary_acc_ib, + avm_binary_acc_ic, avm_binary_mem_tag_ctr, avm_binary_op_id, avm_main_internal_return_ptr, + avm_main_pc, avm_mem_addr, avm_mem_rw, avm_mem_tag, avm_mem_val }; }; RefVector get_shifted() { - return { avm_alu_a_hi_shift, - avm_alu_a_lo_shift, - avm_alu_b_hi_shift, - avm_alu_b_lo_shift, - avm_alu_p_sub_a_hi_shift, - avm_alu_p_sub_a_lo_shift, - avm_alu_p_sub_b_hi_shift, - avm_alu_p_sub_b_lo_shift, - avm_alu_rng_chk_remaining_shift, - avm_alu_rng_chk_sel_shift, - avm_alu_u16_r0_shift, - avm_alu_u16_r1_shift, - avm_alu_u16_r2_shift, - avm_alu_u16_r3_shift, - avm_alu_u16_r4_shift, - avm_alu_u16_r5_shift, - avm_alu_u16_r6_shift, - avm_alu_u16_r7_shift, - avm_binary_acc_ia_shift, - avm_binary_acc_ib_shift, - avm_binary_acc_ic_shift, - avm_binary_mem_tag_ctr_shift, - avm_binary_op_id_shift, - avm_main_internal_return_ptr_shift, - avm_main_pc_shift, - avm_mem_addr_shift, - avm_mem_rw_shift, - avm_mem_tag_shift, + return { avm_alu_a_hi_shift, avm_alu_a_lo_shift, + avm_alu_b_hi_shift, avm_alu_b_lo_shift, + avm_alu_cmp_rng_ctr_shift, avm_alu_p_sub_a_hi_shift, + avm_alu_p_sub_a_lo_shift, avm_alu_p_sub_b_hi_shift, + avm_alu_p_sub_b_lo_shift, avm_alu_rng_chk_sel_shift, + avm_alu_u16_r0_shift, avm_alu_u16_r1_shift, + avm_alu_u16_r2_shift, avm_alu_u16_r3_shift, + avm_alu_u16_r4_shift, avm_alu_u16_r5_shift, + avm_alu_u16_r6_shift, avm_alu_u16_r7_shift, + avm_binary_acc_ia_shift, avm_binary_acc_ib_shift, + avm_binary_acc_ic_shift, avm_binary_mem_tag_ctr_shift, + avm_binary_op_id_shift, avm_main_internal_return_ptr_shift, + avm_main_pc_shift, avm_mem_addr_shift, + avm_mem_rw_shift, avm_mem_tag_shift, avm_mem_val_shift }; }; }; @@ -1085,34 +1053,13 @@ class AvmFlavor { RefVector get_to_be_shifted() { - return { avm_alu_a_hi, - avm_alu_a_lo, - avm_alu_b_hi, - avm_alu_b_lo, - avm_alu_p_sub_a_hi, - avm_alu_p_sub_a_lo, - avm_alu_p_sub_b_hi, - avm_alu_p_sub_b_lo, - avm_alu_rng_chk_remaining, - avm_alu_rng_chk_sel, - avm_alu_u16_r0, - avm_alu_u16_r1, - avm_alu_u16_r2, - avm_alu_u16_r3, - avm_alu_u16_r4, - avm_alu_u16_r5, - avm_alu_u16_r6, - avm_alu_u16_r7, - avm_binary_acc_ia, - avm_binary_acc_ib, - avm_binary_acc_ic, - avm_binary_mem_tag_ctr, - avm_binary_op_id, - avm_main_internal_return_ptr, - avm_main_pc, - avm_mem_addr, - avm_mem_rw, - avm_mem_tag, + return { avm_alu_a_hi, avm_alu_a_lo, avm_alu_b_hi, avm_alu_b_lo, + avm_alu_cmp_rng_ctr, avm_alu_p_sub_a_hi, avm_alu_p_sub_a_lo, avm_alu_p_sub_b_hi, + avm_alu_p_sub_b_lo, avm_alu_rng_chk_sel, avm_alu_u16_r0, avm_alu_u16_r1, + avm_alu_u16_r2, avm_alu_u16_r3, avm_alu_u16_r4, avm_alu_u16_r5, + avm_alu_u16_r6, avm_alu_u16_r7, avm_binary_acc_ia, avm_binary_acc_ib, + avm_binary_acc_ic, avm_binary_mem_tag_ctr, avm_binary_op_id, avm_main_internal_return_ptr, + avm_main_pc, avm_mem_addr, avm_mem_rw, avm_mem_tag, avm_mem_val }; }; @@ -1275,20 +1222,19 @@ class AvmFlavor { Base::avm_alu_borrow = "AVM_ALU_BORROW"; Base::avm_alu_cf = "AVM_ALU_CF"; Base::avm_alu_clk = "AVM_ALU_CLK"; + Base::avm_alu_cmp_rng_ctr = "AVM_ALU_CMP_RNG_CTR"; Base::avm_alu_cmp_sel = "AVM_ALU_CMP_SEL"; Base::avm_alu_ff_tag = "AVM_ALU_FF_TAG"; Base::avm_alu_ia = "AVM_ALU_IA"; Base::avm_alu_ib = "AVM_ALU_IB"; Base::avm_alu_ic = "AVM_ALU_IC"; Base::avm_alu_in_tag = "AVM_ALU_IN_TAG"; - Base::avm_alu_input_ia = "AVM_ALU_INPUT_IA"; - Base::avm_alu_input_ib = "AVM_ALU_INPUT_IB"; - Base::avm_alu_lt_sel = "AVM_ALU_LT_SEL"; - Base::avm_alu_lte_sel = "AVM_ALU_LTE_SEL"; Base::avm_alu_op_add = "AVM_ALU_OP_ADD"; Base::avm_alu_op_div = "AVM_ALU_OP_DIV"; Base::avm_alu_op_eq = "AVM_ALU_OP_EQ"; Base::avm_alu_op_eq_diff_inv = "AVM_ALU_OP_EQ_DIFF_INV"; + Base::avm_alu_op_lt = "AVM_ALU_OP_LT"; + Base::avm_alu_op_lte = "AVM_ALU_OP_LTE"; Base::avm_alu_op_mul = "AVM_ALU_OP_MUL"; Base::avm_alu_op_not = "AVM_ALU_OP_NOT"; Base::avm_alu_op_sub = "AVM_ALU_OP_SUB"; @@ -1300,7 +1246,7 @@ class AvmFlavor { Base::avm_alu_p_sub_b_lo = "AVM_ALU_P_SUB_B_LO"; Base::avm_alu_res_hi = "AVM_ALU_RES_HI"; Base::avm_alu_res_lo = "AVM_ALU_RES_LO"; - Base::avm_alu_rng_chk_remaining = "AVM_ALU_RNG_CHK_REMAINING"; + Base::avm_alu_rng_chk_lookup_selector = "AVM_ALU_RNG_CHK_LOOKUP_SELECTOR"; Base::avm_alu_rng_chk_sel = "AVM_ALU_RNG_CHK_SEL"; Base::avm_alu_u128_tag = "AVM_ALU_U128_TAG"; Base::avm_alu_u16_r0 = "AVM_ALU_U16_R0"; @@ -1348,7 +1294,6 @@ class AvmFlavor { Base::avm_main_alu_sel = "AVM_MAIN_ALU_SEL"; Base::avm_main_bin_op_id = "AVM_MAIN_BIN_OP_ID"; Base::avm_main_bin_sel = "AVM_MAIN_BIN_SEL"; - Base::avm_main_cmp_sel = "AVM_MAIN_CMP_SEL"; Base::avm_main_ia = "AVM_MAIN_IA"; Base::avm_main_ib = "AVM_MAIN_IB"; Base::avm_main_ic = "AVM_MAIN_IC"; @@ -1414,7 +1359,6 @@ class AvmFlavor { Base::avm_mem_w_in_tag = "AVM_MEM_W_IN_TAG"; Base::perm_main_alu = "PERM_MAIN_ALU"; Base::perm_main_bin = "PERM_MAIN_BIN"; - Base::perm_main_cmp = "PERM_MAIN_CMP"; 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"; @@ -1425,10 +1369,14 @@ class AvmFlavor { Base::lookup_byte_operations = "LOOKUP_BYTE_OPERATIONS"; Base::incl_main_tag_err = "INCL_MAIN_TAG_ERR"; Base::incl_mem_tag_err = "INCL_MEM_TAG_ERR"; + Base::lookup_u8_0 = "LOOKUP_U8_0"; + Base::lookup_u8_1 = "LOOKUP_U8_1"; Base::lookup_byte_lengths_counts = "LOOKUP_BYTE_LENGTHS_COUNTS"; Base::lookup_byte_operations_counts = "LOOKUP_BYTE_OPERATIONS_COUNTS"; Base::incl_main_tag_err_counts = "INCL_MAIN_TAG_ERR_COUNTS"; Base::incl_mem_tag_err_counts = "INCL_MEM_TAG_ERR_COUNTS"; + Base::lookup_u8_0_counts = "LOOKUP_U8_0_COUNTS"; + Base::lookup_u8_1_counts = "LOOKUP_U8_1_COUNTS"; }; }; @@ -1456,20 +1404,19 @@ class AvmFlavor { Commitment avm_alu_borrow; Commitment avm_alu_cf; Commitment avm_alu_clk; + Commitment avm_alu_cmp_rng_ctr; Commitment avm_alu_cmp_sel; Commitment avm_alu_ff_tag; Commitment avm_alu_ia; Commitment avm_alu_ib; Commitment avm_alu_ic; Commitment avm_alu_in_tag; - Commitment avm_alu_input_ia; - Commitment avm_alu_input_ib; - Commitment avm_alu_lt_sel; - Commitment avm_alu_lte_sel; Commitment avm_alu_op_add; Commitment avm_alu_op_div; Commitment avm_alu_op_eq; Commitment avm_alu_op_eq_diff_inv; + Commitment avm_alu_op_lt; + Commitment avm_alu_op_lte; Commitment avm_alu_op_mul; Commitment avm_alu_op_not; Commitment avm_alu_op_sub; @@ -1481,7 +1428,7 @@ class AvmFlavor { Commitment avm_alu_p_sub_b_lo; Commitment avm_alu_res_hi; Commitment avm_alu_res_lo; - Commitment avm_alu_rng_chk_remaining; + Commitment avm_alu_rng_chk_lookup_selector; Commitment avm_alu_rng_chk_sel; Commitment avm_alu_u128_tag; Commitment avm_alu_u16_r0; @@ -1529,7 +1476,6 @@ class AvmFlavor { Commitment avm_main_alu_sel; Commitment avm_main_bin_op_id; Commitment avm_main_bin_sel; - Commitment avm_main_cmp_sel; Commitment avm_main_ia; Commitment avm_main_ib; Commitment avm_main_ic; @@ -1611,7 +1557,6 @@ class AvmFlavor { >>>>>>> a43e384f0 (feat: range_chk for cmp) Commitment perm_main_alu; Commitment perm_main_bin; - Commitment perm_main_cmp; Commitment perm_main_mem_a; Commitment perm_main_mem_b; Commitment perm_main_mem_c; @@ -1623,12 +1568,19 @@ class AvmFlavor { Commitment lookup_byte_operations; Commitment incl_main_tag_err; Commitment incl_mem_tag_err; +<<<<<<< HEAD // Lookup counts +======= + Commitment lookup_u8_0; + Commitment lookup_u8_1; +>>>>>>> 8d38899c9 (feat: some wip) Commitment lookup_byte_lengths_counts; Commitment lookup_byte_operations_counts; Commitment incl_main_tag_err_counts; Commitment incl_mem_tag_err_counts; + Commitment lookup_u8_0_counts; + Commitment lookup_u8_1_counts; std::vector> sumcheck_univariates; std::array sumcheck_evaluations; @@ -1656,20 +1608,19 @@ class AvmFlavor { avm_alu_borrow = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_cf = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_clk = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_cmp_rng_ctr = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_cmp_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_ff_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_ia = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_ib = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_ic = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_in_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_input_ia = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_input_ib = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_lt_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_lte_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_op_add = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_op_div = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_op_eq = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_op_eq_diff_inv = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_op_lt = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_op_lte = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_op_mul = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_op_not = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_op_sub = deserialize_from_buffer(Transcript::proof_data, num_frs_read); @@ -1681,7 +1632,7 @@ class AvmFlavor { avm_alu_p_sub_b_lo = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_res_hi = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_res_lo = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_alu_rng_chk_remaining = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_alu_rng_chk_lookup_selector = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_rng_chk_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_u128_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_alu_u16_r0 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); @@ -1730,7 +1681,6 @@ class AvmFlavor { avm_main_alu_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_bin_op_id = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_bin_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_main_cmp_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); 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); @@ -1796,7 +1746,6 @@ class AvmFlavor { avm_mem_w_in_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); perm_main_alu = deserialize_from_buffer(Transcript::proof_data, num_frs_read); perm_main_bin = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - perm_main_cmp = deserialize_from_buffer(Transcript::proof_data, num_frs_read); 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); @@ -1807,10 +1756,14 @@ class AvmFlavor { 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); incl_mem_tag_err = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u8_0 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u8_1 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); lookup_byte_lengths_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); lookup_byte_operations_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); incl_main_tag_err_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); incl_mem_tag_err_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u8_0_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u8_1_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); for (size_t i = 0; i < log_n; ++i) { sumcheck_univariates.emplace_back( @@ -1842,20 +1795,19 @@ class AvmFlavor { serialize_to_buffer(avm_alu_borrow, Transcript::proof_data); serialize_to_buffer(avm_alu_cf, Transcript::proof_data); serialize_to_buffer(avm_alu_clk, Transcript::proof_data); + serialize_to_buffer(avm_alu_cmp_rng_ctr, Transcript::proof_data); serialize_to_buffer(avm_alu_cmp_sel, Transcript::proof_data); serialize_to_buffer(avm_alu_ff_tag, Transcript::proof_data); serialize_to_buffer(avm_alu_ia, Transcript::proof_data); serialize_to_buffer(avm_alu_ib, Transcript::proof_data); serialize_to_buffer(avm_alu_ic, Transcript::proof_data); serialize_to_buffer(avm_alu_in_tag, Transcript::proof_data); - serialize_to_buffer(avm_alu_input_ia, Transcript::proof_data); - serialize_to_buffer(avm_alu_input_ib, Transcript::proof_data); - serialize_to_buffer(avm_alu_lt_sel, Transcript::proof_data); - serialize_to_buffer(avm_alu_lte_sel, Transcript::proof_data); serialize_to_buffer(avm_alu_op_add, Transcript::proof_data); serialize_to_buffer(avm_alu_op_div, Transcript::proof_data); serialize_to_buffer(avm_alu_op_eq, Transcript::proof_data); serialize_to_buffer(avm_alu_op_eq_diff_inv, Transcript::proof_data); + serialize_to_buffer(avm_alu_op_lt, Transcript::proof_data); + serialize_to_buffer(avm_alu_op_lte, Transcript::proof_data); serialize_to_buffer(avm_alu_op_mul, Transcript::proof_data); serialize_to_buffer(avm_alu_op_not, Transcript::proof_data); serialize_to_buffer(avm_alu_op_sub, Transcript::proof_data); @@ -1867,7 +1819,7 @@ class AvmFlavor { serialize_to_buffer(avm_alu_p_sub_b_lo, Transcript::proof_data); serialize_to_buffer(avm_alu_res_hi, Transcript::proof_data); serialize_to_buffer(avm_alu_res_lo, Transcript::proof_data); - serialize_to_buffer(avm_alu_rng_chk_remaining, Transcript::proof_data); + serialize_to_buffer(avm_alu_rng_chk_lookup_selector, Transcript::proof_data); serialize_to_buffer(avm_alu_rng_chk_sel, Transcript::proof_data); serialize_to_buffer(avm_alu_u128_tag, Transcript::proof_data); serialize_to_buffer(avm_alu_u16_r0, Transcript::proof_data); @@ -1915,7 +1867,6 @@ class AvmFlavor { serialize_to_buffer(avm_main_alu_sel, Transcript::proof_data); serialize_to_buffer(avm_main_bin_op_id, Transcript::proof_data); serialize_to_buffer(avm_main_bin_sel, Transcript::proof_data); - serialize_to_buffer(avm_main_cmp_sel, Transcript::proof_data); 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); @@ -1981,7 +1932,6 @@ class AvmFlavor { serialize_to_buffer(avm_mem_w_in_tag, Transcript::proof_data); serialize_to_buffer(perm_main_alu, Transcript::proof_data); serialize_to_buffer(perm_main_bin, Transcript::proof_data); - serialize_to_buffer(perm_main_cmp, Transcript::proof_data); 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); @@ -1992,10 +1942,14 @@ class AvmFlavor { serialize_to_buffer(lookup_byte_operations, Transcript::proof_data); serialize_to_buffer(incl_main_tag_err, Transcript::proof_data); serialize_to_buffer(incl_mem_tag_err, Transcript::proof_data); + serialize_to_buffer(lookup_u8_0, Transcript::proof_data); + serialize_to_buffer(lookup_u8_1, Transcript::proof_data); serialize_to_buffer(lookup_byte_lengths_counts, Transcript::proof_data); serialize_to_buffer(lookup_byte_operations_counts, Transcript::proof_data); serialize_to_buffer(incl_main_tag_err_counts, Transcript::proof_data); serialize_to_buffer(incl_mem_tag_err_counts, Transcript::proof_data); + serialize_to_buffer(lookup_u8_0_counts, Transcript::proof_data); + serialize_to_buffer(lookup_u8_1_counts, Transcript::proof_data); for (size_t i = 0; i < log_n; ++i) { serialize_to_buffer(sumcheck_univariates[i], 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 c89b58efd8d0..cb0927cfb55b 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp @@ -60,6 +60,8 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) commitments.avm_alu_borrow = transcript->template receive_from_prover(commitment_labels.avm_alu_borrow); commitments.avm_alu_cf = transcript->template receive_from_prover(commitment_labels.avm_alu_cf); commitments.avm_alu_clk = transcript->template receive_from_prover(commitment_labels.avm_alu_clk); + commitments.avm_alu_cmp_rng_ctr = + transcript->template receive_from_prover(commitment_labels.avm_alu_cmp_rng_ctr); commitments.avm_alu_cmp_sel = transcript->template receive_from_prover(commitment_labels.avm_alu_cmp_sel); commitments.avm_alu_ff_tag = transcript->template receive_from_prover(commitment_labels.avm_alu_ff_tag); @@ -67,18 +69,13 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) commitments.avm_alu_ib = transcript->template receive_from_prover(commitment_labels.avm_alu_ib); commitments.avm_alu_ic = transcript->template receive_from_prover(commitment_labels.avm_alu_ic); commitments.avm_alu_in_tag = transcript->template receive_from_prover(commitment_labels.avm_alu_in_tag); - commitments.avm_alu_input_ia = - transcript->template receive_from_prover(commitment_labels.avm_alu_input_ia); - commitments.avm_alu_input_ib = - transcript->template receive_from_prover(commitment_labels.avm_alu_input_ib); - commitments.avm_alu_lt_sel = transcript->template receive_from_prover(commitment_labels.avm_alu_lt_sel); - commitments.avm_alu_lte_sel = - transcript->template receive_from_prover(commitment_labels.avm_alu_lte_sel); commitments.avm_alu_op_add = transcript->template receive_from_prover(commitment_labels.avm_alu_op_add); commitments.avm_alu_op_div = transcript->template receive_from_prover(commitment_labels.avm_alu_op_div); commitments.avm_alu_op_eq = transcript->template receive_from_prover(commitment_labels.avm_alu_op_eq); commitments.avm_alu_op_eq_diff_inv = transcript->template receive_from_prover(commitment_labels.avm_alu_op_eq_diff_inv); + commitments.avm_alu_op_lt = transcript->template receive_from_prover(commitment_labels.avm_alu_op_lt); + commitments.avm_alu_op_lte = transcript->template receive_from_prover(commitment_labels.avm_alu_op_lte); commitments.avm_alu_op_mul = transcript->template receive_from_prover(commitment_labels.avm_alu_op_mul); commitments.avm_alu_op_not = transcript->template receive_from_prover(commitment_labels.avm_alu_op_not); commitments.avm_alu_op_sub = transcript->template receive_from_prover(commitment_labels.avm_alu_op_sub); @@ -96,8 +93,8 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) transcript->template receive_from_prover(commitment_labels.avm_alu_p_sub_b_lo); commitments.avm_alu_res_hi = transcript->template receive_from_prover(commitment_labels.avm_alu_res_hi); commitments.avm_alu_res_lo = transcript->template receive_from_prover(commitment_labels.avm_alu_res_lo); - commitments.avm_alu_rng_chk_remaining = - transcript->template receive_from_prover(commitment_labels.avm_alu_rng_chk_remaining); + commitments.avm_alu_rng_chk_lookup_selector = + transcript->template receive_from_prover(commitment_labels.avm_alu_rng_chk_lookup_selector); commitments.avm_alu_rng_chk_sel = transcript->template receive_from_prover(commitment_labels.avm_alu_rng_chk_sel); commitments.avm_alu_u128_tag = @@ -177,8 +174,6 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) transcript->template receive_from_prover(commitment_labels.avm_main_bin_op_id); commitments.avm_main_bin_sel = transcript->template receive_from_prover(commitment_labels.avm_main_bin_sel); - commitments.avm_main_cmp_sel = - transcript->template receive_from_prover(commitment_labels.avm_main_cmp_sel); 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); @@ -318,7 +313,6 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) >>>>>>> a43e384f0 (feat: range_chk for cmp) commitments.perm_main_alu = transcript->template receive_from_prover(commitment_labels.perm_main_alu); commitments.perm_main_bin = transcript->template receive_from_prover(commitment_labels.perm_main_bin); - commitments.perm_main_cmp = transcript->template receive_from_prover(commitment_labels.perm_main_cmp); commitments.perm_main_mem_a = transcript->template receive_from_prover(commitment_labels.perm_main_mem_a); commitments.perm_main_mem_b = @@ -341,6 +335,23 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) transcript->template receive_from_prover(commitment_labels.incl_main_tag_err); commitments.incl_mem_tag_err = transcript->template receive_from_prover(commitment_labels.incl_mem_tag_err); +<<<<<<< HEAD +======= + commitments.lookup_u8_0 = transcript->template receive_from_prover(commitment_labels.lookup_u8_0); + commitments.lookup_u8_1 = transcript->template receive_from_prover(commitment_labels.lookup_u8_1); + commitments.lookup_byte_lengths_counts = + transcript->template receive_from_prover(commitment_labels.lookup_byte_lengths_counts); + commitments.lookup_byte_operations_counts = + transcript->template receive_from_prover(commitment_labels.lookup_byte_operations_counts); + commitments.incl_main_tag_err_counts = + transcript->template receive_from_prover(commitment_labels.incl_main_tag_err_counts); + commitments.incl_mem_tag_err_counts = + transcript->template receive_from_prover(commitment_labels.incl_mem_tag_err_counts); + commitments.lookup_u8_0_counts = + transcript->template receive_from_prover(commitment_labels.lookup_u8_0_counts); + commitments.lookup_u8_1_counts = + transcript->template receive_from_prover(commitment_labels.lookup_u8_1_counts); +>>>>>>> 8d38899c9 (feat: some wip) // Execute Sumcheck Verifier const size_t log_circuit_size = numeric::get_msb(circuit_size); diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_comparison.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_comparison.test.cpp new file mode 100644 index 000000000000..9a7c397c53e4 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_comparison.test.cpp @@ -0,0 +1,229 @@ +#include "avm_common.test.hpp" +#include "barretenberg/common/zip_view.hpp" +#include "barretenberg/numeric/uint128/uint128.hpp" +#include "barretenberg/vm/avm_trace/avm_common.hpp" +#include "barretenberg/vm/tests/helpers.test.hpp" +#include "gtest/gtest.h" +#include +#include +#include +#include +#include +#include +#include + +namespace tests_avm { +using namespace bb::avm_trace; +namespace { + +void common_validate_cmp(Row row, + Row alu_row, + FF const& a, + FF const& b, + FF const& c, + FF const& addr_a, + FF const& addr_b, + FF const& addr_c, + avm_trace::AvmMemoryTag const tag) +{ + + // Use the row in the main trace to find the same operation in the alu trace. + // Check that the correct result is stored at the expected memory location. + EXPECT_EQ(row.avm_main_ic, c); + EXPECT_EQ(row.avm_main_mem_idx_c, addr_c); + EXPECT_EQ(row.avm_main_mem_op_c, FF(1)); + EXPECT_EQ(row.avm_main_rwc, FF(1)); + + // Check that ia register is correctly set with memory load operations. + EXPECT_EQ(row.avm_main_ia, a); + EXPECT_EQ(row.avm_main_mem_idx_a, addr_a); + EXPECT_EQ(row.avm_main_mem_op_a, FF(1)); + EXPECT_EQ(row.avm_main_rwa, FF(0)); + + // Check that ib register is correctly set with memory load operations. + EXPECT_EQ(row.avm_main_ib, b); + EXPECT_EQ(row.avm_main_mem_idx_b, addr_b); + EXPECT_EQ(row.avm_main_mem_op_b, FF(1)); + EXPECT_EQ(row.avm_main_rwb, FF(0)); + + // Check the instruction tags + EXPECT_EQ(row.avm_main_r_in_tag, FF(static_cast(tag))); + EXPECT_EQ(row.avm_main_w_in_tag, FF(1)); + + // Check that intermediate registers are correctly copied in Alu trace + EXPECT_EQ(alu_row.avm_alu_ia, a); + EXPECT_EQ(alu_row.avm_alu_ib, b); + EXPECT_EQ(alu_row.avm_alu_ic, c); +} +} // namespace +using ThreeOpParamRow = std::array; +std::vector positive_op_lt_test_values = { { { FF(1), FF(1), FF(0) }, + { FF(5323), FF(321), FF(0) }, + { FF(13793), FF(10590617LLU), FF(1) }, + { FF(0x7bff744e3cdf79LLU), FF(0x14ccccccccb6LLU), FF(0) }, + { FF(uint256_t{ 0xb900000000000001 }), + FF(uint256_t{ 0x1006021301080000 } << 64) + + uint256_t{ 0x000000000000001080876844827 }, + 1 } } }; +std::vector positive_op_lte_test_values = { + { { FF(1), FF(1), FF(1) }, + { FF(5323), FF(321), FF(0) }, + { FF(13793), FF(10590617LLU), FF(1) }, + { FF(0x7bff744e3cdf79LLU), FF(0x14ccccccccb6LLU), FF(0) }, + { FF(uint256_t{ 0x1006021301080000 } << 64) + uint256_t{ 0x000000000000001080876844827 }, + FF(uint256_t{ 0x1006021301080000 } << 64) + uint256_t{ 0x000000000000001080876844827 }, + FF(1) } } +}; +class AvmCmpTests : public ::testing::Test { + public: + AvmTraceBuilder trace_builder; + + protected: + // 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"); }; +}; +class AvmCmpTestsLT : public AvmCmpTests, public testing::WithParamInterface {}; +class AvmCmpTestsLTE : public AvmCmpTests, public testing::WithParamInterface {}; + +/****************************************************************************** + * + * POSITIVE TESTS + * + ******************************************************************************/ +TEST_P(AvmCmpTestsLT, ParamTest) +{ + const auto [a, b, c] = GetParam(); + trace_builder.calldata_copy(0, 0, 3, 0, std::vector{ a, b, c }); + trace_builder.op_lt(0, 0, 1, 2, AvmMemoryTag::FF); // [1,254,0,0,....] + trace_builder.return_op(0, 0, 0); + auto trace = trace_builder.finalize(); + // Validate the trace + + // Get the row in the avm with the LT selector set + auto row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_lt == FF(1); }); + + // Use the row in the main trace to find the same operation in the alu trace. + FF clk = row->avm_main_clk; + auto alu_row = std::ranges::find_if( + trace.begin(), trace.end(), [clk](Row r) { return r.avm_alu_clk == clk && r.avm_alu_op_lt; }); + // Check that both rows were found + EXPECT_TRUE(row != trace.end()); + EXPECT_TRUE(alu_row != trace.end()); + common_validate_cmp(*row, *alu_row, a, b, c, FF(0), FF(1), FF(2), AvmMemoryTag::FF); + + validate_trace_proof(std::move(trace)); +} +INSTANTIATE_TEST_SUITE_P(AvmCmpTests, AvmCmpTestsLT, testing::ValuesIn(positive_op_lt_test_values)); + +TEST_P(AvmCmpTestsLTE, ParamTest) +{ + const auto [a, b, c] = GetParam(); + trace_builder.calldata_copy(0, 0, 3, 0, std::vector{ a, b, c }); + trace_builder.op_lte(0, 0, 1, 2, AvmMemoryTag::FF); // [1,254,0,0,....] + trace_builder.return_op(0, 0, 0); + auto trace = trace_builder.finalize(); + auto row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_lte == FF(1); }); + + // Use the row in the main trace to find the same operation in the alu trace. + FF clk = row->avm_main_clk; + auto alu_row = std::ranges::find_if( + trace.begin(), trace.end(), [clk](Row r) { return r.avm_alu_clk == clk && r.avm_alu_op_lte; }); + // Check that both rows were found + EXPECT_TRUE(row != trace.end()); + EXPECT_TRUE(alu_row != trace.end()); + common_validate_cmp(*row, *alu_row, a, b, c, FF(0), FF(1), FF(2), AvmMemoryTag::FF); + validate_trace_proof(std::move(trace)); +} +INSTANTIATE_TEST_SUITE_P(AvmCmpTests, AvmCmpTestsLTE, testing::ValuesIn(positive_op_lte_test_values)); + +/****************************************************************************** + * + * NEGATIVE TESTS + * + ******************************************************************************/ +enum CMP_FAILURES { + IncorrectInputDecomposition, + SubLoCheckFailed, + // SubHiCheckFailed, + ResLoCheckFailed, + ResHiCheckFailed, + CounterRelationFailed, + CounterNonZeroCheckFailed, + ShiftRelationFailed, +}; +std::vector> cmp_failures = { + { "INPUT_DECOMP_1", CMP_FAILURES::IncorrectInputDecomposition }, + { "SUB_LO_1", CMP_FAILURES::SubLoCheckFailed }, + // { "SUB_HI_1", CMP_FAILURES::SubHiCheckFailed }, + { "RES_LO", CMP_FAILURES::ResLoCheckFailed }, + { "RES_HI", CMP_FAILURES::ResHiCheckFailed }, + { "CMP_CTR_REL_2", CMP_FAILURES::CounterRelationFailed }, + { "CTR_NON_ZERO_REL", CMP_FAILURES::CounterNonZeroCheckFailed }, + { "SHIFT_RELS", CMP_FAILURES::ShiftRelationFailed }, +}; +std::vector neg_test_lt = { { 12023, 439321, 1 } }; + +using EXPECTED_ERRORS = std::tuple; +std::vector gen_mutated_trace_cmp(std::vector trace, + std::function&& select_row, + CMP_FAILURES fail_mode) +{ + auto main_trace_row = std::ranges::find_if(trace.begin(), trace.end(), select_row); + auto main_clk = main_trace_row->avm_main_clk; + // The corresponding row in the alu trace as well as the row where start = 1 + auto alu_row = + std::ranges::find_if(trace.begin(), trace.end(), [main_clk](Row r) { return r.avm_alu_clk == main_clk; }); + // The corresponding row in the alu trace where the computation ends. + auto range_check_row = + std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_alu_cmp_rng_ctr > FF(0); }); + switch (fail_mode) { + case IncorrectInputDecomposition: + alu_row->avm_alu_a_lo = FF(0); + break; + case SubLoCheckFailed: + alu_row->avm_alu_p_a_borrow = FF::one() - alu_row->avm_alu_p_a_borrow; + break; + // case SubHiCheckFailed: + // alu_row->avm_alu_p_b_borrow = FF::one() - alu_row->avm_alu_p_b_borrow; + // break; + case ResLoCheckFailed: + alu_row->avm_alu_res_lo = FF(0); + break; + case ResHiCheckFailed: + alu_row->avm_alu_res_hi = FF(1); + break; + case CounterRelationFailed: + range_check_row->avm_alu_cmp_rng_ctr = FF(0); + break; + case CounterNonZeroCheckFailed: + range_check_row->avm_alu_rng_chk_sel = FF(0); + break; + case ShiftRelationFailed: + range_check_row->avm_alu_a_lo = range_check_row->avm_alu_res_lo; + range_check_row->avm_alu_a_hi = range_check_row->avm_alu_res_hi; + break; + } + return trace; +} +class AvmCmpNegativeTestsLT : public AvmCmpTests, + public testing::WithParamInterface> {}; + +TEST_P(AvmCmpNegativeTestsLT, ParamTest) +{ + const auto [failure, params] = GetParam(); + const auto [failure_string, failure_mode] = failure; + const auto [a, b, output] = params; + auto trace_builder = avm_trace::AvmTraceBuilder(); + trace_builder.calldata_copy(0, 0, 3, 0, std::vector{ a, b, output }); + trace_builder.op_lt(0, 0, 1, 2, AvmMemoryTag::FF); // [1,254,0,0,....] + trace_builder.return_op(0, 0, 0); + auto trace = trace_builder.finalize(); + std::function&& select_row = [](Row r) { return r.avm_main_sel_op_lt == FF(1); }; + trace = gen_mutated_trace_cmp(trace, std::move(select_row), failure_mode); + EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), failure_string); +} + +INSTANTIATE_TEST_SUITE_P(AvmCmpNegativeTests, + AvmCmpNegativeTestsLT, + testing::Combine(testing::ValuesIn(cmp_failures), testing::ValuesIn(neg_test_lt))); +} // namespace tests_avm From fa9f9a50c3466e45e0981c937b4f14093b8fa559 Mon Sep 17 00:00:00 2001 From: IlyasRidhuan Date: Tue, 9 Apr 2024 17:23:11 +0000 Subject: [PATCH 10/18] fix: 16_bit range checks --- barretenberg/cpp/pil/avm/avm_main.pil | 47 +++ .../relations/generated/avm/declare_views.hpp | 30 ++ .../relations/generated/avm/lookup_u16_0.hpp | 166 ++++++++++ .../relations/generated/avm/lookup_u16_1.hpp | 166 ++++++++++ .../relations/generated/avm/lookup_u16_10.hpp | 166 ++++++++++ .../relations/generated/avm/lookup_u16_11.hpp | 166 ++++++++++ .../relations/generated/avm/lookup_u16_12.hpp | 166 ++++++++++ .../relations/generated/avm/lookup_u16_13.hpp | 166 ++++++++++ .../relations/generated/avm/lookup_u16_14.hpp | 166 ++++++++++ .../relations/generated/avm/lookup_u16_2.hpp | 166 ++++++++++ .../relations/generated/avm/lookup_u16_3.hpp | 166 ++++++++++ .../relations/generated/avm/lookup_u16_4.hpp | 166 ++++++++++ .../relations/generated/avm/lookup_u16_5.hpp | 166 ++++++++++ .../relations/generated/avm/lookup_u16_6.hpp | 166 ++++++++++ .../relations/generated/avm/lookup_u16_7.hpp | 166 ++++++++++ .../relations/generated/avm/lookup_u16_8.hpp | 166 ++++++++++ .../relations/generated/avm/lookup_u16_9.hpp | 166 ++++++++++ .../barretenberg/vm/avm_trace/avm_trace.cpp | 23 +- .../vm/generated/avm_circuit_builder.hpp | 127 +++++++- .../barretenberg/vm/generated/avm_flavor.hpp | 283 +++++++++++++++++- .../vm/generated/avm_verifier.cpp | 48 +++ 21 files changed, 3038 insertions(+), 10 deletions(-) create mode 100644 barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_0.hpp create mode 100644 barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_1.hpp create mode 100644 barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_10.hpp create mode 100644 barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_11.hpp create mode 100644 barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_12.hpp create mode 100644 barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_13.hpp create mode 100644 barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_14.hpp create mode 100644 barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_2.hpp create mode 100644 barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_3.hpp create mode 100644 barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_4.hpp create mode 100644 barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_5.hpp create mode 100644 barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_6.hpp create mode 100644 barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_7.hpp create mode 100644 barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_8.hpp create mode 100644 barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_9.hpp diff --git a/barretenberg/cpp/pil/avm/avm_main.pil b/barretenberg/cpp/pil/avm/avm_main.pil index 71930a395dbb..f673bc709b2b 100644 --- a/barretenberg/cpp/pil/avm/avm_main.pil +++ b/barretenberg/cpp/pil/avm/avm_main.pil @@ -311,8 +311,55 @@ 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}; + //====== Inter-table Constraints (Range Checks) ============================================ #[LOOKUP_U8_0] avm_alu.rng_chk_lookup_selector { avm_alu.u8_r0 } in sel_rng_8 { clk }; #[LOOKUP_U8_1] avm_alu.rng_chk_lookup_selector { avm_alu.u8_r1 } in sel_rng_8 { clk }; + + #[LOOKUP_U16_0] + avm_alu.rng_chk_lookup_selector {avm_alu.u16_r0 } in sel_rng_16 { clk }; + + #[LOOKUP_U16_1] + avm_alu.rng_chk_lookup_selector {avm_alu.u16_r1 } in sel_rng_16 { clk }; + + #[LOOKUP_U16_2] + avm_alu.rng_chk_lookup_selector {avm_alu.u16_r2 } in sel_rng_16 { clk }; + + #[LOOKUP_U16_3] + avm_alu.rng_chk_lookup_selector {avm_alu.u16_r3 } in sel_rng_16 { clk }; + + #[LOOKUP_U16_4] + avm_alu.rng_chk_lookup_selector {avm_alu.u16_r4 } in sel_rng_16 { clk }; + + #[LOOKUP_U16_5] + avm_alu.rng_chk_lookup_selector {avm_alu.u16_r5 } in sel_rng_16 { clk }; + + #[LOOKUP_U16_6] + avm_alu.rng_chk_lookup_selector {avm_alu.u16_r6 } in sel_rng_16 { clk }; + + #[LOOKUP_U16_7] + avm_alu.rng_chk_lookup_selector {avm_alu.u16_r7 } in sel_rng_16 { clk }; + + #[LOOKUP_U16_8] + avm_alu.rng_chk_lookup_selector {avm_alu.u16_r8 } in sel_rng_16 { clk }; + + #[LOOKUP_U16_9] + avm_alu.rng_chk_lookup_selector {avm_alu.u16_r9 } in sel_rng_16 { clk }; + + #[LOOKUP_U16_10] + avm_alu.rng_chk_lookup_selector {avm_alu.u16_r10 } in sel_rng_16 { clk }; + + #[LOOKUP_U16_11] + avm_alu.rng_chk_lookup_selector {avm_alu.u16_r11 } in sel_rng_16 { clk }; + + #[LOOKUP_U16_12] + avm_alu.rng_chk_lookup_selector {avm_alu.u16_r12 } in sel_rng_16 { clk }; + + #[LOOKUP_U16_13] + avm_alu.rng_chk_lookup_selector {avm_alu.u16_r13 } in sel_rng_16 { clk }; + + #[LOOKUP_U16_14] + avm_alu.rng_chk_lookup_selector {avm_alu.u16_r14 } in sel_rng_16 { clk }; + 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 ed16f7a8f00d..8bebe5f792dd 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/declare_views.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/declare_views.hpp @@ -161,12 +161,42 @@ [[maybe_unused]] auto incl_mem_tag_err = View(new_term.incl_mem_tag_err); \ [[maybe_unused]] auto lookup_u8_0 = View(new_term.lookup_u8_0); \ [[maybe_unused]] auto lookup_u8_1 = View(new_term.lookup_u8_1); \ + [[maybe_unused]] auto lookup_u16_0 = View(new_term.lookup_u16_0); \ + [[maybe_unused]] auto lookup_u16_1 = View(new_term.lookup_u16_1); \ + [[maybe_unused]] auto lookup_u16_2 = View(new_term.lookup_u16_2); \ + [[maybe_unused]] auto lookup_u16_3 = View(new_term.lookup_u16_3); \ + [[maybe_unused]] auto lookup_u16_4 = View(new_term.lookup_u16_4); \ + [[maybe_unused]] auto lookup_u16_5 = View(new_term.lookup_u16_5); \ + [[maybe_unused]] auto lookup_u16_6 = View(new_term.lookup_u16_6); \ + [[maybe_unused]] auto lookup_u16_7 = View(new_term.lookup_u16_7); \ + [[maybe_unused]] auto lookup_u16_8 = View(new_term.lookup_u16_8); \ + [[maybe_unused]] auto lookup_u16_9 = View(new_term.lookup_u16_9); \ + [[maybe_unused]] auto lookup_u16_10 = View(new_term.lookup_u16_10); \ + [[maybe_unused]] auto lookup_u16_11 = View(new_term.lookup_u16_11); \ + [[maybe_unused]] auto lookup_u16_12 = View(new_term.lookup_u16_12); \ + [[maybe_unused]] auto lookup_u16_13 = View(new_term.lookup_u16_13); \ + [[maybe_unused]] auto lookup_u16_14 = View(new_term.lookup_u16_14); \ [[maybe_unused]] auto lookup_byte_lengths_counts = View(new_term.lookup_byte_lengths_counts); \ [[maybe_unused]] auto lookup_byte_operations_counts = View(new_term.lookup_byte_operations_counts); \ [[maybe_unused]] auto incl_main_tag_err_counts = View(new_term.incl_main_tag_err_counts); \ [[maybe_unused]] auto incl_mem_tag_err_counts = View(new_term.incl_mem_tag_err_counts); \ [[maybe_unused]] auto lookup_u8_0_counts = View(new_term.lookup_u8_0_counts); \ [[maybe_unused]] auto lookup_u8_1_counts = View(new_term.lookup_u8_1_counts); \ + [[maybe_unused]] auto lookup_u16_0_counts = View(new_term.lookup_u16_0_counts); \ + [[maybe_unused]] auto lookup_u16_1_counts = View(new_term.lookup_u16_1_counts); \ + [[maybe_unused]] auto lookup_u16_2_counts = View(new_term.lookup_u16_2_counts); \ + [[maybe_unused]] auto lookup_u16_3_counts = View(new_term.lookup_u16_3_counts); \ + [[maybe_unused]] auto lookup_u16_4_counts = View(new_term.lookup_u16_4_counts); \ + [[maybe_unused]] auto lookup_u16_5_counts = View(new_term.lookup_u16_5_counts); \ + [[maybe_unused]] auto lookup_u16_6_counts = View(new_term.lookup_u16_6_counts); \ + [[maybe_unused]] auto lookup_u16_7_counts = View(new_term.lookup_u16_7_counts); \ + [[maybe_unused]] auto lookup_u16_8_counts = View(new_term.lookup_u16_8_counts); \ + [[maybe_unused]] auto lookup_u16_9_counts = View(new_term.lookup_u16_9_counts); \ + [[maybe_unused]] auto lookup_u16_10_counts = View(new_term.lookup_u16_10_counts); \ + [[maybe_unused]] auto lookup_u16_11_counts = View(new_term.lookup_u16_11_counts); \ + [[maybe_unused]] auto lookup_u16_12_counts = View(new_term.lookup_u16_12_counts); \ + [[maybe_unused]] auto lookup_u16_13_counts = View(new_term.lookup_u16_13_counts); \ + [[maybe_unused]] auto lookup_u16_14_counts = View(new_term.lookup_u16_14_counts); \ [[maybe_unused]] auto avm_alu_a_hi_shift = View(new_term.avm_alu_a_hi_shift); \ [[maybe_unused]] auto avm_alu_a_lo_shift = View(new_term.avm_alu_a_lo_shift); \ [[maybe_unused]] auto avm_alu_b_hi_shift = View(new_term.avm_alu_b_hi_shift); \ diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_0.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_0.hpp new file mode 100644 index 000000000000..6553a7db9a59 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_0.hpp @@ -0,0 +1,166 @@ + + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_0_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); + } + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); + const auto is_table_entry = View(in.avm_main_sel_rng_16); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_0, + in.lookup_u16_0_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r0, + in.avm_main_clk); + } + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_0, + in.lookup_u16_0_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r0, + in.avm_main_clk); + } +}; + +template using lookup_u16_0_relation = GenericLookupRelation; +template using lookup_u16_0 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_1.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_1.hpp new file mode 100644 index 000000000000..fa1c36018145 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_1.hpp @@ -0,0 +1,166 @@ + + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_1_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); + } + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); + const auto is_table_entry = View(in.avm_main_sel_rng_16); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_1, + in.lookup_u16_1_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r1, + in.avm_main_clk); + } + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_1, + in.lookup_u16_1_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r1, + in.avm_main_clk); + } +}; + +template using lookup_u16_1_relation = GenericLookupRelation; +template using lookup_u16_1 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_10.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_10.hpp new file mode 100644 index 000000000000..987e146a7184 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_10.hpp @@ -0,0 +1,166 @@ + + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_10_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); + } + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); + const auto is_table_entry = View(in.avm_main_sel_rng_16); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_10, + in.lookup_u16_10_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r10, + in.avm_main_clk); + } + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_10, + in.lookup_u16_10_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r10, + in.avm_main_clk); + } +}; + +template using lookup_u16_10_relation = GenericLookupRelation; +template using lookup_u16_10 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_11.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_11.hpp new file mode 100644 index 000000000000..2db300ecf0e5 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_11.hpp @@ -0,0 +1,166 @@ + + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_11_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); + } + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); + const auto is_table_entry = View(in.avm_main_sel_rng_16); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_11, + in.lookup_u16_11_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r11, + in.avm_main_clk); + } + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_11, + in.lookup_u16_11_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r11, + in.avm_main_clk); + } +}; + +template using lookup_u16_11_relation = GenericLookupRelation; +template using lookup_u16_11 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_12.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_12.hpp new file mode 100644 index 000000000000..fd1ea74b50e7 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_12.hpp @@ -0,0 +1,166 @@ + + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_12_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); + } + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); + const auto is_table_entry = View(in.avm_main_sel_rng_16); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_12, + in.lookup_u16_12_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r12, + in.avm_main_clk); + } + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_12, + in.lookup_u16_12_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r12, + in.avm_main_clk); + } +}; + +template using lookup_u16_12_relation = GenericLookupRelation; +template using lookup_u16_12 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_13.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_13.hpp new file mode 100644 index 000000000000..001e22ab832b --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_13.hpp @@ -0,0 +1,166 @@ + + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_13_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); + } + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); + const auto is_table_entry = View(in.avm_main_sel_rng_16); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_13, + in.lookup_u16_13_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r13, + in.avm_main_clk); + } + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_13, + in.lookup_u16_13_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r13, + in.avm_main_clk); + } +}; + +template using lookup_u16_13_relation = GenericLookupRelation; +template using lookup_u16_13 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_14.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_14.hpp new file mode 100644 index 000000000000..b1cfa3029642 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_14.hpp @@ -0,0 +1,166 @@ + + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_14_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); + } + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); + const auto is_table_entry = View(in.avm_main_sel_rng_16); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_14, + in.lookup_u16_14_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r14, + in.avm_main_clk); + } + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_14, + in.lookup_u16_14_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r14, + in.avm_main_clk); + } +}; + +template using lookup_u16_14_relation = GenericLookupRelation; +template using lookup_u16_14 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_2.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_2.hpp new file mode 100644 index 000000000000..f8b6bda1290d --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_2.hpp @@ -0,0 +1,166 @@ + + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_2_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); + } + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); + const auto is_table_entry = View(in.avm_main_sel_rng_16); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_2, + in.lookup_u16_2_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r2, + in.avm_main_clk); + } + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_2, + in.lookup_u16_2_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r2, + in.avm_main_clk); + } +}; + +template using lookup_u16_2_relation = GenericLookupRelation; +template using lookup_u16_2 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_3.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_3.hpp new file mode 100644 index 000000000000..65a6a2dc6bce --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_3.hpp @@ -0,0 +1,166 @@ + + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_3_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); + } + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); + const auto is_table_entry = View(in.avm_main_sel_rng_16); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_3, + in.lookup_u16_3_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r3, + in.avm_main_clk); + } + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_3, + in.lookup_u16_3_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r3, + in.avm_main_clk); + } +}; + +template using lookup_u16_3_relation = GenericLookupRelation; +template using lookup_u16_3 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_4.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_4.hpp new file mode 100644 index 000000000000..f70eea125838 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_4.hpp @@ -0,0 +1,166 @@ + + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_4_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); + } + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); + const auto is_table_entry = View(in.avm_main_sel_rng_16); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_4, + in.lookup_u16_4_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r4, + in.avm_main_clk); + } + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_4, + in.lookup_u16_4_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r4, + in.avm_main_clk); + } +}; + +template using lookup_u16_4_relation = GenericLookupRelation; +template using lookup_u16_4 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_5.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_5.hpp new file mode 100644 index 000000000000..88f50d749c43 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_5.hpp @@ -0,0 +1,166 @@ + + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_5_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); + } + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); + const auto is_table_entry = View(in.avm_main_sel_rng_16); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_5, + in.lookup_u16_5_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r5, + in.avm_main_clk); + } + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_5, + in.lookup_u16_5_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r5, + in.avm_main_clk); + } +}; + +template using lookup_u16_5_relation = GenericLookupRelation; +template using lookup_u16_5 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_6.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_6.hpp new file mode 100644 index 000000000000..297c69a31e5a --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_6.hpp @@ -0,0 +1,166 @@ + + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_6_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); + } + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); + const auto is_table_entry = View(in.avm_main_sel_rng_16); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_6, + in.lookup_u16_6_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r6, + in.avm_main_clk); + } + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_6, + in.lookup_u16_6_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r6, + in.avm_main_clk); + } +}; + +template using lookup_u16_6_relation = GenericLookupRelation; +template using lookup_u16_6 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_7.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_7.hpp new file mode 100644 index 000000000000..37bc7f89d1c0 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_7.hpp @@ -0,0 +1,166 @@ + + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_7_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); + } + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); + const auto is_table_entry = View(in.avm_main_sel_rng_16); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_7, + in.lookup_u16_7_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r7, + in.avm_main_clk); + } + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_7, + in.lookup_u16_7_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r7, + in.avm_main_clk); + } +}; + +template using lookup_u16_7_relation = GenericLookupRelation; +template using lookup_u16_7 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_8.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_8.hpp new file mode 100644 index 000000000000..2cc51625cd5e --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_8.hpp @@ -0,0 +1,166 @@ + + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_8_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); + } + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); + const auto is_table_entry = View(in.avm_main_sel_rng_16); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_8, + in.lookup_u16_8_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r8, + in.avm_main_clk); + } + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_8, + in.lookup_u16_8_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r8, + in.avm_main_clk); + } +}; + +template using lookup_u16_8_relation = GenericLookupRelation; +template using lookup_u16_8 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_9.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_9.hpp new file mode 100644 index 000000000000..c0efd97f30f0 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_9.hpp @@ -0,0 +1,166 @@ + + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class lookup_u16_9_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.avm_alu_rng_chk_lookup_selector == 1 || in.avm_main_sel_rng_16 == 1); + } + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.avm_alu_rng_chk_lookup_selector); + const auto is_table_entry = View(in.avm_main_sel_rng_16); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_9, + in.lookup_u16_9_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r9, + in.avm_main_clk); + } + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.lookup_u16_9, + in.lookup_u16_9_counts, + in.avm_alu_rng_chk_lookup_selector, + in.avm_main_sel_rng_16, + in.avm_alu_u16_r9, + in.avm_main_clk); + } +}; + +template using lookup_u16_9_relation = GenericLookupRelation; +template using lookup_u16_9 = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp index 303faeea5b23..4a31987c2b18 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp @@ -1238,7 +1238,7 @@ std::vector AvmTraceBuilder::finalize() // If the bin_trace_size has entries, we need the main_trace to be as big as our byte lookup table (3 * 2**16 // long) size_t const lookup_table_size = bin_trace_size > 0 ? 3 * (1 << 16) : 0; - size_t const range_check_size = range_checked_required ? UINT8_MAX + 1 : 0; + size_t const range_check_size = range_checked_required ? UINT16_MAX + 1 : 0; std::vector trace_sizes = { mem_trace_size, main_trace_size, alu_trace_size, lookup_table_size, range_check_size }; @@ -1403,12 +1403,29 @@ std::vector AvmTraceBuilder::finalize() r.lookup_u8_0_counts = alu_trace_builder.u8_range_chk_counters[0][static_cast(i)]; r.lookup_u8_1_counts = alu_trace_builder.u8_range_chk_counters[1][static_cast(i)]; r.avm_main_sel_rng_8 = FF(1); - r.avm_main_clk = FF(static_cast(i)); } if (i <= UINT16_MAX) { - r.avm_main_sel_rng_16 = FF(1); + // We add to the clk here in case our trace is smaller than our range checks + // There might be a cleaner way to do this in the future as this only applies + // when our trace (excluding range checks) is < 2**16 + r.lookup_u16_0_counts = alu_trace_builder.u16_range_chk_counters[0][static_cast(i)]; + r.lookup_u16_1_counts = alu_trace_builder.u16_range_chk_counters[1][static_cast(i)]; + r.lookup_u16_2_counts = alu_trace_builder.u16_range_chk_counters[2][static_cast(i)]; + r.lookup_u16_3_counts = alu_trace_builder.u16_range_chk_counters[3][static_cast(i)]; + r.lookup_u16_4_counts = alu_trace_builder.u16_range_chk_counters[4][static_cast(i)]; + r.lookup_u16_5_counts = alu_trace_builder.u16_range_chk_counters[5][static_cast(i)]; + r.lookup_u16_6_counts = alu_trace_builder.u16_range_chk_counters[6][static_cast(i)]; + r.lookup_u16_7_counts = alu_trace_builder.u16_range_chk_counters[7][static_cast(i)]; + r.lookup_u16_8_counts = alu_trace_builder.u16_range_chk_counters[8][static_cast(i)]; + r.lookup_u16_9_counts = alu_trace_builder.u16_range_chk_counters[9][static_cast(i)]; + r.lookup_u16_10_counts = alu_trace_builder.u16_range_chk_counters[10][static_cast(i)]; + r.lookup_u16_11_counts = alu_trace_builder.u16_range_chk_counters[11][static_cast(i)]; + r.lookup_u16_12_counts = alu_trace_builder.u16_range_chk_counters[12][static_cast(i)]; + r.lookup_u16_13_counts = alu_trace_builder.u16_range_chk_counters[13][static_cast(i)]; + r.lookup_u16_14_counts = alu_trace_builder.u16_range_chk_counters[14][static_cast(i)]; r.avm_main_clk = FF(static_cast(i)); + r.avm_main_sel_rng_16 = 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 279a2a44b689..416c43dbb446 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp @@ -19,6 +19,21 @@ #include "barretenberg/relations/generated/avm/incl_mem_tag_err.hpp" #include "barretenberg/relations/generated/avm/lookup_byte_lengths.hpp" #include "barretenberg/relations/generated/avm/lookup_byte_operations.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_0.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_1.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_10.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_11.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_12.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_13.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_14.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_2.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_3.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_4.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_5.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_6.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_7.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_8.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_9.hpp" #include "barretenberg/relations/generated/avm/lookup_u8_0.hpp" #include "barretenberg/relations/generated/avm/lookup_u8_1.hpp" #include "barretenberg/relations/generated/avm/perm_main_alu.hpp" @@ -193,12 +208,42 @@ template struct AvmFullRow { FF incl_mem_tag_err{}; FF lookup_u8_0{}; FF lookup_u8_1{}; + FF lookup_u16_0{}; + FF lookup_u16_1{}; + FF lookup_u16_2{}; + FF lookup_u16_3{}; + FF lookup_u16_4{}; + FF lookup_u16_5{}; + FF lookup_u16_6{}; + FF lookup_u16_7{}; + FF lookup_u16_8{}; + FF lookup_u16_9{}; + FF lookup_u16_10{}; + FF lookup_u16_11{}; + FF lookup_u16_12{}; + FF lookup_u16_13{}; + FF lookup_u16_14{}; FF lookup_byte_lengths_counts{}; FF lookup_byte_operations_counts{}; FF incl_main_tag_err_counts{}; FF incl_mem_tag_err_counts{}; FF lookup_u8_0_counts{}; FF lookup_u8_1_counts{}; + FF lookup_u16_0_counts{}; + FF lookup_u16_1_counts{}; + FF lookup_u16_2_counts{}; + FF lookup_u16_3_counts{}; + FF lookup_u16_4_counts{}; + FF lookup_u16_5_counts{}; + FF lookup_u16_6_counts{}; + FF lookup_u16_7_counts{}; + FF lookup_u16_8_counts{}; + FF lookup_u16_9_counts{}; + FF lookup_u16_10_counts{}; + FF lookup_u16_11_counts{}; + FF lookup_u16_12_counts{}; + FF lookup_u16_13_counts{}; + FF lookup_u16_14_counts{}; FF avm_alu_a_hi_shift{}; FF avm_alu_a_lo_shift{}; FF avm_alu_b_hi_shift{}; @@ -240,8 +285,8 @@ class AvmCircuitBuilder { using Polynomial = Flavor::Polynomial; using ProverPolynomials = Flavor::ProverPolynomials; - static constexpr size_t num_fixed_columns = 194; - static constexpr size_t num_polys = 165; + static constexpr size_t num_fixed_columns = 224; + static constexpr size_t num_polys = 195; std::vector rows; void set_trace(std::vector&& trace) { rows = std::move(trace); } @@ -422,13 +467,46 @@ class AvmCircuitBuilder { ======= polys.lookup_u8_0[i] = rows[i].lookup_u8_0; polys.lookup_u8_1[i] = rows[i].lookup_u8_1; +<<<<<<< HEAD >>>>>>> 8d38899c9 (feat: some wip) +======= + polys.lookup_u16_0[i] = rows[i].lookup_u16_0; + polys.lookup_u16_1[i] = rows[i].lookup_u16_1; + polys.lookup_u16_2[i] = rows[i].lookup_u16_2; + polys.lookup_u16_3[i] = rows[i].lookup_u16_3; + polys.lookup_u16_4[i] = rows[i].lookup_u16_4; + polys.lookup_u16_5[i] = rows[i].lookup_u16_5; + polys.lookup_u16_6[i] = rows[i].lookup_u16_6; + polys.lookup_u16_7[i] = rows[i].lookup_u16_7; + polys.lookup_u16_8[i] = rows[i].lookup_u16_8; + polys.lookup_u16_9[i] = rows[i].lookup_u16_9; + polys.lookup_u16_10[i] = rows[i].lookup_u16_10; + polys.lookup_u16_11[i] = rows[i].lookup_u16_11; + polys.lookup_u16_12[i] = rows[i].lookup_u16_12; + polys.lookup_u16_13[i] = rows[i].lookup_u16_13; + polys.lookup_u16_14[i] = rows[i].lookup_u16_14; +>>>>>>> 760ed7310 (fix: 16_bit range checks) 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; polys.incl_mem_tag_err_counts[i] = rows[i].incl_mem_tag_err_counts; polys.lookup_u8_0_counts[i] = rows[i].lookup_u8_0_counts; polys.lookup_u8_1_counts[i] = rows[i].lookup_u8_1_counts; + polys.lookup_u16_0_counts[i] = rows[i].lookup_u16_0_counts; + polys.lookup_u16_1_counts[i] = rows[i].lookup_u16_1_counts; + polys.lookup_u16_2_counts[i] = rows[i].lookup_u16_2_counts; + polys.lookup_u16_3_counts[i] = rows[i].lookup_u16_3_counts; + polys.lookup_u16_4_counts[i] = rows[i].lookup_u16_4_counts; + polys.lookup_u16_5_counts[i] = rows[i].lookup_u16_5_counts; + polys.lookup_u16_6_counts[i] = rows[i].lookup_u16_6_counts; + polys.lookup_u16_7_counts[i] = rows[i].lookup_u16_7_counts; + polys.lookup_u16_8_counts[i] = rows[i].lookup_u16_8_counts; + polys.lookup_u16_9_counts[i] = rows[i].lookup_u16_9_counts; + polys.lookup_u16_10_counts[i] = rows[i].lookup_u16_10_counts; + polys.lookup_u16_11_counts[i] = rows[i].lookup_u16_11_counts; + polys.lookup_u16_12_counts[i] = rows[i].lookup_u16_12_counts; + polys.lookup_u16_13_counts[i] = rows[i].lookup_u16_13_counts; + polys.lookup_u16_14_counts[i] = rows[i].lookup_u16_14_counts; } polys.avm_alu_a_hi_shift = Polynomial(polys.avm_alu_a_hi.shifted()); @@ -591,6 +669,51 @@ class AvmCircuitBuilder { if (!evaluate_logderivative.template operator()>("LOOKUP_U8_1")) { return false; } + if (!evaluate_logderivative.template operator()>("LOOKUP_U16_0")) { + return false; + } + if (!evaluate_logderivative.template operator()>("LOOKUP_U16_1")) { + return false; + } + if (!evaluate_logderivative.template operator()>("LOOKUP_U16_2")) { + return false; + } + if (!evaluate_logderivative.template operator()>("LOOKUP_U16_3")) { + return false; + } + if (!evaluate_logderivative.template operator()>("LOOKUP_U16_4")) { + return false; + } + if (!evaluate_logderivative.template operator()>("LOOKUP_U16_5")) { + return false; + } + if (!evaluate_logderivative.template operator()>("LOOKUP_U16_6")) { + return false; + } + if (!evaluate_logderivative.template operator()>("LOOKUP_U16_7")) { + return false; + } + if (!evaluate_logderivative.template operator()>("LOOKUP_U16_8")) { + return false; + } + if (!evaluate_logderivative.template operator()>("LOOKUP_U16_9")) { + return false; + } + if (!evaluate_logderivative.template operator()>("LOOKUP_U16_10")) { + return false; + } + if (!evaluate_logderivative.template operator()>("LOOKUP_U16_11")) { + return false; + } + if (!evaluate_logderivative.template operator()>("LOOKUP_U16_12")) { + return false; + } + if (!evaluate_logderivative.template operator()>("LOOKUP_U16_13")) { + return false; + } + if (!evaluate_logderivative.template operator()>("LOOKUP_U16_14")) { + return false; + } return true; } diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp index d425d79d574b..6c390d9909fe 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp @@ -50,11 +50,11 @@ class AvmFlavor { using RelationSeparator = FF; static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 2; - static constexpr size_t NUM_WITNESS_ENTITIES = 163; + 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 = 194; + static constexpr size_t NUM_ALL_ENTITIES = 224; using GrandProductRelations = std::tuple, perm_main_bin_relation, @@ -275,12 +275,42 @@ class AvmFlavor { incl_mem_tag_err, lookup_u8_0, lookup_u8_1, + lookup_u16_0, + lookup_u16_1, + lookup_u16_2, + lookup_u16_3, + lookup_u16_4, + lookup_u16_5, + lookup_u16_6, + lookup_u16_7, + lookup_u16_8, + lookup_u16_9, + lookup_u16_10, + lookup_u16_11, + lookup_u16_12, + lookup_u16_13, + lookup_u16_14, lookup_byte_lengths_counts, lookup_byte_operations_counts, incl_main_tag_err_counts, incl_mem_tag_err_counts, lookup_u8_0_counts, - lookup_u8_1_counts) + lookup_u8_1_counts, + lookup_u16_0_counts, + lookup_u16_1_counts, + lookup_u16_2_counts, + lookup_u16_3_counts, + lookup_u16_4_counts, + lookup_u16_5_counts, + lookup_u16_6_counts, + lookup_u16_7_counts, + lookup_u16_8_counts, + lookup_u16_9_counts, + lookup_u16_10_counts, + lookup_u16_11_counts, + lookup_u16_12_counts, + lookup_u16_13_counts, + lookup_u16_14_counts) RefVector get_wires() { @@ -441,12 +471,42 @@ class AvmFlavor { incl_mem_tag_err, lookup_u8_0, lookup_u8_1, + lookup_u16_0, + lookup_u16_1, + lookup_u16_2, + lookup_u16_3, + lookup_u16_4, + lookup_u16_5, + lookup_u16_6, + lookup_u16_7, + lookup_u16_8, + lookup_u16_9, + lookup_u16_10, + lookup_u16_11, + lookup_u16_12, + lookup_u16_13, + lookup_u16_14, lookup_byte_lengths_counts, lookup_byte_operations_counts, incl_main_tag_err_counts, incl_mem_tag_err_counts, lookup_u8_0_counts, - lookup_u8_1_counts }; + lookup_u8_1_counts, + lookup_u16_0_counts, + lookup_u16_1_counts, + lookup_u16_2_counts, + lookup_u16_3_counts, + lookup_u16_4_counts, + lookup_u16_5_counts, + lookup_u16_6_counts, + lookup_u16_7_counts, + lookup_u16_8_counts, + lookup_u16_9_counts, + lookup_u16_10_counts, + lookup_u16_11_counts, + lookup_u16_12_counts, + lookup_u16_13_counts, + lookup_u16_14_counts }; }; }; @@ -612,12 +672,42 @@ class AvmFlavor { incl_mem_tag_err, lookup_u8_0, lookup_u8_1, + lookup_u16_0, + lookup_u16_1, + lookup_u16_2, + lookup_u16_3, + lookup_u16_4, + lookup_u16_5, + lookup_u16_6, + lookup_u16_7, + lookup_u16_8, + lookup_u16_9, + lookup_u16_10, + lookup_u16_11, + lookup_u16_12, + lookup_u16_13, + lookup_u16_14, lookup_byte_lengths_counts, lookup_byte_operations_counts, incl_main_tag_err_counts, incl_mem_tag_err_counts, lookup_u8_0_counts, lookup_u8_1_counts, + lookup_u16_0_counts, + lookup_u16_1_counts, + lookup_u16_2_counts, + lookup_u16_3_counts, + lookup_u16_4_counts, + lookup_u16_5_counts, + lookup_u16_6_counts, + lookup_u16_7_counts, + lookup_u16_8_counts, + lookup_u16_9_counts, + lookup_u16_10_counts, + lookup_u16_11_counts, + lookup_u16_12_counts, + lookup_u16_13_counts, + lookup_u16_14_counts, avm_alu_a_hi_shift, avm_alu_a_lo_shift, avm_alu_b_hi_shift, @@ -809,12 +899,42 @@ class AvmFlavor { incl_mem_tag_err, lookup_u8_0, lookup_u8_1, + lookup_u16_0, + lookup_u16_1, + lookup_u16_2, + lookup_u16_3, + lookup_u16_4, + lookup_u16_5, + lookup_u16_6, + lookup_u16_7, + lookup_u16_8, + lookup_u16_9, + lookup_u16_10, + lookup_u16_11, + lookup_u16_12, + lookup_u16_13, + lookup_u16_14, lookup_byte_lengths_counts, lookup_byte_operations_counts, incl_main_tag_err_counts, incl_mem_tag_err_counts, lookup_u8_0_counts, lookup_u8_1_counts, + lookup_u16_0_counts, + lookup_u16_1_counts, + lookup_u16_2_counts, + lookup_u16_3_counts, + lookup_u16_4_counts, + lookup_u16_5_counts, + lookup_u16_6_counts, + lookup_u16_7_counts, + lookup_u16_8_counts, + lookup_u16_9_counts, + lookup_u16_10_counts, + lookup_u16_11_counts, + lookup_u16_12_counts, + lookup_u16_13_counts, + lookup_u16_14_counts, avm_alu_a_hi_shift, avm_alu_a_lo_shift, avm_alu_b_hi_shift, @@ -1006,12 +1126,42 @@ class AvmFlavor { incl_mem_tag_err, lookup_u8_0, lookup_u8_1, + lookup_u16_0, + lookup_u16_1, + lookup_u16_2, + lookup_u16_3, + lookup_u16_4, + lookup_u16_5, + lookup_u16_6, + lookup_u16_7, + lookup_u16_8, + lookup_u16_9, + lookup_u16_10, + lookup_u16_11, + lookup_u16_12, + lookup_u16_13, + lookup_u16_14, lookup_byte_lengths_counts, lookup_byte_operations_counts, incl_main_tag_err_counts, incl_mem_tag_err_counts, lookup_u8_0_counts, - lookup_u8_1_counts }; + lookup_u8_1_counts, + lookup_u16_0_counts, + lookup_u16_1_counts, + lookup_u16_2_counts, + lookup_u16_3_counts, + lookup_u16_4_counts, + lookup_u16_5_counts, + lookup_u16_6_counts, + lookup_u16_7_counts, + lookup_u16_8_counts, + lookup_u16_9_counts, + lookup_u16_10_counts, + lookup_u16_11_counts, + lookup_u16_12_counts, + lookup_u16_13_counts, + lookup_u16_14_counts }; }; RefVector get_to_be_shifted() { @@ -1371,12 +1521,42 @@ class AvmFlavor { Base::incl_mem_tag_err = "INCL_MEM_TAG_ERR"; Base::lookup_u8_0 = "LOOKUP_U8_0"; Base::lookup_u8_1 = "LOOKUP_U8_1"; + Base::lookup_u16_0 = "LOOKUP_U16_0"; + Base::lookup_u16_1 = "LOOKUP_U16_1"; + Base::lookup_u16_2 = "LOOKUP_U16_2"; + Base::lookup_u16_3 = "LOOKUP_U16_3"; + Base::lookup_u16_4 = "LOOKUP_U16_4"; + Base::lookup_u16_5 = "LOOKUP_U16_5"; + Base::lookup_u16_6 = "LOOKUP_U16_6"; + Base::lookup_u16_7 = "LOOKUP_U16_7"; + Base::lookup_u16_8 = "LOOKUP_U16_8"; + Base::lookup_u16_9 = "LOOKUP_U16_9"; + Base::lookup_u16_10 = "LOOKUP_U16_10"; + Base::lookup_u16_11 = "LOOKUP_U16_11"; + Base::lookup_u16_12 = "LOOKUP_U16_12"; + Base::lookup_u16_13 = "LOOKUP_U16_13"; + Base::lookup_u16_14 = "LOOKUP_U16_14"; Base::lookup_byte_lengths_counts = "LOOKUP_BYTE_LENGTHS_COUNTS"; Base::lookup_byte_operations_counts = "LOOKUP_BYTE_OPERATIONS_COUNTS"; Base::incl_main_tag_err_counts = "INCL_MAIN_TAG_ERR_COUNTS"; Base::incl_mem_tag_err_counts = "INCL_MEM_TAG_ERR_COUNTS"; Base::lookup_u8_0_counts = "LOOKUP_U8_0_COUNTS"; Base::lookup_u8_1_counts = "LOOKUP_U8_1_COUNTS"; + Base::lookup_u16_0_counts = "LOOKUP_U16_0_COUNTS"; + Base::lookup_u16_1_counts = "LOOKUP_U16_1_COUNTS"; + Base::lookup_u16_2_counts = "LOOKUP_U16_2_COUNTS"; + Base::lookup_u16_3_counts = "LOOKUP_U16_3_COUNTS"; + Base::lookup_u16_4_counts = "LOOKUP_U16_4_COUNTS"; + Base::lookup_u16_5_counts = "LOOKUP_U16_5_COUNTS"; + Base::lookup_u16_6_counts = "LOOKUP_U16_6_COUNTS"; + Base::lookup_u16_7_counts = "LOOKUP_U16_7_COUNTS"; + Base::lookup_u16_8_counts = "LOOKUP_U16_8_COUNTS"; + Base::lookup_u16_9_counts = "LOOKUP_U16_9_COUNTS"; + Base::lookup_u16_10_counts = "LOOKUP_U16_10_COUNTS"; + Base::lookup_u16_11_counts = "LOOKUP_U16_11_COUNTS"; + Base::lookup_u16_12_counts = "LOOKUP_U16_12_COUNTS"; + Base::lookup_u16_13_counts = "LOOKUP_U16_13_COUNTS"; + Base::lookup_u16_14_counts = "LOOKUP_U16_14_COUNTS"; }; }; @@ -1574,13 +1754,46 @@ class AvmFlavor { ======= Commitment lookup_u8_0; Commitment lookup_u8_1; +<<<<<<< HEAD >>>>>>> 8d38899c9 (feat: some wip) +======= + Commitment lookup_u16_0; + Commitment lookup_u16_1; + Commitment lookup_u16_2; + Commitment lookup_u16_3; + Commitment lookup_u16_4; + Commitment lookup_u16_5; + Commitment lookup_u16_6; + Commitment lookup_u16_7; + Commitment lookup_u16_8; + Commitment lookup_u16_9; + Commitment lookup_u16_10; + Commitment lookup_u16_11; + Commitment lookup_u16_12; + Commitment lookup_u16_13; + Commitment lookup_u16_14; +>>>>>>> 760ed7310 (fix: 16_bit range checks) Commitment lookup_byte_lengths_counts; Commitment lookup_byte_operations_counts; Commitment incl_main_tag_err_counts; Commitment incl_mem_tag_err_counts; Commitment lookup_u8_0_counts; Commitment lookup_u8_1_counts; + Commitment lookup_u16_0_counts; + Commitment lookup_u16_1_counts; + Commitment lookup_u16_2_counts; + Commitment lookup_u16_3_counts; + Commitment lookup_u16_4_counts; + Commitment lookup_u16_5_counts; + Commitment lookup_u16_6_counts; + Commitment lookup_u16_7_counts; + Commitment lookup_u16_8_counts; + Commitment lookup_u16_9_counts; + Commitment lookup_u16_10_counts; + Commitment lookup_u16_11_counts; + Commitment lookup_u16_12_counts; + Commitment lookup_u16_13_counts; + Commitment lookup_u16_14_counts; std::vector> sumcheck_univariates; std::array sumcheck_evaluations; @@ -1758,12 +1971,42 @@ class AvmFlavor { incl_mem_tag_err = deserialize_from_buffer(Transcript::proof_data, num_frs_read); lookup_u8_0 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); lookup_u8_1 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_0 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_1 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_2 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_3 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_4 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_5 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_6 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_7 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_8 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_9 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_10 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_11 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_12 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_13 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_14 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); lookup_byte_lengths_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); lookup_byte_operations_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); incl_main_tag_err_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); incl_mem_tag_err_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); lookup_u8_0_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); lookup_u8_1_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_0_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_1_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_2_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_3_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_4_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_5_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_6_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_7_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_8_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_9_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_10_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_11_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_12_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_13_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_u16_14_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); for (size_t i = 0; i < log_n; ++i) { sumcheck_univariates.emplace_back( @@ -1944,12 +2187,42 @@ class AvmFlavor { serialize_to_buffer(incl_mem_tag_err, Transcript::proof_data); serialize_to_buffer(lookup_u8_0, Transcript::proof_data); serialize_to_buffer(lookup_u8_1, Transcript::proof_data); + serialize_to_buffer(lookup_u16_0, Transcript::proof_data); + serialize_to_buffer(lookup_u16_1, Transcript::proof_data); + serialize_to_buffer(lookup_u16_2, Transcript::proof_data); + serialize_to_buffer(lookup_u16_3, Transcript::proof_data); + serialize_to_buffer(lookup_u16_4, Transcript::proof_data); + serialize_to_buffer(lookup_u16_5, Transcript::proof_data); + serialize_to_buffer(lookup_u16_6, Transcript::proof_data); + serialize_to_buffer(lookup_u16_7, Transcript::proof_data); + serialize_to_buffer(lookup_u16_8, Transcript::proof_data); + serialize_to_buffer(lookup_u16_9, Transcript::proof_data); + serialize_to_buffer(lookup_u16_10, Transcript::proof_data); + serialize_to_buffer(lookup_u16_11, Transcript::proof_data); + serialize_to_buffer(lookup_u16_12, Transcript::proof_data); + serialize_to_buffer(lookup_u16_13, Transcript::proof_data); + serialize_to_buffer(lookup_u16_14, Transcript::proof_data); serialize_to_buffer(lookup_byte_lengths_counts, Transcript::proof_data); serialize_to_buffer(lookup_byte_operations_counts, Transcript::proof_data); serialize_to_buffer(incl_main_tag_err_counts, Transcript::proof_data); serialize_to_buffer(incl_mem_tag_err_counts, Transcript::proof_data); serialize_to_buffer(lookup_u8_0_counts, Transcript::proof_data); serialize_to_buffer(lookup_u8_1_counts, Transcript::proof_data); + serialize_to_buffer(lookup_u16_0_counts, Transcript::proof_data); + serialize_to_buffer(lookup_u16_1_counts, Transcript::proof_data); + serialize_to_buffer(lookup_u16_2_counts, Transcript::proof_data); + serialize_to_buffer(lookup_u16_3_counts, Transcript::proof_data); + serialize_to_buffer(lookup_u16_4_counts, Transcript::proof_data); + serialize_to_buffer(lookup_u16_5_counts, Transcript::proof_data); + serialize_to_buffer(lookup_u16_6_counts, Transcript::proof_data); + serialize_to_buffer(lookup_u16_7_counts, Transcript::proof_data); + serialize_to_buffer(lookup_u16_8_counts, Transcript::proof_data); + serialize_to_buffer(lookup_u16_9_counts, Transcript::proof_data); + serialize_to_buffer(lookup_u16_10_counts, Transcript::proof_data); + serialize_to_buffer(lookup_u16_11_counts, Transcript::proof_data); + serialize_to_buffer(lookup_u16_12_counts, Transcript::proof_data); + serialize_to_buffer(lookup_u16_13_counts, Transcript::proof_data); + serialize_to_buffer(lookup_u16_14_counts, Transcript::proof_data); for (size_t i = 0; i < log_n; ++i) { serialize_to_buffer(sumcheck_univariates[i], 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 cb0927cfb55b..105b33fc9cdb 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp @@ -339,6 +339,21 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) ======= commitments.lookup_u8_0 = transcript->template receive_from_prover(commitment_labels.lookup_u8_0); commitments.lookup_u8_1 = transcript->template receive_from_prover(commitment_labels.lookup_u8_1); + commitments.lookup_u16_0 = transcript->template receive_from_prover(commitment_labels.lookup_u16_0); + commitments.lookup_u16_1 = transcript->template receive_from_prover(commitment_labels.lookup_u16_1); + commitments.lookup_u16_2 = transcript->template receive_from_prover(commitment_labels.lookup_u16_2); + commitments.lookup_u16_3 = transcript->template receive_from_prover(commitment_labels.lookup_u16_3); + commitments.lookup_u16_4 = transcript->template receive_from_prover(commitment_labels.lookup_u16_4); + commitments.lookup_u16_5 = transcript->template receive_from_prover(commitment_labels.lookup_u16_5); + commitments.lookup_u16_6 = transcript->template receive_from_prover(commitment_labels.lookup_u16_6); + commitments.lookup_u16_7 = transcript->template receive_from_prover(commitment_labels.lookup_u16_7); + commitments.lookup_u16_8 = transcript->template receive_from_prover(commitment_labels.lookup_u16_8); + commitments.lookup_u16_9 = transcript->template receive_from_prover(commitment_labels.lookup_u16_9); + commitments.lookup_u16_10 = transcript->template receive_from_prover(commitment_labels.lookup_u16_10); + commitments.lookup_u16_11 = transcript->template receive_from_prover(commitment_labels.lookup_u16_11); + commitments.lookup_u16_12 = transcript->template receive_from_prover(commitment_labels.lookup_u16_12); + commitments.lookup_u16_13 = transcript->template receive_from_prover(commitment_labels.lookup_u16_13); + commitments.lookup_u16_14 = transcript->template receive_from_prover(commitment_labels.lookup_u16_14); commitments.lookup_byte_lengths_counts = transcript->template receive_from_prover(commitment_labels.lookup_byte_lengths_counts); commitments.lookup_byte_operations_counts = @@ -351,7 +366,40 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) transcript->template receive_from_prover(commitment_labels.lookup_u8_0_counts); commitments.lookup_u8_1_counts = transcript->template receive_from_prover(commitment_labels.lookup_u8_1_counts); +<<<<<<< HEAD >>>>>>> 8d38899c9 (feat: some wip) +======= + commitments.lookup_u16_0_counts = + transcript->template receive_from_prover(commitment_labels.lookup_u16_0_counts); + commitments.lookup_u16_1_counts = + transcript->template receive_from_prover(commitment_labels.lookup_u16_1_counts); + commitments.lookup_u16_2_counts = + transcript->template receive_from_prover(commitment_labels.lookup_u16_2_counts); + commitments.lookup_u16_3_counts = + transcript->template receive_from_prover(commitment_labels.lookup_u16_3_counts); + commitments.lookup_u16_4_counts = + transcript->template receive_from_prover(commitment_labels.lookup_u16_4_counts); + commitments.lookup_u16_5_counts = + transcript->template receive_from_prover(commitment_labels.lookup_u16_5_counts); + commitments.lookup_u16_6_counts = + transcript->template receive_from_prover(commitment_labels.lookup_u16_6_counts); + commitments.lookup_u16_7_counts = + transcript->template receive_from_prover(commitment_labels.lookup_u16_7_counts); + commitments.lookup_u16_8_counts = + transcript->template receive_from_prover(commitment_labels.lookup_u16_8_counts); + commitments.lookup_u16_9_counts = + transcript->template receive_from_prover(commitment_labels.lookup_u16_9_counts); + commitments.lookup_u16_10_counts = + transcript->template receive_from_prover(commitment_labels.lookup_u16_10_counts); + commitments.lookup_u16_11_counts = + transcript->template receive_from_prover(commitment_labels.lookup_u16_11_counts); + commitments.lookup_u16_12_counts = + transcript->template receive_from_prover(commitment_labels.lookup_u16_12_counts); + commitments.lookup_u16_13_counts = + transcript->template receive_from_prover(commitment_labels.lookup_u16_13_counts); + commitments.lookup_u16_14_counts = + transcript->template receive_from_prover(commitment_labels.lookup_u16_14_counts); +>>>>>>> 760ed7310 (fix: 16_bit range checks) // Execute Sumcheck Verifier const size_t log_circuit_size = numeric::get_msb(circuit_size); From eac00c5f4f34851f929e894814e446b4fb3e5d96 Mon Sep 17 00:00:00 2001 From: IlyasRidhuan Date: Wed, 10 Apr 2024 08:33:21 +0000 Subject: [PATCH 11/18] fix: add negative tests --- barretenberg/cpp/pil/avm/avm_alu.pil | 12 +- barretenberg/cpp/pil/avm/avm_main.pil | 1 + .../vm/tests/avm_comparison.test.cpp | 105 +++++++++++++++++- 3 files changed, 111 insertions(+), 7 deletions(-) diff --git a/barretenberg/cpp/pil/avm/avm_alu.pil b/barretenberg/cpp/pil/avm/avm_alu.pil index 926c84f58bff..7492dd32b6ff 100644 --- a/barretenberg/cpp/pil/avm/avm_alu.pil +++ b/barretenberg/cpp/pil/avm/avm_alu.pil @@ -417,7 +417,6 @@ namespace avm_alu(256); (res_hi - (A_SUB_B_HI * IS_GT + B_SUB_A_HI * (1 - IS_GT))) * cmp_sel = 0; // ========= RANGE OPERATIONS =============================== - // TODO: 8-bit and 16-bit range checks for the respective registers have not yet been implemented. // Each call to LT/LTE requires 5x 256-bit range checks. We keep track of how many are left here. pol commit cmp_rng_ctr; @@ -443,6 +442,10 @@ namespace avm_alu(256); // We perform a range check if we have some range checks remaining or we are performing a comparison op pol RNG_CHK_OP = (rng_chk_sel + cmp_sel); + pol commit rng_chk_lookup_selector; + #[RNG_CHK_LOOKUP_SELECTOR] + rng_chk_lookup_selector = cmp_sel + rng_chk_sel; + // Perform 128-bit range check on lo part #[LOWER_CMP_RNG_CHK] a_lo = SUM_128 * (RNG_CHK_OP); @@ -456,6 +459,9 @@ namespace avm_alu(256); u16_r13 * 2**96 + u16_r14 * 2**112) * (RNG_CHK_OP); // Shift all elements "across" by 2 columns + // TODO: there is an optimisation where we are able to do 1 less range check as the range check on + // P_SUB_B is implied by the other range checks. + // Briefly: given a > b and p > a and p > a - b - 1, it is sufficient confirm that p > b without a range check #[SHIFT_RELS] (a_lo' - b_lo) * rng_chk_sel' = 0; (a_hi' - b_hi) * rng_chk_sel' = 0; @@ -469,7 +475,3 @@ namespace avm_alu(256); (p_sub_b_lo' - res_lo) * rng_chk_sel'= 0; (p_sub_b_hi' - res_hi) * rng_chk_sel'= 0; - // TODO: Investigate optimising these range checks. Handling non-FF elements should require less range checks. - pol commit rng_chk_lookup_selector; - #[RNG_CHK_LOOKUP_SELECTOR] - rng_chk_lookup_selector = cmp_sel + rng_chk_sel; diff --git a/barretenberg/cpp/pil/avm/avm_main.pil b/barretenberg/cpp/pil/avm/avm_main.pil index f673bc709b2b..3dc4144bb489 100644 --- a/barretenberg/cpp/pil/avm/avm_main.pil +++ b/barretenberg/cpp/pil/avm/avm_main.pil @@ -312,6 +312,7 @@ namespace avm_main(256); ind_op_c {clk, ind_c, mem_idx_c} is avm_mem.ind_op_c {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] avm_alu.rng_chk_lookup_selector { avm_alu.u8_r0 } in sel_rng_8 { clk }; diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_comparison.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_comparison.test.cpp index 9a7c397c53e4..1e10d3a85d7e 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_comparison.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_comparison.test.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -150,6 +151,7 @@ enum CMP_FAILURES { CounterRelationFailed, CounterNonZeroCheckFailed, ShiftRelationFailed, + RangeCheckFailed, }; std::vector> cmp_failures = { { "INPUT_DECOMP_1", CMP_FAILURES::IncorrectInputDecomposition }, @@ -160,12 +162,16 @@ std::vector> cmp_failures = { { "CMP_CTR_REL_2", CMP_FAILURES::CounterRelationFailed }, { "CTR_NON_ZERO_REL", CMP_FAILURES::CounterNonZeroCheckFailed }, { "SHIFT_RELS", CMP_FAILURES::ShiftRelationFailed }, + { "LOOKUP_U16_0", CMP_FAILURES::RangeCheckFailed }, + }; -std::vector neg_test_lt = { { 12023, 439321, 1 } }; +std::vector neg_test_lt = { { 12023, 439321, 0 } }; using EXPECTED_ERRORS = std::tuple; + std::vector gen_mutated_trace_cmp(std::vector trace, std::function&& select_row, + FF c_mutated, CMP_FAILURES fail_mode) { auto main_trace_row = std::ranges::find_if(trace.begin(), trace.end(), select_row); @@ -201,12 +207,87 @@ std::vector gen_mutated_trace_cmp(std::vector trace, case ShiftRelationFailed: range_check_row->avm_alu_a_lo = range_check_row->avm_alu_res_lo; range_check_row->avm_alu_a_hi = range_check_row->avm_alu_res_hi; + break; + case RangeCheckFailed: // Canonicalisation check failure + // TODO: We can probably refactor this to another function later as it is a bit verbose + // and we'll probably use it repeatedly for other range check test. + + // The range check fails in the context of the cmp operation if we set the boolean + // result in ic to be incorrect. + // + // Here we falsely claim LT(12,023, 439,321, 0). i.e. 12023 < 439321 is false. + mutate_ic_in_trace(trace, std::move(select_row), c_mutated, true); + // Now we have to also update the value of res_lo = (A_SUB_B_LO * IS_GT + B_SUB_A_LO * (1 - IS_GT)) + // to be B_SUB_A_LO + + alu_row->avm_alu_borrow = FF(0); + FF mutated_res_lo = + alu_row->avm_alu_b_lo - alu_row->avm_alu_a_lo + alu_row->avm_alu_borrow * (uint256_t(1) << 128); + FF mutated_res_hi = alu_row->avm_alu_b_hi - alu_row->avm_alu_a_hi - alu_row->avm_alu_borrow; + alu_row->avm_alu_res_lo = mutated_res_lo; + alu_row->avm_alu_res_hi = mutated_res_hi; + // For each subsequent row that involve the range check, we need to update the shifted values + auto next_row = alu_row + 1; + next_row->avm_alu_p_sub_b_lo = mutated_res_lo; + next_row->avm_alu_p_sub_b_hi = mutated_res_hi; + + next_row = alu_row + 2; + next_row->avm_alu_p_sub_a_lo = mutated_res_lo; + next_row->avm_alu_p_sub_a_hi = mutated_res_hi; + next_row = alu_row + 3; + + next_row->avm_alu_b_lo = mutated_res_lo; + next_row->avm_alu_b_hi = mutated_res_hi; + + auto final_row = alu_row + 4; + final_row->avm_alu_a_lo = mutated_res_lo; + final_row->avm_alu_a_hi = mutated_res_hi; + + uint256_t mutated_res_lo_u256 = mutated_res_lo; + + // The final row contains the mutated res_x values at the a_x slots that will be range check. + // To prevent a trivial range check failure, we need to update the lookup counts in the memory + + // Find the main row where the old u8 value in the first register is looked up + auto lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [final_row](Row r) { + return r.avm_main_clk == final_row->avm_alu_u8_r0 && r.avm_main_sel_rng_8 == FF(1); + }); + // Decrement the counter + lookup_row->lookup_u8_0_counts = lookup_row->lookup_u8_0_counts - 1; + + // Assign the new u8 value that goes into the first slice register. + final_row->avm_alu_u8_r0 = static_cast(mutated_res_lo_u256); + // Find the main row where the new u8 value in the first register WILL be looked up + auto new_lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [final_row](Row r) { + return r.avm_main_clk == final_row->avm_alu_u8_r0 && r.avm_main_sel_rng_8 == FF(1); + }); + // Increment the counter + new_lookup_row->lookup_u8_0_counts = new_lookup_row->lookup_u8_0_counts + 1; + mutated_res_lo_u256 >>= 8; + + // Do the same for the second u8 register + lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [final_row](Row r) { + return r.avm_main_clk == final_row->avm_alu_u8_r1 && r.avm_main_sel_rng_8 == FF(1); + }); + lookup_row->lookup_u8_1_counts = lookup_row->lookup_u8_1_counts - 1; + + final_row->avm_alu_u8_r1 = static_cast(mutated_res_lo_u256); + new_lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [final_row](Row r) { + return r.avm_main_clk == final_row->avm_alu_u8_r1 && r.avm_main_sel_rng_8 == FF(1); + }); + new_lookup_row->lookup_u8_1_counts = new_lookup_row->lookup_u8_1_counts + 1; + mutated_res_lo_u256 >>= 8; + // Set the remaining 112 bits to the first u16 register to trigger the overflow + final_row->avm_alu_u16_r0 = mutated_res_lo_u256; + break; } return trace; } class AvmCmpNegativeTestsLT : public AvmCmpTests, public testing::WithParamInterface> {}; +class AvmCmpNegativeTestsLTE : public AvmCmpTests, + public testing::WithParamInterface> {}; TEST_P(AvmCmpNegativeTestsLT, ParamTest) { @@ -219,11 +300,31 @@ TEST_P(AvmCmpNegativeTestsLT, ParamTest) trace_builder.return_op(0, 0, 0); auto trace = trace_builder.finalize(); std::function&& select_row = [](Row r) { return r.avm_main_sel_op_lt == FF(1); }; - trace = gen_mutated_trace_cmp(trace, std::move(select_row), failure_mode); + trace = gen_mutated_trace_cmp(trace, std::move(select_row), output, failure_mode); + // validate_trace_proof(std::move(trace)); EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), failure_string); } INSTANTIATE_TEST_SUITE_P(AvmCmpNegativeTests, AvmCmpNegativeTestsLT, testing::Combine(testing::ValuesIn(cmp_failures), testing::ValuesIn(neg_test_lt))); +TEST_P(AvmCmpNegativeTestsLTE, ParamTest) +{ + const auto [failure, params] = GetParam(); + const auto [failure_string, failure_mode] = failure; + const auto [a, b, output] = params; + auto trace_builder = avm_trace::AvmTraceBuilder(); + trace_builder.calldata_copy(0, 0, 3, 0, std::vector{ a, b, output }); + trace_builder.op_lte(0, 0, 1, 2, AvmMemoryTag::FF); // [1,254,0,0,....] + trace_builder.return_op(0, 0, 0); + auto trace = trace_builder.finalize(); + std::function&& select_row = [](Row r) { return r.avm_main_sel_op_lte == FF(1); }; + trace = gen_mutated_trace_cmp(trace, std::move(select_row), output, failure_mode); + // validate_trace_proof(std::move(trace)); + EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), failure_string); +} + +INSTANTIATE_TEST_SUITE_P(AvmCmpNegativeTests, + AvmCmpNegativeTestsLTE, + testing::Combine(testing::ValuesIn(cmp_failures), testing::ValuesIn(neg_test_lt))); } // namespace tests_avm From ef308ad4ac5c0cca2ea2cc7a89734fc548494ab4 Mon Sep 17 00:00:00 2001 From: IlyasRidhuan Date: Wed, 10 Apr 2024 08:55:03 +0000 Subject: [PATCH 12/18] chore: clean up comments --- barretenberg/cpp/pil/avm/avm_alu.pil | 3 +- .../relations/generated/avm/avm_alu.hpp | 56 +++++++++---------- .../vm/tests/avm_comparison.test.cpp | 21 +------ 3 files changed, 31 insertions(+), 49 deletions(-) diff --git a/barretenberg/cpp/pil/avm/avm_alu.pil b/barretenberg/cpp/pil/avm/avm_alu.pil index 7492dd32b6ff..70697cc12a0b 100644 --- a/barretenberg/cpp/pil/avm/avm_alu.pil +++ b/barretenberg/cpp/pil/avm/avm_alu.pil @@ -328,7 +328,7 @@ namespace avm_alu(256); pol commit p_b_borrow; p_b_borrow * (1 - p_b_borrow) = 0; - // Check that decomposition of b into lo and hi limbs do not overflow p. + // Check that decomposition of b into lo and hi limbs do not overflow/underflow p. // This is achieved by checking (p_lo > b_lo && p_hi >= bhi) || (p_lo <= b_lo && p_hi > b_hi) // First condition is if borrow = 0, second condition is if borrow = 1; #[SUB_LO_2] @@ -462,6 +462,7 @@ namespace avm_alu(256); // TODO: there is an optimisation where we are able to do 1 less range check as the range check on // P_SUB_B is implied by the other range checks. // Briefly: given a > b and p > a and p > a - b - 1, it is sufficient confirm that p > b without a range check + // To accomplish this we would likely change the order of the range_check so we can skip p_sub_b #[SHIFT_RELS] (a_lo' - b_lo) * rng_chk_sel' = 0; (a_hi' - b_hi) * rng_chk_sel' = 0; 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 aabdb74b155a..4772b8c38e39 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_alu.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_alu.hpp @@ -155,25 +155,25 @@ inline std::string get_relation_label_avm_alu(int index) return "CTR_NON_ZERO_REL"; case 37: - return "LOWER_CMP_RNG_CHK"; + return "RNG_CHK_LOOKUP_SELECTOR"; case 38: - return "UPPER_CMP_RNG_CHK"; + return "LOWER_CMP_RNG_CHK"; case 39: + return "UPPER_CMP_RNG_CHK"; + + case 40: return "SHIFT_RELS"; - case 41: + case 42: return "SHIFT_RELS_1"; - case 43: + case 44: return "SHIFT_RELS_2"; - case 45: + case 46: return "SHIFT_RELS_3"; - - case 47: - return "RNG_CHK_LOOKUP_SELECTOR"; } return std::to_string(index); } @@ -184,7 +184,7 @@ template class avm_aluImpl { static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 5, 5, 5, 6, 6, 8, 3, 4, 4, 5, 4, 4, - 3, 4, 3, 3, 4, 3, 6, 5, 3, 3, 3, 3, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 2, + 3, 4, 3, 3, 4, 3, 6, 5, 3, 3, 3, 3, 4, 2, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, }; template @@ -617,6 +617,14 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(37); + auto tmp = (avm_alu_rng_chk_lookup_selector - (avm_alu_cmp_sel + avm_alu_rng_chk_sel)); + tmp *= scaling_factor; + std::get<37>(evals) += tmp; + } + // Contribution 38 + { + Avm_DECLARE_VIEWS(38); + auto tmp = (avm_alu_a_lo - (((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + (avm_alu_u16_r1 * FF(4294967296UL))) + @@ -627,11 +635,11 @@ template class avm_aluImpl { (avm_alu_u16_r6 * FF(uint256_t{ 0LLU, 281474976710656LLU, 0LLU, 0LLU }))) * (avm_alu_rng_chk_sel + avm_alu_cmp_sel))); tmp *= scaling_factor; - std::get<37>(evals) += tmp; + std::get<38>(evals) += tmp; } - // Contribution 38 + // Contribution 39 { - Avm_DECLARE_VIEWS(38); + Avm_DECLARE_VIEWS(39); auto tmp = (avm_alu_a_hi - ((((((((avm_alu_u16_r7 + (avm_alu_u16_r8 * FF(65536))) + (avm_alu_u16_r9 * FF(4294967296UL))) + @@ -642,21 +650,13 @@ template class avm_aluImpl { (avm_alu_u16_r14 * FF(uint256_t{ 0LLU, 281474976710656LLU, 0LLU, 0LLU }))) * (avm_alu_rng_chk_sel + avm_alu_cmp_sel))); tmp *= scaling_factor; - std::get<38>(evals) += tmp; - } - // Contribution 39 - { - Avm_DECLARE_VIEWS(39); - - auto tmp = ((avm_alu_a_lo_shift - avm_alu_b_lo) * avm_alu_rng_chk_sel_shift); - tmp *= scaling_factor; std::get<39>(evals) += tmp; } // Contribution 40 { Avm_DECLARE_VIEWS(40); - auto tmp = ((avm_alu_a_hi_shift - avm_alu_b_hi) * avm_alu_rng_chk_sel_shift); + auto tmp = ((avm_alu_a_lo_shift - avm_alu_b_lo) * avm_alu_rng_chk_sel_shift); tmp *= scaling_factor; std::get<40>(evals) += tmp; } @@ -664,7 +664,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(41); - auto tmp = ((avm_alu_b_lo_shift - avm_alu_p_sub_a_lo) * avm_alu_rng_chk_sel_shift); + auto tmp = ((avm_alu_a_hi_shift - avm_alu_b_hi) * avm_alu_rng_chk_sel_shift); tmp *= scaling_factor; std::get<41>(evals) += tmp; } @@ -672,7 +672,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(42); - auto tmp = ((avm_alu_b_hi_shift - avm_alu_p_sub_a_hi) * avm_alu_rng_chk_sel_shift); + auto tmp = ((avm_alu_b_lo_shift - avm_alu_p_sub_a_lo) * avm_alu_rng_chk_sel_shift); tmp *= scaling_factor; std::get<42>(evals) += tmp; } @@ -680,7 +680,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(43); - auto tmp = ((avm_alu_p_sub_a_lo_shift - avm_alu_p_sub_b_lo) * avm_alu_rng_chk_sel_shift); + auto tmp = ((avm_alu_b_hi_shift - avm_alu_p_sub_a_hi) * avm_alu_rng_chk_sel_shift); tmp *= scaling_factor; std::get<43>(evals) += tmp; } @@ -688,7 +688,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(44); - auto tmp = ((avm_alu_p_sub_a_hi_shift - avm_alu_p_sub_b_hi) * avm_alu_rng_chk_sel_shift); + auto tmp = ((avm_alu_p_sub_a_lo_shift - avm_alu_p_sub_b_lo) * avm_alu_rng_chk_sel_shift); tmp *= scaling_factor; std::get<44>(evals) += tmp; } @@ -696,7 +696,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(45); - auto tmp = ((avm_alu_p_sub_b_lo_shift - avm_alu_res_lo) * avm_alu_rng_chk_sel_shift); + auto tmp = ((avm_alu_p_sub_a_hi_shift - avm_alu_p_sub_b_hi) * avm_alu_rng_chk_sel_shift); tmp *= scaling_factor; std::get<45>(evals) += tmp; } @@ -704,7 +704,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(46); - auto tmp = ((avm_alu_p_sub_b_hi_shift - avm_alu_res_hi) * avm_alu_rng_chk_sel_shift); + auto tmp = ((avm_alu_p_sub_b_lo_shift - avm_alu_res_lo) * avm_alu_rng_chk_sel_shift); tmp *= scaling_factor; std::get<46>(evals) += tmp; } @@ -712,7 +712,7 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(47); - auto tmp = (avm_alu_rng_chk_lookup_selector - (avm_alu_cmp_sel + avm_alu_rng_chk_sel)); + auto tmp = ((avm_alu_p_sub_b_hi_shift - avm_alu_res_hi) * avm_alu_rng_chk_sel_shift); tmp *= scaling_factor; std::get<47>(evals) += tmp; } diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_comparison.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_comparison.test.cpp index 1e10d3a85d7e..b0cda76b8fce 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_comparison.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_comparison.test.cpp @@ -296,7 +296,7 @@ TEST_P(AvmCmpNegativeTestsLT, ParamTest) const auto [a, b, output] = params; auto trace_builder = avm_trace::AvmTraceBuilder(); trace_builder.calldata_copy(0, 0, 3, 0, std::vector{ a, b, output }); - trace_builder.op_lt(0, 0, 1, 2, AvmMemoryTag::FF); // [1,254,0,0,....] + trace_builder.op_lt(0, 0, 1, 2, AvmMemoryTag::FF); trace_builder.return_op(0, 0, 0); auto trace = trace_builder.finalize(); std::function&& select_row = [](Row r) { return r.avm_main_sel_op_lt == FF(1); }; @@ -308,23 +308,4 @@ TEST_P(AvmCmpNegativeTestsLT, ParamTest) INSTANTIATE_TEST_SUITE_P(AvmCmpNegativeTests, AvmCmpNegativeTestsLT, testing::Combine(testing::ValuesIn(cmp_failures), testing::ValuesIn(neg_test_lt))); -TEST_P(AvmCmpNegativeTestsLTE, ParamTest) -{ - const auto [failure, params] = GetParam(); - const auto [failure_string, failure_mode] = failure; - const auto [a, b, output] = params; - auto trace_builder = avm_trace::AvmTraceBuilder(); - trace_builder.calldata_copy(0, 0, 3, 0, std::vector{ a, b, output }); - trace_builder.op_lte(0, 0, 1, 2, AvmMemoryTag::FF); // [1,254,0,0,....] - trace_builder.return_op(0, 0, 0); - auto trace = trace_builder.finalize(); - std::function&& select_row = [](Row r) { return r.avm_main_sel_op_lte == FF(1); }; - trace = gen_mutated_trace_cmp(trace, std::move(select_row), output, failure_mode); - // validate_trace_proof(std::move(trace)); - EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), failure_string); -} - -INSTANTIATE_TEST_SUITE_P(AvmCmpNegativeTests, - AvmCmpNegativeTestsLTE, - testing::Combine(testing::ValuesIn(cmp_failures), testing::ValuesIn(neg_test_lt))); } // namespace tests_avm From c8727eaca6796599eb9ccb7fbf72b1a28af43989 Mon Sep 17 00:00:00 2001 From: IlyasRidhuan Date: Wed, 10 Apr 2024 09:25:57 +0000 Subject: [PATCH 13/18] chore: rebase --- barretenberg/cpp/pil/avm/avm_main.pil | 2 +- .../relations/generated/avm/avm_alu.hpp | 101 +++--- .../relations/generated/avm/avm_main.hpp | 2 +- .../generated/avm/incl_main_tag_err.hpp | 2 +- .../generated/avm/incl_mem_tag_err.hpp | 2 +- .../generated/avm/lookup_byte_lengths.hpp | 2 +- .../generated/avm/lookup_byte_operations.hpp | 2 +- .../vm/avm_trace/avm_alu_trace.cpp | 8 +- .../barretenberg/vm/avm_trace/avm_helper.cpp | 11 - .../vm/generated/avm_circuit_builder.hpp | 10 - .../vm/generated/avm_composer.cpp | 2 +- .../vm/generated/avm_composer.hpp | 2 +- .../barretenberg/vm/generated/avm_flavor.hpp | 128 +------ .../barretenberg/vm/generated/avm_prover.cpp | 320 +----------------- .../barretenberg/vm/generated/avm_prover.hpp | 2 - .../vm/generated/avm_verifier.cpp | 41 --- .../vm/tests/avm_arithmetic.test.cpp | 12 +- 17 files changed, 79 insertions(+), 570 deletions(-) diff --git a/barretenberg/cpp/pil/avm/avm_main.pil b/barretenberg/cpp/pil/avm/avm_main.pil index 3dc4144bb489..92fa0f4fa833 100644 --- a/barretenberg/cpp/pil/avm/avm_main.pil +++ b/barretenberg/cpp/pil/avm/avm_main.pil @@ -160,7 +160,7 @@ namespace avm_main(256); //====== COMPARATOR OPCODES CONSTRAINTS ===================================== // Enforce that the tag for the ouput of EQ opcode is u8 (i.e. equal to 1). - #[EQ_OUTPUT_U8] + #[OUTPUT_U8] (sel_op_eq + sel_op_lte + sel_op_lt) * (w_in_tag - 1) = 0; // Relation for division over the finite field 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 4772b8c38e39..289808621ae4 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_alu.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_alu.hpp @@ -292,14 +292,14 @@ template class avm_aluImpl { ((((((((((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{ 0LLU, 1LLU, 0LLU, 0LLU }))) + - (avm_alu_u16_r4 * FF(uint256_t{ 0LLU, 65536LLU, 0LLU, 0LLU }))) + - (avm_alu_u16_r5 * FF(uint256_t{ 0LLU, 4294967296LLU, 0LLU, 0LLU }))) + - (avm_alu_u16_r6 * FF(uint256_t{ 0LLU, 281474976710656LLU, 0LLU, 0LLU }))) - + (avm_alu_u16_r3 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + + (avm_alu_u16_r4 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + + (avm_alu_u16_r5 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + + (avm_alu_u16_r6 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }))) - avm_alu_ia) + (avm_alu_ff_tag * avm_alu_ic))) + ((avm_alu_op_add - avm_alu_op_sub) * - ((avm_alu_cf * FF(uint256_t{ 0LLU, 0LLU, 1LLU, 0LLU })) - avm_alu_ib))); + ((avm_alu_cf * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL })) - avm_alu_ib))); tmp *= scaling_factor; std::get<10>(evals) += tmp; } @@ -320,10 +320,10 @@ template class avm_aluImpl { ((((((((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{ 0LLU, 1LLU, 0LLU, 0LLU }))) + - (avm_alu_u16_r4 * FF(uint256_t{ 0LLU, 65536LLU, 0LLU, 0LLU }))) + - (avm_alu_u16_r5 * FF(uint256_t{ 0LLU, 4294967296LLU, 0LLU, 0LLU }))) + - (avm_alu_u16_r6 * FF(uint256_t{ 0LLU, 281474976710656LLU, 0LLU, 0LLU }))))) + + (avm_alu_u16_r3 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + + (avm_alu_u16_r4 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + + (avm_alu_u16_r5 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + + (avm_alu_u16_r6 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }))))) + (avm_alu_ff_tag * avm_alu_ia)) - avm_alu_ic)) + ((avm_alu_ff_tag * (avm_alu_op_add - avm_alu_op_sub)) * avm_alu_ib)); @@ -346,10 +346,10 @@ template class avm_aluImpl { (((((((((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{ 0LLU, 1LLU, 0LLU, 0LLU }))) + - (avm_alu_u16_r4 * FF(uint256_t{ 0LLU, 65536LLU, 0LLU, 0LLU }))) + - (avm_alu_u16_r5 * FF(uint256_t{ 0LLU, 4294967296LLU, 0LLU, 0LLU }))) + - (avm_alu_u16_r6 * FF(uint256_t{ 0LLU, 281474976710656LLU, 0LLU, 0LLU }))) - + (avm_alu_u16_r3 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + + (avm_alu_u16_r4 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + + (avm_alu_u16_r5 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + + (avm_alu_u16_r6 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }))) - (avm_alu_ia * avm_alu_ib))); tmp *= scaling_factor; std::get<13>(evals) += tmp; @@ -379,7 +379,7 @@ template class avm_aluImpl { (avm_alu_u16_r3 * FF(281474976710656UL))) + ((((avm_alu_u16_r4 + (avm_alu_u16_r5 * FF(65536))) + (avm_alu_u16_r6 * FF(4294967296UL))) + (avm_alu_u16_r7 * FF(281474976710656UL))) * - FF(uint256_t{ 0LLU, 1LLU, 0LLU, 0LLU }))) - + FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) - avm_alu_ia)); tmp *= scaling_factor; std::get<15>(evals) += tmp; @@ -395,7 +395,7 @@ template class avm_aluImpl { ((((avm_alu_u16_r4_shift + (avm_alu_u16_r5_shift * FF(65536))) + (avm_alu_u16_r6_shift * FF(4294967296UL))) + (avm_alu_u16_r7_shift * FF(281474976710656UL))) * - FF(uint256_t{ 0LLU, 1LLU, 0LLU, 0LLU }))) - + FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) - avm_alu_ib)); tmp *= scaling_factor; std::get<16>(evals) += tmp; @@ -413,9 +413,9 @@ template class avm_aluImpl { (((avm_alu_u16_r4_shift + (avm_alu_u16_r5_shift * FF(65536))) + (avm_alu_u16_r6_shift * FF(4294967296UL))) + (avm_alu_u16_r7_shift * FF(281474976710656UL)))) * - FF(uint256_t{ 0LLU, 1LLU, 0LLU, 0LLU }))) - - (((avm_alu_cf * FF(uint256_t{ 0LLU, 1LLU, 0LLU, 0LLU })) + avm_alu_u64_r0) * - FF(uint256_t{ 0LLU, 0LLU, 1LLU, 0LLU }))) - + FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) - + (((avm_alu_cf * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL })) + avm_alu_u64_r0) * + FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) - avm_alu_ic)); tmp *= scaling_factor; std::get<17>(evals) += tmp; @@ -435,8 +435,8 @@ template class avm_aluImpl { 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{ 0LLU, 1LLU, 0LLU, 0LLU }))) + - (avm_alu_u128_tag * FF(uint256_t{ 0LLU, 0LLU, 1LLU, 0LLU }))) - + (avm_alu_u64_tag * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + + (avm_alu_u128_tag * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) - FF(1)))); tmp *= scaling_factor; std::get<19>(evals) += tmp; @@ -466,7 +466,7 @@ template class avm_aluImpl { Avm_DECLARE_VIEWS(22); auto tmp = (((avm_alu_op_lt * avm_alu_ib) + (avm_alu_op_lte * avm_alu_ia)) - - ((avm_alu_a_lo + (avm_alu_a_hi * FF(uint256_t{ 0LLU, 0LLU, 1LLU, 0LLU }))) * avm_alu_cmp_sel)); + ((avm_alu_a_lo + (avm_alu_a_hi * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) * avm_alu_cmp_sel)); tmp *= scaling_factor; std::get<22>(evals) += tmp; } @@ -475,7 +475,7 @@ template class avm_aluImpl { Avm_DECLARE_VIEWS(23); auto tmp = (((avm_alu_op_lt * avm_alu_ia) + (avm_alu_op_lte * avm_alu_ib)) - - ((avm_alu_b_lo + (avm_alu_b_hi * FF(uint256_t{ 0LLU, 0LLU, 1LLU, 0LLU }))) * avm_alu_cmp_sel)); + ((avm_alu_b_lo + (avm_alu_b_hi * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) * avm_alu_cmp_sel)); tmp *= scaling_factor; std::get<23>(evals) += tmp; } @@ -491,11 +491,10 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(25); - auto tmp = - ((avm_alu_p_sub_a_lo - - ((-avm_alu_a_lo + FF(uint256_t{ 4891460686036598784LLU, 2896914383306846353LLU, 0LLU, 0LLU })) + - (avm_alu_p_a_borrow * FF(uint256_t{ 0LLU, 0LLU, 1LLU, 0LLU })))) * - avm_alu_cmp_sel); + auto tmp = ((avm_alu_p_sub_a_lo - + ((-avm_alu_a_lo + FF(uint256_t{ 4891460686036598784UL, 2896914383306846353UL, 0UL, 0UL })) + + (avm_alu_p_a_borrow * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL })))) * + avm_alu_cmp_sel); tmp *= scaling_factor; std::get<25>(evals) += tmp; } @@ -503,11 +502,10 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(26); - auto tmp = - ((avm_alu_p_sub_a_hi - - ((-avm_alu_a_hi + FF(uint256_t{ 13281191951274694749LLU, 3486998266802970665LLU, 0LLU, 0LLU })) - - avm_alu_p_a_borrow)) * - avm_alu_cmp_sel); + auto tmp = ((avm_alu_p_sub_a_hi - + ((-avm_alu_a_hi + FF(uint256_t{ 13281191951274694749UL, 3486998266802970665UL, 0UL, 0UL })) - + avm_alu_p_a_borrow)) * + avm_alu_cmp_sel); tmp *= scaling_factor; std::get<26>(evals) += tmp; } @@ -523,11 +521,10 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(28); - auto tmp = - ((avm_alu_p_sub_b_lo - - ((-avm_alu_b_lo + FF(uint256_t{ 4891460686036598784LLU, 2896914383306846353LLU, 0LLU, 0LLU })) + - (avm_alu_p_b_borrow * FF(uint256_t{ 0LLU, 0LLU, 1LLU, 0LLU })))) * - avm_alu_cmp_sel); + auto tmp = ((avm_alu_p_sub_b_lo - + ((-avm_alu_b_lo + FF(uint256_t{ 4891460686036598784UL, 2896914383306846353UL, 0UL, 0UL })) + + (avm_alu_p_b_borrow * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL })))) * + avm_alu_cmp_sel); tmp *= scaling_factor; std::get<28>(evals) += tmp; } @@ -535,11 +532,10 @@ template class avm_aluImpl { { Avm_DECLARE_VIEWS(29); - auto tmp = - ((avm_alu_p_sub_b_hi - - ((-avm_alu_b_hi + FF(uint256_t{ 13281191951274694749LLU, 3486998266802970665LLU, 0LLU, 0LLU })) - - avm_alu_p_b_borrow)) * - avm_alu_cmp_sel); + auto tmp = ((avm_alu_p_sub_b_hi - + ((-avm_alu_b_hi + FF(uint256_t{ 13281191951274694749UL, 3486998266802970665UL, 0UL, 0UL })) - + avm_alu_p_b_borrow)) * + avm_alu_cmp_sel); tmp *= scaling_factor; std::get<29>(evals) += tmp; } @@ -549,10 +545,9 @@ template class avm_aluImpl { auto tmp = ((avm_alu_res_lo - - (((((avm_alu_a_lo - avm_alu_b_lo) - FF(1)) + - (avm_alu_borrow * FF(uint256_t{ 0LLU, 0LLU, 1LLU, 0LLU }))) * + (((((avm_alu_a_lo - avm_alu_b_lo) - FF(1)) + (avm_alu_borrow * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) * ((avm_alu_op_lt * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_op_lte))) + - (((avm_alu_b_lo - avm_alu_a_lo) + (avm_alu_borrow * FF(uint256_t{ 0LLU, 0LLU, 1LLU, 0LLU }))) * + (((avm_alu_b_lo - avm_alu_a_lo) + (avm_alu_borrow * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) * (-((avm_alu_op_lt * avm_alu_ic) + ((-avm_alu_ic + FF(1)) * avm_alu_op_lte)) + FF(1))))) * avm_alu_cmp_sel); tmp *= scaling_factor; @@ -629,10 +624,10 @@ template class avm_aluImpl { (avm_alu_a_lo - (((((((((avm_alu_u8_r0 + (avm_alu_u8_r1 * FF(256))) + (avm_alu_u16_r0 * FF(65536))) + (avm_alu_u16_r1 * FF(4294967296UL))) + (avm_alu_u16_r2 * FF(281474976710656UL))) + - (avm_alu_u16_r3 * FF(uint256_t{ 0LLU, 1LLU, 0LLU, 0LLU }))) + - (avm_alu_u16_r4 * FF(uint256_t{ 0LLU, 65536LLU, 0LLU, 0LLU }))) + - (avm_alu_u16_r5 * FF(uint256_t{ 0LLU, 4294967296LLU, 0LLU, 0LLU }))) + - (avm_alu_u16_r6 * FF(uint256_t{ 0LLU, 281474976710656LLU, 0LLU, 0LLU }))) * + (avm_alu_u16_r3 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + + (avm_alu_u16_r4 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + + (avm_alu_u16_r5 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + + (avm_alu_u16_r6 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }))) * (avm_alu_rng_chk_sel + avm_alu_cmp_sel))); tmp *= scaling_factor; std::get<38>(evals) += tmp; @@ -644,10 +639,10 @@ template class avm_aluImpl { auto tmp = (avm_alu_a_hi - ((((((((avm_alu_u16_r7 + (avm_alu_u16_r8 * FF(65536))) + (avm_alu_u16_r9 * FF(4294967296UL))) + (avm_alu_u16_r10 * FF(281474976710656UL))) + - (avm_alu_u16_r11 * FF(uint256_t{ 0LLU, 1LLU, 0LLU, 0LLU }))) + - (avm_alu_u16_r12 * FF(uint256_t{ 0LLU, 65536LLU, 0LLU, 0LLU }))) + - (avm_alu_u16_r13 * FF(uint256_t{ 0LLU, 4294967296LLU, 0LLU, 0LLU }))) + - (avm_alu_u16_r14 * FF(uint256_t{ 0LLU, 281474976710656LLU, 0LLU, 0LLU }))) * + (avm_alu_u16_r11 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + + (avm_alu_u16_r12 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + + (avm_alu_u16_r13 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + + (avm_alu_u16_r14 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL }))) * (avm_alu_rng_chk_sel + avm_alu_cmp_sel))); tmp *= scaling_factor; std::get<39>(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 e6fecbb3c1f4..b3ae090ccdf3 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_main.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_main.hpp @@ -56,7 +56,7 @@ inline std::string get_relation_label_avm_main(int index) { switch (index) { case 27: - return "EQ_OUTPUT_U8"; + return "OUTPUT_U8"; case 28: return "SUBOP_DIVISION_FF"; diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_main_tag_err.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_main_tag_err.hpp index cfb4885c4b53..01e8335fd7ef 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_main_tag_err.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_main_tag_err.hpp @@ -60,7 +60,7 @@ class incl_main_tag_err_lookup_settings { * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed * */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; /** * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_mem_tag_err.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_mem_tag_err.hpp index 4055ceb7951a..94b436580592 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_mem_tag_err.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_mem_tag_err.hpp @@ -60,7 +60,7 @@ class incl_mem_tag_err_lookup_settings { * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed * */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; /** * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_lengths.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_lengths.hpp index 66268991c7c9..4c5a6bd0d48e 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_lengths.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_lengths.hpp @@ -60,7 +60,7 @@ class lookup_byte_lengths_lookup_settings { * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed * */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; /** * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_operations.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_operations.hpp index baf2995fcb85..92874d3d134a 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_operations.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_operations.hpp @@ -60,7 +60,7 @@ class lookup_byte_operations_lookup_settings { * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed * */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; /** * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.cpp index 2cf5c96e01e4..469242154061 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.cpp @@ -570,18 +570,16 @@ FF AvmAluTraceBuilder::op_lt(FF const& a, FF const& b, AvmMemoryTag in_tag, uint // Note: This is counter-intuitive, to show that a < b we actually show that b > a // The subtlely is here that the circuit is designed as a GT(x,y) circuit, therefor we swap the inputs a & b - FF circuit_input_a = b; - FF circuit_input_b = a; // Get the decomposition of b auto [a_lo, a_hi] = decompose(b); // Get the decomposition of a auto [b_lo, b_hi] = decompose(a); // Get the decomposition of p - a and p - b **remember that we swap the inputs** // Note that a valid witness here is ONLY that p > a and p > b - auto [p_sub_a_lo, p_sub_a_hi, p_a_borrow] = gt_witness(FF::modulus, circuit_input_a); - auto [p_sub_b_lo, p_sub_b_hi, p_b_borrow] = gt_witness(FF::modulus, circuit_input_b); + auto [p_sub_a_lo, p_sub_a_hi, p_a_borrow] = gt_witness(FF::modulus, b); + auto [p_sub_b_lo, p_sub_b_hi, p_b_borrow] = gt_witness(FF::modulus, a); // We either generate a witness that a <= b or a > b (its validity depends on the value of c) - auto [r_lo, r_hi, borrow] = gt_or_lte_witness(circuit_input_a, circuit_input_b); + auto [r_lo, r_hi, borrow] = gt_or_lte_witness(b, a); // The vector of limbs that are used in the GT circuit and that are range checked std::vector hi_lo_limbs = { a_lo, a_hi, b_lo, b_hi, p_sub_a_lo, diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp index fc74537965fb..71bc1b292aea 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp @@ -45,19 +45,9 @@ void log_avm_trace(std::vector const& trace, size_t beg, size_t end, bool e info("alu_ia ", trace.at(i).avm_alu_ia); info("alu_ib ", trace.at(i).avm_alu_ib); info("alu_ic ", trace.at(i).avm_alu_ic); - info("alu_rng_CHECK ", trace.at(i).avm_alu_rng_chk_sel); - info("alu_rng_shift_CHECK ", trace.at(i).avm_alu_rng_chk_sel_shift); - info("alu_rng_REMAINING ", trace.at(i).avm_alu_cmp_rng_ctr); - info("alu_cmp_sel ", trace.at(i).avm_alu_cmp_sel); - info("alu_sel ", trace.at(i).avm_alu_alu_sel); - info("alu_a_lo ", trace.at(i).avm_alu_a_lo); - info("alu_a_hi ", trace.at(i).avm_alu_a_hi); - info("alu_u8_0 ", trace.at(i).avm_alu_u8_r0); - info("rng_chk_lookup_selector", trace.at(i).avm_alu_rng_chk_lookup_selector); info("=======MAIN TRACE===================================================================="); info("clk: ", trace.at(i).avm_main_clk); - info("Sel_rng_8: ", trace.at(i).avm_main_sel_rng_8); info("ia: ", trace.at(i).avm_main_ia); info("ib: ", trace.at(i).avm_main_ib); info("ic: ", trace.at(i).avm_main_ic); @@ -66,7 +56,6 @@ void log_avm_trace(std::vector const& trace, size_t beg, size_t end, bool e info("tag_err ", trace.at(i).avm_main_tag_err); info("first: ", trace.at(i).avm_main_first); info("last: ", trace.at(i).avm_main_last); - info("avm_alu_sel ", trace.at(i).avm_main_alu_sel); info("=======MEM_OP_A======================================================================"); info("mem_op_a: ", trace.at(i).avm_main_mem_op_a); 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 416c43dbb446..de873c69cb2a 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp @@ -448,9 +448,6 @@ class AvmCircuitBuilder { 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; @@ -462,14 +459,8 @@ class AvmCircuitBuilder { 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; -<<<<<<< HEAD ->>>>>>> 7a982d52c (feat: init avm cmp) -======= polys.lookup_u8_0[i] = rows[i].lookup_u8_0; polys.lookup_u8_1[i] = rows[i].lookup_u8_1; -<<<<<<< HEAD ->>>>>>> 8d38899c9 (feat: some wip) -======= polys.lookup_u16_0[i] = rows[i].lookup_u16_0; polys.lookup_u16_1[i] = rows[i].lookup_u16_1; polys.lookup_u16_2[i] = rows[i].lookup_u16_2; @@ -485,7 +476,6 @@ class AvmCircuitBuilder { polys.lookup_u16_12[i] = rows[i].lookup_u16_12; polys.lookup_u16_13[i] = rows[i].lookup_u16_13; polys.lookup_u16_14[i] = rows[i].lookup_u16_14; ->>>>>>> 760ed7310 (fix: 16_bit range checks) 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_composer.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.cpp index d923c58c1cc8..a95109f38ca3 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.cpp @@ -31,7 +31,7 @@ AvmProver AvmComposer::create_prover(CircuitConstructor& circuit_constructor) compute_witness(circuit_constructor); compute_commitment_key(circuit_constructor.get_circuit_subgroup_size()); - AvmProver output_state(proving_key, proving_key->commitment_key); + AvmProver output_state(proving_key, commitment_key); return output_state; } diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.hpp index a2f9fe68dcf5..1c072ebdf4e5 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.hpp @@ -62,7 +62,7 @@ class AvmComposer { void compute_commitment_key(size_t circuit_size) { - proving_key->commitment_key = std::make_shared(circuit_size); + commitment_key = std::make_shared(circuit_size); }; }; diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp index 6c390d9909fe..cf4a6bf7d703 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp @@ -17,10 +17,6 @@ #include "barretenberg/relations/generated/avm/avm_binary.hpp" #include "barretenberg/relations/generated/avm/avm_main.hpp" #include "barretenberg/relations/generated/avm/avm_mem.hpp" -#include "barretenberg/relations/generated/avm/incl_main_tag_err.hpp" -#include "barretenberg/relations/generated/avm/incl_mem_tag_err.hpp" -#include "barretenberg/relations/generated/avm/lookup_byte_lengths.hpp" -#include "barretenberg/relations/generated/avm/lookup_byte_operations.hpp" #include "barretenberg/relations/generated/avm/perm_main_alu.hpp" #include "barretenberg/relations/generated/avm/perm_main_bin.hpp" #include "barretenberg/relations/generated/avm/perm_main_mem_a.hpp" @@ -56,19 +52,6 @@ class AvmFlavor { // the unshifted and one for the shifted static constexpr size_t NUM_ALL_ENTITIES = 224; - using GrandProductRelations = std::tuple, - perm_main_bin_relation, - perm_main_mem_a_relation, - perm_main_mem_b_relation, - perm_main_mem_c_relation, - perm_main_mem_ind_a_relation, - perm_main_mem_ind_b_relation, - perm_main_mem_ind_c_relation, - incl_main_tag_err_relation, - incl_mem_tag_err_relation, - lookup_byte_lengths_relation, - lookup_byte_operations_relation>; - using Relations = std::tuple, Avm_vm::avm_binary, Avm_vm::avm_main, @@ -80,11 +63,7 @@ class AvmFlavor { perm_main_mem_c_relation, perm_main_mem_ind_a_relation, perm_main_mem_ind_b_relation, - perm_main_mem_ind_c_relation, - incl_main_tag_err_relation, - incl_mem_tag_err_relation, - lookup_byte_lengths_relation, - lookup_byte_operations_relation>; + perm_main_mem_ind_c_relation>; static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = compute_max_partial_relation_length(); @@ -92,7 +71,7 @@ class AvmFlavor { // random polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation // length = 3 static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH = MAX_PARTIAL_RELATION_LENGTH + 1; - static constexpr size_t NUM_RELATIONS = std::tuple_size_v; + static constexpr size_t NUM_RELATIONS = std::tuple_size::value; template using ProtogalaxyTupleOfTuplesOfUnivariates = @@ -508,6 +487,7 @@ class AvmFlavor { lookup_u16_13_counts, lookup_u16_14_counts }; }; + RefVector get_sorted_polynomials() { return {}; }; }; template class AllEntities { @@ -1215,56 +1195,9 @@ class AvmFlavor { // The plookup wires that store plookup read data. std::array get_table_column_wires() { return {}; }; - - void compute_logderivative_inverses(const RelationParameters& relation_parameters) - { - ProverPolynomials prover_polynomials = ProverPolynomials(*this); - - 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); - 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); - bb::compute_logderivative_inverse>( - prover_polynomials, relation_parameters, this->circuit_size); - bb::compute_logderivative_inverse>( - prover_polynomials, relation_parameters, this->circuit_size); - } }; - class VerificationKey : public VerificationKey_, VerifierCommitmentKey> { - public: - VerificationKey() = default; - VerificationKey(const size_t circuit_size, const size_t num_public_inputs) - : VerificationKey_(circuit_size, num_public_inputs) - {} - - VerificationKey(ProvingKey& proving_key) - { - this->pcs_verification_key = std::make_shared(); - this->circuit_size = proving_key.circuit_size; - this->log_circuit_size = numeric::get_msb(this->circuit_size); - - for (auto [polynomial, commitment] : zip_view(proving_key.get_precomputed_polynomials(), this->get_all())) { - commitment = proving_key.commitment_key->commit(polynomial); - } - } - }; + using VerificationKey = VerificationKey_, VerifierCommitmentKey>; using FoldedPolynomials = AllEntities>; @@ -1286,29 +1219,7 @@ class AvmFlavor { ProverPolynomials(ProverPolynomials&& o) noexcept = default; ProverPolynomials& operator=(ProverPolynomials&& o) noexcept = default; ~ProverPolynomials() = default; -<<<<<<< HEAD -<<<<<<< HEAD - - // NOTE: copied from goblin ultra - ProverPolynomials(ProvingKey& proving_key) - { - for (auto [prover_poly, key_poly] : zip_view(this->get_unshifted(), proving_key.get_all())) { - ASSERT(flavor_get_label(*this, prover_poly) == flavor_get_label(proving_key, key_poly)); - prover_poly = key_poly.share(); - } - for (auto [prover_poly, key_poly] : zip_view(this->get_shifted(), proving_key.get_to_be_shifted())) { - ASSERT(flavor_get_label(*this, prover_poly) == (flavor_get_label(proving_key, key_poly) + "_shift")); - prover_poly = key_poly.shifted(); - } - } - - [[nodiscard]] size_t get_polynomial_size() const { return avm_alu_alu_sel.size(); } -======= - [[nodiscard]] size_t get_polynomial_size() const { return avm_mem_clk.size(); } ->>>>>>> 7a982d52c (feat: init avm cmp) -======= [[nodiscard]] size_t get_polynomial_size() const { return avm_alu_a_hi.size(); } ->>>>>>> a43e384f0 (feat: range_chk for cmp) /** * @brief Returns the evaluations of all prover polynomials at one point on the boolean hypercube, which * represents one row in the execution trace. @@ -1348,12 +1259,6 @@ class AvmFlavor { */ using ExtendedEdges = ProverUnivariates; - /** - * @brief A container for the witness commitments. - * - */ - using WitnessCommitments = WitnessEntities; - class CommitmentLabels : public AllEntities { private: using Base = AllEntities; @@ -1671,10 +1576,6 @@ class AvmFlavor { Commitment avm_main_mem_idx_a; Commitment avm_main_mem_idx_b; Commitment avm_main_mem_idx_c; -<<<<<<< HEAD -<<<<<<< HEAD -======= ->>>>>>> a43e384f0 (feat: range_chk for cmp) Commitment avm_main_mem_op_a; Commitment avm_main_mem_op_b; Commitment avm_main_mem_op_c; @@ -1693,11 +1594,8 @@ class AvmFlavor { Commitment avm_main_sel_op_and; Commitment avm_main_sel_op_div; Commitment avm_main_sel_op_eq; -<<<<<<< HEAD -======= Commitment avm_main_sel_op_lt; Commitment avm_main_sel_op_lte; ->>>>>>> a43e384f0 (feat: range_chk for cmp) Commitment avm_main_sel_op_mul; Commitment avm_main_sel_op_not; Commitment avm_main_sel_op_or; @@ -1726,15 +1624,6 @@ class AvmFlavor { Commitment avm_mem_tag_err; Commitment avm_mem_val; Commitment avm_mem_w_in_tag; -<<<<<<< HEAD - - // Perm inverses -======= - Commitment avm_main_last; - Commitment avm_main_bin_op_id; ->>>>>>> 7a982d52c (feat: init avm cmp) -======= ->>>>>>> a43e384f0 (feat: range_chk for cmp) Commitment perm_main_alu; Commitment perm_main_bin; Commitment perm_main_mem_a; @@ -1743,20 +1632,12 @@ class AvmFlavor { Commitment perm_main_mem_ind_a; Commitment perm_main_mem_ind_b; Commitment perm_main_mem_ind_c; - // Lookup inverses Commitment lookup_byte_lengths; Commitment lookup_byte_operations; Commitment incl_main_tag_err; Commitment incl_mem_tag_err; -<<<<<<< HEAD - - // Lookup counts -======= Commitment lookup_u8_0; Commitment lookup_u8_1; -<<<<<<< HEAD ->>>>>>> 8d38899c9 (feat: some wip) -======= Commitment lookup_u16_0; Commitment lookup_u16_1; Commitment lookup_u16_2; @@ -1772,7 +1653,6 @@ class AvmFlavor { Commitment lookup_u16_12; Commitment lookup_u16_13; Commitment lookup_u16_14; ->>>>>>> 760ed7310 (fix: 16_bit range checks) 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 0bd67e09fa33..e887045bb963 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp @@ -56,315 +56,11 @@ void AvmProver::execute_preamble_round() */ void AvmProver::execute_wire_commitments_round() { - - auto labels = commitment_labels; - - witness_commitments.avm_alu_alu_sel = commitment_key->commit(key->avm_alu_alu_sel); - witness_commitments.avm_alu_cf = commitment_key->commit(key->avm_alu_cf); - witness_commitments.avm_alu_clk = commitment_key->commit(key->avm_alu_clk); - witness_commitments.avm_alu_ff_tag = commitment_key->commit(key->avm_alu_ff_tag); - witness_commitments.avm_alu_ia = commitment_key->commit(key->avm_alu_ia); - witness_commitments.avm_alu_ib = commitment_key->commit(key->avm_alu_ib); - witness_commitments.avm_alu_ic = commitment_key->commit(key->avm_alu_ic); - witness_commitments.avm_alu_in_tag = commitment_key->commit(key->avm_alu_in_tag); - witness_commitments.avm_alu_op_add = commitment_key->commit(key->avm_alu_op_add); - witness_commitments.avm_alu_op_div = commitment_key->commit(key->avm_alu_op_div); - witness_commitments.avm_alu_op_eq = commitment_key->commit(key->avm_alu_op_eq); - witness_commitments.avm_alu_op_eq_diff_inv = commitment_key->commit(key->avm_alu_op_eq_diff_inv); - witness_commitments.avm_alu_op_mul = commitment_key->commit(key->avm_alu_op_mul); - witness_commitments.avm_alu_op_not = commitment_key->commit(key->avm_alu_op_not); - witness_commitments.avm_alu_op_sub = commitment_key->commit(key->avm_alu_op_sub); - witness_commitments.avm_alu_u128_tag = commitment_key->commit(key->avm_alu_u128_tag); - witness_commitments.avm_alu_u16_r0 = commitment_key->commit(key->avm_alu_u16_r0); - witness_commitments.avm_alu_u16_r1 = commitment_key->commit(key->avm_alu_u16_r1); - witness_commitments.avm_alu_u16_r10 = commitment_key->commit(key->avm_alu_u16_r10); - witness_commitments.avm_alu_u16_r11 = commitment_key->commit(key->avm_alu_u16_r11); - witness_commitments.avm_alu_u16_r12 = commitment_key->commit(key->avm_alu_u16_r12); - witness_commitments.avm_alu_u16_r13 = commitment_key->commit(key->avm_alu_u16_r13); - witness_commitments.avm_alu_u16_r14 = commitment_key->commit(key->avm_alu_u16_r14); - witness_commitments.avm_alu_u16_r2 = commitment_key->commit(key->avm_alu_u16_r2); - witness_commitments.avm_alu_u16_r3 = commitment_key->commit(key->avm_alu_u16_r3); - witness_commitments.avm_alu_u16_r4 = commitment_key->commit(key->avm_alu_u16_r4); - witness_commitments.avm_alu_u16_r5 = commitment_key->commit(key->avm_alu_u16_r5); - witness_commitments.avm_alu_u16_r6 = commitment_key->commit(key->avm_alu_u16_r6); - witness_commitments.avm_alu_u16_r7 = commitment_key->commit(key->avm_alu_u16_r7); - witness_commitments.avm_alu_u16_r8 = commitment_key->commit(key->avm_alu_u16_r8); - witness_commitments.avm_alu_u16_r9 = commitment_key->commit(key->avm_alu_u16_r9); - witness_commitments.avm_alu_u16_tag = commitment_key->commit(key->avm_alu_u16_tag); - witness_commitments.avm_alu_u32_tag = commitment_key->commit(key->avm_alu_u32_tag); - witness_commitments.avm_alu_u64_r0 = commitment_key->commit(key->avm_alu_u64_r0); - witness_commitments.avm_alu_u64_tag = commitment_key->commit(key->avm_alu_u64_tag); - witness_commitments.avm_alu_u8_r0 = commitment_key->commit(key->avm_alu_u8_r0); - witness_commitments.avm_alu_u8_r1 = commitment_key->commit(key->avm_alu_u8_r1); - witness_commitments.avm_alu_u8_tag = commitment_key->commit(key->avm_alu_u8_tag); - witness_commitments.avm_binary_acc_ia = commitment_key->commit(key->avm_binary_acc_ia); - witness_commitments.avm_binary_acc_ib = commitment_key->commit(key->avm_binary_acc_ib); - witness_commitments.avm_binary_acc_ic = commitment_key->commit(key->avm_binary_acc_ic); - witness_commitments.avm_binary_bin_sel = commitment_key->commit(key->avm_binary_bin_sel); - witness_commitments.avm_binary_clk = commitment_key->commit(key->avm_binary_clk); - witness_commitments.avm_binary_ia_bytes = commitment_key->commit(key->avm_binary_ia_bytes); - witness_commitments.avm_binary_ib_bytes = commitment_key->commit(key->avm_binary_ib_bytes); - witness_commitments.avm_binary_ic_bytes = commitment_key->commit(key->avm_binary_ic_bytes); - witness_commitments.avm_binary_in_tag = commitment_key->commit(key->avm_binary_in_tag); - witness_commitments.avm_binary_mem_tag_ctr = commitment_key->commit(key->avm_binary_mem_tag_ctr); - witness_commitments.avm_binary_mem_tag_ctr_inv = commitment_key->commit(key->avm_binary_mem_tag_ctr_inv); - witness_commitments.avm_binary_op_id = commitment_key->commit(key->avm_binary_op_id); - witness_commitments.avm_binary_start = commitment_key->commit(key->avm_binary_start); - witness_commitments.avm_byte_lookup_bin_sel = commitment_key->commit(key->avm_byte_lookup_bin_sel); - witness_commitments.avm_byte_lookup_table_byte_lengths = - commitment_key->commit(key->avm_byte_lookup_table_byte_lengths); - witness_commitments.avm_byte_lookup_table_in_tags = commitment_key->commit(key->avm_byte_lookup_table_in_tags); - witness_commitments.avm_byte_lookup_table_input_a = commitment_key->commit(key->avm_byte_lookup_table_input_a); - witness_commitments.avm_byte_lookup_table_input_b = commitment_key->commit(key->avm_byte_lookup_table_input_b); - witness_commitments.avm_byte_lookup_table_op_id = commitment_key->commit(key->avm_byte_lookup_table_op_id); - witness_commitments.avm_byte_lookup_table_output = commitment_key->commit(key->avm_byte_lookup_table_output); - witness_commitments.avm_main_alu_sel = commitment_key->commit(key->avm_main_alu_sel); - witness_commitments.avm_main_bin_op_id = commitment_key->commit(key->avm_main_bin_op_id); - witness_commitments.avm_main_bin_sel = commitment_key->commit(key->avm_main_bin_sel); - 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_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_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_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_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_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_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_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); - witness_commitments.avm_main_sel_op_eq = commitment_key->commit(key->avm_main_sel_op_eq); - witness_commitments.avm_main_sel_op_mul = commitment_key->commit(key->avm_main_sel_op_mul); - witness_commitments.avm_main_sel_op_not = commitment_key->commit(key->avm_main_sel_op_not); - witness_commitments.avm_main_sel_op_or = commitment_key->commit(key->avm_main_sel_op_or); - witness_commitments.avm_main_sel_op_sub = commitment_key->commit(key->avm_main_sel_op_sub); - witness_commitments.avm_main_sel_op_xor = commitment_key->commit(key->avm_main_sel_op_xor); - witness_commitments.avm_main_sel_rng_16 = commitment_key->commit(key->avm_main_sel_rng_16); - witness_commitments.avm_main_sel_rng_8 = commitment_key->commit(key->avm_main_sel_rng_8); - witness_commitments.avm_main_tag_err = commitment_key->commit(key->avm_main_tag_err); - witness_commitments.avm_main_w_in_tag = commitment_key->commit(key->avm_main_w_in_tag); - witness_commitments.avm_mem_addr = commitment_key->commit(key->avm_mem_addr); - witness_commitments.avm_mem_clk = commitment_key->commit(key->avm_mem_clk); - 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_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_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_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); - witness_commitments.avm_mem_val = commitment_key->commit(key->avm_mem_val); - witness_commitments.avm_mem_w_in_tag = commitment_key->commit(key->avm_mem_w_in_tag); - - // Lookup counts - witness_commitments.lookup_byte_lengths_counts = commitment_key->commit(key->lookup_byte_lengths_counts); - witness_commitments.lookup_byte_operations_counts = commitment_key->commit(key->lookup_byte_operations_counts); - witness_commitments.incl_main_tag_err_counts = commitment_key->commit(key->incl_main_tag_err_counts); - witness_commitments.incl_mem_tag_err_counts = commitment_key->commit(key->incl_mem_tag_err_counts); - - // print some of the commitments to check they have values - - // Send all witness commitments to the verifier - transcript->send_to_verifier(labels.avm_alu_alu_sel, witness_commitments.avm_alu_alu_sel); - transcript->send_to_verifier(labels.avm_alu_cf, witness_commitments.avm_alu_cf); - transcript->send_to_verifier(labels.avm_alu_clk, witness_commitments.avm_alu_clk); - transcript->send_to_verifier(labels.avm_alu_ff_tag, witness_commitments.avm_alu_ff_tag); - transcript->send_to_verifier(labels.avm_alu_ia, witness_commitments.avm_alu_ia); - transcript->send_to_verifier(labels.avm_alu_ib, witness_commitments.avm_alu_ib); - transcript->send_to_verifier(labels.avm_alu_ic, witness_commitments.avm_alu_ic); - transcript->send_to_verifier(labels.avm_alu_in_tag, witness_commitments.avm_alu_in_tag); - transcript->send_to_verifier(labels.avm_alu_op_add, witness_commitments.avm_alu_op_add); - transcript->send_to_verifier(labels.avm_alu_op_div, witness_commitments.avm_alu_op_div); - transcript->send_to_verifier(labels.avm_alu_op_eq, witness_commitments.avm_alu_op_eq); - transcript->send_to_verifier(labels.avm_alu_op_eq_diff_inv, witness_commitments.avm_alu_op_eq_diff_inv); - transcript->send_to_verifier(labels.avm_alu_op_mul, witness_commitments.avm_alu_op_mul); - transcript->send_to_verifier(labels.avm_alu_op_not, witness_commitments.avm_alu_op_not); - transcript->send_to_verifier(labels.avm_alu_op_sub, witness_commitments.avm_alu_op_sub); - transcript->send_to_verifier(labels.avm_alu_u128_tag, witness_commitments.avm_alu_u128_tag); - transcript->send_to_verifier(labels.avm_alu_u16_r0, witness_commitments.avm_alu_u16_r0); - transcript->send_to_verifier(labels.avm_alu_u16_r1, witness_commitments.avm_alu_u16_r1); - transcript->send_to_verifier(labels.avm_alu_u16_r10, witness_commitments.avm_alu_u16_r10); - transcript->send_to_verifier(labels.avm_alu_u16_r11, witness_commitments.avm_alu_u16_r11); - transcript->send_to_verifier(labels.avm_alu_u16_r12, witness_commitments.avm_alu_u16_r12); - transcript->send_to_verifier(labels.avm_alu_u16_r13, witness_commitments.avm_alu_u16_r13); - transcript->send_to_verifier(labels.avm_alu_u16_r14, witness_commitments.avm_alu_u16_r14); - transcript->send_to_verifier(labels.avm_alu_u16_r2, witness_commitments.avm_alu_u16_r2); - transcript->send_to_verifier(labels.avm_alu_u16_r3, witness_commitments.avm_alu_u16_r3); - transcript->send_to_verifier(labels.avm_alu_u16_r4, witness_commitments.avm_alu_u16_r4); - transcript->send_to_verifier(labels.avm_alu_u16_r5, witness_commitments.avm_alu_u16_r5); - transcript->send_to_verifier(labels.avm_alu_u16_r6, witness_commitments.avm_alu_u16_r6); - transcript->send_to_verifier(labels.avm_alu_u16_r7, witness_commitments.avm_alu_u16_r7); - transcript->send_to_verifier(labels.avm_alu_u16_r8, witness_commitments.avm_alu_u16_r8); - transcript->send_to_verifier(labels.avm_alu_u16_r9, witness_commitments.avm_alu_u16_r9); - transcript->send_to_verifier(labels.avm_alu_u16_tag, witness_commitments.avm_alu_u16_tag); - transcript->send_to_verifier(labels.avm_alu_u32_tag, witness_commitments.avm_alu_u32_tag); - transcript->send_to_verifier(labels.avm_alu_u64_r0, witness_commitments.avm_alu_u64_r0); - transcript->send_to_verifier(labels.avm_alu_u64_tag, witness_commitments.avm_alu_u64_tag); - transcript->send_to_verifier(labels.avm_alu_u8_r0, witness_commitments.avm_alu_u8_r0); - transcript->send_to_verifier(labels.avm_alu_u8_r1, witness_commitments.avm_alu_u8_r1); - transcript->send_to_verifier(labels.avm_alu_u8_tag, witness_commitments.avm_alu_u8_tag); - transcript->send_to_verifier(labels.avm_binary_acc_ia, witness_commitments.avm_binary_acc_ia); - transcript->send_to_verifier(labels.avm_binary_acc_ib, witness_commitments.avm_binary_acc_ib); - transcript->send_to_verifier(labels.avm_binary_acc_ic, witness_commitments.avm_binary_acc_ic); - transcript->send_to_verifier(labels.avm_binary_bin_sel, witness_commitments.avm_binary_bin_sel); - transcript->send_to_verifier(labels.avm_binary_clk, witness_commitments.avm_binary_clk); - transcript->send_to_verifier(labels.avm_binary_ia_bytes, witness_commitments.avm_binary_ia_bytes); - transcript->send_to_verifier(labels.avm_binary_ib_bytes, witness_commitments.avm_binary_ib_bytes); - transcript->send_to_verifier(labels.avm_binary_ic_bytes, witness_commitments.avm_binary_ic_bytes); - transcript->send_to_verifier(labels.avm_binary_in_tag, witness_commitments.avm_binary_in_tag); - transcript->send_to_verifier(labels.avm_binary_mem_tag_ctr, witness_commitments.avm_binary_mem_tag_ctr); - transcript->send_to_verifier(labels.avm_binary_mem_tag_ctr_inv, witness_commitments.avm_binary_mem_tag_ctr_inv); - transcript->send_to_verifier(labels.avm_binary_op_id, witness_commitments.avm_binary_op_id); - transcript->send_to_verifier(labels.avm_binary_start, witness_commitments.avm_binary_start); - transcript->send_to_verifier(labels.avm_byte_lookup_bin_sel, witness_commitments.avm_byte_lookup_bin_sel); - transcript->send_to_verifier(labels.avm_byte_lookup_table_byte_lengths, - witness_commitments.avm_byte_lookup_table_byte_lengths); - transcript->send_to_verifier(labels.avm_byte_lookup_table_in_tags, - witness_commitments.avm_byte_lookup_table_in_tags); - transcript->send_to_verifier(labels.avm_byte_lookup_table_input_a, - witness_commitments.avm_byte_lookup_table_input_a); - transcript->send_to_verifier(labels.avm_byte_lookup_table_input_b, - witness_commitments.avm_byte_lookup_table_input_b); - transcript->send_to_verifier(labels.avm_byte_lookup_table_op_id, witness_commitments.avm_byte_lookup_table_op_id); - transcript->send_to_verifier(labels.avm_byte_lookup_table_output, witness_commitments.avm_byte_lookup_table_output); - transcript->send_to_verifier(labels.avm_main_alu_sel, witness_commitments.avm_main_alu_sel); - transcript->send_to_verifier(labels.avm_main_bin_op_id, witness_commitments.avm_main_bin_op_id); - transcript->send_to_verifier(labels.avm_main_bin_sel, witness_commitments.avm_main_bin_sel); - transcript->send_to_verifier(labels.avm_main_ia, witness_commitments.avm_main_ia); - transcript->send_to_verifier(labels.avm_main_ib, witness_commitments.avm_main_ib); - transcript->send_to_verifier(labels.avm_main_ic, witness_commitments.avm_main_ic); - transcript->send_to_verifier(labels.avm_main_ind_a, witness_commitments.avm_main_ind_a); - transcript->send_to_verifier(labels.avm_main_ind_b, witness_commitments.avm_main_ind_b); - transcript->send_to_verifier(labels.avm_main_ind_c, witness_commitments.avm_main_ind_c); - transcript->send_to_verifier(labels.avm_main_ind_op_a, witness_commitments.avm_main_ind_op_a); - transcript->send_to_verifier(labels.avm_main_ind_op_b, witness_commitments.avm_main_ind_op_b); - transcript->send_to_verifier(labels.avm_main_ind_op_c, witness_commitments.avm_main_ind_op_c); - transcript->send_to_verifier(labels.avm_main_internal_return_ptr, witness_commitments.avm_main_internal_return_ptr); - transcript->send_to_verifier(labels.avm_main_inv, witness_commitments.avm_main_inv); - transcript->send_to_verifier(labels.avm_main_last, witness_commitments.avm_main_last); - transcript->send_to_verifier(labels.avm_main_mem_idx_a, witness_commitments.avm_main_mem_idx_a); - transcript->send_to_verifier(labels.avm_main_mem_idx_b, witness_commitments.avm_main_mem_idx_b); - transcript->send_to_verifier(labels.avm_main_mem_idx_c, witness_commitments.avm_main_mem_idx_c); - transcript->send_to_verifier(labels.avm_main_mem_op_a, witness_commitments.avm_main_mem_op_a); - transcript->send_to_verifier(labels.avm_main_mem_op_b, witness_commitments.avm_main_mem_op_b); - transcript->send_to_verifier(labels.avm_main_mem_op_c, witness_commitments.avm_main_mem_op_c); - transcript->send_to_verifier(labels.avm_main_op_err, witness_commitments.avm_main_op_err); - transcript->send_to_verifier(labels.avm_main_pc, witness_commitments.avm_main_pc); - transcript->send_to_verifier(labels.avm_main_r_in_tag, witness_commitments.avm_main_r_in_tag); - transcript->send_to_verifier(labels.avm_main_rwa, witness_commitments.avm_main_rwa); - transcript->send_to_verifier(labels.avm_main_rwb, witness_commitments.avm_main_rwb); - transcript->send_to_verifier(labels.avm_main_rwc, witness_commitments.avm_main_rwc); - transcript->send_to_verifier(labels.avm_main_sel_halt, witness_commitments.avm_main_sel_halt); - transcript->send_to_verifier(labels.avm_main_sel_internal_call, witness_commitments.avm_main_sel_internal_call); - transcript->send_to_verifier(labels.avm_main_sel_internal_return, witness_commitments.avm_main_sel_internal_return); - transcript->send_to_verifier(labels.avm_main_sel_jump, witness_commitments.avm_main_sel_jump); - transcript->send_to_verifier(labels.avm_main_sel_mov, witness_commitments.avm_main_sel_mov); - transcript->send_to_verifier(labels.avm_main_sel_op_add, witness_commitments.avm_main_sel_op_add); - transcript->send_to_verifier(labels.avm_main_sel_op_and, witness_commitments.avm_main_sel_op_and); - transcript->send_to_verifier(labels.avm_main_sel_op_div, witness_commitments.avm_main_sel_op_div); - transcript->send_to_verifier(labels.avm_main_sel_op_eq, witness_commitments.avm_main_sel_op_eq); - transcript->send_to_verifier(labels.avm_main_sel_op_mul, witness_commitments.avm_main_sel_op_mul); - transcript->send_to_verifier(labels.avm_main_sel_op_not, witness_commitments.avm_main_sel_op_not); - transcript->send_to_verifier(labels.avm_main_sel_op_or, witness_commitments.avm_main_sel_op_or); - transcript->send_to_verifier(labels.avm_main_sel_op_sub, witness_commitments.avm_main_sel_op_sub); - transcript->send_to_verifier(labels.avm_main_sel_op_xor, witness_commitments.avm_main_sel_op_xor); - transcript->send_to_verifier(labels.avm_main_sel_rng_16, witness_commitments.avm_main_sel_rng_16); - transcript->send_to_verifier(labels.avm_main_sel_rng_8, witness_commitments.avm_main_sel_rng_8); - transcript->send_to_verifier(labels.avm_main_tag_err, witness_commitments.avm_main_tag_err); - transcript->send_to_verifier(labels.avm_main_w_in_tag, witness_commitments.avm_main_w_in_tag); - transcript->send_to_verifier(labels.avm_mem_addr, witness_commitments.avm_mem_addr); - transcript->send_to_verifier(labels.avm_mem_clk, witness_commitments.avm_mem_clk); - transcript->send_to_verifier(labels.avm_mem_ind_op_a, witness_commitments.avm_mem_ind_op_a); - transcript->send_to_verifier(labels.avm_mem_ind_op_b, witness_commitments.avm_mem_ind_op_b); - transcript->send_to_verifier(labels.avm_mem_ind_op_c, witness_commitments.avm_mem_ind_op_c); - transcript->send_to_verifier(labels.avm_mem_last, witness_commitments.avm_mem_last); - transcript->send_to_verifier(labels.avm_mem_lastAccess, witness_commitments.avm_mem_lastAccess); - transcript->send_to_verifier(labels.avm_mem_one_min_inv, witness_commitments.avm_mem_one_min_inv); - transcript->send_to_verifier(labels.avm_mem_op_a, witness_commitments.avm_mem_op_a); - transcript->send_to_verifier(labels.avm_mem_op_b, witness_commitments.avm_mem_op_b); - transcript->send_to_verifier(labels.avm_mem_op_c, witness_commitments.avm_mem_op_c); - transcript->send_to_verifier(labels.avm_mem_r_in_tag, witness_commitments.avm_mem_r_in_tag); - transcript->send_to_verifier(labels.avm_mem_rw, witness_commitments.avm_mem_rw); - transcript->send_to_verifier(labels.avm_mem_sel_mov, witness_commitments.avm_mem_sel_mov); - transcript->send_to_verifier(labels.avm_mem_sub_clk, witness_commitments.avm_mem_sub_clk); - transcript->send_to_verifier(labels.avm_mem_tag, witness_commitments.avm_mem_tag); - transcript->send_to_verifier(labels.avm_mem_tag_err, witness_commitments.avm_mem_tag_err); - transcript->send_to_verifier(labels.avm_mem_val, witness_commitments.avm_mem_val); - transcript->send_to_verifier(labels.avm_mem_w_in_tag, witness_commitments.avm_mem_w_in_tag); - - // Lookup counts - transcript->send_to_verifier(labels.lookup_byte_lengths_counts, witness_commitments.lookup_byte_lengths_counts); - transcript->send_to_verifier(labels.lookup_byte_operations_counts, - witness_commitments.lookup_byte_operations_counts); - transcript->send_to_verifier(labels.incl_main_tag_err_counts, witness_commitments.incl_main_tag_err_counts); - transcript->send_to_verifier(labels.incl_mem_tag_err_counts, witness_commitments.incl_mem_tag_err_counts); -} - -void AvmProver::execute_log_derivative_inverse_round() -{ - auto [beta, gamma] = transcript->template get_challenges("beta", "gamma"); - - relation_parameters.beta = beta; - relation_parameters.gamma = gamma; - - key->compute_logderivative_inverses(relation_parameters); - - // Permutations - witness_commitments.perm_main_alu = commitment_key->commit(key->perm_main_alu); - witness_commitments.perm_main_bin = commitment_key->commit(key->perm_main_bin); - 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_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); - // Lookups - 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); - witness_commitments.lookup_byte_lengths = commitment_key->commit(key->lookup_byte_lengths); - witness_commitments.lookup_byte_operations = commitment_key->commit(key->lookup_byte_operations); - - // Perms - transcript->send_to_verifier(commitment_labels.perm_main_alu, witness_commitments.perm_main_alu); - transcript->send_to_verifier(commitment_labels.perm_main_bin, witness_commitments.perm_main_bin); - 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_b); - 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); - // Lookups - 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); - 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); + auto wire_polys = key->get_wires(); + auto labels = commitment_labels.get_wires(); + for (size_t idx = 0; idx < wire_polys.size(); ++idx) { + transcript->send_to_verifier(labels[idx], commitment_key->commit(wire_polys[idx])); + } } /** @@ -416,9 +112,13 @@ HonkProof& AvmProver::construct_proof() // Compute wire commitments execute_wire_commitments_round(); + // TODO: not implemented for codegen just yet // Compute sorted list accumulator and commitment + // execute_log_derivative_commitments_round(); + // Fiat-Shamir: bbeta & gamma - execute_log_derivative_inverse_round(); + // Compute grand product(s) and commitments. + // execute_grand_product_computation_round(); // Fiat-Shamir: alpha // Run sumcheck subprotocol. diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.hpp index 47e2603a9caa..1e15b341e17d 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.hpp @@ -28,7 +28,6 @@ class AvmProver { void execute_preamble_round(); void execute_wire_commitments_round(); - void execute_log_derivative_inverse_round(); void execute_relation_check_rounds(); void execute_zeromorph_rounds(); @@ -47,7 +46,6 @@ class AvmProver { ProverPolynomials prover_polynomials; CommitmentLabels commitment_labels; - typename Flavor::WitnessCommitments witness_commitments; Polynomial quotient_W; diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp index 105b33fc9cdb..41365c548ab8 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp @@ -196,10 +196,6 @@ 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); -<<<<<<< HEAD -<<<<<<< HEAD -======= ->>>>>>> a43e384f0 (feat: range_chk for cmp) commitments.avm_main_mem_op_a = transcript->template receive_from_prover(commitment_labels.avm_main_mem_op_a); commitments.avm_main_mem_op_b = @@ -232,13 +228,10 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_div); commitments.avm_main_sel_op_eq = transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_eq); -<<<<<<< HEAD -======= commitments.avm_main_sel_op_lt = transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_lt); commitments.avm_main_sel_op_lte = transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_lte); ->>>>>>> a43e384f0 (feat: range_chk for cmp) commitments.avm_main_sel_op_mul = transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_mul); commitments.avm_main_sel_op_not = @@ -286,31 +279,6 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) commitments.avm_mem_val = transcript->template receive_from_prover(commitment_labels.avm_mem_val); commitments.avm_mem_w_in_tag = transcript->template receive_from_prover(commitment_labels.avm_mem_w_in_tag); -<<<<<<< HEAD - - // Lookup counts - commitments.lookup_byte_lengths_counts = - transcript->template receive_from_prover(commitment_labels.lookup_byte_lengths_counts); - commitments.lookup_byte_operations_counts = - transcript->template receive_from_prover(commitment_labels.lookup_byte_operations_counts); - commitments.incl_main_tag_err_counts = - transcript->template receive_from_prover(commitment_labels.incl_main_tag_err_counts); - commitments.incl_mem_tag_err_counts = - transcript->template receive_from_prover(commitment_labels.incl_mem_tag_err_counts); - - // Calculate the alpha and beta challenges - log derivative inverse round - auto [beta, gamm] = transcript->template get_challenges("beta", "gamma"); - relation_parameters.beta = beta; - relation_parameters.gamma = gamm; - - // Permutations -======= - commitments.avm_main_last = transcript->template receive_from_prover(commitment_labels.avm_main_last); - commitments.avm_main_bin_op_id = - transcript->template receive_from_prover(commitment_labels.avm_main_bin_op_id); ->>>>>>> 7a982d52c (feat: init avm cmp) -======= ->>>>>>> a43e384f0 (feat: range_chk for cmp) commitments.perm_main_alu = transcript->template receive_from_prover(commitment_labels.perm_main_alu); commitments.perm_main_bin = transcript->template receive_from_prover(commitment_labels.perm_main_bin); commitments.perm_main_mem_a = @@ -325,8 +293,6 @@ 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); - - // Lookups commitments.lookup_byte_lengths = transcript->template receive_from_prover(commitment_labels.lookup_byte_lengths); commitments.lookup_byte_operations = @@ -335,8 +301,6 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) transcript->template receive_from_prover(commitment_labels.incl_main_tag_err); commitments.incl_mem_tag_err = transcript->template receive_from_prover(commitment_labels.incl_mem_tag_err); -<<<<<<< HEAD -======= commitments.lookup_u8_0 = transcript->template receive_from_prover(commitment_labels.lookup_u8_0); commitments.lookup_u8_1 = transcript->template receive_from_prover(commitment_labels.lookup_u8_1); commitments.lookup_u16_0 = transcript->template receive_from_prover(commitment_labels.lookup_u16_0); @@ -366,9 +330,6 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) transcript->template receive_from_prover(commitment_labels.lookup_u8_0_counts); commitments.lookup_u8_1_counts = transcript->template receive_from_prover(commitment_labels.lookup_u8_1_counts); -<<<<<<< HEAD ->>>>>>> 8d38899c9 (feat: some wip) -======= commitments.lookup_u16_0_counts = transcript->template receive_from_prover(commitment_labels.lookup_u16_0_counts); commitments.lookup_u16_1_counts = @@ -399,7 +360,6 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) transcript->template receive_from_prover(commitment_labels.lookup_u16_13_counts); commitments.lookup_u16_14_counts = transcript->template receive_from_prover(commitment_labels.lookup_u16_14_counts); ->>>>>>> 760ed7310 (fix: 16_bit range checks) // Execute Sumcheck Verifier const size_t log_circuit_size = numeric::get_msb(circuit_size); @@ -417,7 +377,6 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) // If Sumcheck did not verify, return false if (sumcheck_verified.has_value() && !sumcheck_verified.value()) { - info("Sumcheck did not verify"); return false; } diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_arithmetic.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_arithmetic.test.cpp index 336c22da40b3..1150a95f1ef5 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_arithmetic.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_arithmetic.test.cpp @@ -1828,7 +1828,7 @@ TEST_F(AvmArithmeticNegativeTestsFF, eqOutputWrongTag) ASSERT_TRUE(row != trace.end()); row->avm_main_w_in_tag = FF(4); - EXPECT_THROW_WITH_MESSAGE(validate_trace_check_circuit(std::move(trace)), "EQ_OUTPUT_U8"); + EXPECT_THROW_WITH_MESSAGE(validate_trace_check_circuit(std::move(trace)), "OUTPUT_U8"); } // Tests a situation for field elements the (a-b)^1 is incorrect. i.e. (a-b) * (a-b)^1 != 1 for (a-b) != 0; @@ -1896,7 +1896,7 @@ TEST_F(AvmArithmeticNegativeTestsU8, eqOutputWrongTag) ASSERT_TRUE(row != trace.end()); row->avm_main_w_in_tag = FF(3); - EXPECT_THROW_WITH_MESSAGE(validate_trace_check_circuit(std::move(trace)), "EQ_OUTPUT_U8"); + EXPECT_THROW_WITH_MESSAGE(validate_trace_check_circuit(std::move(trace)), "OUTPUT_U8"); } // Tests a situation for U8 elements the (a-b)^1 is incorrect. i.e. (a-b) * (a-b)^1 != 1 for (a-b) != 0; @@ -1963,7 +1963,7 @@ TEST_F(AvmArithmeticNegativeTestsU16, eqOutputWrongTag) ASSERT_TRUE(row != trace.end()); row->avm_main_w_in_tag = FF(5); - EXPECT_THROW_WITH_MESSAGE(validate_trace_check_circuit(std::move(trace)), "EQ_OUTPUT_U8"); + EXPECT_THROW_WITH_MESSAGE(validate_trace_check_circuit(std::move(trace)), "OUTPUT_U8"); } // Tests a situation for U16 elements the (a-b)^1 is incorrect. i.e. (a-b) * (a-b)^1 != 1 for (a-b) != 0; @@ -2030,7 +2030,7 @@ TEST_F(AvmArithmeticNegativeTestsU32, eqOutputWrongTag) ASSERT_TRUE(row != trace.end()); row->avm_main_w_in_tag = FF(6); - EXPECT_THROW_WITH_MESSAGE(validate_trace_check_circuit(std::move(trace)), "EQ_OUTPUT_U8"); + EXPECT_THROW_WITH_MESSAGE(validate_trace_check_circuit(std::move(trace)), "OUTPUT_U8"); } // Tests a situation for U32 elements the (a-b)^1 is incorrect. i.e. (a-b) * (a-b)^1 != 1 for (a-b) != 0; @@ -2104,7 +2104,7 @@ TEST_F(AvmArithmeticNegativeTestsU64, eqOutputWrongTag) ASSERT_TRUE(row != trace.end()); row->avm_main_w_in_tag = FF(2); - EXPECT_THROW_WITH_MESSAGE(validate_trace_check_circuit(std::move(trace)), "EQ_OUTPUT_U8"); + EXPECT_THROW_WITH_MESSAGE(validate_trace_check_circuit(std::move(trace)), "OUTPUT_U8"); } // Tests a situation for U64 elements the (a-b)^1 is incorrect. i.e. (a-b) * (a-b)^1 != 1 for (a-b) != 0; @@ -2203,7 +2203,7 @@ TEST_F(AvmArithmeticNegativeTestsU128, eqOutputWrongTag) ASSERT_TRUE(row != trace.end()); row->avm_main_w_in_tag = FF(4); - EXPECT_THROW_WITH_MESSAGE(validate_trace_check_circuit(std::move(trace)), "EQ_OUTPUT_U8"); + EXPECT_THROW_WITH_MESSAGE(validate_trace_check_circuit(std::move(trace)), "OUTPUT_U8"); } // Tests a situation for U128 elements the (a-b)^1 is incorrect. i.e. (a-b) * (a-b)^1 != 1 for (a-b) != 0; From 5a3975a508864c05b2963bc1b6f20fec1c073ea0 Mon Sep 17 00:00:00 2001 From: IlyasRidhuan Date: Wed, 10 Apr 2024 09:38:03 +0000 Subject: [PATCH 14/18] chore: clean up --- .../generated/avm/incl_main_tag_err.hpp | 2 +- .../generated/avm/incl_mem_tag_err.hpp | 2 +- .../generated/avm/lookup_byte_lengths.hpp | 2 +- .../generated/avm/lookup_byte_operations.hpp | 2 +- .../relations/generated/avm/lookup_u16_0.hpp | 2 +- .../relations/generated/avm/lookup_u16_1.hpp | 2 +- .../relations/generated/avm/lookup_u16_10.hpp | 2 +- .../relations/generated/avm/lookup_u16_11.hpp | 2 +- .../relations/generated/avm/lookup_u16_12.hpp | 2 +- .../relations/generated/avm/lookup_u16_13.hpp | 2 +- .../relations/generated/avm/lookup_u16_14.hpp | 2 +- .../relations/generated/avm/lookup_u16_2.hpp | 2 +- .../relations/generated/avm/lookup_u16_3.hpp | 2 +- .../relations/generated/avm/lookup_u16_4.hpp | 2 +- .../relations/generated/avm/lookup_u16_5.hpp | 2 +- .../relations/generated/avm/lookup_u16_6.hpp | 2 +- .../relations/generated/avm/lookup_u16_7.hpp | 2 +- .../relations/generated/avm/lookup_u16_8.hpp | 2 +- .../relations/generated/avm/lookup_u16_9.hpp | 2 +- .../relations/generated/avm/lookup_u8_0.hpp | 2 +- .../relations/generated/avm/lookup_u8_1.hpp | 2 +- .../vm/generated/avm_circuit_builder.hpp | 29 -- .../vm/generated/avm_composer.cpp | 2 +- .../vm/generated/avm_composer.hpp | 2 +- .../barretenberg/vm/generated/avm_flavor.hpp | 161 ++++++- .../barretenberg/vm/generated/avm_prover.cpp | 436 +++++++++++++++++- .../barretenberg/vm/generated/avm_prover.hpp | 2 + .../vm/generated/avm_verifier.cpp | 84 ++-- 28 files changed, 650 insertions(+), 108 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_main_tag_err.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_main_tag_err.hpp index 01e8335fd7ef..cfb4885c4b53 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_main_tag_err.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_main_tag_err.hpp @@ -60,7 +60,7 @@ class incl_main_tag_err_lookup_settings { * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed * */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; /** * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_mem_tag_err.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_mem_tag_err.hpp index 94b436580592..4055ceb7951a 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_mem_tag_err.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/incl_mem_tag_err.hpp @@ -60,7 +60,7 @@ class incl_mem_tag_err_lookup_settings { * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed * */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; /** * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_lengths.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_lengths.hpp index 4c5a6bd0d48e..66268991c7c9 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_lengths.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_lengths.hpp @@ -60,7 +60,7 @@ class lookup_byte_lengths_lookup_settings { * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed * */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; /** * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_operations.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_operations.hpp index 92874d3d134a..baf2995fcb85 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_operations.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_byte_operations.hpp @@ -60,7 +60,7 @@ class lookup_byte_operations_lookup_settings { * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed * */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; /** * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_0.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_0.hpp index 6553a7db9a59..67c790536090 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_0.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_0.hpp @@ -60,7 +60,7 @@ class lookup_u16_0_lookup_settings { * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed * */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; /** * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_1.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_1.hpp index fa1c36018145..c5c39dd2f802 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_1.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_1.hpp @@ -60,7 +60,7 @@ class lookup_u16_1_lookup_settings { * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed * */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; /** * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_10.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_10.hpp index 987e146a7184..275dcb0f8249 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_10.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_10.hpp @@ -60,7 +60,7 @@ class lookup_u16_10_lookup_settings { * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed * */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; /** * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_11.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_11.hpp index 2db300ecf0e5..b94a5f65d843 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_11.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_11.hpp @@ -60,7 +60,7 @@ class lookup_u16_11_lookup_settings { * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed * */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; /** * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_12.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_12.hpp index fd1ea74b50e7..4fc5cca4ebe6 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_12.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_12.hpp @@ -60,7 +60,7 @@ class lookup_u16_12_lookup_settings { * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed * */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; /** * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_13.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_13.hpp index 001e22ab832b..908d478b8ad5 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_13.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_13.hpp @@ -60,7 +60,7 @@ class lookup_u16_13_lookup_settings { * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed * */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; /** * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_14.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_14.hpp index b1cfa3029642..735361f8e6c5 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_14.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_14.hpp @@ -60,7 +60,7 @@ class lookup_u16_14_lookup_settings { * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed * */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; /** * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_2.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_2.hpp index f8b6bda1290d..8aa66dc7a70c 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_2.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_2.hpp @@ -60,7 +60,7 @@ class lookup_u16_2_lookup_settings { * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed * */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; /** * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_3.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_3.hpp index 65a6a2dc6bce..b1bda551024e 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_3.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_3.hpp @@ -60,7 +60,7 @@ class lookup_u16_3_lookup_settings { * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed * */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; /** * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_4.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_4.hpp index f70eea125838..5984e1a6e590 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_4.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_4.hpp @@ -60,7 +60,7 @@ class lookup_u16_4_lookup_settings { * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed * */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; /** * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_5.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_5.hpp index 88f50d749c43..d1bc6db3a292 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_5.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_5.hpp @@ -60,7 +60,7 @@ class lookup_u16_5_lookup_settings { * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed * */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; /** * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_6.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_6.hpp index 297c69a31e5a..3838f21e967e 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_6.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_6.hpp @@ -60,7 +60,7 @@ class lookup_u16_6_lookup_settings { * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed * */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; /** * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_7.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_7.hpp index 37bc7f89d1c0..84b098172e9e 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_7.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_7.hpp @@ -60,7 +60,7 @@ class lookup_u16_7_lookup_settings { * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed * */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; /** * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_8.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_8.hpp index 2cc51625cd5e..f75f9fa9c280 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_8.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_8.hpp @@ -60,7 +60,7 @@ class lookup_u16_8_lookup_settings { * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed * */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; /** * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_9.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_9.hpp index c0efd97f30f0..5e72a369ac49 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_9.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u16_9.hpp @@ -60,7 +60,7 @@ class lookup_u16_9_lookup_settings { * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed * */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; /** * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_0.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_0.hpp index c903cd97ff80..37b5936f008a 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_0.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_0.hpp @@ -60,7 +60,7 @@ class lookup_u8_0_lookup_settings { * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed * */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; /** * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_1.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_1.hpp index 525424166fa8..7941ecb1aee1 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_1.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_u8_1.hpp @@ -60,7 +60,7 @@ class lookup_u8_1_lookup_settings { * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed * */ - static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 2; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; /** * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read 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 de873c69cb2a..42e931cbdf39 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp @@ -447,35 +447,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; - 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_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.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; - polys.lookup_u8_0[i] = rows[i].lookup_u8_0; - polys.lookup_u8_1[i] = rows[i].lookup_u8_1; - polys.lookup_u16_0[i] = rows[i].lookup_u16_0; - polys.lookup_u16_1[i] = rows[i].lookup_u16_1; - polys.lookup_u16_2[i] = rows[i].lookup_u16_2; - polys.lookup_u16_3[i] = rows[i].lookup_u16_3; - polys.lookup_u16_4[i] = rows[i].lookup_u16_4; - polys.lookup_u16_5[i] = rows[i].lookup_u16_5; - polys.lookup_u16_6[i] = rows[i].lookup_u16_6; - polys.lookup_u16_7[i] = rows[i].lookup_u16_7; - polys.lookup_u16_8[i] = rows[i].lookup_u16_8; - polys.lookup_u16_9[i] = rows[i].lookup_u16_9; - polys.lookup_u16_10[i] = rows[i].lookup_u16_10; - polys.lookup_u16_11[i] = rows[i].lookup_u16_11; - polys.lookup_u16_12[i] = rows[i].lookup_u16_12; - polys.lookup_u16_13[i] = rows[i].lookup_u16_13; - polys.lookup_u16_14[i] = rows[i].lookup_u16_14; 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_composer.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.cpp index a95109f38ca3..d923c58c1cc8 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.cpp @@ -31,7 +31,7 @@ AvmProver AvmComposer::create_prover(CircuitConstructor& circuit_constructor) compute_witness(circuit_constructor); compute_commitment_key(circuit_constructor.get_circuit_subgroup_size()); - AvmProver output_state(proving_key, commitment_key); + AvmProver output_state(proving_key, proving_key->commitment_key); return output_state; } diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.hpp index 1c072ebdf4e5..a2f9fe68dcf5 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.hpp @@ -62,7 +62,7 @@ class AvmComposer { void compute_commitment_key(size_t circuit_size) { - commitment_key = std::make_shared(circuit_size); + proving_key->commitment_key = std::make_shared(circuit_size); }; }; diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp index cf4a6bf7d703..353ee278c6f1 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp @@ -17,6 +17,27 @@ #include "barretenberg/relations/generated/avm/avm_binary.hpp" #include "barretenberg/relations/generated/avm/avm_main.hpp" #include "barretenberg/relations/generated/avm/avm_mem.hpp" +#include "barretenberg/relations/generated/avm/incl_main_tag_err.hpp" +#include "barretenberg/relations/generated/avm/incl_mem_tag_err.hpp" +#include "barretenberg/relations/generated/avm/lookup_byte_lengths.hpp" +#include "barretenberg/relations/generated/avm/lookup_byte_operations.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_0.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_1.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_10.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_11.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_12.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_13.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_14.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_2.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_3.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_4.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_5.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_6.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_7.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_8.hpp" +#include "barretenberg/relations/generated/avm/lookup_u16_9.hpp" +#include "barretenberg/relations/generated/avm/lookup_u8_0.hpp" +#include "barretenberg/relations/generated/avm/lookup_u8_1.hpp" #include "barretenberg/relations/generated/avm/perm_main_alu.hpp" #include "barretenberg/relations/generated/avm/perm_main_bin.hpp" #include "barretenberg/relations/generated/avm/perm_main_mem_a.hpp" @@ -52,6 +73,36 @@ class AvmFlavor { // the unshifted and one for the shifted static constexpr size_t NUM_ALL_ENTITIES = 224; + using GrandProductRelations = std::tuple, + perm_main_bin_relation, + perm_main_mem_a_relation, + perm_main_mem_b_relation, + perm_main_mem_c_relation, + perm_main_mem_ind_a_relation, + perm_main_mem_ind_b_relation, + perm_main_mem_ind_c_relation, + lookup_byte_lengths_relation, + lookup_byte_operations_relation, + incl_main_tag_err_relation, + incl_mem_tag_err_relation, + lookup_u8_0_relation, + lookup_u8_1_relation, + lookup_u16_0_relation, + lookup_u16_1_relation, + lookup_u16_2_relation, + lookup_u16_3_relation, + lookup_u16_4_relation, + lookup_u16_5_relation, + lookup_u16_6_relation, + lookup_u16_7_relation, + lookup_u16_8_relation, + lookup_u16_9_relation, + lookup_u16_10_relation, + lookup_u16_11_relation, + lookup_u16_12_relation, + lookup_u16_13_relation, + lookup_u16_14_relation>; + using Relations = std::tuple, Avm_vm::avm_binary, Avm_vm::avm_main, @@ -63,7 +114,28 @@ class AvmFlavor { perm_main_mem_c_relation, perm_main_mem_ind_a_relation, perm_main_mem_ind_b_relation, - perm_main_mem_ind_c_relation>; + perm_main_mem_ind_c_relation, + lookup_byte_lengths_relation, + lookup_byte_operations_relation, + incl_main_tag_err_relation, + incl_mem_tag_err_relation, + lookup_u8_0_relation, + lookup_u8_1_relation, + lookup_u16_0_relation, + lookup_u16_1_relation, + lookup_u16_2_relation, + lookup_u16_3_relation, + lookup_u16_4_relation, + lookup_u16_5_relation, + lookup_u16_6_relation, + lookup_u16_7_relation, + lookup_u16_8_relation, + lookup_u16_9_relation, + lookup_u16_10_relation, + lookup_u16_11_relation, + lookup_u16_12_relation, + lookup_u16_13_relation, + lookup_u16_14_relation>; static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = compute_max_partial_relation_length(); @@ -71,7 +143,7 @@ class AvmFlavor { // random polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation // length = 3 static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH = MAX_PARTIAL_RELATION_LENGTH + 1; - static constexpr size_t NUM_RELATIONS = std::tuple_size::value; + static constexpr size_t NUM_RELATIONS = std::tuple_size_v; template using ProtogalaxyTupleOfTuplesOfUnivariates = @@ -487,7 +559,6 @@ class AvmFlavor { lookup_u16_13_counts, lookup_u16_14_counts }; }; - RefVector get_sorted_polynomials() { return {}; }; }; template class AllEntities { @@ -1193,8 +1264,69 @@ class AvmFlavor { avm_mem_val }; }; - // The plookup wires that store plookup read data. - std::array get_table_column_wires() { return {}; }; + void compute_logderivative_inverses(const RelationParameters& relation_parameters) + { + ProverPolynomials prover_polynomials = ProverPolynomials(*this); + + 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); + 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); + 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); + 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); + 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); + 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); + } }; using VerificationKey = VerificationKey_, VerifierCommitmentKey>; @@ -1219,6 +1351,19 @@ class AvmFlavor { ProverPolynomials(ProverPolynomials&& o) noexcept = default; ProverPolynomials& operator=(ProverPolynomials&& o) noexcept = default; ~ProverPolynomials() = default; + + ProverPolynomials(ProvingKey& proving_key) + { + for (auto [prover_poly, key_poly] : zip_view(this->get_unshifted(), proving_key.get_all())) { + ASSERT(flavor_get_label(*this, prover_poly) == flavor_get_label(proving_key, key_poly)); + prover_poly = key_poly.share(); + } + for (auto [prover_poly, key_poly] : zip_view(this->get_shifted(), proving_key.get_to_be_shifted())) { + ASSERT(flavor_get_label(*this, prover_poly) == (flavor_get_label(proving_key, key_poly) + "_shift")); + prover_poly = key_poly.shifted(); + } + } + [[nodiscard]] size_t get_polynomial_size() const { return avm_alu_a_hi.size(); } /** * @brief Returns the evaluations of all prover polynomials at one point on the boolean hypercube, which @@ -1259,6 +1404,12 @@ class AvmFlavor { */ using ExtendedEdges = ProverUnivariates; + /** + * @brief A container for the witness commitments. + * + */ + using WitnessCommitments = WitnessEntities; + class CommitmentLabels : public AllEntities { private: using Base = AllEntities; diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp index e887045bb963..6d1bacc8d973 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp @@ -51,16 +51,433 @@ void AvmProver::execute_preamble_round() } /** - * @brief Compute commitments to the first three wires + * @brief Compute commitments to all of the witness wires (apart from the logderivative inverse wires) * */ void AvmProver::execute_wire_commitments_round() { - auto wire_polys = key->get_wires(); - auto labels = commitment_labels.get_wires(); - for (size_t idx = 0; idx < wire_polys.size(); ++idx) { - transcript->send_to_verifier(labels[idx], commitment_key->commit(wire_polys[idx])); - } + + // Commit to all polynomials (apart from logderivative inverse polynomials, which are committed to in the later + // logderivative phase) + 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); + 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); + witness_commitments.avm_alu_borrow = commitment_key->commit(key->avm_alu_borrow); + witness_commitments.avm_alu_cf = commitment_key->commit(key->avm_alu_cf); + witness_commitments.avm_alu_clk = commitment_key->commit(key->avm_alu_clk); + witness_commitments.avm_alu_cmp_rng_ctr = commitment_key->commit(key->avm_alu_cmp_rng_ctr); + witness_commitments.avm_alu_cmp_sel = commitment_key->commit(key->avm_alu_cmp_sel); + witness_commitments.avm_alu_ff_tag = commitment_key->commit(key->avm_alu_ff_tag); + witness_commitments.avm_alu_ia = commitment_key->commit(key->avm_alu_ia); + witness_commitments.avm_alu_ib = commitment_key->commit(key->avm_alu_ib); + witness_commitments.avm_alu_ic = commitment_key->commit(key->avm_alu_ic); + witness_commitments.avm_alu_in_tag = commitment_key->commit(key->avm_alu_in_tag); + witness_commitments.avm_alu_op_add = commitment_key->commit(key->avm_alu_op_add); + witness_commitments.avm_alu_op_div = commitment_key->commit(key->avm_alu_op_div); + witness_commitments.avm_alu_op_eq = commitment_key->commit(key->avm_alu_op_eq); + witness_commitments.avm_alu_op_eq_diff_inv = commitment_key->commit(key->avm_alu_op_eq_diff_inv); + witness_commitments.avm_alu_op_lt = commitment_key->commit(key->avm_alu_op_lt); + witness_commitments.avm_alu_op_lte = commitment_key->commit(key->avm_alu_op_lte); + witness_commitments.avm_alu_op_mul = commitment_key->commit(key->avm_alu_op_mul); + witness_commitments.avm_alu_op_not = commitment_key->commit(key->avm_alu_op_not); + witness_commitments.avm_alu_op_sub = commitment_key->commit(key->avm_alu_op_sub); + witness_commitments.avm_alu_p_a_borrow = commitment_key->commit(key->avm_alu_p_a_borrow); + witness_commitments.avm_alu_p_b_borrow = commitment_key->commit(key->avm_alu_p_b_borrow); + witness_commitments.avm_alu_p_sub_a_hi = commitment_key->commit(key->avm_alu_p_sub_a_hi); + witness_commitments.avm_alu_p_sub_a_lo = commitment_key->commit(key->avm_alu_p_sub_a_lo); + witness_commitments.avm_alu_p_sub_b_hi = commitment_key->commit(key->avm_alu_p_sub_b_hi); + witness_commitments.avm_alu_p_sub_b_lo = commitment_key->commit(key->avm_alu_p_sub_b_lo); + witness_commitments.avm_alu_res_hi = commitment_key->commit(key->avm_alu_res_hi); + witness_commitments.avm_alu_res_lo = commitment_key->commit(key->avm_alu_res_lo); + witness_commitments.avm_alu_rng_chk_lookup_selector = commitment_key->commit(key->avm_alu_rng_chk_lookup_selector); + witness_commitments.avm_alu_rng_chk_sel = commitment_key->commit(key->avm_alu_rng_chk_sel); + witness_commitments.avm_alu_u128_tag = commitment_key->commit(key->avm_alu_u128_tag); + witness_commitments.avm_alu_u16_r0 = commitment_key->commit(key->avm_alu_u16_r0); + witness_commitments.avm_alu_u16_r1 = commitment_key->commit(key->avm_alu_u16_r1); + witness_commitments.avm_alu_u16_r10 = commitment_key->commit(key->avm_alu_u16_r10); + witness_commitments.avm_alu_u16_r11 = commitment_key->commit(key->avm_alu_u16_r11); + witness_commitments.avm_alu_u16_r12 = commitment_key->commit(key->avm_alu_u16_r12); + witness_commitments.avm_alu_u16_r13 = commitment_key->commit(key->avm_alu_u16_r13); + witness_commitments.avm_alu_u16_r14 = commitment_key->commit(key->avm_alu_u16_r14); + witness_commitments.avm_alu_u16_r2 = commitment_key->commit(key->avm_alu_u16_r2); + witness_commitments.avm_alu_u16_r3 = commitment_key->commit(key->avm_alu_u16_r3); + witness_commitments.avm_alu_u16_r4 = commitment_key->commit(key->avm_alu_u16_r4); + witness_commitments.avm_alu_u16_r5 = commitment_key->commit(key->avm_alu_u16_r5); + witness_commitments.avm_alu_u16_r6 = commitment_key->commit(key->avm_alu_u16_r6); + witness_commitments.avm_alu_u16_r7 = commitment_key->commit(key->avm_alu_u16_r7); + witness_commitments.avm_alu_u16_r8 = commitment_key->commit(key->avm_alu_u16_r8); + witness_commitments.avm_alu_u16_r9 = commitment_key->commit(key->avm_alu_u16_r9); + witness_commitments.avm_alu_u16_tag = commitment_key->commit(key->avm_alu_u16_tag); + witness_commitments.avm_alu_u32_tag = commitment_key->commit(key->avm_alu_u32_tag); + witness_commitments.avm_alu_u64_r0 = commitment_key->commit(key->avm_alu_u64_r0); + witness_commitments.avm_alu_u64_tag = commitment_key->commit(key->avm_alu_u64_tag); + witness_commitments.avm_alu_u8_r0 = commitment_key->commit(key->avm_alu_u8_r0); + witness_commitments.avm_alu_u8_r1 = commitment_key->commit(key->avm_alu_u8_r1); + witness_commitments.avm_alu_u8_tag = commitment_key->commit(key->avm_alu_u8_tag); + witness_commitments.avm_binary_acc_ia = commitment_key->commit(key->avm_binary_acc_ia); + witness_commitments.avm_binary_acc_ib = commitment_key->commit(key->avm_binary_acc_ib); + witness_commitments.avm_binary_acc_ic = commitment_key->commit(key->avm_binary_acc_ic); + witness_commitments.avm_binary_bin_sel = commitment_key->commit(key->avm_binary_bin_sel); + witness_commitments.avm_binary_clk = commitment_key->commit(key->avm_binary_clk); + witness_commitments.avm_binary_ia_bytes = commitment_key->commit(key->avm_binary_ia_bytes); + witness_commitments.avm_binary_ib_bytes = commitment_key->commit(key->avm_binary_ib_bytes); + witness_commitments.avm_binary_ic_bytes = commitment_key->commit(key->avm_binary_ic_bytes); + witness_commitments.avm_binary_in_tag = commitment_key->commit(key->avm_binary_in_tag); + witness_commitments.avm_binary_mem_tag_ctr = commitment_key->commit(key->avm_binary_mem_tag_ctr); + witness_commitments.avm_binary_mem_tag_ctr_inv = commitment_key->commit(key->avm_binary_mem_tag_ctr_inv); + witness_commitments.avm_binary_op_id = commitment_key->commit(key->avm_binary_op_id); + witness_commitments.avm_binary_start = commitment_key->commit(key->avm_binary_start); + witness_commitments.avm_byte_lookup_bin_sel = commitment_key->commit(key->avm_byte_lookup_bin_sel); + witness_commitments.avm_byte_lookup_table_byte_lengths = + commitment_key->commit(key->avm_byte_lookup_table_byte_lengths); + witness_commitments.avm_byte_lookup_table_in_tags = commitment_key->commit(key->avm_byte_lookup_table_in_tags); + witness_commitments.avm_byte_lookup_table_input_a = commitment_key->commit(key->avm_byte_lookup_table_input_a); + witness_commitments.avm_byte_lookup_table_input_b = commitment_key->commit(key->avm_byte_lookup_table_input_b); + witness_commitments.avm_byte_lookup_table_op_id = commitment_key->commit(key->avm_byte_lookup_table_op_id); + witness_commitments.avm_byte_lookup_table_output = commitment_key->commit(key->avm_byte_lookup_table_output); + witness_commitments.avm_main_alu_sel = commitment_key->commit(key->avm_main_alu_sel); + witness_commitments.avm_main_bin_op_id = commitment_key->commit(key->avm_main_bin_op_id); + witness_commitments.avm_main_bin_sel = commitment_key->commit(key->avm_main_bin_sel); + 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_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_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_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_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_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_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_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); + witness_commitments.avm_main_sel_op_eq = commitment_key->commit(key->avm_main_sel_op_eq); + witness_commitments.avm_main_sel_op_lt = commitment_key->commit(key->avm_main_sel_op_lt); + witness_commitments.avm_main_sel_op_lte = commitment_key->commit(key->avm_main_sel_op_lte); + witness_commitments.avm_main_sel_op_mul = commitment_key->commit(key->avm_main_sel_op_mul); + witness_commitments.avm_main_sel_op_not = commitment_key->commit(key->avm_main_sel_op_not); + witness_commitments.avm_main_sel_op_or = commitment_key->commit(key->avm_main_sel_op_or); + witness_commitments.avm_main_sel_op_sub = commitment_key->commit(key->avm_main_sel_op_sub); + witness_commitments.avm_main_sel_op_xor = commitment_key->commit(key->avm_main_sel_op_xor); + witness_commitments.avm_main_sel_rng_16 = commitment_key->commit(key->avm_main_sel_rng_16); + witness_commitments.avm_main_sel_rng_8 = commitment_key->commit(key->avm_main_sel_rng_8); + witness_commitments.avm_main_tag_err = commitment_key->commit(key->avm_main_tag_err); + witness_commitments.avm_main_w_in_tag = commitment_key->commit(key->avm_main_w_in_tag); + witness_commitments.avm_mem_addr = commitment_key->commit(key->avm_mem_addr); + witness_commitments.avm_mem_clk = commitment_key->commit(key->avm_mem_clk); + 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_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_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_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); + witness_commitments.avm_mem_val = commitment_key->commit(key->avm_mem_val); + witness_commitments.avm_mem_w_in_tag = commitment_key->commit(key->avm_mem_w_in_tag); + witness_commitments.lookup_byte_lengths_counts = commitment_key->commit(key->lookup_byte_lengths_counts); + witness_commitments.lookup_byte_operations_counts = commitment_key->commit(key->lookup_byte_operations_counts); + witness_commitments.incl_main_tag_err_counts = commitment_key->commit(key->incl_main_tag_err_counts); + witness_commitments.incl_mem_tag_err_counts = commitment_key->commit(key->incl_mem_tag_err_counts); + witness_commitments.lookup_u8_0_counts = commitment_key->commit(key->lookup_u8_0_counts); + witness_commitments.lookup_u8_1_counts = commitment_key->commit(key->lookup_u8_1_counts); + witness_commitments.lookup_u16_0_counts = commitment_key->commit(key->lookup_u16_0_counts); + witness_commitments.lookup_u16_1_counts = commitment_key->commit(key->lookup_u16_1_counts); + witness_commitments.lookup_u16_2_counts = commitment_key->commit(key->lookup_u16_2_counts); + witness_commitments.lookup_u16_3_counts = commitment_key->commit(key->lookup_u16_3_counts); + witness_commitments.lookup_u16_4_counts = commitment_key->commit(key->lookup_u16_4_counts); + witness_commitments.lookup_u16_5_counts = commitment_key->commit(key->lookup_u16_5_counts); + witness_commitments.lookup_u16_6_counts = commitment_key->commit(key->lookup_u16_6_counts); + witness_commitments.lookup_u16_7_counts = commitment_key->commit(key->lookup_u16_7_counts); + witness_commitments.lookup_u16_8_counts = commitment_key->commit(key->lookup_u16_8_counts); + witness_commitments.lookup_u16_9_counts = commitment_key->commit(key->lookup_u16_9_counts); + witness_commitments.lookup_u16_10_counts = commitment_key->commit(key->lookup_u16_10_counts); + witness_commitments.lookup_u16_11_counts = commitment_key->commit(key->lookup_u16_11_counts); + witness_commitments.lookup_u16_12_counts = commitment_key->commit(key->lookup_u16_12_counts); + witness_commitments.lookup_u16_13_counts = commitment_key->commit(key->lookup_u16_13_counts); + witness_commitments.lookup_u16_14_counts = commitment_key->commit(key->lookup_u16_14_counts); + + // Send all commitments to the verifier + 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); + transcript->send_to_verifier(commitment_labels.avm_alu_b_hi, witness_commitments.avm_alu_b_hi); + transcript->send_to_verifier(commitment_labels.avm_alu_b_lo, witness_commitments.avm_alu_b_lo); + transcript->send_to_verifier(commitment_labels.avm_alu_borrow, witness_commitments.avm_alu_borrow); + 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); + 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_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); + transcript->send_to_verifier(commitment_labels.avm_alu_ic, witness_commitments.avm_alu_ic); + transcript->send_to_verifier(commitment_labels.avm_alu_in_tag, witness_commitments.avm_alu_in_tag); + transcript->send_to_verifier(commitment_labels.avm_alu_op_add, witness_commitments.avm_alu_op_add); + 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); + 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); + 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); + transcript->send_to_verifier(commitment_labels.avm_alu_p_a_borrow, witness_commitments.avm_alu_p_a_borrow); + transcript->send_to_verifier(commitment_labels.avm_alu_p_b_borrow, witness_commitments.avm_alu_p_b_borrow); + transcript->send_to_verifier(commitment_labels.avm_alu_p_sub_a_hi, witness_commitments.avm_alu_p_sub_a_hi); + transcript->send_to_verifier(commitment_labels.avm_alu_p_sub_a_lo, witness_commitments.avm_alu_p_sub_a_lo); + transcript->send_to_verifier(commitment_labels.avm_alu_p_sub_b_hi, witness_commitments.avm_alu_p_sub_b_hi); + transcript->send_to_verifier(commitment_labels.avm_alu_p_sub_b_lo, witness_commitments.avm_alu_p_sub_b_lo); + transcript->send_to_verifier(commitment_labels.avm_alu_res_hi, witness_commitments.avm_alu_res_hi); + transcript->send_to_verifier(commitment_labels.avm_alu_res_lo, witness_commitments.avm_alu_res_lo); + 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_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); + transcript->send_to_verifier(commitment_labels.avm_alu_u16_r10, witness_commitments.avm_alu_u16_r10); + transcript->send_to_verifier(commitment_labels.avm_alu_u16_r11, witness_commitments.avm_alu_u16_r11); + transcript->send_to_verifier(commitment_labels.avm_alu_u16_r12, witness_commitments.avm_alu_u16_r12); + transcript->send_to_verifier(commitment_labels.avm_alu_u16_r13, witness_commitments.avm_alu_u16_r13); + transcript->send_to_verifier(commitment_labels.avm_alu_u16_r14, witness_commitments.avm_alu_u16_r14); + transcript->send_to_verifier(commitment_labels.avm_alu_u16_r2, witness_commitments.avm_alu_u16_r2); + transcript->send_to_verifier(commitment_labels.avm_alu_u16_r3, witness_commitments.avm_alu_u16_r3); + transcript->send_to_verifier(commitment_labels.avm_alu_u16_r4, witness_commitments.avm_alu_u16_r4); + transcript->send_to_verifier(commitment_labels.avm_alu_u16_r5, witness_commitments.avm_alu_u16_r5); + transcript->send_to_verifier(commitment_labels.avm_alu_u16_r6, witness_commitments.avm_alu_u16_r6); + transcript->send_to_verifier(commitment_labels.avm_alu_u16_r7, witness_commitments.avm_alu_u16_r7); + transcript->send_to_verifier(commitment_labels.avm_alu_u16_r8, witness_commitments.avm_alu_u16_r8); + transcript->send_to_verifier(commitment_labels.avm_alu_u16_r9, witness_commitments.avm_alu_u16_r9); + transcript->send_to_verifier(commitment_labels.avm_alu_u16_tag, witness_commitments.avm_alu_u16_tag); + transcript->send_to_verifier(commitment_labels.avm_alu_u32_tag, witness_commitments.avm_alu_u32_tag); + transcript->send_to_verifier(commitment_labels.avm_alu_u64_r0, witness_commitments.avm_alu_u64_r0); + transcript->send_to_verifier(commitment_labels.avm_alu_u64_tag, witness_commitments.avm_alu_u64_tag); + transcript->send_to_verifier(commitment_labels.avm_alu_u8_r0, witness_commitments.avm_alu_u8_r0); + transcript->send_to_verifier(commitment_labels.avm_alu_u8_r1, witness_commitments.avm_alu_u8_r1); + transcript->send_to_verifier(commitment_labels.avm_alu_u8_tag, witness_commitments.avm_alu_u8_tag); + transcript->send_to_verifier(commitment_labels.avm_binary_acc_ia, witness_commitments.avm_binary_acc_ia); + transcript->send_to_verifier(commitment_labels.avm_binary_acc_ib, witness_commitments.avm_binary_acc_ib); + transcript->send_to_verifier(commitment_labels.avm_binary_acc_ic, witness_commitments.avm_binary_acc_ic); + transcript->send_to_verifier(commitment_labels.avm_binary_bin_sel, witness_commitments.avm_binary_bin_sel); + transcript->send_to_verifier(commitment_labels.avm_binary_clk, witness_commitments.avm_binary_clk); + transcript->send_to_verifier(commitment_labels.avm_binary_ia_bytes, witness_commitments.avm_binary_ia_bytes); + transcript->send_to_verifier(commitment_labels.avm_binary_ib_bytes, witness_commitments.avm_binary_ib_bytes); + transcript->send_to_verifier(commitment_labels.avm_binary_ic_bytes, witness_commitments.avm_binary_ic_bytes); + transcript->send_to_verifier(commitment_labels.avm_binary_in_tag, witness_commitments.avm_binary_in_tag); + transcript->send_to_verifier(commitment_labels.avm_binary_mem_tag_ctr, witness_commitments.avm_binary_mem_tag_ctr); + transcript->send_to_verifier(commitment_labels.avm_binary_mem_tag_ctr_inv, + witness_commitments.avm_binary_mem_tag_ctr_inv); + transcript->send_to_verifier(commitment_labels.avm_binary_op_id, witness_commitments.avm_binary_op_id); + transcript->send_to_verifier(commitment_labels.avm_binary_start, witness_commitments.avm_binary_start); + transcript->send_to_verifier(commitment_labels.avm_byte_lookup_bin_sel, + witness_commitments.avm_byte_lookup_bin_sel); + transcript->send_to_verifier(commitment_labels.avm_byte_lookup_table_byte_lengths, + witness_commitments.avm_byte_lookup_table_byte_lengths); + transcript->send_to_verifier(commitment_labels.avm_byte_lookup_table_in_tags, + witness_commitments.avm_byte_lookup_table_in_tags); + transcript->send_to_verifier(commitment_labels.avm_byte_lookup_table_input_a, + witness_commitments.avm_byte_lookup_table_input_a); + transcript->send_to_verifier(commitment_labels.avm_byte_lookup_table_input_b, + witness_commitments.avm_byte_lookup_table_input_b); + transcript->send_to_verifier(commitment_labels.avm_byte_lookup_table_op_id, + witness_commitments.avm_byte_lookup_table_op_id); + transcript->send_to_verifier(commitment_labels.avm_byte_lookup_table_output, + witness_commitments.avm_byte_lookup_table_output); + transcript->send_to_verifier(commitment_labels.avm_main_alu_sel, witness_commitments.avm_main_alu_sel); + transcript->send_to_verifier(commitment_labels.avm_main_bin_op_id, witness_commitments.avm_main_bin_op_id); + transcript->send_to_verifier(commitment_labels.avm_main_bin_sel, witness_commitments.avm_main_bin_sel); + 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); + 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_internal_return_ptr, + witness_commitments.avm_main_internal_return_ptr); + transcript->send_to_verifier(commitment_labels.avm_main_inv, witness_commitments.avm_main_inv); + transcript->send_to_verifier(commitment_labels.avm_main_last, witness_commitments.avm_main_last); + 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); + 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_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); + 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); + transcript->send_to_verifier(commitment_labels.avm_main_sel_internal_return, + 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); + 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); + 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); + 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); + transcript->send_to_verifier(commitment_labels.avm_main_sel_op_sub, witness_commitments.avm_main_sel_op_sub); + transcript->send_to_verifier(commitment_labels.avm_main_sel_op_xor, witness_commitments.avm_main_sel_op_xor); + transcript->send_to_verifier(commitment_labels.avm_main_sel_rng_16, witness_commitments.avm_main_sel_rng_16); + transcript->send_to_verifier(commitment_labels.avm_main_sel_rng_8, witness_commitments.avm_main_sel_rng_8); + transcript->send_to_verifier(commitment_labels.avm_main_tag_err, witness_commitments.avm_main_tag_err); + transcript->send_to_verifier(commitment_labels.avm_main_w_in_tag, witness_commitments.avm_main_w_in_tag); + transcript->send_to_verifier(commitment_labels.avm_mem_addr, witness_commitments.avm_mem_addr); + transcript->send_to_verifier(commitment_labels.avm_mem_clk, witness_commitments.avm_mem_clk); + 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); + 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); + 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_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); + transcript->send_to_verifier(commitment_labels.avm_mem_val, witness_commitments.avm_mem_val); + transcript->send_to_verifier(commitment_labels.avm_mem_w_in_tag, witness_commitments.avm_mem_w_in_tag); + transcript->send_to_verifier(commitment_labels.lookup_byte_lengths_counts, + witness_commitments.lookup_byte_lengths_counts); + transcript->send_to_verifier(commitment_labels.lookup_byte_operations_counts, + witness_commitments.lookup_byte_operations_counts); + transcript->send_to_verifier(commitment_labels.incl_main_tag_err_counts, + 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); + 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); + transcript->send_to_verifier(commitment_labels.lookup_u16_1_counts, witness_commitments.lookup_u16_1_counts); + transcript->send_to_verifier(commitment_labels.lookup_u16_2_counts, witness_commitments.lookup_u16_2_counts); + transcript->send_to_verifier(commitment_labels.lookup_u16_3_counts, witness_commitments.lookup_u16_3_counts); + transcript->send_to_verifier(commitment_labels.lookup_u16_4_counts, witness_commitments.lookup_u16_4_counts); + transcript->send_to_verifier(commitment_labels.lookup_u16_5_counts, witness_commitments.lookup_u16_5_counts); + transcript->send_to_verifier(commitment_labels.lookup_u16_6_counts, witness_commitments.lookup_u16_6_counts); + transcript->send_to_verifier(commitment_labels.lookup_u16_7_counts, witness_commitments.lookup_u16_7_counts); + transcript->send_to_verifier(commitment_labels.lookup_u16_8_counts, witness_commitments.lookup_u16_8_counts); + transcript->send_to_verifier(commitment_labels.lookup_u16_9_counts, witness_commitments.lookup_u16_9_counts); + transcript->send_to_verifier(commitment_labels.lookup_u16_10_counts, witness_commitments.lookup_u16_10_counts); + transcript->send_to_verifier(commitment_labels.lookup_u16_11_counts, witness_commitments.lookup_u16_11_counts); + 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); +} + +void AvmProver::execute_log_derivative_inverse_round() +{ + + auto [beta, gamm] = transcript->template get_challenges("beta", "gamma"); + relation_parameters.beta = beta; + relation_parameters.gamma = gamm; + + key->compute_logderivative_inverses(relation_parameters); + + // Commit to all logderivative inverse polynomials + witness_commitments.perm_main_alu = commitment_key->commit(key->perm_main_alu); + witness_commitments.perm_main_bin = commitment_key->commit(key->perm_main_bin); + 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_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); + 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); + 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); + witness_commitments.lookup_u16_1 = commitment_key->commit(key->lookup_u16_1); + witness_commitments.lookup_u16_2 = commitment_key->commit(key->lookup_u16_2); + witness_commitments.lookup_u16_3 = commitment_key->commit(key->lookup_u16_3); + witness_commitments.lookup_u16_4 = commitment_key->commit(key->lookup_u16_4); + witness_commitments.lookup_u16_5 = commitment_key->commit(key->lookup_u16_5); + witness_commitments.lookup_u16_6 = commitment_key->commit(key->lookup_u16_6); + witness_commitments.lookup_u16_7 = commitment_key->commit(key->lookup_u16_7); + witness_commitments.lookup_u16_8 = commitment_key->commit(key->lookup_u16_8); + witness_commitments.lookup_u16_9 = commitment_key->commit(key->lookup_u16_9); + witness_commitments.lookup_u16_10 = commitment_key->commit(key->lookup_u16_10); + witness_commitments.lookup_u16_11 = commitment_key->commit(key->lookup_u16_11); + 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); + + // Send all commitments to the verifier + transcript->send_to_verifier(commitment_labels.perm_main_alu, witness_commitments.perm_main_alu); + transcript->send_to_verifier(commitment_labels.perm_main_bin, witness_commitments.perm_main_bin); + 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); + 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.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); + 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); + transcript->send_to_verifier(commitment_labels.lookup_u16_1, witness_commitments.lookup_u16_1); + transcript->send_to_verifier(commitment_labels.lookup_u16_2, witness_commitments.lookup_u16_2); + transcript->send_to_verifier(commitment_labels.lookup_u16_3, witness_commitments.lookup_u16_3); + transcript->send_to_verifier(commitment_labels.lookup_u16_4, witness_commitments.lookup_u16_4); + transcript->send_to_verifier(commitment_labels.lookup_u16_5, witness_commitments.lookup_u16_5); + transcript->send_to_verifier(commitment_labels.lookup_u16_6, witness_commitments.lookup_u16_6); + transcript->send_to_verifier(commitment_labels.lookup_u16_7, witness_commitments.lookup_u16_7); + transcript->send_to_verifier(commitment_labels.lookup_u16_8, witness_commitments.lookup_u16_8); + transcript->send_to_verifier(commitment_labels.lookup_u16_9, witness_commitments.lookup_u16_9); + transcript->send_to_verifier(commitment_labels.lookup_u16_10, witness_commitments.lookup_u16_10); + transcript->send_to_verifier(commitment_labels.lookup_u16_11, witness_commitments.lookup_u16_11); + 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); } /** @@ -112,13 +529,8 @@ HonkProof& AvmProver::construct_proof() // Compute wire commitments execute_wire_commitments_round(); - // TODO: not implemented for codegen just yet // Compute sorted list accumulator and commitment - // execute_log_derivative_commitments_round(); - - // Fiat-Shamir: bbeta & gamma - // Compute grand product(s) and commitments. - // execute_grand_product_computation_round(); + execute_log_derivative_inverse_round(); // Fiat-Shamir: alpha // Run sumcheck subprotocol. diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.hpp index 1e15b341e17d..47e2603a9caa 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.hpp @@ -28,6 +28,7 @@ class AvmProver { void execute_preamble_round(); void execute_wire_commitments_round(); + void execute_log_derivative_inverse_round(); void execute_relation_check_rounds(); void execute_zeromorph_rounds(); @@ -46,6 +47,7 @@ class AvmProver { ProverPolynomials prover_polynomials; CommitmentLabels commitment_labels; + typename Flavor::WitnessCommitments witness_commitments; Polynomial quotient_W; diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp index 41365c548ab8..aabdf2c2d6bb 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp @@ -279,45 +279,6 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) commitments.avm_mem_val = transcript->template receive_from_prover(commitment_labels.avm_mem_val); commitments.avm_mem_w_in_tag = transcript->template receive_from_prover(commitment_labels.avm_mem_w_in_tag); - commitments.perm_main_alu = transcript->template receive_from_prover(commitment_labels.perm_main_alu); - commitments.perm_main_bin = transcript->template receive_from_prover(commitment_labels.perm_main_bin); - commitments.perm_main_mem_a = - transcript->template receive_from_prover(commitment_labels.perm_main_mem_a); - commitments.perm_main_mem_b = - 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_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); - commitments.lookup_byte_lengths = - transcript->template receive_from_prover(commitment_labels.lookup_byte_lengths); - commitments.lookup_byte_operations = - transcript->template receive_from_prover(commitment_labels.lookup_byte_operations); - commitments.incl_main_tag_err = - transcript->template receive_from_prover(commitment_labels.incl_main_tag_err); - commitments.incl_mem_tag_err = - transcript->template receive_from_prover(commitment_labels.incl_mem_tag_err); - commitments.lookup_u8_0 = transcript->template receive_from_prover(commitment_labels.lookup_u8_0); - commitments.lookup_u8_1 = transcript->template receive_from_prover(commitment_labels.lookup_u8_1); - commitments.lookup_u16_0 = transcript->template receive_from_prover(commitment_labels.lookup_u16_0); - commitments.lookup_u16_1 = transcript->template receive_from_prover(commitment_labels.lookup_u16_1); - commitments.lookup_u16_2 = transcript->template receive_from_prover(commitment_labels.lookup_u16_2); - commitments.lookup_u16_3 = transcript->template receive_from_prover(commitment_labels.lookup_u16_3); - commitments.lookup_u16_4 = transcript->template receive_from_prover(commitment_labels.lookup_u16_4); - commitments.lookup_u16_5 = transcript->template receive_from_prover(commitment_labels.lookup_u16_5); - commitments.lookup_u16_6 = transcript->template receive_from_prover(commitment_labels.lookup_u16_6); - commitments.lookup_u16_7 = transcript->template receive_from_prover(commitment_labels.lookup_u16_7); - commitments.lookup_u16_8 = transcript->template receive_from_prover(commitment_labels.lookup_u16_8); - commitments.lookup_u16_9 = transcript->template receive_from_prover(commitment_labels.lookup_u16_9); - commitments.lookup_u16_10 = transcript->template receive_from_prover(commitment_labels.lookup_u16_10); - commitments.lookup_u16_11 = transcript->template receive_from_prover(commitment_labels.lookup_u16_11); - commitments.lookup_u16_12 = transcript->template receive_from_prover(commitment_labels.lookup_u16_12); - commitments.lookup_u16_13 = transcript->template receive_from_prover(commitment_labels.lookup_u16_13); - commitments.lookup_u16_14 = transcript->template receive_from_prover(commitment_labels.lookup_u16_14); commitments.lookup_byte_lengths_counts = transcript->template receive_from_prover(commitment_labels.lookup_byte_lengths_counts); commitments.lookup_byte_operations_counts = @@ -361,6 +322,51 @@ bool AvmVerifier::verify_proof(const HonkProof& proof) commitments.lookup_u16_14_counts = transcript->template receive_from_prover(commitment_labels.lookup_u16_14_counts); + auto [beta, gamm] = transcript->template get_challenges("beta", "gamma"); + relation_parameters.beta = beta; + relation_parameters.gamma = gamm; + + // Get commitments to inverses + commitments.perm_main_alu = transcript->template receive_from_prover(commitment_labels.perm_main_alu); + commitments.perm_main_bin = transcript->template receive_from_prover(commitment_labels.perm_main_bin); + commitments.perm_main_mem_a = + transcript->template receive_from_prover(commitment_labels.perm_main_mem_a); + commitments.perm_main_mem_b = + 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_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); + commitments.lookup_byte_lengths = + transcript->template receive_from_prover(commitment_labels.lookup_byte_lengths); + commitments.lookup_byte_operations = + transcript->template receive_from_prover(commitment_labels.lookup_byte_operations); + commitments.incl_main_tag_err = + transcript->template receive_from_prover(commitment_labels.incl_main_tag_err); + commitments.incl_mem_tag_err = + transcript->template receive_from_prover(commitment_labels.incl_mem_tag_err); + commitments.lookup_u8_0 = transcript->template receive_from_prover(commitment_labels.lookup_u8_0); + commitments.lookup_u8_1 = transcript->template receive_from_prover(commitment_labels.lookup_u8_1); + commitments.lookup_u16_0 = transcript->template receive_from_prover(commitment_labels.lookup_u16_0); + commitments.lookup_u16_1 = transcript->template receive_from_prover(commitment_labels.lookup_u16_1); + commitments.lookup_u16_2 = transcript->template receive_from_prover(commitment_labels.lookup_u16_2); + commitments.lookup_u16_3 = transcript->template receive_from_prover(commitment_labels.lookup_u16_3); + commitments.lookup_u16_4 = transcript->template receive_from_prover(commitment_labels.lookup_u16_4); + commitments.lookup_u16_5 = transcript->template receive_from_prover(commitment_labels.lookup_u16_5); + commitments.lookup_u16_6 = transcript->template receive_from_prover(commitment_labels.lookup_u16_6); + commitments.lookup_u16_7 = transcript->template receive_from_prover(commitment_labels.lookup_u16_7); + commitments.lookup_u16_8 = transcript->template receive_from_prover(commitment_labels.lookup_u16_8); + commitments.lookup_u16_9 = transcript->template receive_from_prover(commitment_labels.lookup_u16_9); + commitments.lookup_u16_10 = transcript->template receive_from_prover(commitment_labels.lookup_u16_10); + commitments.lookup_u16_11 = transcript->template receive_from_prover(commitment_labels.lookup_u16_11); + commitments.lookup_u16_12 = transcript->template receive_from_prover(commitment_labels.lookup_u16_12); + commitments.lookup_u16_13 = transcript->template receive_from_prover(commitment_labels.lookup_u16_13); + commitments.lookup_u16_14 = transcript->template receive_from_prover(commitment_labels.lookup_u16_14); + // Execute Sumcheck Verifier const size_t log_circuit_size = numeric::get_msb(circuit_size); auto sumcheck = SumcheckVerifier(log_circuit_size, transcript); From 56d37bcbd7b3f9b73f0de4afab53db61555ba56f Mon Sep 17 00:00:00 2001 From: IlyasRidhuan Date: Wed, 10 Apr 2024 10:11:40 +0000 Subject: [PATCH 15/18] test: negative range check tests --- .../vm/tests/avm_comparison.test.cpp | 55 +++--- .../barretenberg/vm/tests/helpers.test.cpp | 157 ++++++++++++++++++ .../barretenberg/vm/tests/helpers.test.hpp | 3 +- 3 files changed, 188 insertions(+), 27 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_comparison.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_comparison.test.cpp index b0cda76b8fce..8267a9e33d8b 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_comparison.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_comparison.test.cpp @@ -145,7 +145,6 @@ INSTANTIATE_TEST_SUITE_P(AvmCmpTests, AvmCmpTestsLTE, testing::ValuesIn(positive enum CMP_FAILURES { IncorrectInputDecomposition, SubLoCheckFailed, - // SubHiCheckFailed, ResLoCheckFailed, ResHiCheckFailed, CounterRelationFailed, @@ -156,7 +155,6 @@ enum CMP_FAILURES { std::vector> cmp_failures = { { "INPUT_DECOMP_1", CMP_FAILURES::IncorrectInputDecomposition }, { "SUB_LO_1", CMP_FAILURES::SubLoCheckFailed }, - // { "SUB_HI_1", CMP_FAILURES::SubHiCheckFailed }, { "RES_LO", CMP_FAILURES::ResLoCheckFailed }, { "RES_HI", CMP_FAILURES::ResHiCheckFailed }, { "CMP_CTR_REL_2", CMP_FAILURES::CounterRelationFailed }, @@ -166,6 +164,7 @@ std::vector> cmp_failures = { }; std::vector neg_test_lt = { { 12023, 439321, 0 } }; +std::vector neg_test_lte = { { 12023, 12023, 0 } }; using EXPECTED_ERRORS = std::tuple; @@ -189,11 +188,8 @@ std::vector gen_mutated_trace_cmp(std::vector trace, case SubLoCheckFailed: alu_row->avm_alu_p_a_borrow = FF::one() - alu_row->avm_alu_p_a_borrow; break; - // case SubHiCheckFailed: - // alu_row->avm_alu_p_b_borrow = FF::one() - alu_row->avm_alu_p_b_borrow; - // break; case ResLoCheckFailed: - alu_row->avm_alu_res_lo = FF(0); + alu_row->avm_alu_res_lo = alu_row->avm_alu_res_lo - FF(1); break; case ResHiCheckFailed: alu_row->avm_alu_res_hi = FF(1); @@ -214,12 +210,11 @@ std::vector gen_mutated_trace_cmp(std::vector trace, // The range check fails in the context of the cmp operation if we set the boolean // result in ic to be incorrect. - // // Here we falsely claim LT(12,023, 439,321, 0). i.e. 12023 < 439321 is false. mutate_ic_in_trace(trace, std::move(select_row), c_mutated, true); + // Now we have to also update the value of res_lo = (A_SUB_B_LO * IS_GT + B_SUB_A_LO * (1 - IS_GT)) // to be B_SUB_A_LO - alu_row->avm_alu_borrow = FF(0); FF mutated_res_lo = alu_row->avm_alu_b_lo - alu_row->avm_alu_a_lo + alu_row->avm_alu_borrow * (uint256_t(1) << 128); @@ -239,21 +234,16 @@ std::vector gen_mutated_trace_cmp(std::vector trace, next_row->avm_alu_b_lo = mutated_res_lo; next_row->avm_alu_b_hi = mutated_res_hi; + // The final row contains the mutated res_x values at the a_x slots that will be range check. auto final_row = alu_row + 4; + // To prevent a trivial range check failure, we need to clear the lookup counters for the + // current value of res_lo stored in a_lo + clear_range_check_counters(trace, final_row->avm_alu_a_lo); final_row->avm_alu_a_lo = mutated_res_lo; final_row->avm_alu_a_hi = mutated_res_hi; uint256_t mutated_res_lo_u256 = mutated_res_lo; - - // The final row contains the mutated res_x values at the a_x slots that will be range check. - // To prevent a trivial range check failure, we need to update the lookup counts in the memory - - // Find the main row where the old u8 value in the first register is looked up - auto lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [final_row](Row r) { - return r.avm_main_clk == final_row->avm_alu_u8_r0 && r.avm_main_sel_rng_8 == FF(1); - }); - // Decrement the counter - lookup_row->lookup_u8_0_counts = lookup_row->lookup_u8_0_counts - 1; + // We update range check lookup counters and the registers here // Assign the new u8 value that goes into the first slice register. final_row->avm_alu_u8_r0 = static_cast(mutated_res_lo_u256); @@ -265,19 +255,15 @@ std::vector gen_mutated_trace_cmp(std::vector trace, new_lookup_row->lookup_u8_0_counts = new_lookup_row->lookup_u8_0_counts + 1; mutated_res_lo_u256 >>= 8; - // Do the same for the second u8 register - lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [final_row](Row r) { - return r.avm_main_clk == final_row->avm_alu_u8_r1 && r.avm_main_sel_rng_8 == FF(1); - }); - lookup_row->lookup_u8_1_counts = lookup_row->lookup_u8_1_counts - 1; - + // Assign the new u8 value that goes into the second slice register. final_row->avm_alu_u8_r1 = static_cast(mutated_res_lo_u256); new_lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [final_row](Row r) { return r.avm_main_clk == final_row->avm_alu_u8_r1 && r.avm_main_sel_rng_8 == FF(1); }); new_lookup_row->lookup_u8_1_counts = new_lookup_row->lookup_u8_1_counts + 1; mutated_res_lo_u256 >>= 8; - // Set the remaining 112 bits to the first u16 register to trigger the overflow + + // Set the remaining bits (that are > 16) to the first u16 register to trigger the overflow final_row->avm_alu_u16_r0 = mutated_res_lo_u256; break; @@ -301,11 +287,28 @@ TEST_P(AvmCmpNegativeTestsLT, ParamTest) auto trace = trace_builder.finalize(); std::function&& select_row = [](Row r) { return r.avm_main_sel_op_lt == FF(1); }; trace = gen_mutated_trace_cmp(trace, std::move(select_row), output, failure_mode); - // validate_trace_proof(std::move(trace)); EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), failure_string); } INSTANTIATE_TEST_SUITE_P(AvmCmpNegativeTests, AvmCmpNegativeTestsLT, testing::Combine(testing::ValuesIn(cmp_failures), testing::ValuesIn(neg_test_lt))); + +TEST_P(AvmCmpNegativeTestsLTE, ParamTest) +{ + const auto [failure, params] = GetParam(); + const auto [failure_string, failure_mode] = failure; + const auto [a, b, output] = params; + auto trace_builder = avm_trace::AvmTraceBuilder(); + trace_builder.calldata_copy(0, 0, 3, 0, std::vector{ a, b, output }); + trace_builder.op_lt(0, 0, 1, 2, AvmMemoryTag::FF); + trace_builder.return_op(0, 0, 0); + auto trace = trace_builder.finalize(); + std::function&& select_row = [](Row r) { return r.avm_main_sel_op_lt == FF(1); }; + trace = gen_mutated_trace_cmp(trace, std::move(select_row), output, failure_mode); + EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), failure_string); +} +INSTANTIATE_TEST_SUITE_P(AvmCmpNegativeTests, + AvmCmpNegativeTestsLTE, + testing::Combine(testing::ValuesIn(cmp_failures), testing::ValuesIn(neg_test_lte))); } // namespace tests_avm diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp index 05ad9ba6540a..b3e19758f8cb 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp @@ -76,4 +76,161 @@ void mutate_ic_in_trace(std::vector& trace, std::function&& sele EXPECT_TRUE(mem_row != trace.end()); mem_row->avm_mem_val = newValue; }; + +// TODO: There has to be a better way to do. +// This is a helper function to clear the range check counters associated with the alu register decomposition of +// "previous_value" so we don't trigger a trivial range_check count error +void clear_range_check_counters(std::vector& trace, uint256_t previous_value) +{ + // Find the main row where the old u8 value in the first register is looked up + FF lookup_value = static_cast(previous_value); + auto lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { + return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_8 == FF(1); + }); + // Decrement the counter + lookup_row->lookup_u8_0_counts = lookup_row->lookup_u8_0_counts - 1; + previous_value >>= 8; + lookup_value = static_cast(previous_value); + // Find the main row where the old u16 value in the second register is looked up + lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { + return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_8 == FF(1); + }); + // Decrement the counter + lookup_row->lookup_u8_1_counts = lookup_row->lookup_u8_1_counts - 1; + previous_value >>= 8; + + // U_16_0: Find the main row where the old u16 value in the first register is looked up + lookup_value = static_cast(previous_value); + lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { + return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); + }); + // Decrement the counter + lookup_row->lookup_u16_0_counts = lookup_row->lookup_u16_0_counts - 1; + previous_value >>= 16; + + // U_16_1: Find the main row where the old u16 value in the second register is looked up + lookup_value = static_cast(previous_value); + lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { + return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); + }); + // Decrement the counter + lookup_row->lookup_u16_1_counts = lookup_row->lookup_u16_1_counts - 1; + previous_value >>= 16; + + // U_16_2: Find the main row where the old u16 value in the second register is looked up + lookup_value = static_cast(previous_value); + lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { + return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); + }); + // Decrement the counter + lookup_row->lookup_u16_2_counts = lookup_row->lookup_u16_2_counts - 1; + previous_value >>= 16; + // U_16_3: Find the main row where the old u16 value in the second register is looked up + lookup_value = static_cast(previous_value); + lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { + return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); + }); + // Decrement the counter + lookup_row->lookup_u16_3_counts = lookup_row->lookup_u16_3_counts - 1; + previous_value >>= 16; + + // U_16_4: Find the main row where the old u16 value in the second register is looked up + lookup_value = static_cast(previous_value); + lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { + return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); + }); + // Decrement the counter + lookup_row->lookup_u16_4_counts = lookup_row->lookup_u16_4_counts - 1; + previous_value >>= 16; + + // U_16_5: Find the main row where the old u16 value in the second register is looked up + lookup_value = static_cast(previous_value); + lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { + return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); + }); + // Decrement the counter + lookup_row->lookup_u16_5_counts = lookup_row->lookup_u16_5_counts - 1; + previous_value >>= 16; + + // U_16_6: Find the main row where the old u16 value in the second register is looked up + lookup_value = static_cast(previous_value); + lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { + return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); + }); + // Decrement the counter + lookup_row->lookup_u16_6_counts = lookup_row->lookup_u16_6_counts - 1; + previous_value >>= 16; + + // U_16_7: Find the main row where the old u16 value in the second register is looked up + lookup_value = static_cast(previous_value); + lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { + return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); + }); + // Decrement the counter + lookup_row->lookup_u16_7_counts = lookup_row->lookup_u16_7_counts - 1; + previous_value >>= 16; + + // U_16_8: Find the main row where the old u16 value in the second register is looked up + lookup_value = static_cast(previous_value); + lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { + return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); + }); + // Decrement the counter + lookup_row->lookup_u16_8_counts = lookup_row->lookup_u16_8_counts - 1; + previous_value >>= 16; + + // U_16_9: Find the main row where the old u16 value in the second register is looked up + lookup_value = static_cast(previous_value); + lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { + return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); + }); + // Decrement the counter + lookup_row->lookup_u16_9_counts = lookup_row->lookup_u16_9_counts - 1; + previous_value >>= 16; + + // U_16_10: Find the main row where the old u16 value in the second register is looked up + lookup_value = static_cast(previous_value); + lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { + return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); + }); + // Decrement the counter + lookup_row->lookup_u16_10_counts = lookup_row->lookup_u16_10_counts - 1; + previous_value >>= 16; + + // U_16_11: Find the main row where the old u16 value in the second register is looked up + lookup_value = static_cast(previous_value); + lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { + return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); + }); + // Decrement the counter + lookup_row->lookup_u16_11_counts = lookup_row->lookup_u16_11_counts - 1; + previous_value >>= 16; + + // U_16_12: Find the main row where the old u16 value in the second register is looked up + lookup_value = static_cast(previous_value); + lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { + return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); + }); + // Decrement the counter + lookup_row->lookup_u16_12_counts = lookup_row->lookup_u16_12_counts - 1; + previous_value >>= 16; + + // U_16_13: Find the main row where the old u16 value in the second register is looked up + lookup_value = static_cast(previous_value); + lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { + return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); + }); + // Decrement the counter + lookup_row->lookup_u16_13_counts = lookup_row->lookup_u16_13_counts - 1; + previous_value >>= 16; + + // U_16_14: Find the main row where the old u16 value in the second register is looked up + lookup_value = static_cast(previous_value); + lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { + return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); + }); + // Decrement the counter + lookup_row->lookup_u16_14_counts = lookup_row->lookup_u16_14_counts - 1; + previous_value >>= 16; +} } // namespace tests_avm diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.hpp b/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.hpp index 0116ccaf538e..f55cfa923072 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.hpp @@ -22,5 +22,6 @@ void mutate_ic_in_trace(std::vector& trace, std::function&& selectRow, FF const& newValue, bool alu = false); +void clear_range_check_counters(std::vector& trace, uint256_t previous_value); -} // namespace tests_avm \ No newline at end of file +} // namespace tests_avm From 21bdef42acc19917969f4aae7c0ca856ad96a558 Mon Sep 17 00:00:00 2001 From: IlyasRidhuan Date: Wed, 10 Apr 2024 14:21:51 +0000 Subject: [PATCH 16/18] test: add mem_tags and simplify counter clearing --- .../vm/tests/avm_comparison.test.cpp | 59 +++++++----- .../barretenberg/vm/tests/helpers.test.cpp | 89 ++++--------------- 2 files changed, 58 insertions(+), 90 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_comparison.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_comparison.test.cpp index 8267a9e33d8b..1c05ee9d7cb2 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_comparison.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_comparison.test.cpp @@ -57,16 +57,17 @@ void common_validate_cmp(Row row, EXPECT_EQ(alu_row.avm_alu_ic, c); } } // namespace -using ThreeOpParamRow = std::array; -std::vector positive_op_lt_test_values = { { { FF(1), FF(1), FF(0) }, - { FF(5323), FF(321), FF(0) }, - { FF(13793), FF(10590617LLU), FF(1) }, - { FF(0x7bff744e3cdf79LLU), FF(0x14ccccccccb6LLU), FF(0) }, - { FF(uint256_t{ 0xb900000000000001 }), - FF(uint256_t{ 0x1006021301080000 } << 64) + - uint256_t{ 0x000000000000001080876844827 }, - 1 } } }; -std::vector positive_op_lte_test_values = { +using ThreeOpParam = std::array; +using ThreeOpParamRow = std::tuple; +std::vector positive_op_lt_test_values = { { { FF(1), FF(1), FF(0) }, + { FF(5323), FF(321), FF(0) }, + { FF(13793), FF(10590617LLU), FF(1) }, + { FF(0x7bff744e3cdf79LLU), FF(0x14ccccccccb6LLU), FF(0) }, + { FF(uint256_t{ 0xb900000000000001 }), + FF(uint256_t{ 0x1006021301080000 } << 64) + + uint256_t{ 0x000000000000001080876844827 }, + 1 } } }; +std::vector positive_op_lte_test_values = { { { FF(1), FF(1), FF(1) }, { FF(5323), FF(321), FF(0) }, { FF(13793), FF(10590617LLU), FF(1) }, @@ -75,6 +76,18 @@ std::vector positive_op_lte_test_values = { FF(uint256_t{ 0x1006021301080000 } << 64) + uint256_t{ 0x000000000000001080876844827 }, FF(1) } } }; + +std::vector gen_three_op_params(std::vector operands, std::vector mem_tags) +{ + std::vector params; + for (size_t i = 0; i < 5; i++) { + params.emplace_back(operands[i], mem_tags[i]); + } + return params; +} +std::vector mem_tags{ + { AvmMemoryTag::U8, AvmMemoryTag::U16, AvmMemoryTag::U32, AvmMemoryTag::U64, AvmMemoryTag::U128 } +}; class AvmCmpTests : public ::testing::Test { public: AvmTraceBuilder trace_builder; @@ -93,9 +106,10 @@ class AvmCmpTestsLTE : public AvmCmpTests, public testing::WithParamInterface{ a, b, c }); - trace_builder.op_lt(0, 0, 1, 2, AvmMemoryTag::FF); // [1,254,0,0,....] + trace_builder.op_lt(0, 0, 1, 2, mem_tag); trace_builder.return_op(0, 0, 0); auto trace = trace_builder.finalize(); // Validate the trace @@ -114,13 +128,16 @@ TEST_P(AvmCmpTestsLT, ParamTest) validate_trace_proof(std::move(trace)); } -INSTANTIATE_TEST_SUITE_P(AvmCmpTests, AvmCmpTestsLT, testing::ValuesIn(positive_op_lt_test_values)); +INSTANTIATE_TEST_SUITE_P(AvmCmpTests, + AvmCmpTestsLT, + testing::ValuesIn(gen_three_op_params(positive_op_lt_test_values, mem_tags))); TEST_P(AvmCmpTestsLTE, ParamTest) { - const auto [a, b, c] = GetParam(); + const auto [params, mem_tag] = GetParam(); + const auto [a, b, c] = params; trace_builder.calldata_copy(0, 0, 3, 0, std::vector{ a, b, c }); - trace_builder.op_lte(0, 0, 1, 2, AvmMemoryTag::FF); // [1,254,0,0,....] + trace_builder.op_lte(0, 0, 1, 2, mem_tag); trace_builder.return_op(0, 0, 0); auto trace = trace_builder.finalize(); auto row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_lte == FF(1); }); @@ -135,7 +152,9 @@ TEST_P(AvmCmpTestsLTE, ParamTest) common_validate_cmp(*row, *alu_row, a, b, c, FF(0), FF(1), FF(2), AvmMemoryTag::FF); validate_trace_proof(std::move(trace)); } -INSTANTIATE_TEST_SUITE_P(AvmCmpTests, AvmCmpTestsLTE, testing::ValuesIn(positive_op_lte_test_values)); +INSTANTIATE_TEST_SUITE_P(AvmCmpTests, + AvmCmpTestsLTE, + testing::ValuesIn(gen_three_op_params(positive_op_lte_test_values, mem_tags))); /****************************************************************************** * @@ -163,8 +182,8 @@ std::vector> cmp_failures = { { "LOOKUP_U16_0", CMP_FAILURES::RangeCheckFailed }, }; -std::vector neg_test_lt = { { 12023, 439321, 0 } }; -std::vector neg_test_lte = { { 12023, 12023, 0 } }; +std::vector neg_test_lt = { { 12023, 439321, 0 } }; +std::vector neg_test_lte = { { 12023, 12023, 0 } }; using EXPECTED_ERRORS = std::tuple; @@ -271,9 +290,9 @@ std::vector gen_mutated_trace_cmp(std::vector trace, return trace; } class AvmCmpNegativeTestsLT : public AvmCmpTests, - public testing::WithParamInterface> {}; + public testing::WithParamInterface> {}; class AvmCmpNegativeTestsLTE : public AvmCmpTests, - public testing::WithParamInterface> {}; + public testing::WithParamInterface> {}; TEST_P(AvmCmpNegativeTestsLT, ParamTest) { diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp index b3e19758f8cb..2745d5dd0bc9 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp @@ -83,154 +83,103 @@ void mutate_ic_in_trace(std::vector& trace, std::function&& sele void clear_range_check_counters(std::vector& trace, uint256_t previous_value) { // Find the main row where the old u8 value in the first register is looked up - FF lookup_value = static_cast(previous_value); - auto lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { - return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_8 == FF(1); - }); + size_t lookup_value = static_cast(previous_value); // Decrement the counter - lookup_row->lookup_u8_0_counts = lookup_row->lookup_u8_0_counts - 1; + trace.at(lookup_value).lookup_u8_0_counts = trace.at(lookup_value).lookup_u8_0_counts - 1; previous_value >>= 8; lookup_value = static_cast(previous_value); - // Find the main row where the old u16 value in the second register is looked up - lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { - return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_8 == FF(1); - }); // Decrement the counter - lookup_row->lookup_u8_1_counts = lookup_row->lookup_u8_1_counts - 1; + trace.at(lookup_value).lookup_u8_1_counts = trace.at(lookup_value).lookup_u8_1_counts - 1; previous_value >>= 8; // U_16_0: Find the main row where the old u16 value in the first register is looked up lookup_value = static_cast(previous_value); - lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { - return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); - }); // Decrement the counter - lookup_row->lookup_u16_0_counts = lookup_row->lookup_u16_0_counts - 1; + trace.at(lookup_value).lookup_u16_0_counts = trace.at(lookup_value).lookup_u16_0_counts - 1; previous_value >>= 16; // U_16_1: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); - lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { - return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); - }); // Decrement the counter - lookup_row->lookup_u16_1_counts = lookup_row->lookup_u16_1_counts - 1; + trace.at(lookup_value).lookup_u16_1_counts = trace.at(lookup_value).lookup_u16_1_counts - 1; previous_value >>= 16; // U_16_2: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); - lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { - return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); - }); // Decrement the counter - lookup_row->lookup_u16_2_counts = lookup_row->lookup_u16_2_counts - 1; + trace.at(lookup_value).lookup_u16_2_counts = trace.at(lookup_value).lookup_u16_2_counts - 1; previous_value >>= 16; + // U_16_3: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); - lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { - return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); - }); // Decrement the counter - lookup_row->lookup_u16_3_counts = lookup_row->lookup_u16_3_counts - 1; + trace.at(lookup_value).lookup_u16_3_counts = trace.at(lookup_value).lookup_u16_3_counts - 1; previous_value >>= 16; // U_16_4: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); - lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { - return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); - }); // Decrement the counter - lookup_row->lookup_u16_4_counts = lookup_row->lookup_u16_4_counts - 1; + trace.at(lookup_value).lookup_u16_4_counts = trace.at(lookup_value).lookup_u16_4_counts - 1; previous_value >>= 16; // U_16_5: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); - lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { - return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); - }); // Decrement the counter - lookup_row->lookup_u16_5_counts = lookup_row->lookup_u16_5_counts - 1; + trace.at(lookup_value).lookup_u16_5_counts = trace.at(lookup_value).lookup_u16_5_counts - 1; previous_value >>= 16; // U_16_6: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); - lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { - return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); - }); // Decrement the counter - lookup_row->lookup_u16_6_counts = lookup_row->lookup_u16_6_counts - 1; + trace.at(lookup_value).lookup_u16_6_counts = trace.at(lookup_value).lookup_u16_6_counts - 1; previous_value >>= 16; // U_16_7: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); - lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { - return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); - }); // Decrement the counter - lookup_row->lookup_u16_7_counts = lookup_row->lookup_u16_7_counts - 1; + trace.at(lookup_value).lookup_u16_7_counts = trace.at(lookup_value).lookup_u16_7_counts - 1; previous_value >>= 16; // U_16_8: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); - lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { - return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); - }); // Decrement the counter - lookup_row->lookup_u16_8_counts = lookup_row->lookup_u16_8_counts - 1; + trace.at(lookup_value).lookup_u16_8_counts = trace.at(lookup_value).lookup_u16_8_counts - 1; previous_value >>= 16; // U_16_9: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); - lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { - return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); - }); // Decrement the counter - lookup_row->lookup_u16_9_counts = lookup_row->lookup_u16_9_counts - 1; + trace.at(lookup_value).lookup_u16_9_counts = trace.at(lookup_value).lookup_u16_9_counts - 1; previous_value >>= 16; // U_16_10: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); - lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { - return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); - }); // Decrement the counter - lookup_row->lookup_u16_10_counts = lookup_row->lookup_u16_10_counts - 1; + trace.at(lookup_value).lookup_u16_10_counts = trace.at(lookup_value).lookup_u16_10_counts - 1; previous_value >>= 16; // U_16_11: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); - lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { - return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); - }); // Decrement the counter - lookup_row->lookup_u16_11_counts = lookup_row->lookup_u16_11_counts - 1; + trace.at(lookup_value).lookup_u16_11_counts = trace.at(lookup_value).lookup_u16_11_counts - 1; previous_value >>= 16; // U_16_12: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); - lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { - return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); - }); // Decrement the counter - lookup_row->lookup_u16_12_counts = lookup_row->lookup_u16_12_counts - 1; + trace.at(lookup_value).lookup_u16_12_counts = trace.at(lookup_value).lookup_u16_12_counts - 1; previous_value >>= 16; // U_16_13: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); - lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { - return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); - }); // Decrement the counter - lookup_row->lookup_u16_13_counts = lookup_row->lookup_u16_13_counts - 1; + trace.at(lookup_value).lookup_u16_13_counts = trace.at(lookup_value).lookup_u16_13_counts - 1; previous_value >>= 16; // U_16_14: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); - lookup_row = std::ranges::find_if(trace.begin(), trace.end(), [lookup_value](Row r) { - return r.avm_main_clk == lookup_value && r.avm_main_sel_rng_16 == FF(1); - }); // Decrement the counter - lookup_row->lookup_u16_14_counts = lookup_row->lookup_u16_14_counts - 1; + trace.at(lookup_value).lookup_u16_14_counts = trace.at(lookup_value).lookup_u16_14_counts - 1; previous_value >>= 16; } } // namespace tests_avm From bdff6f8064706e38e15b525921b88543e05bc2a2 Mon Sep 17 00:00:00 2001 From: IlyasRidhuan Date: Wed, 10 Apr 2024 16:01:51 +0000 Subject: [PATCH 17/18] chore: final fixes --- barretenberg/cpp/pil/avm/avm_alu.pil | 10 +-- .../relations/generated/avm/avm_alu.hpp | 8 +- .../vm/avm_trace/avm_alu_trace.cpp | 26 ++++--- .../vm/tests/avm_comparison.test.cpp | 77 +++++++++++-------- .../barretenberg/vm/tests/helpers.test.cpp | 34 ++++---- 5 files changed, 82 insertions(+), 73 deletions(-) diff --git a/barretenberg/cpp/pil/avm/avm_alu.pil b/barretenberg/cpp/pil/avm/avm_alu.pil index 70697cc12a0b..224c8f3d6f36 100644 --- a/barretenberg/cpp/pil/avm/avm_alu.pil +++ b/barretenberg/cpp/pil/avm/avm_alu.pil @@ -62,9 +62,7 @@ namespace avm_alu(256); pol commit cf; // Compute predicate telling whether there is a row entry in the ALU table. - #[SELECTOR_REL] alu_sel = op_add + op_sub + op_mul + op_not + op_eq + op_lt + op_lte; - #[SELECTOR_REL_2] cmp_sel = op_lt + op_lte; // ========= Type Constraints ============================================= @@ -440,7 +438,7 @@ namespace avm_alu(256); cmp_rng_ctr * ((1 - rng_chk_sel) * (1 - op_eq_diff_inv) + op_eq_diff_inv) - rng_chk_sel = 0; // We perform a range check if we have some range checks remaining or we are performing a comparison op - pol RNG_CHK_OP = (rng_chk_sel + cmp_sel); + pol RNG_CHK_OP = rng_chk_sel + cmp_sel; pol commit rng_chk_lookup_selector; #[RNG_CHK_LOOKUP_SELECTOR] @@ -448,7 +446,7 @@ namespace avm_alu(256); // Perform 128-bit range check on lo part #[LOWER_CMP_RNG_CHK] - a_lo = SUM_128 * (RNG_CHK_OP); + a_lo = SUM_128 * RNG_CHK_OP; // Perform 128-bit range check on hi part @@ -456,14 +454,14 @@ namespace avm_alu(256); a_hi = (u16_r7 + u16_r8 * 2**16 + u16_r9 * 2**32 + u16_r10 * 2**48 + u16_r11 * 2**64 + u16_r12 * 2**80 + - u16_r13 * 2**96 + u16_r14 * 2**112) * (RNG_CHK_OP); + u16_r13 * 2**96 + u16_r14 * 2**112) * RNG_CHK_OP; // Shift all elements "across" by 2 columns // TODO: there is an optimisation where we are able to do 1 less range check as the range check on // P_SUB_B is implied by the other range checks. // Briefly: given a > b and p > a and p > a - b - 1, it is sufficient confirm that p > b without a range check // To accomplish this we would likely change the order of the range_check so we can skip p_sub_b - #[SHIFT_RELS] + #[SHIFT_RELS_0] (a_lo' - b_lo) * rng_chk_sel' = 0; (a_hi' - b_hi) * rng_chk_sel' = 0; #[SHIFT_RELS_1] 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 289808621ae4..fc4fcff7998e 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_alu.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_alu.hpp @@ -85,12 +85,6 @@ template struct Avm_aluRow { inline std::string get_relation_label_avm_alu(int index) { switch (index) { - case 0: - return "SELECTOR_REL"; - - case 1: - return "SELECTOR_REL_2"; - case 10: return "ALU_ADD_SUB_1"; @@ -164,7 +158,7 @@ inline std::string get_relation_label_avm_alu(int index) return "UPPER_CMP_RNG_CHK"; case 40: - return "SHIFT_RELS"; + return "SHIFT_RELS_0"; case 42: return "SHIFT_RELS_1"; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.cpp index 469242154061..8414c411c3cb 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.cpp @@ -464,8 +464,8 @@ std::tuple> AvmAluTraceBuilder::to_alu_s } /** - * @brief This is a helper function that is used to generate the range check entries for the comparison operation. - * This additionally increments the counts for the corresponding range lookups entries. + * @brief This is a helper function that is used to generate the range check entries for the comparison operation + * (LT/LTE opcodes). This additionally increments the counts for the corresponding range lookups entries. * @param row The initial row where the comparison operation was performed * @param hi_lo_limbs The vector of 128-bit limbs hi and lo pairs of limbs that will be range checked. * @return A vector of AluTraceEntry rows for the range checks for the comparison operation. @@ -480,28 +480,30 @@ std::vector AvmAluTraceBuilder::cmp_range_che std::vector rows{ std::move(row) }; rows.resize(num_rows, {}); + // We need to ensure that the number of rows is even + ASSERT(hi_lo_limbs.size() % 2 == 0); // Now for each row, we need to unpack a pair from the hi_lo_limb array into the ALUs 8-bit and 16-bit registers // The first row unpacks a_lo and a_hi, the second row unpacks b_lo and b_hi, and so on. for (size_t j = 0; j < num_rows; j++) { - auto* r = &rows.at(j); + auto& r = rows.at(j); uint256_t lo_limb = hi_lo_limbs.at(2 * j); uint256_t hi_limb = hi_lo_limbs.at(2 * j + 1); uint256_t limb = lo_limb + (hi_limb << 128); // Unpack lo limb and handle in the 8-bit registers auto [alu_u8_r0, alu_u8_r1, alu_u16_reg] = AvmAluTraceBuilder::to_alu_slice_registers(limb); - r->alu_u8_r0 = alu_u8_r0; - r->alu_u8_r1 = alu_u8_r1; - std::copy(alu_u16_reg.begin(), alu_u16_reg.end(), r->alu_u16_reg.begin()); + r.alu_u8_r0 = alu_u8_r0; + r.alu_u8_r1 = alu_u8_r1; + std::copy(alu_u16_reg.begin(), alu_u16_reg.end(), r.alu_u16_reg.begin()); - r->cmp_rng_ctr = j > 0 ? static_cast(num_rows - j) : 0; - r->rng_chk_sel = j > 0; - r->alu_op_eq_diff_inv = j > 0 ? FF(num_rows - j).invert() : 0; + r.cmp_rng_ctr = j > 0 ? static_cast(num_rows - j) : 0; + r.rng_chk_sel = j > 0; + r.alu_op_eq_diff_inv = j > 0 ? FF(num_rows - j).invert() : 0; std::vector limb_arr = { hi_lo_limbs.begin() + static_cast(2 * j), hi_lo_limbs.end() }; // Resizing here is probably suboptimal for performance, we can probably handle the shorter vectors and // pad with zero during the finalise limb_arr.resize(10, FF::zero()); - r->hi_lo_limbs = limb_arr; + r.hi_lo_limbs = limb_arr; } return rows; } @@ -560,6 +562,7 @@ std::tuple gt_or_lte_witness(uint256_t const& a, uin * @param a Left operand of the LT * @param b Right operand of the LT * @param clk Clock referring to the operation in the main trace. + * @param in_tag Instruction tag defining the number of bits for the LT. * * @return FF The boolean result of LT casted to a finite field element */ @@ -569,7 +572,7 @@ FF AvmAluTraceBuilder::op_lt(FF const& a, FF const& b, AvmMemoryTag in_tag, uint bool c = uint256_t(a) < uint256_t(b); // Note: This is counter-intuitive, to show that a < b we actually show that b > a - // The subtlely is here that the circuit is designed as a GT(x,y) circuit, therefor we swap the inputs a & b + // The subtlety is here that the circuit is designed as a GT(x,y) circuit, therefore we swap the inputs a & b // Get the decomposition of b auto [a_lo, a_hi] = decompose(b); // Get the decomposition of a @@ -616,6 +619,7 @@ FF AvmAluTraceBuilder::op_lt(FF const& a, FF const& b, AvmMemoryTag in_tag, uint * @param a Left operand of the LTE * @param b Right operand of the LTE * @param clk Clock referring to the operation in the main trace. + * @param in_tag Instruction tag defining the number of bits for the LT. * * @return FF The boolean result of LTE casted to a finite field element */ diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_comparison.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_comparison.test.cpp index 1c05ee9d7cb2..ea50cc468a0f 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_comparison.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_comparison.test.cpp @@ -17,8 +17,8 @@ namespace tests_avm { using namespace bb::avm_trace; namespace { -void common_validate_cmp(Row row, - Row alu_row, +void common_validate_cmp(Row const& row, + Row const& alu_row, FF const& a, FF const& b, FF const& c, @@ -49,7 +49,7 @@ void common_validate_cmp(Row row, // Check the instruction tags EXPECT_EQ(row.avm_main_r_in_tag, FF(static_cast(tag))); - EXPECT_EQ(row.avm_main_w_in_tag, FF(1)); + EXPECT_EQ(row.avm_main_w_in_tag, FF(static_cast(AvmMemoryTag::U8))); // Check that intermediate registers are correctly copied in Alu trace EXPECT_EQ(alu_row.avm_alu_ia, a); @@ -77,15 +77,16 @@ std::vector positive_op_lte_test_values = { FF(1) } } }; -std::vector gen_three_op_params(std::vector operands, std::vector mem_tags) +std::vector gen_three_op_params(std::vector operands, + std::vector mem_tag_arr) { std::vector params; for (size_t i = 0; i < 5; i++) { - params.emplace_back(operands[i], mem_tags[i]); + params.emplace_back(operands[i], mem_tag_arr[i]); } return params; } -std::vector mem_tags{ +std::vector mem_tag_arr{ { AvmMemoryTag::U8, AvmMemoryTag::U16, AvmMemoryTag::U32, AvmMemoryTag::U64, AvmMemoryTag::U128 } }; class AvmCmpTests : public ::testing::Test { @@ -108,11 +109,15 @@ TEST_P(AvmCmpTestsLT, ParamTest) { const auto [params, mem_tag] = GetParam(); const auto [a, b, c] = params; - trace_builder.calldata_copy(0, 0, 3, 0, std::vector{ a, b, c }); + if (mem_tag == AvmMemoryTag::FF) { + trace_builder.calldata_copy(0, 0, 2, 0, std::vector{ a, b }); + } else { + trace_builder.op_set(0, uint128_t(a), 0, mem_tag); + trace_builder.op_set(0, uint128_t(b), 1, mem_tag); + } trace_builder.op_lt(0, 0, 1, 2, mem_tag); trace_builder.return_op(0, 0, 0); auto trace = trace_builder.finalize(); - // Validate the trace // Get the row in the avm with the LT selector set auto row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_lt == FF(1); }); @@ -120,23 +125,28 @@ TEST_P(AvmCmpTestsLT, ParamTest) // Use the row in the main trace to find the same operation in the alu trace. FF clk = row->avm_main_clk; auto alu_row = std::ranges::find_if( - trace.begin(), trace.end(), [clk](Row r) { return r.avm_alu_clk == clk && r.avm_alu_op_lt; }); + trace.begin(), trace.end(), [clk](Row r) { return r.avm_alu_clk == clk && r.avm_alu_op_lt == FF(1); }); // Check that both rows were found - EXPECT_TRUE(row != trace.end()); - EXPECT_TRUE(alu_row != trace.end()); - common_validate_cmp(*row, *alu_row, a, b, c, FF(0), FF(1), FF(2), AvmMemoryTag::FF); + ASSERT_TRUE(row != trace.end()); + ASSERT_TRUE(alu_row != trace.end()); + common_validate_cmp(*row, *alu_row, a, b, c, FF(0), FF(1), FF(2), mem_tag); validate_trace_proof(std::move(trace)); } INSTANTIATE_TEST_SUITE_P(AvmCmpTests, AvmCmpTestsLT, - testing::ValuesIn(gen_three_op_params(positive_op_lt_test_values, mem_tags))); + testing::ValuesIn(gen_three_op_params(positive_op_lt_test_values, mem_tag_arr))); TEST_P(AvmCmpTestsLTE, ParamTest) { const auto [params, mem_tag] = GetParam(); const auto [a, b, c] = params; - trace_builder.calldata_copy(0, 0, 3, 0, std::vector{ a, b, c }); + if (mem_tag == AvmMemoryTag::FF) { + trace_builder.calldata_copy(0, 0, 2, 0, std::vector{ a, b }); + } else { + trace_builder.op_set(0, uint128_t(a), 0, mem_tag); + trace_builder.op_set(0, uint128_t(b), 1, mem_tag); + } trace_builder.op_lte(0, 0, 1, 2, mem_tag); trace_builder.return_op(0, 0, 0); auto trace = trace_builder.finalize(); @@ -147,14 +157,14 @@ TEST_P(AvmCmpTestsLTE, ParamTest) auto alu_row = std::ranges::find_if( trace.begin(), trace.end(), [clk](Row r) { return r.avm_alu_clk == clk && r.avm_alu_op_lte; }); // Check that both rows were found - EXPECT_TRUE(row != trace.end()); - EXPECT_TRUE(alu_row != trace.end()); - common_validate_cmp(*row, *alu_row, a, b, c, FF(0), FF(1), FF(2), AvmMemoryTag::FF); + ASSERT_TRUE(row != trace.end()); + ASSERT_TRUE(alu_row != trace.end()); + common_validate_cmp(*row, *alu_row, a, b, c, FF(0), FF(1), FF(2), mem_tag); validate_trace_proof(std::move(trace)); } INSTANTIATE_TEST_SUITE_P(AvmCmpTests, AvmCmpTestsLTE, - testing::ValuesIn(gen_three_op_params(positive_op_lte_test_values, mem_tags))); + testing::ValuesIn(gen_three_op_params(positive_op_lte_test_values, mem_tag_arr))); /****************************************************************************** * @@ -178,19 +188,17 @@ std::vector> cmp_failures = { { "RES_HI", CMP_FAILURES::ResHiCheckFailed }, { "CMP_CTR_REL_2", CMP_FAILURES::CounterRelationFailed }, { "CTR_NON_ZERO_REL", CMP_FAILURES::CounterNonZeroCheckFailed }, - { "SHIFT_RELS", CMP_FAILURES::ShiftRelationFailed }, + { "SHIFT_RELS_0", CMP_FAILURES::ShiftRelationFailed }, { "LOOKUP_U16_0", CMP_FAILURES::RangeCheckFailed }, }; -std::vector neg_test_lt = { { 12023, 439321, 0 } }; -std::vector neg_test_lte = { { 12023, 12023, 0 } }; +std::vector neg_test_lt = { { FF::modulus - 1, FF::modulus_minus_two, 0 } }; +std::vector neg_test_lte = { { FF::modulus - 1, FF::modulus - 1, 0 } }; using EXPECTED_ERRORS = std::tuple; -std::vector gen_mutated_trace_cmp(std::vector trace, - std::function&& select_row, - FF c_mutated, - CMP_FAILURES fail_mode) +std::vector gen_mutated_trace_cmp( + std::vector trace, std::function select_row, FF c_mutated, CMP_FAILURES fail_mode, bool is_lte) { auto main_trace_row = std::ranges::find_if(trace.begin(), trace.end(), select_row); auto main_clk = main_trace_row->avm_main_clk; @@ -202,7 +210,7 @@ std::vector gen_mutated_trace_cmp(std::vector trace, std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_alu_cmp_rng_ctr > FF(0); }); switch (fail_mode) { case IncorrectInputDecomposition: - alu_row->avm_alu_a_lo = FF(0); + alu_row->avm_alu_a_lo = alu_row->avm_alu_a_lo + FF(1); break; case SubLoCheckFailed: alu_row->avm_alu_p_a_borrow = FF::one() - alu_row->avm_alu_p_a_borrow; @@ -233,11 +241,16 @@ std::vector gen_mutated_trace_cmp(std::vector trace, mutate_ic_in_trace(trace, std::move(select_row), c_mutated, true); // Now we have to also update the value of res_lo = (A_SUB_B_LO * IS_GT + B_SUB_A_LO * (1 - IS_GT)) - // to be B_SUB_A_LO alu_row->avm_alu_borrow = FF(0); FF mutated_res_lo = alu_row->avm_alu_b_lo - alu_row->avm_alu_a_lo + alu_row->avm_alu_borrow * (uint256_t(1) << 128); FF mutated_res_hi = alu_row->avm_alu_b_hi - alu_row->avm_alu_a_hi - alu_row->avm_alu_borrow; + + if (is_lte) { + mutated_res_lo = alu_row->avm_alu_a_lo - alu_row->avm_alu_b_lo - FF::one() + + alu_row->avm_alu_borrow * (uint256_t(1) << 128); + mutated_res_hi = alu_row->avm_alu_a_hi - alu_row->avm_alu_b_hi - alu_row->avm_alu_borrow; + } alu_row->avm_alu_res_lo = mutated_res_lo; alu_row->avm_alu_res_hi = mutated_res_hi; // For each subsequent row that involve the range check, we need to update the shifted values @@ -304,8 +317,8 @@ TEST_P(AvmCmpNegativeTestsLT, ParamTest) trace_builder.op_lt(0, 0, 1, 2, AvmMemoryTag::FF); trace_builder.return_op(0, 0, 0); auto trace = trace_builder.finalize(); - std::function&& select_row = [](Row r) { return r.avm_main_sel_op_lt == FF(1); }; - trace = gen_mutated_trace_cmp(trace, std::move(select_row), output, failure_mode); + std::function select_row = [](Row r) { return r.avm_main_sel_op_lt == FF(1); }; + trace = gen_mutated_trace_cmp(trace, select_row, output, failure_mode, false); EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), failure_string); } @@ -320,11 +333,11 @@ TEST_P(AvmCmpNegativeTestsLTE, ParamTest) const auto [a, b, output] = params; auto trace_builder = avm_trace::AvmTraceBuilder(); trace_builder.calldata_copy(0, 0, 3, 0, std::vector{ a, b, output }); - trace_builder.op_lt(0, 0, 1, 2, AvmMemoryTag::FF); + trace_builder.op_lte(0, 0, 1, 2, AvmMemoryTag::FF); trace_builder.return_op(0, 0, 0); auto trace = trace_builder.finalize(); - std::function&& select_row = [](Row r) { return r.avm_main_sel_op_lt == FF(1); }; - trace = gen_mutated_trace_cmp(trace, std::move(select_row), output, failure_mode); + std::function select_row = [](Row r) { return r.avm_main_sel_op_lte == FF(1); }; + trace = gen_mutated_trace_cmp(trace, select_row, output, failure_mode, true); EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), failure_string); } INSTANTIATE_TEST_SUITE_P(AvmCmpNegativeTests, diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp index 2745d5dd0bc9..c54e34cc6b19 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp @@ -85,101 +85,101 @@ void clear_range_check_counters(std::vector& trace, uint256_t previous_valu // Find the main row where the old u8 value in the first register is looked up size_t lookup_value = static_cast(previous_value); // Decrement the counter - trace.at(lookup_value).lookup_u8_0_counts = trace.at(lookup_value).lookup_u8_0_counts - 1; + trace.at(lookup_value + 1).lookup_u8_0_counts = trace.at(lookup_value + 1).lookup_u8_0_counts - 1; previous_value >>= 8; lookup_value = static_cast(previous_value); // Decrement the counter - trace.at(lookup_value).lookup_u8_1_counts = trace.at(lookup_value).lookup_u8_1_counts - 1; + trace.at(lookup_value + 1).lookup_u8_1_counts = trace.at(lookup_value + 1).lookup_u8_1_counts - 1; previous_value >>= 8; // U_16_0: Find the main row where the old u16 value in the first register is looked up lookup_value = static_cast(previous_value); // Decrement the counter - trace.at(lookup_value).lookup_u16_0_counts = trace.at(lookup_value).lookup_u16_0_counts - 1; + trace.at(lookup_value + 1).lookup_u16_0_counts = trace.at(lookup_value + 1).lookup_u16_0_counts - 1; previous_value >>= 16; // U_16_1: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); // Decrement the counter - trace.at(lookup_value).lookup_u16_1_counts = trace.at(lookup_value).lookup_u16_1_counts - 1; + trace.at(lookup_value + 1).lookup_u16_1_counts = trace.at(lookup_value + 1).lookup_u16_1_counts - 1; previous_value >>= 16; // U_16_2: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); // Decrement the counter - trace.at(lookup_value).lookup_u16_2_counts = trace.at(lookup_value).lookup_u16_2_counts - 1; + trace.at(lookup_value + 1).lookup_u16_2_counts = trace.at(lookup_value + 1).lookup_u16_2_counts - 1; previous_value >>= 16; // U_16_3: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); // Decrement the counter - trace.at(lookup_value).lookup_u16_3_counts = trace.at(lookup_value).lookup_u16_3_counts - 1; + trace.at(lookup_value + 1).lookup_u16_3_counts = trace.at(lookup_value + 1).lookup_u16_3_counts - 1; previous_value >>= 16; // U_16_4: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); // Decrement the counter - trace.at(lookup_value).lookup_u16_4_counts = trace.at(lookup_value).lookup_u16_4_counts - 1; + trace.at(lookup_value + 1).lookup_u16_4_counts = trace.at(lookup_value + 1).lookup_u16_4_counts - 1; previous_value >>= 16; // U_16_5: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); // Decrement the counter - trace.at(lookup_value).lookup_u16_5_counts = trace.at(lookup_value).lookup_u16_5_counts - 1; + trace.at(lookup_value + 1).lookup_u16_5_counts = trace.at(lookup_value + 1).lookup_u16_5_counts - 1; previous_value >>= 16; // U_16_6: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); // Decrement the counter - trace.at(lookup_value).lookup_u16_6_counts = trace.at(lookup_value).lookup_u16_6_counts - 1; + trace.at(lookup_value + 1).lookup_u16_6_counts = trace.at(lookup_value + 1).lookup_u16_6_counts - 1; previous_value >>= 16; // U_16_7: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); // Decrement the counter - trace.at(lookup_value).lookup_u16_7_counts = trace.at(lookup_value).lookup_u16_7_counts - 1; + trace.at(lookup_value + 1).lookup_u16_7_counts = trace.at(lookup_value + 1).lookup_u16_7_counts - 1; previous_value >>= 16; // U_16_8: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); // Decrement the counter - trace.at(lookup_value).lookup_u16_8_counts = trace.at(lookup_value).lookup_u16_8_counts - 1; + trace.at(lookup_value + 1).lookup_u16_8_counts = trace.at(lookup_value + 1).lookup_u16_8_counts - 1; previous_value >>= 16; // U_16_9: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); // Decrement the counter - trace.at(lookup_value).lookup_u16_9_counts = trace.at(lookup_value).lookup_u16_9_counts - 1; + trace.at(lookup_value + 1).lookup_u16_9_counts = trace.at(lookup_value + 1).lookup_u16_9_counts - 1; previous_value >>= 16; // U_16_10: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); // Decrement the counter - trace.at(lookup_value).lookup_u16_10_counts = trace.at(lookup_value).lookup_u16_10_counts - 1; + trace.at(lookup_value + 1).lookup_u16_10_counts = trace.at(lookup_value + 1).lookup_u16_10_counts - 1; previous_value >>= 16; // U_16_11: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); // Decrement the counter - trace.at(lookup_value).lookup_u16_11_counts = trace.at(lookup_value).lookup_u16_11_counts - 1; + trace.at(lookup_value + 1).lookup_u16_11_counts = trace.at(lookup_value + 1).lookup_u16_11_counts - 1; previous_value >>= 16; // U_16_12: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); // Decrement the counter - trace.at(lookup_value).lookup_u16_12_counts = trace.at(lookup_value).lookup_u16_12_counts - 1; + trace.at(lookup_value + 1).lookup_u16_12_counts = trace.at(lookup_value + 1).lookup_u16_12_counts - 1; previous_value >>= 16; // U_16_13: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); // Decrement the counter - trace.at(lookup_value).lookup_u16_13_counts = trace.at(lookup_value).lookup_u16_13_counts - 1; + trace.at(lookup_value + 1).lookup_u16_13_counts = trace.at(lookup_value + 1).lookup_u16_13_counts - 1; previous_value >>= 16; // U_16_14: Find the main row where the old u16 value in the second register is looked up lookup_value = static_cast(previous_value); // Decrement the counter - trace.at(lookup_value).lookup_u16_14_counts = trace.at(lookup_value).lookup_u16_14_counts - 1; + trace.at(lookup_value + 1).lookup_u16_14_counts = trace.at(lookup_value + 1).lookup_u16_14_counts - 1; previous_value >>= 16; } } // namespace tests_avm From 3035c925201e42ae69c165f16bfbfc52c21bb4b2 Mon Sep 17 00:00:00 2001 From: IlyasRidhuan Date: Wed, 10 Apr 2024 17:08:23 +0000 Subject: [PATCH 18/18] fix: initial value to satisfy gcc build --- .../cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.hpp index ccfd299a7b68..7d15c2f70df9 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_alu_trace.hpp @@ -47,7 +47,7 @@ class AvmAluTraceBuilder { // Comparison Operation bool borrow = false; - std::vector hi_lo_limbs; + std::vector hi_lo_limbs{}; bool p_a_borrow = false; bool p_b_borrow = false; uint8_t cmp_rng_ctr = 0;