diff --git a/barretenberg/cpp/pil/avm/alu.pil b/barretenberg/cpp/pil/avm/alu.pil index cb20b528252f..70d8b3042854 100644 --- a/barretenberg/cpp/pil/avm/alu.pil +++ b/barretenberg/cpp/pil/avm/alu.pil @@ -1,3 +1,4 @@ +include "gadgets/range_check.pil"; namespace alu(256); // ========= Table ALU-TR ================================================= diff --git a/barretenberg/cpp/pil/avm/gadgets/range_check.pil b/barretenberg/cpp/pil/avm/gadgets/range_check.pil new file mode 100644 index 000000000000..fb82a13baf46 --- /dev/null +++ b/barretenberg/cpp/pil/avm/gadgets/range_check.pil @@ -0,0 +1,190 @@ +include "../main.pil"; +include "../fixed/powers.pil"; + +namespace range_check(256); + pol commit clk; + + // Range check selector + pol commit sel_rng_chk; + sel_rng_chk * (1 - sel_rng_chk) = 0; + + // Witnesses + // Value to range check + pol commit value; + // Number of bits to check against + pol commit rng_chk_bits; + + // Bit Size Columns + // It is enforced (further down) that the selected column is the lowest multiple of 16 that is greater than rng_chk_bits + // e.g., rng_chk_bits = 10 ===> is_lte_u16, rng_chk_bits = 100 ==> is_lte_u112 + // If rng_chk_bits is a multiple of 16, a prover is able to choose either is_lte_xx or is_lte_xx(+16), since the dynamic register will prove 0 + // This isn't a concern and only costs the prover additional compute. + // TODO: Maybe we can get rid of is_lte_u128 since it's implicit if we have sel_rng_chk and no other is_lte_x + pol commit is_lte_u16; + pol commit is_lte_u32; + pol commit is_lte_u48; + pol commit is_lte_u64; + pol commit is_lte_u80; + pol commit is_lte_u96; + pol commit is_lte_u112; + pol commit is_lte_u128; + is_lte_u16 * (1 - is_lte_u16) = 0; + is_lte_u32 * (1 - is_lte_u32) = 0; + is_lte_u48 * (1 - is_lte_u48) = 0; + is_lte_u64 * (1 - is_lte_u64) = 0; + is_lte_u80 * (1 - is_lte_u80) = 0; + is_lte_u96 * (1 - is_lte_u96) = 0; + is_lte_u112 * (1 - is_lte_u112) = 0; + is_lte_u128 * (1 - is_lte_u128) = 0; + + // Mutual Exclusivity condition + is_lte_u16 + is_lte_u32 + is_lte_u48 + is_lte_u64 + is_lte_u80 + is_lte_u96 + is_lte_u112 + is_lte_u128 = sel_rng_chk; + + // Eight 16-bit slice registers + pol commit u16_r0; + pol commit u16_r1; + pol commit u16_r2; + pol commit u16_r3; + pol commit u16_r4; + pol commit u16_r5; + pol commit u16_r6; + // This register has a (more expensive) set of constraint that enables dynamic range check of bit values between 0 and 16 bits + pol commit u16_r7; + + // In each of these relations, the u16_r7 register contains the most significant 16 bits of value. + pol X_0 = is_lte_u16 * u16_r7; + pol X_1 = is_lte_u32 * (u16_r0 + u16_r7 * 2**16); + pol X_2 = is_lte_u48 * (u16_r0 + u16_r1 * 2**16 + u16_r7 * 2**32); + pol X_3 = is_lte_u64 * (u16_r0 + u16_r1 * 2**16 + u16_r2 * 2**32 + u16_r7 * 2**48); + pol X_4 = is_lte_u80 * (u16_r0 + u16_r1 * 2**16 + u16_r2 * 2**32 + u16_r3 * 2**48 + u16_r7 * 2**64); + pol X_5 = is_lte_u96 * (u16_r0 + u16_r1 * 2**16 + u16_r2 * 2**32 + u16_r3 * 2**48 + u16_r4 * 2**64 + u16_r7 * 2**80); + pol X_6 = is_lte_u112 * (u16_r0 + u16_r1 * 2**16 + u16_r2 * 2**32 + u16_r3 * 2**48 + u16_r4 * 2**64 + u16_r5 * 2**80 + u16_r7 * 2**96); + pol X_7 = is_lte_u128 * (u16_r0 + u16_r1 * 2**16 + u16_r2 * 2**32 + u16_r3 * 2**48 + u16_r4 * 2**64 + u16_r5 * 2**80 + u16_r6 * 2**96 + u16_r7 * 2**112); + + // Since the is_lte_x are mutually exclusive, only one of the Xs will be non-zero + pol RESULT = X_0 + X_1 + X_2 + X_3 + X_4 + X_5 + X_6 + X_7; + + #[CHECK_RECOMPOSITION] + sel_rng_chk * (RESULT - value) = 0; + + // ===== Dynamic Check Constraints ===== + + // The number of bits that form the dynamic range check is depending on the claimed lte value and the witness rng_chk_bits + // claimed is_lte_x | dyn_rng_chk_bits + // -----------------|----------------- + // is_lte_u16 | rng_chk_bits + // is_lte_u32 | rng_chk_bits - 16 + // is_lte_u48 | rng_chk_bits - 32 + // is_lte_u64 | rng_chk_bits - 48 + // is_lte_u80 | rng_chk_bits - 64 + // is_lte_u96 | rng_chk_bits - 80 + // is_lte_u112 | rng_chk_bits - 96 + // is_lte_u128 | rng_chk_bits - 112 + + // [CALCULATION STEPS] + // 1) Calculate dyn_rng_chk_bits from the table above + // 2) Calculate dyn_rng_chk_pow_2 = 2^dyn_rng_chk_bits + // 3) Calculate dyn_diff = dyn_rng_chk_pow_2 - u16_r7 - 1 + + // [ASSERTIONS] + // 1) Assert 0 <= dyn_rng_chk_bits <= 16 (i.e. dyn_rng_chk_bits supports up to a 16-bit number) + // 2) Assert dyn_diff > 0 (i.e. dyn_diff did not underflow) + + // === Ensuring dyn_rng_chk_bits is in the range [0,16] === + // 1) We perform an 8-bit lookup to get dyn_rng_chk_pow_2 - note this is an 8-bit lookup so only constrains dyn_rng_chk_bits to be [0, 255] + // 2) This value is used in dyn_diff = dyn_rng_chk_pow_2 - u16_r7 - 1 + // (a) A 16-bit lookup is performed on dyn_diff to check it hasn't underflowed - this constrains it to be between [0, 2^16 - 1] + // (b) u16_r7 is constrained by a 16-bit lookup table [0, 2^16 - 1] + // 3) If the value of dyn_rng_chk_pow_2 > 2^16, i.e. dyn_rng_chk_bits is > 16, the condition (2a) will not hold + // (a) [0, 2^16 - 1] = dyn_rng_chk_pow_2 - [0, 2^16 - 1] - 1 + // (b) from above, dyn_rng_check_pow_2 must be [0, 2^16] + + // Some counter-examples + // Assume a range check that the value 3 fits into 100 bits + // [A Valid Proof] + // 1) value = 3, rng_chk_bits = 100, is_lte_u112 = 1 + // 2) u16_r0 = 3, while all other registers including u16_r7 (the dynamic one) are set to zero - passing #[CHECK_RECOMPOSITION] + // 3) dyn_rng_chk_bits = 100 - 96 = 4, as per the table above - this passes #[LOOKUP_RNG_CHK_POW_2] + // 4) dyn_rng_chk_pow_2 = 2^4 = 16 + // 5) dyn_diff = dyn_rng_chk_pow_2 - u16_r7 - 1 = 16 - 0 - 1 = 15 - passing the range check #[LOOKUP_RNG_CHK_DIFF] + + // [An Invalid Proof where dyn_rng_chk_bits > 16] + // 1) value = 3, rng_chk_bits = 100, is_lte_u16 = 1 -- a prover tries to claim the value is between 0 and u16 (which it is but isnt what the range check attesting) + // 2) u16_r7 = 3, this still passes #[CHECK_RECOMPOSITION] + // 3) dyn_rng_chk_bits = 100, as per the table - this still passes #[LOOKUP_RNG_CHK_POW_2] + // 4) dyn_rng_check_pow_2 = 2^100 + // 5) dyn_diff = dyn_rng_chk_pow_2 - u16_r7 - 1 = 2^100 - 3 - 1 = 2^100 - 4 - this would fail the 16-bit range check #[LOOKUP_RNG_CHK_DIFF] + + // [An Invalid Proof where dyn_rng_chk_bits < 0] + // 1) value = 3, rng_chk_bits = 100, is_lte_u128 = 1 -- a prover claims it fits within u112 and u128. + // 2) u16_r0 = 3, while all other registers including u16_r7 (the dynamic one) are set to zero - passing #[CHECK_RECOMPOSITION] + // 3) dyn_rng_chk_bits = 100 - 112 = -12, as per the table above - this fails #[LOOKUP_RNG_CHK_POW_2] + + + // The number of bits that need to be dynamically range checked. + pol commit dyn_rng_chk_bits; + // Valid values for dyn_rng_chk_bits are in the range [0, 16] + dyn_rng_chk_bits - (rng_chk_bits - (is_lte_u32 * 16) - (is_lte_u48 * 32) - (is_lte_u64 * 48) - (is_lte_u80 * 64) - (is_lte_u96 * 80) - (is_lte_u112 * 96) - (is_lte_u128 * 112)) = 0; + + // To perform the dynamic range check we also need the value of 2^dyn_rng_chk_bits + pol commit dyn_rng_chk_pow_2; + + // This lookup does 2 things (1) Indirectly range checks dyn_rng_chk_bits to not have underflowed and (2) Simplified calculation of 2^dyn_rng_chk_bits + #[LOOKUP_RNG_CHK_POW_2] + sel_rng_chk {dyn_rng_chk_bits, dyn_rng_chk_pow_2} in main.sel_rng_8 {main.clk, powers.power_of_2}; + + + // Now we need to perform the dynamic range check itself + // We check that u16_r7 < dyn_rng_chk_pow_2 ==> dyn_rng_chk_pow_2 - u16_r7 - 1 >= 0 + pol commit dyn_diff; + sel_rng_chk * (dyn_diff - (dyn_rng_chk_pow_2 - u16_r7 - 1)) = 0; + // The value of dyn_diff has to be between [0, 2^16) + // To check we did not underflow we just range check it + #[LOOKUP_RNG_CHK_DIFF] + sel_rng_chk { dyn_diff } in main.sel_rng_16 { main.clk }; + + + // Lookup relations. + // We only need these relations while we do not support pol in the LHS selector + pol commit sel_lookup_0; + pol commit sel_lookup_1; + pol commit sel_lookup_2; + pol commit sel_lookup_3; + pol commit sel_lookup_4; + pol commit sel_lookup_5; + pol commit sel_lookup_6; + + // The lookups are cumulative - i.e. every value greater than 16 bits involve sel_lookup_0 + // Note that the lookup for the u16_r7 is always active (dynamic range check) + sel_lookup_0 - (is_lte_u32 + is_lte_u48 + is_lte_u64 + is_lte_u80 + is_lte_u96 + is_lte_u112 + is_lte_u128) = 0; + sel_lookup_1 - (is_lte_u48 + is_lte_u64 + is_lte_u80 + is_lte_u96 + is_lte_u112 + is_lte_u128) = 0; + sel_lookup_2 - (is_lte_u64 + is_lte_u80 + is_lte_u96 + is_lte_u112 + is_lte_u128) = 0; + sel_lookup_3 - (is_lte_u80 + is_lte_u96 + is_lte_u112 + is_lte_u128) = 0; + sel_lookup_4 - (is_lte_u96 + is_lte_u112 + is_lte_u128) = 0; + sel_lookup_5 - (is_lte_u112 + is_lte_u128) = 0; + sel_lookup_6 - is_lte_u128 = 0; + + #[LOOKUP_RNG_CHK_0] + sel_lookup_0 { u16_r0 } in main.sel_rng_16 { main.clk }; + + #[LOOKUP_RNG_CHK_1] + sel_lookup_1 { u16_r1 } in main.sel_rng_16 { main.clk }; + + #[LOOKUP_RNG_CHK_2] + sel_lookup_2 { u16_r2 } in main.sel_rng_16 { main.clk }; + + #[LOOKUP_RNG_CHK_3] + sel_lookup_3 { u16_r3 } in main.sel_rng_16 { main.clk }; + + #[LOOKUP_RNG_CHK_4] + sel_lookup_4 { u16_r4 } in main.sel_rng_16 { main.clk }; + + #[LOOKUP_RNG_CHK_5] + sel_lookup_5 { u16_r5 } in main.sel_rng_16 { main.clk }; + + #[LOOKUP_RNG_CHK_6] + sel_lookup_6 { u16_r6 } in main.sel_rng_16 { main.clk }; + + #[LOOKUP_RNG_CHK_7] + sel_rng_chk { u16_r7 } in main.sel_rng_16 { main.clk }; + diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/circuit_builder.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/circuit_builder.cpp index ec768c0055b5..eeb4dde6e012 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/circuit_builder.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/circuit_builder.cpp @@ -611,6 +611,36 @@ AvmCircuitBuilder::ProverPolynomials AvmCircuitBuilder::compute_polynomials() co polys.poseidon2_mem_addr_write_d[i] = rows[i].poseidon2_mem_addr_write_d; polys.poseidon2_output_addr[i] = rows[i].poseidon2_output_addr; polys.poseidon2_sel_poseidon_perm[i] = rows[i].poseidon2_sel_poseidon_perm; + polys.range_check_clk[i] = rows[i].range_check_clk; + polys.range_check_dyn_diff[i] = rows[i].range_check_dyn_diff; + polys.range_check_dyn_rng_chk_bits[i] = rows[i].range_check_dyn_rng_chk_bits; + polys.range_check_dyn_rng_chk_pow_2[i] = rows[i].range_check_dyn_rng_chk_pow_2; + polys.range_check_is_lte_u112[i] = rows[i].range_check_is_lte_u112; + polys.range_check_is_lte_u128[i] = rows[i].range_check_is_lte_u128; + polys.range_check_is_lte_u16[i] = rows[i].range_check_is_lte_u16; + polys.range_check_is_lte_u32[i] = rows[i].range_check_is_lte_u32; + polys.range_check_is_lte_u48[i] = rows[i].range_check_is_lte_u48; + polys.range_check_is_lte_u64[i] = rows[i].range_check_is_lte_u64; + polys.range_check_is_lte_u80[i] = rows[i].range_check_is_lte_u80; + polys.range_check_is_lte_u96[i] = rows[i].range_check_is_lte_u96; + polys.range_check_rng_chk_bits[i] = rows[i].range_check_rng_chk_bits; + polys.range_check_sel_lookup_0[i] = rows[i].range_check_sel_lookup_0; + polys.range_check_sel_lookup_1[i] = rows[i].range_check_sel_lookup_1; + polys.range_check_sel_lookup_2[i] = rows[i].range_check_sel_lookup_2; + polys.range_check_sel_lookup_3[i] = rows[i].range_check_sel_lookup_3; + polys.range_check_sel_lookup_4[i] = rows[i].range_check_sel_lookup_4; + polys.range_check_sel_lookup_5[i] = rows[i].range_check_sel_lookup_5; + polys.range_check_sel_lookup_6[i] = rows[i].range_check_sel_lookup_6; + polys.range_check_sel_rng_chk[i] = rows[i].range_check_sel_rng_chk; + polys.range_check_u16_r0[i] = rows[i].range_check_u16_r0; + polys.range_check_u16_r1[i] = rows[i].range_check_u16_r1; + polys.range_check_u16_r2[i] = rows[i].range_check_u16_r2; + polys.range_check_u16_r3[i] = rows[i].range_check_u16_r3; + polys.range_check_u16_r4[i] = rows[i].range_check_u16_r4; + polys.range_check_u16_r5[i] = rows[i].range_check_u16_r5; + polys.range_check_u16_r6[i] = rows[i].range_check_u16_r6; + polys.range_check_u16_r7[i] = rows[i].range_check_u16_r7; + polys.range_check_value[i] = rows[i].range_check_value; polys.sha256_clk[i] = rows[i].sha256_clk; polys.sha256_input[i] = rows[i].sha256_input; polys.sha256_output[i] = rows[i].sha256_output; @@ -627,6 +657,16 @@ AvmCircuitBuilder::ProverPolynomials AvmCircuitBuilder::compute_polynomials() co polys.slice_sel_start[i] = rows[i].slice_sel_start; polys.slice_space_id[i] = rows[i].slice_space_id; polys.slice_val[i] = rows[i].slice_val; + polys.lookup_rng_chk_pow_2_counts[i] = rows[i].lookup_rng_chk_pow_2_counts; + polys.lookup_rng_chk_diff_counts[i] = rows[i].lookup_rng_chk_diff_counts; + polys.lookup_rng_chk_0_counts[i] = rows[i].lookup_rng_chk_0_counts; + polys.lookup_rng_chk_1_counts[i] = rows[i].lookup_rng_chk_1_counts; + polys.lookup_rng_chk_2_counts[i] = rows[i].lookup_rng_chk_2_counts; + polys.lookup_rng_chk_3_counts[i] = rows[i].lookup_rng_chk_3_counts; + polys.lookup_rng_chk_4_counts[i] = rows[i].lookup_rng_chk_4_counts; + polys.lookup_rng_chk_5_counts[i] = rows[i].lookup_rng_chk_5_counts; + polys.lookup_rng_chk_6_counts[i] = rows[i].lookup_rng_chk_6_counts; + polys.lookup_rng_chk_7_counts[i] = rows[i].lookup_rng_chk_7_counts; polys.lookup_pow_2_0_counts[i] = rows[i].lookup_pow_2_0_counts; polys.lookup_pow_2_1_counts[i] = rows[i].lookup_pow_2_1_counts; polys.lookup_u8_0_counts[i] = rows[i].lookup_u8_0_counts; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp index 02c17d98dec1..347cff15dccf 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp @@ -592,206 +592,256 @@ AvmFlavor::AllConstRefValues::AllConstRefValues( , poseidon2_mem_addr_write_d(il[584]) , poseidon2_output_addr(il[585]) , poseidon2_sel_poseidon_perm(il[586]) - , sha256_clk(il[587]) - , sha256_input(il[588]) - , sha256_output(il[589]) - , sha256_sel_sha256_compression(il[590]) - , sha256_state(il[591]) - , slice_addr(il[592]) - , slice_clk(il[593]) - , slice_cnt(il[594]) - , slice_col_offset(il[595]) - , slice_one_min_inv(il[596]) - , slice_sel_cd_cpy(il[597]) - , slice_sel_mem_active(il[598]) - , slice_sel_return(il[599]) - , slice_sel_start(il[600]) - , slice_space_id(il[601]) - , slice_val(il[602]) - , lookup_pow_2_0_counts(il[603]) - , lookup_pow_2_1_counts(il[604]) - , lookup_u8_0_counts(il[605]) - , lookup_u8_1_counts(il[606]) - , lookup_u16_0_counts(il[607]) - , lookup_u16_1_counts(il[608]) - , lookup_u16_2_counts(il[609]) - , lookup_u16_3_counts(il[610]) - , lookup_u16_4_counts(il[611]) - , lookup_u16_5_counts(il[612]) - , lookup_u16_6_counts(il[613]) - , lookup_u16_7_counts(il[614]) - , lookup_u16_8_counts(il[615]) - , lookup_u16_9_counts(il[616]) - , lookup_u16_10_counts(il[617]) - , lookup_u16_11_counts(il[618]) - , lookup_u16_12_counts(il[619]) - , lookup_u16_13_counts(il[620]) - , lookup_u16_14_counts(il[621]) - , lookup_div_u16_0_counts(il[622]) - , lookup_div_u16_1_counts(il[623]) - , lookup_div_u16_2_counts(il[624]) - , lookup_div_u16_3_counts(il[625]) - , lookup_div_u16_4_counts(il[626]) - , lookup_div_u16_5_counts(il[627]) - , lookup_div_u16_6_counts(il[628]) - , lookup_div_u16_7_counts(il[629]) - , lookup_byte_lengths_counts(il[630]) - , lookup_byte_operations_counts(il[631]) - , lookup_opcode_gas_counts(il[632]) - , range_check_l2_gas_hi_counts(il[633]) - , range_check_l2_gas_lo_counts(il[634]) - , range_check_da_gas_hi_counts(il[635]) - , range_check_da_gas_lo_counts(il[636]) - , kernel_output_lookup_counts(il[637]) - , lookup_into_kernel_counts(il[638]) - , lookup_cd_value_counts(il[639]) - , lookup_ret_value_counts(il[640]) - , incl_main_tag_err_counts(il[641]) - , incl_mem_tag_err_counts(il[642]) - , lookup_mem_rng_chk_lo_counts(il[643]) - , lookup_mem_rng_chk_mid_counts(il[644]) - , lookup_mem_rng_chk_hi_counts(il[645]) - , perm_pos_mem_read_a_inv(il[646]) - , perm_pos_mem_read_b_inv(il[647]) - , perm_pos_mem_read_c_inv(il[648]) - , perm_pos_mem_read_d_inv(il[649]) - , perm_pos_mem_write_a_inv(il[650]) - , perm_pos_mem_write_b_inv(il[651]) - , perm_pos_mem_write_c_inv(il[652]) - , perm_pos_mem_write_d_inv(il[653]) - , perm_slice_mem_inv(il[654]) - , perm_main_alu_inv(il[655]) - , perm_main_bin_inv(il[656]) - , perm_main_conv_inv(il[657]) - , perm_main_pos2_perm_inv(il[658]) - , perm_main_pedersen_inv(il[659]) - , perm_main_slice_inv(il[660]) - , perm_main_mem_a_inv(il[661]) - , perm_main_mem_b_inv(il[662]) - , perm_main_mem_c_inv(il[663]) - , perm_main_mem_d_inv(il[664]) - , perm_main_mem_ind_addr_a_inv(il[665]) - , perm_main_mem_ind_addr_b_inv(il[666]) - , perm_main_mem_ind_addr_c_inv(il[667]) - , perm_main_mem_ind_addr_d_inv(il[668]) - , lookup_pow_2_0_inv(il[669]) - , lookup_pow_2_1_inv(il[670]) - , lookup_u8_0_inv(il[671]) - , lookup_u8_1_inv(il[672]) - , lookup_u16_0_inv(il[673]) - , lookup_u16_1_inv(il[674]) - , lookup_u16_2_inv(il[675]) - , lookup_u16_3_inv(il[676]) - , lookup_u16_4_inv(il[677]) - , lookup_u16_5_inv(il[678]) - , lookup_u16_6_inv(il[679]) - , lookup_u16_7_inv(il[680]) - , lookup_u16_8_inv(il[681]) - , lookup_u16_9_inv(il[682]) - , lookup_u16_10_inv(il[683]) - , lookup_u16_11_inv(il[684]) - , lookup_u16_12_inv(il[685]) - , lookup_u16_13_inv(il[686]) - , lookup_u16_14_inv(il[687]) - , lookup_div_u16_0_inv(il[688]) - , lookup_div_u16_1_inv(il[689]) - , lookup_div_u16_2_inv(il[690]) - , lookup_div_u16_3_inv(il[691]) - , lookup_div_u16_4_inv(il[692]) - , lookup_div_u16_5_inv(il[693]) - , lookup_div_u16_6_inv(il[694]) - , lookup_div_u16_7_inv(il[695]) - , lookup_byte_lengths_inv(il[696]) - , lookup_byte_operations_inv(il[697]) - , lookup_opcode_gas_inv(il[698]) - , range_check_l2_gas_hi_inv(il[699]) - , range_check_l2_gas_lo_inv(il[700]) - , range_check_da_gas_hi_inv(il[701]) - , range_check_da_gas_lo_inv(il[702]) - , kernel_output_lookup_inv(il[703]) - , lookup_into_kernel_inv(il[704]) - , lookup_cd_value_inv(il[705]) - , lookup_ret_value_inv(il[706]) - , incl_main_tag_err_inv(il[707]) - , incl_mem_tag_err_inv(il[708]) - , lookup_mem_rng_chk_lo_inv(il[709]) - , lookup_mem_rng_chk_mid_inv(il[710]) - , lookup_mem_rng_chk_hi_inv(il[711]) - , alu_a_hi_shift(il[712]) - , alu_a_lo_shift(il[713]) - , alu_b_hi_shift(il[714]) - , alu_b_lo_shift(il[715]) - , alu_cmp_rng_ctr_shift(il[716]) - , alu_div_u16_r0_shift(il[717]) - , alu_div_u16_r1_shift(il[718]) - , alu_div_u16_r2_shift(il[719]) - , alu_div_u16_r3_shift(il[720]) - , alu_div_u16_r4_shift(il[721]) - , alu_div_u16_r5_shift(il[722]) - , alu_div_u16_r6_shift(il[723]) - , alu_div_u16_r7_shift(il[724]) - , alu_op_add_shift(il[725]) - , alu_op_cast_shift(il[726]) - , alu_op_cast_prev_shift(il[727]) - , alu_op_div_shift(il[728]) - , alu_op_mul_shift(il[729]) - , alu_op_shl_shift(il[730]) - , alu_op_shr_shift(il[731]) - , alu_op_sub_shift(il[732]) - , alu_p_sub_a_hi_shift(il[733]) - , alu_p_sub_a_lo_shift(il[734]) - , alu_p_sub_b_hi_shift(il[735]) - , alu_p_sub_b_lo_shift(il[736]) - , alu_sel_alu_shift(il[737]) - , alu_sel_cmp_shift(il[738]) - , alu_sel_div_rng_chk_shift(il[739]) - , alu_sel_rng_chk_shift(il[740]) - , alu_sel_rng_chk_lookup_shift(il[741]) - , alu_u16_r0_shift(il[742]) - , alu_u16_r1_shift(il[743]) - , alu_u16_r2_shift(il[744]) - , alu_u16_r3_shift(il[745]) - , alu_u16_r4_shift(il[746]) - , alu_u16_r5_shift(il[747]) - , alu_u16_r6_shift(il[748]) - , alu_u8_r0_shift(il[749]) - , alu_u8_r1_shift(il[750]) - , binary_acc_ia_shift(il[751]) - , binary_acc_ib_shift(il[752]) - , binary_acc_ic_shift(il[753]) - , binary_mem_tag_ctr_shift(il[754]) - , binary_op_id_shift(il[755]) - , main_da_gas_remaining_shift(il[756]) - , main_emit_l2_to_l1_msg_write_offset_shift(il[757]) - , main_emit_note_hash_write_offset_shift(il[758]) - , main_emit_nullifier_write_offset_shift(il[759]) - , main_emit_unencrypted_log_write_offset_shift(il[760]) - , main_internal_return_ptr_shift(il[761]) - , main_l1_to_l2_msg_exists_write_offset_shift(il[762]) - , main_l2_gas_remaining_shift(il[763]) - , main_note_hash_exist_write_offset_shift(il[764]) - , main_nullifier_exists_write_offset_shift(il[765]) - , main_nullifier_non_exists_write_offset_shift(il[766]) - , main_pc_shift(il[767]) - , main_sel_execution_row_shift(il[768]) - , main_side_effect_counter_shift(il[769]) - , main_sload_write_offset_shift(il[770]) - , main_sstore_write_offset_shift(il[771]) - , mem_glob_addr_shift(il[772]) - , mem_rw_shift(il[773]) - , mem_sel_mem_shift(il[774]) - , mem_tag_shift(il[775]) - , mem_tsp_shift(il[776]) - , mem_val_shift(il[777]) - , slice_addr_shift(il[778]) - , slice_clk_shift(il[779]) - , slice_cnt_shift(il[780]) - , slice_col_offset_shift(il[781]) - , slice_sel_cd_cpy_shift(il[782]) - , slice_sel_mem_active_shift(il[783]) - , slice_sel_return_shift(il[784]) - , slice_sel_start_shift(il[785]) - , slice_space_id_shift(il[786]) + , range_check_clk(il[587]) + , range_check_dyn_diff(il[588]) + , range_check_dyn_rng_chk_bits(il[589]) + , range_check_dyn_rng_chk_pow_2(il[590]) + , range_check_is_lte_u112(il[591]) + , range_check_is_lte_u128(il[592]) + , range_check_is_lte_u16(il[593]) + , range_check_is_lte_u32(il[594]) + , range_check_is_lte_u48(il[595]) + , range_check_is_lte_u64(il[596]) + , range_check_is_lte_u80(il[597]) + , range_check_is_lte_u96(il[598]) + , range_check_rng_chk_bits(il[599]) + , range_check_sel_lookup_0(il[600]) + , range_check_sel_lookup_1(il[601]) + , range_check_sel_lookup_2(il[602]) + , range_check_sel_lookup_3(il[603]) + , range_check_sel_lookup_4(il[604]) + , range_check_sel_lookup_5(il[605]) + , range_check_sel_lookup_6(il[606]) + , range_check_sel_rng_chk(il[607]) + , range_check_u16_r0(il[608]) + , range_check_u16_r1(il[609]) + , range_check_u16_r2(il[610]) + , range_check_u16_r3(il[611]) + , range_check_u16_r4(il[612]) + , range_check_u16_r5(il[613]) + , range_check_u16_r6(il[614]) + , range_check_u16_r7(il[615]) + , range_check_value(il[616]) + , sha256_clk(il[617]) + , sha256_input(il[618]) + , sha256_output(il[619]) + , sha256_sel_sha256_compression(il[620]) + , sha256_state(il[621]) + , slice_addr(il[622]) + , slice_clk(il[623]) + , slice_cnt(il[624]) + , slice_col_offset(il[625]) + , slice_one_min_inv(il[626]) + , slice_sel_cd_cpy(il[627]) + , slice_sel_mem_active(il[628]) + , slice_sel_return(il[629]) + , slice_sel_start(il[630]) + , slice_space_id(il[631]) + , slice_val(il[632]) + , lookup_rng_chk_pow_2_counts(il[633]) + , lookup_rng_chk_diff_counts(il[634]) + , lookup_rng_chk_0_counts(il[635]) + , lookup_rng_chk_1_counts(il[636]) + , lookup_rng_chk_2_counts(il[637]) + , lookup_rng_chk_3_counts(il[638]) + , lookup_rng_chk_4_counts(il[639]) + , lookup_rng_chk_5_counts(il[640]) + , lookup_rng_chk_6_counts(il[641]) + , lookup_rng_chk_7_counts(il[642]) + , lookup_pow_2_0_counts(il[643]) + , lookup_pow_2_1_counts(il[644]) + , lookup_u8_0_counts(il[645]) + , lookup_u8_1_counts(il[646]) + , lookup_u16_0_counts(il[647]) + , lookup_u16_1_counts(il[648]) + , lookup_u16_2_counts(il[649]) + , lookup_u16_3_counts(il[650]) + , lookup_u16_4_counts(il[651]) + , lookup_u16_5_counts(il[652]) + , lookup_u16_6_counts(il[653]) + , lookup_u16_7_counts(il[654]) + , lookup_u16_8_counts(il[655]) + , lookup_u16_9_counts(il[656]) + , lookup_u16_10_counts(il[657]) + , lookup_u16_11_counts(il[658]) + , lookup_u16_12_counts(il[659]) + , lookup_u16_13_counts(il[660]) + , lookup_u16_14_counts(il[661]) + , lookup_div_u16_0_counts(il[662]) + , lookup_div_u16_1_counts(il[663]) + , lookup_div_u16_2_counts(il[664]) + , lookup_div_u16_3_counts(il[665]) + , lookup_div_u16_4_counts(il[666]) + , lookup_div_u16_5_counts(il[667]) + , lookup_div_u16_6_counts(il[668]) + , lookup_div_u16_7_counts(il[669]) + , lookup_byte_lengths_counts(il[670]) + , lookup_byte_operations_counts(il[671]) + , lookup_opcode_gas_counts(il[672]) + , range_check_l2_gas_hi_counts(il[673]) + , range_check_l2_gas_lo_counts(il[674]) + , range_check_da_gas_hi_counts(il[675]) + , range_check_da_gas_lo_counts(il[676]) + , kernel_output_lookup_counts(il[677]) + , lookup_into_kernel_counts(il[678]) + , lookup_cd_value_counts(il[679]) + , lookup_ret_value_counts(il[680]) + , incl_main_tag_err_counts(il[681]) + , incl_mem_tag_err_counts(il[682]) + , lookup_mem_rng_chk_lo_counts(il[683]) + , lookup_mem_rng_chk_mid_counts(il[684]) + , lookup_mem_rng_chk_hi_counts(il[685]) + , perm_pos_mem_read_a_inv(il[686]) + , perm_pos_mem_read_b_inv(il[687]) + , perm_pos_mem_read_c_inv(il[688]) + , perm_pos_mem_read_d_inv(il[689]) + , perm_pos_mem_write_a_inv(il[690]) + , perm_pos_mem_write_b_inv(il[691]) + , perm_pos_mem_write_c_inv(il[692]) + , perm_pos_mem_write_d_inv(il[693]) + , perm_slice_mem_inv(il[694]) + , perm_main_alu_inv(il[695]) + , perm_main_bin_inv(il[696]) + , perm_main_conv_inv(il[697]) + , perm_main_pos2_perm_inv(il[698]) + , perm_main_pedersen_inv(il[699]) + , perm_main_slice_inv(il[700]) + , perm_main_mem_a_inv(il[701]) + , perm_main_mem_b_inv(il[702]) + , perm_main_mem_c_inv(il[703]) + , perm_main_mem_d_inv(il[704]) + , perm_main_mem_ind_addr_a_inv(il[705]) + , perm_main_mem_ind_addr_b_inv(il[706]) + , perm_main_mem_ind_addr_c_inv(il[707]) + , perm_main_mem_ind_addr_d_inv(il[708]) + , lookup_rng_chk_pow_2_inv(il[709]) + , lookup_rng_chk_diff_inv(il[710]) + , lookup_rng_chk_0_inv(il[711]) + , lookup_rng_chk_1_inv(il[712]) + , lookup_rng_chk_2_inv(il[713]) + , lookup_rng_chk_3_inv(il[714]) + , lookup_rng_chk_4_inv(il[715]) + , lookup_rng_chk_5_inv(il[716]) + , lookup_rng_chk_6_inv(il[717]) + , lookup_rng_chk_7_inv(il[718]) + , lookup_pow_2_0_inv(il[719]) + , lookup_pow_2_1_inv(il[720]) + , lookup_u8_0_inv(il[721]) + , lookup_u8_1_inv(il[722]) + , lookup_u16_0_inv(il[723]) + , lookup_u16_1_inv(il[724]) + , lookup_u16_2_inv(il[725]) + , lookup_u16_3_inv(il[726]) + , lookup_u16_4_inv(il[727]) + , lookup_u16_5_inv(il[728]) + , lookup_u16_6_inv(il[729]) + , lookup_u16_7_inv(il[730]) + , lookup_u16_8_inv(il[731]) + , lookup_u16_9_inv(il[732]) + , lookup_u16_10_inv(il[733]) + , lookup_u16_11_inv(il[734]) + , lookup_u16_12_inv(il[735]) + , lookup_u16_13_inv(il[736]) + , lookup_u16_14_inv(il[737]) + , lookup_div_u16_0_inv(il[738]) + , lookup_div_u16_1_inv(il[739]) + , lookup_div_u16_2_inv(il[740]) + , lookup_div_u16_3_inv(il[741]) + , lookup_div_u16_4_inv(il[742]) + , lookup_div_u16_5_inv(il[743]) + , lookup_div_u16_6_inv(il[744]) + , lookup_div_u16_7_inv(il[745]) + , lookup_byte_lengths_inv(il[746]) + , lookup_byte_operations_inv(il[747]) + , lookup_opcode_gas_inv(il[748]) + , range_check_l2_gas_hi_inv(il[749]) + , range_check_l2_gas_lo_inv(il[750]) + , range_check_da_gas_hi_inv(il[751]) + , range_check_da_gas_lo_inv(il[752]) + , kernel_output_lookup_inv(il[753]) + , lookup_into_kernel_inv(il[754]) + , lookup_cd_value_inv(il[755]) + , lookup_ret_value_inv(il[756]) + , incl_main_tag_err_inv(il[757]) + , incl_mem_tag_err_inv(il[758]) + , lookup_mem_rng_chk_lo_inv(il[759]) + , lookup_mem_rng_chk_mid_inv(il[760]) + , lookup_mem_rng_chk_hi_inv(il[761]) + , alu_a_hi_shift(il[762]) + , alu_a_lo_shift(il[763]) + , alu_b_hi_shift(il[764]) + , alu_b_lo_shift(il[765]) + , alu_cmp_rng_ctr_shift(il[766]) + , alu_div_u16_r0_shift(il[767]) + , alu_div_u16_r1_shift(il[768]) + , alu_div_u16_r2_shift(il[769]) + , alu_div_u16_r3_shift(il[770]) + , alu_div_u16_r4_shift(il[771]) + , alu_div_u16_r5_shift(il[772]) + , alu_div_u16_r6_shift(il[773]) + , alu_div_u16_r7_shift(il[774]) + , alu_op_add_shift(il[775]) + , alu_op_cast_shift(il[776]) + , alu_op_cast_prev_shift(il[777]) + , alu_op_div_shift(il[778]) + , alu_op_mul_shift(il[779]) + , alu_op_shl_shift(il[780]) + , alu_op_shr_shift(il[781]) + , alu_op_sub_shift(il[782]) + , alu_p_sub_a_hi_shift(il[783]) + , alu_p_sub_a_lo_shift(il[784]) + , alu_p_sub_b_hi_shift(il[785]) + , alu_p_sub_b_lo_shift(il[786]) + , alu_sel_alu_shift(il[787]) + , alu_sel_cmp_shift(il[788]) + , alu_sel_div_rng_chk_shift(il[789]) + , alu_sel_rng_chk_shift(il[790]) + , alu_sel_rng_chk_lookup_shift(il[791]) + , alu_u16_r0_shift(il[792]) + , alu_u16_r1_shift(il[793]) + , alu_u16_r2_shift(il[794]) + , alu_u16_r3_shift(il[795]) + , alu_u16_r4_shift(il[796]) + , alu_u16_r5_shift(il[797]) + , alu_u16_r6_shift(il[798]) + , alu_u8_r0_shift(il[799]) + , alu_u8_r1_shift(il[800]) + , binary_acc_ia_shift(il[801]) + , binary_acc_ib_shift(il[802]) + , binary_acc_ic_shift(il[803]) + , binary_mem_tag_ctr_shift(il[804]) + , binary_op_id_shift(il[805]) + , main_da_gas_remaining_shift(il[806]) + , main_emit_l2_to_l1_msg_write_offset_shift(il[807]) + , main_emit_note_hash_write_offset_shift(il[808]) + , main_emit_nullifier_write_offset_shift(il[809]) + , main_emit_unencrypted_log_write_offset_shift(il[810]) + , main_internal_return_ptr_shift(il[811]) + , main_l1_to_l2_msg_exists_write_offset_shift(il[812]) + , main_l2_gas_remaining_shift(il[813]) + , main_note_hash_exist_write_offset_shift(il[814]) + , main_nullifier_exists_write_offset_shift(il[815]) + , main_nullifier_non_exists_write_offset_shift(il[816]) + , main_pc_shift(il[817]) + , main_sel_execution_row_shift(il[818]) + , main_side_effect_counter_shift(il[819]) + , main_sload_write_offset_shift(il[820]) + , main_sstore_write_offset_shift(il[821]) + , mem_glob_addr_shift(il[822]) + , mem_rw_shift(il[823]) + , mem_sel_mem_shift(il[824]) + , mem_tag_shift(il[825]) + , mem_tsp_shift(il[826]) + , mem_val_shift(il[827]) + , slice_addr_shift(il[828]) + , slice_clk_shift(il[829]) + , slice_cnt_shift(il[830]) + , slice_col_offset_shift(il[831]) + , slice_sel_cd_cpy_shift(il[832]) + , slice_sel_mem_active_shift(il[833]) + , slice_sel_return_shift(il[834]) + , slice_sel_start_shift(il[835]) + , slice_space_id_shift(il[836]) {} AvmFlavor::ProverPolynomials::ProverPolynomials(ProvingKey& proving_key) @@ -1395,6 +1445,36 @@ AvmFlavor::AllConstRefValues AvmFlavor::ProverPolynomials::get_row(size_t row_id poseidon2_mem_addr_write_d[row_idx], poseidon2_output_addr[row_idx], poseidon2_sel_poseidon_perm[row_idx], + range_check_clk[row_idx], + range_check_dyn_diff[row_idx], + range_check_dyn_rng_chk_bits[row_idx], + range_check_dyn_rng_chk_pow_2[row_idx], + range_check_is_lte_u112[row_idx], + range_check_is_lte_u128[row_idx], + range_check_is_lte_u16[row_idx], + range_check_is_lte_u32[row_idx], + range_check_is_lte_u48[row_idx], + range_check_is_lte_u64[row_idx], + range_check_is_lte_u80[row_idx], + range_check_is_lte_u96[row_idx], + range_check_rng_chk_bits[row_idx], + range_check_sel_lookup_0[row_idx], + range_check_sel_lookup_1[row_idx], + range_check_sel_lookup_2[row_idx], + range_check_sel_lookup_3[row_idx], + range_check_sel_lookup_4[row_idx], + range_check_sel_lookup_5[row_idx], + range_check_sel_lookup_6[row_idx], + range_check_sel_rng_chk[row_idx], + range_check_u16_r0[row_idx], + range_check_u16_r1[row_idx], + range_check_u16_r2[row_idx], + range_check_u16_r3[row_idx], + range_check_u16_r4[row_idx], + range_check_u16_r5[row_idx], + range_check_u16_r6[row_idx], + range_check_u16_r7[row_idx], + range_check_value[row_idx], sha256_clk[row_idx], sha256_input[row_idx], sha256_output[row_idx], @@ -1411,6 +1491,16 @@ AvmFlavor::AllConstRefValues AvmFlavor::ProverPolynomials::get_row(size_t row_id slice_sel_start[row_idx], slice_space_id[row_idx], slice_val[row_idx], + lookup_rng_chk_pow_2_counts[row_idx], + lookup_rng_chk_diff_counts[row_idx], + lookup_rng_chk_0_counts[row_idx], + lookup_rng_chk_1_counts[row_idx], + lookup_rng_chk_2_counts[row_idx], + lookup_rng_chk_3_counts[row_idx], + lookup_rng_chk_4_counts[row_idx], + lookup_rng_chk_5_counts[row_idx], + lookup_rng_chk_6_counts[row_idx], + lookup_rng_chk_7_counts[row_idx], lookup_pow_2_0_counts[row_idx], lookup_pow_2_1_counts[row_idx], lookup_u8_0_counts[row_idx], @@ -1477,6 +1567,16 @@ AvmFlavor::AllConstRefValues AvmFlavor::ProverPolynomials::get_row(size_t row_id perm_main_mem_ind_addr_b_inv[row_idx], perm_main_mem_ind_addr_c_inv[row_idx], perm_main_mem_ind_addr_d_inv[row_idx], + lookup_rng_chk_pow_2_inv[row_idx], + lookup_rng_chk_diff_inv[row_idx], + lookup_rng_chk_0_inv[row_idx], + lookup_rng_chk_1_inv[row_idx], + lookup_rng_chk_2_inv[row_idx], + lookup_rng_chk_3_inv[row_idx], + lookup_rng_chk_4_inv[row_idx], + lookup_rng_chk_5_inv[row_idx], + lookup_rng_chk_6_inv[row_idx], + lookup_rng_chk_7_inv[row_idx], lookup_pow_2_0_inv[row_idx], lookup_pow_2_1_inv[row_idx], lookup_u8_0_inv[row_idx], @@ -2186,6 +2286,36 @@ AvmFlavor::CommitmentLabels::CommitmentLabels() Base::poseidon2_mem_addr_write_d = "POSEIDON2_MEM_ADDR_WRITE_D"; Base::poseidon2_output_addr = "POSEIDON2_OUTPUT_ADDR"; Base::poseidon2_sel_poseidon_perm = "POSEIDON2_SEL_POSEIDON_PERM"; + Base::range_check_clk = "RANGE_CHECK_CLK"; + Base::range_check_dyn_diff = "RANGE_CHECK_DYN_DIFF"; + Base::range_check_dyn_rng_chk_bits = "RANGE_CHECK_DYN_RNG_CHK_BITS"; + Base::range_check_dyn_rng_chk_pow_2 = "RANGE_CHECK_DYN_RNG_CHK_POW_2"; + Base::range_check_is_lte_u112 = "RANGE_CHECK_IS_LTE_U112"; + Base::range_check_is_lte_u128 = "RANGE_CHECK_IS_LTE_U128"; + Base::range_check_is_lte_u16 = "RANGE_CHECK_IS_LTE_U16"; + Base::range_check_is_lte_u32 = "RANGE_CHECK_IS_LTE_U32"; + Base::range_check_is_lte_u48 = "RANGE_CHECK_IS_LTE_U48"; + Base::range_check_is_lte_u64 = "RANGE_CHECK_IS_LTE_U64"; + Base::range_check_is_lte_u80 = "RANGE_CHECK_IS_LTE_U80"; + Base::range_check_is_lte_u96 = "RANGE_CHECK_IS_LTE_U96"; + Base::range_check_rng_chk_bits = "RANGE_CHECK_RNG_CHK_BITS"; + Base::range_check_sel_lookup_0 = "RANGE_CHECK_SEL_LOOKUP_0"; + Base::range_check_sel_lookup_1 = "RANGE_CHECK_SEL_LOOKUP_1"; + Base::range_check_sel_lookup_2 = "RANGE_CHECK_SEL_LOOKUP_2"; + Base::range_check_sel_lookup_3 = "RANGE_CHECK_SEL_LOOKUP_3"; + Base::range_check_sel_lookup_4 = "RANGE_CHECK_SEL_LOOKUP_4"; + Base::range_check_sel_lookup_5 = "RANGE_CHECK_SEL_LOOKUP_5"; + Base::range_check_sel_lookup_6 = "RANGE_CHECK_SEL_LOOKUP_6"; + Base::range_check_sel_rng_chk = "RANGE_CHECK_SEL_RNG_CHK"; + Base::range_check_u16_r0 = "RANGE_CHECK_U16_R0"; + Base::range_check_u16_r1 = "RANGE_CHECK_U16_R1"; + Base::range_check_u16_r2 = "RANGE_CHECK_U16_R2"; + Base::range_check_u16_r3 = "RANGE_CHECK_U16_R3"; + Base::range_check_u16_r4 = "RANGE_CHECK_U16_R4"; + Base::range_check_u16_r5 = "RANGE_CHECK_U16_R5"; + Base::range_check_u16_r6 = "RANGE_CHECK_U16_R6"; + Base::range_check_u16_r7 = "RANGE_CHECK_U16_R7"; + Base::range_check_value = "RANGE_CHECK_VALUE"; Base::sha256_clk = "SHA256_CLK"; Base::sha256_input = "SHA256_INPUT"; Base::sha256_output = "SHA256_OUTPUT"; @@ -2225,6 +2355,16 @@ AvmFlavor::CommitmentLabels::CommitmentLabels() Base::perm_main_mem_ind_addr_b_inv = "PERM_MAIN_MEM_IND_ADDR_B_INV"; Base::perm_main_mem_ind_addr_c_inv = "PERM_MAIN_MEM_IND_ADDR_C_INV"; Base::perm_main_mem_ind_addr_d_inv = "PERM_MAIN_MEM_IND_ADDR_D_INV"; + Base::lookup_rng_chk_pow_2_inv = "LOOKUP_RNG_CHK_POW_2_INV"; + Base::lookup_rng_chk_diff_inv = "LOOKUP_RNG_CHK_DIFF_INV"; + Base::lookup_rng_chk_0_inv = "LOOKUP_RNG_CHK_0_INV"; + Base::lookup_rng_chk_1_inv = "LOOKUP_RNG_CHK_1_INV"; + Base::lookup_rng_chk_2_inv = "LOOKUP_RNG_CHK_2_INV"; + Base::lookup_rng_chk_3_inv = "LOOKUP_RNG_CHK_3_INV"; + Base::lookup_rng_chk_4_inv = "LOOKUP_RNG_CHK_4_INV"; + Base::lookup_rng_chk_5_inv = "LOOKUP_RNG_CHK_5_INV"; + Base::lookup_rng_chk_6_inv = "LOOKUP_RNG_CHK_6_INV"; + Base::lookup_rng_chk_7_inv = "LOOKUP_RNG_CHK_7_INV"; Base::lookup_pow_2_0_inv = "LOOKUP_POW_2_0_INV"; Base::lookup_pow_2_1_inv = "LOOKUP_POW_2_1_INV"; Base::lookup_u8_0_inv = "LOOKUP_U8_0_INV"; @@ -2268,6 +2408,16 @@ AvmFlavor::CommitmentLabels::CommitmentLabels() Base::lookup_mem_rng_chk_lo_inv = "LOOKUP_MEM_RNG_CHK_LO_INV"; Base::lookup_mem_rng_chk_mid_inv = "LOOKUP_MEM_RNG_CHK_MID_INV"; Base::lookup_mem_rng_chk_hi_inv = "LOOKUP_MEM_RNG_CHK_HI_INV"; + Base::lookup_rng_chk_pow_2_counts = "LOOKUP_RNG_CHK_POW_2_COUNTS"; + Base::lookup_rng_chk_diff_counts = "LOOKUP_RNG_CHK_DIFF_COUNTS"; + Base::lookup_rng_chk_0_counts = "LOOKUP_RNG_CHK_0_COUNTS"; + Base::lookup_rng_chk_1_counts = "LOOKUP_RNG_CHK_1_COUNTS"; + Base::lookup_rng_chk_2_counts = "LOOKUP_RNG_CHK_2_COUNTS"; + Base::lookup_rng_chk_3_counts = "LOOKUP_RNG_CHK_3_COUNTS"; + Base::lookup_rng_chk_4_counts = "LOOKUP_RNG_CHK_4_COUNTS"; + Base::lookup_rng_chk_5_counts = "LOOKUP_RNG_CHK_5_COUNTS"; + Base::lookup_rng_chk_6_counts = "LOOKUP_RNG_CHK_6_COUNTS"; + Base::lookup_rng_chk_7_counts = "LOOKUP_RNG_CHK_7_COUNTS"; Base::lookup_pow_2_0_counts = "LOOKUP_POW_2_0_COUNTS"; Base::lookup_pow_2_1_counts = "LOOKUP_POW_2_1_COUNTS"; Base::lookup_u8_0_counts = "LOOKUP_U8_0_COUNTS"; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp index da57edf4b8d4..ec2021f1fc6e 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp @@ -26,6 +26,7 @@ #include "barretenberg/vm/avm/generated/relations/mem_slice.hpp" #include "barretenberg/vm/avm/generated/relations/pedersen.hpp" #include "barretenberg/vm/avm/generated/relations/poseidon2.hpp" +#include "barretenberg/vm/avm/generated/relations/range_check.hpp" #include "barretenberg/vm/avm/generated/relations/sha256.hpp" // Lookup and permutation relations @@ -51,6 +52,16 @@ #include "barretenberg/vm/avm/generated/relations/lookup_pow_2_0.hpp" #include "barretenberg/vm/avm/generated/relations/lookup_pow_2_1.hpp" #include "barretenberg/vm/avm/generated/relations/lookup_ret_value.hpp" +#include "barretenberg/vm/avm/generated/relations/lookup_rng_chk_0.hpp" +#include "barretenberg/vm/avm/generated/relations/lookup_rng_chk_1.hpp" +#include "barretenberg/vm/avm/generated/relations/lookup_rng_chk_2.hpp" +#include "barretenberg/vm/avm/generated/relations/lookup_rng_chk_3.hpp" +#include "barretenberg/vm/avm/generated/relations/lookup_rng_chk_4.hpp" +#include "barretenberg/vm/avm/generated/relations/lookup_rng_chk_5.hpp" +#include "barretenberg/vm/avm/generated/relations/lookup_rng_chk_6.hpp" +#include "barretenberg/vm/avm/generated/relations/lookup_rng_chk_7.hpp" +#include "barretenberg/vm/avm/generated/relations/lookup_rng_chk_diff.hpp" +#include "barretenberg/vm/avm/generated/relations/lookup_rng_chk_pow_2.hpp" #include "barretenberg/vm/avm/generated/relations/lookup_u16_0.hpp" #include "barretenberg/vm/avm/generated/relations/lookup_u16_1.hpp" #include "barretenberg/vm/avm/generated/relations/lookup_u16_10.hpp" @@ -102,8 +113,8 @@ template using tuple_cat_t = decltype(std::tuple_cat(std:: // The entities that will be used in the flavor. // clang-format off #define PRECOMPUTED_ENTITIES byte_lookup_sel_bin, byte_lookup_table_byte_lengths, byte_lookup_table_in_tags, byte_lookup_table_input_a, byte_lookup_table_input_b, byte_lookup_table_op_id, byte_lookup_table_output, gas_base_da_gas_fixed_table, gas_base_l2_gas_fixed_table, gas_dyn_da_gas_fixed_table, gas_dyn_l2_gas_fixed_table, gas_sel_gas_cost, main_clk, main_sel_first, main_zeroes, powers_power_of_2 -#define WIRE_ENTITIES main_kernel_inputs, main_kernel_value_out, main_kernel_side_effect_out, main_kernel_metadata_out, main_calldata, main_returndata, alu_a_hi, alu_a_lo, alu_b_hi, alu_b_lo, alu_borrow, alu_cf, alu_clk, alu_cmp_rng_ctr, alu_div_u16_r0, alu_div_u16_r1, alu_div_u16_r2, alu_div_u16_r3, alu_div_u16_r4, alu_div_u16_r5, alu_div_u16_r6, alu_div_u16_r7, alu_divisor_hi, alu_divisor_lo, alu_ff_tag, alu_ia, alu_ib, alu_ic, alu_in_tag, alu_op_add, alu_op_cast, alu_op_cast_prev, alu_op_div, alu_op_div_a_lt_b, alu_op_div_std, alu_op_eq, alu_op_eq_diff_inv, alu_op_lt, alu_op_lte, alu_op_mul, alu_op_not, alu_op_shl, alu_op_shr, alu_op_sub, alu_p_a_borrow, alu_p_b_borrow, alu_p_sub_a_hi, alu_p_sub_a_lo, alu_p_sub_b_hi, alu_p_sub_b_lo, alu_partial_prod_hi, alu_partial_prod_lo, alu_quotient_hi, alu_quotient_lo, alu_remainder, alu_res_hi, alu_res_lo, alu_sel_alu, alu_sel_cmp, alu_sel_div_rng_chk, alu_sel_rng_chk, alu_sel_rng_chk_lookup, alu_sel_shift_which, alu_shift_lt_bit_len, alu_t_sub_s_bits, alu_two_pow_s, alu_two_pow_t_sub_s, alu_u128_tag, alu_u16_r0, alu_u16_r1, alu_u16_r10, alu_u16_r11, alu_u16_r12, alu_u16_r13, alu_u16_r14, alu_u16_r2, alu_u16_r3, alu_u16_r4, alu_u16_r5, alu_u16_r6, alu_u16_r7, alu_u16_r8, alu_u16_r9, alu_u16_tag, alu_u32_tag, alu_u64_tag, alu_u8_r0, alu_u8_r1, alu_u8_tag, binary_acc_ia, binary_acc_ib, binary_acc_ic, binary_clk, binary_ia_bytes, binary_ib_bytes, binary_ic_bytes, binary_in_tag, binary_mem_tag_ctr, binary_mem_tag_ctr_inv, binary_op_id, binary_sel_bin, binary_start, conversion_clk, conversion_input, conversion_num_limbs, conversion_radix, conversion_sel_to_radix_le, keccakf1600_clk, keccakf1600_input, keccakf1600_output, keccakf1600_sel_keccakf1600, main_abs_da_rem_gas_hi, main_abs_da_rem_gas_lo, main_abs_l2_rem_gas_hi, main_abs_l2_rem_gas_lo, main_alu_in_tag, main_base_da_gas_op_cost, main_base_l2_gas_op_cost, main_bin_op_id, main_call_ptr, main_da_gas_remaining, main_da_out_of_gas, main_dyn_da_gas_op_cost, main_dyn_gas_multiplier, main_dyn_l2_gas_op_cost, main_emit_l2_to_l1_msg_write_offset, main_emit_note_hash_write_offset, main_emit_nullifier_write_offset, main_emit_unencrypted_log_write_offset, main_ia, main_ib, main_ic, main_id, main_id_zero, main_ind_addr_a, main_ind_addr_b, main_ind_addr_c, main_ind_addr_d, main_internal_return_ptr, main_inv, main_kernel_in_offset, main_kernel_out_offset, main_l1_to_l2_msg_exists_write_offset, main_l2_gas_remaining, main_l2_out_of_gas, main_mem_addr_a, main_mem_addr_b, main_mem_addr_c, main_mem_addr_d, main_note_hash_exist_write_offset, main_nullifier_exists_write_offset, main_nullifier_non_exists_write_offset, main_op_err, main_opcode_val, main_pc, main_r_in_tag, main_rwa, main_rwb, main_rwc, main_rwd, main_sel_alu, main_sel_bin, main_sel_calldata, main_sel_execution_row, main_sel_kernel_inputs, main_sel_kernel_out, main_sel_last, main_sel_mem_op_a, main_sel_mem_op_b, main_sel_mem_op_c, main_sel_mem_op_d, main_sel_mov_ia_to_ic, main_sel_mov_ib_to_ic, main_sel_op_add, main_sel_op_address, main_sel_op_and, main_sel_op_block_number, main_sel_op_calldata_copy, main_sel_op_cast, main_sel_op_chain_id, main_sel_op_cmov, main_sel_op_coinbase, main_sel_op_dagasleft, main_sel_op_div, main_sel_op_ecadd, main_sel_op_emit_l2_to_l1_msg, main_sel_op_emit_note_hash, main_sel_op_emit_nullifier, main_sel_op_emit_unencrypted_log, main_sel_op_eq, main_sel_op_external_call, main_sel_op_external_return, main_sel_op_external_revert, main_sel_op_fdiv, main_sel_op_fee_per_da_gas, main_sel_op_fee_per_l2_gas, main_sel_op_function_selector, main_sel_op_get_contract_instance, main_sel_op_internal_call, main_sel_op_internal_return, main_sel_op_jump, main_sel_op_jumpi, main_sel_op_keccak, main_sel_op_l1_to_l2_msg_exists, main_sel_op_l2gasleft, main_sel_op_lt, main_sel_op_lte, main_sel_op_mov, main_sel_op_msm, main_sel_op_mul, main_sel_op_not, main_sel_op_note_hash_exists, main_sel_op_nullifier_exists, main_sel_op_or, main_sel_op_pedersen, main_sel_op_pedersen_commit, main_sel_op_poseidon2, main_sel_op_radix_le, main_sel_op_sender, main_sel_op_set, main_sel_op_sha256, main_sel_op_shl, main_sel_op_shr, main_sel_op_sload, main_sel_op_sstore, main_sel_op_storage_address, main_sel_op_sub, main_sel_op_timestamp, main_sel_op_transaction_fee, main_sel_op_version, main_sel_op_xor, main_sel_q_kernel_lookup, main_sel_q_kernel_output_lookup, main_sel_resolve_ind_addr_a, main_sel_resolve_ind_addr_b, main_sel_resolve_ind_addr_c, main_sel_resolve_ind_addr_d, main_sel_returndata, main_sel_rng_16, main_sel_rng_8, main_sel_slice_gadget, main_side_effect_counter, main_sload_write_offset, main_space_id, main_sstore_write_offset, main_tag_err, main_w_in_tag, mem_addr, mem_clk, mem_diff_hi, mem_diff_lo, mem_diff_mid, mem_glob_addr, mem_last, mem_lastAccess, mem_one_min_inv, mem_r_in_tag, mem_rw, mem_sel_mem, mem_sel_mov_ia_to_ic, mem_sel_mov_ib_to_ic, mem_sel_op_a, mem_sel_op_b, mem_sel_op_c, mem_sel_op_cmov, mem_sel_op_d, mem_sel_op_poseidon_read_a, mem_sel_op_poseidon_read_b, mem_sel_op_poseidon_read_c, mem_sel_op_poseidon_read_d, mem_sel_op_poseidon_write_a, mem_sel_op_poseidon_write_b, mem_sel_op_poseidon_write_c, mem_sel_op_poseidon_write_d, mem_sel_op_slice, mem_sel_resolve_ind_addr_a, mem_sel_resolve_ind_addr_b, mem_sel_resolve_ind_addr_c, mem_sel_resolve_ind_addr_d, mem_sel_rng_chk, mem_skip_check_tag, mem_space_id, mem_tag, mem_tag_err, mem_tsp, mem_val, mem_w_in_tag, pedersen_clk, pedersen_input, pedersen_output, pedersen_sel_pedersen, poseidon2_B_10_0, poseidon2_B_10_1, poseidon2_B_10_2, poseidon2_B_10_3, poseidon2_B_11_0, poseidon2_B_11_1, poseidon2_B_11_2, poseidon2_B_11_3, poseidon2_B_12_0, poseidon2_B_12_1, poseidon2_B_12_2, poseidon2_B_12_3, poseidon2_B_13_0, poseidon2_B_13_1, poseidon2_B_13_2, poseidon2_B_13_3, poseidon2_B_14_0, poseidon2_B_14_1, poseidon2_B_14_2, poseidon2_B_14_3, poseidon2_B_15_0, poseidon2_B_15_1, poseidon2_B_15_2, poseidon2_B_15_3, poseidon2_B_16_0, poseidon2_B_16_1, poseidon2_B_16_2, poseidon2_B_16_3, poseidon2_B_17_0, poseidon2_B_17_1, poseidon2_B_17_2, poseidon2_B_17_3, poseidon2_B_18_0, poseidon2_B_18_1, poseidon2_B_18_2, poseidon2_B_18_3, poseidon2_B_19_0, poseidon2_B_19_1, poseidon2_B_19_2, poseidon2_B_19_3, poseidon2_B_20_0, poseidon2_B_20_1, poseidon2_B_20_2, poseidon2_B_20_3, poseidon2_B_21_0, poseidon2_B_21_1, poseidon2_B_21_2, poseidon2_B_21_3, poseidon2_B_22_0, poseidon2_B_22_1, poseidon2_B_22_2, poseidon2_B_22_3, poseidon2_B_23_0, poseidon2_B_23_1, poseidon2_B_23_2, poseidon2_B_23_3, poseidon2_B_24_0, poseidon2_B_24_1, poseidon2_B_24_2, poseidon2_B_24_3, poseidon2_B_25_0, poseidon2_B_25_1, poseidon2_B_25_2, poseidon2_B_25_3, poseidon2_B_26_0, poseidon2_B_26_1, poseidon2_B_26_2, poseidon2_B_26_3, poseidon2_B_27_0, poseidon2_B_27_1, poseidon2_B_27_2, poseidon2_B_27_3, poseidon2_B_28_0, poseidon2_B_28_1, poseidon2_B_28_2, poseidon2_B_28_3, poseidon2_B_29_0, poseidon2_B_29_1, poseidon2_B_29_2, poseidon2_B_29_3, poseidon2_B_30_0, poseidon2_B_30_1, poseidon2_B_30_2, poseidon2_B_30_3, poseidon2_B_31_0, poseidon2_B_31_1, poseidon2_B_31_2, poseidon2_B_31_3, poseidon2_B_32_0, poseidon2_B_32_1, poseidon2_B_32_2, poseidon2_B_32_3, poseidon2_B_33_0, poseidon2_B_33_1, poseidon2_B_33_2, poseidon2_B_33_3, poseidon2_B_34_0, poseidon2_B_34_1, poseidon2_B_34_2, poseidon2_B_34_3, poseidon2_B_35_0, poseidon2_B_35_1, poseidon2_B_35_2, poseidon2_B_35_3, poseidon2_B_36_0, poseidon2_B_36_1, poseidon2_B_36_2, poseidon2_B_36_3, poseidon2_B_37_0, poseidon2_B_37_1, poseidon2_B_37_2, poseidon2_B_37_3, poseidon2_B_38_0, poseidon2_B_38_1, poseidon2_B_38_2, poseidon2_B_38_3, poseidon2_B_39_0, poseidon2_B_39_1, poseidon2_B_39_2, poseidon2_B_39_3, poseidon2_B_40_0, poseidon2_B_40_1, poseidon2_B_40_2, poseidon2_B_40_3, poseidon2_B_41_0, poseidon2_B_41_1, poseidon2_B_41_2, poseidon2_B_41_3, poseidon2_B_42_0, poseidon2_B_42_1, poseidon2_B_42_2, poseidon2_B_42_3, poseidon2_B_43_0, poseidon2_B_43_1, poseidon2_B_43_2, poseidon2_B_43_3, poseidon2_B_44_0, poseidon2_B_44_1, poseidon2_B_44_2, poseidon2_B_44_3, poseidon2_B_45_0, poseidon2_B_45_1, poseidon2_B_45_2, poseidon2_B_45_3, poseidon2_B_46_0, poseidon2_B_46_1, poseidon2_B_46_2, poseidon2_B_46_3, poseidon2_B_47_0, poseidon2_B_47_1, poseidon2_B_47_2, poseidon2_B_47_3, poseidon2_B_48_0, poseidon2_B_48_1, poseidon2_B_48_2, poseidon2_B_48_3, poseidon2_B_49_0, poseidon2_B_49_1, poseidon2_B_49_2, poseidon2_B_49_3, poseidon2_B_4_0, poseidon2_B_4_1, poseidon2_B_4_2, poseidon2_B_4_3, poseidon2_B_50_0, poseidon2_B_50_1, poseidon2_B_50_2, poseidon2_B_50_3, poseidon2_B_51_0, poseidon2_B_51_1, poseidon2_B_51_2, poseidon2_B_51_3, poseidon2_B_52_0, poseidon2_B_52_1, poseidon2_B_52_2, poseidon2_B_52_3, poseidon2_B_53_0, poseidon2_B_53_1, poseidon2_B_53_2, poseidon2_B_53_3, poseidon2_B_54_0, poseidon2_B_54_1, poseidon2_B_54_2, poseidon2_B_54_3, poseidon2_B_55_0, poseidon2_B_55_1, poseidon2_B_55_2, poseidon2_B_55_3, poseidon2_B_56_0, poseidon2_B_56_1, poseidon2_B_56_2, poseidon2_B_56_3, poseidon2_B_57_0, poseidon2_B_57_1, poseidon2_B_57_2, poseidon2_B_57_3, poseidon2_B_58_0, poseidon2_B_58_1, poseidon2_B_58_2, poseidon2_B_58_3, poseidon2_B_59_0, poseidon2_B_59_1, poseidon2_B_59_2, poseidon2_B_59_3, poseidon2_B_5_0, poseidon2_B_5_1, poseidon2_B_5_2, poseidon2_B_5_3, poseidon2_B_6_0, poseidon2_B_6_1, poseidon2_B_6_2, poseidon2_B_6_3, poseidon2_B_7_0, poseidon2_B_7_1, poseidon2_B_7_2, poseidon2_B_7_3, poseidon2_B_8_0, poseidon2_B_8_1, poseidon2_B_8_2, poseidon2_B_8_3, poseidon2_B_9_0, poseidon2_B_9_1, poseidon2_B_9_2, poseidon2_B_9_3, poseidon2_EXT_LAYER_4, poseidon2_EXT_LAYER_5, poseidon2_EXT_LAYER_6, poseidon2_EXT_LAYER_7, poseidon2_T_0_4, poseidon2_T_0_5, poseidon2_T_0_6, poseidon2_T_0_7, poseidon2_T_1_4, poseidon2_T_1_5, poseidon2_T_1_6, poseidon2_T_1_7, poseidon2_T_2_4, poseidon2_T_2_5, poseidon2_T_2_6, poseidon2_T_2_7, poseidon2_T_3_4, poseidon2_T_3_5, poseidon2_T_3_6, poseidon2_T_3_7, poseidon2_T_60_4, poseidon2_T_60_5, poseidon2_T_60_6, poseidon2_T_60_7, poseidon2_T_61_4, poseidon2_T_61_5, poseidon2_T_61_6, poseidon2_T_61_7, poseidon2_T_62_4, poseidon2_T_62_5, poseidon2_T_62_6, poseidon2_T_62_7, poseidon2_T_63_4, poseidon2_T_63_5, poseidon2_T_63_6, poseidon2_T_63_7, poseidon2_a_0, poseidon2_a_1, poseidon2_a_2, poseidon2_a_3, poseidon2_b_0, poseidon2_b_1, poseidon2_b_2, poseidon2_b_3, poseidon2_clk, poseidon2_input_addr, poseidon2_mem_addr_read_a, poseidon2_mem_addr_read_b, poseidon2_mem_addr_read_c, poseidon2_mem_addr_read_d, poseidon2_mem_addr_write_a, poseidon2_mem_addr_write_b, poseidon2_mem_addr_write_c, poseidon2_mem_addr_write_d, poseidon2_output_addr, poseidon2_sel_poseidon_perm, sha256_clk, sha256_input, sha256_output, sha256_sel_sha256_compression, sha256_state, slice_addr, slice_clk, slice_cnt, slice_col_offset, slice_one_min_inv, slice_sel_cd_cpy, slice_sel_mem_active, slice_sel_return, slice_sel_start, slice_space_id, slice_val, lookup_pow_2_0_counts, lookup_pow_2_1_counts, lookup_u8_0_counts, lookup_u8_1_counts, lookup_u16_0_counts, lookup_u16_1_counts, lookup_u16_2_counts, lookup_u16_3_counts, lookup_u16_4_counts, lookup_u16_5_counts, lookup_u16_6_counts, lookup_u16_7_counts, lookup_u16_8_counts, lookup_u16_9_counts, lookup_u16_10_counts, lookup_u16_11_counts, lookup_u16_12_counts, lookup_u16_13_counts, lookup_u16_14_counts, lookup_div_u16_0_counts, lookup_div_u16_1_counts, lookup_div_u16_2_counts, lookup_div_u16_3_counts, lookup_div_u16_4_counts, lookup_div_u16_5_counts, lookup_div_u16_6_counts, lookup_div_u16_7_counts, lookup_byte_lengths_counts, lookup_byte_operations_counts, lookup_opcode_gas_counts, range_check_l2_gas_hi_counts, range_check_l2_gas_lo_counts, range_check_da_gas_hi_counts, range_check_da_gas_lo_counts, kernel_output_lookup_counts, lookup_into_kernel_counts, lookup_cd_value_counts, lookup_ret_value_counts, incl_main_tag_err_counts, incl_mem_tag_err_counts, lookup_mem_rng_chk_lo_counts, lookup_mem_rng_chk_mid_counts, lookup_mem_rng_chk_hi_counts -#define DERIVED_WITNESS_ENTITIES perm_pos_mem_read_a_inv, perm_pos_mem_read_b_inv, perm_pos_mem_read_c_inv, perm_pos_mem_read_d_inv, perm_pos_mem_write_a_inv, perm_pos_mem_write_b_inv, perm_pos_mem_write_c_inv, perm_pos_mem_write_d_inv, perm_slice_mem_inv, perm_main_alu_inv, perm_main_bin_inv, perm_main_conv_inv, perm_main_pos2_perm_inv, perm_main_pedersen_inv, perm_main_slice_inv, perm_main_mem_a_inv, perm_main_mem_b_inv, perm_main_mem_c_inv, perm_main_mem_d_inv, perm_main_mem_ind_addr_a_inv, perm_main_mem_ind_addr_b_inv, perm_main_mem_ind_addr_c_inv, perm_main_mem_ind_addr_d_inv, lookup_pow_2_0_inv, lookup_pow_2_1_inv, lookup_u8_0_inv, lookup_u8_1_inv, lookup_u16_0_inv, lookup_u16_1_inv, lookup_u16_2_inv, lookup_u16_3_inv, lookup_u16_4_inv, lookup_u16_5_inv, lookup_u16_6_inv, lookup_u16_7_inv, lookup_u16_8_inv, lookup_u16_9_inv, lookup_u16_10_inv, lookup_u16_11_inv, lookup_u16_12_inv, lookup_u16_13_inv, lookup_u16_14_inv, lookup_div_u16_0_inv, lookup_div_u16_1_inv, lookup_div_u16_2_inv, lookup_div_u16_3_inv, lookup_div_u16_4_inv, lookup_div_u16_5_inv, lookup_div_u16_6_inv, lookup_div_u16_7_inv, lookup_byte_lengths_inv, lookup_byte_operations_inv, lookup_opcode_gas_inv, range_check_l2_gas_hi_inv, range_check_l2_gas_lo_inv, range_check_da_gas_hi_inv, range_check_da_gas_lo_inv, kernel_output_lookup_inv, lookup_into_kernel_inv, lookup_cd_value_inv, lookup_ret_value_inv, incl_main_tag_err_inv, incl_mem_tag_err_inv, lookup_mem_rng_chk_lo_inv, lookup_mem_rng_chk_mid_inv, lookup_mem_rng_chk_hi_inv +#define WIRE_ENTITIES main_kernel_inputs, main_kernel_value_out, main_kernel_side_effect_out, main_kernel_metadata_out, main_calldata, main_returndata, alu_a_hi, alu_a_lo, alu_b_hi, alu_b_lo, alu_borrow, alu_cf, alu_clk, alu_cmp_rng_ctr, alu_div_u16_r0, alu_div_u16_r1, alu_div_u16_r2, alu_div_u16_r3, alu_div_u16_r4, alu_div_u16_r5, alu_div_u16_r6, alu_div_u16_r7, alu_divisor_hi, alu_divisor_lo, alu_ff_tag, alu_ia, alu_ib, alu_ic, alu_in_tag, alu_op_add, alu_op_cast, alu_op_cast_prev, alu_op_div, alu_op_div_a_lt_b, alu_op_div_std, alu_op_eq, alu_op_eq_diff_inv, alu_op_lt, alu_op_lte, alu_op_mul, alu_op_not, alu_op_shl, alu_op_shr, alu_op_sub, alu_p_a_borrow, alu_p_b_borrow, alu_p_sub_a_hi, alu_p_sub_a_lo, alu_p_sub_b_hi, alu_p_sub_b_lo, alu_partial_prod_hi, alu_partial_prod_lo, alu_quotient_hi, alu_quotient_lo, alu_remainder, alu_res_hi, alu_res_lo, alu_sel_alu, alu_sel_cmp, alu_sel_div_rng_chk, alu_sel_rng_chk, alu_sel_rng_chk_lookup, alu_sel_shift_which, alu_shift_lt_bit_len, alu_t_sub_s_bits, alu_two_pow_s, alu_two_pow_t_sub_s, alu_u128_tag, alu_u16_r0, alu_u16_r1, alu_u16_r10, alu_u16_r11, alu_u16_r12, alu_u16_r13, alu_u16_r14, alu_u16_r2, alu_u16_r3, alu_u16_r4, alu_u16_r5, alu_u16_r6, alu_u16_r7, alu_u16_r8, alu_u16_r9, alu_u16_tag, alu_u32_tag, alu_u64_tag, alu_u8_r0, alu_u8_r1, alu_u8_tag, binary_acc_ia, binary_acc_ib, binary_acc_ic, binary_clk, binary_ia_bytes, binary_ib_bytes, binary_ic_bytes, binary_in_tag, binary_mem_tag_ctr, binary_mem_tag_ctr_inv, binary_op_id, binary_sel_bin, binary_start, conversion_clk, conversion_input, conversion_num_limbs, conversion_radix, conversion_sel_to_radix_le, keccakf1600_clk, keccakf1600_input, keccakf1600_output, keccakf1600_sel_keccakf1600, main_abs_da_rem_gas_hi, main_abs_da_rem_gas_lo, main_abs_l2_rem_gas_hi, main_abs_l2_rem_gas_lo, main_alu_in_tag, main_base_da_gas_op_cost, main_base_l2_gas_op_cost, main_bin_op_id, main_call_ptr, main_da_gas_remaining, main_da_out_of_gas, main_dyn_da_gas_op_cost, main_dyn_gas_multiplier, main_dyn_l2_gas_op_cost, main_emit_l2_to_l1_msg_write_offset, main_emit_note_hash_write_offset, main_emit_nullifier_write_offset, main_emit_unencrypted_log_write_offset, main_ia, main_ib, main_ic, main_id, main_id_zero, main_ind_addr_a, main_ind_addr_b, main_ind_addr_c, main_ind_addr_d, main_internal_return_ptr, main_inv, main_kernel_in_offset, main_kernel_out_offset, main_l1_to_l2_msg_exists_write_offset, main_l2_gas_remaining, main_l2_out_of_gas, main_mem_addr_a, main_mem_addr_b, main_mem_addr_c, main_mem_addr_d, main_note_hash_exist_write_offset, main_nullifier_exists_write_offset, main_nullifier_non_exists_write_offset, main_op_err, main_opcode_val, main_pc, main_r_in_tag, main_rwa, main_rwb, main_rwc, main_rwd, main_sel_alu, main_sel_bin, main_sel_calldata, main_sel_execution_row, main_sel_kernel_inputs, main_sel_kernel_out, main_sel_last, main_sel_mem_op_a, main_sel_mem_op_b, main_sel_mem_op_c, main_sel_mem_op_d, main_sel_mov_ia_to_ic, main_sel_mov_ib_to_ic, main_sel_op_add, main_sel_op_address, main_sel_op_and, main_sel_op_block_number, main_sel_op_calldata_copy, main_sel_op_cast, main_sel_op_chain_id, main_sel_op_cmov, main_sel_op_coinbase, main_sel_op_dagasleft, main_sel_op_div, main_sel_op_ecadd, main_sel_op_emit_l2_to_l1_msg, main_sel_op_emit_note_hash, main_sel_op_emit_nullifier, main_sel_op_emit_unencrypted_log, main_sel_op_eq, main_sel_op_external_call, main_sel_op_external_return, main_sel_op_external_revert, main_sel_op_fdiv, main_sel_op_fee_per_da_gas, main_sel_op_fee_per_l2_gas, main_sel_op_function_selector, main_sel_op_get_contract_instance, main_sel_op_internal_call, main_sel_op_internal_return, main_sel_op_jump, main_sel_op_jumpi, main_sel_op_keccak, main_sel_op_l1_to_l2_msg_exists, main_sel_op_l2gasleft, main_sel_op_lt, main_sel_op_lte, main_sel_op_mov, main_sel_op_msm, main_sel_op_mul, main_sel_op_not, main_sel_op_note_hash_exists, main_sel_op_nullifier_exists, main_sel_op_or, main_sel_op_pedersen, main_sel_op_pedersen_commit, main_sel_op_poseidon2, main_sel_op_radix_le, main_sel_op_sender, main_sel_op_set, main_sel_op_sha256, main_sel_op_shl, main_sel_op_shr, main_sel_op_sload, main_sel_op_sstore, main_sel_op_storage_address, main_sel_op_sub, main_sel_op_timestamp, main_sel_op_transaction_fee, main_sel_op_version, main_sel_op_xor, main_sel_q_kernel_lookup, main_sel_q_kernel_output_lookup, main_sel_resolve_ind_addr_a, main_sel_resolve_ind_addr_b, main_sel_resolve_ind_addr_c, main_sel_resolve_ind_addr_d, main_sel_returndata, main_sel_rng_16, main_sel_rng_8, main_sel_slice_gadget, main_side_effect_counter, main_sload_write_offset, main_space_id, main_sstore_write_offset, main_tag_err, main_w_in_tag, mem_addr, mem_clk, mem_diff_hi, mem_diff_lo, mem_diff_mid, mem_glob_addr, mem_last, mem_lastAccess, mem_one_min_inv, mem_r_in_tag, mem_rw, mem_sel_mem, mem_sel_mov_ia_to_ic, mem_sel_mov_ib_to_ic, mem_sel_op_a, mem_sel_op_b, mem_sel_op_c, mem_sel_op_cmov, mem_sel_op_d, mem_sel_op_poseidon_read_a, mem_sel_op_poseidon_read_b, mem_sel_op_poseidon_read_c, mem_sel_op_poseidon_read_d, mem_sel_op_poseidon_write_a, mem_sel_op_poseidon_write_b, mem_sel_op_poseidon_write_c, mem_sel_op_poseidon_write_d, mem_sel_op_slice, mem_sel_resolve_ind_addr_a, mem_sel_resolve_ind_addr_b, mem_sel_resolve_ind_addr_c, mem_sel_resolve_ind_addr_d, mem_sel_rng_chk, mem_skip_check_tag, mem_space_id, mem_tag, mem_tag_err, mem_tsp, mem_val, mem_w_in_tag, pedersen_clk, pedersen_input, pedersen_output, pedersen_sel_pedersen, poseidon2_B_10_0, poseidon2_B_10_1, poseidon2_B_10_2, poseidon2_B_10_3, poseidon2_B_11_0, poseidon2_B_11_1, poseidon2_B_11_2, poseidon2_B_11_3, poseidon2_B_12_0, poseidon2_B_12_1, poseidon2_B_12_2, poseidon2_B_12_3, poseidon2_B_13_0, poseidon2_B_13_1, poseidon2_B_13_2, poseidon2_B_13_3, poseidon2_B_14_0, poseidon2_B_14_1, poseidon2_B_14_2, poseidon2_B_14_3, poseidon2_B_15_0, poseidon2_B_15_1, poseidon2_B_15_2, poseidon2_B_15_3, poseidon2_B_16_0, poseidon2_B_16_1, poseidon2_B_16_2, poseidon2_B_16_3, poseidon2_B_17_0, poseidon2_B_17_1, poseidon2_B_17_2, poseidon2_B_17_3, poseidon2_B_18_0, poseidon2_B_18_1, poseidon2_B_18_2, poseidon2_B_18_3, poseidon2_B_19_0, poseidon2_B_19_1, poseidon2_B_19_2, poseidon2_B_19_3, poseidon2_B_20_0, poseidon2_B_20_1, poseidon2_B_20_2, poseidon2_B_20_3, poseidon2_B_21_0, poseidon2_B_21_1, poseidon2_B_21_2, poseidon2_B_21_3, poseidon2_B_22_0, poseidon2_B_22_1, poseidon2_B_22_2, poseidon2_B_22_3, poseidon2_B_23_0, poseidon2_B_23_1, poseidon2_B_23_2, poseidon2_B_23_3, poseidon2_B_24_0, poseidon2_B_24_1, poseidon2_B_24_2, poseidon2_B_24_3, poseidon2_B_25_0, poseidon2_B_25_1, poseidon2_B_25_2, poseidon2_B_25_3, poseidon2_B_26_0, poseidon2_B_26_1, poseidon2_B_26_2, poseidon2_B_26_3, poseidon2_B_27_0, poseidon2_B_27_1, poseidon2_B_27_2, poseidon2_B_27_3, poseidon2_B_28_0, poseidon2_B_28_1, poseidon2_B_28_2, poseidon2_B_28_3, poseidon2_B_29_0, poseidon2_B_29_1, poseidon2_B_29_2, poseidon2_B_29_3, poseidon2_B_30_0, poseidon2_B_30_1, poseidon2_B_30_2, poseidon2_B_30_3, poseidon2_B_31_0, poseidon2_B_31_1, poseidon2_B_31_2, poseidon2_B_31_3, poseidon2_B_32_0, poseidon2_B_32_1, poseidon2_B_32_2, poseidon2_B_32_3, poseidon2_B_33_0, poseidon2_B_33_1, poseidon2_B_33_2, poseidon2_B_33_3, poseidon2_B_34_0, poseidon2_B_34_1, poseidon2_B_34_2, poseidon2_B_34_3, poseidon2_B_35_0, poseidon2_B_35_1, poseidon2_B_35_2, poseidon2_B_35_3, poseidon2_B_36_0, poseidon2_B_36_1, poseidon2_B_36_2, poseidon2_B_36_3, poseidon2_B_37_0, poseidon2_B_37_1, poseidon2_B_37_2, poseidon2_B_37_3, poseidon2_B_38_0, poseidon2_B_38_1, poseidon2_B_38_2, poseidon2_B_38_3, poseidon2_B_39_0, poseidon2_B_39_1, poseidon2_B_39_2, poseidon2_B_39_3, poseidon2_B_40_0, poseidon2_B_40_1, poseidon2_B_40_2, poseidon2_B_40_3, poseidon2_B_41_0, poseidon2_B_41_1, poseidon2_B_41_2, poseidon2_B_41_3, poseidon2_B_42_0, poseidon2_B_42_1, poseidon2_B_42_2, poseidon2_B_42_3, poseidon2_B_43_0, poseidon2_B_43_1, poseidon2_B_43_2, poseidon2_B_43_3, poseidon2_B_44_0, poseidon2_B_44_1, poseidon2_B_44_2, poseidon2_B_44_3, poseidon2_B_45_0, poseidon2_B_45_1, poseidon2_B_45_2, poseidon2_B_45_3, poseidon2_B_46_0, poseidon2_B_46_1, poseidon2_B_46_2, poseidon2_B_46_3, poseidon2_B_47_0, poseidon2_B_47_1, poseidon2_B_47_2, poseidon2_B_47_3, poseidon2_B_48_0, poseidon2_B_48_1, poseidon2_B_48_2, poseidon2_B_48_3, poseidon2_B_49_0, poseidon2_B_49_1, poseidon2_B_49_2, poseidon2_B_49_3, poseidon2_B_4_0, poseidon2_B_4_1, poseidon2_B_4_2, poseidon2_B_4_3, poseidon2_B_50_0, poseidon2_B_50_1, poseidon2_B_50_2, poseidon2_B_50_3, poseidon2_B_51_0, poseidon2_B_51_1, poseidon2_B_51_2, poseidon2_B_51_3, poseidon2_B_52_0, poseidon2_B_52_1, poseidon2_B_52_2, poseidon2_B_52_3, poseidon2_B_53_0, poseidon2_B_53_1, poseidon2_B_53_2, poseidon2_B_53_3, poseidon2_B_54_0, poseidon2_B_54_1, poseidon2_B_54_2, poseidon2_B_54_3, poseidon2_B_55_0, poseidon2_B_55_1, poseidon2_B_55_2, poseidon2_B_55_3, poseidon2_B_56_0, poseidon2_B_56_1, poseidon2_B_56_2, poseidon2_B_56_3, poseidon2_B_57_0, poseidon2_B_57_1, poseidon2_B_57_2, poseidon2_B_57_3, poseidon2_B_58_0, poseidon2_B_58_1, poseidon2_B_58_2, poseidon2_B_58_3, poseidon2_B_59_0, poseidon2_B_59_1, poseidon2_B_59_2, poseidon2_B_59_3, poseidon2_B_5_0, poseidon2_B_5_1, poseidon2_B_5_2, poseidon2_B_5_3, poseidon2_B_6_0, poseidon2_B_6_1, poseidon2_B_6_2, poseidon2_B_6_3, poseidon2_B_7_0, poseidon2_B_7_1, poseidon2_B_7_2, poseidon2_B_7_3, poseidon2_B_8_0, poseidon2_B_8_1, poseidon2_B_8_2, poseidon2_B_8_3, poseidon2_B_9_0, poseidon2_B_9_1, poseidon2_B_9_2, poseidon2_B_9_3, poseidon2_EXT_LAYER_4, poseidon2_EXT_LAYER_5, poseidon2_EXT_LAYER_6, poseidon2_EXT_LAYER_7, poseidon2_T_0_4, poseidon2_T_0_5, poseidon2_T_0_6, poseidon2_T_0_7, poseidon2_T_1_4, poseidon2_T_1_5, poseidon2_T_1_6, poseidon2_T_1_7, poseidon2_T_2_4, poseidon2_T_2_5, poseidon2_T_2_6, poseidon2_T_2_7, poseidon2_T_3_4, poseidon2_T_3_5, poseidon2_T_3_6, poseidon2_T_3_7, poseidon2_T_60_4, poseidon2_T_60_5, poseidon2_T_60_6, poseidon2_T_60_7, poseidon2_T_61_4, poseidon2_T_61_5, poseidon2_T_61_6, poseidon2_T_61_7, poseidon2_T_62_4, poseidon2_T_62_5, poseidon2_T_62_6, poseidon2_T_62_7, poseidon2_T_63_4, poseidon2_T_63_5, poseidon2_T_63_6, poseidon2_T_63_7, poseidon2_a_0, poseidon2_a_1, poseidon2_a_2, poseidon2_a_3, poseidon2_b_0, poseidon2_b_1, poseidon2_b_2, poseidon2_b_3, poseidon2_clk, poseidon2_input_addr, poseidon2_mem_addr_read_a, poseidon2_mem_addr_read_b, poseidon2_mem_addr_read_c, poseidon2_mem_addr_read_d, poseidon2_mem_addr_write_a, poseidon2_mem_addr_write_b, poseidon2_mem_addr_write_c, poseidon2_mem_addr_write_d, poseidon2_output_addr, poseidon2_sel_poseidon_perm, range_check_clk, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_is_lte_u112, range_check_is_lte_u128, range_check_is_lte_u16, range_check_is_lte_u32, range_check_is_lte_u48, range_check_is_lte_u64, range_check_is_lte_u80, range_check_is_lte_u96, range_check_rng_chk_bits, range_check_sel_lookup_0, range_check_sel_lookup_1, range_check_sel_lookup_2, range_check_sel_lookup_3, range_check_sel_lookup_4, range_check_sel_lookup_5, range_check_sel_lookup_6, range_check_sel_rng_chk, range_check_u16_r0, range_check_u16_r1, range_check_u16_r2, range_check_u16_r3, range_check_u16_r4, range_check_u16_r5, range_check_u16_r6, range_check_u16_r7, range_check_value, sha256_clk, sha256_input, sha256_output, sha256_sel_sha256_compression, sha256_state, slice_addr, slice_clk, slice_cnt, slice_col_offset, slice_one_min_inv, slice_sel_cd_cpy, slice_sel_mem_active, slice_sel_return, slice_sel_start, slice_space_id, slice_val, lookup_rng_chk_pow_2_counts, lookup_rng_chk_diff_counts, lookup_rng_chk_0_counts, lookup_rng_chk_1_counts, lookup_rng_chk_2_counts, lookup_rng_chk_3_counts, lookup_rng_chk_4_counts, lookup_rng_chk_5_counts, lookup_rng_chk_6_counts, lookup_rng_chk_7_counts, lookup_pow_2_0_counts, lookup_pow_2_1_counts, lookup_u8_0_counts, lookup_u8_1_counts, lookup_u16_0_counts, lookup_u16_1_counts, lookup_u16_2_counts, lookup_u16_3_counts, lookup_u16_4_counts, lookup_u16_5_counts, lookup_u16_6_counts, lookup_u16_7_counts, lookup_u16_8_counts, lookup_u16_9_counts, lookup_u16_10_counts, lookup_u16_11_counts, lookup_u16_12_counts, lookup_u16_13_counts, lookup_u16_14_counts, lookup_div_u16_0_counts, lookup_div_u16_1_counts, lookup_div_u16_2_counts, lookup_div_u16_3_counts, lookup_div_u16_4_counts, lookup_div_u16_5_counts, lookup_div_u16_6_counts, lookup_div_u16_7_counts, lookup_byte_lengths_counts, lookup_byte_operations_counts, lookup_opcode_gas_counts, range_check_l2_gas_hi_counts, range_check_l2_gas_lo_counts, range_check_da_gas_hi_counts, range_check_da_gas_lo_counts, kernel_output_lookup_counts, lookup_into_kernel_counts, lookup_cd_value_counts, lookup_ret_value_counts, incl_main_tag_err_counts, incl_mem_tag_err_counts, lookup_mem_rng_chk_lo_counts, lookup_mem_rng_chk_mid_counts, lookup_mem_rng_chk_hi_counts +#define DERIVED_WITNESS_ENTITIES perm_pos_mem_read_a_inv, perm_pos_mem_read_b_inv, perm_pos_mem_read_c_inv, perm_pos_mem_read_d_inv, perm_pos_mem_write_a_inv, perm_pos_mem_write_b_inv, perm_pos_mem_write_c_inv, perm_pos_mem_write_d_inv, perm_slice_mem_inv, perm_main_alu_inv, perm_main_bin_inv, perm_main_conv_inv, perm_main_pos2_perm_inv, perm_main_pedersen_inv, perm_main_slice_inv, perm_main_mem_a_inv, perm_main_mem_b_inv, perm_main_mem_c_inv, perm_main_mem_d_inv, perm_main_mem_ind_addr_a_inv, perm_main_mem_ind_addr_b_inv, perm_main_mem_ind_addr_c_inv, perm_main_mem_ind_addr_d_inv, lookup_rng_chk_pow_2_inv, lookup_rng_chk_diff_inv, lookup_rng_chk_0_inv, lookup_rng_chk_1_inv, lookup_rng_chk_2_inv, lookup_rng_chk_3_inv, lookup_rng_chk_4_inv, lookup_rng_chk_5_inv, lookup_rng_chk_6_inv, lookup_rng_chk_7_inv, lookup_pow_2_0_inv, lookup_pow_2_1_inv, lookup_u8_0_inv, lookup_u8_1_inv, lookup_u16_0_inv, lookup_u16_1_inv, lookup_u16_2_inv, lookup_u16_3_inv, lookup_u16_4_inv, lookup_u16_5_inv, lookup_u16_6_inv, lookup_u16_7_inv, lookup_u16_8_inv, lookup_u16_9_inv, lookup_u16_10_inv, lookup_u16_11_inv, lookup_u16_12_inv, lookup_u16_13_inv, lookup_u16_14_inv, lookup_div_u16_0_inv, lookup_div_u16_1_inv, lookup_div_u16_2_inv, lookup_div_u16_3_inv, lookup_div_u16_4_inv, lookup_div_u16_5_inv, lookup_div_u16_6_inv, lookup_div_u16_7_inv, lookup_byte_lengths_inv, lookup_byte_operations_inv, lookup_opcode_gas_inv, range_check_l2_gas_hi_inv, range_check_l2_gas_lo_inv, range_check_da_gas_hi_inv, range_check_da_gas_lo_inv, kernel_output_lookup_inv, lookup_into_kernel_inv, lookup_cd_value_inv, lookup_ret_value_inv, incl_main_tag_err_inv, incl_mem_tag_err_inv, lookup_mem_rng_chk_lo_inv, lookup_mem_rng_chk_mid_inv, lookup_mem_rng_chk_hi_inv #define SHIFTED_ENTITIES alu_a_hi_shift, alu_a_lo_shift, alu_b_hi_shift, alu_b_lo_shift, alu_cmp_rng_ctr_shift, alu_div_u16_r0_shift, alu_div_u16_r1_shift, alu_div_u16_r2_shift, alu_div_u16_r3_shift, alu_div_u16_r4_shift, alu_div_u16_r5_shift, alu_div_u16_r6_shift, alu_div_u16_r7_shift, alu_op_add_shift, alu_op_cast_shift, alu_op_cast_prev_shift, alu_op_div_shift, alu_op_mul_shift, alu_op_shl_shift, alu_op_shr_shift, alu_op_sub_shift, alu_p_sub_a_hi_shift, alu_p_sub_a_lo_shift, alu_p_sub_b_hi_shift, alu_p_sub_b_lo_shift, alu_sel_alu_shift, alu_sel_cmp_shift, alu_sel_div_rng_chk_shift, alu_sel_rng_chk_shift, alu_sel_rng_chk_lookup_shift, alu_u16_r0_shift, alu_u16_r1_shift, alu_u16_r2_shift, alu_u16_r3_shift, alu_u16_r4_shift, alu_u16_r5_shift, alu_u16_r6_shift, alu_u8_r0_shift, alu_u8_r1_shift, binary_acc_ia_shift, binary_acc_ib_shift, binary_acc_ic_shift, binary_mem_tag_ctr_shift, binary_op_id_shift, main_da_gas_remaining_shift, main_emit_l2_to_l1_msg_write_offset_shift, main_emit_note_hash_write_offset_shift, main_emit_nullifier_write_offset_shift, main_emit_unencrypted_log_write_offset_shift, main_internal_return_ptr_shift, main_l1_to_l2_msg_exists_write_offset_shift, main_l2_gas_remaining_shift, main_note_hash_exist_write_offset_shift, main_nullifier_exists_write_offset_shift, main_nullifier_non_exists_write_offset_shift, main_pc_shift, main_sel_execution_row_shift, main_side_effect_counter_shift, main_sload_write_offset_shift, main_sstore_write_offset_shift, mem_glob_addr_shift, mem_rw_shift, mem_sel_mem_shift, mem_tag_shift, mem_tsp_shift, mem_val_shift, slice_addr_shift, slice_clk_shift, slice_cnt_shift, slice_col_offset_shift, slice_sel_cd_cpy_shift, slice_sel_mem_active_shift, slice_sel_return_shift, slice_sel_start_shift, slice_space_id_shift #define TO_BE_SHIFTED(e) e.alu_a_hi, e.alu_a_lo, e.alu_b_hi, e.alu_b_lo, e.alu_cmp_rng_ctr, e.alu_div_u16_r0, e.alu_div_u16_r1, e.alu_div_u16_r2, e.alu_div_u16_r3, e.alu_div_u16_r4, e.alu_div_u16_r5, e.alu_div_u16_r6, e.alu_div_u16_r7, e.alu_op_add, e.alu_op_cast, e.alu_op_cast_prev, e.alu_op_div, e.alu_op_mul, e.alu_op_shl, e.alu_op_shr, e.alu_op_sub, e.alu_p_sub_a_hi, e.alu_p_sub_a_lo, e.alu_p_sub_b_hi, e.alu_p_sub_b_lo, e.alu_sel_alu, e.alu_sel_cmp, e.alu_sel_div_rng_chk, e.alu_sel_rng_chk, e.alu_sel_rng_chk_lookup, e.alu_u16_r0, e.alu_u16_r1, e.alu_u16_r2, e.alu_u16_r3, e.alu_u16_r4, e.alu_u16_r5, e.alu_u16_r6, e.alu_u8_r0, e.alu_u8_r1, e.binary_acc_ia, e.binary_acc_ib, e.binary_acc_ic, e.binary_mem_tag_ctr, e.binary_op_id, e.main_da_gas_remaining, e.main_emit_l2_to_l1_msg_write_offset, e.main_emit_note_hash_write_offset, e.main_emit_nullifier_write_offset, e.main_emit_unencrypted_log_write_offset, e.main_internal_return_ptr, e.main_l1_to_l2_msg_exists_write_offset, e.main_l2_gas_remaining, e.main_note_hash_exist_write_offset, e.main_nullifier_exists_write_offset, e.main_nullifier_non_exists_write_offset, e.main_pc, e.main_sel_execution_row, e.main_side_effect_counter, e.main_sload_write_offset, e.main_sstore_write_offset, e.mem_glob_addr, e.mem_rw, e.mem_sel_mem, e.mem_tag, e.mem_tsp, e.mem_val, e.slice_addr, e.slice_clk, e.slice_cnt, e.slice_col_offset, e.slice_sel_cd_cpy, e.slice_sel_mem_active, e.slice_sel_return, e.slice_sel_start, e.slice_space_id #define ALL_ENTITIES PRECOMPUTED_ENTITIES, WIRE_ENTITIES, DERIVED_WITNESS_ENTITIES, SHIFTED_ENTITIES @@ -131,12 +142,12 @@ class AvmFlavor { static constexpr bool HasZK = false; static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 16; - static constexpr size_t NUM_WITNESS_ENTITIES = 696; + static constexpr size_t NUM_WITNESS_ENTITIES = 746; static constexpr size_t NUM_SHIFTED_ENTITIES = 75; static constexpr size_t NUM_WIRES = NUM_WITNESS_ENTITIES + NUM_PRECOMPUTED_ENTITIES; // We have two copies of the witness entities, so we subtract the number of fixed ones (they have no shift), one for // the unshifted and one for the shifted - static constexpr size_t NUM_ALL_ENTITIES = 787; + static constexpr size_t NUM_ALL_ENTITIES = 837; // The total number of witnesses including shifts and derived entities. static constexpr size_t NUM_ALL_WITNESS_ENTITIES = NUM_WITNESS_ENTITIES + NUM_SHIFTED_ENTITIES; @@ -153,6 +164,7 @@ class AvmFlavor { Avm_vm::mem_slice, Avm_vm::pedersen, Avm_vm::poseidon2, + Avm_vm::range_check, Avm_vm::sha256>; using LookupRelations = std::tuple< @@ -179,6 +191,16 @@ class AvmFlavor { lookup_pow_2_0_relation, lookup_pow_2_1_relation, lookup_ret_value_relation, + lookup_rng_chk_0_relation, + lookup_rng_chk_1_relation, + lookup_rng_chk_2_relation, + lookup_rng_chk_3_relation, + lookup_rng_chk_4_relation, + lookup_rng_chk_5_relation, + lookup_rng_chk_6_relation, + lookup_rng_chk_7_relation, + lookup_rng_chk_diff_relation, + lookup_rng_chk_pow_2_relation, lookup_u16_0_relation, lookup_u16_1_relation, lookup_u16_10_relation, diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.cpp index 25dc4756728e..dddc721fc639 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.cpp @@ -606,6 +606,36 @@ template std::vector AvmFullRow::names() "poseidon2_mem_addr_write_d", "poseidon2_output_addr", "poseidon2_sel_poseidon_perm", + "range_check_clk", + "range_check_dyn_diff", + "range_check_dyn_rng_chk_bits", + "range_check_dyn_rng_chk_pow_2", + "range_check_is_lte_u112", + "range_check_is_lte_u128", + "range_check_is_lte_u16", + "range_check_is_lte_u32", + "range_check_is_lte_u48", + "range_check_is_lte_u64", + "range_check_is_lte_u80", + "range_check_is_lte_u96", + "range_check_rng_chk_bits", + "range_check_sel_lookup_0", + "range_check_sel_lookup_1", + "range_check_sel_lookup_2", + "range_check_sel_lookup_3", + "range_check_sel_lookup_4", + "range_check_sel_lookup_5", + "range_check_sel_lookup_6", + "range_check_sel_rng_chk", + "range_check_u16_r0", + "range_check_u16_r1", + "range_check_u16_r2", + "range_check_u16_r3", + "range_check_u16_r4", + "range_check_u16_r5", + "range_check_u16_r6", + "range_check_u16_r7", + "range_check_value", "sha256_clk", "sha256_input", "sha256_output", @@ -645,6 +675,16 @@ template std::vector AvmFullRow::names() "perm_main_mem_ind_addr_b_inv", "perm_main_mem_ind_addr_c_inv", "perm_main_mem_ind_addr_d_inv", + "lookup_rng_chk_pow_2_inv", + "lookup_rng_chk_diff_inv", + "lookup_rng_chk_0_inv", + "lookup_rng_chk_1_inv", + "lookup_rng_chk_2_inv", + "lookup_rng_chk_3_inv", + "lookup_rng_chk_4_inv", + "lookup_rng_chk_5_inv", + "lookup_rng_chk_6_inv", + "lookup_rng_chk_7_inv", "lookup_pow_2_0_inv", "lookup_pow_2_1_inv", "lookup_u8_0_inv", @@ -688,6 +728,16 @@ template std::vector AvmFullRow::names() "lookup_mem_rng_chk_lo_inv", "lookup_mem_rng_chk_mid_inv", "lookup_mem_rng_chk_hi_inv", + "lookup_rng_chk_pow_2_counts", + "lookup_rng_chk_diff_counts", + "lookup_rng_chk_0_counts", + "lookup_rng_chk_1_counts", + "lookup_rng_chk_2_counts", + "lookup_rng_chk_3_counts", + "lookup_rng_chk_4_counts", + "lookup_rng_chk_5_counts", + "lookup_rng_chk_6_counts", + "lookup_rng_chk_7_counts", "lookup_pow_2_0_counts", "lookup_pow_2_1_counts", "lookup_u8_0_counts", @@ -1323,6 +1373,36 @@ template RefVector AvmFullRow::as_vector() const poseidon2_mem_addr_write_d, poseidon2_output_addr, poseidon2_sel_poseidon_perm, + range_check_clk, + range_check_dyn_diff, + range_check_dyn_rng_chk_bits, + range_check_dyn_rng_chk_pow_2, + range_check_is_lte_u112, + range_check_is_lte_u128, + range_check_is_lte_u16, + range_check_is_lte_u32, + range_check_is_lte_u48, + range_check_is_lte_u64, + range_check_is_lte_u80, + range_check_is_lte_u96, + range_check_rng_chk_bits, + range_check_sel_lookup_0, + range_check_sel_lookup_1, + range_check_sel_lookup_2, + range_check_sel_lookup_3, + range_check_sel_lookup_4, + range_check_sel_lookup_5, + range_check_sel_lookup_6, + range_check_sel_rng_chk, + range_check_u16_r0, + range_check_u16_r1, + range_check_u16_r2, + range_check_u16_r3, + range_check_u16_r4, + range_check_u16_r5, + range_check_u16_r6, + range_check_u16_r7, + range_check_value, sha256_clk, sha256_input, sha256_output, @@ -1362,6 +1442,16 @@ template RefVector AvmFullRow::as_vector() const perm_main_mem_ind_addr_b_inv, perm_main_mem_ind_addr_c_inv, perm_main_mem_ind_addr_d_inv, + lookup_rng_chk_pow_2_inv, + lookup_rng_chk_diff_inv, + lookup_rng_chk_0_inv, + lookup_rng_chk_1_inv, + lookup_rng_chk_2_inv, + lookup_rng_chk_3_inv, + lookup_rng_chk_4_inv, + lookup_rng_chk_5_inv, + lookup_rng_chk_6_inv, + lookup_rng_chk_7_inv, lookup_pow_2_0_inv, lookup_pow_2_1_inv, lookup_u8_0_inv, @@ -1405,6 +1495,16 @@ template RefVector AvmFullRow::as_vector() const lookup_mem_rng_chk_lo_inv, lookup_mem_rng_chk_mid_inv, lookup_mem_rng_chk_hi_inv, + lookup_rng_chk_pow_2_counts, + lookup_rng_chk_diff_counts, + lookup_rng_chk_0_counts, + lookup_rng_chk_1_counts, + lookup_rng_chk_2_counts, + lookup_rng_chk_3_counts, + lookup_rng_chk_4_counts, + lookup_rng_chk_5_counts, + lookup_rng_chk_6_counts, + lookup_rng_chk_7_counts, lookup_pow_2_0_counts, lookup_pow_2_1_counts, lookup_u8_0_counts, diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.hpp index 4c8e36640e39..39cdf0e216c7 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.hpp @@ -597,6 +597,36 @@ template struct AvmFullRow { FF poseidon2_mem_addr_write_d{}; FF poseidon2_output_addr{}; FF poseidon2_sel_poseidon_perm{}; + FF range_check_clk{}; + FF range_check_dyn_diff{}; + FF range_check_dyn_rng_chk_bits{}; + FF range_check_dyn_rng_chk_pow_2{}; + FF range_check_is_lte_u112{}; + FF range_check_is_lte_u128{}; + FF range_check_is_lte_u16{}; + FF range_check_is_lte_u32{}; + FF range_check_is_lte_u48{}; + FF range_check_is_lte_u64{}; + FF range_check_is_lte_u80{}; + FF range_check_is_lte_u96{}; + FF range_check_rng_chk_bits{}; + FF range_check_sel_lookup_0{}; + FF range_check_sel_lookup_1{}; + FF range_check_sel_lookup_2{}; + FF range_check_sel_lookup_3{}; + FF range_check_sel_lookup_4{}; + FF range_check_sel_lookup_5{}; + FF range_check_sel_lookup_6{}; + FF range_check_sel_rng_chk{}; + FF range_check_u16_r0{}; + FF range_check_u16_r1{}; + FF range_check_u16_r2{}; + FF range_check_u16_r3{}; + FF range_check_u16_r4{}; + FF range_check_u16_r5{}; + FF range_check_u16_r6{}; + FF range_check_u16_r7{}; + FF range_check_value{}; FF sha256_clk{}; FF sha256_input{}; FF sha256_output{}; @@ -636,6 +666,16 @@ template struct AvmFullRow { FF perm_main_mem_ind_addr_b_inv{}; FF perm_main_mem_ind_addr_c_inv{}; FF perm_main_mem_ind_addr_d_inv{}; + FF lookup_rng_chk_pow_2_inv{}; + FF lookup_rng_chk_diff_inv{}; + FF lookup_rng_chk_0_inv{}; + FF lookup_rng_chk_1_inv{}; + FF lookup_rng_chk_2_inv{}; + FF lookup_rng_chk_3_inv{}; + FF lookup_rng_chk_4_inv{}; + FF lookup_rng_chk_5_inv{}; + FF lookup_rng_chk_6_inv{}; + FF lookup_rng_chk_7_inv{}; FF lookup_pow_2_0_inv{}; FF lookup_pow_2_1_inv{}; FF lookup_u8_0_inv{}; @@ -679,6 +719,16 @@ template struct AvmFullRow { FF lookup_mem_rng_chk_lo_inv{}; FF lookup_mem_rng_chk_mid_inv{}; FF lookup_mem_rng_chk_hi_inv{}; + FF lookup_rng_chk_pow_2_counts{}; + FF lookup_rng_chk_diff_counts{}; + FF lookup_rng_chk_0_counts{}; + FF lookup_rng_chk_1_counts{}; + FF lookup_rng_chk_2_counts{}; + FF lookup_rng_chk_3_counts{}; + FF lookup_rng_chk_4_counts{}; + FF lookup_rng_chk_5_counts{}; + FF lookup_rng_chk_6_counts{}; + FF lookup_rng_chk_7_counts{}; FF lookup_pow_2_0_counts{}; FF lookup_pow_2_1_counts{}; FF lookup_u8_0_counts{}; @@ -726,7 +776,7 @@ template struct AvmFullRow { RefVector as_vector() const; static std::vector names(); - static constexpr size_t SIZE = 712; + static constexpr size_t SIZE = 762; }; template std::ostream& operator<<(std::ostream& os, AvmFullRow const& row); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_0.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_0.hpp new file mode 100644 index 000000000000..6c885f428f83 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_0.hpp @@ -0,0 +1,64 @@ +// AUTOGENERATED FILE +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +class lookup_rng_chk_0_lookup_settings { + public: + static constexpr size_t READ_TERMS = 1; + static constexpr size_t WRITE_TERMS = 1; + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + static constexpr size_t READ_TERM_DEGREE = 0; + static constexpr size_t WRITE_TERM_DEGREE = 0; + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.range_check_sel_lookup_0 == 1 || in.main_sel_rng_16 == 1); + } + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.range_check_sel_lookup_0); + const auto is_table_entry = View(in.main_sel_rng_16); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + template static inline auto get_const_entities(const AllEntities& in) + { + return std::forward_as_tuple(in.lookup_rng_chk_0_inv, + in.lookup_rng_chk_0_counts, + in.range_check_sel_lookup_0, + in.main_sel_rng_16, + in.range_check_u16_r0, + in.main_clk); + } + + template static inline auto get_nonconst_entities(AllEntities& in) + { + return std::forward_as_tuple(in.lookup_rng_chk_0_inv, + in.lookup_rng_chk_0_counts, + in.range_check_sel_lookup_0, + in.main_sel_rng_16, + in.range_check_u16_r0, + in.main_clk); + } +}; + +template +class lookup_rng_chk_0_relation : public GenericLookupRelation { + public: + static constexpr const char* NAME = "LOOKUP_RNG_CHK_0"; +}; +template using lookup_rng_chk_0 = GenericLookup; + +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_1.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_1.hpp new file mode 100644 index 000000000000..52707ee271ba --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_1.hpp @@ -0,0 +1,64 @@ +// AUTOGENERATED FILE +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +class lookup_rng_chk_1_lookup_settings { + public: + static constexpr size_t READ_TERMS = 1; + static constexpr size_t WRITE_TERMS = 1; + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + static constexpr size_t READ_TERM_DEGREE = 0; + static constexpr size_t WRITE_TERM_DEGREE = 0; + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.range_check_sel_lookup_1 == 1 || in.main_sel_rng_16 == 1); + } + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.range_check_sel_lookup_1); + const auto is_table_entry = View(in.main_sel_rng_16); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + template static inline auto get_const_entities(const AllEntities& in) + { + return std::forward_as_tuple(in.lookup_rng_chk_1_inv, + in.lookup_rng_chk_1_counts, + in.range_check_sel_lookup_1, + in.main_sel_rng_16, + in.range_check_u16_r1, + in.main_clk); + } + + template static inline auto get_nonconst_entities(AllEntities& in) + { + return std::forward_as_tuple(in.lookup_rng_chk_1_inv, + in.lookup_rng_chk_1_counts, + in.range_check_sel_lookup_1, + in.main_sel_rng_16, + in.range_check_u16_r1, + in.main_clk); + } +}; + +template +class lookup_rng_chk_1_relation : public GenericLookupRelation { + public: + static constexpr const char* NAME = "LOOKUP_RNG_CHK_1"; +}; +template using lookup_rng_chk_1 = GenericLookup; + +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_2.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_2.hpp new file mode 100644 index 000000000000..dd268fb7ee61 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_2.hpp @@ -0,0 +1,64 @@ +// AUTOGENERATED FILE +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +class lookup_rng_chk_2_lookup_settings { + public: + static constexpr size_t READ_TERMS = 1; + static constexpr size_t WRITE_TERMS = 1; + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + static constexpr size_t READ_TERM_DEGREE = 0; + static constexpr size_t WRITE_TERM_DEGREE = 0; + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.range_check_sel_lookup_2 == 1 || in.main_sel_rng_16 == 1); + } + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.range_check_sel_lookup_2); + const auto is_table_entry = View(in.main_sel_rng_16); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + template static inline auto get_const_entities(const AllEntities& in) + { + return std::forward_as_tuple(in.lookup_rng_chk_2_inv, + in.lookup_rng_chk_2_counts, + in.range_check_sel_lookup_2, + in.main_sel_rng_16, + in.range_check_u16_r2, + in.main_clk); + } + + template static inline auto get_nonconst_entities(AllEntities& in) + { + return std::forward_as_tuple(in.lookup_rng_chk_2_inv, + in.lookup_rng_chk_2_counts, + in.range_check_sel_lookup_2, + in.main_sel_rng_16, + in.range_check_u16_r2, + in.main_clk); + } +}; + +template +class lookup_rng_chk_2_relation : public GenericLookupRelation { + public: + static constexpr const char* NAME = "LOOKUP_RNG_CHK_2"; +}; +template using lookup_rng_chk_2 = GenericLookup; + +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_3.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_3.hpp new file mode 100644 index 000000000000..dc30497b8146 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_3.hpp @@ -0,0 +1,64 @@ +// AUTOGENERATED FILE +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +class lookup_rng_chk_3_lookup_settings { + public: + static constexpr size_t READ_TERMS = 1; + static constexpr size_t WRITE_TERMS = 1; + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + static constexpr size_t READ_TERM_DEGREE = 0; + static constexpr size_t WRITE_TERM_DEGREE = 0; + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.range_check_sel_lookup_3 == 1 || in.main_sel_rng_16 == 1); + } + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.range_check_sel_lookup_3); + const auto is_table_entry = View(in.main_sel_rng_16); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + template static inline auto get_const_entities(const AllEntities& in) + { + return std::forward_as_tuple(in.lookup_rng_chk_3_inv, + in.lookup_rng_chk_3_counts, + in.range_check_sel_lookup_3, + in.main_sel_rng_16, + in.range_check_u16_r3, + in.main_clk); + } + + template static inline auto get_nonconst_entities(AllEntities& in) + { + return std::forward_as_tuple(in.lookup_rng_chk_3_inv, + in.lookup_rng_chk_3_counts, + in.range_check_sel_lookup_3, + in.main_sel_rng_16, + in.range_check_u16_r3, + in.main_clk); + } +}; + +template +class lookup_rng_chk_3_relation : public GenericLookupRelation { + public: + static constexpr const char* NAME = "LOOKUP_RNG_CHK_3"; +}; +template using lookup_rng_chk_3 = GenericLookup; + +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_4.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_4.hpp new file mode 100644 index 000000000000..b9ee0fd24616 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_4.hpp @@ -0,0 +1,64 @@ +// AUTOGENERATED FILE +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +class lookup_rng_chk_4_lookup_settings { + public: + static constexpr size_t READ_TERMS = 1; + static constexpr size_t WRITE_TERMS = 1; + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + static constexpr size_t READ_TERM_DEGREE = 0; + static constexpr size_t WRITE_TERM_DEGREE = 0; + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.range_check_sel_lookup_4 == 1 || in.main_sel_rng_16 == 1); + } + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.range_check_sel_lookup_4); + const auto is_table_entry = View(in.main_sel_rng_16); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + template static inline auto get_const_entities(const AllEntities& in) + { + return std::forward_as_tuple(in.lookup_rng_chk_4_inv, + in.lookup_rng_chk_4_counts, + in.range_check_sel_lookup_4, + in.main_sel_rng_16, + in.range_check_u16_r4, + in.main_clk); + } + + template static inline auto get_nonconst_entities(AllEntities& in) + { + return std::forward_as_tuple(in.lookup_rng_chk_4_inv, + in.lookup_rng_chk_4_counts, + in.range_check_sel_lookup_4, + in.main_sel_rng_16, + in.range_check_u16_r4, + in.main_clk); + } +}; + +template +class lookup_rng_chk_4_relation : public GenericLookupRelation { + public: + static constexpr const char* NAME = "LOOKUP_RNG_CHK_4"; +}; +template using lookup_rng_chk_4 = GenericLookup; + +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_5.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_5.hpp new file mode 100644 index 000000000000..c3f480217279 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_5.hpp @@ -0,0 +1,64 @@ +// AUTOGENERATED FILE +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +class lookup_rng_chk_5_lookup_settings { + public: + static constexpr size_t READ_TERMS = 1; + static constexpr size_t WRITE_TERMS = 1; + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + static constexpr size_t READ_TERM_DEGREE = 0; + static constexpr size_t WRITE_TERM_DEGREE = 0; + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.range_check_sel_lookup_5 == 1 || in.main_sel_rng_16 == 1); + } + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.range_check_sel_lookup_5); + const auto is_table_entry = View(in.main_sel_rng_16); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + template static inline auto get_const_entities(const AllEntities& in) + { + return std::forward_as_tuple(in.lookup_rng_chk_5_inv, + in.lookup_rng_chk_5_counts, + in.range_check_sel_lookup_5, + in.main_sel_rng_16, + in.range_check_u16_r5, + in.main_clk); + } + + template static inline auto get_nonconst_entities(AllEntities& in) + { + return std::forward_as_tuple(in.lookup_rng_chk_5_inv, + in.lookup_rng_chk_5_counts, + in.range_check_sel_lookup_5, + in.main_sel_rng_16, + in.range_check_u16_r5, + in.main_clk); + } +}; + +template +class lookup_rng_chk_5_relation : public GenericLookupRelation { + public: + static constexpr const char* NAME = "LOOKUP_RNG_CHK_5"; +}; +template using lookup_rng_chk_5 = GenericLookup; + +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_6.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_6.hpp new file mode 100644 index 000000000000..aa9d4155d175 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_6.hpp @@ -0,0 +1,64 @@ +// AUTOGENERATED FILE +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +class lookup_rng_chk_6_lookup_settings { + public: + static constexpr size_t READ_TERMS = 1; + static constexpr size_t WRITE_TERMS = 1; + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + static constexpr size_t READ_TERM_DEGREE = 0; + static constexpr size_t WRITE_TERM_DEGREE = 0; + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.range_check_sel_lookup_6 == 1 || in.main_sel_rng_16 == 1); + } + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.range_check_sel_lookup_6); + const auto is_table_entry = View(in.main_sel_rng_16); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + template static inline auto get_const_entities(const AllEntities& in) + { + return std::forward_as_tuple(in.lookup_rng_chk_6_inv, + in.lookup_rng_chk_6_counts, + in.range_check_sel_lookup_6, + in.main_sel_rng_16, + in.range_check_u16_r6, + in.main_clk); + } + + template static inline auto get_nonconst_entities(AllEntities& in) + { + return std::forward_as_tuple(in.lookup_rng_chk_6_inv, + in.lookup_rng_chk_6_counts, + in.range_check_sel_lookup_6, + in.main_sel_rng_16, + in.range_check_u16_r6, + in.main_clk); + } +}; + +template +class lookup_rng_chk_6_relation : public GenericLookupRelation { + public: + static constexpr const char* NAME = "LOOKUP_RNG_CHK_6"; +}; +template using lookup_rng_chk_6 = GenericLookup; + +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_7.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_7.hpp new file mode 100644 index 000000000000..355d956bce8c --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_7.hpp @@ -0,0 +1,64 @@ +// AUTOGENERATED FILE +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +class lookup_rng_chk_7_lookup_settings { + public: + static constexpr size_t READ_TERMS = 1; + static constexpr size_t WRITE_TERMS = 1; + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + static constexpr size_t READ_TERM_DEGREE = 0; + static constexpr size_t WRITE_TERM_DEGREE = 0; + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.range_check_sel_rng_chk == 1 || in.main_sel_rng_16 == 1); + } + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.range_check_sel_rng_chk); + const auto is_table_entry = View(in.main_sel_rng_16); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + template static inline auto get_const_entities(const AllEntities& in) + { + return std::forward_as_tuple(in.lookup_rng_chk_7_inv, + in.lookup_rng_chk_7_counts, + in.range_check_sel_rng_chk, + in.main_sel_rng_16, + in.range_check_u16_r7, + in.main_clk); + } + + template static inline auto get_nonconst_entities(AllEntities& in) + { + return std::forward_as_tuple(in.lookup_rng_chk_7_inv, + in.lookup_rng_chk_7_counts, + in.range_check_sel_rng_chk, + in.main_sel_rng_16, + in.range_check_u16_r7, + in.main_clk); + } +}; + +template +class lookup_rng_chk_7_relation : public GenericLookupRelation { + public: + static constexpr const char* NAME = "LOOKUP_RNG_CHK_7"; +}; +template using lookup_rng_chk_7 = GenericLookup; + +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_diff.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_diff.hpp new file mode 100644 index 000000000000..1e8436a046ca --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_diff.hpp @@ -0,0 +1,64 @@ +// AUTOGENERATED FILE +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +class lookup_rng_chk_diff_lookup_settings { + public: + static constexpr size_t READ_TERMS = 1; + static constexpr size_t WRITE_TERMS = 1; + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + static constexpr size_t LOOKUP_TUPLE_SIZE = 1; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + static constexpr size_t READ_TERM_DEGREE = 0; + static constexpr size_t WRITE_TERM_DEGREE = 0; + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.range_check_sel_rng_chk == 1 || in.main_sel_rng_16 == 1); + } + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.range_check_sel_rng_chk); + const auto is_table_entry = View(in.main_sel_rng_16); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + template static inline auto get_const_entities(const AllEntities& in) + { + return std::forward_as_tuple(in.lookup_rng_chk_diff_inv, + in.lookup_rng_chk_diff_counts, + in.range_check_sel_rng_chk, + in.main_sel_rng_16, + in.range_check_dyn_diff, + in.main_clk); + } + + template static inline auto get_nonconst_entities(AllEntities& in) + { + return std::forward_as_tuple(in.lookup_rng_chk_diff_inv, + in.lookup_rng_chk_diff_counts, + in.range_check_sel_rng_chk, + in.main_sel_rng_16, + in.range_check_dyn_diff, + in.main_clk); + } +}; + +template +class lookup_rng_chk_diff_relation : public GenericLookupRelation { + public: + static constexpr const char* NAME = "LOOKUP_RNG_CHK_DIFF"; +}; +template using lookup_rng_chk_diff = GenericLookup; + +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_pow_2.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_pow_2.hpp new file mode 100644 index 000000000000..47c08e7a0141 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/lookup_rng_chk_pow_2.hpp @@ -0,0 +1,68 @@ +// AUTOGENERATED FILE +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +class lookup_rng_chk_pow_2_lookup_settings { + public: + static constexpr size_t READ_TERMS = 1; + static constexpr size_t WRITE_TERMS = 1; + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + static constexpr size_t LOOKUP_TUPLE_SIZE = 2; + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + static constexpr size_t READ_TERM_DEGREE = 0; + static constexpr size_t WRITE_TERM_DEGREE = 0; + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.range_check_sel_rng_chk == 1 || in.main_sel_rng_8 == 1); + } + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.range_check_sel_rng_chk); + const auto is_table_entry = View(in.main_sel_rng_8); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + template static inline auto get_const_entities(const AllEntities& in) + { + return std::forward_as_tuple(in.lookup_rng_chk_pow_2_inv, + in.lookup_rng_chk_pow_2_counts, + in.range_check_sel_rng_chk, + in.main_sel_rng_8, + in.range_check_dyn_rng_chk_bits, + in.range_check_dyn_rng_chk_pow_2, + in.main_clk, + in.powers_power_of_2); + } + + template static inline auto get_nonconst_entities(AllEntities& in) + { + return std::forward_as_tuple(in.lookup_rng_chk_pow_2_inv, + in.lookup_rng_chk_pow_2_counts, + in.range_check_sel_rng_chk, + in.main_sel_rng_8, + in.range_check_dyn_rng_chk_bits, + in.range_check_dyn_rng_chk_pow_2, + in.main_clk, + in.powers_power_of_2); + } +}; + +template +class lookup_rng_chk_pow_2_relation : public GenericLookupRelation { + public: + static constexpr const char* NAME = "LOOKUP_RNG_CHK_POW_2"; +}; +template using lookup_rng_chk_pow_2 = GenericLookup; + +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/range_check.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/range_check.hpp new file mode 100644 index 000000000000..be65234513fc --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/range_check.hpp @@ -0,0 +1,239 @@ +// AUTOGENERATED FILE +#pragma once + +#include "barretenberg/relations/relation_parameters.hpp" +#include "barretenberg/relations/relation_types.hpp" + +namespace bb::Avm_vm { + +template class range_checkImpl { + public: + using FF = FF_; + + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, + 4, 2, 3, 2, 2, 2, 2, 2, 2, 2 }; + + template + void static accumulate(ContainerOverSubrelations& evals, + const AllEntities& new_term, + [[maybe_unused]] const RelationParameters&, + [[maybe_unused]] const FF& scaling_factor) + { + const auto range_check_X_0 = (new_term.range_check_is_lte_u16 * new_term.range_check_u16_r7); + const auto range_check_X_1 = (new_term.range_check_is_lte_u32 * + (new_term.range_check_u16_r0 + (new_term.range_check_u16_r7 * FF(65536)))); + const auto range_check_X_2 = (new_term.range_check_is_lte_u48 * + ((new_term.range_check_u16_r0 + (new_term.range_check_u16_r1 * FF(65536))) + + (new_term.range_check_u16_r7 * FF(4294967296UL)))); + const auto range_check_X_3 = (new_term.range_check_is_lte_u64 * + (((new_term.range_check_u16_r0 + (new_term.range_check_u16_r1 * FF(65536))) + + (new_term.range_check_u16_r2 * FF(4294967296UL))) + + (new_term.range_check_u16_r7 * FF(281474976710656UL)))); + const auto range_check_X_4 = (new_term.range_check_is_lte_u80 * + ((((new_term.range_check_u16_r0 + (new_term.range_check_u16_r1 * FF(65536))) + + (new_term.range_check_u16_r2 * FF(4294967296UL))) + + (new_term.range_check_u16_r3 * FF(281474976710656UL))) + + (new_term.range_check_u16_r7 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL })))); + const auto range_check_X_5 = (new_term.range_check_is_lte_u96 * + (((((new_term.range_check_u16_r0 + (new_term.range_check_u16_r1 * FF(65536))) + + (new_term.range_check_u16_r2 * FF(4294967296UL))) + + (new_term.range_check_u16_r3 * FF(281474976710656UL))) + + (new_term.range_check_u16_r4 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + + (new_term.range_check_u16_r7 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL })))); + const auto range_check_X_6 = (new_term.range_check_is_lte_u112 * + ((((((new_term.range_check_u16_r0 + (new_term.range_check_u16_r1 * FF(65536))) + + (new_term.range_check_u16_r2 * FF(4294967296UL))) + + (new_term.range_check_u16_r3 * FF(281474976710656UL))) + + (new_term.range_check_u16_r4 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + + (new_term.range_check_u16_r5 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + + (new_term.range_check_u16_r7 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL })))); + const auto range_check_X_7 = + (new_term.range_check_is_lte_u128 * + (((((((new_term.range_check_u16_r0 + (new_term.range_check_u16_r1 * FF(65536))) + + (new_term.range_check_u16_r2 * FF(4294967296UL))) + + (new_term.range_check_u16_r3 * FF(281474976710656UL))) + + (new_term.range_check_u16_r4 * FF(uint256_t{ 0UL, 1UL, 0UL, 0UL }))) + + (new_term.range_check_u16_r5 * FF(uint256_t{ 0UL, 65536UL, 0UL, 0UL }))) + + (new_term.range_check_u16_r6 * FF(uint256_t{ 0UL, 4294967296UL, 0UL, 0UL }))) + + (new_term.range_check_u16_r7 * FF(uint256_t{ 0UL, 281474976710656UL, 0UL, 0UL })))); + const auto range_check_RESULT = + (((((((range_check_X_0 + range_check_X_1) + range_check_X_2) + range_check_X_3) + range_check_X_4) + + range_check_X_5) + + range_check_X_6) + + range_check_X_7); + + { + using Accumulator = typename std::tuple_element_t<0, ContainerOverSubrelations>; + auto tmp = (new_term.range_check_sel_rng_chk * (FF(1) - new_term.range_check_sel_rng_chk)); + tmp *= scaling_factor; + std::get<0>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<1, ContainerOverSubrelations>; + auto tmp = (new_term.range_check_is_lte_u16 * (FF(1) - new_term.range_check_is_lte_u16)); + tmp *= scaling_factor; + std::get<1>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<2, ContainerOverSubrelations>; + auto tmp = (new_term.range_check_is_lte_u32 * (FF(1) - new_term.range_check_is_lte_u32)); + tmp *= scaling_factor; + std::get<2>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<3, ContainerOverSubrelations>; + auto tmp = (new_term.range_check_is_lte_u48 * (FF(1) - new_term.range_check_is_lte_u48)); + tmp *= scaling_factor; + std::get<3>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<4, ContainerOverSubrelations>; + auto tmp = (new_term.range_check_is_lte_u64 * (FF(1) - new_term.range_check_is_lte_u64)); + tmp *= scaling_factor; + std::get<4>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<5, ContainerOverSubrelations>; + auto tmp = (new_term.range_check_is_lte_u80 * (FF(1) - new_term.range_check_is_lte_u80)); + tmp *= scaling_factor; + std::get<5>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<6, ContainerOverSubrelations>; + auto tmp = (new_term.range_check_is_lte_u96 * (FF(1) - new_term.range_check_is_lte_u96)); + tmp *= scaling_factor; + std::get<6>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<7, ContainerOverSubrelations>; + auto tmp = (new_term.range_check_is_lte_u112 * (FF(1) - new_term.range_check_is_lte_u112)); + tmp *= scaling_factor; + std::get<7>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<8, ContainerOverSubrelations>; + auto tmp = (new_term.range_check_is_lte_u128 * (FF(1) - new_term.range_check_is_lte_u128)); + tmp *= scaling_factor; + std::get<8>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<9, ContainerOverSubrelations>; + auto tmp = ((((((((new_term.range_check_is_lte_u16 + new_term.range_check_is_lte_u32) + + new_term.range_check_is_lte_u48) + + new_term.range_check_is_lte_u64) + + new_term.range_check_is_lte_u80) + + new_term.range_check_is_lte_u96) + + new_term.range_check_is_lte_u112) + + new_term.range_check_is_lte_u128) - + new_term.range_check_sel_rng_chk); + tmp *= scaling_factor; + std::get<9>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<10, ContainerOverSubrelations>; + auto tmp = (new_term.range_check_sel_rng_chk * (range_check_RESULT - new_term.range_check_value)); + tmp *= scaling_factor; + std::get<10>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<11, ContainerOverSubrelations>; + auto tmp = (new_term.range_check_dyn_rng_chk_bits - + (((((((new_term.range_check_rng_chk_bits - (new_term.range_check_is_lte_u32 * FF(16))) - + (new_term.range_check_is_lte_u48 * FF(32))) - + (new_term.range_check_is_lte_u64 * FF(48))) - + (new_term.range_check_is_lte_u80 * FF(64))) - + (new_term.range_check_is_lte_u96 * FF(80))) - + (new_term.range_check_is_lte_u112 * FF(96))) - + (new_term.range_check_is_lte_u128 * FF(112)))); + tmp *= scaling_factor; + std::get<11>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<12, ContainerOverSubrelations>; + auto tmp = (new_term.range_check_sel_rng_chk * + (new_term.range_check_dyn_diff - + ((new_term.range_check_dyn_rng_chk_pow_2 - new_term.range_check_u16_r7) - FF(1)))); + tmp *= scaling_factor; + std::get<12>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<13, ContainerOverSubrelations>; + auto tmp = (new_term.range_check_sel_lookup_0 - + ((((((new_term.range_check_is_lte_u32 + new_term.range_check_is_lte_u48) + + new_term.range_check_is_lte_u64) + + new_term.range_check_is_lte_u80) + + new_term.range_check_is_lte_u96) + + new_term.range_check_is_lte_u112) + + new_term.range_check_is_lte_u128)); + tmp *= scaling_factor; + std::get<13>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<14, ContainerOverSubrelations>; + auto tmp = (new_term.range_check_sel_lookup_1 - + (((((new_term.range_check_is_lte_u48 + new_term.range_check_is_lte_u64) + + new_term.range_check_is_lte_u80) + + new_term.range_check_is_lte_u96) + + new_term.range_check_is_lte_u112) + + new_term.range_check_is_lte_u128)); + tmp *= scaling_factor; + std::get<14>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<15, ContainerOverSubrelations>; + auto tmp = (new_term.range_check_sel_lookup_2 - + ((((new_term.range_check_is_lte_u64 + new_term.range_check_is_lte_u80) + + new_term.range_check_is_lte_u96) + + new_term.range_check_is_lte_u112) + + new_term.range_check_is_lte_u128)); + tmp *= scaling_factor; + std::get<15>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<16, ContainerOverSubrelations>; + auto tmp = (new_term.range_check_sel_lookup_3 - + (((new_term.range_check_is_lte_u80 + new_term.range_check_is_lte_u96) + + new_term.range_check_is_lte_u112) + + new_term.range_check_is_lte_u128)); + tmp *= scaling_factor; + std::get<16>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<17, ContainerOverSubrelations>; + auto tmp = (new_term.range_check_sel_lookup_4 - + ((new_term.range_check_is_lte_u96 + new_term.range_check_is_lte_u112) + + new_term.range_check_is_lte_u128)); + tmp *= scaling_factor; + std::get<17>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<18, ContainerOverSubrelations>; + auto tmp = (new_term.range_check_sel_lookup_5 - + (new_term.range_check_is_lte_u112 + new_term.range_check_is_lte_u128)); + tmp *= scaling_factor; + std::get<18>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<19, ContainerOverSubrelations>; + auto tmp = (new_term.range_check_sel_lookup_6 - new_term.range_check_is_lte_u128); + tmp *= scaling_factor; + std::get<19>(evals) += typename Accumulator::View(tmp); + } + } +}; + +template class range_check : public Relation> { + public: + static constexpr const char* NAME = "range_check"; + + static std::string get_subrelation_label(size_t index) + { + switch (index) { + case 10: + return "CHECK_RECOMPOSITION"; + } + return std::to_string(index); + } +}; + +} // namespace bb::Avm_vm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/tests/fuzz_skippable.test.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/tests/fuzz_skippable.test.cpp index f779b412be20..f513cd87cf4f 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/tests/fuzz_skippable.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/tests/fuzz_skippable.test.cpp @@ -83,4 +83,4 @@ TEST(AvmSkippableTests, shouldSkipCorrectly) } } -} // namespace tests_avm \ No newline at end of file +} // namespace tests_avm diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/tests/range_check.test.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/tests/range_check.test.cpp new file mode 100644 index 000000000000..95a4b795338d --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm/avm/tests/range_check.test.cpp @@ -0,0 +1,140 @@ +#include "barretenberg/common/thread.hpp" +#include "barretenberg/vm/avm/generated/circuit_builder.hpp" +#include "barretenberg/vm/avm/generated/flavor.hpp" +#include "barretenberg/vm/avm/generated/full_row.hpp" +#include "barretenberg/vm/avm/trace/fixed_powers.hpp" + +#include "barretenberg/vm/avm/trace/gadgets/range_check.hpp" + +#include +#include +#include +#include + +namespace tests_avm { + +using namespace bb; +using namespace bb::Avm_vm; + +TEST(AvmRangeCheck, shouldRangeCheck) +{ + using FF = AvmFlavor::FF; + constexpr size_t TRACE_SIZE = 1 << 16; + + std::vector> trace(TRACE_SIZE); + + bb::avm_trace::AvmRangeCheckBuilder range_check_builder; + std::cerr << "Generating trace of size " << TRACE_SIZE << "..." << std::endl; + + // Do a bunch of range checks (clk does not matter here so we just have it as 0) + range_check_builder.assert_range(FF(0), 0, EventEmitter::ALU, 0); + range_check_builder.assert_range(FF(0), 1, EventEmitter::ALU, 0); + range_check_builder.assert_range(FF(0), 16, EventEmitter::ALU, 0); + range_check_builder.assert_range(FF(2), 2, EventEmitter::ALU, 0); + range_check_builder.assert_range(FF(255), 8, EventEmitter::ALU, 0); + range_check_builder.assert_range(FF((1 << 16)), 17, EventEmitter::ALU, 0); + range_check_builder.assert_range(FF(1 << 18), 32, EventEmitter::ALU, 0); + range_check_builder.assert_range(FF(uint256_t::from_uint128(uint128_t(1) << 66)), 67, EventEmitter::ALU, 0); + range_check_builder.assert_range(FF(1024), 109, EventEmitter::ALU, 0); + range_check_builder.assert_range(FF(1), 128, EventEmitter::ALU, 0); + + auto finalised_builder = range_check_builder.finalize(); + for (size_t i = 0; i < finalised_builder.size(); i++) { + range_check_builder.merge_into(trace[i], finalised_builder[i]); + } + + for (size_t i = 0; i < TRACE_SIZE; i++) { + // Standard clk, range_check and powers_of_2 + trace[i].main_clk = i; + if (i <= UINT8_MAX) { + trace[i].main_sel_rng_8 = FF(1); + merge_into(trace[i], bb::avm_trace::FixedPowersTable::get().at(i)); + } + trace[i].main_sel_rng_16 = FF(1); + + // Put counts in the right place + trace[i].lookup_rng_chk_0_counts = range_check_builder.u16_range_chk_counters[0][uint16_t(i)]; + trace[i].lookup_rng_chk_1_counts = range_check_builder.u16_range_chk_counters[1][uint16_t(i)]; + trace[i].lookup_rng_chk_2_counts = range_check_builder.u16_range_chk_counters[2][uint16_t(i)]; + trace[i].lookup_rng_chk_3_counts = range_check_builder.u16_range_chk_counters[3][uint16_t(i)]; + trace[i].lookup_rng_chk_4_counts = range_check_builder.u16_range_chk_counters[4][uint16_t(i)]; + trace[i].lookup_rng_chk_5_counts = range_check_builder.u16_range_chk_counters[5][uint16_t(i)]; + trace[i].lookup_rng_chk_6_counts = range_check_builder.u16_range_chk_counters[6][uint16_t(i)]; + trace[i].lookup_rng_chk_7_counts = range_check_builder.u16_range_chk_counters[7][uint16_t(i)]; + trace[i].lookup_rng_chk_diff_counts = range_check_builder.dyn_diff_counts[uint16_t(i)]; + trace[i].lookup_rng_chk_pow_2_counts = range_check_builder.powers_of_2_counts[uint16_t(i)]; + } + std::cerr << "Done generating trace..." << std::endl; + + // We build the polynomials needed to run "sumcheck". + AvmCircuitBuilder cb; + cb.set_trace(std::move(trace)); + auto polys = cb.compute_polynomials(); + const size_t num_rows = polys.get_polynomial_size(); + std::cerr << "Done computing polynomials..." << std::endl; + + std::cerr << "Accumulating relations..." << std::endl; + using Relation = Avm_vm::range_check; + + typename Relation::SumcheckArrayOfValuesOverSubrelations result; + for (auto& r : result) { + r = 0; + } + + // We set the conditions up there. + for (size_t r = 0; r < num_rows; ++r) { + Relation::accumulate(result, polys.get_row(r), {}, 1); + } + + for (size_t j = 0; j < result.size(); ++j) { + if (result[j] != 0) { + EXPECT_EQ(result[j], 0) << "Relation " << Relation::NAME << " subrelation " + << Relation::get_subrelation_label(j) << " was expected to be zero."; + } + } + std::cerr << "Accumulating lookup relations..." << std::endl; + + // Let's be explicit about the lookups we are checking + using AllLookupRelations = std::tuple< + // Lookups + lookup_rng_chk_0_relation, + lookup_rng_chk_1_relation, + lookup_rng_chk_2_relation, + lookup_rng_chk_3_relation, + lookup_rng_chk_4_relation, + lookup_rng_chk_5_relation, + lookup_rng_chk_6_relation, + lookup_rng_chk_7_relation, + lookup_rng_chk_pow_2_relation, + lookup_rng_chk_diff_relation>; + + const FF gamma = FF::random_element(); + const FF beta = FF::random_element(); + bb::RelationParameters params{ + .beta = beta, + .gamma = gamma, + }; + bb::constexpr_for<0, std::tuple_size_v, 1>([&]() { + using LookupRelations = std::tuple_element_t; + + // Check the logderivative relation + bb::compute_logderivative_inverse(polys, params, num_rows); + + typename LookupRelations::SumcheckArrayOfValuesOverSubrelations lookup_result; + + for (auto& r : lookup_result) { + r = 0; + } + for (size_t r = 0; r < num_rows; ++r) { + LookupRelations::accumulate(lookup_result, polys.get_row(r), params, 1); + } + for (const auto& j : lookup_result) { + if (j != 0) { + EXPECT_EQ(j, 0) << "Lookup Relation " << LookupRelations::NAME << " subrelation "; + } + } + }); + std::cerr << "Relations accumulated..." << std::endl; +} + +} // namespace tests_avm diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/range_check.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/range_check.cpp new file mode 100644 index 000000000000..1cc98dfb1b5b --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/range_check.cpp @@ -0,0 +1,53 @@ + +#include "barretenberg/vm/avm/trace/gadgets/range_check.hpp" +namespace bb::avm_trace { + +// This function just enqueues a range check event, we handle processing them later in finalize. +bool AvmRangeCheckBuilder::assert_range(FF value, uint8_t num_bits, EventEmitter e, uint32_t clk) +{ + // We don't support range checks on values that are field-sized + // ASSERT(num_bits <= 128); + range_check_events.push_back({ clk, uint128_t(value), num_bits, e }); + return true; +} +// Turns range check events into real entries +std::vector AvmRangeCheckBuilder::finalize() +{ + std::vector entries; + // Process each range check event into entries + for (auto& event : range_check_events) { + auto entry = RangeCheckEntry{}; + // Set all the easy stuff + entry.clk = event.clk; + entry.value = event.value; + entry.num_bits = event.num_bits; + auto value_u256 = uint256_t::from_uint128(event.value); + + // Now some harder stuff, split the value into 16-bit chunks + for (size_t i = 0; i < 8; i++) { + // The most significant 16-bits have to be placed in the dynamic slice register + if (event.num_bits <= 16) { + entry.dynamic_slice_register = uint16_t(value_u256); + u16_range_chk_counters[7][entry.dynamic_slice_register]++; + // Set the bit range flag at this bit range + entry.bit_range_flag |= 1 << i; + entry.dyn_bits = event.num_bits; + break; + } + // We have more chunks of 16-bits to operate on, so set the ith fixed register + entry.fixed_slice_registers[i] = uint16_t(value_u256); + u16_range_chk_counters[i][uint16_t(value_u256)]++; + event.num_bits -= 16; + value_u256 >>= 16; + } + + // Update the other counters + powers_of_2_counts[entry.dyn_bits]++; + auto dyn_diff = uint16_t((1 << entry.dyn_bits) - entry.dynamic_slice_register - 1); + entry.dyn_diff = dyn_diff; + dyn_diff_counts[dyn_diff]++; + entries.push_back(entry); + } + return entries; +} +} // namespace bb::avm_trace diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/range_check.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/range_check.hpp new file mode 100644 index 000000000000..42f420f85795 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/range_check.hpp @@ -0,0 +1,88 @@ +#pragma once + +#include "barretenberg/vm/avm/generated/relations/range_check.hpp" +#include "barretenberg/vm/avm/trace/common.hpp" +#include + +enum class EventEmitter { + ALU, + MEMORY, +}; + +namespace bb::avm_trace { +class AvmRangeCheckBuilder { + public: + struct RangeCheckEvent { + uint32_t clk; + uint128_t value; + uint8_t num_bits; + EventEmitter emitter; + }; + + struct RangeCheckEntry { + uint32_t clk; + uint128_t value; + uint8_t num_bits; + // 8 total 16-bit registers, the last one is dynamic + std::array fixed_slice_registers; + uint16_t dynamic_slice_register; + // The number of bits that need to be dynamically checked + uint16_t dyn_bits; + // The difference between + uint16_t dyn_diff; + // Bit string representing which of the is_lte_x flags are on + // From LSB to MSB: + // [is_lte_u16, is_lte_u32, is_lte_u48, is_lte_u64, is_lte_u80, is_lte_u96, is_lte_u112, is_lte_u128] + uint8_t bit_range_flag; + }; + + std::array, 8> u16_range_chk_counters; + std::unordered_map powers_of_2_counts; + std::unordered_map dyn_diff_counts; + + // This function just enqueues a range check event, we handle processing them later in finalize. + bool assert_range(FF value, uint8_t num_bits, EventEmitter e, uint32_t clk); + + // Turns range check events into real entries + std::vector finalize(); + + template void merge_into(DestRow& row, RangeCheckEntry const& entry) + { + row.range_check_sel_rng_chk = FF::one(); + row.range_check_value = entry.value; + row.range_check_rng_chk_bits = entry.num_bits; + row.range_check_dyn_rng_chk_bits = entry.dyn_bits; + row.range_check_dyn_rng_chk_pow_2 = 1 << entry.dyn_bits; + row.range_check_dyn_diff = entry.dyn_diff; + + // The position of the set bit in the bit_range_flag tells us which flag to set + row.range_check_is_lte_u16 = entry.bit_range_flag & 1; + row.range_check_is_lte_u32 = entry.bit_range_flag >> 1 & 1; + row.range_check_is_lte_u48 = entry.bit_range_flag >> 2 & 1; + row.range_check_is_lte_u64 = entry.bit_range_flag >> 3 & 1; + row.range_check_is_lte_u80 = entry.bit_range_flag >> 4 & 1; + row.range_check_is_lte_u96 = entry.bit_range_flag >> 5 & 1; + row.range_check_is_lte_u112 = entry.bit_range_flag >> 6 & 1; + row.range_check_is_lte_u128 = entry.bit_range_flag >> 7 & 1; + // The value of the bit_range_flag tells us registers are part of the range check + row.range_check_sel_lookup_0 = entry.bit_range_flag >= 2; + row.range_check_sel_lookup_1 = entry.bit_range_flag >= 4; + row.range_check_sel_lookup_2 = entry.bit_range_flag >= 8; + row.range_check_sel_lookup_3 = entry.bit_range_flag >= 16; + row.range_check_sel_lookup_4 = entry.bit_range_flag >= 32; + row.range_check_sel_lookup_5 = entry.bit_range_flag >= 64; + row.range_check_sel_lookup_6 = entry.bit_range_flag >= 128; + row.range_check_u16_r0 = entry.fixed_slice_registers[0]; + row.range_check_u16_r1 = entry.fixed_slice_registers[1]; + row.range_check_u16_r2 = entry.fixed_slice_registers[2]; + row.range_check_u16_r3 = entry.fixed_slice_registers[3]; + row.range_check_u16_r4 = entry.fixed_slice_registers[4]; + row.range_check_u16_r5 = entry.fixed_slice_registers[5]; + row.range_check_u16_r6 = entry.fixed_slice_registers[6]; + row.range_check_u16_r7 = entry.dynamic_slice_register; + } + + private: + std::vector range_check_events; +}; +} // namespace bb::avm_trace