diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/alu.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/alu.hpp index eda58900a6eb..c76657688978 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/alu.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/alu.hpp @@ -1,8 +1,8 @@ - #pragma once -#include "../../relation_parameters.hpp" -#include "../../relation_types.hpp" -#include "./declare_views.hpp" + +#include "barretenberg/relations/generated/avm/declare_views.hpp" +#include "barretenberg/relations/relation_parameters.hpp" +#include "barretenberg/relations/relation_types.hpp" namespace bb::Avm_vm { @@ -127,8 +127,6 @@ template struct AluRow { FF alu_u8_r1{}; FF alu_u8_r1_shift{}; FF alu_u8_tag{}; - - [[maybe_unused]] static std::vector names(); }; inline std::string get_relation_label_alu(int index) @@ -136,139 +134,94 @@ inline std::string get_relation_label_alu(int index) switch (index) { case 12: return "ALU_ADD_SUB_1"; - case 13: return "ALU_ADD_SUB_2"; - case 14: return "ALU_MULTIPLICATION_FF"; - case 15: return "ALU_MUL_COMMON_1"; - case 16: return "ALU_MUL_COMMON_2"; - case 19: return "ALU_MULTIPLICATION_OUT_U128"; - case 20: return "ALU_FF_NOT_XOR"; - case 21: return "ALU_OP_NOT"; - case 22: return "ALU_RES_IS_BOOL"; - case 23: return "ALU_OP_EQ"; - case 24: return "INPUT_DECOMP_1"; - case 25: return "INPUT_DECOMP_2"; - case 27: return "SUB_LO_1"; - case 28: return "SUB_HI_1"; - case 30: return "SUB_LO_2"; - case 31: return "SUB_HI_2"; - case 32: return "RES_LO"; - case 33: return "RES_HI"; - case 34: return "CMP_CTR_REL_1"; - case 35: return "CMP_CTR_REL_2"; - case 38: return "CTR_NON_ZERO_REL"; - case 39: return "RNG_CHK_LOOKUP_SELECTOR"; - case 40: return "LOWER_CMP_RNG_CHK"; - case 41: return "UPPER_CMP_RNG_CHK"; - case 42: return "SHIFT_RELS_0"; - case 44: return "SHIFT_RELS_1"; - case 46: return "SHIFT_RELS_2"; - case 48: return "SHIFT_RELS_3"; - case 50: return "OP_CAST_PREV_LINE"; - case 51: return "ALU_OP_CAST"; - case 52: return "OP_CAST_RNG_CHECK_P_SUB_A_LOW"; - case 53: return "OP_CAST_RNG_CHECK_P_SUB_A_HIGH"; - case 54: return "TWO_LINE_OP_NO_OVERLAP"; - case 55: return "SHR_RANGE_0"; - case 56: return "SHR_RANGE_1"; - case 57: return "SHL_RANGE_0"; - case 58: return "SHL_RANGE_1"; - case 60: return "SHIFT_LT_BIT_LEN"; - case 61: return "SHR_INPUT_DECOMPOSITION"; - case 62: return "SHR_OUTPUT"; - case 63: return "SHL_INPUT_DECOMPOSITION"; - case 64: return "SHL_OUTPUT"; - case 74: return "ALU_PROD_DIV"; - case 75: return "REMAINDER_RANGE_CHK"; - case 76: return "CMP_CTR_REL_3"; - case 78: return "DIVISION_RELATION"; } @@ -279,10 +232,10 @@ template class aluImpl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 5, 5, 5, 6, 6, 8, 3, 4, 4, 5, 4, 4, 3, 4, 3, 3, 4, 3, 6, 5, 3, 3, 3, 3, 4, 3, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 2, 5, 3, 3, 4, 4, 4, 4, - 4, 3, 5, 5, 4, 5, 5, 2, 3, 3, 3, 3, 3, 4, 4, 3, 5, 3, 3, 3, 5, 3, 3, 4, 4, 4, 4, 4, 4, + 4, 3, 5, 5, 4, 5, 5, 2, 3, 3, 3, 3, 3, 4, 4, 3, 5, 3, 3, 3, 5, 3, 3, 4, 4, 4, 4, 4, 4 }; template @@ -291,11 +244,9 @@ template class aluImpl { [[maybe_unused]] const RelationParameters&, [[maybe_unused]] const FF& scaling_factor) { - // Contribution 0 { Avm_DECLARE_VIEWS(0); - auto tmp = (alu_sel_alu - ((((((((((alu_op_add + alu_op_sub) + alu_op_mul) + alu_op_not) + alu_op_eq) + alu_op_cast) + alu_op_lt) + @@ -309,7 +260,6 @@ template class aluImpl { // Contribution 1 { Avm_DECLARE_VIEWS(1); - auto tmp = (alu_sel_cmp - (alu_op_lt + alu_op_lte)); tmp *= scaling_factor; std::get<1>(evals) += tmp; @@ -317,7 +267,6 @@ template class aluImpl { // Contribution 2 { Avm_DECLARE_VIEWS(2); - auto tmp = (alu_sel_shift_which - (alu_op_shl + alu_op_shr)); tmp *= scaling_factor; std::get<2>(evals) += tmp; @@ -325,7 +274,6 @@ template class aluImpl { // Contribution 3 { Avm_DECLARE_VIEWS(3); - auto tmp = (alu_cf * (-alu_cf + FF(1))); tmp *= scaling_factor; std::get<3>(evals) += tmp; @@ -333,7 +281,6 @@ template class aluImpl { // Contribution 4 { Avm_DECLARE_VIEWS(4); - auto tmp = (alu_ff_tag * (-alu_ff_tag + FF(1))); tmp *= scaling_factor; std::get<4>(evals) += tmp; @@ -341,7 +288,6 @@ template class aluImpl { // Contribution 5 { Avm_DECLARE_VIEWS(5); - auto tmp = (alu_u8_tag * (-alu_u8_tag + FF(1))); tmp *= scaling_factor; std::get<5>(evals) += tmp; @@ -349,7 +295,6 @@ template class aluImpl { // Contribution 6 { Avm_DECLARE_VIEWS(6); - auto tmp = (alu_u16_tag * (-alu_u16_tag + FF(1))); tmp *= scaling_factor; std::get<6>(evals) += tmp; @@ -357,7 +302,6 @@ template class aluImpl { // Contribution 7 { Avm_DECLARE_VIEWS(7); - auto tmp = (alu_u32_tag * (-alu_u32_tag + FF(1))); tmp *= scaling_factor; std::get<7>(evals) += tmp; @@ -365,7 +309,6 @@ template class aluImpl { // Contribution 8 { Avm_DECLARE_VIEWS(8); - auto tmp = (alu_u64_tag * (-alu_u64_tag + FF(1))); tmp *= scaling_factor; std::get<8>(evals) += tmp; @@ -373,7 +316,6 @@ template class aluImpl { // Contribution 9 { Avm_DECLARE_VIEWS(9); - auto tmp = (alu_u128_tag * (-alu_u128_tag + FF(1))); tmp *= scaling_factor; std::get<9>(evals) += tmp; @@ -381,7 +323,6 @@ template class aluImpl { // Contribution 10 { Avm_DECLARE_VIEWS(10); - auto tmp = (alu_sel_alu * ((((((alu_ff_tag + alu_u8_tag) + alu_u16_tag) + alu_u32_tag) + alu_u64_tag) + alu_u128_tag) - FF(1))); @@ -391,7 +332,6 @@ template class aluImpl { // Contribution 11 { Avm_DECLARE_VIEWS(11); - auto tmp = (alu_in_tag - (((((alu_u8_tag + (alu_u16_tag * FF(2))) + (alu_u32_tag * FF(3))) + (alu_u64_tag * FF(4))) + (alu_u128_tag * FF(5))) + @@ -402,7 +342,6 @@ template class aluImpl { // Contribution 12 { Avm_DECLARE_VIEWS(12); - auto tmp = (((alu_op_add + alu_op_sub) * ((((((((((alu_u8_r0 + (alu_u8_r1 * FF(256))) + (alu_u16_r0 * FF(65536))) + (alu_u16_r1 * FF(4294967296UL))) + @@ -420,7 +359,6 @@ template class aluImpl { // Contribution 13 { Avm_DECLARE_VIEWS(13); - auto tmp = (((alu_op_add + alu_op_sub) * (((((((alu_u8_tag * alu_u8_r0) + (alu_u16_tag * (alu_u8_r0 + (alu_u8_r1 * FF(256))))) + (alu_u32_tag * ((alu_u8_r0 + (alu_u8_r1 * FF(256))) + (alu_u16_r0 * FF(65536))))) + @@ -443,7 +381,6 @@ template class aluImpl { // Contribution 14 { Avm_DECLARE_VIEWS(14); - auto tmp = ((alu_ff_tag * alu_op_mul) * ((alu_ia * alu_ib) - alu_ic)); tmp *= scaling_factor; std::get<14>(evals) += tmp; @@ -451,7 +388,6 @@ template class aluImpl { // Contribution 15 { Avm_DECLARE_VIEWS(15); - auto tmp = ((((-alu_ff_tag + FF(1)) - alu_u128_tag) * alu_op_mul) * (((((((((alu_u8_r0 + (alu_u8_r1 * FF(256))) + (alu_u16_r0 * FF(65536))) + (alu_u16_r1 * FF(4294967296UL))) + @@ -467,7 +403,6 @@ template class aluImpl { // Contribution 16 { Avm_DECLARE_VIEWS(16); - auto tmp = (alu_op_mul * (((((alu_u8_tag * alu_u8_r0) + (alu_u16_tag * (alu_u8_r0 + (alu_u8_r1 * FF(256))))) + (alu_u32_tag * ((alu_u8_r0 + (alu_u8_r1 * FF(256))) + (alu_u16_r0 * FF(65536))))) + @@ -481,7 +416,6 @@ template class aluImpl { // Contribution 17 { Avm_DECLARE_VIEWS(17); - auto tmp = ((alu_u128_tag * alu_op_mul) * ((((((alu_u8_r0 + (alu_u8_r1 * FF(256))) + (alu_u16_r0 * FF(65536))) + (alu_u16_r1 * FF(4294967296UL))) + @@ -496,7 +430,6 @@ template class aluImpl { // Contribution 18 { Avm_DECLARE_VIEWS(18); - auto tmp = ((alu_u128_tag * alu_op_mul) * ((((((alu_u8_r0_shift + (alu_u8_r1_shift * FF(256))) + (alu_u16_r0_shift * FF(65536))) + @@ -512,7 +445,6 @@ template class aluImpl { // Contribution 19 { Avm_DECLARE_VIEWS(19); - auto tmp = ((alu_u128_tag * alu_op_mul) * ((((alu_ia * ((((alu_u8_r0_shift + (alu_u8_r1_shift * FF(256))) + (alu_u16_r0_shift * FF(65536))) + @@ -535,7 +467,6 @@ template class aluImpl { // Contribution 20 { Avm_DECLARE_VIEWS(20); - auto tmp = (alu_op_not * alu_ff_tag); tmp *= scaling_factor; std::get<20>(evals) += tmp; @@ -543,7 +474,6 @@ template class aluImpl { // Contribution 21 { Avm_DECLARE_VIEWS(21); - auto tmp = (alu_op_not * ((alu_ia + alu_ic) - ((((((alu_u8_tag * FF(256)) + (alu_u16_tag * FF(65536))) + (alu_u32_tag * FF(4294967296UL))) + @@ -556,7 +486,6 @@ template class aluImpl { // Contribution 22 { Avm_DECLARE_VIEWS(22); - auto tmp = ((alu_sel_cmp + alu_op_eq) * (alu_ic * (-alu_ic + FF(1)))); tmp *= scaling_factor; std::get<22>(evals) += tmp; @@ -564,7 +493,6 @@ template class aluImpl { // Contribution 23 { Avm_DECLARE_VIEWS(23); - auto tmp = (alu_op_eq * ((((alu_ia - alu_ib) * ((alu_ic * (-alu_op_eq_diff_inv + FF(1))) + alu_op_eq_diff_inv)) - FF(1)) + @@ -575,7 +503,6 @@ template class aluImpl { // Contribution 24 { Avm_DECLARE_VIEWS(24); - auto tmp = (((alu_op_lt * alu_ib) + ((alu_op_lte + alu_op_cast) * alu_ia)) - ((alu_a_lo + (alu_a_hi * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) * (alu_sel_cmp + alu_op_cast))); tmp *= scaling_factor; @@ -584,7 +511,6 @@ template class aluImpl { // Contribution 25 { Avm_DECLARE_VIEWS(25); - auto tmp = (((alu_op_lt * alu_ia) + (alu_op_lte * alu_ib)) - ((alu_b_lo + (alu_b_hi * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) * alu_sel_cmp)); tmp *= scaling_factor; @@ -593,7 +519,6 @@ template class aluImpl { // Contribution 26 { Avm_DECLARE_VIEWS(26); - auto tmp = (alu_p_a_borrow * (-alu_p_a_borrow + FF(1))); tmp *= scaling_factor; std::get<26>(evals) += tmp; @@ -601,7 +526,6 @@ template class aluImpl { // Contribution 27 { Avm_DECLARE_VIEWS(27); - auto tmp = ((alu_p_sub_a_lo - ((-alu_a_lo + FF(uint256_t{ 4891460686036598784UL, 2896914383306846353UL, 0UL, 0UL })) + (alu_p_a_borrow * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL })))) * @@ -612,7 +536,6 @@ template class aluImpl { // Contribution 28 { Avm_DECLARE_VIEWS(28); - auto tmp = ((alu_p_sub_a_hi - ((-alu_a_hi + FF(uint256_t{ 13281191951274694749UL, 3486998266802970665UL, 0UL, 0UL })) - alu_p_a_borrow)) * @@ -623,7 +546,6 @@ template class aluImpl { // Contribution 29 { Avm_DECLARE_VIEWS(29); - auto tmp = (alu_p_b_borrow * (-alu_p_b_borrow + FF(1))); tmp *= scaling_factor; std::get<29>(evals) += tmp; @@ -631,7 +553,6 @@ template class aluImpl { // Contribution 30 { Avm_DECLARE_VIEWS(30); - auto tmp = ((alu_p_sub_b_lo - ((-alu_b_lo + FF(uint256_t{ 4891460686036598784UL, 2896914383306846353UL, 0UL, 0UL })) + (alu_p_b_borrow * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL })))) * @@ -642,7 +563,6 @@ template class aluImpl { // Contribution 31 { Avm_DECLARE_VIEWS(31); - auto tmp = ((alu_p_sub_b_hi - ((-alu_b_hi + FF(uint256_t{ 13281191951274694749UL, 3486998266802970665UL, 0UL, 0UL })) - alu_p_b_borrow)) * @@ -653,7 +573,6 @@ template class aluImpl { // Contribution 32 { Avm_DECLARE_VIEWS(32); - auto tmp = ((alu_res_lo - (((((alu_a_lo - alu_b_lo) - FF(1)) + (alu_borrow * FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }))) * ((alu_op_lt * alu_ic) + ((-alu_ic + FF(1)) * alu_op_lte))) + @@ -666,7 +585,6 @@ template class aluImpl { // Contribution 33 { Avm_DECLARE_VIEWS(33); - auto tmp = ((alu_res_hi - ((((alu_a_hi - alu_b_hi) - alu_borrow) * ((alu_op_lt * alu_ic) + ((-alu_ic + FF(1)) * alu_op_lte))) + @@ -679,7 +597,6 @@ template class aluImpl { // Contribution 34 { Avm_DECLARE_VIEWS(34); - auto tmp = (((alu_cmp_rng_ctr_shift - alu_cmp_rng_ctr) + FF(1)) * alu_cmp_rng_ctr); tmp *= scaling_factor; std::get<34>(evals) += tmp; @@ -687,7 +604,6 @@ template class aluImpl { // Contribution 35 { Avm_DECLARE_VIEWS(35); - auto tmp = ((alu_cmp_rng_ctr_shift - FF(4)) * alu_sel_cmp); tmp *= scaling_factor; std::get<35>(evals) += tmp; @@ -695,7 +611,6 @@ template class aluImpl { // Contribution 36 { Avm_DECLARE_VIEWS(36); - auto tmp = (alu_sel_rng_chk * (-alu_sel_rng_chk + FF(1))); tmp *= scaling_factor; std::get<36>(evals) += tmp; @@ -703,7 +618,6 @@ template class aluImpl { // Contribution 37 { Avm_DECLARE_VIEWS(37); - auto tmp = (alu_sel_rng_chk * alu_sel_cmp); tmp *= scaling_factor; std::get<37>(evals) += tmp; @@ -711,7 +625,6 @@ template class aluImpl { // Contribution 38 { Avm_DECLARE_VIEWS(38); - auto tmp = ((alu_cmp_rng_ctr * (((-alu_sel_rng_chk + FF(1)) * (-alu_op_eq_diff_inv + FF(1))) + alu_op_eq_diff_inv)) - alu_sel_rng_chk); @@ -721,7 +634,6 @@ template class aluImpl { // Contribution 39 { Avm_DECLARE_VIEWS(39); - auto tmp = (alu_sel_rng_chk_lookup_shift - ((((((((((alu_sel_cmp_shift + alu_sel_rng_chk_shift) + alu_op_add_shift) + alu_op_sub_shift) + alu_op_mul_shift) + @@ -737,7 +649,6 @@ template class aluImpl { // Contribution 40 { Avm_DECLARE_VIEWS(40); - auto tmp = (alu_a_lo - (((((((((alu_u8_r0 + (alu_u8_r1 * FF(256))) + (alu_u16_r0 * FF(65536))) + @@ -755,7 +666,6 @@ template class aluImpl { // Contribution 41 { Avm_DECLARE_VIEWS(41); - auto tmp = (alu_a_hi - ((((((((alu_u16_r7 + (alu_u16_r8 * FF(65536))) + (alu_u16_r9 * FF(4294967296UL))) + @@ -772,7 +682,6 @@ template class aluImpl { // Contribution 42 { Avm_DECLARE_VIEWS(42); - auto tmp = ((alu_a_lo_shift - alu_b_lo) * alu_sel_rng_chk_shift); tmp *= scaling_factor; std::get<42>(evals) += tmp; @@ -780,7 +689,6 @@ template class aluImpl { // Contribution 43 { Avm_DECLARE_VIEWS(43); - auto tmp = ((alu_a_hi_shift - alu_b_hi) * alu_sel_rng_chk_shift); tmp *= scaling_factor; std::get<43>(evals) += tmp; @@ -788,7 +696,6 @@ template class aluImpl { // Contribution 44 { Avm_DECLARE_VIEWS(44); - auto tmp = ((alu_b_lo_shift - alu_p_sub_a_lo) * alu_sel_rng_chk_shift); tmp *= scaling_factor; std::get<44>(evals) += tmp; @@ -796,7 +703,6 @@ template class aluImpl { // Contribution 45 { Avm_DECLARE_VIEWS(45); - auto tmp = ((alu_b_hi_shift - alu_p_sub_a_hi) * alu_sel_rng_chk_shift); tmp *= scaling_factor; std::get<45>(evals) += tmp; @@ -804,7 +710,6 @@ template class aluImpl { // Contribution 46 { Avm_DECLARE_VIEWS(46); - auto tmp = ((alu_p_sub_a_lo_shift - alu_p_sub_b_lo) * alu_sel_rng_chk_shift); tmp *= scaling_factor; std::get<46>(evals) += tmp; @@ -812,7 +717,6 @@ template class aluImpl { // Contribution 47 { Avm_DECLARE_VIEWS(47); - auto tmp = ((alu_p_sub_a_hi_shift - alu_p_sub_b_hi) * alu_sel_rng_chk_shift); tmp *= scaling_factor; std::get<47>(evals) += tmp; @@ -820,7 +724,6 @@ template class aluImpl { // Contribution 48 { Avm_DECLARE_VIEWS(48); - auto tmp = ((alu_p_sub_b_lo_shift - alu_res_lo) * alu_sel_rng_chk_shift); tmp *= scaling_factor; std::get<48>(evals) += tmp; @@ -828,7 +731,6 @@ template class aluImpl { // Contribution 49 { Avm_DECLARE_VIEWS(49); - auto tmp = ((alu_p_sub_b_hi_shift - alu_res_hi) * alu_sel_rng_chk_shift); tmp *= scaling_factor; std::get<49>(evals) += tmp; @@ -836,7 +738,6 @@ template class aluImpl { // Contribution 50 { Avm_DECLARE_VIEWS(50); - auto tmp = (alu_op_cast_prev_shift - alu_op_cast); tmp *= scaling_factor; std::get<50>(evals) += tmp; @@ -844,7 +745,6 @@ template class aluImpl { // Contribution 51 { Avm_DECLARE_VIEWS(51); - auto tmp = (alu_op_cast * (((((((alu_u8_tag * alu_u8_r0) + (alu_u16_tag * (alu_u8_r0 + (alu_u8_r1 * FF(256))))) + (alu_u32_tag * ((alu_u8_r0 + (alu_u8_r1 * FF(256))) + (alu_u16_r0 * FF(65536))))) + @@ -866,7 +766,6 @@ template class aluImpl { // Contribution 52 { Avm_DECLARE_VIEWS(52); - auto tmp = (alu_op_cast * (alu_a_lo_shift - alu_p_sub_a_lo)); tmp *= scaling_factor; std::get<52>(evals) += tmp; @@ -874,7 +773,6 @@ template class aluImpl { // Contribution 53 { Avm_DECLARE_VIEWS(53); - auto tmp = (alu_op_cast * (alu_a_hi_shift - alu_p_sub_a_hi)); tmp *= scaling_factor; std::get<53>(evals) += tmp; @@ -882,7 +780,6 @@ template class aluImpl { // Contribution 54 { Avm_DECLARE_VIEWS(54); - auto tmp = (((alu_op_mul * alu_u128_tag) + alu_op_cast) * alu_sel_alu_shift); tmp *= scaling_factor; std::get<54>(evals) += tmp; @@ -890,7 +787,6 @@ template class aluImpl { // Contribution 55 { Avm_DECLARE_VIEWS(55); - auto tmp = ((alu_shift_lt_bit_len * alu_op_shr) * (alu_a_lo - ((alu_two_pow_s - alu_b_lo) - FF(1)))); tmp *= scaling_factor; std::get<55>(evals) += tmp; @@ -898,7 +794,6 @@ template class aluImpl { // Contribution 56 { Avm_DECLARE_VIEWS(56); - auto tmp = ((alu_shift_lt_bit_len * alu_op_shr) * (alu_a_hi - ((alu_two_pow_t_sub_s - alu_b_hi) - FF(1)))); tmp *= scaling_factor; std::get<56>(evals) += tmp; @@ -906,7 +801,6 @@ template class aluImpl { // Contribution 57 { Avm_DECLARE_VIEWS(57); - auto tmp = ((alu_shift_lt_bit_len * alu_op_shl) * (alu_a_lo - ((alu_two_pow_t_sub_s - alu_b_lo) - FF(1)))); tmp *= scaling_factor; std::get<57>(evals) += tmp; @@ -914,7 +808,6 @@ template class aluImpl { // Contribution 58 { Avm_DECLARE_VIEWS(58); - auto tmp = ((alu_shift_lt_bit_len * alu_op_shl) * (alu_a_hi - ((alu_two_pow_s - alu_b_hi) - FF(1)))); tmp *= scaling_factor; std::get<58>(evals) += tmp; @@ -922,7 +815,6 @@ template class aluImpl { // Contribution 59 { Avm_DECLARE_VIEWS(59); - auto tmp = (alu_shift_lt_bit_len * (-alu_shift_lt_bit_len + FF(1))); tmp *= scaling_factor; std::get<59>(evals) += tmp; @@ -930,7 +822,6 @@ template class aluImpl { // Contribution 60 { Avm_DECLARE_VIEWS(60); - auto tmp = (alu_t_sub_s_bits - (alu_sel_shift_which * ((alu_shift_lt_bit_len * @@ -948,7 +839,6 @@ template class aluImpl { // Contribution 61 { Avm_DECLARE_VIEWS(61); - auto tmp = ((alu_shift_lt_bit_len * alu_op_shr) * (((alu_b_hi * alu_two_pow_s) + alu_b_lo) - alu_ia)); tmp *= scaling_factor; std::get<61>(evals) += tmp; @@ -956,7 +846,6 @@ template class aluImpl { // Contribution 62 { Avm_DECLARE_VIEWS(62); - auto tmp = (alu_op_shr * (alu_ic - (alu_b_hi * alu_shift_lt_bit_len))); tmp *= scaling_factor; std::get<62>(evals) += tmp; @@ -964,7 +853,6 @@ template class aluImpl { // Contribution 63 { Avm_DECLARE_VIEWS(63); - auto tmp = ((alu_shift_lt_bit_len * alu_op_shl) * (((alu_b_hi * alu_two_pow_t_sub_s) + alu_b_lo) - alu_ia)); tmp *= scaling_factor; std::get<63>(evals) += tmp; @@ -972,7 +860,6 @@ template class aluImpl { // Contribution 64 { Avm_DECLARE_VIEWS(64); - auto tmp = (alu_op_shl * (alu_ic - ((alu_b_lo * alu_two_pow_s) * alu_shift_lt_bit_len))); tmp *= scaling_factor; std::get<64>(evals) += tmp; @@ -980,7 +867,6 @@ template class aluImpl { // Contribution 65 { Avm_DECLARE_VIEWS(65); - auto tmp = (alu_op_div - (alu_op_div_std + alu_op_div_a_lt_b)); tmp *= scaling_factor; std::get<65>(evals) += tmp; @@ -988,7 +874,6 @@ template class aluImpl { // Contribution 66 { Avm_DECLARE_VIEWS(66); - auto tmp = (alu_op_div_a_lt_b * (-alu_op_div_a_lt_b + FF(1))); tmp *= scaling_factor; std::get<66>(evals) += tmp; @@ -996,7 +881,6 @@ template class aluImpl { // Contribution 67 { Avm_DECLARE_VIEWS(67); - auto tmp = (alu_op_div_a_lt_b * (alu_a_lo - ((alu_ib - alu_ia) - FF(1)))); tmp *= scaling_factor; std::get<67>(evals) += tmp; @@ -1004,7 +888,6 @@ template class aluImpl { // Contribution 68 { Avm_DECLARE_VIEWS(68); - auto tmp = (alu_op_div_a_lt_b * alu_ic); tmp *= scaling_factor; std::get<68>(evals) += tmp; @@ -1012,7 +895,6 @@ template class aluImpl { // Contribution 69 { Avm_DECLARE_VIEWS(69); - auto tmp = (alu_op_div_a_lt_b * (alu_ia - alu_remainder)); tmp *= scaling_factor; std::get<69>(evals) += tmp; @@ -1020,7 +902,6 @@ template class aluImpl { // Contribution 70 { Avm_DECLARE_VIEWS(70); - auto tmp = (alu_op_div_std * (-alu_op_div_std + FF(1))); tmp *= scaling_factor; std::get<70>(evals) += tmp; @@ -1028,7 +909,6 @@ template class aluImpl { // Contribution 71 { Avm_DECLARE_VIEWS(71); - auto tmp = (alu_op_div_std * ((alu_ib - alu_divisor_lo) - (alu_divisor_hi * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL })))); tmp *= scaling_factor; @@ -1037,7 +917,6 @@ template class aluImpl { // Contribution 72 { Avm_DECLARE_VIEWS(72); - auto tmp = (alu_op_div_std * ((alu_ic - alu_quotient_lo) - (alu_quotient_hi * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL })))); tmp *= scaling_factor; @@ -1046,7 +925,6 @@ template class aluImpl { // Contribution 73 { Avm_DECLARE_VIEWS(73); - auto tmp = (((alu_divisor_hi * alu_quotient_lo) + (alu_divisor_lo * alu_quotient_hi)) - (alu_partial_prod_lo + (alu_partial_prod_hi * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL })))); tmp *= scaling_factor; @@ -1055,7 +933,6 @@ template class aluImpl { // Contribution 74 { Avm_DECLARE_VIEWS(74); - auto tmp = (alu_op_div_std * ((((alu_divisor_lo * alu_quotient_lo) + (alu_partial_prod_lo * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + @@ -1067,7 +944,6 @@ template class aluImpl { // Contribution 75 { Avm_DECLARE_VIEWS(75); - auto tmp = (alu_op_div_std * (alu_b_hi - ((alu_ib - alu_remainder) - FF(1)))); tmp *= scaling_factor; std::get<75>(evals) += tmp; @@ -1075,7 +951,6 @@ template class aluImpl { // Contribution 76 { Avm_DECLARE_VIEWS(76); - auto tmp = ((alu_cmp_rng_ctr_shift - FF(2)) * alu_op_div_std); tmp *= scaling_factor; std::get<76>(evals) += tmp; @@ -1083,7 +958,6 @@ template class aluImpl { // Contribution 77 { Avm_DECLARE_VIEWS(77); - auto tmp = (alu_sel_rng_chk * alu_op_div_std); tmp *= scaling_factor; std::get<77>(evals) += tmp; @@ -1091,7 +965,6 @@ template class aluImpl { // Contribution 78 { Avm_DECLARE_VIEWS(78); - auto tmp = (alu_op_div_std * ((((alu_divisor_lo * alu_quotient_lo) + (alu_partial_prod_lo * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + @@ -1103,7 +976,6 @@ template class aluImpl { // Contribution 79 { Avm_DECLARE_VIEWS(79); - auto tmp = (alu_sel_div_rng_chk * (-alu_sel_div_rng_chk + FF(1))); tmp *= scaling_factor; std::get<79>(evals) += tmp; @@ -1111,7 +983,6 @@ template class aluImpl { // Contribution 80 { Avm_DECLARE_VIEWS(80); - auto tmp = ((alu_sel_div_rng_chk * alu_sel_div_rng_chk_shift) - alu_op_div_std); tmp *= scaling_factor; std::get<80>(evals) += tmp; @@ -1119,7 +990,6 @@ template class aluImpl { // Contribution 81 { Avm_DECLARE_VIEWS(81); - auto tmp = (alu_divisor_lo - (alu_op_div_std * (((alu_div_u16_r0 + (alu_div_u16_r1 * FF(65536))) + (alu_div_u16_r2 * FF(4294967296UL))) + (alu_div_u16_r3 * FF(281474976710656UL))))); @@ -1129,7 +999,6 @@ template class aluImpl { // Contribution 82 { Avm_DECLARE_VIEWS(82); - auto tmp = (alu_divisor_hi - (alu_op_div_std * (((alu_div_u16_r4 + (alu_div_u16_r5 * FF(65536))) + (alu_div_u16_r6 * FF(4294967296UL))) + (alu_div_u16_r7 * FF(281474976710656UL))))); @@ -1139,7 +1008,6 @@ template class aluImpl { // Contribution 83 { Avm_DECLARE_VIEWS(83); - auto tmp = (alu_quotient_lo - (alu_op_div_std * (((alu_div_u16_r0_shift + (alu_div_u16_r1_shift * FF(65536))) + (alu_div_u16_r2_shift * FF(4294967296UL))) + @@ -1150,7 +1018,6 @@ template class aluImpl { // Contribution 84 { Avm_DECLARE_VIEWS(84); - auto tmp = (alu_quotient_hi - (alu_op_div_std * (((alu_div_u16_r4_shift + (alu_div_u16_r5_shift * FF(65536))) + (alu_div_u16_r6_shift * FF(4294967296UL))) + @@ -1161,7 +1028,6 @@ template class aluImpl { // Contribution 85 { Avm_DECLARE_VIEWS(85); - auto tmp = (alu_partial_prod_lo - (alu_op_div_std * ((((alu_u8_r0_shift + (alu_u8_r1_shift * FF(256))) + (alu_u16_r0_shift * FF(65536))) + (alu_u16_r1_shift * FF(4294967296UL))) + @@ -1172,7 +1038,6 @@ template class aluImpl { // Contribution 86 { Avm_DECLARE_VIEWS(86); - auto tmp = (alu_partial_prod_hi - (alu_op_div_std * (((alu_u16_r3_shift + (alu_u16_r4_shift * FF(65536))) + (alu_u16_r5_shift * FF(4294967296UL))) + (alu_u16_r6_shift * FF(281474976710656UL))))); diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/binary.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/binary.hpp index 98260f373373..63f5885ec62a 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/binary.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/binary.hpp @@ -1,8 +1,8 @@ - #pragma once -#include "../../relation_parameters.hpp" -#include "../../relation_types.hpp" -#include "./declare_views.hpp" + +#include "barretenberg/relations/generated/avm/declare_views.hpp" +#include "barretenberg/relations/relation_parameters.hpp" +#include "barretenberg/relations/relation_types.hpp" namespace bb::Avm_vm { @@ -22,8 +22,6 @@ template struct BinaryRow { FF binary_op_id{}; FF binary_op_id_shift{}; FF binary_sel_bin{}; - - [[maybe_unused]] static std::vector names(); }; inline std::string get_relation_label_binary(int index) @@ -31,19 +29,14 @@ inline std::string get_relation_label_binary(int index) switch (index) { case 1: return "OP_ID_REL"; - case 2: return "MEM_TAG_REL"; - case 3: return "SEL_BIN_CTR_REL"; - case 7: return "ACC_REL_A"; - case 8: return "ACC_REL_B"; - case 9: return "ACC_REL_C"; } @@ -54,9 +47,7 @@ template class binaryImpl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, 3, 3, 4, 3, 3, 3, 4, 4, 4, - }; + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3, 3, 3, 4, 3, 3, 3, 4, 4, 4 }; template void static accumulate(ContainerOverSubrelations& evals, @@ -64,11 +55,9 @@ template class binaryImpl { [[maybe_unused]] const RelationParameters&, [[maybe_unused]] const FF& scaling_factor) { - // Contribution 0 { Avm_DECLARE_VIEWS(0); - auto tmp = (binary_sel_bin * (-binary_sel_bin + FF(1))); tmp *= scaling_factor; std::get<0>(evals) += tmp; @@ -76,7 +65,6 @@ template class binaryImpl { // Contribution 1 { Avm_DECLARE_VIEWS(1); - auto tmp = ((binary_op_id_shift - binary_op_id) * binary_mem_tag_ctr); tmp *= scaling_factor; std::get<1>(evals) += tmp; @@ -84,7 +72,6 @@ template class binaryImpl { // Contribution 2 { Avm_DECLARE_VIEWS(2); - auto tmp = (((binary_mem_tag_ctr_shift - binary_mem_tag_ctr) + FF(1)) * binary_mem_tag_ctr); tmp *= scaling_factor; std::get<2>(evals) += tmp; @@ -92,7 +79,6 @@ template class binaryImpl { // Contribution 3 { Avm_DECLARE_VIEWS(3); - auto tmp = ((binary_mem_tag_ctr * (((-binary_sel_bin + FF(1)) * (-binary_mem_tag_ctr_inv + FF(1))) + binary_mem_tag_ctr_inv)) - binary_sel_bin); @@ -102,7 +88,6 @@ template class binaryImpl { // Contribution 4 { Avm_DECLARE_VIEWS(4); - auto tmp = ((-binary_sel_bin + FF(1)) * binary_acc_ia); tmp *= scaling_factor; std::get<4>(evals) += tmp; @@ -110,7 +95,6 @@ template class binaryImpl { // Contribution 5 { Avm_DECLARE_VIEWS(5); - auto tmp = ((-binary_sel_bin + FF(1)) * binary_acc_ib); tmp *= scaling_factor; std::get<5>(evals) += tmp; @@ -118,7 +102,6 @@ template class binaryImpl { // Contribution 6 { Avm_DECLARE_VIEWS(6); - auto tmp = ((-binary_sel_bin + FF(1)) * binary_acc_ic); tmp *= scaling_factor; std::get<6>(evals) += tmp; @@ -126,7 +109,6 @@ template class binaryImpl { // Contribution 7 { Avm_DECLARE_VIEWS(7); - auto tmp = (((binary_acc_ia - binary_ia_bytes) - (binary_acc_ia_shift * FF(256))) * binary_mem_tag_ctr); tmp *= scaling_factor; std::get<7>(evals) += tmp; @@ -134,7 +116,6 @@ template class binaryImpl { // Contribution 8 { Avm_DECLARE_VIEWS(8); - auto tmp = (((binary_acc_ib - binary_ib_bytes) - (binary_acc_ib_shift * FF(256))) * binary_mem_tag_ctr); tmp *= scaling_factor; std::get<8>(evals) += tmp; @@ -142,7 +123,6 @@ template class binaryImpl { // Contribution 9 { Avm_DECLARE_VIEWS(9); - auto tmp = (((binary_acc_ic - binary_ic_bytes) - (binary_acc_ic_shift * FF(256))) * binary_mem_tag_ctr); tmp *= scaling_factor; std::get<9>(evals) += tmp; diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/conversion.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/conversion.hpp index b83fb6bf7ac6..cb63fa92f15b 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/conversion.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/conversion.hpp @@ -1,15 +1,13 @@ - #pragma once -#include "../../relation_parameters.hpp" -#include "../../relation_types.hpp" -#include "./declare_views.hpp" + +#include "barretenberg/relations/generated/avm/declare_views.hpp" +#include "barretenberg/relations/relation_parameters.hpp" +#include "barretenberg/relations/relation_types.hpp" namespace bb::Avm_vm { template struct ConversionRow { FF conversion_sel_to_radix_le{}; - - [[maybe_unused]] static std::vector names(); }; inline std::string get_relation_label_conversion(int index) @@ -22,9 +20,7 @@ template class conversionImpl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, - }; + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3 }; template void static accumulate(ContainerOverSubrelations& evals, @@ -32,11 +28,9 @@ template class conversionImpl { [[maybe_unused]] const RelationParameters&, [[maybe_unused]] const FF& scaling_factor) { - // Contribution 0 { Avm_DECLARE_VIEWS(0); - auto tmp = (conversion_sel_to_radix_le * (-conversion_sel_to_radix_le + FF(1))); tmp *= scaling_factor; std::get<0>(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 c50b8825f71d..f0c272ca4f7f 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/declare_views.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/declare_views.hpp @@ -1,3 +1,4 @@ +#pragma once #define Avm_DECLARE_VIEWS(index) \ using Accumulator = typename std::tuple_element::type; \ diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/gas.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/gas.hpp index a5e2adfe5a02..01bfe18a01db 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/gas.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/gas.hpp @@ -1,8 +1,8 @@ - #pragma once -#include "../../relation_parameters.hpp" -#include "../../relation_types.hpp" -#include "./declare_views.hpp" + +#include "barretenberg/relations/generated/avm/declare_views.hpp" +#include "barretenberg/relations/relation_parameters.hpp" +#include "barretenberg/relations/relation_types.hpp" namespace bb::Avm_vm { @@ -10,8 +10,6 @@ template struct GasRow { FF gas_da_gas_fixed_table{}; FF gas_l2_gas_fixed_table{}; FF gas_sel_gas_cost{}; - - [[maybe_unused]] static std::vector names(); }; inline std::string get_relation_label_gas(int index) @@ -24,11 +22,7 @@ template class gasImpl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 2, - 2, - 2, - }; + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 2, 2, 2 }; template void static accumulate(ContainerOverSubrelations& evals, @@ -36,11 +30,9 @@ template class gasImpl { [[maybe_unused]] const RelationParameters&, [[maybe_unused]] const FF& scaling_factor) { - // Contribution 0 { Avm_DECLARE_VIEWS(0); - auto tmp = (gas_sel_gas_cost - gas_sel_gas_cost); tmp *= scaling_factor; std::get<0>(evals) += tmp; @@ -48,7 +40,6 @@ template class gasImpl { // Contribution 1 { Avm_DECLARE_VIEWS(1); - auto tmp = (gas_l2_gas_fixed_table - gas_l2_gas_fixed_table); tmp *= scaling_factor; std::get<1>(evals) += tmp; @@ -56,7 +47,6 @@ template class gasImpl { // Contribution 2 { Avm_DECLARE_VIEWS(2); - auto tmp = (gas_da_gas_fixed_table - gas_da_gas_fixed_table); tmp *= scaling_factor; std::get<2>(evals) += tmp; diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/keccakf1600.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/keccakf1600.hpp index 56e0a9e6a5d3..e041345d104a 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/keccakf1600.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/keccakf1600.hpp @@ -1,15 +1,13 @@ - #pragma once -#include "../../relation_parameters.hpp" -#include "../../relation_types.hpp" -#include "./declare_views.hpp" + +#include "barretenberg/relations/generated/avm/declare_views.hpp" +#include "barretenberg/relations/relation_parameters.hpp" +#include "barretenberg/relations/relation_types.hpp" namespace bb::Avm_vm { template struct Keccakf1600Row { FF keccakf1600_sel_keccakf1600{}; - - [[maybe_unused]] static std::vector names(); }; inline std::string get_relation_label_keccakf1600(int index) @@ -22,9 +20,7 @@ template class keccakf1600Impl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, - }; + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3 }; template void static accumulate(ContainerOverSubrelations& evals, @@ -32,11 +28,9 @@ template class keccakf1600Impl { [[maybe_unused]] const RelationParameters&, [[maybe_unused]] const FF& scaling_factor) { - // Contribution 0 { Avm_DECLARE_VIEWS(0); - auto tmp = (keccakf1600_sel_keccakf1600 * (-keccakf1600_sel_keccakf1600 + FF(1))); tmp *= scaling_factor; std::get<0>(evals) += tmp; diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/kernel.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/kernel.hpp index a53770f6481b..7e57a548fc6a 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/kernel.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/kernel.hpp @@ -1,8 +1,8 @@ - #pragma once -#include "../../relation_parameters.hpp" -#include "../../relation_types.hpp" -#include "./declare_views.hpp" + +#include "barretenberg/relations/generated/avm/declare_views.hpp" +#include "barretenberg/relations/relation_parameters.hpp" +#include "barretenberg/relations/relation_types.hpp" namespace bb::Avm_vm { @@ -38,8 +38,6 @@ template struct KernelRow { FF main_sel_op_nullifier_exists{}; FF main_sel_op_sload{}; FF main_sel_op_sstore{}; - - [[maybe_unused]] static std::vector names(); }; inline std::string get_relation_label_kernel(int index) @@ -47,31 +45,22 @@ inline std::string get_relation_label_kernel(int index) switch (index) { case 0: return "NOTE_HASH_EXISTS_INC_CONSISTENCY_CHECK"; - case 1: return "EMIT_NOTE_HASH_INC_CONSISTENCY_CHECK"; - case 2: return "NULLIFIER_EXISTS_INC_CONSISTENCY_CHECK"; - case 3: return "NULLIFIER_NON_EXISTS_INC_CONSISTENCY_CHECK"; - case 4: return "EMIT_NULLIFIER_INC_CONSISTENCY_CHECK"; - case 5: return "L1_TO_L2_MSG_EXISTS_INC_CONSISTENCY_CHECK"; - case 6: return "EMIT_UNENCRYPTED_LOG_INC_CONSISTENCY_CHECK"; - case 7: return "EMIT_L2_TO_L1_MSG_INC_CONSISTENCY_CHECK"; - case 8: return "SLOAD_INC_CONSISTENCY_CHECK"; - case 9: return "SSTORE_INC_CONSISTENCY_CHECK"; } @@ -82,9 +71,7 @@ template class kernelImpl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, 3, 4, 4, 3, 3, 3, 3, 3, 3, - }; + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3, 3, 4, 4, 3, 3, 3, 3, 3, 3 }; template void static accumulate(ContainerOverSubrelations& evals, @@ -92,11 +79,9 @@ template class kernelImpl { [[maybe_unused]] const RelationParameters&, [[maybe_unused]] const FF& scaling_factor) { - // Contribution 0 { Avm_DECLARE_VIEWS(0); - auto tmp = ((-main_sel_last + FF(1)) * (kernel_note_hash_exist_write_offset_shift - (kernel_note_hash_exist_write_offset + main_sel_op_note_hash_exists))); @@ -106,7 +91,6 @@ template class kernelImpl { // Contribution 1 { Avm_DECLARE_VIEWS(1); - auto tmp = ((-main_sel_last + FF(1)) * (kernel_emit_note_hash_write_offset_shift - (kernel_emit_note_hash_write_offset + main_sel_op_emit_note_hash))); tmp *= scaling_factor; @@ -115,7 +99,6 @@ template class kernelImpl { // Contribution 2 { Avm_DECLARE_VIEWS(2); - auto tmp = ((-main_sel_last + FF(1)) * (kernel_nullifier_exists_write_offset_shift - (kernel_nullifier_exists_write_offset + (main_sel_op_nullifier_exists * main_ib)))); @@ -125,7 +108,6 @@ template class kernelImpl { // Contribution 3 { Avm_DECLARE_VIEWS(3); - auto tmp = ((-main_sel_last + FF(1)) * (kernel_nullifier_non_exists_write_offset_shift - @@ -136,7 +118,6 @@ template class kernelImpl { // Contribution 4 { Avm_DECLARE_VIEWS(4); - auto tmp = ((-main_sel_last + FF(1)) * (kernel_emit_nullifier_write_offset_shift - (kernel_emit_nullifier_write_offset + main_sel_op_emit_nullifier))); tmp *= scaling_factor; @@ -145,7 +126,6 @@ template class kernelImpl { // Contribution 5 { Avm_DECLARE_VIEWS(5); - auto tmp = ((-main_sel_last + FF(1)) * (kernel_l1_to_l2_msg_exists_write_offset_shift - (kernel_l1_to_l2_msg_exists_write_offset + main_sel_op_l1_to_l2_msg_exists))); @@ -155,7 +135,6 @@ template class kernelImpl { // Contribution 6 { Avm_DECLARE_VIEWS(6); - auto tmp = ((-main_sel_last + FF(1)) * (kernel_emit_unencrypted_log_write_offset_shift - (kernel_emit_unencrypted_log_write_offset + main_sel_op_emit_unencrypted_log))); @@ -165,7 +144,6 @@ template class kernelImpl { // Contribution 7 { Avm_DECLARE_VIEWS(7); - auto tmp = ((-main_sel_last + FF(1)) * (kernel_emit_l2_to_l1_msg_write_offset_shift - (kernel_emit_l2_to_l1_msg_write_offset + main_sel_op_emit_l2_to_l1_msg))); @@ -175,7 +153,6 @@ template class kernelImpl { // Contribution 8 { Avm_DECLARE_VIEWS(8); - auto tmp = ((-main_sel_last + FF(1)) * (kernel_sload_write_offset_shift - (kernel_sload_write_offset + main_sel_op_sload))); tmp *= scaling_factor; @@ -184,7 +161,6 @@ template class kernelImpl { // Contribution 9 { Avm_DECLARE_VIEWS(9); - auto tmp = ((-main_sel_last + FF(1)) * (kernel_sstore_write_offset_shift - (kernel_sstore_write_offset + main_sel_op_sstore))); tmp *= scaling_factor; diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/main.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/main.hpp index 36cdae9545be..ccddbaad2c83 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/main.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/main.hpp @@ -1,8 +1,8 @@ - #pragma once -#include "../../relation_parameters.hpp" -#include "../../relation_types.hpp" -#include "./declare_views.hpp" + +#include "barretenberg/relations/generated/avm/declare_views.hpp" +#include "barretenberg/relations/relation_parameters.hpp" +#include "barretenberg/relations/relation_types.hpp" namespace bb::Avm_vm { @@ -126,8 +126,6 @@ template struct MainRow { FF main_space_id{}; FF main_tag_err{}; FF main_w_in_tag{}; - - [[maybe_unused]] static std::vector names(); }; inline std::string get_relation_label_main(int index) @@ -135,154 +133,104 @@ inline std::string get_relation_label_main(int index) switch (index) { case 2: return "L2_GAS_REMAINING_DECREMENT"; - case 3: return "DA_GAS_REMAINING_DECREMENT"; - case 4: return "L2_GAS_INACTIVE"; - case 5: return "DA_GAS_INACTIVE"; - case 75: return "OUTPUT_U8"; - case 76: return "SUBOP_FDIV"; - case 77: return "SUBOP_FDIV_ZERO_ERR1"; - case 78: return "SUBOP_FDIV_ZERO_ERR2"; - case 79: return "SUBOP_FDIV_R_IN_TAG_FF"; - case 80: return "SUBOP_FDIV_W_IN_TAG_FF"; - case 81: return "SUBOP_ERROR_RELEVANT_OP"; - case 82: return "KERNEL_INPUT_ACTIVE_CHECK"; - case 83: return "KERNEL_OUTPUT_ACTIVE_CHECK"; - case 84: return "PC_JUMP"; - case 85: return "PC_JUMPI"; - case 86: return "RETURN_POINTER_INCREMENT"; - case 92: return "RETURN_POINTER_DECREMENT"; - case 98: return "PC_INCREMENT"; - case 99: return "INTERNAL_RETURN_POINTER_CONSISTENCY"; - case 100: return "SPACE_ID_INTERNAL"; - case 101: return "SPACE_ID_STANDARD_OPCODES"; - case 102: return "CMOV_CONDITION_RES_1"; - case 103: return "CMOV_CONDITION_RES_2"; - case 106: return "MOV_SAME_VALUE_A"; - case 107: return "MOV_SAME_VALUE_B"; - case 108: return "MOV_MAIN_SAME_TAG"; - case 112: return "L2GASLEFT"; - case 113: return "DAGASLEFT"; - case 114: return "ADDRESS_KERNEL"; - case 115: return "STORAGE_ADDRESS_KERNEL"; - case 116: return "SENDER_KERNEL"; - case 117: return "FUNCTION_SELECTOR_KERNEL"; - case 118: return "FEE_TRANSACTION_FEE_KERNEL"; - case 119: return "CHAIN_ID_KERNEL"; - case 120: return "VERSION_KERNEL"; - case 121: return "BLOCK_NUMBER_KERNEL"; - case 122: return "TIMESTAMP_KERNEL"; - case 123: return "COINBASE_KERNEL"; - case 124: return "FEE_DA_GAS_KERNEL"; - case 125: return "FEE_L2_GAS_KERNEL"; - case 126: return "NOTE_HASH_KERNEL_OUTPUT"; - case 128: return "EMIT_NOTE_HASH_KERNEL_OUTPUT"; - case 130: return "NULLIFIER_EXISTS_KERNEL_OUTPUT"; - case 133: return "EMIT_NULLIFIER_KERNEL_OUTPUT"; - case 135: return "L1_TO_L2_MSG_EXISTS_KERNEL_OUTPUT"; - case 137: return "EMIT_UNENCRYPTED_LOG_KERNEL_OUTPUT"; - case 139: return "EMIT_L2_TO_L1_MSGS_KERNEL_OUTPUT"; - case 141: return "SLOAD_KERNEL_OUTPUT"; - case 143: return "SSTORE_KERNEL_OUTPUT"; - case 146: return "BIN_SEL_1"; - case 147: return "BIN_SEL_2"; } @@ -293,11 +241,11 @@ template class 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, 5, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 4, 4, 3, 3, 3, 3, 3, 3, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 5, 3, 3, 3, 4, 4, 3, 3, 3, 3, 3, 4, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2 }; template @@ -306,11 +254,9 @@ template class mainImpl { [[maybe_unused]] const RelationParameters&, [[maybe_unused]] const FF& scaling_factor) { - // Contribution 0 { Avm_DECLARE_VIEWS(0); - auto tmp = (main_l2_out_of_gas * (-main_l2_out_of_gas + FF(1))); tmp *= scaling_factor; std::get<0>(evals) += tmp; @@ -318,7 +264,6 @@ template class mainImpl { // Contribution 1 { Avm_DECLARE_VIEWS(1); - auto tmp = (main_da_out_of_gas * (-main_da_out_of_gas + FF(1))); tmp *= scaling_factor; std::get<1>(evals) += tmp; @@ -326,7 +271,6 @@ template class mainImpl { // Contribution 2 { Avm_DECLARE_VIEWS(2); - auto tmp = (main_sel_gas_accounting_active * ((main_l2_gas_remaining_shift - main_l2_gas_remaining) + main_l2_gas_op_cost)); tmp *= scaling_factor; @@ -335,7 +279,6 @@ template class mainImpl { // Contribution 3 { Avm_DECLARE_VIEWS(3); - auto tmp = (main_sel_gas_accounting_active * ((main_da_gas_remaining_shift - main_da_gas_remaining) + main_da_gas_op_cost)); tmp *= scaling_factor; @@ -344,7 +287,6 @@ template class mainImpl { // Contribution 4 { Avm_DECLARE_VIEWS(4); - auto tmp = ((-main_sel_gas_accounting_active + FF(1)) * main_l2_gas_op_cost); tmp *= scaling_factor; std::get<4>(evals) += tmp; @@ -352,7 +294,6 @@ template class mainImpl { // Contribution 5 { Avm_DECLARE_VIEWS(5); - auto tmp = ((-main_sel_gas_accounting_active + FF(1)) * main_da_gas_op_cost); tmp *= scaling_factor; std::get<5>(evals) += tmp; @@ -360,7 +301,6 @@ template class mainImpl { // Contribution 6 { Avm_DECLARE_VIEWS(6); - auto tmp = (main_sel_gas_accounting_active * ((((-(main_l2_out_of_gas * FF(2)) + FF(1)) * main_l2_gas_remaining_shift) - (main_abs_l2_rem_gas_hi * FF(65536))) - @@ -371,7 +311,6 @@ template class mainImpl { // Contribution 7 { Avm_DECLARE_VIEWS(7); - auto tmp = (main_sel_gas_accounting_active * ((((-(main_da_out_of_gas * FF(2)) + FF(1)) * main_da_gas_remaining_shift) - (main_abs_da_rem_gas_hi * FF(65536))) - @@ -382,7 +321,6 @@ template class mainImpl { // Contribution 8 { Avm_DECLARE_VIEWS(8); - auto tmp = (main_sel_op_address * (-main_sel_op_address + FF(1))); tmp *= scaling_factor; std::get<8>(evals) += tmp; @@ -390,7 +328,6 @@ template class mainImpl { // Contribution 9 { Avm_DECLARE_VIEWS(9); - auto tmp = (main_sel_op_storage_address * (-main_sel_op_storage_address + FF(1))); tmp *= scaling_factor; std::get<9>(evals) += tmp; @@ -398,7 +335,6 @@ template class mainImpl { // Contribution 10 { Avm_DECLARE_VIEWS(10); - auto tmp = (main_sel_op_sender * (-main_sel_op_sender + FF(1))); tmp *= scaling_factor; std::get<10>(evals) += tmp; @@ -406,7 +342,6 @@ template class mainImpl { // Contribution 11 { Avm_DECLARE_VIEWS(11); - auto tmp = (main_sel_op_function_selector * (-main_sel_op_function_selector + FF(1))); tmp *= scaling_factor; std::get<11>(evals) += tmp; @@ -414,7 +349,6 @@ template class mainImpl { // Contribution 12 { Avm_DECLARE_VIEWS(12); - auto tmp = (main_sel_op_transaction_fee * (-main_sel_op_transaction_fee + FF(1))); tmp *= scaling_factor; std::get<12>(evals) += tmp; @@ -422,7 +356,6 @@ template class mainImpl { // Contribution 13 { Avm_DECLARE_VIEWS(13); - auto tmp = (main_sel_op_chain_id * (-main_sel_op_chain_id + FF(1))); tmp *= scaling_factor; std::get<13>(evals) += tmp; @@ -430,7 +363,6 @@ template class mainImpl { // Contribution 14 { Avm_DECLARE_VIEWS(14); - auto tmp = (main_sel_op_version * (-main_sel_op_version + FF(1))); tmp *= scaling_factor; std::get<14>(evals) += tmp; @@ -438,7 +370,6 @@ template class mainImpl { // Contribution 15 { Avm_DECLARE_VIEWS(15); - auto tmp = (main_sel_op_block_number * (-main_sel_op_block_number + FF(1))); tmp *= scaling_factor; std::get<15>(evals) += tmp; @@ -446,7 +377,6 @@ template class mainImpl { // Contribution 16 { Avm_DECLARE_VIEWS(16); - auto tmp = (main_sel_op_coinbase * (-main_sel_op_coinbase + FF(1))); tmp *= scaling_factor; std::get<16>(evals) += tmp; @@ -454,7 +384,6 @@ template class mainImpl { // Contribution 17 { Avm_DECLARE_VIEWS(17); - auto tmp = (main_sel_op_timestamp * (-main_sel_op_timestamp + FF(1))); tmp *= scaling_factor; std::get<17>(evals) += tmp; @@ -462,7 +391,6 @@ template class mainImpl { // Contribution 18 { Avm_DECLARE_VIEWS(18); - auto tmp = (main_sel_op_fee_per_l2_gas * (-main_sel_op_fee_per_l2_gas + FF(1))); tmp *= scaling_factor; std::get<18>(evals) += tmp; @@ -470,7 +398,6 @@ template class mainImpl { // Contribution 19 { Avm_DECLARE_VIEWS(19); - auto tmp = (main_sel_op_fee_per_da_gas * (-main_sel_op_fee_per_da_gas + FF(1))); tmp *= scaling_factor; std::get<19>(evals) += tmp; @@ -478,7 +405,6 @@ template class mainImpl { // Contribution 20 { Avm_DECLARE_VIEWS(20); - auto tmp = (main_sel_op_l2gasleft * (-main_sel_op_l2gasleft + FF(1))); tmp *= scaling_factor; std::get<20>(evals) += tmp; @@ -486,7 +412,6 @@ template class mainImpl { // Contribution 21 { Avm_DECLARE_VIEWS(21); - auto tmp = (main_sel_op_dagasleft * (-main_sel_op_dagasleft + FF(1))); tmp *= scaling_factor; std::get<21>(evals) += tmp; @@ -494,7 +419,6 @@ template class mainImpl { // Contribution 22 { Avm_DECLARE_VIEWS(22); - auto tmp = (main_sel_op_note_hash_exists * (-main_sel_op_note_hash_exists + FF(1))); tmp *= scaling_factor; std::get<22>(evals) += tmp; @@ -502,7 +426,6 @@ template class mainImpl { // Contribution 23 { Avm_DECLARE_VIEWS(23); - auto tmp = (main_sel_op_emit_note_hash * (-main_sel_op_emit_note_hash + FF(1))); tmp *= scaling_factor; std::get<23>(evals) += tmp; @@ -510,7 +433,6 @@ template class mainImpl { // Contribution 24 { Avm_DECLARE_VIEWS(24); - auto tmp = (main_sel_op_nullifier_exists * (-main_sel_op_nullifier_exists + FF(1))); tmp *= scaling_factor; std::get<24>(evals) += tmp; @@ -518,7 +440,6 @@ template class mainImpl { // Contribution 25 { Avm_DECLARE_VIEWS(25); - auto tmp = (main_sel_op_emit_nullifier * (-main_sel_op_emit_nullifier + FF(1))); tmp *= scaling_factor; std::get<25>(evals) += tmp; @@ -526,7 +447,6 @@ template class mainImpl { // Contribution 26 { Avm_DECLARE_VIEWS(26); - auto tmp = (main_sel_op_l1_to_l2_msg_exists * (-main_sel_op_l1_to_l2_msg_exists + FF(1))); tmp *= scaling_factor; std::get<26>(evals) += tmp; @@ -534,7 +454,6 @@ template class mainImpl { // Contribution 27 { Avm_DECLARE_VIEWS(27); - auto tmp = (main_sel_op_emit_unencrypted_log * (-main_sel_op_emit_unencrypted_log + FF(1))); tmp *= scaling_factor; std::get<27>(evals) += tmp; @@ -542,7 +461,6 @@ template class mainImpl { // Contribution 28 { Avm_DECLARE_VIEWS(28); - auto tmp = (main_sel_op_emit_l2_to_l1_msg * (-main_sel_op_emit_l2_to_l1_msg + FF(1))); tmp *= scaling_factor; std::get<28>(evals) += tmp; @@ -550,7 +468,6 @@ template class mainImpl { // Contribution 29 { Avm_DECLARE_VIEWS(29); - auto tmp = (main_sel_op_get_contract_instance * (-main_sel_op_get_contract_instance + FF(1))); tmp *= scaling_factor; std::get<29>(evals) += tmp; @@ -558,7 +475,6 @@ template class mainImpl { // Contribution 30 { Avm_DECLARE_VIEWS(30); - auto tmp = (main_sel_op_sload * (-main_sel_op_sload + FF(1))); tmp *= scaling_factor; std::get<30>(evals) += tmp; @@ -566,7 +482,6 @@ template class mainImpl { // Contribution 31 { Avm_DECLARE_VIEWS(31); - auto tmp = (main_sel_op_sstore * (-main_sel_op_sstore + FF(1))); tmp *= scaling_factor; std::get<31>(evals) += tmp; @@ -574,7 +489,6 @@ template class mainImpl { // Contribution 32 { Avm_DECLARE_VIEWS(32); - auto tmp = (main_sel_op_radix_le * (-main_sel_op_radix_le + FF(1))); tmp *= scaling_factor; std::get<32>(evals) += tmp; @@ -582,7 +496,6 @@ template class mainImpl { // Contribution 33 { Avm_DECLARE_VIEWS(33); - auto tmp = (main_sel_op_sha256 * (-main_sel_op_sha256 + FF(1))); tmp *= scaling_factor; std::get<33>(evals) += tmp; @@ -590,7 +503,6 @@ template class mainImpl { // Contribution 34 { Avm_DECLARE_VIEWS(34); - auto tmp = (main_sel_op_poseidon2 * (-main_sel_op_poseidon2 + FF(1))); tmp *= scaling_factor; std::get<34>(evals) += tmp; @@ -598,7 +510,6 @@ template class mainImpl { // Contribution 35 { Avm_DECLARE_VIEWS(35); - auto tmp = (main_sel_op_keccak * (-main_sel_op_keccak + FF(1))); tmp *= scaling_factor; std::get<35>(evals) += tmp; @@ -606,7 +517,6 @@ template class mainImpl { // Contribution 36 { Avm_DECLARE_VIEWS(36); - auto tmp = (main_sel_op_pedersen * (-main_sel_op_pedersen + FF(1))); tmp *= scaling_factor; std::get<36>(evals) += tmp; @@ -614,7 +524,6 @@ template class mainImpl { // Contribution 37 { Avm_DECLARE_VIEWS(37); - auto tmp = (main_sel_op_add * (-main_sel_op_add + FF(1))); tmp *= scaling_factor; std::get<37>(evals) += tmp; @@ -622,7 +531,6 @@ template class mainImpl { // Contribution 38 { Avm_DECLARE_VIEWS(38); - auto tmp = (main_sel_op_sub * (-main_sel_op_sub + FF(1))); tmp *= scaling_factor; std::get<38>(evals) += tmp; @@ -630,7 +538,6 @@ template class mainImpl { // Contribution 39 { Avm_DECLARE_VIEWS(39); - auto tmp = (main_sel_op_mul * (-main_sel_op_mul + FF(1))); tmp *= scaling_factor; std::get<39>(evals) += tmp; @@ -638,7 +545,6 @@ template class mainImpl { // Contribution 40 { Avm_DECLARE_VIEWS(40); - auto tmp = (main_sel_op_div * (-main_sel_op_div + FF(1))); tmp *= scaling_factor; std::get<40>(evals) += tmp; @@ -646,7 +552,6 @@ template class mainImpl { // Contribution 41 { Avm_DECLARE_VIEWS(41); - auto tmp = (main_sel_op_fdiv * (-main_sel_op_fdiv + FF(1))); tmp *= scaling_factor; std::get<41>(evals) += tmp; @@ -654,7 +559,6 @@ template class mainImpl { // Contribution 42 { Avm_DECLARE_VIEWS(42); - auto tmp = (main_sel_op_not * (-main_sel_op_not + FF(1))); tmp *= scaling_factor; std::get<42>(evals) += tmp; @@ -662,7 +566,6 @@ template class mainImpl { // Contribution 43 { Avm_DECLARE_VIEWS(43); - auto tmp = (main_sel_op_eq * (-main_sel_op_eq + FF(1))); tmp *= scaling_factor; std::get<43>(evals) += tmp; @@ -670,7 +573,6 @@ template class mainImpl { // Contribution 44 { Avm_DECLARE_VIEWS(44); - auto tmp = (main_sel_op_and * (-main_sel_op_and + FF(1))); tmp *= scaling_factor; std::get<44>(evals) += tmp; @@ -678,7 +580,6 @@ template class mainImpl { // Contribution 45 { Avm_DECLARE_VIEWS(45); - auto tmp = (main_sel_op_or * (-main_sel_op_or + FF(1))); tmp *= scaling_factor; std::get<45>(evals) += tmp; @@ -686,7 +587,6 @@ template class mainImpl { // Contribution 46 { Avm_DECLARE_VIEWS(46); - auto tmp = (main_sel_op_xor * (-main_sel_op_xor + FF(1))); tmp *= scaling_factor; std::get<46>(evals) += tmp; @@ -694,7 +594,6 @@ template class mainImpl { // Contribution 47 { Avm_DECLARE_VIEWS(47); - auto tmp = (main_sel_op_cast * (-main_sel_op_cast + FF(1))); tmp *= scaling_factor; std::get<47>(evals) += tmp; @@ -702,7 +601,6 @@ template class mainImpl { // Contribution 48 { Avm_DECLARE_VIEWS(48); - auto tmp = (main_sel_op_lt * (-main_sel_op_lt + FF(1))); tmp *= scaling_factor; std::get<48>(evals) += tmp; @@ -710,7 +608,6 @@ template class mainImpl { // Contribution 49 { Avm_DECLARE_VIEWS(49); - auto tmp = (main_sel_op_lte * (-main_sel_op_lte + FF(1))); tmp *= scaling_factor; std::get<49>(evals) += tmp; @@ -718,7 +615,6 @@ template class mainImpl { // Contribution 50 { Avm_DECLARE_VIEWS(50); - auto tmp = (main_sel_op_shl * (-main_sel_op_shl + FF(1))); tmp *= scaling_factor; std::get<50>(evals) += tmp; @@ -726,7 +622,6 @@ template class mainImpl { // Contribution 51 { Avm_DECLARE_VIEWS(51); - auto tmp = (main_sel_op_shr * (-main_sel_op_shr + FF(1))); tmp *= scaling_factor; std::get<51>(evals) += tmp; @@ -734,7 +629,6 @@ template class mainImpl { // Contribution 52 { Avm_DECLARE_VIEWS(52); - auto tmp = (main_sel_op_internal_call * (-main_sel_op_internal_call + FF(1))); tmp *= scaling_factor; std::get<52>(evals) += tmp; @@ -742,7 +636,6 @@ template class mainImpl { // Contribution 53 { Avm_DECLARE_VIEWS(53); - auto tmp = (main_sel_op_internal_return * (-main_sel_op_internal_return + FF(1))); tmp *= scaling_factor; std::get<53>(evals) += tmp; @@ -750,7 +643,6 @@ template class mainImpl { // Contribution 54 { Avm_DECLARE_VIEWS(54); - auto tmp = (main_sel_op_jump * (-main_sel_op_jump + FF(1))); tmp *= scaling_factor; std::get<54>(evals) += tmp; @@ -758,7 +650,6 @@ template class mainImpl { // Contribution 55 { Avm_DECLARE_VIEWS(55); - auto tmp = (main_sel_op_jumpi * (-main_sel_op_jumpi + FF(1))); tmp *= scaling_factor; std::get<55>(evals) += tmp; @@ -766,7 +657,6 @@ template class mainImpl { // Contribution 56 { Avm_DECLARE_VIEWS(56); - auto tmp = (main_sel_op_halt * (-main_sel_op_halt + FF(1))); tmp *= scaling_factor; std::get<56>(evals) += tmp; @@ -774,7 +664,6 @@ template class mainImpl { // Contribution 57 { Avm_DECLARE_VIEWS(57); - auto tmp = (main_sel_op_external_call * (-main_sel_op_external_call + FF(1))); tmp *= scaling_factor; std::get<57>(evals) += tmp; @@ -782,7 +671,6 @@ template class mainImpl { // Contribution 58 { Avm_DECLARE_VIEWS(58); - auto tmp = (main_sel_op_mov * (-main_sel_op_mov + FF(1))); tmp *= scaling_factor; std::get<58>(evals) += tmp; @@ -790,7 +678,6 @@ template class mainImpl { // Contribution 59 { Avm_DECLARE_VIEWS(59); - auto tmp = (main_sel_op_cmov * (-main_sel_op_cmov + FF(1))); tmp *= scaling_factor; std::get<59>(evals) += tmp; @@ -798,7 +685,6 @@ template class mainImpl { // Contribution 60 { Avm_DECLARE_VIEWS(60); - auto tmp = (main_op_err * (-main_op_err + FF(1))); tmp *= scaling_factor; std::get<60>(evals) += tmp; @@ -806,7 +692,6 @@ template class mainImpl { // Contribution 61 { Avm_DECLARE_VIEWS(61); - auto tmp = (main_tag_err * (-main_tag_err + FF(1))); tmp *= scaling_factor; std::get<61>(evals) += tmp; @@ -814,7 +699,6 @@ template class mainImpl { // Contribution 62 { Avm_DECLARE_VIEWS(62); - auto tmp = (main_id_zero * (-main_id_zero + FF(1))); tmp *= scaling_factor; std::get<62>(evals) += tmp; @@ -822,7 +706,6 @@ template class mainImpl { // Contribution 63 { Avm_DECLARE_VIEWS(63); - auto tmp = (main_sel_mem_op_a * (-main_sel_mem_op_a + FF(1))); tmp *= scaling_factor; std::get<63>(evals) += tmp; @@ -830,7 +713,6 @@ template class mainImpl { // Contribution 64 { Avm_DECLARE_VIEWS(64); - auto tmp = (main_sel_mem_op_b * (-main_sel_mem_op_b + FF(1))); tmp *= scaling_factor; std::get<64>(evals) += tmp; @@ -838,7 +720,6 @@ template class mainImpl { // Contribution 65 { Avm_DECLARE_VIEWS(65); - auto tmp = (main_sel_mem_op_c * (-main_sel_mem_op_c + FF(1))); tmp *= scaling_factor; std::get<65>(evals) += tmp; @@ -846,7 +727,6 @@ template class mainImpl { // Contribution 66 { Avm_DECLARE_VIEWS(66); - auto tmp = (main_sel_mem_op_d * (-main_sel_mem_op_d + FF(1))); tmp *= scaling_factor; std::get<66>(evals) += tmp; @@ -854,7 +734,6 @@ template class mainImpl { // Contribution 67 { Avm_DECLARE_VIEWS(67); - auto tmp = (main_rwa * (-main_rwa + FF(1))); tmp *= scaling_factor; std::get<67>(evals) += tmp; @@ -862,7 +741,6 @@ template class mainImpl { // Contribution 68 { Avm_DECLARE_VIEWS(68); - auto tmp = (main_rwb * (-main_rwb + FF(1))); tmp *= scaling_factor; std::get<68>(evals) += tmp; @@ -870,7 +748,6 @@ template class mainImpl { // Contribution 69 { Avm_DECLARE_VIEWS(69); - auto tmp = (main_rwc * (-main_rwc + FF(1))); tmp *= scaling_factor; std::get<69>(evals) += tmp; @@ -878,7 +755,6 @@ template class mainImpl { // Contribution 70 { Avm_DECLARE_VIEWS(70); - auto tmp = (main_rwd * (-main_rwd + FF(1))); tmp *= scaling_factor; std::get<70>(evals) += tmp; @@ -886,7 +762,6 @@ template class mainImpl { // Contribution 71 { Avm_DECLARE_VIEWS(71); - auto tmp = (main_sel_resolve_ind_addr_a * (-main_sel_resolve_ind_addr_a + FF(1))); tmp *= scaling_factor; std::get<71>(evals) += tmp; @@ -894,7 +769,6 @@ template class mainImpl { // Contribution 72 { Avm_DECLARE_VIEWS(72); - auto tmp = (main_sel_resolve_ind_addr_b * (-main_sel_resolve_ind_addr_b + FF(1))); tmp *= scaling_factor; std::get<72>(evals) += tmp; @@ -902,7 +776,6 @@ template class mainImpl { // Contribution 73 { Avm_DECLARE_VIEWS(73); - auto tmp = (main_sel_resolve_ind_addr_c * (-main_sel_resolve_ind_addr_c + FF(1))); tmp *= scaling_factor; std::get<73>(evals) += tmp; @@ -910,7 +783,6 @@ template class mainImpl { // Contribution 74 { Avm_DECLARE_VIEWS(74); - auto tmp = (main_sel_resolve_ind_addr_d * (-main_sel_resolve_ind_addr_d + FF(1))); tmp *= scaling_factor; std::get<74>(evals) += tmp; @@ -918,7 +790,6 @@ template class mainImpl { // Contribution 75 { Avm_DECLARE_VIEWS(75); - auto tmp = (((main_sel_op_eq + main_sel_op_lte) + main_sel_op_lt) * (main_w_in_tag - FF(1))); tmp *= scaling_factor; std::get<75>(evals) += tmp; @@ -926,7 +797,6 @@ template class mainImpl { // Contribution 76 { Avm_DECLARE_VIEWS(76); - auto tmp = ((main_sel_op_fdiv * (-main_op_err + FF(1))) * ((main_ic * main_ib) - main_ia)); tmp *= scaling_factor; std::get<76>(evals) += tmp; @@ -934,7 +804,6 @@ template class mainImpl { // Contribution 77 { Avm_DECLARE_VIEWS(77); - auto tmp = ((main_sel_op_fdiv + main_sel_op_div) * (((main_ib * main_inv) - FF(1)) + main_op_err)); tmp *= scaling_factor; std::get<77>(evals) += tmp; @@ -942,7 +811,6 @@ template class mainImpl { // Contribution 78 { Avm_DECLARE_VIEWS(78); - auto tmp = (((main_sel_op_fdiv + main_sel_op_div) * main_op_err) * (-main_inv + FF(1))); tmp *= scaling_factor; std::get<78>(evals) += tmp; @@ -950,7 +818,6 @@ template class mainImpl { // Contribution 79 { Avm_DECLARE_VIEWS(79); - auto tmp = (main_sel_op_fdiv * (main_r_in_tag - FF(6))); tmp *= scaling_factor; std::get<79>(evals) += tmp; @@ -958,7 +825,6 @@ template class mainImpl { // Contribution 80 { Avm_DECLARE_VIEWS(80); - auto tmp = (main_sel_op_fdiv * (main_w_in_tag - FF(6))); tmp *= scaling_factor; std::get<80>(evals) += tmp; @@ -966,7 +832,6 @@ template class mainImpl { // Contribution 81 { Avm_DECLARE_VIEWS(81); - auto tmp = (main_op_err * ((main_sel_op_fdiv + main_sel_op_div) - FF(1))); tmp *= scaling_factor; std::get<81>(evals) += tmp; @@ -974,7 +839,6 @@ template class mainImpl { // Contribution 82 { Avm_DECLARE_VIEWS(82); - auto tmp = ((((((((((((main_sel_op_address + main_sel_op_storage_address) + main_sel_op_sender) + main_sel_op_function_selector) + main_sel_op_transaction_fee) + @@ -992,7 +856,6 @@ template class mainImpl { // Contribution 83 { Avm_DECLARE_VIEWS(83); - auto tmp = (((((((main_sel_op_note_hash_exists + main_sel_op_emit_note_hash) + main_sel_op_nullifier_exists) + main_sel_op_emit_nullifier) + @@ -1006,7 +869,6 @@ template class mainImpl { // Contribution 84 { Avm_DECLARE_VIEWS(84); - auto tmp = (main_sel_op_jump * (main_pc_shift - main_ia)); tmp *= scaling_factor; std::get<84>(evals) += tmp; @@ -1014,7 +876,6 @@ template class mainImpl { // Contribution 85 { Avm_DECLARE_VIEWS(85); - auto tmp = (main_sel_op_jumpi * (((-main_id_zero + FF(1)) * (main_pc_shift - main_ia)) + (main_id_zero * ((main_pc_shift - main_pc) - FF(1))))); tmp *= scaling_factor; @@ -1023,7 +884,6 @@ template class mainImpl { // Contribution 86 { Avm_DECLARE_VIEWS(86); - auto tmp = (main_sel_op_internal_call * (main_internal_return_ptr_shift - (main_internal_return_ptr + FF(1)))); tmp *= scaling_factor; @@ -1032,7 +892,6 @@ template class mainImpl { // Contribution 87 { Avm_DECLARE_VIEWS(87); - auto tmp = (main_sel_op_internal_call * (main_internal_return_ptr - main_mem_addr_b)); tmp *= scaling_factor; std::get<87>(evals) += tmp; @@ -1040,7 +899,6 @@ template class mainImpl { // Contribution 88 { Avm_DECLARE_VIEWS(88); - auto tmp = (main_sel_op_internal_call * (main_pc_shift - main_ia)); tmp *= scaling_factor; std::get<88>(evals) += tmp; @@ -1048,7 +906,6 @@ template class mainImpl { // Contribution 89 { Avm_DECLARE_VIEWS(89); - auto tmp = (main_sel_op_internal_call * ((main_pc + FF(1)) - main_ib)); tmp *= scaling_factor; std::get<89>(evals) += tmp; @@ -1056,7 +913,6 @@ template class mainImpl { // Contribution 90 { Avm_DECLARE_VIEWS(90); - auto tmp = (main_sel_op_internal_call * (main_rwb - FF(1))); tmp *= scaling_factor; std::get<90>(evals) += tmp; @@ -1064,7 +920,6 @@ template class mainImpl { // Contribution 91 { Avm_DECLARE_VIEWS(91); - auto tmp = (main_sel_op_internal_call * (main_sel_mem_op_b - FF(1))); tmp *= scaling_factor; std::get<91>(evals) += tmp; @@ -1072,7 +927,6 @@ template class mainImpl { // Contribution 92 { Avm_DECLARE_VIEWS(92); - auto tmp = (main_sel_op_internal_return * (main_internal_return_ptr_shift - (main_internal_return_ptr - FF(1)))); tmp *= scaling_factor; @@ -1081,7 +935,6 @@ template class mainImpl { // Contribution 93 { Avm_DECLARE_VIEWS(93); - auto tmp = (main_sel_op_internal_return * ((main_internal_return_ptr - FF(1)) - main_mem_addr_a)); tmp *= scaling_factor; std::get<93>(evals) += tmp; @@ -1089,7 +942,6 @@ template class mainImpl { // Contribution 94 { Avm_DECLARE_VIEWS(94); - auto tmp = (main_sel_op_internal_return * (main_pc_shift - main_ia)); tmp *= scaling_factor; std::get<94>(evals) += tmp; @@ -1097,7 +949,6 @@ template class mainImpl { // Contribution 95 { Avm_DECLARE_VIEWS(95); - auto tmp = (main_sel_op_internal_return * main_rwa); tmp *= scaling_factor; std::get<95>(evals) += tmp; @@ -1105,7 +956,6 @@ template class mainImpl { // Contribution 96 { Avm_DECLARE_VIEWS(96); - auto tmp = (main_sel_op_internal_return * (main_sel_mem_op_a - FF(1))); tmp *= scaling_factor; std::get<96>(evals) += tmp; @@ -1113,7 +963,6 @@ template class mainImpl { // Contribution 97 { Avm_DECLARE_VIEWS(97); - auto tmp = (((((main_sel_gas_accounting_active - (((((((main_sel_op_fdiv + @@ -1157,7 +1006,6 @@ template class mainImpl { // Contribution 98 { Avm_DECLARE_VIEWS(98); - auto tmp = ((((-main_sel_first + FF(1)) * (-main_sel_op_halt + FF(1))) * (((((((main_sel_op_fdiv + @@ -1196,7 +1044,6 @@ template class mainImpl { // Contribution 99 { Avm_DECLARE_VIEWS(99); - auto tmp = ((-(((main_sel_first + main_sel_op_internal_call) + main_sel_op_internal_return) + main_sel_op_halt) + FF(1)) * @@ -1207,7 +1054,6 @@ template class mainImpl { // Contribution 100 { Avm_DECLARE_VIEWS(100); - auto tmp = ((main_sel_op_internal_call + main_sel_op_internal_return) * (main_space_id - FF(255))); tmp *= scaling_factor; std::get<100>(evals) += tmp; @@ -1215,7 +1061,6 @@ template class mainImpl { // Contribution 101 { Avm_DECLARE_VIEWS(101); - auto tmp = ((((((((main_sel_op_fdiv + ((((((((((main_sel_op_add + main_sel_op_sub) + main_sel_op_mul) + main_sel_op_div) + @@ -1253,7 +1098,6 @@ template class mainImpl { // Contribution 102 { Avm_DECLARE_VIEWS(102); - auto tmp = ((main_sel_op_cmov + main_sel_op_jumpi) * (((main_id * main_inv) - FF(1)) + main_id_zero)); tmp *= scaling_factor; std::get<102>(evals) += tmp; @@ -1261,7 +1105,6 @@ template class mainImpl { // Contribution 103 { Avm_DECLARE_VIEWS(103); - auto tmp = (((main_sel_op_cmov + main_sel_op_jumpi) * main_id_zero) * (-main_inv + FF(1))); tmp *= scaling_factor; std::get<103>(evals) += tmp; @@ -1269,7 +1112,6 @@ template class mainImpl { // Contribution 104 { Avm_DECLARE_VIEWS(104); - auto tmp = (main_sel_mov_ia_to_ic - (main_sel_op_mov + (main_sel_op_cmov * (-main_id_zero + FF(1))))); tmp *= scaling_factor; std::get<104>(evals) += tmp; @@ -1277,7 +1119,6 @@ template class mainImpl { // Contribution 105 { Avm_DECLARE_VIEWS(105); - auto tmp = (main_sel_mov_ib_to_ic - (main_sel_op_cmov * main_id_zero)); tmp *= scaling_factor; std::get<105>(evals) += tmp; @@ -1285,7 +1126,6 @@ template class mainImpl { // Contribution 106 { Avm_DECLARE_VIEWS(106); - auto tmp = (main_sel_mov_ia_to_ic * (main_ia - main_ic)); tmp *= scaling_factor; std::get<106>(evals) += tmp; @@ -1293,7 +1133,6 @@ template class mainImpl { // Contribution 107 { Avm_DECLARE_VIEWS(107); - auto tmp = (main_sel_mov_ib_to_ic * (main_ib - main_ic)); tmp *= scaling_factor; std::get<107>(evals) += tmp; @@ -1301,7 +1140,6 @@ template class mainImpl { // Contribution 108 { Avm_DECLARE_VIEWS(108); - auto tmp = ((main_sel_op_mov + main_sel_op_cmov) * (main_r_in_tag - main_w_in_tag)); tmp *= scaling_factor; std::get<108>(evals) += tmp; @@ -1309,7 +1147,6 @@ template class mainImpl { // Contribution 109 { Avm_DECLARE_VIEWS(109); - auto tmp = (main_sel_alu - ((((((((((((main_sel_op_add + main_sel_op_sub) + main_sel_op_mul) + main_sel_op_div) + main_sel_op_not) + @@ -1327,7 +1164,6 @@ template class mainImpl { // Contribution 110 { Avm_DECLARE_VIEWS(110); - auto tmp = ((((((((((main_sel_op_add + main_sel_op_sub) + main_sel_op_mul) + main_sel_op_div) + main_sel_op_not) + main_sel_op_eq) + @@ -1342,7 +1178,6 @@ template class mainImpl { // Contribution 111 { Avm_DECLARE_VIEWS(111); - auto tmp = (main_sel_op_cast * (main_alu_in_tag - main_w_in_tag)); tmp *= scaling_factor; std::get<111>(evals) += tmp; @@ -1350,7 +1185,6 @@ template class mainImpl { // Contribution 112 { Avm_DECLARE_VIEWS(112); - auto tmp = (main_sel_op_l2gasleft * (main_ia - main_l2_gas_remaining_shift)); tmp *= scaling_factor; std::get<112>(evals) += tmp; @@ -1358,7 +1192,6 @@ template class mainImpl { // Contribution 113 { Avm_DECLARE_VIEWS(113); - auto tmp = (main_sel_op_dagasleft * (main_ia - main_da_gas_remaining_shift)); tmp *= scaling_factor; std::get<113>(evals) += tmp; @@ -1366,7 +1199,6 @@ template class mainImpl { // Contribution 114 { Avm_DECLARE_VIEWS(114); - auto tmp = (main_sel_op_address * (kernel_kernel_in_offset - FF(1))); tmp *= scaling_factor; std::get<114>(evals) += tmp; @@ -1374,7 +1206,6 @@ template class mainImpl { // Contribution 115 { Avm_DECLARE_VIEWS(115); - auto tmp = (main_sel_op_storage_address * (kernel_kernel_in_offset - FF(1))); tmp *= scaling_factor; std::get<115>(evals) += tmp; @@ -1382,7 +1213,6 @@ template class mainImpl { // Contribution 116 { Avm_DECLARE_VIEWS(116); - auto tmp = (main_sel_op_sender * kernel_kernel_in_offset); tmp *= scaling_factor; std::get<116>(evals) += tmp; @@ -1390,7 +1220,6 @@ template class mainImpl { // Contribution 117 { Avm_DECLARE_VIEWS(117); - auto tmp = (main_sel_op_function_selector * (kernel_kernel_in_offset - FF(2))); tmp *= scaling_factor; std::get<117>(evals) += tmp; @@ -1398,7 +1227,6 @@ template class mainImpl { // Contribution 118 { Avm_DECLARE_VIEWS(118); - auto tmp = (main_sel_op_transaction_fee * (kernel_kernel_in_offset - FF(40))); tmp *= scaling_factor; std::get<118>(evals) += tmp; @@ -1406,7 +1234,6 @@ template class mainImpl { // Contribution 119 { Avm_DECLARE_VIEWS(119); - auto tmp = (main_sel_op_chain_id * (kernel_kernel_in_offset - FF(29))); tmp *= scaling_factor; std::get<119>(evals) += tmp; @@ -1414,7 +1241,6 @@ template class mainImpl { // Contribution 120 { Avm_DECLARE_VIEWS(120); - auto tmp = (main_sel_op_version * (kernel_kernel_in_offset - FF(30))); tmp *= scaling_factor; std::get<120>(evals) += tmp; @@ -1422,7 +1248,6 @@ template class mainImpl { // Contribution 121 { Avm_DECLARE_VIEWS(121); - auto tmp = (main_sel_op_block_number * (kernel_kernel_in_offset - FF(31))); tmp *= scaling_factor; std::get<121>(evals) += tmp; @@ -1430,7 +1255,6 @@ template class mainImpl { // Contribution 122 { Avm_DECLARE_VIEWS(122); - auto tmp = (main_sel_op_timestamp * (kernel_kernel_in_offset - FF(32))); tmp *= scaling_factor; std::get<122>(evals) += tmp; @@ -1438,7 +1262,6 @@ template class mainImpl { // Contribution 123 { Avm_DECLARE_VIEWS(123); - auto tmp = (main_sel_op_coinbase * (kernel_kernel_in_offset - FF(33))); tmp *= scaling_factor; std::get<123>(evals) += tmp; @@ -1446,7 +1269,6 @@ template class mainImpl { // Contribution 124 { Avm_DECLARE_VIEWS(124); - auto tmp = (main_sel_op_fee_per_da_gas * (kernel_kernel_in_offset - FF(35))); tmp *= scaling_factor; std::get<124>(evals) += tmp; @@ -1454,7 +1276,6 @@ template class mainImpl { // Contribution 125 { Avm_DECLARE_VIEWS(125); - auto tmp = (main_sel_op_fee_per_l2_gas * (kernel_kernel_in_offset - FF(36))); tmp *= scaling_factor; std::get<125>(evals) += tmp; @@ -1462,7 +1283,6 @@ template class mainImpl { // Contribution 126 { Avm_DECLARE_VIEWS(126); - auto tmp = (main_sel_op_note_hash_exists * (kernel_kernel_out_offset - (kernel_note_hash_exist_write_offset + FF(0)))); tmp *= scaling_factor; @@ -1471,7 +1291,6 @@ template class mainImpl { // Contribution 127 { Avm_DECLARE_VIEWS(127); - auto tmp = (main_sel_first * kernel_note_hash_exist_write_offset); tmp *= scaling_factor; std::get<127>(evals) += tmp; @@ -1479,7 +1298,6 @@ template class mainImpl { // Contribution 128 { Avm_DECLARE_VIEWS(128); - auto tmp = (main_sel_op_emit_note_hash * (kernel_kernel_out_offset - (kernel_emit_note_hash_write_offset + FF(128)))); tmp *= scaling_factor; @@ -1488,7 +1306,6 @@ template class mainImpl { // Contribution 129 { Avm_DECLARE_VIEWS(129); - auto tmp = (main_sel_first * kernel_emit_note_hash_write_offset); tmp *= scaling_factor; std::get<129>(evals) += tmp; @@ -1496,7 +1313,6 @@ template class mainImpl { // Contribution 130 { Avm_DECLARE_VIEWS(130); - auto tmp = (main_sel_op_nullifier_exists * (kernel_kernel_out_offset - ((main_ib * (kernel_nullifier_exists_write_offset + FF(16))) + @@ -1507,7 +1323,6 @@ template class mainImpl { // Contribution 131 { Avm_DECLARE_VIEWS(131); - auto tmp = (main_sel_first * kernel_nullifier_exists_write_offset); tmp *= scaling_factor; std::get<131>(evals) += tmp; @@ -1515,7 +1330,6 @@ template class mainImpl { // Contribution 132 { Avm_DECLARE_VIEWS(132); - auto tmp = (main_sel_first * kernel_nullifier_non_exists_write_offset); tmp *= scaling_factor; std::get<132>(evals) += tmp; @@ -1523,7 +1337,6 @@ template class mainImpl { // Contribution 133 { Avm_DECLARE_VIEWS(133); - auto tmp = (main_sel_op_emit_nullifier * (kernel_kernel_out_offset - (kernel_emit_nullifier_write_offset + FF(144)))); tmp *= scaling_factor; @@ -1532,7 +1345,6 @@ template class mainImpl { // Contribution 134 { Avm_DECLARE_VIEWS(134); - auto tmp = (main_sel_first * kernel_emit_nullifier_write_offset); tmp *= scaling_factor; std::get<134>(evals) += tmp; @@ -1540,7 +1352,6 @@ template class mainImpl { // Contribution 135 { Avm_DECLARE_VIEWS(135); - auto tmp = (main_sel_op_l1_to_l2_msg_exists * (kernel_kernel_out_offset - (kernel_l1_to_l2_msg_exists_write_offset + FF(48)))); tmp *= scaling_factor; @@ -1549,7 +1360,6 @@ template class mainImpl { // Contribution 136 { Avm_DECLARE_VIEWS(136); - auto tmp = (main_sel_first * kernel_l1_to_l2_msg_exists_write_offset); tmp *= scaling_factor; std::get<136>(evals) += tmp; @@ -1557,7 +1367,6 @@ template class mainImpl { // Contribution 137 { Avm_DECLARE_VIEWS(137); - auto tmp = (main_sel_op_emit_unencrypted_log * (kernel_kernel_out_offset - (kernel_emit_unencrypted_log_write_offset + FF(162)))); tmp *= scaling_factor; @@ -1566,7 +1375,6 @@ template class mainImpl { // Contribution 138 { Avm_DECLARE_VIEWS(138); - auto tmp = (main_sel_first * kernel_emit_unencrypted_log_write_offset); tmp *= scaling_factor; std::get<138>(evals) += tmp; @@ -1574,7 +1382,6 @@ template class mainImpl { // Contribution 139 { Avm_DECLARE_VIEWS(139); - auto tmp = (main_sel_op_emit_l2_to_l1_msg * (kernel_kernel_out_offset - (kernel_emit_l2_to_l1_msg_write_offset + FF(160)))); tmp *= scaling_factor; @@ -1583,7 +1390,6 @@ template class mainImpl { // Contribution 140 { Avm_DECLARE_VIEWS(140); - auto tmp = (main_sel_first * kernel_emit_l2_to_l1_msg_write_offset); tmp *= scaling_factor; std::get<140>(evals) += tmp; @@ -1591,7 +1397,6 @@ template class mainImpl { // Contribution 141 { Avm_DECLARE_VIEWS(141); - auto tmp = (main_sel_op_sload * (kernel_kernel_out_offset - (kernel_sload_write_offset + FF(96)))); tmp *= scaling_factor; std::get<141>(evals) += tmp; @@ -1599,7 +1404,6 @@ template class mainImpl { // Contribution 142 { Avm_DECLARE_VIEWS(142); - auto tmp = (main_sel_first * kernel_sload_write_offset); tmp *= scaling_factor; std::get<142>(evals) += tmp; @@ -1607,7 +1411,6 @@ template class mainImpl { // Contribution 143 { Avm_DECLARE_VIEWS(143); - auto tmp = (main_sel_op_sstore * (kernel_kernel_out_offset - (kernel_sstore_write_offset + FF(64)))); tmp *= scaling_factor; std::get<143>(evals) += tmp; @@ -1615,7 +1418,6 @@ template class mainImpl { // Contribution 144 { Avm_DECLARE_VIEWS(144); - auto tmp = (main_sel_first * kernel_sstore_write_offset); tmp *= scaling_factor; std::get<144>(evals) += tmp; @@ -1623,7 +1425,6 @@ template class mainImpl { // Contribution 145 { Avm_DECLARE_VIEWS(145); - auto tmp = (((((((main_sel_op_note_hash_exists + main_sel_op_emit_note_hash) + main_sel_op_nullifier_exists) + main_sel_op_emit_nullifier) + @@ -1637,7 +1438,6 @@ template class mainImpl { // Contribution 146 { Avm_DECLARE_VIEWS(146); - auto tmp = (main_bin_op_id - (main_sel_op_or + (main_sel_op_xor * FF(2)))); tmp *= scaling_factor; std::get<146>(evals) += tmp; @@ -1645,7 +1445,6 @@ template class mainImpl { // Contribution 147 { Avm_DECLARE_VIEWS(147); - auto tmp = (main_sel_bin - ((main_sel_op_and + main_sel_op_or) + main_sel_op_xor)); tmp *= scaling_factor; std::get<147>(evals) += tmp; diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/mem.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/mem.hpp index da94d705197f..232d79fe1906 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/mem.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/mem.hpp @@ -1,8 +1,8 @@ - #pragma once -#include "../../relation_parameters.hpp" -#include "../../relation_types.hpp" -#include "./declare_views.hpp" + +#include "barretenberg/relations/generated/avm/declare_views.hpp" +#include "barretenberg/relations/relation_parameters.hpp" +#include "barretenberg/relations/relation_types.hpp" namespace bb::Avm_vm { @@ -45,8 +45,6 @@ template struct MemRow { FF mem_val{}; FF mem_val_shift{}; FF mem_w_in_tag{}; - - [[maybe_unused]] static std::vector names(); }; inline std::string get_relation_label_mem(int index) @@ -54,52 +52,36 @@ inline std::string get_relation_label_mem(int index) switch (index) { case 14: return "MEM_CONTIGUOUS"; - case 15: return "MEM_FIRST_EMPTY"; - case 16: return "MEM_LAST"; - case 18: return "TIMESTAMP"; - case 19: return "GLOBAL_ADDR"; - case 20: return "LAST_ACCESS_FIRST_ROW"; - case 21: return "MEM_LAST_ACCESS_DELIMITER"; - case 22: return "DIFF_RNG_CHK_DEC"; - case 23: return "MEM_READ_WRITE_VAL_CONSISTENCY"; - case 24: return "MEM_READ_WRITE_TAG_CONSISTENCY"; - case 25: return "MEM_ZERO_INIT"; - case 26: return "SKIP_CHECK_TAG"; - case 27: return "MEM_IN_TAG_CONSISTENCY_1"; - case 28: return "MEM_IN_TAG_CONSISTENCY_2"; - case 29: return "NO_TAG_ERR_WRITE_OR_SKIP"; - case 31: return "NO_TAG_ERR_WRITE"; - case 40: return "MOV_SAME_TAG"; } @@ -110,10 +92,9 @@ template class memImpl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 4, 3, 4, 3, 4, 3, 3, - 3, 4, 4, 4, 4, 4, 6, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - }; + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, + 4, 3, 4, 3, 4, 3, 3, 3, 4, 4, 4, 4, 4, 6, + 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }; template void static accumulate(ContainerOverSubrelations& evals, @@ -121,11 +102,9 @@ template class memImpl { [[maybe_unused]] const RelationParameters&, [[maybe_unused]] const FF& scaling_factor) { - // Contribution 0 { Avm_DECLARE_VIEWS(0); - auto tmp = (mem_lastAccess * (-mem_lastAccess + FF(1))); tmp *= scaling_factor; std::get<0>(evals) += tmp; @@ -133,7 +112,6 @@ template class memImpl { // Contribution 1 { Avm_DECLARE_VIEWS(1); - auto tmp = (mem_last * (-mem_last + FF(1))); tmp *= scaling_factor; std::get<1>(evals) += tmp; @@ -141,7 +119,6 @@ template class memImpl { // Contribution 2 { Avm_DECLARE_VIEWS(2); - auto tmp = (mem_rw * (-mem_rw + FF(1))); tmp *= scaling_factor; std::get<2>(evals) += tmp; @@ -149,7 +126,6 @@ template class memImpl { // Contribution 3 { Avm_DECLARE_VIEWS(3); - auto tmp = (mem_tag_err * (-mem_tag_err + FF(1))); tmp *= scaling_factor; std::get<3>(evals) += tmp; @@ -157,7 +133,6 @@ template class memImpl { // Contribution 4 { Avm_DECLARE_VIEWS(4); - auto tmp = (mem_sel_op_a * (-mem_sel_op_a + FF(1))); tmp *= scaling_factor; std::get<4>(evals) += tmp; @@ -165,7 +140,6 @@ template class memImpl { // Contribution 5 { Avm_DECLARE_VIEWS(5); - auto tmp = (mem_sel_op_b * (-mem_sel_op_b + FF(1))); tmp *= scaling_factor; std::get<5>(evals) += tmp; @@ -173,7 +147,6 @@ template class memImpl { // Contribution 6 { Avm_DECLARE_VIEWS(6); - auto tmp = (mem_sel_op_c * (-mem_sel_op_c + FF(1))); tmp *= scaling_factor; std::get<6>(evals) += tmp; @@ -181,7 +154,6 @@ template class memImpl { // Contribution 7 { Avm_DECLARE_VIEWS(7); - auto tmp = (mem_sel_op_d * (-mem_sel_op_d + FF(1))); tmp *= scaling_factor; std::get<7>(evals) += tmp; @@ -189,7 +161,6 @@ template class memImpl { // Contribution 8 { Avm_DECLARE_VIEWS(8); - auto tmp = (mem_sel_resolve_ind_addr_a * (-mem_sel_resolve_ind_addr_a + FF(1))); tmp *= scaling_factor; std::get<8>(evals) += tmp; @@ -197,7 +168,6 @@ template class memImpl { // Contribution 9 { Avm_DECLARE_VIEWS(9); - auto tmp = (mem_sel_resolve_ind_addr_b * (-mem_sel_resolve_ind_addr_b + FF(1))); tmp *= scaling_factor; std::get<9>(evals) += tmp; @@ -205,7 +175,6 @@ template class memImpl { // Contribution 10 { Avm_DECLARE_VIEWS(10); - auto tmp = (mem_sel_resolve_ind_addr_c * (-mem_sel_resolve_ind_addr_c + FF(1))); tmp *= scaling_factor; std::get<10>(evals) += tmp; @@ -213,7 +182,6 @@ template class memImpl { // Contribution 11 { Avm_DECLARE_VIEWS(11); - auto tmp = (mem_sel_resolve_ind_addr_d * (-mem_sel_resolve_ind_addr_d + FF(1))); tmp *= scaling_factor; std::get<11>(evals) += tmp; @@ -221,7 +189,6 @@ template class memImpl { // Contribution 12 { Avm_DECLARE_VIEWS(12); - auto tmp = (mem_sel_mem - (((((((mem_sel_op_a + mem_sel_op_b) + mem_sel_op_c) + mem_sel_op_d) + mem_sel_resolve_ind_addr_a) + @@ -234,7 +201,6 @@ template class memImpl { // Contribution 13 { Avm_DECLARE_VIEWS(13); - auto tmp = (mem_sel_mem * (mem_sel_mem - FF(1))); tmp *= scaling_factor; std::get<13>(evals) += tmp; @@ -242,7 +208,6 @@ template class memImpl { // Contribution 14 { Avm_DECLARE_VIEWS(14); - auto tmp = (((-main_sel_first + FF(1)) * mem_sel_mem_shift) * (-mem_sel_mem + FF(1))); tmp *= scaling_factor; std::get<14>(evals) += tmp; @@ -250,7 +215,6 @@ template class memImpl { // Contribution 15 { Avm_DECLARE_VIEWS(15); - auto tmp = (main_sel_first * mem_sel_mem); tmp *= scaling_factor; std::get<15>(evals) += tmp; @@ -258,7 +222,6 @@ template class memImpl { // Contribution 16 { Avm_DECLARE_VIEWS(16); - auto tmp = (((-mem_last + FF(1)) * mem_sel_mem) * (-mem_sel_mem_shift + FF(1))); tmp *= scaling_factor; std::get<16>(evals) += tmp; @@ -266,7 +229,6 @@ template class memImpl { // Contribution 17 { Avm_DECLARE_VIEWS(17); - auto tmp = (mem_sel_rng_chk - (mem_sel_mem * (-mem_last + FF(1)))); tmp *= scaling_factor; std::get<17>(evals) += tmp; @@ -274,7 +236,6 @@ template class memImpl { // Contribution 18 { Avm_DECLARE_VIEWS(18); - auto tmp = (mem_tsp - ((mem_clk * FF(12)) + @@ -293,7 +254,6 @@ template class memImpl { // Contribution 19 { Avm_DECLARE_VIEWS(19); - auto tmp = (mem_glob_addr - ((mem_space_id * FF(4294967296UL)) + mem_addr)); tmp *= scaling_factor; std::get<19>(evals) += tmp; @@ -301,7 +261,6 @@ template class memImpl { // Contribution 20 { Avm_DECLARE_VIEWS(20); - auto tmp = (main_sel_first * (-mem_lastAccess + FF(1))); tmp *= scaling_factor; std::get<20>(evals) += tmp; @@ -309,7 +268,6 @@ template class memImpl { // Contribution 21 { Avm_DECLARE_VIEWS(21); - auto tmp = ((-mem_lastAccess + FF(1)) * (mem_glob_addr_shift - mem_glob_addr)); tmp *= scaling_factor; std::get<21>(evals) += tmp; @@ -317,7 +275,6 @@ template class memImpl { // Contribution 22 { Avm_DECLARE_VIEWS(22); - auto tmp = (mem_sel_rng_chk * (((((mem_lastAccess * (mem_glob_addr_shift - mem_glob_addr)) + ((-mem_lastAccess + FF(1)) * (mem_tsp_shift - mem_tsp))) - (mem_diff_hi * FF(4294967296UL))) - @@ -329,7 +286,6 @@ template class memImpl { // Contribution 23 { Avm_DECLARE_VIEWS(23); - auto tmp = (((-mem_lastAccess + FF(1)) * (-mem_rw_shift + FF(1))) * (mem_val_shift - mem_val)); tmp *= scaling_factor; std::get<23>(evals) += tmp; @@ -337,7 +293,6 @@ template class memImpl { // Contribution 24 { Avm_DECLARE_VIEWS(24); - auto tmp = (((-mem_lastAccess + FF(1)) * (-mem_rw_shift + FF(1))) * (mem_tag_shift - mem_tag)); tmp *= scaling_factor; std::get<24>(evals) += tmp; @@ -345,7 +300,6 @@ template class memImpl { // Contribution 25 { Avm_DECLARE_VIEWS(25); - auto tmp = ((mem_lastAccess * (-mem_rw_shift + FF(1))) * mem_val_shift); tmp *= scaling_factor; std::get<25>(evals) += tmp; @@ -353,7 +307,6 @@ template class memImpl { // Contribution 26 { Avm_DECLARE_VIEWS(26); - auto tmp = (mem_skip_check_tag - (mem_sel_op_cmov * ((mem_sel_op_d + (mem_sel_op_a * (-mem_sel_mov_ia_to_ic + FF(1)))) + (mem_sel_op_b * (-mem_sel_mov_ib_to_ic + FF(1)))))); @@ -363,7 +316,6 @@ template class memImpl { // Contribution 27 { Avm_DECLARE_VIEWS(27); - auto tmp = (((mem_tag * (-mem_skip_check_tag + FF(1))) * (-mem_rw + FF(1))) * (((mem_r_in_tag - mem_tag) * (-mem_one_min_inv + FF(1))) - mem_tag_err)); tmp *= scaling_factor; @@ -372,7 +324,6 @@ template class memImpl { // Contribution 28 { Avm_DECLARE_VIEWS(28); - auto tmp = ((mem_tag * (-mem_tag_err + FF(1))) * mem_one_min_inv); tmp *= scaling_factor; std::get<28>(evals) += tmp; @@ -380,7 +331,6 @@ template class memImpl { // Contribution 29 { Avm_DECLARE_VIEWS(29); - auto tmp = ((mem_skip_check_tag + mem_rw) * mem_tag_err); tmp *= scaling_factor; std::get<29>(evals) += tmp; @@ -388,7 +338,6 @@ template class memImpl { // Contribution 30 { Avm_DECLARE_VIEWS(30); - auto tmp = (mem_rw * (mem_w_in_tag - mem_tag)); tmp *= scaling_factor; std::get<30>(evals) += tmp; @@ -396,7 +345,6 @@ template class memImpl { // Contribution 31 { Avm_DECLARE_VIEWS(31); - auto tmp = (mem_rw * mem_tag_err); tmp *= scaling_factor; std::get<31>(evals) += tmp; @@ -404,7 +352,6 @@ template class memImpl { // Contribution 32 { Avm_DECLARE_VIEWS(32); - auto tmp = (mem_sel_resolve_ind_addr_a * (mem_r_in_tag - FF(3))); tmp *= scaling_factor; std::get<32>(evals) += tmp; @@ -412,7 +359,6 @@ template class memImpl { // Contribution 33 { Avm_DECLARE_VIEWS(33); - auto tmp = (mem_sel_resolve_ind_addr_b * (mem_r_in_tag - FF(3))); tmp *= scaling_factor; std::get<33>(evals) += tmp; @@ -420,7 +366,6 @@ template class memImpl { // Contribution 34 { Avm_DECLARE_VIEWS(34); - auto tmp = (mem_sel_resolve_ind_addr_c * (mem_r_in_tag - FF(3))); tmp *= scaling_factor; std::get<34>(evals) += tmp; @@ -428,7 +373,6 @@ template class memImpl { // Contribution 35 { Avm_DECLARE_VIEWS(35); - auto tmp = (mem_sel_resolve_ind_addr_d * (mem_r_in_tag - FF(3))); tmp *= scaling_factor; std::get<35>(evals) += tmp; @@ -436,7 +380,6 @@ template class memImpl { // Contribution 36 { Avm_DECLARE_VIEWS(36); - auto tmp = (mem_sel_resolve_ind_addr_a * mem_rw); tmp *= scaling_factor; std::get<36>(evals) += tmp; @@ -444,7 +387,6 @@ template class memImpl { // Contribution 37 { Avm_DECLARE_VIEWS(37); - auto tmp = (mem_sel_resolve_ind_addr_b * mem_rw); tmp *= scaling_factor; std::get<37>(evals) += tmp; @@ -452,7 +394,6 @@ template class memImpl { // Contribution 38 { Avm_DECLARE_VIEWS(38); - auto tmp = (mem_sel_resolve_ind_addr_c * mem_rw); tmp *= scaling_factor; std::get<38>(evals) += tmp; @@ -460,7 +401,6 @@ template class memImpl { // Contribution 39 { Avm_DECLARE_VIEWS(39); - auto tmp = (mem_sel_resolve_ind_addr_d * mem_rw); tmp *= scaling_factor; std::get<39>(evals) += tmp; @@ -468,7 +408,6 @@ template class memImpl { // Contribution 40 { Avm_DECLARE_VIEWS(40); - auto tmp = ((mem_sel_mov_ia_to_ic + mem_sel_mov_ib_to_ic) * mem_tag_err); tmp *= scaling_factor; std::get<40>(evals) += tmp; diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/pedersen.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/pedersen.hpp index d09722720e9e..0e0669c87174 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/pedersen.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/pedersen.hpp @@ -1,15 +1,13 @@ - #pragma once -#include "../../relation_parameters.hpp" -#include "../../relation_types.hpp" -#include "./declare_views.hpp" + +#include "barretenberg/relations/generated/avm/declare_views.hpp" +#include "barretenberg/relations/relation_parameters.hpp" +#include "barretenberg/relations/relation_types.hpp" namespace bb::Avm_vm { template struct PedersenRow { FF pedersen_sel_pedersen{}; - - [[maybe_unused]] static std::vector names(); }; inline std::string get_relation_label_pedersen(int index) @@ -22,9 +20,7 @@ template class pedersenImpl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, - }; + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3 }; template void static accumulate(ContainerOverSubrelations& evals, @@ -32,11 +28,9 @@ template class pedersenImpl { [[maybe_unused]] const RelationParameters&, [[maybe_unused]] const FF& scaling_factor) { - // Contribution 0 { Avm_DECLARE_VIEWS(0); - auto tmp = (pedersen_sel_pedersen * (-pedersen_sel_pedersen + FF(1))); tmp *= scaling_factor; std::get<0>(evals) += tmp; diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/poseidon2.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/poseidon2.hpp index a758f8333b2b..a153b4f64a9f 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/poseidon2.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/poseidon2.hpp @@ -1,15 +1,13 @@ - #pragma once -#include "../../relation_parameters.hpp" -#include "../../relation_types.hpp" -#include "./declare_views.hpp" + +#include "barretenberg/relations/generated/avm/declare_views.hpp" +#include "barretenberg/relations/relation_parameters.hpp" +#include "barretenberg/relations/relation_types.hpp" namespace bb::Avm_vm { template struct Poseidon2Row { FF poseidon2_sel_poseidon_perm{}; - - [[maybe_unused]] static std::vector names(); }; inline std::string get_relation_label_poseidon2(int index) @@ -22,9 +20,7 @@ template class poseidon2Impl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, - }; + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3 }; template void static accumulate(ContainerOverSubrelations& evals, @@ -32,11 +28,9 @@ template class poseidon2Impl { [[maybe_unused]] const RelationParameters&, [[maybe_unused]] const FF& scaling_factor) { - // Contribution 0 { Avm_DECLARE_VIEWS(0); - auto tmp = (poseidon2_sel_poseidon_perm * (-poseidon2_sel_poseidon_perm + FF(1))); tmp *= scaling_factor; std::get<0>(evals) += tmp; diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/powers.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/powers.hpp index dab82e6757ee..6a5cf38d4102 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/powers.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/powers.hpp @@ -1,15 +1,13 @@ - #pragma once -#include "../../relation_parameters.hpp" -#include "../../relation_types.hpp" -#include "./declare_views.hpp" + +#include "barretenberg/relations/generated/avm/declare_views.hpp" +#include "barretenberg/relations/relation_parameters.hpp" +#include "barretenberg/relations/relation_types.hpp" namespace bb::Avm_vm { template struct PowersRow { FF powers_power_of_2{}; - - [[maybe_unused]] static std::vector names(); }; inline std::string get_relation_label_powers(int index) @@ -22,9 +20,7 @@ template class powersImpl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 2, - }; + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 2 }; template void static accumulate(ContainerOverSubrelations& evals, @@ -32,11 +28,9 @@ template class powersImpl { [[maybe_unused]] const RelationParameters&, [[maybe_unused]] const FF& scaling_factor) { - // Contribution 0 { Avm_DECLARE_VIEWS(0); - auto tmp = (powers_power_of_2 - powers_power_of_2); tmp *= scaling_factor; std::get<0>(evals) += tmp; diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/sha256.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/sha256.hpp index 189cbb7c699c..7db78bc343fa 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/sha256.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/sha256.hpp @@ -1,15 +1,13 @@ - #pragma once -#include "../../relation_parameters.hpp" -#include "../../relation_types.hpp" -#include "./declare_views.hpp" + +#include "barretenberg/relations/generated/avm/declare_views.hpp" +#include "barretenberg/relations/relation_parameters.hpp" +#include "barretenberg/relations/relation_types.hpp" namespace bb::Avm_vm { template struct Sha256Row { FF sha256_sel_sha256_compression{}; - - [[maybe_unused]] static std::vector names(); }; inline std::string get_relation_label_sha256(int index) @@ -22,9 +20,7 @@ template class sha256Impl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, - }; + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3 }; template void static accumulate(ContainerOverSubrelations& evals, @@ -32,11 +28,9 @@ template class sha256Impl { [[maybe_unused]] const RelationParameters&, [[maybe_unused]] const FF& scaling_factor) { - // Contribution 0 { Avm_DECLARE_VIEWS(0); - auto tmp = (sha256_sel_sha256_compression * (-sha256_sel_sha256_compression + FF(1))); tmp *= scaling_factor; std::get<0>(evals) += tmp; diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.cpp index a1194d51e98f..a3edcb9c1a04 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.cpp @@ -1,4 +1,3 @@ - #include "barretenberg/vm/generated/avm_circuit_builder.hpp" namespace bb { @@ -404,228 +403,403 @@ template std::vector AvmFullRow::names() "lookup_div_u16_4_counts", "lookup_div_u16_5_counts", "lookup_div_u16_6_counts", - "lookup_div_u16_7_counts", - "" }; + "lookup_div_u16_7_counts" }; } template std::ostream& operator<<(std::ostream& os, AvmFullRow const& row) { - return os - << field_to_string(row.main_clk) << "," << field_to_string(row.main_sel_first) << "," - << field_to_string(row.kernel_kernel_inputs) << "," << field_to_string(row.kernel_kernel_value_out) << "," - << field_to_string(row.kernel_kernel_side_effect_out) << "," - << field_to_string(row.kernel_kernel_metadata_out) << "," << field_to_string(row.main_calldata) << "," - << field_to_string(row.alu_a_hi) << "," << field_to_string(row.alu_a_lo) << "," - << field_to_string(row.alu_b_hi) << "," << field_to_string(row.alu_b_lo) << "," - << field_to_string(row.alu_borrow) << "," << field_to_string(row.alu_cf) << "," - << field_to_string(row.alu_clk) << "," << field_to_string(row.alu_cmp_rng_ctr) << "," - << field_to_string(row.alu_div_u16_r0) << "," << field_to_string(row.alu_div_u16_r1) << "," - << field_to_string(row.alu_div_u16_r2) << "," << field_to_string(row.alu_div_u16_r3) << "," - << field_to_string(row.alu_div_u16_r4) << "," << field_to_string(row.alu_div_u16_r5) << "," - << field_to_string(row.alu_div_u16_r6) << "," << field_to_string(row.alu_div_u16_r7) << "," - << field_to_string(row.alu_divisor_hi) << "," << field_to_string(row.alu_divisor_lo) << "," - << field_to_string(row.alu_ff_tag) << "," << field_to_string(row.alu_ia) << "," - << field_to_string(row.alu_ib) << "," << field_to_string(row.alu_ic) << "," - << field_to_string(row.alu_in_tag) << "," << field_to_string(row.alu_op_add) << "," - << field_to_string(row.alu_op_cast) << "," << field_to_string(row.alu_op_cast_prev) << "," - << field_to_string(row.alu_op_div) << "," << field_to_string(row.alu_op_div_a_lt_b) << "," - << field_to_string(row.alu_op_div_std) << "," << field_to_string(row.alu_op_eq) << "," - << field_to_string(row.alu_op_eq_diff_inv) << "," << field_to_string(row.alu_op_lt) << "," - << field_to_string(row.alu_op_lte) << "," << field_to_string(row.alu_op_mul) << "," - << field_to_string(row.alu_op_not) << "," << field_to_string(row.alu_op_shl) << "," - << field_to_string(row.alu_op_shr) << "," << field_to_string(row.alu_op_sub) << "," - << field_to_string(row.alu_p_a_borrow) << "," << field_to_string(row.alu_p_b_borrow) << "," - << field_to_string(row.alu_p_sub_a_hi) << "," << field_to_string(row.alu_p_sub_a_lo) << "," - << field_to_string(row.alu_p_sub_b_hi) << "," << field_to_string(row.alu_p_sub_b_lo) << "," - << field_to_string(row.alu_partial_prod_hi) << "," << field_to_string(row.alu_partial_prod_lo) << "," - << field_to_string(row.alu_quotient_hi) << "," << field_to_string(row.alu_quotient_lo) << "," - << field_to_string(row.alu_remainder) << "," << field_to_string(row.alu_res_hi) << "," - << field_to_string(row.alu_res_lo) << "," << field_to_string(row.alu_sel_alu) << "," - << field_to_string(row.alu_sel_cmp) << "," << field_to_string(row.alu_sel_div_rng_chk) << "," - << field_to_string(row.alu_sel_rng_chk) << "," << field_to_string(row.alu_sel_rng_chk_lookup) << "," - << field_to_string(row.alu_sel_shift_which) << "," << field_to_string(row.alu_shift_lt_bit_len) << "," - << field_to_string(row.alu_t_sub_s_bits) << "," << field_to_string(row.alu_two_pow_s) << "," - << field_to_string(row.alu_two_pow_t_sub_s) << "," << field_to_string(row.alu_u128_tag) << "," - << field_to_string(row.alu_u16_r0) << "," << field_to_string(row.alu_u16_r1) << "," - << field_to_string(row.alu_u16_r10) << "," << field_to_string(row.alu_u16_r11) << "," - << field_to_string(row.alu_u16_r12) << "," << field_to_string(row.alu_u16_r13) << "," - << field_to_string(row.alu_u16_r14) << "," << field_to_string(row.alu_u16_r2) << "," - << field_to_string(row.alu_u16_r3) << "," << field_to_string(row.alu_u16_r4) << "," - << field_to_string(row.alu_u16_r5) << "," << field_to_string(row.alu_u16_r6) << "," - << field_to_string(row.alu_u16_r7) << "," << field_to_string(row.alu_u16_r8) << "," - << field_to_string(row.alu_u16_r9) << "," << field_to_string(row.alu_u16_tag) << "," - << field_to_string(row.alu_u32_tag) << "," << field_to_string(row.alu_u64_tag) << "," - << field_to_string(row.alu_u8_r0) << "," << field_to_string(row.alu_u8_r1) << "," - << field_to_string(row.alu_u8_tag) << "," << field_to_string(row.binary_acc_ia) << "," - << field_to_string(row.binary_acc_ib) << "," << field_to_string(row.binary_acc_ic) << "," - << field_to_string(row.binary_clk) << "," << field_to_string(row.binary_ia_bytes) << "," - << field_to_string(row.binary_ib_bytes) << "," << field_to_string(row.binary_ic_bytes) << "," - << field_to_string(row.binary_in_tag) << "," << field_to_string(row.binary_mem_tag_ctr) << "," - << field_to_string(row.binary_mem_tag_ctr_inv) << "," << field_to_string(row.binary_op_id) << "," - << field_to_string(row.binary_sel_bin) << "," << field_to_string(row.binary_start) << "," - << field_to_string(row.byte_lookup_sel_bin) << "," << field_to_string(row.byte_lookup_table_byte_lengths) - << "," << field_to_string(row.byte_lookup_table_in_tags) << "," - << field_to_string(row.byte_lookup_table_input_a) << "," << field_to_string(row.byte_lookup_table_input_b) - << "," << field_to_string(row.byte_lookup_table_op_id) << "," - << field_to_string(row.byte_lookup_table_output) << "," << field_to_string(row.conversion_clk) << "," - << field_to_string(row.conversion_input) << "," << field_to_string(row.conversion_num_limbs) << "," - << field_to_string(row.conversion_radix) << "," << field_to_string(row.conversion_sel_to_radix_le) << "," - << field_to_string(row.gas_da_gas_fixed_table) << "," << field_to_string(row.gas_l2_gas_fixed_table) << "," - << field_to_string(row.gas_sel_gas_cost) << "," << field_to_string(row.keccakf1600_clk) << "," - << field_to_string(row.keccakf1600_input) << "," << field_to_string(row.keccakf1600_output) << "," - << field_to_string(row.keccakf1600_sel_keccakf1600) << "," - << field_to_string(row.kernel_emit_l2_to_l1_msg_write_offset) << "," - << field_to_string(row.kernel_emit_note_hash_write_offset) << "," - << field_to_string(row.kernel_emit_nullifier_write_offset) << "," - << field_to_string(row.kernel_emit_unencrypted_log_write_offset) << "," - << field_to_string(row.kernel_kernel_in_offset) << "," << field_to_string(row.kernel_kernel_out_offset) - << "," << field_to_string(row.kernel_l1_to_l2_msg_exists_write_offset) << "," - << field_to_string(row.kernel_note_hash_exist_write_offset) << "," - << field_to_string(row.kernel_nullifier_exists_write_offset) << "," - << field_to_string(row.kernel_nullifier_non_exists_write_offset) << "," - << field_to_string(row.kernel_q_public_input_kernel_add_to_table) << "," - << field_to_string(row.kernel_q_public_input_kernel_out_add_to_table) << "," - << field_to_string(row.kernel_side_effect_counter) << "," << field_to_string(row.kernel_sload_write_offset) - << "," << field_to_string(row.kernel_sstore_write_offset) << "," - << field_to_string(row.main_abs_da_rem_gas_hi) << "," << field_to_string(row.main_abs_da_rem_gas_lo) << "," - << field_to_string(row.main_abs_l2_rem_gas_hi) << "," << field_to_string(row.main_abs_l2_rem_gas_lo) << "," - << field_to_string(row.main_alu_in_tag) << "," << field_to_string(row.main_bin_op_id) << "," - << field_to_string(row.main_call_ptr) << "," << field_to_string(row.main_da_gas_op_cost) << "," - << field_to_string(row.main_da_gas_remaining) << "," << field_to_string(row.main_da_out_of_gas) << "," - << field_to_string(row.main_ia) << "," << field_to_string(row.main_ib) << "," << field_to_string(row.main_ic) - << "," << field_to_string(row.main_id) << "," << field_to_string(row.main_id_zero) << "," - << field_to_string(row.main_ind_addr_a) << "," << field_to_string(row.main_ind_addr_b) << "," - << field_to_string(row.main_ind_addr_c) << "," << field_to_string(row.main_ind_addr_d) << "," - << field_to_string(row.main_internal_return_ptr) << "," << field_to_string(row.main_inv) << "," - << field_to_string(row.main_l2_gas_op_cost) << "," << field_to_string(row.main_l2_gas_remaining) << "," - << field_to_string(row.main_l2_out_of_gas) << "," << field_to_string(row.main_mem_addr_a) << "," - << field_to_string(row.main_mem_addr_b) << "," << field_to_string(row.main_mem_addr_c) << "," - << field_to_string(row.main_mem_addr_d) << "," << field_to_string(row.main_op_err) << "," - << field_to_string(row.main_opcode_val) << "," << field_to_string(row.main_pc) << "," - << field_to_string(row.main_r_in_tag) << "," << field_to_string(row.main_rwa) << "," - << field_to_string(row.main_rwb) << "," << field_to_string(row.main_rwc) << "," - << field_to_string(row.main_rwd) << "," << field_to_string(row.main_sel_alu) << "," - << field_to_string(row.main_sel_bin) << "," << field_to_string(row.main_sel_gas_accounting_active) << "," - << field_to_string(row.main_sel_last) << "," << field_to_string(row.main_sel_mem_op_a) << "," - << field_to_string(row.main_sel_mem_op_activate_gas) << "," << field_to_string(row.main_sel_mem_op_b) << "," - << field_to_string(row.main_sel_mem_op_c) << "," << field_to_string(row.main_sel_mem_op_d) << "," - << field_to_string(row.main_sel_mov_ia_to_ic) << "," << field_to_string(row.main_sel_mov_ib_to_ic) << "," - << field_to_string(row.main_sel_op_add) << "," << field_to_string(row.main_sel_op_address) << "," - << field_to_string(row.main_sel_op_and) << "," << field_to_string(row.main_sel_op_block_number) << "," - << field_to_string(row.main_sel_op_cast) << "," << field_to_string(row.main_sel_op_chain_id) << "," - << field_to_string(row.main_sel_op_cmov) << "," << field_to_string(row.main_sel_op_coinbase) << "," - << field_to_string(row.main_sel_op_dagasleft) << "," << field_to_string(row.main_sel_op_div) << "," - << field_to_string(row.main_sel_op_emit_l2_to_l1_msg) << "," - << field_to_string(row.main_sel_op_emit_note_hash) << "," << field_to_string(row.main_sel_op_emit_nullifier) - << "," << field_to_string(row.main_sel_op_emit_unencrypted_log) << "," << field_to_string(row.main_sel_op_eq) - << "," << field_to_string(row.main_sel_op_external_call) << "," << field_to_string(row.main_sel_op_fdiv) - << "," << field_to_string(row.main_sel_op_fee_per_da_gas) << "," - << field_to_string(row.main_sel_op_fee_per_l2_gas) << "," - << field_to_string(row.main_sel_op_function_selector) << "," - << field_to_string(row.main_sel_op_get_contract_instance) << "," << field_to_string(row.main_sel_op_halt) - << "," << field_to_string(row.main_sel_op_internal_call) << "," - << field_to_string(row.main_sel_op_internal_return) << "," << field_to_string(row.main_sel_op_jump) << "," - << field_to_string(row.main_sel_op_jumpi) << "," << field_to_string(row.main_sel_op_keccak) << "," - << field_to_string(row.main_sel_op_l1_to_l2_msg_exists) << "," << field_to_string(row.main_sel_op_l2gasleft) - << "," << field_to_string(row.main_sel_op_lt) << "," << field_to_string(row.main_sel_op_lte) << "," - << field_to_string(row.main_sel_op_mov) << "," << field_to_string(row.main_sel_op_mul) << "," - << field_to_string(row.main_sel_op_not) << "," << field_to_string(row.main_sel_op_note_hash_exists) << "," - << field_to_string(row.main_sel_op_nullifier_exists) << "," << field_to_string(row.main_sel_op_or) << "," - << field_to_string(row.main_sel_op_pedersen) << "," << field_to_string(row.main_sel_op_poseidon2) << "," - << field_to_string(row.main_sel_op_radix_le) << "," << field_to_string(row.main_sel_op_sender) << "," - << field_to_string(row.main_sel_op_sha256) << "," << field_to_string(row.main_sel_op_shl) << "," - << field_to_string(row.main_sel_op_shr) << "," << field_to_string(row.main_sel_op_sload) << "," - << field_to_string(row.main_sel_op_sstore) << "," << field_to_string(row.main_sel_op_storage_address) << "," - << field_to_string(row.main_sel_op_sub) << "," << field_to_string(row.main_sel_op_timestamp) << "," - << field_to_string(row.main_sel_op_transaction_fee) << "," << field_to_string(row.main_sel_op_version) << "," - << field_to_string(row.main_sel_op_xor) << "," << field_to_string(row.main_sel_q_kernel_lookup) << "," - << field_to_string(row.main_sel_q_kernel_output_lookup) << "," - << field_to_string(row.main_sel_resolve_ind_addr_a) << "," - << field_to_string(row.main_sel_resolve_ind_addr_b) << "," - << field_to_string(row.main_sel_resolve_ind_addr_c) << "," - << field_to_string(row.main_sel_resolve_ind_addr_d) << "," << field_to_string(row.main_sel_rng_16) << "," - << field_to_string(row.main_sel_rng_8) << "," << field_to_string(row.main_space_id) << "," - << field_to_string(row.main_tag_err) << "," << field_to_string(row.main_w_in_tag) << "," - << field_to_string(row.mem_addr) << "," << field_to_string(row.mem_clk) << "," - << field_to_string(row.mem_diff_hi) << "," << field_to_string(row.mem_diff_lo) << "," - << field_to_string(row.mem_diff_mid) << "," << field_to_string(row.mem_glob_addr) << "," - << field_to_string(row.mem_last) << "," << field_to_string(row.mem_lastAccess) << "," - << field_to_string(row.mem_one_min_inv) << "," << field_to_string(row.mem_r_in_tag) << "," - << field_to_string(row.mem_rw) << "," << field_to_string(row.mem_sel_mem) << "," - << field_to_string(row.mem_sel_mov_ia_to_ic) << "," << field_to_string(row.mem_sel_mov_ib_to_ic) << "," - << field_to_string(row.mem_sel_op_a) << "," << field_to_string(row.mem_sel_op_b) << "," - << field_to_string(row.mem_sel_op_c) << "," << field_to_string(row.mem_sel_op_cmov) << "," - << field_to_string(row.mem_sel_op_d) << "," << field_to_string(row.mem_sel_resolve_ind_addr_a) << "," - << field_to_string(row.mem_sel_resolve_ind_addr_b) << "," << field_to_string(row.mem_sel_resolve_ind_addr_c) - << "," << field_to_string(row.mem_sel_resolve_ind_addr_d) << "," << field_to_string(row.mem_sel_rng_chk) - << "," << field_to_string(row.mem_skip_check_tag) << "," << field_to_string(row.mem_space_id) << "," - << field_to_string(row.mem_tag) << "," << field_to_string(row.mem_tag_err) << "," - << field_to_string(row.mem_tsp) << "," << field_to_string(row.mem_val) << "," - << field_to_string(row.mem_w_in_tag) << "," << field_to_string(row.pedersen_clk) << "," - << field_to_string(row.pedersen_input) << "," << field_to_string(row.pedersen_output) << "," - << field_to_string(row.pedersen_sel_pedersen) << "," << field_to_string(row.poseidon2_clk) << "," - << field_to_string(row.poseidon2_input) << "," << field_to_string(row.poseidon2_output) << "," - << field_to_string(row.poseidon2_sel_poseidon_perm) << "," << field_to_string(row.powers_power_of_2) << "," - << field_to_string(row.sha256_clk) << "," << field_to_string(row.sha256_input) << "," - << field_to_string(row.sha256_output) << "," << field_to_string(row.sha256_sel_sha256_compression) << "," - << field_to_string(row.sha256_state) << "," << field_to_string(row.perm_main_alu) << "," - << field_to_string(row.perm_main_bin) << "," << field_to_string(row.perm_main_conv) << "," - << field_to_string(row.perm_main_pos2_perm) << "," << field_to_string(row.perm_main_pedersen) << "," - << field_to_string(row.perm_main_mem_a) << "," << field_to_string(row.perm_main_mem_b) << "," - << field_to_string(row.perm_main_mem_c) << "," << field_to_string(row.perm_main_mem_d) << "," - << field_to_string(row.perm_main_mem_ind_addr_a) << "," << field_to_string(row.perm_main_mem_ind_addr_b) - << "," << field_to_string(row.perm_main_mem_ind_addr_c) << "," - << field_to_string(row.perm_main_mem_ind_addr_d) << "," << field_to_string(row.lookup_byte_lengths) << "," - << field_to_string(row.lookup_byte_operations) << "," << field_to_string(row.lookup_opcode_gas) << "," - << field_to_string(row.range_check_l2_gas_hi) << "," << field_to_string(row.range_check_l2_gas_lo) << "," - << field_to_string(row.range_check_da_gas_hi) << "," << field_to_string(row.range_check_da_gas_lo) << "," - << field_to_string(row.kernel_output_lookup) << "," << field_to_string(row.lookup_into_kernel) << "," - << field_to_string(row.incl_main_tag_err) << "," << field_to_string(row.incl_mem_tag_err) << "," - << field_to_string(row.lookup_mem_rng_chk_lo) << "," << field_to_string(row.lookup_mem_rng_chk_mid) << "," - << field_to_string(row.lookup_mem_rng_chk_hi) << "," << field_to_string(row.lookup_pow_2_0) << "," - << field_to_string(row.lookup_pow_2_1) << "," << field_to_string(row.lookup_u8_0) << "," - << field_to_string(row.lookup_u8_1) << "," << field_to_string(row.lookup_u16_0) << "," - << field_to_string(row.lookup_u16_1) << "," << field_to_string(row.lookup_u16_2) << "," - << field_to_string(row.lookup_u16_3) << "," << field_to_string(row.lookup_u16_4) << "," - << field_to_string(row.lookup_u16_5) << "," << field_to_string(row.lookup_u16_6) << "," - << field_to_string(row.lookup_u16_7) << "," << field_to_string(row.lookup_u16_8) << "," - << field_to_string(row.lookup_u16_9) << "," << field_to_string(row.lookup_u16_10) << "," - << field_to_string(row.lookup_u16_11) << "," << field_to_string(row.lookup_u16_12) << "," - << field_to_string(row.lookup_u16_13) << "," << field_to_string(row.lookup_u16_14) << "," - << field_to_string(row.lookup_div_u16_0) << "," << field_to_string(row.lookup_div_u16_1) << "," - << field_to_string(row.lookup_div_u16_2) << "," << field_to_string(row.lookup_div_u16_3) << "," - << field_to_string(row.lookup_div_u16_4) << "," << field_to_string(row.lookup_div_u16_5) << "," - << field_to_string(row.lookup_div_u16_6) << "," << field_to_string(row.lookup_div_u16_7) << "," - << field_to_string(row.lookup_byte_lengths_counts) << "," - << field_to_string(row.lookup_byte_operations_counts) << "," << field_to_string(row.lookup_opcode_gas_counts) - << "," << field_to_string(row.range_check_l2_gas_hi_counts) << "," - << field_to_string(row.range_check_l2_gas_lo_counts) << "," - << field_to_string(row.range_check_da_gas_hi_counts) << "," - << field_to_string(row.range_check_da_gas_lo_counts) << "," - << field_to_string(row.kernel_output_lookup_counts) << "," << field_to_string(row.lookup_into_kernel_counts) - << "," << field_to_string(row.incl_main_tag_err_counts) << "," - << field_to_string(row.incl_mem_tag_err_counts) << "," << field_to_string(row.lookup_mem_rng_chk_lo_counts) - << "," << field_to_string(row.lookup_mem_rng_chk_mid_counts) << "," - << field_to_string(row.lookup_mem_rng_chk_hi_counts) << "," << field_to_string(row.lookup_pow_2_0_counts) - << "," << field_to_string(row.lookup_pow_2_1_counts) << "," << field_to_string(row.lookup_u8_0_counts) << "," - << field_to_string(row.lookup_u8_1_counts) << "," << field_to_string(row.lookup_u16_0_counts) << "," - << field_to_string(row.lookup_u16_1_counts) << "," << field_to_string(row.lookup_u16_2_counts) << "," - << field_to_string(row.lookup_u16_3_counts) << "," << field_to_string(row.lookup_u16_4_counts) << "," - << field_to_string(row.lookup_u16_5_counts) << "," << field_to_string(row.lookup_u16_6_counts) << "," - << field_to_string(row.lookup_u16_7_counts) << "," << field_to_string(row.lookup_u16_8_counts) << "," - << field_to_string(row.lookup_u16_9_counts) << "," << field_to_string(row.lookup_u16_10_counts) << "," - << field_to_string(row.lookup_u16_11_counts) << "," << field_to_string(row.lookup_u16_12_counts) << "," - << field_to_string(row.lookup_u16_13_counts) << "," << field_to_string(row.lookup_u16_14_counts) << "," - << field_to_string(row.lookup_div_u16_0_counts) << "," << field_to_string(row.lookup_div_u16_1_counts) << "," - << field_to_string(row.lookup_div_u16_2_counts) << "," << field_to_string(row.lookup_div_u16_3_counts) << "," - << field_to_string(row.lookup_div_u16_4_counts) << "," << field_to_string(row.lookup_div_u16_5_counts) << "," - << field_to_string(row.lookup_div_u16_6_counts) << "," << field_to_string(row.lookup_div_u16_7_counts) - << "," - ""; + return os << field_to_string(row.main_clk) // + << "," << field_to_string(row.main_sel_first) // + << "," << field_to_string(row.kernel_kernel_inputs) // + << "," << field_to_string(row.kernel_kernel_value_out) // + << "," << field_to_string(row.kernel_kernel_side_effect_out) // + << "," << field_to_string(row.kernel_kernel_metadata_out) // + << "," << field_to_string(row.main_calldata) // + << "," << field_to_string(row.alu_a_hi) // + << "," << field_to_string(row.alu_a_lo) // + << "," << field_to_string(row.alu_b_hi) // + << "," << field_to_string(row.alu_b_lo) // + << "," << field_to_string(row.alu_borrow) // + << "," << field_to_string(row.alu_cf) // + << "," << field_to_string(row.alu_clk) // + << "," << field_to_string(row.alu_cmp_rng_ctr) // + << "," << field_to_string(row.alu_div_u16_r0) // + << "," << field_to_string(row.alu_div_u16_r1) // + << "," << field_to_string(row.alu_div_u16_r2) // + << "," << field_to_string(row.alu_div_u16_r3) // + << "," << field_to_string(row.alu_div_u16_r4) // + << "," << field_to_string(row.alu_div_u16_r5) // + << "," << field_to_string(row.alu_div_u16_r6) // + << "," << field_to_string(row.alu_div_u16_r7) // + << "," << field_to_string(row.alu_divisor_hi) // + << "," << field_to_string(row.alu_divisor_lo) // + << "," << field_to_string(row.alu_ff_tag) // + << "," << field_to_string(row.alu_ia) // + << "," << field_to_string(row.alu_ib) // + << "," << field_to_string(row.alu_ic) // + << "," << field_to_string(row.alu_in_tag) // + << "," << field_to_string(row.alu_op_add) // + << "," << field_to_string(row.alu_op_cast) // + << "," << field_to_string(row.alu_op_cast_prev) // + << "," << field_to_string(row.alu_op_div) // + << "," << field_to_string(row.alu_op_div_a_lt_b) // + << "," << field_to_string(row.alu_op_div_std) // + << "," << field_to_string(row.alu_op_eq) // + << "," << field_to_string(row.alu_op_eq_diff_inv) // + << "," << field_to_string(row.alu_op_lt) // + << "," << field_to_string(row.alu_op_lte) // + << "," << field_to_string(row.alu_op_mul) // + << "," << field_to_string(row.alu_op_not) // + << "," << field_to_string(row.alu_op_shl) // + << "," << field_to_string(row.alu_op_shr) // + << "," << field_to_string(row.alu_op_sub) // + << "," << field_to_string(row.alu_p_a_borrow) // + << "," << field_to_string(row.alu_p_b_borrow) // + << "," << field_to_string(row.alu_p_sub_a_hi) // + << "," << field_to_string(row.alu_p_sub_a_lo) // + << "," << field_to_string(row.alu_p_sub_b_hi) // + << "," << field_to_string(row.alu_p_sub_b_lo) // + << "," << field_to_string(row.alu_partial_prod_hi) // + << "," << field_to_string(row.alu_partial_prod_lo) // + << "," << field_to_string(row.alu_quotient_hi) // + << "," << field_to_string(row.alu_quotient_lo) // + << "," << field_to_string(row.alu_remainder) // + << "," << field_to_string(row.alu_res_hi) // + << "," << field_to_string(row.alu_res_lo) // + << "," << field_to_string(row.alu_sel_alu) // + << "," << field_to_string(row.alu_sel_cmp) // + << "," << field_to_string(row.alu_sel_div_rng_chk) // + << "," << field_to_string(row.alu_sel_rng_chk) // + << "," << field_to_string(row.alu_sel_rng_chk_lookup) // + << "," << field_to_string(row.alu_sel_shift_which) // + << "," << field_to_string(row.alu_shift_lt_bit_len) // + << "," << field_to_string(row.alu_t_sub_s_bits) // + << "," << field_to_string(row.alu_two_pow_s) // + << "," << field_to_string(row.alu_two_pow_t_sub_s) // + << "," << field_to_string(row.alu_u128_tag) // + << "," << field_to_string(row.alu_u16_r0) // + << "," << field_to_string(row.alu_u16_r1) // + << "," << field_to_string(row.alu_u16_r10) // + << "," << field_to_string(row.alu_u16_r11) // + << "," << field_to_string(row.alu_u16_r12) // + << "," << field_to_string(row.alu_u16_r13) // + << "," << field_to_string(row.alu_u16_r14) // + << "," << field_to_string(row.alu_u16_r2) // + << "," << field_to_string(row.alu_u16_r3) // + << "," << field_to_string(row.alu_u16_r4) // + << "," << field_to_string(row.alu_u16_r5) // + << "," << field_to_string(row.alu_u16_r6) // + << "," << field_to_string(row.alu_u16_r7) // + << "," << field_to_string(row.alu_u16_r8) // + << "," << field_to_string(row.alu_u16_r9) // + << "," << field_to_string(row.alu_u16_tag) // + << "," << field_to_string(row.alu_u32_tag) // + << "," << field_to_string(row.alu_u64_tag) // + << "," << field_to_string(row.alu_u8_r0) // + << "," << field_to_string(row.alu_u8_r1) // + << "," << field_to_string(row.alu_u8_tag) // + << "," << field_to_string(row.binary_acc_ia) // + << "," << field_to_string(row.binary_acc_ib) // + << "," << field_to_string(row.binary_acc_ic) // + << "," << field_to_string(row.binary_clk) // + << "," << field_to_string(row.binary_ia_bytes) // + << "," << field_to_string(row.binary_ib_bytes) // + << "," << field_to_string(row.binary_ic_bytes) // + << "," << field_to_string(row.binary_in_tag) // + << "," << field_to_string(row.binary_mem_tag_ctr) // + << "," << field_to_string(row.binary_mem_tag_ctr_inv) // + << "," << field_to_string(row.binary_op_id) // + << "," << field_to_string(row.binary_sel_bin) // + << "," << field_to_string(row.binary_start) // + << "," << field_to_string(row.byte_lookup_sel_bin) // + << "," << field_to_string(row.byte_lookup_table_byte_lengths) // + << "," << field_to_string(row.byte_lookup_table_in_tags) // + << "," << field_to_string(row.byte_lookup_table_input_a) // + << "," << field_to_string(row.byte_lookup_table_input_b) // + << "," << field_to_string(row.byte_lookup_table_op_id) // + << "," << field_to_string(row.byte_lookup_table_output) // + << "," << field_to_string(row.conversion_clk) // + << "," << field_to_string(row.conversion_input) // + << "," << field_to_string(row.conversion_num_limbs) // + << "," << field_to_string(row.conversion_radix) // + << "," << field_to_string(row.conversion_sel_to_radix_le) // + << "," << field_to_string(row.gas_da_gas_fixed_table) // + << "," << field_to_string(row.gas_l2_gas_fixed_table) // + << "," << field_to_string(row.gas_sel_gas_cost) // + << "," << field_to_string(row.keccakf1600_clk) // + << "," << field_to_string(row.keccakf1600_input) // + << "," << field_to_string(row.keccakf1600_output) // + << "," << field_to_string(row.keccakf1600_sel_keccakf1600) // + << "," << field_to_string(row.kernel_emit_l2_to_l1_msg_write_offset) // + << "," << field_to_string(row.kernel_emit_note_hash_write_offset) // + << "," << field_to_string(row.kernel_emit_nullifier_write_offset) // + << "," << field_to_string(row.kernel_emit_unencrypted_log_write_offset) // + << "," << field_to_string(row.kernel_kernel_in_offset) // + << "," << field_to_string(row.kernel_kernel_out_offset) // + << "," << field_to_string(row.kernel_l1_to_l2_msg_exists_write_offset) // + << "," << field_to_string(row.kernel_note_hash_exist_write_offset) // + << "," << field_to_string(row.kernel_nullifier_exists_write_offset) // + << "," << field_to_string(row.kernel_nullifier_non_exists_write_offset) // + << "," << field_to_string(row.kernel_q_public_input_kernel_add_to_table) // + << "," << field_to_string(row.kernel_q_public_input_kernel_out_add_to_table) // + << "," << field_to_string(row.kernel_side_effect_counter) // + << "," << field_to_string(row.kernel_sload_write_offset) // + << "," << field_to_string(row.kernel_sstore_write_offset) // + << "," << field_to_string(row.main_abs_da_rem_gas_hi) // + << "," << field_to_string(row.main_abs_da_rem_gas_lo) // + << "," << field_to_string(row.main_abs_l2_rem_gas_hi) // + << "," << field_to_string(row.main_abs_l2_rem_gas_lo) // + << "," << field_to_string(row.main_alu_in_tag) // + << "," << field_to_string(row.main_bin_op_id) // + << "," << field_to_string(row.main_call_ptr) // + << "," << field_to_string(row.main_da_gas_op_cost) // + << "," << field_to_string(row.main_da_gas_remaining) // + << "," << field_to_string(row.main_da_out_of_gas) // + << "," << field_to_string(row.main_ia) // + << "," << field_to_string(row.main_ib) // + << "," << field_to_string(row.main_ic) // + << "," << field_to_string(row.main_id) // + << "," << field_to_string(row.main_id_zero) // + << "," << field_to_string(row.main_ind_addr_a) // + << "," << field_to_string(row.main_ind_addr_b) // + << "," << field_to_string(row.main_ind_addr_c) // + << "," << field_to_string(row.main_ind_addr_d) // + << "," << field_to_string(row.main_internal_return_ptr) // + << "," << field_to_string(row.main_inv) // + << "," << field_to_string(row.main_l2_gas_op_cost) // + << "," << field_to_string(row.main_l2_gas_remaining) // + << "," << field_to_string(row.main_l2_out_of_gas) // + << "," << field_to_string(row.main_mem_addr_a) // + << "," << field_to_string(row.main_mem_addr_b) // + << "," << field_to_string(row.main_mem_addr_c) // + << "," << field_to_string(row.main_mem_addr_d) // + << "," << field_to_string(row.main_op_err) // + << "," << field_to_string(row.main_opcode_val) // + << "," << field_to_string(row.main_pc) // + << "," << field_to_string(row.main_r_in_tag) // + << "," << field_to_string(row.main_rwa) // + << "," << field_to_string(row.main_rwb) // + << "," << field_to_string(row.main_rwc) // + << "," << field_to_string(row.main_rwd) // + << "," << field_to_string(row.main_sel_alu) // + << "," << field_to_string(row.main_sel_bin) // + << "," << field_to_string(row.main_sel_gas_accounting_active) // + << "," << field_to_string(row.main_sel_last) // + << "," << field_to_string(row.main_sel_mem_op_a) // + << "," << field_to_string(row.main_sel_mem_op_activate_gas) // + << "," << field_to_string(row.main_sel_mem_op_b) // + << "," << field_to_string(row.main_sel_mem_op_c) // + << "," << field_to_string(row.main_sel_mem_op_d) // + << "," << field_to_string(row.main_sel_mov_ia_to_ic) // + << "," << field_to_string(row.main_sel_mov_ib_to_ic) // + << "," << field_to_string(row.main_sel_op_add) // + << "," << field_to_string(row.main_sel_op_address) // + << "," << field_to_string(row.main_sel_op_and) // + << "," << field_to_string(row.main_sel_op_block_number) // + << "," << field_to_string(row.main_sel_op_cast) // + << "," << field_to_string(row.main_sel_op_chain_id) // + << "," << field_to_string(row.main_sel_op_cmov) // + << "," << field_to_string(row.main_sel_op_coinbase) // + << "," << field_to_string(row.main_sel_op_dagasleft) // + << "," << field_to_string(row.main_sel_op_div) // + << "," << field_to_string(row.main_sel_op_emit_l2_to_l1_msg) // + << "," << field_to_string(row.main_sel_op_emit_note_hash) // + << "," << field_to_string(row.main_sel_op_emit_nullifier) // + << "," << field_to_string(row.main_sel_op_emit_unencrypted_log) // + << "," << field_to_string(row.main_sel_op_eq) // + << "," << field_to_string(row.main_sel_op_external_call) // + << "," << field_to_string(row.main_sel_op_fdiv) // + << "," << field_to_string(row.main_sel_op_fee_per_da_gas) // + << "," << field_to_string(row.main_sel_op_fee_per_l2_gas) // + << "," << field_to_string(row.main_sel_op_function_selector) // + << "," << field_to_string(row.main_sel_op_get_contract_instance) // + << "," << field_to_string(row.main_sel_op_halt) // + << "," << field_to_string(row.main_sel_op_internal_call) // + << "," << field_to_string(row.main_sel_op_internal_return) // + << "," << field_to_string(row.main_sel_op_jump) // + << "," << field_to_string(row.main_sel_op_jumpi) // + << "," << field_to_string(row.main_sel_op_keccak) // + << "," << field_to_string(row.main_sel_op_l1_to_l2_msg_exists) // + << "," << field_to_string(row.main_sel_op_l2gasleft) // + << "," << field_to_string(row.main_sel_op_lt) // + << "," << field_to_string(row.main_sel_op_lte) // + << "," << field_to_string(row.main_sel_op_mov) // + << "," << field_to_string(row.main_sel_op_mul) // + << "," << field_to_string(row.main_sel_op_not) // + << "," << field_to_string(row.main_sel_op_note_hash_exists) // + << "," << field_to_string(row.main_sel_op_nullifier_exists) // + << "," << field_to_string(row.main_sel_op_or) // + << "," << field_to_string(row.main_sel_op_pedersen) // + << "," << field_to_string(row.main_sel_op_poseidon2) // + << "," << field_to_string(row.main_sel_op_radix_le) // + << "," << field_to_string(row.main_sel_op_sender) // + << "," << field_to_string(row.main_sel_op_sha256) // + << "," << field_to_string(row.main_sel_op_shl) // + << "," << field_to_string(row.main_sel_op_shr) // + << "," << field_to_string(row.main_sel_op_sload) // + << "," << field_to_string(row.main_sel_op_sstore) // + << "," << field_to_string(row.main_sel_op_storage_address) // + << "," << field_to_string(row.main_sel_op_sub) // + << "," << field_to_string(row.main_sel_op_timestamp) // + << "," << field_to_string(row.main_sel_op_transaction_fee) // + << "," << field_to_string(row.main_sel_op_version) // + << "," << field_to_string(row.main_sel_op_xor) // + << "," << field_to_string(row.main_sel_q_kernel_lookup) // + << "," << field_to_string(row.main_sel_q_kernel_output_lookup) // + << "," << field_to_string(row.main_sel_resolve_ind_addr_a) // + << "," << field_to_string(row.main_sel_resolve_ind_addr_b) // + << "," << field_to_string(row.main_sel_resolve_ind_addr_c) // + << "," << field_to_string(row.main_sel_resolve_ind_addr_d) // + << "," << field_to_string(row.main_sel_rng_16) // + << "," << field_to_string(row.main_sel_rng_8) // + << "," << field_to_string(row.main_space_id) // + << "," << field_to_string(row.main_tag_err) // + << "," << field_to_string(row.main_w_in_tag) // + << "," << field_to_string(row.mem_addr) // + << "," << field_to_string(row.mem_clk) // + << "," << field_to_string(row.mem_diff_hi) // + << "," << field_to_string(row.mem_diff_lo) // + << "," << field_to_string(row.mem_diff_mid) // + << "," << field_to_string(row.mem_glob_addr) // + << "," << field_to_string(row.mem_last) // + << "," << field_to_string(row.mem_lastAccess) // + << "," << field_to_string(row.mem_one_min_inv) // + << "," << field_to_string(row.mem_r_in_tag) // + << "," << field_to_string(row.mem_rw) // + << "," << field_to_string(row.mem_sel_mem) // + << "," << field_to_string(row.mem_sel_mov_ia_to_ic) // + << "," << field_to_string(row.mem_sel_mov_ib_to_ic) // + << "," << field_to_string(row.mem_sel_op_a) // + << "," << field_to_string(row.mem_sel_op_b) // + << "," << field_to_string(row.mem_sel_op_c) // + << "," << field_to_string(row.mem_sel_op_cmov) // + << "," << field_to_string(row.mem_sel_op_d) // + << "," << field_to_string(row.mem_sel_resolve_ind_addr_a) // + << "," << field_to_string(row.mem_sel_resolve_ind_addr_b) // + << "," << field_to_string(row.mem_sel_resolve_ind_addr_c) // + << "," << field_to_string(row.mem_sel_resolve_ind_addr_d) // + << "," << field_to_string(row.mem_sel_rng_chk) // + << "," << field_to_string(row.mem_skip_check_tag) // + << "," << field_to_string(row.mem_space_id) // + << "," << field_to_string(row.mem_tag) // + << "," << field_to_string(row.mem_tag_err) // + << "," << field_to_string(row.mem_tsp) // + << "," << field_to_string(row.mem_val) // + << "," << field_to_string(row.mem_w_in_tag) // + << "," << field_to_string(row.pedersen_clk) // + << "," << field_to_string(row.pedersen_input) // + << "," << field_to_string(row.pedersen_output) // + << "," << field_to_string(row.pedersen_sel_pedersen) // + << "," << field_to_string(row.poseidon2_clk) // + << "," << field_to_string(row.poseidon2_input) // + << "," << field_to_string(row.poseidon2_output) // + << "," << field_to_string(row.poseidon2_sel_poseidon_perm) // + << "," << field_to_string(row.powers_power_of_2) // + << "," << field_to_string(row.sha256_clk) // + << "," << field_to_string(row.sha256_input) // + << "," << field_to_string(row.sha256_output) // + << "," << field_to_string(row.sha256_sel_sha256_compression) // + << "," << field_to_string(row.sha256_state) // + << "," << field_to_string(row.perm_main_alu) // + << "," << field_to_string(row.perm_main_bin) // + << "," << field_to_string(row.perm_main_conv) // + << "," << field_to_string(row.perm_main_pos2_perm) // + << "," << field_to_string(row.perm_main_pedersen) // + << "," << field_to_string(row.perm_main_mem_a) // + << "," << field_to_string(row.perm_main_mem_b) // + << "," << field_to_string(row.perm_main_mem_c) // + << "," << field_to_string(row.perm_main_mem_d) // + << "," << field_to_string(row.perm_main_mem_ind_addr_a) // + << "," << field_to_string(row.perm_main_mem_ind_addr_b) // + << "," << field_to_string(row.perm_main_mem_ind_addr_c) // + << "," << field_to_string(row.perm_main_mem_ind_addr_d) // + << "," << field_to_string(row.lookup_byte_lengths) // + << "," << field_to_string(row.lookup_byte_operations) // + << "," << field_to_string(row.lookup_opcode_gas) // + << "," << field_to_string(row.range_check_l2_gas_hi) // + << "," << field_to_string(row.range_check_l2_gas_lo) // + << "," << field_to_string(row.range_check_da_gas_hi) // + << "," << field_to_string(row.range_check_da_gas_lo) // + << "," << field_to_string(row.kernel_output_lookup) // + << "," << field_to_string(row.lookup_into_kernel) // + << "," << field_to_string(row.incl_main_tag_err) // + << "," << field_to_string(row.incl_mem_tag_err) // + << "," << field_to_string(row.lookup_mem_rng_chk_lo) // + << "," << field_to_string(row.lookup_mem_rng_chk_mid) // + << "," << field_to_string(row.lookup_mem_rng_chk_hi) // + << "," << field_to_string(row.lookup_pow_2_0) // + << "," << field_to_string(row.lookup_pow_2_1) // + << "," << field_to_string(row.lookup_u8_0) // + << "," << field_to_string(row.lookup_u8_1) // + << "," << field_to_string(row.lookup_u16_0) // + << "," << field_to_string(row.lookup_u16_1) // + << "," << field_to_string(row.lookup_u16_2) // + << "," << field_to_string(row.lookup_u16_3) // + << "," << field_to_string(row.lookup_u16_4) // + << "," << field_to_string(row.lookup_u16_5) // + << "," << field_to_string(row.lookup_u16_6) // + << "," << field_to_string(row.lookup_u16_7) // + << "," << field_to_string(row.lookup_u16_8) // + << "," << field_to_string(row.lookup_u16_9) // + << "," << field_to_string(row.lookup_u16_10) // + << "," << field_to_string(row.lookup_u16_11) // + << "," << field_to_string(row.lookup_u16_12) // + << "," << field_to_string(row.lookup_u16_13) // + << "," << field_to_string(row.lookup_u16_14) // + << "," << field_to_string(row.lookup_div_u16_0) // + << "," << field_to_string(row.lookup_div_u16_1) // + << "," << field_to_string(row.lookup_div_u16_2) // + << "," << field_to_string(row.lookup_div_u16_3) // + << "," << field_to_string(row.lookup_div_u16_4) // + << "," << field_to_string(row.lookup_div_u16_5) // + << "," << field_to_string(row.lookup_div_u16_6) // + << "," << field_to_string(row.lookup_div_u16_7) // + << "," << field_to_string(row.lookup_byte_lengths_counts) // + << "," << field_to_string(row.lookup_byte_operations_counts) // + << "," << field_to_string(row.lookup_opcode_gas_counts) // + << "," << field_to_string(row.range_check_l2_gas_hi_counts) // + << "," << field_to_string(row.range_check_l2_gas_lo_counts) // + << "," << field_to_string(row.range_check_da_gas_hi_counts) // + << "," << field_to_string(row.range_check_da_gas_lo_counts) // + << "," << field_to_string(row.kernel_output_lookup_counts) // + << "," << field_to_string(row.lookup_into_kernel_counts) // + << "," << field_to_string(row.incl_main_tag_err_counts) // + << "," << field_to_string(row.incl_mem_tag_err_counts) // + << "," << field_to_string(row.lookup_mem_rng_chk_lo_counts) // + << "," << field_to_string(row.lookup_mem_rng_chk_mid_counts) // + << "," << field_to_string(row.lookup_mem_rng_chk_hi_counts) // + << "," << field_to_string(row.lookup_pow_2_0_counts) // + << "," << field_to_string(row.lookup_pow_2_1_counts) // + << "," << field_to_string(row.lookup_u8_0_counts) // + << "," << field_to_string(row.lookup_u8_1_counts) // + << "," << field_to_string(row.lookup_u16_0_counts) // + << "," << field_to_string(row.lookup_u16_1_counts) // + << "," << field_to_string(row.lookup_u16_2_counts) // + << "," << field_to_string(row.lookup_u16_3_counts) // + << "," << field_to_string(row.lookup_u16_4_counts) // + << "," << field_to_string(row.lookup_u16_5_counts) // + << "," << field_to_string(row.lookup_u16_6_counts) // + << "," << field_to_string(row.lookup_u16_7_counts) // + << "," << field_to_string(row.lookup_u16_8_counts) // + << "," << field_to_string(row.lookup_u16_9_counts) // + << "," << field_to_string(row.lookup_u16_10_counts) // + << "," << field_to_string(row.lookup_u16_11_counts) // + << "," << field_to_string(row.lookup_u16_12_counts) // + << "," << field_to_string(row.lookup_u16_13_counts) // + << "," << field_to_string(row.lookup_u16_14_counts) // + << "," << field_to_string(row.lookup_div_u16_0_counts) // + << "," << field_to_string(row.lookup_div_u16_1_counts) // + << "," << field_to_string(row.lookup_div_u16_2_counts) // + << "," << field_to_string(row.lookup_div_u16_3_counts) // + << "," << field_to_string(row.lookup_div_u16_4_counts) // + << "," << field_to_string(row.lookup_div_u16_5_counts) // + << "," << field_to_string(row.lookup_div_u16_6_counts) // + << "," << field_to_string(row.lookup_div_u16_7_counts) // + ; } // Explicit template instantiation. template std::ostream& operator<<(std::ostream& os, AvmFullRow const& row); template std::vector AvmFullRow::names(); -} // namespace bb \ No newline at end of file +} // 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 6508ba7d465b..55b9243fa934 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp @@ -1,5 +1,3 @@ - - // AUTOGENERATED FILE #pragma once @@ -16,72 +14,7 @@ #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" #include "barretenberg/stdlib_circuit_builders/circuit_builder_base.hpp" -#include "barretenberg/relations/generated/avm/alu.hpp" -#include "barretenberg/relations/generated/avm/binary.hpp" -#include "barretenberg/relations/generated/avm/conversion.hpp" -#include "barretenberg/relations/generated/avm/gas.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/keccakf1600.hpp" -#include "barretenberg/relations/generated/avm/kernel.hpp" -#include "barretenberg/relations/generated/avm/kernel_output_lookup.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_div_u16_0.hpp" -#include "barretenberg/relations/generated/avm/lookup_div_u16_1.hpp" -#include "barretenberg/relations/generated/avm/lookup_div_u16_2.hpp" -#include "barretenberg/relations/generated/avm/lookup_div_u16_3.hpp" -#include "barretenberg/relations/generated/avm/lookup_div_u16_4.hpp" -#include "barretenberg/relations/generated/avm/lookup_div_u16_5.hpp" -#include "barretenberg/relations/generated/avm/lookup_div_u16_6.hpp" -#include "barretenberg/relations/generated/avm/lookup_div_u16_7.hpp" -#include "barretenberg/relations/generated/avm/lookup_into_kernel.hpp" -#include "barretenberg/relations/generated/avm/lookup_mem_rng_chk_hi.hpp" -#include "barretenberg/relations/generated/avm/lookup_mem_rng_chk_lo.hpp" -#include "barretenberg/relations/generated/avm/lookup_mem_rng_chk_mid.hpp" -#include "barretenberg/relations/generated/avm/lookup_opcode_gas.hpp" -#include "barretenberg/relations/generated/avm/lookup_pow_2_0.hpp" -#include "barretenberg/relations/generated/avm/lookup_pow_2_1.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/main.hpp" -#include "barretenberg/relations/generated/avm/mem.hpp" -#include "barretenberg/relations/generated/avm/pedersen.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_conv.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" -#include "barretenberg/relations/generated/avm/perm_main_mem_d.hpp" -#include "barretenberg/relations/generated/avm/perm_main_mem_ind_addr_a.hpp" -#include "barretenberg/relations/generated/avm/perm_main_mem_ind_addr_b.hpp" -#include "barretenberg/relations/generated/avm/perm_main_mem_ind_addr_c.hpp" -#include "barretenberg/relations/generated/avm/perm_main_mem_ind_addr_d.hpp" -#include "barretenberg/relations/generated/avm/perm_main_pedersen.hpp" -#include "barretenberg/relations/generated/avm/perm_main_pos2_perm.hpp" -#include "barretenberg/relations/generated/avm/poseidon2.hpp" -#include "barretenberg/relations/generated/avm/powers.hpp" -#include "barretenberg/relations/generated/avm/range_check_da_gas_hi.hpp" -#include "barretenberg/relations/generated/avm/range_check_da_gas_lo.hpp" -#include "barretenberg/relations/generated/avm/range_check_l2_gas_hi.hpp" -#include "barretenberg/relations/generated/avm/range_check_l2_gas_lo.hpp" -#include "barretenberg/relations/generated/avm/sha256.hpp" +// This already imports the relations and permutations. For now we rely on the transitive includes. #include "barretenberg/vm/generated/avm_flavor.hpp" namespace bb { @@ -555,8 +488,8 @@ class AvmCircuitBuilder { using Polynomial = Flavor::Polynomial; using ProverPolynomials = Flavor::ProverPolynomials; - static constexpr size_t num_fixed_columns = 452; - static constexpr size_t num_polys = 387; + static constexpr size_t num_fixed_columns = 387; + static constexpr size_t num_polys = 387 + 65; std::vector rows; void set_trace(std::vector&& trace) { rows = std::move(trace); } @@ -985,7 +918,6 @@ class AvmCircuitBuilder { [[maybe_unused]] bool check_circuit() { - const FF gamma = FF::random_element(); const FF beta = FF::random_element(); bb::RelationParameters params{ @@ -1050,426 +982,297 @@ class AvmCircuitBuilder { return true; }; + // Check relations auto alu = [=]() { return evaluate_relation.template operator()>("alu", Avm_vm::get_relation_label_alu); }; - auto binary = [=]() { return evaluate_relation.template operator()>("binary", Avm_vm::get_relation_label_binary); }; - auto conversion = [=]() { return evaluate_relation.template operator()>("conversion", Avm_vm::get_relation_label_conversion); }; - auto gas = [=]() { return evaluate_relation.template operator()>("gas", Avm_vm::get_relation_label_gas); }; - auto keccakf1600 = [=]() { return evaluate_relation.template operator()>( "keccakf1600", Avm_vm::get_relation_label_keccakf1600); }; - auto kernel = [=]() { return evaluate_relation.template operator()>("kernel", Avm_vm::get_relation_label_kernel); }; - auto main = [=]() { return evaluate_relation.template operator()>("main", Avm_vm::get_relation_label_main); }; - auto mem = [=]() { return evaluate_relation.template operator()>("mem", Avm_vm::get_relation_label_mem); }; - auto pedersen = [=]() { return evaluate_relation.template operator()>("pedersen", Avm_vm::get_relation_label_pedersen); }; - auto poseidon2 = [=]() { return evaluate_relation.template operator()>("poseidon2", Avm_vm::get_relation_label_poseidon2); }; - auto powers = [=]() { return evaluate_relation.template operator()>("powers", Avm_vm::get_relation_label_powers); }; - auto sha256 = [=]() { return evaluate_relation.template operator()>("sha256", Avm_vm::get_relation_label_sha256); }; + // Check lookups auto perm_main_alu = [=]() { return evaluate_logderivative.template operator()>("PERM_MAIN_ALU"); }; - auto perm_main_bin = [=]() { return evaluate_logderivative.template operator()>("PERM_MAIN_BIN"); }; - auto perm_main_conv = [=]() { return evaluate_logderivative.template operator()>("PERM_MAIN_CONV"); }; - auto perm_main_pos2_perm = [=]() { return evaluate_logderivative.template operator()>("PERM_MAIN_POS2_PERM"); }; - auto perm_main_pedersen = [=]() { return evaluate_logderivative.template operator()>("PERM_MAIN_PEDERSEN"); }; - auto perm_main_mem_a = [=]() { return evaluate_logderivative.template operator()>("PERM_MAIN_MEM_A"); }; - auto perm_main_mem_b = [=]() { return evaluate_logderivative.template operator()>("PERM_MAIN_MEM_B"); }; - auto perm_main_mem_c = [=]() { return evaluate_logderivative.template operator()>("PERM_MAIN_MEM_C"); }; - auto perm_main_mem_d = [=]() { return evaluate_logderivative.template operator()>("PERM_MAIN_MEM_D"); }; - auto perm_main_mem_ind_addr_a = [=]() { return evaluate_logderivative.template operator()>( "PERM_MAIN_MEM_IND_ADDR_A"); }; - auto perm_main_mem_ind_addr_b = [=]() { return evaluate_logderivative.template operator()>( "PERM_MAIN_MEM_IND_ADDR_B"); }; - auto perm_main_mem_ind_addr_c = [=]() { return evaluate_logderivative.template operator()>( "PERM_MAIN_MEM_IND_ADDR_C"); }; - auto perm_main_mem_ind_addr_d = [=]() { return evaluate_logderivative.template operator()>( "PERM_MAIN_MEM_IND_ADDR_D"); }; - auto lookup_byte_lengths = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_BYTE_LENGTHS"); }; - auto lookup_byte_operations = [=]() { return evaluate_logderivative.template operator()>( "LOOKUP_BYTE_OPERATIONS"); }; - auto lookup_opcode_gas = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_OPCODE_GAS"); }; - auto range_check_l2_gas_hi = [=]() { return evaluate_logderivative.template operator()>( "RANGE_CHECK_L2_GAS_HI"); }; - auto range_check_l2_gas_lo = [=]() { return evaluate_logderivative.template operator()>( "RANGE_CHECK_L2_GAS_LO"); }; - auto range_check_da_gas_hi = [=]() { return evaluate_logderivative.template operator()>( "RANGE_CHECK_DA_GAS_HI"); }; - auto range_check_da_gas_lo = [=]() { return evaluate_logderivative.template operator()>( "RANGE_CHECK_DA_GAS_LO"); }; - auto kernel_output_lookup = [=]() { return evaluate_logderivative.template operator()>( "KERNEL_OUTPUT_LOOKUP"); }; - auto lookup_into_kernel = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_INTO_KERNEL"); }; - auto incl_main_tag_err = [=]() { return evaluate_logderivative.template operator()>("INCL_MAIN_TAG_ERR"); }; - auto incl_mem_tag_err = [=]() { return evaluate_logderivative.template operator()>("INCL_MEM_TAG_ERR"); }; - auto lookup_mem_rng_chk_lo = [=]() { return evaluate_logderivative.template operator()>( "LOOKUP_MEM_RNG_CHK_LO"); }; - auto lookup_mem_rng_chk_mid = [=]() { return evaluate_logderivative.template operator()>( "LOOKUP_MEM_RNG_CHK_MID"); }; - auto lookup_mem_rng_chk_hi = [=]() { return evaluate_logderivative.template operator()>( "LOOKUP_MEM_RNG_CHK_HI"); }; - auto lookup_pow_2_0 = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_POW_2_0"); }; - auto lookup_pow_2_1 = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_POW_2_1"); }; - auto lookup_u8_0 = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_U8_0"); }; - auto lookup_u8_1 = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_U8_1"); }; - auto lookup_u16_0 = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_U16_0"); }; - auto lookup_u16_1 = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_U16_1"); }; - auto lookup_u16_2 = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_U16_2"); }; - auto lookup_u16_3 = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_U16_3"); }; - auto lookup_u16_4 = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_U16_4"); }; - auto lookup_u16_5 = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_U16_5"); }; - auto lookup_u16_6 = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_U16_6"); }; - auto lookup_u16_7 = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_U16_7"); }; - auto lookup_u16_8 = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_U16_8"); }; - auto lookup_u16_9 = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_U16_9"); }; - auto lookup_u16_10 = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_U16_10"); }; - auto lookup_u16_11 = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_U16_11"); }; - auto lookup_u16_12 = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_U16_12"); }; - auto lookup_u16_13 = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_U16_13"); }; - auto lookup_u16_14 = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_U16_14"); }; - auto lookup_div_u16_0 = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_DIV_U16_0"); }; - auto lookup_div_u16_1 = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_DIV_U16_1"); }; - auto lookup_div_u16_2 = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_DIV_U16_2"); }; - auto lookup_div_u16_3 = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_DIV_U16_3"); }; - auto lookup_div_u16_4 = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_DIV_U16_4"); }; - auto lookup_div_u16_5 = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_DIV_U16_5"); }; - auto lookup_div_u16_6 = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_DIV_U16_6"); }; - auto lookup_div_u16_7 = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_DIV_U16_7"); }; -#ifndef __wasm__ - // Evaluate check circuit closures as futures std::vector> relation_futures; relation_futures.emplace_back(std::async(std::launch::async, alu)); - relation_futures.emplace_back(std::async(std::launch::async, binary)); - relation_futures.emplace_back(std::async(std::launch::async, conversion)); - relation_futures.emplace_back(std::async(std::launch::async, gas)); - relation_futures.emplace_back(std::async(std::launch::async, keccakf1600)); - relation_futures.emplace_back(std::async(std::launch::async, kernel)); - relation_futures.emplace_back(std::async(std::launch::async, main)); - relation_futures.emplace_back(std::async(std::launch::async, mem)); - relation_futures.emplace_back(std::async(std::launch::async, pedersen)); - relation_futures.emplace_back(std::async(std::launch::async, poseidon2)); - relation_futures.emplace_back(std::async(std::launch::async, powers)); - relation_futures.emplace_back(std::async(std::launch::async, sha256)); - relation_futures.emplace_back(std::async(std::launch::async, perm_main_alu)); - relation_futures.emplace_back(std::async(std::launch::async, perm_main_bin)); - relation_futures.emplace_back(std::async(std::launch::async, perm_main_conv)); - relation_futures.emplace_back(std::async(std::launch::async, perm_main_pos2_perm)); - relation_futures.emplace_back(std::async(std::launch::async, perm_main_pedersen)); - relation_futures.emplace_back(std::async(std::launch::async, perm_main_mem_a)); - relation_futures.emplace_back(std::async(std::launch::async, perm_main_mem_b)); - relation_futures.emplace_back(std::async(std::launch::async, perm_main_mem_c)); - relation_futures.emplace_back(std::async(std::launch::async, perm_main_mem_d)); - relation_futures.emplace_back(std::async(std::launch::async, perm_main_mem_ind_addr_a)); - relation_futures.emplace_back(std::async(std::launch::async, perm_main_mem_ind_addr_b)); - relation_futures.emplace_back(std::async(std::launch::async, perm_main_mem_ind_addr_c)); - relation_futures.emplace_back(std::async(std::launch::async, perm_main_mem_ind_addr_d)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_byte_lengths)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_byte_operations)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_opcode_gas)); - relation_futures.emplace_back(std::async(std::launch::async, range_check_l2_gas_hi)); - relation_futures.emplace_back(std::async(std::launch::async, range_check_l2_gas_lo)); - relation_futures.emplace_back(std::async(std::launch::async, range_check_da_gas_hi)); - relation_futures.emplace_back(std::async(std::launch::async, range_check_da_gas_lo)); - relation_futures.emplace_back(std::async(std::launch::async, kernel_output_lookup)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_into_kernel)); - relation_futures.emplace_back(std::async(std::launch::async, incl_main_tag_err)); - relation_futures.emplace_back(std::async(std::launch::async, incl_mem_tag_err)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_mem_rng_chk_lo)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_mem_rng_chk_mid)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_mem_rng_chk_hi)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_pow_2_0)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_pow_2_1)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_u8_0)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_u8_1)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_u16_0)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_u16_1)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_u16_2)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_u16_3)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_u16_4)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_u16_5)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_u16_6)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_u16_7)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_u16_8)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_u16_9)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_u16_10)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_u16_11)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_u16_12)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_u16_13)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_u16_14)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_div_u16_0)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_div_u16_1)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_div_u16_2)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_div_u16_3)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_div_u16_4)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_div_u16_5)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_div_u16_6)); - relation_futures.emplace_back(std::async(std::launch::async, lookup_div_u16_7)); // Wait for lookup evaluations to complete @@ -1479,141 +1282,6 @@ class AvmCircuitBuilder { return false; } } -#else - - alu(); - - binary(); - - conversion(); - - gas(); - - keccakf1600(); - - kernel(); - - main(); - - mem(); - - pedersen(); - - poseidon2(); - - powers(); - - sha256(); - - perm_main_alu(); - - perm_main_bin(); - - perm_main_conv(); - - perm_main_pos2_perm(); - - perm_main_pedersen(); - - perm_main_mem_a(); - - perm_main_mem_b(); - - perm_main_mem_c(); - - perm_main_mem_d(); - - perm_main_mem_ind_addr_a(); - - perm_main_mem_ind_addr_b(); - - perm_main_mem_ind_addr_c(); - - perm_main_mem_ind_addr_d(); - - lookup_byte_lengths(); - - lookup_byte_operations(); - - lookup_opcode_gas(); - - range_check_l2_gas_hi(); - - range_check_l2_gas_lo(); - - range_check_da_gas_hi(); - - range_check_da_gas_lo(); - - kernel_output_lookup(); - - lookup_into_kernel(); - - incl_main_tag_err(); - - incl_mem_tag_err(); - - lookup_mem_rng_chk_lo(); - - lookup_mem_rng_chk_mid(); - - lookup_mem_rng_chk_hi(); - - lookup_pow_2_0(); - - lookup_pow_2_1(); - - 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_div_u16_0(); - - lookup_div_u16_1(); - - lookup_div_u16_2(); - - lookup_div_u16_3(); - - lookup_div_u16_4(); - - lookup_div_u16_5(); - - lookup_div_u16_6(); - - lookup_div_u16_7(); - -#endif return true; } @@ -1628,4 +1296,5 @@ class AvmCircuitBuilder { return num_rows_pow2; } }; -} // namespace bb + +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.cpp index d923c58c1cc8..e0086cfeab01 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.cpp @@ -1,6 +1,5 @@ +#include "barretenberg/vm/generated/avm_composer.hpp" - -#include "./avm_composer.hpp" #include "barretenberg/plonk_honk_shared/composer/composer_lib.hpp" #include "barretenberg/plonk_honk_shared/composer/permutation_lib.hpp" #include "barretenberg/vm/generated/avm_circuit_builder.hpp" @@ -82,4 +81,4 @@ std::shared_ptr AvmComposer::compute_verification_key(C return verification_key; } -} // namespace bb +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.hpp index a2f9fe68dcf5..9eb218aaba02 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_composer.hpp @@ -1,5 +1,3 @@ - - #pragma once #include "barretenberg/plonk_honk_shared/composer/composer_lib.hpp" @@ -9,6 +7,7 @@ #include "barretenberg/vm/generated/avm_verifier.hpp" namespace bb { + class AvmComposer { public: using Flavor = AvmFlavor; @@ -66,4 +65,4 @@ class AvmComposer { }; }; -} // namespace bb +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp index dc0a5392567c..2633bb78f0fe 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp @@ -1,6 +1,5 @@ +#include "barretenberg/vm/generated/avm_prover.hpp" - -#include "avm_prover.hpp" #include "barretenberg/commitment_schemes/claim.hpp" #include "barretenberg/commitment_schemes/commitment_key.hpp" #include "barretenberg/honk/proof_system/logderivative_library.hpp" @@ -9,7 +8,6 @@ #include "barretenberg/polynomials/polynomial.hpp" #include "barretenberg/relations/permutation_relation.hpp" #include "barretenberg/sumcheck/sumcheck.hpp" -#include "barretenberg/vm/avm_trace/stats.hpp" namespace bb { @@ -23,7 +21,7 @@ using FF = Flavor::FF; * @param input_manifest Input manifest * * @tparam settings Settings class. - * */ + */ AvmProver::AvmProver(std::shared_ptr input_key, std::shared_ptr commitment_key) : key(input_key) , commitment_key(commitment_key) @@ -56,7 +54,6 @@ void AvmProver::execute_preamble_round() */ void AvmProver::execute_wire_commitments_round() { - // Commit to all polynomials (apart from logderivative inverse polynomials, which are committed to in the later // logderivative phase) auto wire_polys = prover_polynomials.get_wires(); @@ -68,7 +65,6 @@ void AvmProver::execute_wire_commitments_round() void AvmProver::execute_log_derivative_inverse_round() { - auto [beta, gamm] = transcript->template get_challenges("beta", "gamma"); relation_parameters.beta = beta; relation_parameters.gamma = gamm; @@ -214,8 +210,7 @@ void AvmProver::execute_relation_check_rounds() /** * @brief Execute the ZeroMorph protocol to prove the multilinear evaluations produced by Sumcheck * @details See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description of the unrolled protocol. - * - * */ + */ void AvmProver::execute_pcs_rounds() { auto prover_opening_claim = ZeroMorph::prove(key->circuit_size, @@ -241,20 +236,20 @@ HonkProof AvmProver::construct_proof() execute_preamble_round(); // Compute wire commitments - AVM_TRACK_TIME("proving/wire_commitments_round_ms", execute_wire_commitments_round()); + execute_wire_commitments_round(); // Compute sorted list accumulator and commitment - AVM_TRACK_TIME("proving/log_derivative_inverse_round_ms", execute_log_derivative_inverse_round()); + execute_log_derivative_inverse_round(); // Fiat-Shamir: alpha // Run sumcheck subprotocol. - AVM_TRACK_TIME("proving/relation_check_rounds_ms", execute_relation_check_rounds()); + execute_relation_check_rounds(); // Fiat-Shamir: rho, y, x, z // Execute Zeromorph multilinear PCS - AVM_TRACK_TIME("proving/pcs_rounds_ms", execute_pcs_rounds()); + execute_pcs_rounds(); return export_proof(); } -} // namespace bb +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.hpp index 3f95563ac066..892b11a525ff 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.hpp @@ -1,6 +1,5 @@ - - #pragma once + #include "barretenberg/commitment_schemes/zeromorph/zeromorph.hpp" #include "barretenberg/plonk/proof_system/types/proof.hpp" #include "barretenberg/relations/relation_parameters.hpp" @@ -12,7 +11,6 @@ namespace bb { class AvmProver { - using Flavor = AvmFlavor; using FF = Flavor::FF; using PCS = Flavor::PCS; @@ -61,4 +59,4 @@ class AvmProver { HonkProof proof; }; -} // namespace bb +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp index 71f078ae5605..b1046c8400a7 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp @@ -1,6 +1,5 @@ +#include "barretenberg/vm/generated/avm_verifier.hpp" - -#include "./avm_verifier.hpp" #include "barretenberg/commitment_schemes/zeromorph/zeromorph.hpp" #include "barretenberg/numeric/bitop/get_msb.hpp" #include "barretenberg/polynomials/polynomial.hpp" @@ -194,24 +193,20 @@ bool AvmVerifier::verify_proof(const HonkProof& proof, const std::vector transcript; }; -} // namespace bb +} // namespace bb \ No newline at end of file diff --git a/bb-pilcom/bb-pil-backend/src/circuit_builder.rs b/bb-pilcom/bb-pil-backend/src/circuit_builder.rs index 1f93f0367e8e..2ea0da2a0d00 100644 --- a/bb-pilcom/bb-pil-backend/src/circuit_builder.rs +++ b/bb-pilcom/bb-pil-backend/src/circuit_builder.rs @@ -1,8 +1,6 @@ -use crate::{ - file_writer::BBFiles, - relation_builder::create_row_type, - utils::{get_relations_imports, map_with_newline, snake_case}, -}; +use crate::{file_writer::BBFiles, utils::snake_case}; +use handlebars::Handlebars; +use serde_json::json; pub trait CircuitBuilder { fn create_circuit_builder_hpp( @@ -19,52 +17,7 @@ pub trait CircuitBuilder { fn create_circuit_builder_cpp(&mut self, name: &str, all_cols: &[String]); } -fn circuit_hpp_includes(name: &str, relations: &[String], permutations: &[String]) -> String { - let relation_imports = get_relations_imports(name, relations, permutations); - format!( - " - // AUTOGENERATED FILE - #pragma once - - #include -#ifndef __wasm__ - #include -#endif - - #include \"barretenberg/common/constexpr_utils.hpp\" - #include \"barretenberg/common/throw_or_abort.hpp\" - #include \"barretenberg/ecc/curves/bn254/fr.hpp\" - #include \"barretenberg/stdlib_circuit_builders/circuit_builder_base.hpp\" - #include \"barretenberg/relations/generic_permutation/generic_permutation_relation.hpp\" - #include \"barretenberg/relations/generic_lookup/generic_lookup_relation.hpp\" - #include \"barretenberg/honk/proof_system/logderivative_library.hpp\" - - #include \"barretenberg/vm/generated/{name}_flavor.hpp\" - {relation_imports} -" - ) -} - -fn get_params() -> &'static str { - r#" - const FF gamma = FF::random_element(); - const FF beta = FF::random_element(); - bb::RelationParameters params{ - .eta = 0, - .beta = beta, - .gamma = gamma, - .public_input_delta = 0, - .lookup_grand_product_delta = 0, - .beta_sqr = 0, - .beta_cube = 0, - .eccvm_set_permutation_delta = 0, - }; - "# -} - impl CircuitBuilder for BBFiles { - // Create circuit builder - // Generate some code that can read a commits.bin and constants.bin into data structures that bberg understands fn create_circuit_builder_hpp( &mut self, name: &str, @@ -75,182 +28,27 @@ impl CircuitBuilder for BBFiles { to_be_shifted: &[String], all_cols_with_shifts: &[String], ) { - let includes = circuit_hpp_includes(&snake_case(name), relations, permutations); - - let row_with_all_included = create_row_type(&format!("{name}Full"), all_cols_with_shifts); - - let num_polys = all_cols.len(); - let num_cols = all_cols.len() + to_be_shifted.len(); - - // Declare mapping transformations - let compute_polys_transformation = - |name: &String| format!("polys.{name}[i] = rows[i].{name};"); - let all_polys_transformation = - |name: &String| format!("polys.{name}_shift = Polynomial(polys.{name}.shifted());"); - let check_circuit_transformation = |relation_name: &String| { - format!( - "auto {relation_name} = [=]() {{ - return evaluate_relation.template operator()<{name}_vm::{relation_name}>(\"{relation_name}\", {name}_vm::get_relation_label_{relation_name}); - }}; - ", - name = name, - relation_name = relation_name - ) - }; - let check_lookup_transformation = |lookup_name: &String| { - let lookup_name_upper = lookup_name.to_uppercase(); - format!( - "auto {lookup_name} = [=]() {{ - return evaluate_logderivative.template operator()<{lookup_name}_relation>(\"{lookup_name_upper}\"); - }}; - " - ) - }; - - // When we are running natively, we want check circuit to run as futures; however, futures are not supported in wasm, so we must provide an - // alternative codepath that will execute the closures in serial - let emplace_future_transformation = |relation_name: &String| { - format!( - " - relation_futures.emplace_back(std::async(std::launch::async, {relation_name})); - " - ) - }; + let mut handlebars = Handlebars::new(); + + let data = &json!({ + "name": name, + "relations": relations, + "permutations": permutations, + "all_cols_without_inverses": all_cols_without_inverses, + "all_cols": all_cols, + "to_be_shifted": to_be_shifted, + "all_cols_with_shifts": all_cols_with_shifts, + }); - let execute_serial_transformation = |relation_name: &String| { - format!( - " - {relation_name}(); - " + handlebars + .register_template_string( + "circuit_builder.hpp", + std::str::from_utf8(include_bytes!("../templates/circuit_builder.hpp.hbs")) + .unwrap(), ) - }; - - // Apply transformations - let compute_polys_assignemnt = - map_with_newline(all_cols_without_inverses, compute_polys_transformation); - let all_poly_shifts = map_with_newline(to_be_shifted, all_polys_transformation); - let check_circuit_for_each_relation = - map_with_newline(relations, check_circuit_transformation); - let check_circuit_for_each_lookup = - map_with_newline(permutations, check_lookup_transformation); - - // With futures - let emplace_future_relations = map_with_newline(relations, emplace_future_transformation); - let emplace_future_lookups = map_with_newline(permutations, emplace_future_transformation); - - // With threads - let serial_relations = map_with_newline(relations, execute_serial_transformation); - let serial_lookups = map_with_newline(permutations, execute_serial_transformation); - - let (params, lookup_check_closure) = if !permutations.is_empty() { - (get_params(), get_lookup_check_closure()) - } else { - ("", "".to_owned()) - }; - let relation_check_closure = if !relations.is_empty() { - get_relation_check_closure() - } else { - "".to_owned() - }; - - let circuit_hpp = format!(" -{includes} - -namespace bb {{ - -{row_with_all_included}; - -template std::ostream& operator<<(std::ostream& os, {name}FullRow const& row); - -class {name}CircuitBuilder {{ - public: - using Flavor = bb::{name}Flavor; - using FF = Flavor::FF; - using Row = {name}FullRow; - - // TODO: template - using Polynomial = Flavor::Polynomial; - using ProverPolynomials = Flavor::ProverPolynomials; - - static constexpr size_t num_fixed_columns = {num_cols}; - static constexpr size_t num_polys = {num_polys}; - std::vector rows; - - void set_trace(std::vector&& trace) {{ rows = std::move(trace); }} - - ProverPolynomials compute_polynomials() {{ - const auto num_rows = get_circuit_subgroup_size(); - ProverPolynomials polys; - - // Allocate mem for each column - for (auto& poly : polys.get_all()) {{ - poly = Polynomial(num_rows); - }} - - for (size_t i = 0; i < rows.size(); i++) {{ - {compute_polys_assignemnt} - }} - - {all_poly_shifts } - - return polys; - }} - - [[maybe_unused]] bool check_circuit() - {{ - {params} + .unwrap(); - auto polys = compute_polynomials(); - const size_t num_rows = polys.get_polynomial_size(); - - {relation_check_closure} - - {lookup_check_closure} - - {check_circuit_for_each_relation} - - {check_circuit_for_each_lookup} - -#ifndef __wasm__ - - // Evaluate check circuit closures as futures - std::vector> relation_futures; - - {emplace_future_relations} - {emplace_future_lookups} - - - // Wait for lookup evaluations to complete - for (auto& future : relation_futures) {{ - int result = future.get(); - if (!result) {{ - return false; - }} - }} -#else - {serial_relations} - {serial_lookups} - -#endif - - return true; - }} - - - [[nodiscard]] size_t get_num_gates() const {{ return rows.size(); }} - - [[nodiscard]] size_t get_circuit_subgroup_size() const - {{ - const size_t num_rows = get_num_gates(); - const auto num_rows_log2 = static_cast(numeric::get_msb64(num_rows)); - size_t num_rows_pow2 = 1UL << (num_rows_log2 + (1UL << num_rows_log2 == num_rows ? 0 : 1)); - return num_rows_pow2; - }} - - -}}; -}} - "); + let circuit_hpp = handlebars.render("circuit_builder.hpp", data).unwrap(); self.write_file( &self.circuit, @@ -260,49 +58,22 @@ class {name}CircuitBuilder {{ } fn create_circuit_builder_cpp(&mut self, name: &str, all_cols: &[String]) { - let names_list = map_with_newline(all_cols, |name: &String| format!("\"{}\",", name)); - let stream_all_relations = map_with_newline(all_cols, |name: &String| { - format!("<< field_to_string(row.{}) << \",\"", name) - }); - let snake_name = snake_case(name); + let mut handlebars = Handlebars::new(); - let circuit_cpp = format!( - " -#include \"barretenberg/vm/generated/{snake_name}_circuit_builder.hpp\" - -namespace bb {{ -namespace {{ - -template std::string field_to_string(const FF& ff) -{{ - std::ostringstream os; - os << ff; - std::string raw = os.str(); - auto first_not_zero = raw.find_first_not_of('0', 2); - std::string result = \"0x\" + (first_not_zero != std::string::npos ? raw.substr(first_not_zero) : \"0\"); - return result; -}} - -}} // namespace - -template std::vector {name}FullRow::names() {{ - return {{ - {names_list} - \"\" - }}; -}} - -template std::ostream& operator<<(std::ostream& os, {name}FullRow const& row) {{ - return os {stream_all_relations} - \"\"; -}} + let data = &json!({ + "name": name, + "all_cols": all_cols, + }); -// Explicit template instantiation. -template std::ostream& operator<<(std::ostream& os, AvmFullRow const& row); -template std::vector AvmFullRow::names(); + handlebars + .register_template_string( + "circuit_builder.cpp", + std::str::from_utf8(include_bytes!("../templates/circuit_builder.cpp.hbs")) + .unwrap(), + ) + .unwrap(); -}} // namespace bb" - ); + let circuit_cpp = handlebars.render("circuit_builder.cpp", data).unwrap(); self.write_file( &self.circuit, @@ -311,64 +82,3 @@ template std::vector AvmFullRow::names(); ); } } - -fn get_lookup_check_closure() -> String { - " - const auto evaluate_logderivative = [&](const std::string& lookup_name) { - - // Check the logderivative relation - bb::compute_logderivative_inverse< - Flavor, - LogDerivativeSettings>( - polys, params, num_rows); - - typename LogDerivativeSettings::SumcheckArrayOfValuesOverSubrelations - lookup_result; - - for (auto& r : lookup_result) { - r = 0; - } - for (size_t i = 0; i < num_rows; ++i) { - LogDerivativeSettings::accumulate(lookup_result, polys.get_row(i), params, 1); - } - for (auto r : lookup_result) { - if (r != 0) { - throw_or_abort(format(\"Lookup \", lookup_name, \" failed.\")); - return false; - } - } - return true; - }; - ".to_string() -} - -fn get_relation_check_closure() -> String { - " - const auto evaluate_relation = [&](const std::string& relation_name, - std::string (*debug_label)(int)) { - typename Relation::SumcheckArrayOfValuesOverSubrelations result; - for (auto& r : result) { - r = 0; - } - constexpr size_t NUM_SUBRELATIONS = result.size(); - - for (size_t i = 0; i < num_rows; ++i) { - Relation::accumulate(result, polys.get_row(i), {}, 1); - - bool x = true; - for (size_t j = 0; j < NUM_SUBRELATIONS; ++j) { - if (result[j] != 0) { - std::string row_name = debug_label(static_cast(j)); - throw_or_abort( - format(\"Relation \", relation_name, \", subrelation index \", row_name, \" failed at row \", i)); - x = false; - } - } - if (!x) { - return false; - } - } - return true; - }; - ".to_string() -} diff --git a/bb-pilcom/bb-pil-backend/src/composer_builder.rs b/bb-pilcom/bb-pil-backend/src/composer_builder.rs index 2cbd8576d1a5..7849b50c487a 100644 --- a/bb-pilcom/bb-pil-backend/src/composer_builder.rs +++ b/bb-pilcom/bb-pil-backend/src/composer_builder.rs @@ -1,5 +1,6 @@ -use crate::file_writer::BBFiles; -use crate::utils::snake_case; +use crate::{file_writer::BBFiles, utils::snake_case}; +use handlebars::Handlebars; +use serde_json::json; pub trait ComposerBuilder { fn create_composer_cpp(&mut self, name: &str); @@ -8,94 +9,21 @@ pub trait ComposerBuilder { impl ComposerBuilder for BBFiles { fn create_composer_cpp(&mut self, name: &str) { - // Create a composer file, this is used to a prover and verifier for our flavour - let include_str = cpp_includes(&snake_case(name)); + let mut handlebars = Handlebars::new(); - let composer_cpp = format!( - " -{include_str} + let data = &json!({ + "name": name, + }); -namespace bb {{ + handlebars + .register_template_string( + "composer.cpp", + std::str::from_utf8(include_bytes!("../templates/composer.cpp.hbs")).unwrap(), + ) + .unwrap(); -using Flavor = {name}Flavor; -void {name}Composer::compute_witness(CircuitConstructor& circuit) -{{ - if (computed_witness) {{ - return; - }} + let composer_cpp = handlebars.render("composer.cpp", data).unwrap(); - auto polynomials = circuit.compute_polynomials(); - - for (auto [key_poly, prover_poly] : zip_view(proving_key->get_all(), polynomials.get_unshifted())) {{ - ASSERT(flavor_get_label(*proving_key, key_poly) == flavor_get_label(polynomials, prover_poly)); - key_poly = prover_poly; - }} - - computed_witness = true; -}} - -{name}Prover {name}Composer::create_prover(CircuitConstructor& circuit_constructor) -{{ - compute_proving_key(circuit_constructor); - compute_witness(circuit_constructor); - compute_commitment_key(circuit_constructor.get_circuit_subgroup_size()); - - {name}Prover output_state(proving_key, proving_key->commitment_key); - - return output_state; -}} - -{name}Verifier {name}Composer::create_verifier( - CircuitConstructor& circuit_constructor) -{{ - auto verification_key = compute_verification_key(circuit_constructor); - - {name}Verifier output_state(verification_key); - - auto pcs_verification_key = std::make_unique(); - - output_state.pcs_verification_key = std::move(pcs_verification_key); - - return output_state; -}} - -std::shared_ptr {name}Composer::compute_proving_key( - CircuitConstructor& circuit_constructor) -{{ - if (proving_key) {{ - return proving_key; - }} - - // Initialize proving_key - {{ - const size_t subgroup_size = circuit_constructor.get_circuit_subgroup_size(); - proving_key = std::make_shared(subgroup_size, 0); - }} - - proving_key->contains_recursive_proof = false; - - return proving_key; -}} - -std::shared_ptr {name}Composer::compute_verification_key( - CircuitConstructor& circuit_constructor) -{{ - if (verification_key) {{ - return verification_key; - }} - - if (!proving_key) {{ - compute_proving_key(circuit_constructor); - }} - - verification_key = - std::make_shared(proving_key->circuit_size, proving_key->num_public_inputs); - - return verification_key; -}} - -}} -"); self.write_file( &self.composer, &format!("{}_composer.cpp", snake_case(name)), @@ -104,76 +32,20 @@ std::shared_ptr {name}Composer::compute_verification_ke } fn create_composer_hpp(&mut self, name: &str) { - let include_str = hpp_includes(&snake_case(name)); + let mut handlebars = Handlebars::new(); - let composer_hpp = format!( - " -{include_str} + let data = &json!({ + "name": name, + }); -namespace bb {{ -class {name}Composer {{ - public: - using Flavor = {name}Flavor; - using CircuitConstructor = {name}CircuitBuilder; - using ProvingKey = Flavor::ProvingKey; - using VerificationKey = Flavor::VerificationKey; - using PCS = Flavor::PCS; - using CommitmentKey = Flavor::CommitmentKey; - using VerifierCommitmentKey = Flavor::VerifierCommitmentKey; + handlebars + .register_template_string( + "composer.hpp", + std::str::from_utf8(include_bytes!("../templates/composer.hpp.hbs")).unwrap(), + ) + .unwrap(); - // TODO: which of these will we really need - static constexpr std::string_view NAME_STRING = \"{name}\"; - static constexpr size_t NUM_RESERVED_GATES = 0; - static constexpr size_t NUM_WIRES = Flavor::NUM_WIRES; - - std::shared_ptr proving_key; - std::shared_ptr verification_key; - - // The crs_factory holds the path to the srs and exposes methods to extract the srs elements - std::shared_ptr> crs_factory_; - - // The commitment key is passed to the prover but also used herein to compute the verfication key commitments - std::shared_ptr commitment_key; - - std::vector recursive_proof_public_input_indices; - bool contains_recursive_proof = false; - bool computed_witness = false; - - {name}Composer() - {{ - crs_factory_ = bb::srs::get_bn254_crs_factory(); - }} - - {name}Composer(std::shared_ptr p_key, std::shared_ptr v_key) - : proving_key(std::move(p_key)) - , verification_key(std::move(v_key)) - {{}} - - {name}Composer({name}Composer&& other) noexcept = default; - {name}Composer({name}Composer const& other) noexcept = default; - {name}Composer& operator=({name}Composer&& other) noexcept = default; - {name}Composer& operator=({name}Composer const& other) noexcept = default; - ~{name}Composer() = default; - - std::shared_ptr compute_proving_key(CircuitConstructor& circuit_constructor); - std::shared_ptr compute_verification_key(CircuitConstructor& circuit_constructor); - - void compute_witness(CircuitConstructor& circuit_constructor); - - {name}Prover create_prover(CircuitConstructor& circuit_constructor); - {name}Verifier create_verifier(CircuitConstructor& circuit_constructor); - - void add_table_column_selector_poly_to_proving_key(bb::polynomial& small, const std::string& tag); - - void compute_commitment_key(size_t circuit_size) - {{ - proving_key->commitment_key = std::make_shared(circuit_size); - }}; -}}; - -}} // namespace bb -" - ); + let composer_hpp = handlebars.render("composer.hpp", data).unwrap(); self.write_file( &self.composer, @@ -182,29 +54,3 @@ class {name}Composer {{ ); } } - -fn cpp_includes(name: &str) -> String { - format!( - " -#include \"./{name}_composer.hpp\" -#include \"barretenberg/plonk_honk_shared/composer/composer_lib.hpp\" -#include \"barretenberg/plonk_honk_shared/composer/permutation_lib.hpp\" -#include \"barretenberg/vm/generated/{name}_circuit_builder.hpp\" -#include \"barretenberg/vm/generated/{name}_verifier.hpp\" -" - ) -} - -pub fn hpp_includes(name: &str) -> String { - format!( - " -#pragma once - -#include \"barretenberg/plonk_honk_shared/composer/composer_lib.hpp\" -#include \"barretenberg/srs/global_crs.hpp\" -#include \"barretenberg/vm/generated/{name}_circuit_builder.hpp\" -#include \"barretenberg/vm/generated/{name}_prover.hpp\" -#include \"barretenberg/vm/generated/{name}_verifier.hpp\" - " - ) -} diff --git a/bb-pilcom/bb-pil-backend/src/prover_builder.rs b/bb-pilcom/bb-pil-backend/src/prover_builder.rs index 9a2ce5643a9c..f74a8c71a70c 100644 --- a/bb-pilcom/bb-pil-backend/src/prover_builder.rs +++ b/bb-pilcom/bb-pil-backend/src/prover_builder.rs @@ -1,5 +1,6 @@ -use crate::file_writer::BBFiles; -use crate::utils::{map_with_newline, snake_case}; +use crate::{file_writer::BBFiles, utils::snake_case}; +use handlebars::Handlebars; +use serde_json::json; pub trait ProverBuilder { fn create_prover_hpp(&mut self, name: &str); @@ -9,65 +10,21 @@ pub trait ProverBuilder { impl ProverBuilder for BBFiles { fn create_prover_hpp(&mut self, name: &str) { - let include_str = includes_hpp(&snake_case(name)); + let mut handlebars = Handlebars::new(); - let prover_hpp = format!(" - {include_str} - namespace bb {{ - - class {name}Prover {{ - - using Flavor = {name}Flavor; - using FF = Flavor::FF; - using PCS = Flavor::PCS; - using Curve = Flavor::Curve; - using ZeroMorph = ZeroMorphProver_; - using PCSCommitmentKey = Flavor::CommitmentKey; - using ProvingKey = Flavor::ProvingKey; - using Polynomial = Flavor::Polynomial; - using ProverPolynomials = Flavor::ProverPolynomials; - using CommitmentLabels = Flavor::CommitmentLabels; - using Transcript = Flavor::Transcript; - - public: - explicit {name}Prover(std::shared_ptr input_key, std::shared_ptr commitment_key); - - void execute_preamble_round(); - void execute_wire_commitments_round(); - void execute_log_derivative_inverse_round(); - void execute_relation_check_rounds(); - void execute_pcs_rounds(); - - HonkProof export_proof(); - HonkProof construct_proof(); - - std::shared_ptr transcript = std::make_shared(); - - std::vector public_inputs; - - bb::RelationParameters relation_parameters; - - std::shared_ptr key; - - // Container for spans of all polynomials required by the prover (i.e. all multivariates evaluated by Sumcheck). - ProverPolynomials prover_polynomials; - - CommitmentLabels commitment_labels; - typename Flavor::WitnessCommitments witness_commitments; + let data = &json!({ + "name": name, + }); + + handlebars + .register_template_string( + "prover.hpp", + std::str::from_utf8(include_bytes!("../templates/prover.hpp.hbs")).unwrap(), + ) + .unwrap(); + + let prover_hpp = handlebars.render("prover.hpp", data).unwrap(); - Polynomial quotient_W; - - SumcheckOutput sumcheck_output; - - std::shared_ptr commitment_key; - - private: - HonkProof proof; - }}; - - }} // namespace bb - - "); self.write_file( &self.prover, &format!("{}_prover.hpp", snake_case(name)), @@ -75,148 +32,22 @@ impl ProverBuilder for BBFiles { ); } - /// Create the prover cpp file - /// - /// Committed polys are included as we manually unroll all commitments, as we do not commit to everything fn create_prover_cpp(&mut self, name: &str, lookup_names: &[String]) { - let include_str = includes_cpp(&snake_case(name)); - - let polynomial_commitment_phase = create_commitments_phase(); - let log_derivative_inverse_phase = create_log_derivative_inverse_round(lookup_names); - - let prover_cpp = format!(" - {include_str} - - namespace bb {{ - - using Flavor = {name}Flavor; - using FF = Flavor::FF; - - /** - * Create {name}Prover from proving key, witness and manifest. - * - * @param input_key Proving key. - * @param input_manifest Input manifest - * - * @tparam settings Settings class. - * */ - {name}Prover::{name}Prover(std::shared_ptr input_key, - std::shared_ptr commitment_key) - : key(input_key) - , commitment_key(commitment_key) - {{ - for (auto [prover_poly, key_poly] : zip_view(prover_polynomials.get_unshifted(), key->get_all())) {{ - ASSERT(bb::flavor_get_label(prover_polynomials, prover_poly) == - bb::flavor_get_label(*key, key_poly)); - prover_poly = key_poly.share(); - }} - for (auto [prover_poly, key_poly] : zip_view(prover_polynomials.get_shifted(), key->get_to_be_shifted())) {{ - ASSERT(bb::flavor_get_label(prover_polynomials, prover_poly) == - bb::flavor_get_label(*key, key_poly) + \"_shift\"); - prover_poly = key_poly.shifted(); - }} - }} - - - /** - * @brief Add circuit size, public input size, and public inputs to transcript - * - */ - void {name}Prover::execute_preamble_round() - {{ - const auto circuit_size = static_cast(key->circuit_size); - - transcript->send_to_verifier(\"circuit_size\", circuit_size); - }} - - /** - * @brief Compute commitments to all of the witness wires (apart from the logderivative inverse wires) - * - */ - void {name}Prover::execute_wire_commitments_round() - {{ - - {polynomial_commitment_phase} - - }} + let mut handlebars = Handlebars::new(); - void {name}Prover::execute_log_derivative_inverse_round() - {{ + let data = &json!({ + "name": name, + "lookups": lookup_names, + }); - {log_derivative_inverse_phase} - }} - - /** - * @brief Run Sumcheck resulting in u = (u_1,...,u_d) challenges and all evaluations at u being calculated. - * - */ - void {name}Prover::execute_relation_check_rounds() - {{ - using Sumcheck = SumcheckProver; - - auto sumcheck = Sumcheck(key->circuit_size, transcript); + handlebars + .register_template_string( + "prover.cpp", + std::str::from_utf8(include_bytes!("../templates/prover.cpp.hbs")).unwrap(), + ) + .unwrap(); - FF alpha = transcript->template get_challenge(\"Sumcheck:alpha\"); - std::vector gate_challenges(numeric::get_msb(key->circuit_size)); - - for (size_t idx = 0; idx < gate_challenges.size(); idx++) {{ - gate_challenges[idx] = transcript->template get_challenge(\"Sumcheck:gate_challenge_\" + std::to_string(idx)); - }} - sumcheck_output = sumcheck.prove(prover_polynomials, relation_parameters, alpha, gate_challenges); - }} - - - /** - * @brief Execute the ZeroMorph protocol to prove the multilinear evaluations produced by Sumcheck - * @details See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description of the unrolled protocol. - * - * */ - void {name}Prover::execute_pcs_rounds() - {{ - auto prover_opening_claim = ZeroMorph::prove(key->circuit_size, - prover_polynomials.get_unshifted(), - prover_polynomials.get_to_be_shifted(), - sumcheck_output.claimed_evaluations.get_unshifted(), - sumcheck_output.claimed_evaluations.get_shifted(), - sumcheck_output.challenge, - commitment_key, - transcript); - PCS::compute_opening_proof(commitment_key, prover_opening_claim, transcript); - }} - - - HonkProof {name}Prover::export_proof() - {{ - proof = transcript->proof_data; - return proof; - }} - - HonkProof {name}Prover::construct_proof() - {{ - // Add circuit size public input size and public inputs to transcript. - execute_preamble_round(); - - // Compute wire commitments - AVM_TRACK_TIME(\"proving/wire_commitments_round_ms\", execute_wire_commitments_round()); - - // Compute sorted list accumulator and commitment - AVM_TRACK_TIME(\"proving/log_derivative_inverse_round_ms\", execute_log_derivative_inverse_round()); - - // Fiat-Shamir: alpha - // Run sumcheck subprotocol. - AVM_TRACK_TIME(\"proving/relation_check_rounds_ms\", execute_relation_check_rounds()); - - // Fiat-Shamir: rho, y, x, z - // Execute Zeromorph multilinear PCS - AVM_TRACK_TIME(\"proving/pcs_rounds_ms\", execute_pcs_rounds()); - - return export_proof(); - }} - - }} // namespace bb - - - "); + let prover_cpp = handlebars.render("prover.cpp", data).unwrap(); self.write_file( &self.prover, @@ -225,90 +56,3 @@ impl ProverBuilder for BBFiles { ); } } - -fn includes_hpp(name: &str) -> String { - format!( - " -#pragma once -#include \"barretenberg/commitment_schemes/zeromorph/zeromorph.hpp\" -#include \"barretenberg/plonk/proof_system/types/proof.hpp\" -#include \"barretenberg/relations/relation_parameters.hpp\" -#include \"barretenberg/sumcheck/sumcheck_output.hpp\" -#include \"barretenberg/transcript/transcript.hpp\" - -#include \"barretenberg/vm/generated/{name}_flavor.hpp\" - - " - ) -} - -fn includes_cpp(name: &str) -> String { - format!( - " - - #include \"{name}_prover.hpp\" - #include \"barretenberg/commitment_schemes/claim.hpp\" - #include \"barretenberg/commitment_schemes/commitment_key.hpp\" - #include \"barretenberg/honk/proof_system/logderivative_library.hpp\" - #include \"barretenberg/honk/proof_system/permutation_library.hpp\" - #include \"barretenberg/plonk_honk_shared/library/grand_product_library.hpp\" - #include \"barretenberg/polynomials/polynomial.hpp\" - #include \"barretenberg/relations/permutation_relation.hpp\" - #include \"barretenberg/sumcheck/sumcheck.hpp\" - #include \"barretenberg/vm/avm_trace/stats.hpp\" - " - ) -} - -/// Commitment Transform -/// -/// Produces code to perform kzg commitment, then stores in the witness_commitments struct -fn commitment_transform(name: &String) -> String { - format!("witness_commitments.{name} = commitment_key->commit(key->{name});") -} - -/// Send to Verifier Transform -/// -/// Sends commitment produces in commitment_transform to the verifier -fn send_to_verifier_transform(name: &String) -> String { - format!("transcript->send_to_verifier(commitment_labels.{name}, witness_commitments.{name});") -} - -fn create_commitments_phase() -> String { - format!( - " - // Commit to all polynomials (apart from logderivative inverse polynomials, which are committed to in the later logderivative phase) - auto wire_polys = prover_polynomials.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])); - }} - " - ) -} - -fn create_log_derivative_inverse_round(lookup_operations: &[String]) -> String { - if lookup_operations.is_empty() { - return "".to_owned(); - } - - let all_commit_operations = map_with_newline(lookup_operations, commitment_transform); - let send_to_verifier_operations = - map_with_newline(lookup_operations, send_to_verifier_transform); - - format!( - " - 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 - {all_commit_operations} - - // Send all commitments to the verifier - {send_to_verifier_operations} - " - ) -} diff --git a/bb-pilcom/bb-pil-backend/src/relation_builder.rs b/bb-pilcom/bb-pil-backend/src/relation_builder.rs index dcb15e54f4e2..b76c54a2de9a 100644 --- a/bb-pilcom/bb-pil-backend/src/relation_builder.rs +++ b/bb-pilcom/bb-pil-backend/src/relation_builder.rs @@ -14,8 +14,11 @@ use std::path::Path; use powdr_number::{BigUint, DegreeType, FieldElement}; +use handlebars::Handlebars; +use serde_json::json; + use crate::file_writer::BBFiles; -use crate::utils::{capitalize, map_with_newline, snake_case}; +use crate::utils::snake_case; /// Returned back to the vm builder from the create_relations call pub struct RelationOutput { @@ -57,10 +60,9 @@ pub trait RelationBuilder { &self, root_name: &str, name: &str, - sub_relations: &[String], identities: &[BBIdentity], - row_type: &str, - labels_lookup: String, + all_cols: &[String], + labels: &HashMap, ); /// Declare views @@ -84,35 +86,27 @@ impl RelationBuilder for BBFiles { relations.sort(); // Contains all of the rows in each relation, will be useful for creating composite builder types - let mut all_rows: HashMap = HashMap::new(); let mut shifted_polys: Vec = Vec::new(); // ----------------------- Create the relation files ----------------------- for (relation_name, analyzed_idents) in grouped_relations.iter() { let IdentitiesOutput { - subrelations, + subrelations: _, identities, collected_cols, collected_shifts, expression_labels, } = create_identities(file_name, analyzed_idents); - // TODO: This can probably be moved into the create_identities function - let row_type = create_row_type(&capitalize(relation_name), &collected_cols); - // Aggregate all shifted polys shifted_polys.extend(collected_shifts); - // Aggregate all rows - all_rows.insert(relation_name.to_owned(), row_type.clone()); - let labels_lookup = create_relation_labels(relation_name, expression_labels); self.create_relation( file_name, relation_name, - &subrelations, &identities, - &row_type, - labels_lookup, + &collected_cols, + &expression_labels, ); } @@ -129,57 +123,68 @@ impl RelationBuilder for BBFiles { &self, root_name: &str, name: &str, - sub_relations: &[String], identities: &[BBIdentity], - row_type: &str, - labels_lookup: String, + all_cols: &[String], + labels: &HashMap, ) { - let includes = relation_includes(); - let class_boilerplate = relation_class_boilerplate(name, sub_relations, identities); - let export = get_export(name); - - let relations = format!( - "{includes} -namespace bb::{root_name}_vm {{ - -{row_type}; - -{labels_lookup} - -{class_boilerplate} - -{export} - - }}" - ); + let mut handlebars = Handlebars::new(); + let degrees: Vec<_> = identities.iter().map(|(d, _)| d + 1).collect(); + let sorted_labels = labels + .iter() + .sorted_by_key(|(idx, _)| *idx) + .collect::>(); + + let data = &json!({ + "root_name": root_name, + "name": name, + "identities": identities.iter().map(|(d, id)| { + json!({ + "degree": d, + "identity": id, + }) + }).collect::>(), + "degrees": degrees, + "all_cols": all_cols, + "labels": sorted_labels, + }); + + handlebars + .register_template_string( + "relation.hpp", + std::str::from_utf8(include_bytes!("../templates/relation.hpp.hbs")).unwrap(), + ) + .unwrap(); + + let relation_hpp = handlebars.render("relation.hpp", data).unwrap(); self.write_file( &format!("{}/{}", &self.rel, snake_case(root_name)), &format!("{}.hpp", snake_case(name)), - &relations, + &relation_hpp, ); } fn create_declare_views(&self, name: &str, all_cols_and_shifts: &[String]) { - let view_transformation = - |name: &String| format!("[[maybe_unused]] auto {name} = View(new_term.{name}); \\"); - let make_view_per_row = map_with_newline(all_cols_and_shifts, view_transformation); + let mut handlebars = Handlebars::new(); - let declare_views = format!( - " - #define {name}_DECLARE_VIEWS(index) \\ - using Accumulator = typename std::tuple_element::type; \\ - using View = typename Accumulator::View; \\ - {make_view_per_row} + let data = &json!({ + "root_name": name, + "all_cols_and_shifts": all_cols_and_shifts, + }); + handlebars + .register_template_string( + "declare_views.hpp", + std::str::from_utf8(include_bytes!("../templates/declare_views.hpp.hbs")).unwrap(), + ) + .unwrap(); - " - ); + let declare_views_hpp = handlebars.render("declare_views.hpp", data).unwrap(); self.write_file( &format!("{}/{}", &self.rel, snake_case(name)), "declare_views.hpp", - &declare_views, + &declare_views_hpp, ); } } @@ -219,92 +224,6 @@ fn group_relations_per_file( }) } -fn relation_class_boilerplate( - name: &str, - sub_relations: &[String], - identities: &[BBIdentity], -) -> String { - // We add one to all degrees because we have an extra scaling factor - let degrees = identities.iter().map(|(d, _)| d + 1).collect(); - let degree_boilerplate = get_degree_boilerplate(degrees); - let relation_code = get_relation_code(sub_relations); - format!( - "template class {name}Impl {{ - public: - using FF = FF_; - - {degree_boilerplate} - - {relation_code} -}};", - ) -} - -fn get_export(name: &str) -> String { - format!( - "template using {name} = Relation<{name}Impl>;", - name = name - ) -} - -fn get_relation_code(ids: &[String]) -> String { - let mut relation_code = r#" - template - void static accumulate( - ContainerOverSubrelations& evals, - const AllEntities& new_term, - [[maybe_unused]] const RelationParameters&, - [[maybe_unused]] const FF& scaling_factor - ){ - - "# - .to_owned(); - for id in ids { - relation_code.push_str(&format!("{}\n", id)); - } - relation_code.push_str("}\n"); - relation_code -} - -fn get_degree_boilerplate(degrees: Vec) -> String { - let num_degrees = degrees.len(); - - let mut degree_boilerplate = format!( - "static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{{\n" - ); - for degree in °rees { - degree_boilerplate.push_str(&format!(" {},\n", degree)); - } - degree_boilerplate.push_str("};"); - - degree_boilerplate -} - -// The include statements required for a new relation file -fn relation_includes() -> &'static str { - r#" -#pragma once -#include "../../relation_parameters.hpp" -#include "../../relation_types.hpp" -#include "./declare_views.hpp" -"# -} - -// Each vm will need to have a row which is a combination of all of the witness columns -pub(crate) fn create_row_type(name: &str, all_rows: &[String]) -> String { - let row_transformation = |row: &_| format!(" FF {row} {{}};"); - let all_annotated = map_with_newline(all_rows, row_transformation); - - format!( - "template struct {name}Row {{ - {} - - [[maybe_unused]] static std::vector names(); - }}", - all_annotated, - ) -} - fn create_identity( expression: &SelectedExpressions>, collected_cols: &mut HashSet, @@ -532,42 +451,3 @@ pub(crate) fn create_identities( expression_labels, } } - -/// Relation labels -/// -/// To view relation labels we create a sparse switch that contains all of the collected labels -/// Whenever there is a failure, we can lookup into this mapping -/// -/// Note: this mapping will never be that big, so we are quite naive in implementation -/// It should be able to be called from else where with relation_name::get_relation_label -fn create_relation_labels(relation_name: &str, labels: HashMap) -> String { - // Sort labels by the index - let label_transformation = |(index, label)| { - format!( - "case {index}: - return \"{label}\"; - " - ) - }; - - // Sort the labels by their index - let mut sorted_labels: Vec<(usize, String)> = labels.into_iter().collect(); - sorted_labels.sort_by(|a, b| a.0.cmp(&b.0)); - - let switch_statement: String = sorted_labels - .into_iter() - .map(label_transformation) - .collect::>() - .join("\n"); - - format!( - " - inline std::string get_relation_label_{relation_name}(int index) {{ - switch (index) {{ - {switch_statement} - }} - return std::to_string(index); - }} - " - ) -} diff --git a/bb-pilcom/bb-pil-backend/src/utils.rs b/bb-pilcom/bb-pil-backend/src/utils.rs index f84dfac2f1d9..9a4ce358953e 100644 --- a/bb-pilcom/bb-pil-backend/src/utils.rs +++ b/bb-pilcom/bb-pil-backend/src/utils.rs @@ -1,18 +1,5 @@ use itertools::Itertools; -/// Get Relations Imports -/// -/// We may have multiple relation files in the generated foler -/// This method will return all of the imports for the relation header files -pub fn get_relations_imports(name: &str, relations: &[String], permutations: &[String]) -> String { - let all_relations = flatten(&[relations.to_vec(), permutations.to_vec()]); - let transformation = |relation_name: &_| { - format!("#include \"barretenberg/relations/generated/{name}/{relation_name}.hpp\"") - }; - - map_with_newline(&all_relations, transformation) -} - /// Sanitize Names /// /// Column titles that we get from pil contain . to distinguish which pil namespace they belong to @@ -21,26 +8,6 @@ pub fn sanitize_name(string: &str) -> String { string.replace(['.', '[', ']'], "_") } -/// Capitalize -pub fn capitalize(s: &str) -> String { - let mut c = s.chars(); - match c.next() { - None => String::new(), - Some(f) => f.to_uppercase().collect::() + c.as_str(), - } -} - -/// Map With Newline -/// This utility function is used all over the codegen pipeline -/// It takes a list, usually the names of columns in an execution trace and applies a string transformation "op" -/// to each element in the list -pub fn map_with_newline(list: &[String], op: Func) -> String -where - Func: Fn(&String) -> String, -{ - transform_map(list, op).join("\n") -} - /// Collect Col /// /// Transforms columns from powdr representation ( where the witnesses are linked ) diff --git a/bb-pilcom/bb-pil-backend/src/verifier_builder.rs b/bb-pilcom/bb-pil-backend/src/verifier_builder.rs index 588574de2ca3..eb9a774f8026 100644 --- a/bb-pilcom/bb-pil-backend/src/verifier_builder.rs +++ b/bb-pilcom/bb-pil-backend/src/verifier_builder.rs @@ -1,7 +1,6 @@ -use crate::{ - file_writer::BBFiles, - utils::{map_with_newline, snake_case}, -}; +use crate::{file_writer::BBFiles, utils::snake_case}; +use handlebars::Handlebars; +use serde_json::json; pub trait VerifierBuilder { fn create_verifier_cpp( @@ -21,269 +20,56 @@ impl VerifierBuilder for BBFiles { inverses: &[String], public_cols: &[(String, usize)], ) { - let include_str = includes_cpp(&snake_case(name)); - - let wire_transformation = |n: &String| { - format!( - "commitments.{n} = transcript->template receive_from_prover(commitment_labels.{n});" - ) - }; - let has_public_input_columns = !public_cols.is_empty(); - let has_inverses = !inverses.is_empty(); - - let get_inverse_challenges = if has_inverses { - " - auto [beta, gamm] = transcript->template get_challenges(\"beta\", \"gamma\"); - relation_parameters.beta = beta; - relation_parameters.gamma = gamm; - " - .to_string() - } else { - "".to_owned() - }; - - let verify_proof_function_declaration: String = if has_public_input_columns { - format!("bool {name}Verifier::verify_proof(const HonkProof& proof, const std::vector>& public_inputs)") - } else { - format!("bool {name}Verifier::verify_proof(const HonkProof& proof)") - }; - - let public_inputs_column_transformation = - |public_inputs_column_name: &String, idx: usize| { - format!( - " - FF {public_inputs_column_name}_evaluation = evaluate_public_input_column(public_inputs[{idx}], circuit_size, mle_challenge); - if ({public_inputs_column_name}_evaluation != claimed_evaluations.{public_inputs_column_name}) {{ - return false; - }} - " + let mut handlebars = Handlebars::new(); + + let data = &json!({ + "name": name, + "inverses": inverses, + "public_cols": public_cols.iter().map(|(name, idx)| { + json!({ + "col": name, + "idx": idx, + }) + }).collect::>() + }); + + handlebars + .register_template_string( + "verifier.cpp", + std::str::from_utf8(include_bytes!("../templates/verifier.cpp.hbs")).unwrap(), ) - }; - - let (public_inputs_check, evaluate_public_inputs) = if has_public_input_columns { - let inputs_check = public_cols - .iter() - .map(|(col_name, idx)| public_inputs_column_transformation(col_name, *idx)) - .collect::(); - - let evaluate_public_inputs = format!( - " - - using FF = {name}Flavor::FF; - - // Evaluate the given public input column over the multivariate challenge points - [[maybe_unused]] inline FF evaluate_public_input_column(const std::vector& points, const size_t circuit_size, std::vector challenges) {{ - - // TODO(https://github.com/AztecProtocol/aztec-packages/issues/6361): we pad the points to the circuit size in order to get the correct evaluation. - // This is not efficient, and will not be valid in production. - std::vector new_points(circuit_size, 0); - std::copy(points.begin(), points.end(), new_points.data()); - - Polynomial polynomial(new_points); - return polynomial.evaluate_mle(challenges); - }} - " - ); - - (inputs_check, evaluate_public_inputs) - } else { - ("".to_owned(), "".to_owned()) - }; - - let inverse_commitments = map_with_newline(inverses, wire_transformation); - - let ver_cpp = format!(" -{include_str} - - namespace bb {{ - - - {name}Verifier::{name}Verifier(std::shared_ptr verifier_key) - : key(verifier_key) - {{}} - - {name}Verifier::{name}Verifier({name}Verifier&& other) noexcept - : key(std::move(other.key)) - , pcs_verification_key(std::move(other.pcs_verification_key)) - {{}} - - {name}Verifier& {name}Verifier::operator=({name}Verifier&& other) noexcept - {{ - key = other.key; - pcs_verification_key = (std::move(other.pcs_verification_key)); - commitments.clear(); - return *this; - }} + .unwrap(); - {evaluate_public_inputs} - - - /** - * @brief This function verifies an {name} Honk proof for given program settings. - * - */ - {verify_proof_function_declaration} - {{ - using Flavor = {name}Flavor; - using FF = Flavor::FF; - using Commitment = Flavor::Commitment; - // using PCS = Flavor::PCS; - // using Curve = Flavor::Curve; - // using ZeroMorph = ZeroMorphVerifier_; - using VerifierCommitments = Flavor::VerifierCommitments; - using CommitmentLabels = Flavor::CommitmentLabels; - - RelationParameters relation_parameters; - - transcript = std::make_shared(proof); - - VerifierCommitments commitments {{ key }}; - CommitmentLabels commitment_labels; - - const auto circuit_size = transcript->template receive_from_prover(\"circuit_size\"); - - if (circuit_size != key->circuit_size) {{ - return false; - }} - - // Get commitments to VM wires - for (auto [comm, label] : zip_view(commitments.get_wires(), commitment_labels.get_wires())) {{ - comm = transcript->template receive_from_prover(label); - }} - - {get_inverse_challenges} - - // Get commitments to inverses - {inverse_commitments} - - // Execute Sumcheck Verifier - const size_t log_circuit_size = numeric::get_msb(circuit_size); - auto sumcheck = SumcheckVerifier(log_circuit_size, transcript); - - FF alpha = transcript->template get_challenge(\"Sumcheck:alpha\"); - - auto gate_challenges = std::vector(log_circuit_size); - for (size_t idx = 0; idx < log_circuit_size; idx++) {{ - gate_challenges[idx] = transcript->template get_challenge(\"Sumcheck:gate_challenge_\" + std::to_string(idx)); - }} - - auto [multivariate_challenge, claimed_evaluations, sumcheck_verified] = - sumcheck.verify(relation_parameters, alpha, gate_challenges); - - // If Sumcheck did not verify, return false - if (sumcheck_verified.has_value() && !sumcheck_verified.value()) {{ - return false; - }} - - // Public columns evaluation checks - std::vector mle_challenge(multivariate_challenge.begin(), - multivariate_challenge.begin() + static_cast(log_circuit_size)); - {public_inputs_check} - - // Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description of the - // unrolled protocol. - // NOTE: temporarily disabled - facing integration issues - // auto opening_claim = ZeroMorph::verify(commitments.get_unshifted(), - // commitments.get_to_be_shifted(), - // claimed_evaluations.get_unshifted(), - // claimed_evaluations.get_shifted(), - // multivariate_challenge, - // pcs_verification_key->get_g1_identity(), - // transcript); - - // auto pairing_points = PCS::reduce_verify(opening_claim, transcript); - // auto verified = pcs_verification_key->pairing_check(pairing_points[0], pairing_points[1]); - // return sumcheck_verified.value() && verified; - return sumcheck_verified.value(); - }} - - - }} // namespace bb - - - "); + let verifier_cpp = handlebars.render("verifier.cpp", data).unwrap(); self.write_file( &self.prover, &format!("{}_verifier.cpp", snake_case(name)), - &ver_cpp, + &verifier_cpp, ); } fn create_verifier_hpp(&mut self, name: &str, public_cols: &[(String, usize)]) { - let include_str = include_hpp(&snake_case(name)); + let mut handlebars = Handlebars::new(); - // If there are public input columns, then the generated verifier must take them in as an argument for the verify_proof - let verify_proof = if !public_cols.is_empty() { - "bool verify_proof(const HonkProof& proof, const std::vector>& public_inputs);" - .to_string() - } else { - "bool verify_proof(const HonkProof& proof);".to_owned() - }; + let data = &json!({ + "name": name, + "public_cols": public_cols, + }); - let ver_hpp = format!( - " -{include_str} - - namespace bb {{ - class {name}Verifier {{ - using Flavor = {name}Flavor; - using FF = Flavor::FF; - using Commitment = Flavor::Commitment; - using VerificationKey = Flavor::VerificationKey; - using VerifierCommitmentKey = Flavor::VerifierCommitmentKey; - using Transcript = Flavor::Transcript; - - public: - explicit {name}Verifier(std::shared_ptr verifier_key = nullptr); - {name}Verifier({name}Verifier&& other) noexcept; - {name}Verifier(const {name}Verifier& other) = delete; - - {name}Verifier& operator=(const {name}Verifier& other) = delete; - {name}Verifier& operator=({name}Verifier&& other) noexcept; - - {verify_proof} - - std::shared_ptr key; - std::map commitments; - std::shared_ptr pcs_verification_key; - std::shared_ptr transcript; - }}; - - }} // namespace bb - - - " - ); + handlebars + .register_template_string( + "verifier.hpp", + std::str::from_utf8(include_bytes!("../templates/verifier.hpp.hbs")).unwrap(), + ) + .unwrap(); + + let verifier_hpp = handlebars.render("verifier.hpp", data).unwrap(); self.write_file( &self.prover, &format!("{}_verifier.hpp", snake_case(name)), - &ver_hpp, + &verifier_hpp, ); } } - -fn include_hpp(name: &str) -> String { - format!( - " -#pragma once -#include \"barretenberg/plonk/proof_system/types/proof.hpp\" -#include \"barretenberg/sumcheck/sumcheck.hpp\" -#include \"barretenberg/vm/generated/{name}_flavor.hpp\" -#include \"barretenberg/vm/avm_trace/constants.hpp\" -" - ) -} - -fn includes_cpp(name: &str) -> String { - format!( - " - #include \"./{name}_verifier.hpp\" - #include \"barretenberg/commitment_schemes/zeromorph/zeromorph.hpp\" - #include \"barretenberg/numeric/bitop/get_msb.hpp\" - #include \"barretenberg/polynomials/polynomial.hpp\" - #include \"barretenberg/transcript/transcript.hpp\" - " - ) -} diff --git a/bb-pilcom/bb-pil-backend/templates/circuit_builder.cpp.hbs b/bb-pilcom/bb-pil-backend/templates/circuit_builder.cpp.hbs new file mode 100644 index 000000000000..26dd5d3d5148 --- /dev/null +++ b/bb-pilcom/bb-pil-backend/templates/circuit_builder.cpp.hbs @@ -0,0 +1,39 @@ +#include "barretenberg/vm/generated/{{snakeCase name}}_circuit_builder.hpp" + +namespace bb { +namespace { + +template std::string field_to_string(const FF& ff) +{ + std::ostringstream os; + os << ff; + std::string raw = os.str(); + auto first_not_zero = raw.find_first_not_of('0', 2); + std::string result = "0x" + (first_not_zero != std::string::npos ? raw.substr(first_not_zero) : "0"); + return result; +} + +} // namespace + +template std::vector {{name}}FullRow::names() +{ + return { + {{#each all_cols as |col|}} + {{#if @index}},{{/if}}"{{col}}" + {{/each}} + }; +} + +template std::ostream& operator<<(std::ostream& os, {{name}}FullRow const& row) +{ + return os << + {{#each all_cols as |col|}} + {{#if @index}}<< "," << {{/if}}field_to_string(row.{{col}}) // + {{/each}}; +} + +// Explicit template instantiation. +template std::ostream& operator<<(std::ostream& os, {{name}}FullRow const& row); +template std::vector {{name}}FullRow::names(); + +} // namespace bb diff --git a/bb-pilcom/bb-pil-backend/templates/circuit_builder.hpp.hbs b/bb-pilcom/bb-pil-backend/templates/circuit_builder.hpp.hbs new file mode 100644 index 000000000000..03606a232615 --- /dev/null +++ b/bb-pilcom/bb-pil-backend/templates/circuit_builder.hpp.hbs @@ -0,0 +1,188 @@ +// AUTOGENERATED FILE +#pragma once + +#include +#ifndef __wasm__ +#include +#endif + +#include "barretenberg/common/constexpr_utils.hpp" +#include "barretenberg/common/throw_or_abort.hpp" +#include "barretenberg/ecc/curves/bn254/fr.hpp" +#include "barretenberg/stdlib_circuit_builders/circuit_builder_base.hpp" +#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" +#include "barretenberg/honk/proof_system/logderivative_library.hpp" + +// This already imports the relations and permutations. For now we rely on the transitive includes. +#include "barretenberg/vm/generated/{{snakeCase name}}_flavor.hpp" + +namespace bb { + +template +struct {{name}}FullRow { + {{#each all_cols_with_shifts as |col|}} + FF {{col}}{}; + {{/each}} + + [[maybe_unused]] static std::vector names(); +}; + +template std::ostream& operator<<(std::ostream& os, {{name}}FullRow const& row); + +class {{name}}CircuitBuilder { + public: + using Flavor = bb::{{name}}Flavor; + using FF = Flavor::FF; + using Row = {{name}}FullRow; + + // TODO: template + using Polynomial = Flavor::Polynomial; + using ProverPolynomials = Flavor::ProverPolynomials; + + static constexpr size_t num_fixed_columns = {{len all_cols}}; + static constexpr size_t num_polys = {{len all_cols}} + {{len to_be_shifted}}; + std::vector rows; + + void set_trace(std::vector&& trace) { rows = std::move(trace); } + + ProverPolynomials compute_polynomials() { + const auto num_rows = get_circuit_subgroup_size(); + ProverPolynomials polys; + + // Allocate mem for each column + for (auto& poly : polys.get_all()) { + poly = Polynomial(num_rows); + } + + for (size_t i = 0; i < rows.size(); i++) { + {{#each all_cols_without_inverses as |poly|}} + polys.{{poly}}[i] = rows[i].{{poly}}; + {{/each}} + } + + {{#each to_be_shifted as |poly|}} + polys.{{poly}}_shift = Polynomial(polys.{{poly}}.shifted()); + {{/each}} + + return polys; + } + + [[maybe_unused]] bool check_circuit() + { + const FF gamma = FF::random_element(); + const FF beta = FF::random_element(); + bb::RelationParameters params{ + .eta = 0, + .beta = beta, + .gamma = gamma, + .public_input_delta = 0, + .lookup_grand_product_delta = 0, + .beta_sqr = 0, + .beta_cube = 0, + .eccvm_set_permutation_delta = 0, + }; + + auto polys = compute_polynomials(); + const size_t num_rows = polys.get_polynomial_size(); + + const auto evaluate_relation = [&](const std::string& relation_name, + std::string (*debug_label)(int)) { + typename Relation::SumcheckArrayOfValuesOverSubrelations result; + for (auto& r : result) { + r = 0; + } + constexpr size_t NUM_SUBRELATIONS = result.size(); + + for (size_t i = 0; i < num_rows; ++i) { + Relation::accumulate(result, polys.get_row(i), {}, 1); + + bool x = true; + for (size_t j = 0; j < NUM_SUBRELATIONS; ++j) { + if (result[j] != 0) { + std::string row_name = debug_label(static_cast(j)); + throw_or_abort( + format("Relation ", relation_name, ", subrelation index ", row_name, " failed at row ", i)); + x = false; + } + } + if (!x) { + return false; + } + } + return true; + }; + + const auto evaluate_logderivative = [&](const std::string& lookup_name) { + // Check the logderivative relation + bb::compute_logderivative_inverse< + Flavor, + LogDerivativeSettings>( + polys, params, num_rows); + + typename LogDerivativeSettings::SumcheckArrayOfValuesOverSubrelations + lookup_result; + + for (auto& r : lookup_result) { + r = 0; + } + for (size_t i = 0; i < num_rows; ++i) { + LogDerivativeSettings::accumulate(lookup_result, polys.get_row(i), params, 1); + } + for (auto r : lookup_result) { + if (r != 0) { + throw_or_abort(format("Lookup ", lookup_name, " failed.")); + return false; + } + } + return true; + }; + + // Check relations + {{#each relations as |rel|}} + auto {{rel}} = [=]() { + return evaluate_relation.template operator()<{{../name}}_vm::{{rel}}>("{{rel}}", {{../name}}_vm::get_relation_label_{{rel}}); + }; + {{/each}} + + // Check lookups + {{#each permutations as |l|}} + auto {{l}} = [=]() { + return evaluate_logderivative.template operator()<{{l}}_relation>("{{shoutySnakeCase l}}"); + }; + {{/each}} + + // Evaluate check circuit closures as futures + std::vector> relation_futures; + + {{#each relations as |rel|}} + relation_futures.emplace_back(std::async(std::launch::async, {{rel}})); + {{/each}} + {{#each permutations as |l|}} + relation_futures.emplace_back(std::async(std::launch::async, {{l}})); + {{/each}} + + // Wait for lookup evaluations to complete + for (auto& future : relation_futures) { + int result = future.get(); + if (!result) { + return false; + } + } + + return true; + } + + + [[nodiscard]] size_t get_num_gates() const { return rows.size(); } + + [[nodiscard]] size_t get_circuit_subgroup_size() const + { + const size_t num_rows = get_num_gates(); + const auto num_rows_log2 = static_cast(numeric::get_msb64(num_rows)); + size_t num_rows_pow2 = 1UL << (num_rows_log2 + (1UL << num_rows_log2 == num_rows ? 0 : 1)); + return num_rows_pow2; + } +}; + +} // namespace bb \ No newline at end of file diff --git a/bb-pilcom/bb-pil-backend/templates/composer.cpp.hbs b/bb-pilcom/bb-pil-backend/templates/composer.cpp.hbs new file mode 100644 index 000000000000..ddb2743c1254 --- /dev/null +++ b/bb-pilcom/bb-pil-backend/templates/composer.cpp.hbs @@ -0,0 +1,84 @@ +#include "barretenberg/vm/generated/{{snakeCase name}}_composer.hpp" + +#include "barretenberg/plonk_honk_shared/composer/composer_lib.hpp" +#include "barretenberg/plonk_honk_shared/composer/permutation_lib.hpp" +#include "barretenberg/vm/generated/{{snakeCase name}}_circuit_builder.hpp" +#include "barretenberg/vm/generated/{{snakeCase name}}_verifier.hpp" + +namespace bb { + +using Flavor = {{name}}Flavor; +void {{name}}Composer::compute_witness(CircuitConstructor& circuit) +{ + if (computed_witness) { + return; + } + + auto polynomials = circuit.compute_polynomials(); + + for (auto [key_poly, prover_poly] : zip_view(proving_key->get_all(), polynomials.get_unshifted())) { + ASSERT(flavor_get_label(*proving_key, key_poly) == flavor_get_label(polynomials, prover_poly)); + key_poly = prover_poly; + } + + computed_witness = true; +} + +{{name}}Prover {{name}}Composer::create_prover(CircuitConstructor& circuit_constructor) +{ + compute_proving_key(circuit_constructor); + compute_witness(circuit_constructor); + compute_commitment_key(circuit_constructor.get_circuit_subgroup_size()); + + {{name}}Prover output_state(proving_key, proving_key->commitment_key); + + return output_state; +} + +{{name}}Verifier {{name}}Composer::create_verifier(CircuitConstructor& circuit_constructor) +{ + auto verification_key = compute_verification_key(circuit_constructor); + + {{name}}Verifier output_state(verification_key); + + auto pcs_verification_key = std::make_unique(); + + output_state.pcs_verification_key = std::move(pcs_verification_key); + + return output_state; +} + +std::shared_ptr {{name}}Composer::compute_proving_key(CircuitConstructor& circuit_constructor) +{ + if (proving_key) { + return proving_key; + } + + // Initialize proving_key + { + const size_t subgroup_size = circuit_constructor.get_circuit_subgroup_size(); + proving_key = std::make_shared(subgroup_size, 0); + } + + proving_key->contains_recursive_proof = false; + + return proving_key; +} + +std::shared_ptr {{name}}Composer::compute_verification_key(CircuitConstructor& circuit_constructor) +{ + if (verification_key) { + return verification_key; + } + + if (!proving_key) { + compute_proving_key(circuit_constructor); + } + + verification_key = + std::make_shared(proving_key->circuit_size, proving_key->num_public_inputs); + + return verification_key; +} + +} // namespace bb \ No newline at end of file diff --git a/bb-pilcom/bb-pil-backend/templates/composer.hpp.hbs b/bb-pilcom/bb-pil-backend/templates/composer.hpp.hbs new file mode 100644 index 000000000000..d6c8e4155c64 --- /dev/null +++ b/bb-pilcom/bb-pil-backend/templates/composer.hpp.hbs @@ -0,0 +1,68 @@ +#pragma once + +#include "barretenberg/plonk_honk_shared/composer/composer_lib.hpp" +#include "barretenberg/srs/global_crs.hpp" +#include "barretenberg/vm/generated/{{snakeCase name}}_circuit_builder.hpp" +#include "barretenberg/vm/generated/{{snakeCase name}}_prover.hpp" +#include "barretenberg/vm/generated/{{snakeCase name}}_verifier.hpp" + +namespace bb { + +class {{name}}Composer { + public: + using Flavor = {{name}}Flavor; + using CircuitConstructor = {{name}}CircuitBuilder; + using ProvingKey = Flavor::ProvingKey; + using VerificationKey = Flavor::VerificationKey; + using PCS = Flavor::PCS; + using CommitmentKey = Flavor::CommitmentKey; + using VerifierCommitmentKey = Flavor::VerifierCommitmentKey; + + // TODO: which of these will we really need + static constexpr std::string_view NAME_STRING = "{{name}}"; + static constexpr size_t NUM_RESERVED_GATES = 0; + static constexpr size_t NUM_WIRES = Flavor::NUM_WIRES; + + std::shared_ptr proving_key; + std::shared_ptr verification_key; + + // The crs_factory holds the path to the srs and exposes methods to extract the srs elements + std::shared_ptr> crs_factory_; + + // The commitment key is passed to the prover but also used herein to compute the verfication key commitments + std::shared_ptr commitment_key; + + std::vector recursive_proof_public_input_indices; + bool contains_recursive_proof = false; + bool computed_witness = false; + + {{name}}Composer() { crs_factory_ = bb::srs::get_bn254_crs_factory(); } + + {{name}}Composer(std::shared_ptr p_key, std::shared_ptr v_key) + : proving_key(std::move(p_key)) + , verification_key(std::move(v_key)) + {} + + {{name}}Composer({{name}}Composer&& other) noexcept = default; + {{name}}Composer({{name}}Composer const& other) noexcept = default; + {{name}}Composer& operator=({{name}}Composer&& other) noexcept = default; + {{name}}Composer& operator=({{name}}Composer const& other) noexcept = default; + ~{{name}}Composer() = default; + + std::shared_ptr compute_proving_key(CircuitConstructor& circuit_constructor); + std::shared_ptr compute_verification_key(CircuitConstructor& circuit_constructor); + + void compute_witness(CircuitConstructor& circuit_constructor); + + {{name}}Prover create_prover(CircuitConstructor& circuit_constructor); + {{name}}Verifier create_verifier(CircuitConstructor& circuit_constructor); + + void add_table_column_selector_poly_to_proving_key(bb::polynomial& small, const std::string& tag); + + void compute_commitment_key(size_t circuit_size) + { + proving_key->commitment_key = std::make_shared(circuit_size); + }; +}; + +} // namespace bb \ No newline at end of file diff --git a/bb-pilcom/bb-pil-backend/templates/declare_views.hpp.hbs b/bb-pilcom/bb-pil-backend/templates/declare_views.hpp.hbs new file mode 100644 index 000000000000..3187ad0a92f9 --- /dev/null +++ b/bb-pilcom/bb-pil-backend/templates/declare_views.hpp.hbs @@ -0,0 +1,8 @@ +#pragma once + +#define {{root_name}}_DECLARE_VIEWS(index) \ + using Accumulator = typename std::tuple_element::type; \ + using View = typename Accumulator::View; \ + {{#each all_cols_and_shifts as |col| ~}} + [[maybe_unused]] auto {{col}} = View(new_term.{{col}});{{#unless @last}} \\{{/unless}} + {{/each}} \ No newline at end of file diff --git a/bb-pilcom/bb-pil-backend/templates/prover.cpp.hbs b/bb-pilcom/bb-pil-backend/templates/prover.cpp.hbs new file mode 100644 index 000000000000..75a9862e2fe7 --- /dev/null +++ b/bb-pilcom/bb-pil-backend/templates/prover.cpp.hbs @@ -0,0 +1,150 @@ +#include "barretenberg/vm/generated/{{snakeCase name}}_prover.hpp" + +#include "barretenberg/commitment_schemes/claim.hpp" +#include "barretenberg/commitment_schemes/commitment_key.hpp" +#include "barretenberg/honk/proof_system/logderivative_library.hpp" +#include "barretenberg/honk/proof_system/permutation_library.hpp" +#include "barretenberg/plonk_honk_shared/library/grand_product_library.hpp" +#include "barretenberg/polynomials/polynomial.hpp" +#include "barretenberg/relations/permutation_relation.hpp" +#include "barretenberg/sumcheck/sumcheck.hpp" + +namespace bb { + +using Flavor = {{name}}Flavor; +using FF = Flavor::FF; + +/** + * Create {{name}}Prover from proving key, witness and manifest. + * + * @param input_key Proving key. + * @param input_manifest Input manifest + * + * @tparam settings Settings class. + */ +{{name}}Prover::{{name}}Prover(std::shared_ptr input_key, + std::shared_ptr commitment_key) + : key(input_key) + , commitment_key(commitment_key) +{ + for (auto [prover_poly, key_poly] : zip_view(prover_polynomials.get_unshifted(), key->get_all())) { + ASSERT(bb::flavor_get_label(prover_polynomials, prover_poly) == + bb::flavor_get_label(*key, key_poly)); + prover_poly = key_poly.share(); + } + for (auto [prover_poly, key_poly] : zip_view(prover_polynomials.get_shifted(), key->get_to_be_shifted())) { + ASSERT(bb::flavor_get_label(prover_polynomials, prover_poly) == + bb::flavor_get_label(*key, key_poly) + "_shift"); + prover_poly = key_poly.shifted(); + } +} + +/** + * @brief Add circuit size, public input size, and public inputs to transcript + * + */ +void {{name}}Prover::execute_preamble_round() +{ + const auto circuit_size = static_cast(key->circuit_size); + + transcript->send_to_verifier("circuit_size", circuit_size); +} + +/** + * @brief Compute commitments to all of the witness wires (apart from the logderivative inverse wires) + * + */ +void {{name}}Prover::execute_wire_commitments_round() +{ + // Commit to all polynomials (apart from logderivative inverse polynomials, which are committed to in the later logderivative phase) + auto wire_polys = prover_polynomials.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])); + } +} + +void {{name}}Prover::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 + {{#each lookups as |l|}} + witness_commitments.{{l}} = commitment_key->commit(key->{{l}}); + {{/each}} + + // Send all commitments to the verifier + {{#each lookups as |l|}} + transcript->send_to_verifier(commitment_labels.{{l}}, witness_commitments.{{l}}); + {{/each}} +} + +/** + * @brief Run Sumcheck resulting in u = (u_1,...,u_d) challenges and all evaluations at u being calculated. + * + */ +void {{name}}Prover::execute_relation_check_rounds() +{ + using Sumcheck = SumcheckProver; + + auto sumcheck = Sumcheck(key->circuit_size, transcript); + + FF alpha = transcript->template get_challenge("Sumcheck:alpha"); + std::vector gate_challenges(numeric::get_msb(key->circuit_size)); + + for (size_t idx = 0; idx < gate_challenges.size(); idx++) { + gate_challenges[idx] = transcript->template get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx)); + } + sumcheck_output = sumcheck.prove(prover_polynomials, relation_parameters, alpha, gate_challenges); +} + +/** + * @brief Execute the ZeroMorph protocol to prove the multilinear evaluations produced by Sumcheck + * @details See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description of the unrolled protocol. + */ +void {{name}}Prover::execute_pcs_rounds() +{ + auto prover_opening_claim = ZeroMorph::prove(key->circuit_size, + prover_polynomials.get_unshifted(), + prover_polynomials.get_to_be_shifted(), + sumcheck_output.claimed_evaluations.get_unshifted(), + sumcheck_output.claimed_evaluations.get_shifted(), + sumcheck_output.challenge, + commitment_key, + transcript); + PCS::compute_opening_proof(commitment_key, prover_opening_claim, transcript); +} + +HonkProof {{name}}Prover::export_proof() +{ + proof = transcript->proof_data; + return proof; +} + +HonkProof {{name}}Prover::construct_proof() +{ + // Add circuit size public input size and public inputs to transcript. + execute_preamble_round(); + + // Compute wire commitments + execute_wire_commitments_round(); + + // Compute sorted list accumulator and commitment + execute_log_derivative_inverse_round(); + + // Fiat-Shamir: alpha + // Run sumcheck subprotocol. + execute_relation_check_rounds(); + + // Fiat-Shamir: rho, y, x, z + // Execute Zeromorph multilinear PCS + execute_pcs_rounds(); + + return export_proof(); +} + +} // namespace bb \ No newline at end of file diff --git a/bb-pilcom/bb-pil-backend/templates/prover.hpp.hbs b/bb-pilcom/bb-pil-backend/templates/prover.hpp.hbs new file mode 100644 index 000000000000..8915a9d8f29a --- /dev/null +++ b/bb-pilcom/bb-pil-backend/templates/prover.hpp.hbs @@ -0,0 +1,62 @@ +#pragma once + +#include "barretenberg/commitment_schemes/zeromorph/zeromorph.hpp" +#include "barretenberg/plonk/proof_system/types/proof.hpp" +#include "barretenberg/relations/relation_parameters.hpp" +#include "barretenberg/sumcheck/sumcheck_output.hpp" +#include "barretenberg/transcript/transcript.hpp" + +#include "barretenberg/vm/generated/{{snakeCase name}}_flavor.hpp" + +namespace bb { + +class {{name}}Prover { + using Flavor = {{name}}Flavor; + using FF = Flavor::FF; + using PCS = Flavor::PCS; + using Curve = Flavor::Curve; + using ZeroMorph = ZeroMorphProver_; + using PCSCommitmentKey = Flavor::CommitmentKey; + using ProvingKey = Flavor::ProvingKey; + using Polynomial = Flavor::Polynomial; + using ProverPolynomials = Flavor::ProverPolynomials; + using CommitmentLabels = Flavor::CommitmentLabels; + using Transcript = Flavor::Transcript; + + public: + explicit {{name}}Prover(std::shared_ptr input_key, std::shared_ptr commitment_key); + + void execute_preamble_round(); + void execute_wire_commitments_round(); + void execute_log_derivative_inverse_round(); + void execute_relation_check_rounds(); + void execute_pcs_rounds(); + + HonkProof export_proof(); + HonkProof construct_proof(); + + std::shared_ptr transcript = std::make_shared(); + + std::vector public_inputs; + + bb::RelationParameters relation_parameters; + + std::shared_ptr key; + + // Container for spans of all polynomials required by the prover (i.e. all multivariates evaluated by Sumcheck). + ProverPolynomials prover_polynomials; + + CommitmentLabels commitment_labels; + typename Flavor::WitnessCommitments witness_commitments; + + Polynomial quotient_W; + + SumcheckOutput sumcheck_output; + + std::shared_ptr commitment_key; + + private: + HonkProof proof; +}; + +} // namespace bb \ No newline at end of file diff --git a/bb-pilcom/bb-pil-backend/templates/relation.hpp.hbs b/bb-pilcom/bb-pil-backend/templates/relation.hpp.hbs new file mode 100644 index 000000000000..e295b642e420 --- /dev/null +++ b/bb-pilcom/bb-pil-backend/templates/relation.hpp.hbs @@ -0,0 +1,54 @@ +#pragma once + +#include "barretenberg/relations/relation_parameters.hpp" +#include "barretenberg/relations/relation_types.hpp" +#include "barretenberg/relations/generated/{{snakeCase root_name}}/declare_views.hpp" + +namespace bb::{{root_name}}_vm { + +template struct {{upperCamelCase name}}Row { + {{#each all_cols as |col|}} + FF {{col}}{}; + {{/each}} +}; + +inline std::string get_relation_label_{{name}}(int index) { + switch (index) { + {{#each labels as |label|}} + case {{label.0}}: + return "{{label.1}}"; + {{/each}} + } + return std::to_string(index); +} + +template class {{name}}Impl { + public: + using FF = FF_; + + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { + {{#each degrees as |degree|}}{{degree}}{{#unless @last}},{{/unless}}{{/each}} + }; + + template + void static accumulate( + ContainerOverSubrelations& evals, + const AllEntities& new_term, + [[maybe_unused]] const RelationParameters&, + [[maybe_unused]] const FF& scaling_factor + ){ + {{#each identities}} + // Contribution {{@index}} + { + {{../root_name}}_DECLARE_VIEWS({{@index}}); + auto tmp = {{identity}}; + tmp *= scaling_factor; + std::get<{{@index}}>(evals) += tmp; + } + {{/each}} + } +}; + +template using {{name}} = Relation<{{name}}Impl>; + +} // namespace bb::{{root_name}}_vm \ No newline at end of file diff --git a/bb-pilcom/bb-pil-backend/templates/verifier.cpp.hbs b/bb-pilcom/bb-pil-backend/templates/verifier.cpp.hbs new file mode 100644 index 000000000000..264f38b19087 --- /dev/null +++ b/bb-pilcom/bb-pil-backend/templates/verifier.cpp.hbs @@ -0,0 +1,133 @@ +#include "barretenberg/vm/generated/{{snakeCase name}}_verifier.hpp" + +#include "barretenberg/commitment_schemes/zeromorph/zeromorph.hpp" +#include "barretenberg/numeric/bitop/get_msb.hpp" +#include "barretenberg/polynomials/polynomial.hpp" +#include "barretenberg/transcript/transcript.hpp" + +namespace bb { + +{{name}}Verifier::{{name}}Verifier(std::shared_ptr verifier_key) + : key(verifier_key) +{} + +{{name}}Verifier::{{name}}Verifier({{name}}Verifier&& other) noexcept + : key(std::move(other.key)) + , pcs_verification_key(std::move(other.pcs_verification_key)) +{} + +{{name}}Verifier& {{name}}Verifier::operator=({{name}}Verifier&& other) noexcept +{ + key = other.key; + pcs_verification_key = (std::move(other.pcs_verification_key)); + commitments.clear(); + return *this; +} + +using FF = {{name}}Flavor::FF; + +// Evaluate the given public input column over the multivariate challenge points +[[maybe_unused]] inline FF evaluate_public_input_column(const std::vector& points, + const size_t circuit_size, + std::vector challenges) +{ + + // TODO(https://github.com/AztecProtocol/aztec-packages/issues/6361): we pad the points to the circuit size in order + // to get the correct evaluation. This is not efficient, and will not be valid in production. + std::vector new_points(circuit_size, 0); + std::copy(points.begin(), points.end(), new_points.data()); + + Polynomial polynomial(new_points); + return polynomial.evaluate_mle(challenges); +} + +/** + * @brief This function verifies an {{name}} Honk proof for given program settings. + * + */ +bool {{name}}Verifier::verify_proof(const HonkProof& proof, const std::vector>& public_inputs) +{ + using Flavor = {{name}}Flavor; + using FF = Flavor::FF; + using Commitment = Flavor::Commitment; + // using PCS = Flavor::PCS; + // using Curve = Flavor::Curve; + // using ZeroMorph = ZeroMorphVerifier_; + using VerifierCommitments = Flavor::VerifierCommitments; + using CommitmentLabels = Flavor::CommitmentLabels; + + RelationParameters relation_parameters; + + transcript = std::make_shared(proof); + + VerifierCommitments commitments{ key }; + CommitmentLabels commitment_labels; + + const auto circuit_size = transcript->template receive_from_prover("circuit_size"); + + if (circuit_size != key->circuit_size) { + return false; + } + + // Get commitments to VM wires + for (auto [comm, label] : zip_view(commitments.get_wires(), commitment_labels.get_wires())) { + comm = transcript->template receive_from_prover(label); + } + + auto [beta, gamm] = transcript->template get_challenges("beta", "gamma"); + relation_parameters.beta = beta; + relation_parameters.gamma = gamm; + + // Get commitments to inverses + {{#each inverses as |inv|}} + commitments.{{inv}} = transcript->template receive_from_prover(commitment_labels.{{inv}}); + {{/each}} + + // Execute Sumcheck Verifier + const size_t log_circuit_size = numeric::get_msb(circuit_size); + auto sumcheck = SumcheckVerifier(log_circuit_size, transcript); + + FF alpha = transcript->template get_challenge("Sumcheck:alpha"); + + auto gate_challenges = std::vector(log_circuit_size); + for (size_t idx = 0; idx < log_circuit_size; idx++) { + gate_challenges[idx] = transcript->template get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx)); + } + + auto [multivariate_challenge, claimed_evaluations, sumcheck_verified] = + sumcheck.verify(relation_parameters, alpha, gate_challenges); + + // If Sumcheck did not verify, return false + if (sumcheck_verified.has_value() && !sumcheck_verified.value()) { + return false; + } + + // Public columns evaluation checks + std::vector mle_challenge(multivariate_challenge.begin(), + multivariate_challenge.begin() + static_cast(log_circuit_size)); + + {{#each public_cols}} + FF {{col}}_evaluation = evaluate_public_input_column(public_inputs[{{idx}}], circuit_size, mle_challenge); + if ({{col}}_evaluation != claimed_evaluations.{{col}}) { + return false; + } + {{/each}} + + // Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description of the + // unrolled protocol. + // NOTE: temporarily disabled - facing integration issues + // auto opening_claim = ZeroMorph::verify(commitments.get_unshifted(), + // commitments.get_to_be_shifted(), + // claimed_evaluations.get_unshifted(), + // claimed_evaluations.get_shifted(), + // multivariate_challenge, + // pcs_verification_key->get_g1_identity(), + // transcript); + + // auto pairing_points = PCS::reduce_verify(opening_claim, transcript); + // auto verified = pcs_verification_key->pairing_check(pairing_points[0], pairing_points[1]); + // return sumcheck_verified.value() && verified; + return sumcheck_verified.value(); +} + +} // namespace bb \ No newline at end of file diff --git a/bb-pilcom/bb-pil-backend/templates/verifier.hpp.hbs b/bb-pilcom/bb-pil-backend/templates/verifier.hpp.hbs new file mode 100644 index 000000000000..11e150b6f023 --- /dev/null +++ b/bb-pilcom/bb-pil-backend/templates/verifier.hpp.hbs @@ -0,0 +1,34 @@ +#pragma once + +#include "barretenberg/plonk/proof_system/types/proof.hpp" +#include "barretenberg/sumcheck/sumcheck.hpp" +#include "barretenberg/vm/{{snakeCase name}}_trace/constants.hpp" +#include "barretenberg/vm/generated/{{snakeCase name}}_flavor.hpp" + +namespace bb { + +class {{name}}Verifier { + using Flavor = {{name}}Flavor; + using FF = Flavor::FF; + using Commitment = Flavor::Commitment; + using VerificationKey = Flavor::VerificationKey; + using VerifierCommitmentKey = Flavor::VerifierCommitmentKey; + using Transcript = Flavor::Transcript; + + public: + explicit {{name}}Verifier(std::shared_ptr verifier_key = nullptr); + {{name}}Verifier({{name}}Verifier&& other) noexcept; + {{name}}Verifier(const {{name}}Verifier& other) = delete; + + {{name}}Verifier& operator=(const {{name}}Verifier& other) = delete; + {{name}}Verifier& operator=({{name}}Verifier&& other) noexcept; + + bool verify_proof(const HonkProof& proof, const std::vector>& public_inputs); + + std::shared_ptr key; + std::map commitments; + std::shared_ptr pcs_verification_key; + std::shared_ptr transcript; +}; + +} // namespace bb \ No newline at end of file