From 6e2a4e174002052ac2e9a7acfdd7323c39198366 Mon Sep 17 00:00:00 2001 From: dbanks12 Date: Fri, 11 Oct 2024 19:20:07 +0000 Subject: [PATCH] feat\!: remove hash opcodes from AVM --- avm-transpiler/src/opcodes.rs | 8 +- avm-transpiler/src/transpile.rs | 53 +- barretenberg/cpp/pil/avm/gadgets/pedersen.pil | 11 - barretenberg/cpp/pil/avm/main.pil | 30 +- .../vm/avm/generated/circuit_builder.cpp | 6 - .../barretenberg/vm/avm/generated/flavor.cpp | 1073 ++++++++--------- .../barretenberg/vm/avm/generated/flavor.hpp | 16 +- .../vm/avm/generated/full_row.cpp | 18 +- .../vm/avm/generated/full_row.hpp | 11 +- .../vm/avm/generated/relations/main.hpp | 276 ++--- .../vm/avm/generated/relations/pedersen.hpp | 42 - .../generated/relations/perm_main_keccak.hpp | 57 + .../relations/perm_main_pedersen.hpp | 53 - .../generated/relations/perm_main_sha256.hpp | 61 + .../vm/avm/tests/execution.test.cpp | 212 +--- .../vm/avm/trace/deserialization.cpp | 11 +- .../barretenberg/vm/avm/trace/execution.cpp | 52 +- .../barretenberg/vm/avm/trace/fixed_gas.cpp | 6 +- .../vm/avm/trace/gadgets/keccak.cpp | 40 - .../vm/avm/trace/gadgets/keccak.hpp | 1 - .../vm/avm/trace/gadgets/pedersen.cpp | 29 - .../vm/avm/trace/gadgets/pedersen.hpp | 32 - .../vm/avm/trace/gadgets/sha256.cpp | 8 - .../vm/avm/trace/gadgets/sha256.hpp | 1 - .../src/barretenberg/vm/avm/trace/opcode.cpp | 6 +- .../src/barretenberg/vm/avm/trace/opcode.hpp | 5 +- .../src/barretenberg/vm/avm/trace/trace.cpp | 449 +++---- .../src/barretenberg/vm/avm/trace/trace.hpp | 12 - .../src/barretenberg/vm/aztec_constants.hpp | 14 +- .../crates/types/src/constants.nr | 16 +- yarn-project/circuits.js/src/constants.gen.ts | 14 +- yarn-project/simulator/src/avm/avm_gas.ts | 5 - .../src/avm/opcodes/commitment.test.ts | 120 -- .../simulator/src/avm/opcodes/commitment.ts | 65 - .../simulator/src/avm/opcodes/hashing.test.ts | 150 +-- .../simulator/src/avm/opcodes/hashing.ts | 106 +- .../simulator/src/avm/opcodes/index.ts | 1 - .../serialization/bytecode_serialization.ts | 6 - .../instruction_serialization.ts | 3 - 39 files changed, 994 insertions(+), 2085 deletions(-) delete mode 100644 barretenberg/cpp/pil/avm/gadgets/pedersen.pil delete mode 100644 barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/pedersen.hpp create mode 100644 barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/perm_main_keccak.hpp delete mode 100644 barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/perm_main_pedersen.hpp create mode 100644 barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/perm_main_sha256.hpp delete mode 100644 barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/pedersen.cpp delete mode 100644 barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/pedersen.hpp delete mode 100644 yarn-project/simulator/src/avm/opcodes/commitment.test.ts delete mode 100644 yarn-project/simulator/src/avm/opcodes/commitment.ts diff --git a/avm-transpiler/src/opcodes.rs b/avm-transpiler/src/opcodes.rs index 1de1f7803c8..d3ad47af1f4 100644 --- a/avm-transpiler/src/opcodes.rs +++ b/avm-transpiler/src/opcodes.rs @@ -72,14 +72,11 @@ pub enum AvmOpcode { // Misc DEBUGLOG, // Gadgets - KECCAK, POSEIDON2, SHA256COMPRESSION, KECCAKF1600, - PEDERSEN, // temp - may be removed, but alot of contracts rely on it ECADD, MSM, - PEDERSENCOMMITMENT, // temp // Conversions TORADIXLE, } @@ -170,14 +167,11 @@ impl AvmOpcode { AvmOpcode::DEBUGLOG => "DEBUGLOG", // Gadgets - AvmOpcode::KECCAK => "KECCAK", - AvmOpcode::KECCAKF1600 => "KECCAKF1600", AvmOpcode::POSEIDON2 => "POSEIDON2", AvmOpcode::SHA256COMPRESSION => "SHA256COMPRESSION", - AvmOpcode::PEDERSEN => "PEDERSEN", + AvmOpcode::KECCAKF1600 => "KECCAKF1600", AvmOpcode::ECADD => "ECADD", AvmOpcode::MSM => "MSM", - AvmOpcode::PEDERSENCOMMITMENT => "PEDERSENCOMMITMENT", // Conversions AvmOpcode::TORADIXLE => "TORADIXLE", } diff --git a/avm-transpiler/src/transpile.rs b/avm-transpiler/src/transpile.rs index 1b48fa90b7d..c453c1476f2 100644 --- a/avm-transpiler/src/transpile.rs +++ b/avm-transpiler/src/transpile.rs @@ -963,7 +963,7 @@ fn generate_mov_instruction( } } -/// Black box functions, for the meantime only covers pedersen operations as the blackbox function api suits our current needs. +/// Black box functions /// (array goes in -> field element comes out) fn handle_black_box_function(avm_instrs: &mut Vec, operation: &BlackBoxOp) { match operation { @@ -989,32 +989,6 @@ fn handle_black_box_function(avm_instrs: &mut Vec, operation: &B ..Default::default() }); } - BlackBoxOp::PedersenHash { inputs, domain_separator, output } => { - let message_offset = inputs.pointer.to_usize(); - let message_size_offset = inputs.size.to_usize(); - - let index_offset = domain_separator.to_usize(); - let dest_offset = output.to_usize(); - - avm_instrs.push(AvmInstruction { - opcode: AvmOpcode::PEDERSEN, - indirect: Some( - AddressingModeBuilder::default() - .direct_operand(domain_separator) - .direct_operand(output) - .indirect_operand(&inputs.pointer) - .direct_operand(&inputs.size) - .build(), - ), - operands: vec![ - AvmOperand::U32 { value: index_offset as u32 }, - AvmOperand::U32 { value: dest_offset as u32 }, - AvmOperand::U32 { value: message_offset as u32 }, - AvmOperand::U32 { value: message_size_offset as u32 }, - ], - ..Default::default() - }); - } BlackBoxOp::Poseidon2Permutation { message, output, @@ -1151,31 +1125,6 @@ fn handle_black_box_function(avm_instrs: &mut Vec, operation: &B ..Default::default() }); } - // Temporary while we dont have efficient noir implementations (again) - BlackBoxOp::PedersenCommitment { inputs, domain_separator, output } => { - let input_offset = inputs.pointer.to_usize(); - let input_size_offset = inputs.size.to_usize(); - let index_offset = domain_separator.to_usize(); - let output_offset = output.pointer.to_usize(); - avm_instrs.push(AvmInstruction { - opcode: AvmOpcode::PEDERSENCOMMITMENT, - indirect: Some( - AddressingModeBuilder::default() - .indirect_operand(&inputs.pointer) - .indirect_operand(&output.pointer) - .direct_operand(&inputs.size) - .direct_operand(domain_separator) - .build(), - ), - operands: vec![ - AvmOperand::U32 { value: input_offset as u32 }, - AvmOperand::U32 { value: output_offset as u32 }, - AvmOperand::U32 { value: input_size_offset as u32 }, - AvmOperand::U32 { value: index_offset as u32 }, - ], - ..Default::default() - }); - } _ => panic!("Transpiler doesn't know how to process {:?}", operation), } } diff --git a/barretenberg/cpp/pil/avm/gadgets/pedersen.pil b/barretenberg/cpp/pil/avm/gadgets/pedersen.pil deleted file mode 100644 index cf881233ca4..00000000000 --- a/barretenberg/cpp/pil/avm/gadgets/pedersen.pil +++ /dev/null @@ -1,11 +0,0 @@ -namespace pedersen(256); - - pol commit clk; - - // Selector for Pedersen Hash Operation - pol commit sel_pedersen; - sel_pedersen * (1 - sel_pedersen) = 0; - - // These will all be arrays, but we just store the first element for permutation to the main trace for now - pol commit input; - pol commit output; diff --git a/barretenberg/cpp/pil/avm/main.pil b/barretenberg/cpp/pil/avm/main.pil index 1ea776c0490..88dbf576901 100644 --- a/barretenberg/cpp/pil/avm/main.pil +++ b/barretenberg/cpp/pil/avm/main.pil @@ -10,7 +10,6 @@ include "gadgets/conversion.pil"; include "gadgets/sha256.pil"; include "gadgets/poseidon2.pil"; include "gadgets/keccakf1600.pil"; -include "gadgets/pedersen.pil"; include "gadgets/mem_slice.pil"; namespace main(256); @@ -89,9 +88,7 @@ namespace main(256); pol commit sel_op_sha256; pol commit sel_op_poseidon2; pol commit sel_op_keccak; - pol commit sel_op_pedersen; pol commit sel_op_ecadd; - pol commit sel_op_pedersen_commit; pol commit sel_op_msm; //===== Memory Slice Gadget Selectors ========================================= @@ -250,9 +247,7 @@ namespace main(256); sel_op_sha256 * (1 - sel_op_sha256) = 0; sel_op_poseidon2 * (1 - sel_op_poseidon2) = 0; sel_op_keccak * (1 - sel_op_keccak) = 0; - sel_op_pedersen * (1 - sel_op_pedersen) = 0; sel_op_ecadd * (1 - sel_op_ecadd) = 0; - sel_op_pedersen_commit * (1 - sel_op_pedersen_commit) = 0; sel_op_msm * (1 - sel_op_msm) = 0; sel_op_add * (1 - sel_op_add) = 0; @@ -421,8 +416,8 @@ namespace main(256); pol SEL_ALL_ALU = SEL_ALU_R_TAG + SEL_ALU_W_TAG; pol SEL_ALL_LEFTGAS = sel_op_dagasleft + sel_op_l2gasleft; pol SEL_ALL_BINARY = sel_op_and + sel_op_or + sel_op_xor; - pol SEL_ALL_GADGET = sel_op_radix_le + sel_op_sha256 + sel_op_poseidon2 + sel_op_keccak + sel_op_pedersen - + sel_op_ecadd + sel_op_pedersen_commit + sel_op_msm; + pol SEL_ALL_GADGET = sel_op_radix_le + sel_op_sha256 + sel_op_poseidon2 + sel_op_keccak + + sel_op_ecadd + sel_op_msm; pol SEL_ALL_MEMORY = sel_op_mov + sel_op_set; pol OPCODE_SELECTORS = sel_op_fdiv + sel_op_calldata_copy + sel_op_get_contract_instance + SEL_ALL_ALU + SEL_ALL_BINARY + SEL_ALL_MEMORY + SEL_ALL_GADGET @@ -546,11 +541,10 @@ namespace main(256); is conversion.sel_to_radix_le {conversion.clk, conversion.input, conversion.radix, conversion.num_limbs, conversion.output_bits}; - // This will be enabled when we migrate just to sha256Compression, as getting sha256 to work with it is tricky. - // #[PERM_MAIN_SHA256] - // sel_op_sha256 {clk, ia, ib, ic} - // is - // sha256.sel_sha256_compression {sha256.clk, sha256.state, sha256.input, sha256.output}; + #[PERM_MAIN_SHA256] + sel_op_sha256 {clk, ia, ib, ic} + is + sha256.sel_sha256_compression {sha256.clk, sha256.state, sha256.input, sha256.output}; // Mem_addr_a points to the start of the input array of length 4 // Mem_addr_b points to the start of the output array of length 4 @@ -559,16 +553,10 @@ namespace main(256); is poseidon2.sel_poseidon_perm {poseidon2.clk, poseidon2.input_addr, poseidon2.output_addr}; - // This will be enabled when we migrate just to keccakf1600, as getting keccak to work with it is tricky. - // #[PERM_MAIN_KECCAK] - // sel_op_keccak {clk, ia, ic} - // is - // keccakf1600.sel_keccakf1600 {keccakf1600.clk, keccakf1600.input, keccakf1600.output}; - - #[PERM_MAIN_PEDERSEN] - sel_op_pedersen {clk, ia} + #[PERM_MAIN_KECCAK] + sel_op_keccak {clk, ia, ic} is - pedersen.sel_pedersen {pedersen.clk, pedersen.input}; + keccakf1600.sel_keccakf1600 {keccakf1600.clk, keccakf1600.input, keccakf1600.output}; #[PERM_MAIN_SLICE] sel_slice_gadget {clk, space_id, ia, ib, mem_addr_c, sel_op_calldata_copy, sel_op_external_return} 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 ed5d12ccac6..6d979d4c887 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/circuit_builder.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/circuit_builder.cpp @@ -280,8 +280,6 @@ AvmCircuitBuilder::ProverPolynomials AvmCircuitBuilder::compute_polynomials() co polys.main_sel_op_note_hash_exists.set_if_valid_index(i, rows[i].main_sel_op_note_hash_exists); polys.main_sel_op_nullifier_exists.set_if_valid_index(i, rows[i].main_sel_op_nullifier_exists); polys.main_sel_op_or.set_if_valid_index(i, rows[i].main_sel_op_or); - polys.main_sel_op_pedersen.set_if_valid_index(i, rows[i].main_sel_op_pedersen); - polys.main_sel_op_pedersen_commit.set_if_valid_index(i, rows[i].main_sel_op_pedersen_commit); polys.main_sel_op_poseidon2.set_if_valid_index(i, rows[i].main_sel_op_poseidon2); polys.main_sel_op_radix_le.set_if_valid_index(i, rows[i].main_sel_op_radix_le); polys.main_sel_op_sender.set_if_valid_index(i, rows[i].main_sel_op_sender); @@ -351,10 +349,6 @@ AvmCircuitBuilder::ProverPolynomials AvmCircuitBuilder::compute_polynomials() co polys.mem_tsp.set_if_valid_index(i, rows[i].mem_tsp); polys.mem_val.set_if_valid_index(i, rows[i].mem_val); polys.mem_w_in_tag.set_if_valid_index(i, rows[i].mem_w_in_tag); - polys.pedersen_clk.set_if_valid_index(i, rows[i].pedersen_clk); - polys.pedersen_input.set_if_valid_index(i, rows[i].pedersen_input); - polys.pedersen_output.set_if_valid_index(i, rows[i].pedersen_output); - polys.pedersen_sel_pedersen.set_if_valid_index(i, rows[i].pedersen_sel_pedersen); polys.poseidon2_B_10_0.set_if_valid_index(i, rows[i].poseidon2_B_10_0); polys.poseidon2_B_10_1.set_if_valid_index(i, rows[i].poseidon2_B_10_1); polys.poseidon2_B_10_2.set_if_valid_index(i, rows[i].poseidon2_B_10_2); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp index 4e2a5a5290f..43803c8d702 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp @@ -230,536 +230,531 @@ AvmFlavor::AllConstRefValues::AllConstRefValues( , main_sel_op_note_hash_exists(il[222]) , main_sel_op_nullifier_exists(il[223]) , main_sel_op_or(il[224]) - , main_sel_op_pedersen(il[225]) - , main_sel_op_pedersen_commit(il[226]) - , main_sel_op_poseidon2(il[227]) - , main_sel_op_radix_le(il[228]) - , main_sel_op_sender(il[229]) - , main_sel_op_set(il[230]) - , main_sel_op_sha256(il[231]) - , main_sel_op_shl(il[232]) - , main_sel_op_shr(il[233]) - , main_sel_op_sload(il[234]) - , main_sel_op_sstore(il[235]) - , main_sel_op_static_call(il[236]) - , main_sel_op_storage_address(il[237]) - , main_sel_op_sub(il[238]) - , main_sel_op_timestamp(il[239]) - , main_sel_op_transaction_fee(il[240]) - , main_sel_op_version(il[241]) - , main_sel_op_xor(il[242]) - , main_sel_q_kernel_lookup(il[243]) - , main_sel_q_kernel_output_lookup(il[244]) - , main_sel_resolve_ind_addr_a(il[245]) - , main_sel_resolve_ind_addr_b(il[246]) - , main_sel_resolve_ind_addr_c(il[247]) - , main_sel_resolve_ind_addr_d(il[248]) - , main_sel_returndata(il[249]) - , main_sel_rng_16(il[250]) - , main_sel_rng_8(il[251]) - , main_sel_slice_gadget(il[252]) - , main_side_effect_counter(il[253]) - , main_sload_write_offset(il[254]) - , main_space_id(il[255]) - , main_sstore_write_offset(il[256]) - , main_tag_err(il[257]) - , main_w_in_tag(il[258]) - , mem_addr(il[259]) - , mem_clk(il[260]) - , mem_diff(il[261]) - , mem_glob_addr(il[262]) - , mem_last(il[263]) - , mem_lastAccess(il[264]) - , mem_one_min_inv(il[265]) - , mem_r_in_tag(il[266]) - , mem_rw(il[267]) - , mem_sel_mem(il[268]) - , mem_sel_mov_ia_to_ic(il[269]) - , mem_sel_mov_ib_to_ic(il[270]) - , mem_sel_op_a(il[271]) - , mem_sel_op_b(il[272]) - , mem_sel_op_c(il[273]) - , mem_sel_op_d(il[274]) - , mem_sel_op_poseidon_read_a(il[275]) - , mem_sel_op_poseidon_read_b(il[276]) - , mem_sel_op_poseidon_read_c(il[277]) - , mem_sel_op_poseidon_read_d(il[278]) - , mem_sel_op_poseidon_write_a(il[279]) - , mem_sel_op_poseidon_write_b(il[280]) - , mem_sel_op_poseidon_write_c(il[281]) - , mem_sel_op_poseidon_write_d(il[282]) - , mem_sel_op_slice(il[283]) - , mem_sel_resolve_ind_addr_a(il[284]) - , mem_sel_resolve_ind_addr_b(il[285]) - , mem_sel_resolve_ind_addr_c(il[286]) - , mem_sel_resolve_ind_addr_d(il[287]) - , mem_sel_rng_chk(il[288]) - , mem_skip_check_tag(il[289]) - , mem_space_id(il[290]) - , mem_tag(il[291]) - , mem_tag_err(il[292]) - , mem_tsp(il[293]) - , mem_val(il[294]) - , mem_w_in_tag(il[295]) - , pedersen_clk(il[296]) - , pedersen_input(il[297]) - , pedersen_output(il[298]) - , pedersen_sel_pedersen(il[299]) - , poseidon2_B_10_0(il[300]) - , poseidon2_B_10_1(il[301]) - , poseidon2_B_10_2(il[302]) - , poseidon2_B_10_3(il[303]) - , poseidon2_B_11_0(il[304]) - , poseidon2_B_11_1(il[305]) - , poseidon2_B_11_2(il[306]) - , poseidon2_B_11_3(il[307]) - , poseidon2_B_12_0(il[308]) - , poseidon2_B_12_1(il[309]) - , poseidon2_B_12_2(il[310]) - , poseidon2_B_12_3(il[311]) - , poseidon2_B_13_0(il[312]) - , poseidon2_B_13_1(il[313]) - , poseidon2_B_13_2(il[314]) - , poseidon2_B_13_3(il[315]) - , poseidon2_B_14_0(il[316]) - , poseidon2_B_14_1(il[317]) - , poseidon2_B_14_2(il[318]) - , poseidon2_B_14_3(il[319]) - , poseidon2_B_15_0(il[320]) - , poseidon2_B_15_1(il[321]) - , poseidon2_B_15_2(il[322]) - , poseidon2_B_15_3(il[323]) - , poseidon2_B_16_0(il[324]) - , poseidon2_B_16_1(il[325]) - , poseidon2_B_16_2(il[326]) - , poseidon2_B_16_3(il[327]) - , poseidon2_B_17_0(il[328]) - , poseidon2_B_17_1(il[329]) - , poseidon2_B_17_2(il[330]) - , poseidon2_B_17_3(il[331]) - , poseidon2_B_18_0(il[332]) - , poseidon2_B_18_1(il[333]) - , poseidon2_B_18_2(il[334]) - , poseidon2_B_18_3(il[335]) - , poseidon2_B_19_0(il[336]) - , poseidon2_B_19_1(il[337]) - , poseidon2_B_19_2(il[338]) - , poseidon2_B_19_3(il[339]) - , poseidon2_B_20_0(il[340]) - , poseidon2_B_20_1(il[341]) - , poseidon2_B_20_2(il[342]) - , poseidon2_B_20_3(il[343]) - , poseidon2_B_21_0(il[344]) - , poseidon2_B_21_1(il[345]) - , poseidon2_B_21_2(il[346]) - , poseidon2_B_21_3(il[347]) - , poseidon2_B_22_0(il[348]) - , poseidon2_B_22_1(il[349]) - , poseidon2_B_22_2(il[350]) - , poseidon2_B_22_3(il[351]) - , poseidon2_B_23_0(il[352]) - , poseidon2_B_23_1(il[353]) - , poseidon2_B_23_2(il[354]) - , poseidon2_B_23_3(il[355]) - , poseidon2_B_24_0(il[356]) - , poseidon2_B_24_1(il[357]) - , poseidon2_B_24_2(il[358]) - , poseidon2_B_24_3(il[359]) - , poseidon2_B_25_0(il[360]) - , poseidon2_B_25_1(il[361]) - , poseidon2_B_25_2(il[362]) - , poseidon2_B_25_3(il[363]) - , poseidon2_B_26_0(il[364]) - , poseidon2_B_26_1(il[365]) - , poseidon2_B_26_2(il[366]) - , poseidon2_B_26_3(il[367]) - , poseidon2_B_27_0(il[368]) - , poseidon2_B_27_1(il[369]) - , poseidon2_B_27_2(il[370]) - , poseidon2_B_27_3(il[371]) - , poseidon2_B_28_0(il[372]) - , poseidon2_B_28_1(il[373]) - , poseidon2_B_28_2(il[374]) - , poseidon2_B_28_3(il[375]) - , poseidon2_B_29_0(il[376]) - , poseidon2_B_29_1(il[377]) - , poseidon2_B_29_2(il[378]) - , poseidon2_B_29_3(il[379]) - , poseidon2_B_30_0(il[380]) - , poseidon2_B_30_1(il[381]) - , poseidon2_B_30_2(il[382]) - , poseidon2_B_30_3(il[383]) - , poseidon2_B_31_0(il[384]) - , poseidon2_B_31_1(il[385]) - , poseidon2_B_31_2(il[386]) - , poseidon2_B_31_3(il[387]) - , poseidon2_B_32_0(il[388]) - , poseidon2_B_32_1(il[389]) - , poseidon2_B_32_2(il[390]) - , poseidon2_B_32_3(il[391]) - , poseidon2_B_33_0(il[392]) - , poseidon2_B_33_1(il[393]) - , poseidon2_B_33_2(il[394]) - , poseidon2_B_33_3(il[395]) - , poseidon2_B_34_0(il[396]) - , poseidon2_B_34_1(il[397]) - , poseidon2_B_34_2(il[398]) - , poseidon2_B_34_3(il[399]) - , poseidon2_B_35_0(il[400]) - , poseidon2_B_35_1(il[401]) - , poseidon2_B_35_2(il[402]) - , poseidon2_B_35_3(il[403]) - , poseidon2_B_36_0(il[404]) - , poseidon2_B_36_1(il[405]) - , poseidon2_B_36_2(il[406]) - , poseidon2_B_36_3(il[407]) - , poseidon2_B_37_0(il[408]) - , poseidon2_B_37_1(il[409]) - , poseidon2_B_37_2(il[410]) - , poseidon2_B_37_3(il[411]) - , poseidon2_B_38_0(il[412]) - , poseidon2_B_38_1(il[413]) - , poseidon2_B_38_2(il[414]) - , poseidon2_B_38_3(il[415]) - , poseidon2_B_39_0(il[416]) - , poseidon2_B_39_1(il[417]) - , poseidon2_B_39_2(il[418]) - , poseidon2_B_39_3(il[419]) - , poseidon2_B_40_0(il[420]) - , poseidon2_B_40_1(il[421]) - , poseidon2_B_40_2(il[422]) - , poseidon2_B_40_3(il[423]) - , poseidon2_B_41_0(il[424]) - , poseidon2_B_41_1(il[425]) - , poseidon2_B_41_2(il[426]) - , poseidon2_B_41_3(il[427]) - , poseidon2_B_42_0(il[428]) - , poseidon2_B_42_1(il[429]) - , poseidon2_B_42_2(il[430]) - , poseidon2_B_42_3(il[431]) - , poseidon2_B_43_0(il[432]) - , poseidon2_B_43_1(il[433]) - , poseidon2_B_43_2(il[434]) - , poseidon2_B_43_3(il[435]) - , poseidon2_B_44_0(il[436]) - , poseidon2_B_44_1(il[437]) - , poseidon2_B_44_2(il[438]) - , poseidon2_B_44_3(il[439]) - , poseidon2_B_45_0(il[440]) - , poseidon2_B_45_1(il[441]) - , poseidon2_B_45_2(il[442]) - , poseidon2_B_45_3(il[443]) - , poseidon2_B_46_0(il[444]) - , poseidon2_B_46_1(il[445]) - , poseidon2_B_46_2(il[446]) - , poseidon2_B_46_3(il[447]) - , poseidon2_B_47_0(il[448]) - , poseidon2_B_47_1(il[449]) - , poseidon2_B_47_2(il[450]) - , poseidon2_B_47_3(il[451]) - , poseidon2_B_48_0(il[452]) - , poseidon2_B_48_1(il[453]) - , poseidon2_B_48_2(il[454]) - , poseidon2_B_48_3(il[455]) - , poseidon2_B_49_0(il[456]) - , poseidon2_B_49_1(il[457]) - , poseidon2_B_49_2(il[458]) - , poseidon2_B_49_3(il[459]) - , poseidon2_B_4_0(il[460]) - , poseidon2_B_4_1(il[461]) - , poseidon2_B_4_2(il[462]) - , poseidon2_B_4_3(il[463]) - , poseidon2_B_50_0(il[464]) - , poseidon2_B_50_1(il[465]) - , poseidon2_B_50_2(il[466]) - , poseidon2_B_50_3(il[467]) - , poseidon2_B_51_0(il[468]) - , poseidon2_B_51_1(il[469]) - , poseidon2_B_51_2(il[470]) - , poseidon2_B_51_3(il[471]) - , poseidon2_B_52_0(il[472]) - , poseidon2_B_52_1(il[473]) - , poseidon2_B_52_2(il[474]) - , poseidon2_B_52_3(il[475]) - , poseidon2_B_53_0(il[476]) - , poseidon2_B_53_1(il[477]) - , poseidon2_B_53_2(il[478]) - , poseidon2_B_53_3(il[479]) - , poseidon2_B_54_0(il[480]) - , poseidon2_B_54_1(il[481]) - , poseidon2_B_54_2(il[482]) - , poseidon2_B_54_3(il[483]) - , poseidon2_B_55_0(il[484]) - , poseidon2_B_55_1(il[485]) - , poseidon2_B_55_2(il[486]) - , poseidon2_B_55_3(il[487]) - , poseidon2_B_56_0(il[488]) - , poseidon2_B_56_1(il[489]) - , poseidon2_B_56_2(il[490]) - , poseidon2_B_56_3(il[491]) - , poseidon2_B_57_0(il[492]) - , poseidon2_B_57_1(il[493]) - , poseidon2_B_57_2(il[494]) - , poseidon2_B_57_3(il[495]) - , poseidon2_B_58_0(il[496]) - , poseidon2_B_58_1(il[497]) - , poseidon2_B_58_2(il[498]) - , poseidon2_B_58_3(il[499]) - , poseidon2_B_59_0(il[500]) - , poseidon2_B_59_1(il[501]) - , poseidon2_B_59_2(il[502]) - , poseidon2_B_59_3(il[503]) - , poseidon2_B_5_0(il[504]) - , poseidon2_B_5_1(il[505]) - , poseidon2_B_5_2(il[506]) - , poseidon2_B_5_3(il[507]) - , poseidon2_B_6_0(il[508]) - , poseidon2_B_6_1(il[509]) - , poseidon2_B_6_2(il[510]) - , poseidon2_B_6_3(il[511]) - , poseidon2_B_7_0(il[512]) - , poseidon2_B_7_1(il[513]) - , poseidon2_B_7_2(il[514]) - , poseidon2_B_7_3(il[515]) - , poseidon2_B_8_0(il[516]) - , poseidon2_B_8_1(il[517]) - , poseidon2_B_8_2(il[518]) - , poseidon2_B_8_3(il[519]) - , poseidon2_B_9_0(il[520]) - , poseidon2_B_9_1(il[521]) - , poseidon2_B_9_2(il[522]) - , poseidon2_B_9_3(il[523]) - , poseidon2_EXT_LAYER_4(il[524]) - , poseidon2_EXT_LAYER_5(il[525]) - , poseidon2_EXT_LAYER_6(il[526]) - , poseidon2_EXT_LAYER_7(il[527]) - , poseidon2_T_0_4(il[528]) - , poseidon2_T_0_5(il[529]) - , poseidon2_T_0_6(il[530]) - , poseidon2_T_0_7(il[531]) - , poseidon2_T_1_4(il[532]) - , poseidon2_T_1_5(il[533]) - , poseidon2_T_1_6(il[534]) - , poseidon2_T_1_7(il[535]) - , poseidon2_T_2_4(il[536]) - , poseidon2_T_2_5(il[537]) - , poseidon2_T_2_6(il[538]) - , poseidon2_T_2_7(il[539]) - , poseidon2_T_3_4(il[540]) - , poseidon2_T_3_5(il[541]) - , poseidon2_T_3_6(il[542]) - , poseidon2_T_3_7(il[543]) - , poseidon2_T_60_4(il[544]) - , poseidon2_T_60_5(il[545]) - , poseidon2_T_60_6(il[546]) - , poseidon2_T_60_7(il[547]) - , poseidon2_T_61_4(il[548]) - , poseidon2_T_61_5(il[549]) - , poseidon2_T_61_6(il[550]) - , poseidon2_T_61_7(il[551]) - , poseidon2_T_62_4(il[552]) - , poseidon2_T_62_5(il[553]) - , poseidon2_T_62_6(il[554]) - , poseidon2_T_62_7(il[555]) - , poseidon2_T_63_4(il[556]) - , poseidon2_T_63_5(il[557]) - , poseidon2_T_63_6(il[558]) - , poseidon2_T_63_7(il[559]) - , poseidon2_a_0(il[560]) - , poseidon2_a_1(il[561]) - , poseidon2_a_2(il[562]) - , poseidon2_a_3(il[563]) - , poseidon2_b_0(il[564]) - , poseidon2_b_1(il[565]) - , poseidon2_b_2(il[566]) - , poseidon2_b_3(il[567]) - , poseidon2_clk(il[568]) - , poseidon2_input_addr(il[569]) - , poseidon2_mem_addr_read_a(il[570]) - , poseidon2_mem_addr_read_b(il[571]) - , poseidon2_mem_addr_read_c(il[572]) - , poseidon2_mem_addr_read_d(il[573]) - , poseidon2_mem_addr_write_a(il[574]) - , poseidon2_mem_addr_write_b(il[575]) - , poseidon2_mem_addr_write_c(il[576]) - , poseidon2_mem_addr_write_d(il[577]) - , poseidon2_output_addr(il[578]) - , poseidon2_sel_poseidon_perm(il[579]) - , range_check_alu_rng_chk(il[580]) - , range_check_clk(il[581]) - , range_check_cmp_hi_bits_rng_chk(il[582]) - , range_check_cmp_lo_bits_rng_chk(il[583]) - , range_check_dyn_diff(il[584]) - , range_check_dyn_rng_chk_bits(il[585]) - , range_check_dyn_rng_chk_pow_2(il[586]) - , range_check_gas_da_rng_chk(il[587]) - , range_check_gas_l2_rng_chk(il[588]) - , range_check_is_lte_u112(il[589]) - , range_check_is_lte_u128(il[590]) - , range_check_is_lte_u16(il[591]) - , range_check_is_lte_u32(il[592]) - , range_check_is_lte_u48(il[593]) - , range_check_is_lte_u64(il[594]) - , range_check_is_lte_u80(il[595]) - , range_check_is_lte_u96(il[596]) - , range_check_mem_rng_chk(il[597]) - , range_check_rng_chk_bits(il[598]) - , range_check_sel_lookup_0(il[599]) - , range_check_sel_lookup_1(il[600]) - , range_check_sel_lookup_2(il[601]) - , range_check_sel_lookup_3(il[602]) - , range_check_sel_lookup_4(il[603]) - , range_check_sel_lookup_5(il[604]) - , range_check_sel_lookup_6(il[605]) - , range_check_sel_rng_chk(il[606]) - , range_check_u16_r0(il[607]) - , range_check_u16_r1(il[608]) - , range_check_u16_r2(il[609]) - , range_check_u16_r3(il[610]) - , range_check_u16_r4(il[611]) - , range_check_u16_r5(il[612]) - , range_check_u16_r6(il[613]) - , range_check_u16_r7(il[614]) - , range_check_value(il[615]) - , sha256_clk(il[616]) - , sha256_input(il[617]) - , sha256_output(il[618]) - , sha256_sel_sha256_compression(il[619]) - , sha256_state(il[620]) - , slice_addr(il[621]) - , slice_clk(il[622]) - , slice_cnt(il[623]) - , slice_col_offset(il[624]) - , slice_one_min_inv(il[625]) - , slice_sel_cd_cpy(il[626]) - , slice_sel_mem_active(il[627]) - , slice_sel_return(il[628]) - , slice_sel_start(il[629]) - , slice_space_id(il[630]) - , slice_val(il[631]) - , lookup_rng_chk_pow_2_counts(il[632]) - , lookup_rng_chk_diff_counts(il[633]) - , lookup_rng_chk_0_counts(il[634]) - , lookup_rng_chk_1_counts(il[635]) - , lookup_rng_chk_2_counts(il[636]) - , lookup_rng_chk_3_counts(il[637]) - , lookup_rng_chk_4_counts(il[638]) - , lookup_rng_chk_5_counts(il[639]) - , lookup_rng_chk_6_counts(il[640]) - , lookup_rng_chk_7_counts(il[641]) - , lookup_pow_2_0_counts(il[642]) - , lookup_pow_2_1_counts(il[643]) - , lookup_byte_lengths_counts(il[644]) - , lookup_byte_operations_counts(il[645]) - , lookup_opcode_gas_counts(il[646]) - , kernel_output_lookup_counts(il[647]) - , lookup_into_kernel_counts(il[648]) - , lookup_cd_value_counts(il[649]) - , lookup_ret_value_counts(il[650]) - , incl_main_tag_err_counts(il[651]) - , incl_mem_tag_err_counts(il[652]) - , perm_rng_mem_inv(il[653]) - , perm_rng_cmp_lo_inv(il[654]) - , perm_rng_cmp_hi_inv(il[655]) - , perm_rng_alu_inv(il[656]) - , perm_cmp_alu_inv(il[657]) - , perm_rng_gas_l2_inv(il[658]) - , perm_rng_gas_da_inv(il[659]) - , perm_l2_start_gas_inv(il[660]) - , perm_da_start_gas_inv(il[661]) - , perm_l2_end_gas_inv(il[662]) - , perm_da_end_gas_inv(il[663]) - , perm_pos_mem_read_a_inv(il[664]) - , perm_pos_mem_read_b_inv(il[665]) - , perm_pos_mem_read_c_inv(il[666]) - , perm_pos_mem_read_d_inv(il[667]) - , perm_pos_mem_write_a_inv(il[668]) - , perm_pos_mem_write_b_inv(il[669]) - , perm_pos_mem_write_c_inv(il[670]) - , perm_pos_mem_write_d_inv(il[671]) - , perm_slice_mem_inv(il[672]) - , perm_main_alu_inv(il[673]) - , perm_main_bin_inv(il[674]) - , perm_main_conv_inv(il[675]) - , perm_main_pos2_perm_inv(il[676]) - , perm_main_pedersen_inv(il[677]) - , perm_main_slice_inv(il[678]) - , perm_main_mem_a_inv(il[679]) - , perm_main_mem_b_inv(il[680]) - , perm_main_mem_c_inv(il[681]) - , perm_main_mem_d_inv(il[682]) - , perm_main_mem_ind_addr_a_inv(il[683]) - , perm_main_mem_ind_addr_b_inv(il[684]) - , perm_main_mem_ind_addr_c_inv(il[685]) - , perm_main_mem_ind_addr_d_inv(il[686]) - , lookup_rng_chk_pow_2_inv(il[687]) - , lookup_rng_chk_diff_inv(il[688]) - , lookup_rng_chk_0_inv(il[689]) - , lookup_rng_chk_1_inv(il[690]) - , lookup_rng_chk_2_inv(il[691]) - , lookup_rng_chk_3_inv(il[692]) - , lookup_rng_chk_4_inv(il[693]) - , lookup_rng_chk_5_inv(il[694]) - , lookup_rng_chk_6_inv(il[695]) - , lookup_rng_chk_7_inv(il[696]) - , lookup_pow_2_0_inv(il[697]) - , lookup_pow_2_1_inv(il[698]) - , lookup_byte_lengths_inv(il[699]) - , lookup_byte_operations_inv(il[700]) - , lookup_opcode_gas_inv(il[701]) - , kernel_output_lookup_inv(il[702]) - , lookup_into_kernel_inv(il[703]) - , lookup_cd_value_inv(il[704]) - , lookup_ret_value_inv(il[705]) - , incl_main_tag_err_inv(il[706]) - , incl_mem_tag_err_inv(il[707]) - , binary_acc_ia_shift(il[708]) - , binary_acc_ib_shift(il[709]) - , binary_acc_ic_shift(il[710]) - , binary_mem_tag_ctr_shift(il[711]) - , binary_op_id_shift(il[712]) - , cmp_a_hi_shift(il[713]) - , cmp_a_lo_shift(il[714]) - , cmp_b_hi_shift(il[715]) - , cmp_b_lo_shift(il[716]) - , cmp_cmp_rng_ctr_shift(il[717]) - , cmp_op_gt_shift(il[718]) - , cmp_p_sub_a_hi_shift(il[719]) - , cmp_p_sub_a_lo_shift(il[720]) - , cmp_p_sub_b_hi_shift(il[721]) - , cmp_p_sub_b_lo_shift(il[722]) - , cmp_sel_rng_chk_shift(il[723]) - , main_da_gas_remaining_shift(il[724]) - , main_emit_l2_to_l1_msg_write_offset_shift(il[725]) - , main_emit_note_hash_write_offset_shift(il[726]) - , main_emit_nullifier_write_offset_shift(il[727]) - , main_emit_unencrypted_log_write_offset_shift(il[728]) - , main_internal_return_ptr_shift(il[729]) - , main_l1_to_l2_msg_exists_write_offset_shift(il[730]) - , main_l2_gas_remaining_shift(il[731]) - , main_note_hash_exist_write_offset_shift(il[732]) - , main_nullifier_exists_write_offset_shift(il[733]) - , main_nullifier_non_exists_write_offset_shift(il[734]) - , main_pc_shift(il[735]) - , main_sel_execution_end_shift(il[736]) - , main_sel_execution_row_shift(il[737]) - , main_sload_write_offset_shift(il[738]) - , main_sstore_write_offset_shift(il[739]) - , mem_glob_addr_shift(il[740]) - , mem_rw_shift(il[741]) - , mem_sel_mem_shift(il[742]) - , mem_tag_shift(il[743]) - , mem_tsp_shift(il[744]) - , mem_val_shift(il[745]) - , slice_addr_shift(il[746]) - , slice_clk_shift(il[747]) - , slice_cnt_shift(il[748]) - , slice_col_offset_shift(il[749]) - , slice_sel_cd_cpy_shift(il[750]) - , slice_sel_mem_active_shift(il[751]) - , slice_sel_return_shift(il[752]) - , slice_sel_start_shift(il[753]) - , slice_space_id_shift(il[754]) + , main_sel_op_poseidon2(il[225]) + , main_sel_op_radix_le(il[226]) + , main_sel_op_sender(il[227]) + , main_sel_op_set(il[228]) + , main_sel_op_sha256(il[229]) + , main_sel_op_shl(il[230]) + , main_sel_op_shr(il[231]) + , main_sel_op_sload(il[232]) + , main_sel_op_sstore(il[233]) + , main_sel_op_static_call(il[234]) + , main_sel_op_storage_address(il[235]) + , main_sel_op_sub(il[236]) + , main_sel_op_timestamp(il[237]) + , main_sel_op_transaction_fee(il[238]) + , main_sel_op_version(il[239]) + , main_sel_op_xor(il[240]) + , main_sel_q_kernel_lookup(il[241]) + , main_sel_q_kernel_output_lookup(il[242]) + , main_sel_resolve_ind_addr_a(il[243]) + , main_sel_resolve_ind_addr_b(il[244]) + , main_sel_resolve_ind_addr_c(il[245]) + , main_sel_resolve_ind_addr_d(il[246]) + , main_sel_returndata(il[247]) + , main_sel_rng_16(il[248]) + , main_sel_rng_8(il[249]) + , main_sel_slice_gadget(il[250]) + , main_side_effect_counter(il[251]) + , main_sload_write_offset(il[252]) + , main_space_id(il[253]) + , main_sstore_write_offset(il[254]) + , main_tag_err(il[255]) + , main_w_in_tag(il[256]) + , mem_addr(il[257]) + , mem_clk(il[258]) + , mem_diff(il[259]) + , mem_glob_addr(il[260]) + , mem_last(il[261]) + , mem_lastAccess(il[262]) + , mem_one_min_inv(il[263]) + , mem_r_in_tag(il[264]) + , mem_rw(il[265]) + , mem_sel_mem(il[266]) + , mem_sel_mov_ia_to_ic(il[267]) + , mem_sel_mov_ib_to_ic(il[268]) + , mem_sel_op_a(il[269]) + , mem_sel_op_b(il[270]) + , mem_sel_op_c(il[271]) + , mem_sel_op_d(il[272]) + , mem_sel_op_poseidon_read_a(il[273]) + , mem_sel_op_poseidon_read_b(il[274]) + , mem_sel_op_poseidon_read_c(il[275]) + , mem_sel_op_poseidon_read_d(il[276]) + , mem_sel_op_poseidon_write_a(il[277]) + , mem_sel_op_poseidon_write_b(il[278]) + , mem_sel_op_poseidon_write_c(il[279]) + , mem_sel_op_poseidon_write_d(il[280]) + , mem_sel_op_slice(il[281]) + , mem_sel_resolve_ind_addr_a(il[282]) + , mem_sel_resolve_ind_addr_b(il[283]) + , mem_sel_resolve_ind_addr_c(il[284]) + , mem_sel_resolve_ind_addr_d(il[285]) + , mem_sel_rng_chk(il[286]) + , mem_skip_check_tag(il[287]) + , mem_space_id(il[288]) + , mem_tag(il[289]) + , mem_tag_err(il[290]) + , mem_tsp(il[291]) + , mem_val(il[292]) + , mem_w_in_tag(il[293]) + , poseidon2_B_10_0(il[294]) + , poseidon2_B_10_1(il[295]) + , poseidon2_B_10_2(il[296]) + , poseidon2_B_10_3(il[297]) + , poseidon2_B_11_0(il[298]) + , poseidon2_B_11_1(il[299]) + , poseidon2_B_11_2(il[300]) + , poseidon2_B_11_3(il[301]) + , poseidon2_B_12_0(il[302]) + , poseidon2_B_12_1(il[303]) + , poseidon2_B_12_2(il[304]) + , poseidon2_B_12_3(il[305]) + , poseidon2_B_13_0(il[306]) + , poseidon2_B_13_1(il[307]) + , poseidon2_B_13_2(il[308]) + , poseidon2_B_13_3(il[309]) + , poseidon2_B_14_0(il[310]) + , poseidon2_B_14_1(il[311]) + , poseidon2_B_14_2(il[312]) + , poseidon2_B_14_3(il[313]) + , poseidon2_B_15_0(il[314]) + , poseidon2_B_15_1(il[315]) + , poseidon2_B_15_2(il[316]) + , poseidon2_B_15_3(il[317]) + , poseidon2_B_16_0(il[318]) + , poseidon2_B_16_1(il[319]) + , poseidon2_B_16_2(il[320]) + , poseidon2_B_16_3(il[321]) + , poseidon2_B_17_0(il[322]) + , poseidon2_B_17_1(il[323]) + , poseidon2_B_17_2(il[324]) + , poseidon2_B_17_3(il[325]) + , poseidon2_B_18_0(il[326]) + , poseidon2_B_18_1(il[327]) + , poseidon2_B_18_2(il[328]) + , poseidon2_B_18_3(il[329]) + , poseidon2_B_19_0(il[330]) + , poseidon2_B_19_1(il[331]) + , poseidon2_B_19_2(il[332]) + , poseidon2_B_19_3(il[333]) + , poseidon2_B_20_0(il[334]) + , poseidon2_B_20_1(il[335]) + , poseidon2_B_20_2(il[336]) + , poseidon2_B_20_3(il[337]) + , poseidon2_B_21_0(il[338]) + , poseidon2_B_21_1(il[339]) + , poseidon2_B_21_2(il[340]) + , poseidon2_B_21_3(il[341]) + , poseidon2_B_22_0(il[342]) + , poseidon2_B_22_1(il[343]) + , poseidon2_B_22_2(il[344]) + , poseidon2_B_22_3(il[345]) + , poseidon2_B_23_0(il[346]) + , poseidon2_B_23_1(il[347]) + , poseidon2_B_23_2(il[348]) + , poseidon2_B_23_3(il[349]) + , poseidon2_B_24_0(il[350]) + , poseidon2_B_24_1(il[351]) + , poseidon2_B_24_2(il[352]) + , poseidon2_B_24_3(il[353]) + , poseidon2_B_25_0(il[354]) + , poseidon2_B_25_1(il[355]) + , poseidon2_B_25_2(il[356]) + , poseidon2_B_25_3(il[357]) + , poseidon2_B_26_0(il[358]) + , poseidon2_B_26_1(il[359]) + , poseidon2_B_26_2(il[360]) + , poseidon2_B_26_3(il[361]) + , poseidon2_B_27_0(il[362]) + , poseidon2_B_27_1(il[363]) + , poseidon2_B_27_2(il[364]) + , poseidon2_B_27_3(il[365]) + , poseidon2_B_28_0(il[366]) + , poseidon2_B_28_1(il[367]) + , poseidon2_B_28_2(il[368]) + , poseidon2_B_28_3(il[369]) + , poseidon2_B_29_0(il[370]) + , poseidon2_B_29_1(il[371]) + , poseidon2_B_29_2(il[372]) + , poseidon2_B_29_3(il[373]) + , poseidon2_B_30_0(il[374]) + , poseidon2_B_30_1(il[375]) + , poseidon2_B_30_2(il[376]) + , poseidon2_B_30_3(il[377]) + , poseidon2_B_31_0(il[378]) + , poseidon2_B_31_1(il[379]) + , poseidon2_B_31_2(il[380]) + , poseidon2_B_31_3(il[381]) + , poseidon2_B_32_0(il[382]) + , poseidon2_B_32_1(il[383]) + , poseidon2_B_32_2(il[384]) + , poseidon2_B_32_3(il[385]) + , poseidon2_B_33_0(il[386]) + , poseidon2_B_33_1(il[387]) + , poseidon2_B_33_2(il[388]) + , poseidon2_B_33_3(il[389]) + , poseidon2_B_34_0(il[390]) + , poseidon2_B_34_1(il[391]) + , poseidon2_B_34_2(il[392]) + , poseidon2_B_34_3(il[393]) + , poseidon2_B_35_0(il[394]) + , poseidon2_B_35_1(il[395]) + , poseidon2_B_35_2(il[396]) + , poseidon2_B_35_3(il[397]) + , poseidon2_B_36_0(il[398]) + , poseidon2_B_36_1(il[399]) + , poseidon2_B_36_2(il[400]) + , poseidon2_B_36_3(il[401]) + , poseidon2_B_37_0(il[402]) + , poseidon2_B_37_1(il[403]) + , poseidon2_B_37_2(il[404]) + , poseidon2_B_37_3(il[405]) + , poseidon2_B_38_0(il[406]) + , poseidon2_B_38_1(il[407]) + , poseidon2_B_38_2(il[408]) + , poseidon2_B_38_3(il[409]) + , poseidon2_B_39_0(il[410]) + , poseidon2_B_39_1(il[411]) + , poseidon2_B_39_2(il[412]) + , poseidon2_B_39_3(il[413]) + , poseidon2_B_40_0(il[414]) + , poseidon2_B_40_1(il[415]) + , poseidon2_B_40_2(il[416]) + , poseidon2_B_40_3(il[417]) + , poseidon2_B_41_0(il[418]) + , poseidon2_B_41_1(il[419]) + , poseidon2_B_41_2(il[420]) + , poseidon2_B_41_3(il[421]) + , poseidon2_B_42_0(il[422]) + , poseidon2_B_42_1(il[423]) + , poseidon2_B_42_2(il[424]) + , poseidon2_B_42_3(il[425]) + , poseidon2_B_43_0(il[426]) + , poseidon2_B_43_1(il[427]) + , poseidon2_B_43_2(il[428]) + , poseidon2_B_43_3(il[429]) + , poseidon2_B_44_0(il[430]) + , poseidon2_B_44_1(il[431]) + , poseidon2_B_44_2(il[432]) + , poseidon2_B_44_3(il[433]) + , poseidon2_B_45_0(il[434]) + , poseidon2_B_45_1(il[435]) + , poseidon2_B_45_2(il[436]) + , poseidon2_B_45_3(il[437]) + , poseidon2_B_46_0(il[438]) + , poseidon2_B_46_1(il[439]) + , poseidon2_B_46_2(il[440]) + , poseidon2_B_46_3(il[441]) + , poseidon2_B_47_0(il[442]) + , poseidon2_B_47_1(il[443]) + , poseidon2_B_47_2(il[444]) + , poseidon2_B_47_3(il[445]) + , poseidon2_B_48_0(il[446]) + , poseidon2_B_48_1(il[447]) + , poseidon2_B_48_2(il[448]) + , poseidon2_B_48_3(il[449]) + , poseidon2_B_49_0(il[450]) + , poseidon2_B_49_1(il[451]) + , poseidon2_B_49_2(il[452]) + , poseidon2_B_49_3(il[453]) + , poseidon2_B_4_0(il[454]) + , poseidon2_B_4_1(il[455]) + , poseidon2_B_4_2(il[456]) + , poseidon2_B_4_3(il[457]) + , poseidon2_B_50_0(il[458]) + , poseidon2_B_50_1(il[459]) + , poseidon2_B_50_2(il[460]) + , poseidon2_B_50_3(il[461]) + , poseidon2_B_51_0(il[462]) + , poseidon2_B_51_1(il[463]) + , poseidon2_B_51_2(il[464]) + , poseidon2_B_51_3(il[465]) + , poseidon2_B_52_0(il[466]) + , poseidon2_B_52_1(il[467]) + , poseidon2_B_52_2(il[468]) + , poseidon2_B_52_3(il[469]) + , poseidon2_B_53_0(il[470]) + , poseidon2_B_53_1(il[471]) + , poseidon2_B_53_2(il[472]) + , poseidon2_B_53_3(il[473]) + , poseidon2_B_54_0(il[474]) + , poseidon2_B_54_1(il[475]) + , poseidon2_B_54_2(il[476]) + , poseidon2_B_54_3(il[477]) + , poseidon2_B_55_0(il[478]) + , poseidon2_B_55_1(il[479]) + , poseidon2_B_55_2(il[480]) + , poseidon2_B_55_3(il[481]) + , poseidon2_B_56_0(il[482]) + , poseidon2_B_56_1(il[483]) + , poseidon2_B_56_2(il[484]) + , poseidon2_B_56_3(il[485]) + , poseidon2_B_57_0(il[486]) + , poseidon2_B_57_1(il[487]) + , poseidon2_B_57_2(il[488]) + , poseidon2_B_57_3(il[489]) + , poseidon2_B_58_0(il[490]) + , poseidon2_B_58_1(il[491]) + , poseidon2_B_58_2(il[492]) + , poseidon2_B_58_3(il[493]) + , poseidon2_B_59_0(il[494]) + , poseidon2_B_59_1(il[495]) + , poseidon2_B_59_2(il[496]) + , poseidon2_B_59_3(il[497]) + , poseidon2_B_5_0(il[498]) + , poseidon2_B_5_1(il[499]) + , poseidon2_B_5_2(il[500]) + , poseidon2_B_5_3(il[501]) + , poseidon2_B_6_0(il[502]) + , poseidon2_B_6_1(il[503]) + , poseidon2_B_6_2(il[504]) + , poseidon2_B_6_3(il[505]) + , poseidon2_B_7_0(il[506]) + , poseidon2_B_7_1(il[507]) + , poseidon2_B_7_2(il[508]) + , poseidon2_B_7_3(il[509]) + , poseidon2_B_8_0(il[510]) + , poseidon2_B_8_1(il[511]) + , poseidon2_B_8_2(il[512]) + , poseidon2_B_8_3(il[513]) + , poseidon2_B_9_0(il[514]) + , poseidon2_B_9_1(il[515]) + , poseidon2_B_9_2(il[516]) + , poseidon2_B_9_3(il[517]) + , poseidon2_EXT_LAYER_4(il[518]) + , poseidon2_EXT_LAYER_5(il[519]) + , poseidon2_EXT_LAYER_6(il[520]) + , poseidon2_EXT_LAYER_7(il[521]) + , poseidon2_T_0_4(il[522]) + , poseidon2_T_0_5(il[523]) + , poseidon2_T_0_6(il[524]) + , poseidon2_T_0_7(il[525]) + , poseidon2_T_1_4(il[526]) + , poseidon2_T_1_5(il[527]) + , poseidon2_T_1_6(il[528]) + , poseidon2_T_1_7(il[529]) + , poseidon2_T_2_4(il[530]) + , poseidon2_T_2_5(il[531]) + , poseidon2_T_2_6(il[532]) + , poseidon2_T_2_7(il[533]) + , poseidon2_T_3_4(il[534]) + , poseidon2_T_3_5(il[535]) + , poseidon2_T_3_6(il[536]) + , poseidon2_T_3_7(il[537]) + , poseidon2_T_60_4(il[538]) + , poseidon2_T_60_5(il[539]) + , poseidon2_T_60_6(il[540]) + , poseidon2_T_60_7(il[541]) + , poseidon2_T_61_4(il[542]) + , poseidon2_T_61_5(il[543]) + , poseidon2_T_61_6(il[544]) + , poseidon2_T_61_7(il[545]) + , poseidon2_T_62_4(il[546]) + , poseidon2_T_62_5(il[547]) + , poseidon2_T_62_6(il[548]) + , poseidon2_T_62_7(il[549]) + , poseidon2_T_63_4(il[550]) + , poseidon2_T_63_5(il[551]) + , poseidon2_T_63_6(il[552]) + , poseidon2_T_63_7(il[553]) + , poseidon2_a_0(il[554]) + , poseidon2_a_1(il[555]) + , poseidon2_a_2(il[556]) + , poseidon2_a_3(il[557]) + , poseidon2_b_0(il[558]) + , poseidon2_b_1(il[559]) + , poseidon2_b_2(il[560]) + , poseidon2_b_3(il[561]) + , poseidon2_clk(il[562]) + , poseidon2_input_addr(il[563]) + , poseidon2_mem_addr_read_a(il[564]) + , poseidon2_mem_addr_read_b(il[565]) + , poseidon2_mem_addr_read_c(il[566]) + , poseidon2_mem_addr_read_d(il[567]) + , poseidon2_mem_addr_write_a(il[568]) + , poseidon2_mem_addr_write_b(il[569]) + , poseidon2_mem_addr_write_c(il[570]) + , poseidon2_mem_addr_write_d(il[571]) + , poseidon2_output_addr(il[572]) + , poseidon2_sel_poseidon_perm(il[573]) + , range_check_alu_rng_chk(il[574]) + , range_check_clk(il[575]) + , range_check_cmp_hi_bits_rng_chk(il[576]) + , range_check_cmp_lo_bits_rng_chk(il[577]) + , range_check_dyn_diff(il[578]) + , range_check_dyn_rng_chk_bits(il[579]) + , range_check_dyn_rng_chk_pow_2(il[580]) + , range_check_gas_da_rng_chk(il[581]) + , range_check_gas_l2_rng_chk(il[582]) + , range_check_is_lte_u112(il[583]) + , range_check_is_lte_u128(il[584]) + , range_check_is_lte_u16(il[585]) + , range_check_is_lte_u32(il[586]) + , range_check_is_lte_u48(il[587]) + , range_check_is_lte_u64(il[588]) + , range_check_is_lte_u80(il[589]) + , range_check_is_lte_u96(il[590]) + , range_check_mem_rng_chk(il[591]) + , range_check_rng_chk_bits(il[592]) + , range_check_sel_lookup_0(il[593]) + , range_check_sel_lookup_1(il[594]) + , range_check_sel_lookup_2(il[595]) + , range_check_sel_lookup_3(il[596]) + , range_check_sel_lookup_4(il[597]) + , range_check_sel_lookup_5(il[598]) + , range_check_sel_lookup_6(il[599]) + , range_check_sel_rng_chk(il[600]) + , range_check_u16_r0(il[601]) + , range_check_u16_r1(il[602]) + , range_check_u16_r2(il[603]) + , range_check_u16_r3(il[604]) + , range_check_u16_r4(il[605]) + , range_check_u16_r5(il[606]) + , range_check_u16_r6(il[607]) + , range_check_u16_r7(il[608]) + , range_check_value(il[609]) + , sha256_clk(il[610]) + , sha256_input(il[611]) + , sha256_output(il[612]) + , sha256_sel_sha256_compression(il[613]) + , sha256_state(il[614]) + , slice_addr(il[615]) + , slice_clk(il[616]) + , slice_cnt(il[617]) + , slice_col_offset(il[618]) + , slice_one_min_inv(il[619]) + , slice_sel_cd_cpy(il[620]) + , slice_sel_mem_active(il[621]) + , slice_sel_return(il[622]) + , slice_sel_start(il[623]) + , slice_space_id(il[624]) + , slice_val(il[625]) + , lookup_rng_chk_pow_2_counts(il[626]) + , lookup_rng_chk_diff_counts(il[627]) + , lookup_rng_chk_0_counts(il[628]) + , lookup_rng_chk_1_counts(il[629]) + , lookup_rng_chk_2_counts(il[630]) + , lookup_rng_chk_3_counts(il[631]) + , lookup_rng_chk_4_counts(il[632]) + , lookup_rng_chk_5_counts(il[633]) + , lookup_rng_chk_6_counts(il[634]) + , lookup_rng_chk_7_counts(il[635]) + , lookup_pow_2_0_counts(il[636]) + , lookup_pow_2_1_counts(il[637]) + , lookup_byte_lengths_counts(il[638]) + , lookup_byte_operations_counts(il[639]) + , lookup_opcode_gas_counts(il[640]) + , kernel_output_lookup_counts(il[641]) + , lookup_into_kernel_counts(il[642]) + , lookup_cd_value_counts(il[643]) + , lookup_ret_value_counts(il[644]) + , incl_main_tag_err_counts(il[645]) + , incl_mem_tag_err_counts(il[646]) + , perm_rng_mem_inv(il[647]) + , perm_rng_cmp_lo_inv(il[648]) + , perm_rng_cmp_hi_inv(il[649]) + , perm_rng_alu_inv(il[650]) + , perm_cmp_alu_inv(il[651]) + , perm_rng_gas_l2_inv(il[652]) + , perm_rng_gas_da_inv(il[653]) + , perm_l2_start_gas_inv(il[654]) + , perm_da_start_gas_inv(il[655]) + , perm_l2_end_gas_inv(il[656]) + , perm_da_end_gas_inv(il[657]) + , perm_pos_mem_read_a_inv(il[658]) + , perm_pos_mem_read_b_inv(il[659]) + , perm_pos_mem_read_c_inv(il[660]) + , perm_pos_mem_read_d_inv(il[661]) + , perm_pos_mem_write_a_inv(il[662]) + , perm_pos_mem_write_b_inv(il[663]) + , perm_pos_mem_write_c_inv(il[664]) + , perm_pos_mem_write_d_inv(il[665]) + , perm_slice_mem_inv(il[666]) + , perm_main_alu_inv(il[667]) + , perm_main_bin_inv(il[668]) + , perm_main_conv_inv(il[669]) + , perm_main_sha256_inv(il[670]) + , perm_main_pos2_perm_inv(il[671]) + , perm_main_keccak_inv(il[672]) + , perm_main_slice_inv(il[673]) + , perm_main_mem_a_inv(il[674]) + , perm_main_mem_b_inv(il[675]) + , perm_main_mem_c_inv(il[676]) + , perm_main_mem_d_inv(il[677]) + , perm_main_mem_ind_addr_a_inv(il[678]) + , perm_main_mem_ind_addr_b_inv(il[679]) + , perm_main_mem_ind_addr_c_inv(il[680]) + , perm_main_mem_ind_addr_d_inv(il[681]) + , lookup_rng_chk_pow_2_inv(il[682]) + , lookup_rng_chk_diff_inv(il[683]) + , lookup_rng_chk_0_inv(il[684]) + , lookup_rng_chk_1_inv(il[685]) + , lookup_rng_chk_2_inv(il[686]) + , lookup_rng_chk_3_inv(il[687]) + , lookup_rng_chk_4_inv(il[688]) + , lookup_rng_chk_5_inv(il[689]) + , lookup_rng_chk_6_inv(il[690]) + , lookup_rng_chk_7_inv(il[691]) + , lookup_pow_2_0_inv(il[692]) + , lookup_pow_2_1_inv(il[693]) + , lookup_byte_lengths_inv(il[694]) + , lookup_byte_operations_inv(il[695]) + , lookup_opcode_gas_inv(il[696]) + , kernel_output_lookup_inv(il[697]) + , lookup_into_kernel_inv(il[698]) + , lookup_cd_value_inv(il[699]) + , lookup_ret_value_inv(il[700]) + , incl_main_tag_err_inv(il[701]) + , incl_mem_tag_err_inv(il[702]) + , binary_acc_ia_shift(il[703]) + , binary_acc_ib_shift(il[704]) + , binary_acc_ic_shift(il[705]) + , binary_mem_tag_ctr_shift(il[706]) + , binary_op_id_shift(il[707]) + , cmp_a_hi_shift(il[708]) + , cmp_a_lo_shift(il[709]) + , cmp_b_hi_shift(il[710]) + , cmp_b_lo_shift(il[711]) + , cmp_cmp_rng_ctr_shift(il[712]) + , cmp_op_gt_shift(il[713]) + , cmp_p_sub_a_hi_shift(il[714]) + , cmp_p_sub_a_lo_shift(il[715]) + , cmp_p_sub_b_hi_shift(il[716]) + , cmp_p_sub_b_lo_shift(il[717]) + , cmp_sel_rng_chk_shift(il[718]) + , main_da_gas_remaining_shift(il[719]) + , main_emit_l2_to_l1_msg_write_offset_shift(il[720]) + , main_emit_note_hash_write_offset_shift(il[721]) + , main_emit_nullifier_write_offset_shift(il[722]) + , main_emit_unencrypted_log_write_offset_shift(il[723]) + , main_internal_return_ptr_shift(il[724]) + , main_l1_to_l2_msg_exists_write_offset_shift(il[725]) + , main_l2_gas_remaining_shift(il[726]) + , main_note_hash_exist_write_offset_shift(il[727]) + , main_nullifier_exists_write_offset_shift(il[728]) + , main_nullifier_non_exists_write_offset_shift(il[729]) + , main_pc_shift(il[730]) + , main_sel_execution_end_shift(il[731]) + , main_sel_execution_row_shift(il[732]) + , main_sload_write_offset_shift(il[733]) + , main_sstore_write_offset_shift(il[734]) + , mem_glob_addr_shift(il[735]) + , mem_rw_shift(il[736]) + , mem_sel_mem_shift(il[737]) + , mem_tag_shift(il[738]) + , mem_tsp_shift(il[739]) + , mem_val_shift(il[740]) + , slice_addr_shift(il[741]) + , slice_clk_shift(il[742]) + , slice_cnt_shift(il[743]) + , slice_col_offset_shift(il[744]) + , slice_sel_cd_cpy_shift(il[745]) + , slice_sel_mem_active_shift(il[746]) + , slice_sel_return_shift(il[747]) + , slice_sel_start_shift(il[748]) + , slice_space_id_shift(il[749]) {} AvmFlavor::ProverPolynomials::ProverPolynomials(ProvingKey& proving_key) @@ -1001,8 +996,6 @@ AvmFlavor::AllConstRefValues AvmFlavor::ProverPolynomials::get_row(size_t row_id main_sel_op_note_hash_exists[row_idx], main_sel_op_nullifier_exists[row_idx], main_sel_op_or[row_idx], - main_sel_op_pedersen[row_idx], - main_sel_op_pedersen_commit[row_idx], main_sel_op_poseidon2[row_idx], main_sel_op_radix_le[row_idx], main_sel_op_sender[row_idx], @@ -1072,10 +1065,6 @@ AvmFlavor::AllConstRefValues AvmFlavor::ProverPolynomials::get_row(size_t row_id mem_tsp[row_idx], mem_val[row_idx], mem_w_in_tag[row_idx], - pedersen_clk[row_idx], - pedersen_input[row_idx], - pedersen_output[row_idx], - pedersen_sel_pedersen[row_idx], poseidon2_B_10_0[row_idx], poseidon2_B_10_1[row_idx], poseidon2_B_10_2[row_idx], @@ -1452,8 +1441,9 @@ AvmFlavor::AllConstRefValues AvmFlavor::ProverPolynomials::get_row(size_t row_id perm_main_alu_inv[row_idx], perm_main_bin_inv[row_idx], perm_main_conv_inv[row_idx], + perm_main_sha256_inv[row_idx], perm_main_pos2_perm_inv[row_idx], - perm_main_pedersen_inv[row_idx], + perm_main_keccak_inv[row_idx], perm_main_slice_inv[row_idx], perm_main_mem_a_inv[row_idx], perm_main_mem_b_inv[row_idx], @@ -1760,8 +1750,6 @@ AvmFlavor::CommitmentLabels::CommitmentLabels() Base::main_sel_op_note_hash_exists = "MAIN_SEL_OP_NOTE_HASH_EXISTS"; Base::main_sel_op_nullifier_exists = "MAIN_SEL_OP_NULLIFIER_EXISTS"; Base::main_sel_op_or = "MAIN_SEL_OP_OR"; - Base::main_sel_op_pedersen = "MAIN_SEL_OP_PEDERSEN"; - Base::main_sel_op_pedersen_commit = "MAIN_SEL_OP_PEDERSEN_COMMIT"; Base::main_sel_op_poseidon2 = "MAIN_SEL_OP_POSEIDON2"; Base::main_sel_op_radix_le = "MAIN_SEL_OP_RADIX_LE"; Base::main_sel_op_sender = "MAIN_SEL_OP_SENDER"; @@ -1831,10 +1819,6 @@ AvmFlavor::CommitmentLabels::CommitmentLabels() Base::mem_tsp = "MEM_TSP"; Base::mem_val = "MEM_VAL"; Base::mem_w_in_tag = "MEM_W_IN_TAG"; - Base::pedersen_clk = "PEDERSEN_CLK"; - Base::pedersen_input = "PEDERSEN_INPUT"; - Base::pedersen_output = "PEDERSEN_OUTPUT"; - Base::pedersen_sel_pedersen = "PEDERSEN_SEL_PEDERSEN"; Base::poseidon2_B_10_0 = "POSEIDON2_B_10_0"; Base::poseidon2_B_10_1 = "POSEIDON2_B_10_1"; Base::poseidon2_B_10_2 = "POSEIDON2_B_10_2"; @@ -2190,8 +2174,9 @@ AvmFlavor::CommitmentLabels::CommitmentLabels() Base::perm_main_alu_inv = "PERM_MAIN_ALU_INV"; Base::perm_main_bin_inv = "PERM_MAIN_BIN_INV"; Base::perm_main_conv_inv = "PERM_MAIN_CONV_INV"; + Base::perm_main_sha256_inv = "PERM_MAIN_SHA256_INV"; Base::perm_main_pos2_perm_inv = "PERM_MAIN_POS2_PERM_INV"; - Base::perm_main_pedersen_inv = "PERM_MAIN_PEDERSEN_INV"; + Base::perm_main_keccak_inv = "PERM_MAIN_KECCAK_INV"; Base::perm_main_slice_inv = "PERM_MAIN_SLICE_INV"; Base::perm_main_mem_a_inv = "PERM_MAIN_MEM_A_INV"; Base::perm_main_mem_b_inv = "PERM_MAIN_MEM_B_INV"; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp index 5805df2cf50..0afcdca8969 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp @@ -26,7 +26,6 @@ #include "barretenberg/vm/avm/generated/relations/main.hpp" #include "barretenberg/vm/avm/generated/relations/mem.hpp" #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" @@ -61,6 +60,7 @@ #include "barretenberg/vm/avm/generated/relations/perm_main_alu.hpp" #include "barretenberg/vm/avm/generated/relations/perm_main_bin.hpp" #include "barretenberg/vm/avm/generated/relations/perm_main_conv.hpp" +#include "barretenberg/vm/avm/generated/relations/perm_main_keccak.hpp" #include "barretenberg/vm/avm/generated/relations/perm_main_mem_a.hpp" #include "barretenberg/vm/avm/generated/relations/perm_main_mem_b.hpp" #include "barretenberg/vm/avm/generated/relations/perm_main_mem_c.hpp" @@ -69,8 +69,8 @@ #include "barretenberg/vm/avm/generated/relations/perm_main_mem_ind_addr_b.hpp" #include "barretenberg/vm/avm/generated/relations/perm_main_mem_ind_addr_c.hpp" #include "barretenberg/vm/avm/generated/relations/perm_main_mem_ind_addr_d.hpp" -#include "barretenberg/vm/avm/generated/relations/perm_main_pedersen.hpp" #include "barretenberg/vm/avm/generated/relations/perm_main_pos2_perm.hpp" +#include "barretenberg/vm/avm/generated/relations/perm_main_sha256.hpp" #include "barretenberg/vm/avm/generated/relations/perm_main_slice.hpp" #include "barretenberg/vm/avm/generated/relations/perm_pos_mem_read_a.hpp" #include "barretenberg/vm/avm/generated/relations/perm_pos_mem_read_b.hpp" @@ -94,8 +94,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_da_end_gas_kernel_input, main_sel_da_start_gas_kernel_input, main_sel_first, main_sel_l2_end_gas_kernel_input, main_sel_l2_start_gas_kernel_input, main_sel_start_exec, 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_b_pow, alu_c_hi, alu_c_lo, alu_cf, alu_clk, alu_cmp_gadget_gt, alu_cmp_gadget_input_a, alu_cmp_gadget_input_b, alu_cmp_gadget_result, alu_cmp_gadget_sel, alu_ff_tag, alu_ia, alu_ib, alu_ic, alu_in_tag, alu_max_bits_sub_b_bits, alu_max_bits_sub_b_pow, alu_op_add, alu_op_cast, alu_op_div, alu_op_eq, alu_op_lt, alu_op_lte, alu_op_mul, alu_op_not, alu_op_shl, alu_op_shr, alu_op_sub, alu_partial_prod_hi, alu_partial_prod_lo, alu_range_check_input_value, alu_range_check_num_bits, alu_range_check_sel, alu_remainder, alu_sel_alu, alu_sel_cmp, alu_sel_shift_which, alu_u128_tag, alu_u16_tag, alu_u1_tag, alu_u32_tag, alu_u64_tag, alu_u8_tag, alu_zero_shift, 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, cmp_a_hi, cmp_a_lo, cmp_b_hi, cmp_b_lo, cmp_borrow, cmp_clk, cmp_cmp_rng_ctr, cmp_input_a, cmp_input_b, cmp_op_eq, cmp_op_eq_diff_inv, cmp_op_gt, cmp_p_a_borrow, cmp_p_b_borrow, cmp_p_sub_a_hi, cmp_p_sub_a_lo, cmp_p_sub_b_hi, cmp_p_sub_b_lo, cmp_range_chk_clk, cmp_res_hi, cmp_res_lo, cmp_result, cmp_sel_cmp, cmp_sel_rng_chk, cmp_shift_sel, conversion_clk, conversion_input, conversion_num_limbs, conversion_output_bits, conversion_radix, conversion_sel_to_radix_le, keccakf1600_clk, keccakf1600_input, keccakf1600_output, keccakf1600_sel_keccakf1600, main_abs_da_rem_gas, main_abs_l2_rem_gas, 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_is_fake_row, main_is_gas_accounted, 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_end, main_sel_execution_row, main_sel_kernel_inputs, main_sel_kernel_out, 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_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_is_static_call, 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_static_call, 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, 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_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_alu_rng_chk, range_check_clk, range_check_cmp_hi_bits_rng_chk, range_check_cmp_lo_bits_rng_chk, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_gas_da_rng_chk, range_check_gas_l2_rng_chk, 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_mem_rng_chk, 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_byte_lengths_counts, lookup_byte_operations_counts, lookup_opcode_gas_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 -#define DERIVED_WITNESS_ENTITIES perm_rng_mem_inv, perm_rng_cmp_lo_inv, perm_rng_cmp_hi_inv, perm_rng_alu_inv, perm_cmp_alu_inv, perm_rng_gas_l2_inv, perm_rng_gas_da_inv, perm_l2_start_gas_inv, perm_da_start_gas_inv, perm_l2_end_gas_inv, perm_da_end_gas_inv, 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_byte_lengths_inv, lookup_byte_operations_inv, lookup_opcode_gas_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 +#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_b_pow, alu_c_hi, alu_c_lo, alu_cf, alu_clk, alu_cmp_gadget_gt, alu_cmp_gadget_input_a, alu_cmp_gadget_input_b, alu_cmp_gadget_result, alu_cmp_gadget_sel, alu_ff_tag, alu_ia, alu_ib, alu_ic, alu_in_tag, alu_max_bits_sub_b_bits, alu_max_bits_sub_b_pow, alu_op_add, alu_op_cast, alu_op_div, alu_op_eq, alu_op_lt, alu_op_lte, alu_op_mul, alu_op_not, alu_op_shl, alu_op_shr, alu_op_sub, alu_partial_prod_hi, alu_partial_prod_lo, alu_range_check_input_value, alu_range_check_num_bits, alu_range_check_sel, alu_remainder, alu_sel_alu, alu_sel_cmp, alu_sel_shift_which, alu_u128_tag, alu_u16_tag, alu_u1_tag, alu_u32_tag, alu_u64_tag, alu_u8_tag, alu_zero_shift, 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, cmp_a_hi, cmp_a_lo, cmp_b_hi, cmp_b_lo, cmp_borrow, cmp_clk, cmp_cmp_rng_ctr, cmp_input_a, cmp_input_b, cmp_op_eq, cmp_op_eq_diff_inv, cmp_op_gt, cmp_p_a_borrow, cmp_p_b_borrow, cmp_p_sub_a_hi, cmp_p_sub_a_lo, cmp_p_sub_b_hi, cmp_p_sub_b_lo, cmp_range_chk_clk, cmp_res_hi, cmp_res_lo, cmp_result, cmp_sel_cmp, cmp_sel_rng_chk, cmp_shift_sel, conversion_clk, conversion_input, conversion_num_limbs, conversion_output_bits, conversion_radix, conversion_sel_to_radix_le, keccakf1600_clk, keccakf1600_input, keccakf1600_output, keccakf1600_sel_keccakf1600, main_abs_da_rem_gas, main_abs_l2_rem_gas, 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_is_fake_row, main_is_gas_accounted, 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_end, main_sel_execution_row, main_sel_kernel_inputs, main_sel_kernel_out, 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_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_is_static_call, 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_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_static_call, 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, 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_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, 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_alu_rng_chk, range_check_clk, range_check_cmp_hi_bits_rng_chk, range_check_cmp_lo_bits_rng_chk, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_gas_da_rng_chk, range_check_gas_l2_rng_chk, 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_mem_rng_chk, 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_byte_lengths_counts, lookup_byte_operations_counts, lookup_opcode_gas_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 +#define DERIVED_WITNESS_ENTITIES perm_rng_mem_inv, perm_rng_cmp_lo_inv, perm_rng_cmp_hi_inv, perm_rng_alu_inv, perm_cmp_alu_inv, perm_rng_gas_l2_inv, perm_rng_gas_da_inv, perm_l2_start_gas_inv, perm_da_start_gas_inv, perm_l2_end_gas_inv, perm_da_end_gas_inv, 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_sha256_inv, perm_main_pos2_perm_inv, perm_main_keccak_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_byte_lengths_inv, lookup_byte_operations_inv, lookup_opcode_gas_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 #define SHIFTED_ENTITIES binary_acc_ia_shift, binary_acc_ib_shift, binary_acc_ic_shift, binary_mem_tag_ctr_shift, binary_op_id_shift, cmp_a_hi_shift, cmp_a_lo_shift, cmp_b_hi_shift, cmp_b_lo_shift, cmp_cmp_rng_ctr_shift, cmp_op_gt_shift, cmp_p_sub_a_hi_shift, cmp_p_sub_a_lo_shift, cmp_p_sub_b_hi_shift, cmp_p_sub_b_lo_shift, cmp_sel_rng_chk_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_end_shift, main_sel_execution_row_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.binary_acc_ia, e.binary_acc_ib, e.binary_acc_ic, e.binary_mem_tag_ctr, e.binary_op_id, e.cmp_a_hi, e.cmp_a_lo, e.cmp_b_hi, e.cmp_b_lo, e.cmp_cmp_rng_ctr, e.cmp_op_gt, e.cmp_p_sub_a_hi, e.cmp_p_sub_a_lo, e.cmp_p_sub_b_hi, e.cmp_p_sub_b_lo, e.cmp_sel_rng_chk, 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_end, e.main_sel_execution_row, 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 @@ -123,12 +123,12 @@ class AvmFlavor { static constexpr bool HasZK = false; static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 21; - static constexpr size_t NUM_WITNESS_ENTITIES = 687; + static constexpr size_t NUM_WITNESS_ENTITIES = 682; static constexpr size_t NUM_SHIFTED_ENTITIES = 47; 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 = 755; + static constexpr size_t NUM_ALL_ENTITIES = 750; // The total number of witnesses including shifts and derived entities. static constexpr size_t NUM_ALL_WITNESS_ENTITIES = NUM_WITNESS_ENTITIES + NUM_SHIFTED_ENTITIES; @@ -146,7 +146,6 @@ class AvmFlavor { Avm_vm::main, Avm_vm::mem, Avm_vm::mem_slice, - Avm_vm::pedersen, Avm_vm::poseidon2, Avm_vm::range_check, Avm_vm::sha256>; @@ -186,6 +185,7 @@ class AvmFlavor { perm_main_alu_relation, perm_main_bin_relation, perm_main_conv_relation, + perm_main_keccak_relation, perm_main_mem_a_relation, perm_main_mem_b_relation, perm_main_mem_c_relation, @@ -194,8 +194,8 @@ class AvmFlavor { perm_main_mem_ind_addr_b_relation, perm_main_mem_ind_addr_c_relation, perm_main_mem_ind_addr_d_relation, - perm_main_pedersen_relation, perm_main_pos2_perm_relation, + perm_main_sha256_relation, perm_main_slice_relation, perm_pos_mem_read_a_relation, perm_pos_mem_read_b_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 1ad7557bb26..d80461ed674 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.cpp @@ -244,8 +244,6 @@ template std::vector AvmFullRow::names() "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", @@ -315,10 +313,6 @@ template std::vector AvmFullRow::names() "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", @@ -674,8 +668,9 @@ template std::vector AvmFullRow::names() "perm_main_alu_inv", "perm_main_bin_inv", "perm_main_conv_inv", + "perm_main_sha256_inv", "perm_main_pos2_perm_inv", - "perm_main_pedersen_inv", + "perm_main_keccak_inv", "perm_main_slice_inv", "perm_main_mem_a_inv", "perm_main_mem_b_inv", @@ -957,8 +952,6 @@ template RefVector AvmFullRow::as_vector() const 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, @@ -1028,10 +1021,6 @@ template RefVector AvmFullRow::as_vector() const 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, @@ -1387,8 +1376,9 @@ template RefVector AvmFullRow::as_vector() const perm_main_alu_inv, perm_main_bin_inv, perm_main_conv_inv, + perm_main_sha256_inv, perm_main_pos2_perm_inv, - perm_main_pedersen_inv, + perm_main_keccak_inv, perm_main_slice_inv, perm_main_mem_a_inv, perm_main_mem_b_inv, 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 19bad253079..22b73d42db4 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.hpp @@ -235,8 +235,6 @@ template struct AvmFullRow { FF main_sel_op_note_hash_exists{}; FF main_sel_op_nullifier_exists{}; FF main_sel_op_or{}; - FF main_sel_op_pedersen{}; - FF main_sel_op_pedersen_commit{}; FF main_sel_op_poseidon2{}; FF main_sel_op_radix_le{}; FF main_sel_op_sender{}; @@ -306,10 +304,6 @@ template struct AvmFullRow { FF mem_tsp{}; FF mem_val{}; FF mem_w_in_tag{}; - FF pedersen_clk{}; - FF pedersen_input{}; - FF pedersen_output{}; - FF pedersen_sel_pedersen{}; FF poseidon2_B_10_0{}; FF poseidon2_B_10_1{}; FF poseidon2_B_10_2{}; @@ -665,8 +659,9 @@ template struct AvmFullRow { FF perm_main_alu_inv{}; FF perm_main_bin_inv{}; FF perm_main_conv_inv{}; + FF perm_main_sha256_inv{}; FF perm_main_pos2_perm_inv{}; - FF perm_main_pedersen_inv{}; + FF perm_main_keccak_inv{}; FF perm_main_slice_inv{}; FF perm_main_mem_a_inv{}; FF perm_main_mem_b_inv{}; @@ -722,7 +717,7 @@ template struct AvmFullRow { RefVector as_vector() const; static std::vector names(); - static constexpr size_t SIZE = 708; + static constexpr size_t SIZE = 703; }; template std::ostream& operator<<(std::ostream& os, AvmFullRow const& row); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/main.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/main.hpp index 963b2b0895d..1afbb462616 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/main.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/main.hpp @@ -10,11 +10,11 @@ template class mainImpl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { - 2, 3, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 4, 4, 3, 3, 3, 3, 4, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 5, 3, 3, 4, 4, 3, 3, 3, 3, 4, 3, 3, 3, 3, 4, 2, 2 + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { + 2, 3, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 4, 4, 3, 3, 3, 3, 4, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 5, 3, 3, 4, 4, 3, 3, 3, 3, 4, 3, 3, 3, 3, 4, 2, 2 }; template @@ -68,11 +68,9 @@ template class mainImpl { const auto main_SEL_ALL_BINARY = ((new_term.main_sel_op_and + new_term.main_sel_op_or) + new_term.main_sel_op_xor); const auto main_SEL_ALL_GADGET = - (((((((new_term.main_sel_op_radix_le + new_term.main_sel_op_sha256) + new_term.main_sel_op_poseidon2) + - new_term.main_sel_op_keccak) + - new_term.main_sel_op_pedersen) + - new_term.main_sel_op_ecadd) + - new_term.main_sel_op_pedersen_commit) + + (((((new_term.main_sel_op_radix_le + new_term.main_sel_op_sha256) + new_term.main_sel_op_poseidon2) + + new_term.main_sel_op_keccak) + + new_term.main_sel_op_ecadd) + new_term.main_sel_op_msm); const auto main_SEL_ALL_MEMORY = (new_term.main_sel_op_mov + new_term.main_sel_op_set); const auto main_OPCODE_SELECTORS = ((((((((((new_term.main_sel_op_fdiv + new_term.main_sel_op_calldata_copy) + @@ -280,520 +278,508 @@ template class mainImpl { } { using Accumulator = typename std::tuple_element_t<31, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_pedersen * (FF(1) - new_term.main_sel_op_pedersen)); + auto tmp = (new_term.main_sel_op_ecadd * (FF(1) - new_term.main_sel_op_ecadd)); tmp *= scaling_factor; std::get<31>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<32, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_ecadd * (FF(1) - new_term.main_sel_op_ecadd)); + auto tmp = (new_term.main_sel_op_msm * (FF(1) - new_term.main_sel_op_msm)); tmp *= scaling_factor; std::get<32>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<33, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_pedersen_commit * (FF(1) - new_term.main_sel_op_pedersen_commit)); + auto tmp = (new_term.main_sel_op_add * (FF(1) - new_term.main_sel_op_add)); tmp *= scaling_factor; std::get<33>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<34, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_msm * (FF(1) - new_term.main_sel_op_msm)); + auto tmp = (new_term.main_sel_op_sub * (FF(1) - new_term.main_sel_op_sub)); tmp *= scaling_factor; std::get<34>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<35, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_add * (FF(1) - new_term.main_sel_op_add)); + auto tmp = (new_term.main_sel_op_mul * (FF(1) - new_term.main_sel_op_mul)); tmp *= scaling_factor; std::get<35>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<36, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_sub * (FF(1) - new_term.main_sel_op_sub)); + auto tmp = (new_term.main_sel_op_div * (FF(1) - new_term.main_sel_op_div)); tmp *= scaling_factor; std::get<36>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<37, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_mul * (FF(1) - new_term.main_sel_op_mul)); + auto tmp = (new_term.main_sel_op_fdiv * (FF(1) - new_term.main_sel_op_fdiv)); tmp *= scaling_factor; std::get<37>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<38, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_div * (FF(1) - new_term.main_sel_op_div)); + auto tmp = (new_term.main_sel_op_not * (FF(1) - new_term.main_sel_op_not)); tmp *= scaling_factor; std::get<38>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<39, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_fdiv * (FF(1) - new_term.main_sel_op_fdiv)); + auto tmp = (new_term.main_sel_op_eq * (FF(1) - new_term.main_sel_op_eq)); tmp *= scaling_factor; std::get<39>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<40, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_not * (FF(1) - new_term.main_sel_op_not)); + auto tmp = (new_term.main_sel_op_and * (FF(1) - new_term.main_sel_op_and)); tmp *= scaling_factor; std::get<40>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<41, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_eq * (FF(1) - new_term.main_sel_op_eq)); + auto tmp = (new_term.main_sel_op_or * (FF(1) - new_term.main_sel_op_or)); tmp *= scaling_factor; std::get<41>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<42, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_and * (FF(1) - new_term.main_sel_op_and)); + auto tmp = (new_term.main_sel_op_xor * (FF(1) - new_term.main_sel_op_xor)); tmp *= scaling_factor; std::get<42>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<43, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_or * (FF(1) - new_term.main_sel_op_or)); + auto tmp = (new_term.main_sel_op_cast * (FF(1) - new_term.main_sel_op_cast)); tmp *= scaling_factor; std::get<43>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<44, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_xor * (FF(1) - new_term.main_sel_op_xor)); + auto tmp = (new_term.main_sel_op_lt * (FF(1) - new_term.main_sel_op_lt)); tmp *= scaling_factor; std::get<44>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<45, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_cast * (FF(1) - new_term.main_sel_op_cast)); + auto tmp = (new_term.main_sel_op_lte * (FF(1) - new_term.main_sel_op_lte)); tmp *= scaling_factor; std::get<45>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<46, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_lt * (FF(1) - new_term.main_sel_op_lt)); + auto tmp = (new_term.main_sel_op_shl * (FF(1) - new_term.main_sel_op_shl)); tmp *= scaling_factor; std::get<46>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<47, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_lte * (FF(1) - new_term.main_sel_op_lte)); + auto tmp = (new_term.main_sel_op_shr * (FF(1) - new_term.main_sel_op_shr)); tmp *= scaling_factor; std::get<47>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<48, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_shl * (FF(1) - new_term.main_sel_op_shl)); + auto tmp = (new_term.main_sel_op_internal_call * (FF(1) - new_term.main_sel_op_internal_call)); tmp *= scaling_factor; std::get<48>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<49, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_shr * (FF(1) - new_term.main_sel_op_shr)); + auto tmp = (new_term.main_sel_op_internal_return * (FF(1) - new_term.main_sel_op_internal_return)); tmp *= scaling_factor; std::get<49>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<50, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_internal_call * (FF(1) - new_term.main_sel_op_internal_call)); + auto tmp = (new_term.main_sel_op_jump * (FF(1) - new_term.main_sel_op_jump)); tmp *= scaling_factor; std::get<50>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<51, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_internal_return * (FF(1) - new_term.main_sel_op_internal_return)); + auto tmp = (new_term.main_sel_op_jumpi * (FF(1) - new_term.main_sel_op_jumpi)); tmp *= scaling_factor; std::get<51>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<52, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_jump * (FF(1) - new_term.main_sel_op_jump)); + auto tmp = (new_term.main_sel_op_external_call * (FF(1) - new_term.main_sel_op_external_call)); tmp *= scaling_factor; std::get<52>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<53, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_jumpi * (FF(1) - new_term.main_sel_op_jumpi)); + auto tmp = (new_term.main_sel_op_static_call * (FF(1) - new_term.main_sel_op_static_call)); tmp *= scaling_factor; std::get<53>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<54, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_external_call * (FF(1) - new_term.main_sel_op_external_call)); + auto tmp = (new_term.main_sel_op_calldata_copy * (FF(1) - new_term.main_sel_op_calldata_copy)); tmp *= scaling_factor; std::get<54>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<55, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_static_call * (FF(1) - new_term.main_sel_op_static_call)); + auto tmp = (new_term.main_sel_op_external_return * (FF(1) - new_term.main_sel_op_external_return)); tmp *= scaling_factor; std::get<55>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<56, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_calldata_copy * (FF(1) - new_term.main_sel_op_calldata_copy)); + auto tmp = (new_term.main_sel_op_external_revert * (FF(1) - new_term.main_sel_op_external_revert)); tmp *= scaling_factor; std::get<56>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<57, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_external_return * (FF(1) - new_term.main_sel_op_external_return)); + auto tmp = (new_term.main_sel_op_set * (FF(1) - new_term.main_sel_op_set)); tmp *= scaling_factor; std::get<57>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<58, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_external_revert * (FF(1) - new_term.main_sel_op_external_revert)); + auto tmp = (new_term.main_sel_op_mov * (FF(1) - new_term.main_sel_op_mov)); tmp *= scaling_factor; std::get<58>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<59, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_set * (FF(1) - new_term.main_sel_op_set)); + auto tmp = (new_term.main_op_err * (FF(1) - new_term.main_op_err)); tmp *= scaling_factor; std::get<59>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<60, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_mov * (FF(1) - new_term.main_sel_op_mov)); + auto tmp = (new_term.main_tag_err * (FF(1) - new_term.main_tag_err)); tmp *= scaling_factor; std::get<60>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<61, ContainerOverSubrelations>; - auto tmp = (new_term.main_op_err * (FF(1) - new_term.main_op_err)); + auto tmp = (new_term.main_id_zero * (FF(1) - new_term.main_id_zero)); tmp *= scaling_factor; std::get<61>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<62, ContainerOverSubrelations>; - auto tmp = (new_term.main_tag_err * (FF(1) - new_term.main_tag_err)); + auto tmp = (new_term.main_sel_mem_op_a * (FF(1) - new_term.main_sel_mem_op_a)); tmp *= scaling_factor; std::get<62>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<63, ContainerOverSubrelations>; - auto tmp = (new_term.main_id_zero * (FF(1) - new_term.main_id_zero)); + auto tmp = (new_term.main_sel_mem_op_b * (FF(1) - new_term.main_sel_mem_op_b)); tmp *= scaling_factor; std::get<63>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<64, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_mem_op_a * (FF(1) - new_term.main_sel_mem_op_a)); + auto tmp = (new_term.main_sel_mem_op_c * (FF(1) - new_term.main_sel_mem_op_c)); tmp *= scaling_factor; std::get<64>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<65, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_mem_op_b * (FF(1) - new_term.main_sel_mem_op_b)); + auto tmp = (new_term.main_sel_mem_op_d * (FF(1) - new_term.main_sel_mem_op_d)); tmp *= scaling_factor; std::get<65>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<66, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_mem_op_c * (FF(1) - new_term.main_sel_mem_op_c)); + auto tmp = (new_term.main_rwa * (FF(1) - new_term.main_rwa)); tmp *= scaling_factor; std::get<66>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<67, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_mem_op_d * (FF(1) - new_term.main_sel_mem_op_d)); + auto tmp = (new_term.main_rwb * (FF(1) - new_term.main_rwb)); tmp *= scaling_factor; std::get<67>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<68, ContainerOverSubrelations>; - auto tmp = (new_term.main_rwa * (FF(1) - new_term.main_rwa)); + auto tmp = (new_term.main_rwc * (FF(1) - new_term.main_rwc)); tmp *= scaling_factor; std::get<68>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<69, ContainerOverSubrelations>; - auto tmp = (new_term.main_rwb * (FF(1) - new_term.main_rwb)); + auto tmp = (new_term.main_rwd * (FF(1) - new_term.main_rwd)); tmp *= scaling_factor; std::get<69>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<70, ContainerOverSubrelations>; - auto tmp = (new_term.main_rwc * (FF(1) - new_term.main_rwc)); + auto tmp = (new_term.main_sel_resolve_ind_addr_a * (FF(1) - new_term.main_sel_resolve_ind_addr_a)); tmp *= scaling_factor; std::get<70>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<71, ContainerOverSubrelations>; - auto tmp = (new_term.main_rwd * (FF(1) - new_term.main_rwd)); + auto tmp = (new_term.main_sel_resolve_ind_addr_b * (FF(1) - new_term.main_sel_resolve_ind_addr_b)); tmp *= scaling_factor; std::get<71>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<72, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_resolve_ind_addr_a * (FF(1) - new_term.main_sel_resolve_ind_addr_a)); + auto tmp = (new_term.main_sel_resolve_ind_addr_c * (FF(1) - new_term.main_sel_resolve_ind_addr_c)); tmp *= scaling_factor; std::get<72>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<73, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_resolve_ind_addr_b * (FF(1) - new_term.main_sel_resolve_ind_addr_b)); + auto tmp = (new_term.main_sel_resolve_ind_addr_d * (FF(1) - new_term.main_sel_resolve_ind_addr_d)); tmp *= scaling_factor; std::get<73>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<74, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_resolve_ind_addr_c * (FF(1) - new_term.main_sel_resolve_ind_addr_c)); + auto tmp = (((new_term.main_sel_op_eq + new_term.main_sel_op_lte) + new_term.main_sel_op_lt) * + (new_term.main_w_in_tag - constants_MEM_TAG_U1)); tmp *= scaling_factor; std::get<74>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<75, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_resolve_ind_addr_d * (FF(1) - new_term.main_sel_resolve_ind_addr_d)); + auto tmp = ((new_term.main_sel_op_fdiv * (FF(1) - new_term.main_op_err)) * + ((new_term.main_ic * new_term.main_ib) - new_term.main_ia)); tmp *= scaling_factor; std::get<75>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<76, ContainerOverSubrelations>; - auto tmp = (((new_term.main_sel_op_eq + new_term.main_sel_op_lte) + new_term.main_sel_op_lt) * - (new_term.main_w_in_tag - constants_MEM_TAG_U1)); + auto tmp = ((new_term.main_sel_op_fdiv + new_term.main_sel_op_div) * + (((new_term.main_ib * new_term.main_inv) - FF(1)) + new_term.main_op_err)); tmp *= scaling_factor; std::get<76>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<77, ContainerOverSubrelations>; - auto tmp = ((new_term.main_sel_op_fdiv * (FF(1) - new_term.main_op_err)) * - ((new_term.main_ic * new_term.main_ib) - new_term.main_ia)); + auto tmp = (((new_term.main_sel_op_fdiv + new_term.main_sel_op_div) * new_term.main_op_err) * + (FF(1) - new_term.main_inv)); tmp *= scaling_factor; std::get<77>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<78, ContainerOverSubrelations>; - auto tmp = ((new_term.main_sel_op_fdiv + new_term.main_sel_op_div) * - (((new_term.main_ib * new_term.main_inv) - FF(1)) + new_term.main_op_err)); + auto tmp = (new_term.main_sel_op_fdiv * (new_term.main_r_in_tag - constants_MEM_TAG_FF)); tmp *= scaling_factor; std::get<78>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<79, ContainerOverSubrelations>; - auto tmp = (((new_term.main_sel_op_fdiv + new_term.main_sel_op_div) * new_term.main_op_err) * - (FF(1) - new_term.main_inv)); + auto tmp = (new_term.main_sel_op_fdiv * (new_term.main_w_in_tag - constants_MEM_TAG_FF)); tmp *= scaling_factor; std::get<79>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<80, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_fdiv * (new_term.main_r_in_tag - constants_MEM_TAG_FF)); + auto tmp = (new_term.main_op_err * ((new_term.main_sel_op_fdiv + new_term.main_sel_op_div) - FF(1))); tmp *= scaling_factor; std::get<80>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<81, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_fdiv * (new_term.main_w_in_tag - constants_MEM_TAG_FF)); + auto tmp = (new_term.main_sel_op_jump * (new_term.main_pc_shift - new_term.main_ia)); tmp *= scaling_factor; std::get<81>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<82, ContainerOverSubrelations>; - auto tmp = (new_term.main_op_err * ((new_term.main_sel_op_fdiv + new_term.main_sel_op_div) - FF(1))); + auto tmp = (new_term.main_sel_op_jumpi * + (((FF(1) - new_term.main_id_zero) * (new_term.main_pc_shift - new_term.main_ia)) + + (new_term.main_id_zero * ((new_term.main_pc_shift - new_term.main_pc) - FF(1))))); tmp *= scaling_factor; std::get<82>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<83, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_jump * (new_term.main_pc_shift - new_term.main_ia)); + auto tmp = (new_term.main_sel_op_internal_call * + (new_term.main_internal_return_ptr_shift - (new_term.main_internal_return_ptr + FF(1)))); tmp *= scaling_factor; std::get<83>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<84, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_jumpi * - (((FF(1) - new_term.main_id_zero) * (new_term.main_pc_shift - new_term.main_ia)) + - (new_term.main_id_zero * ((new_term.main_pc_shift - new_term.main_pc) - FF(1))))); + auto tmp = + (new_term.main_sel_op_internal_call * (new_term.main_internal_return_ptr - new_term.main_mem_addr_b)); tmp *= scaling_factor; std::get<84>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<85, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_internal_call * - (new_term.main_internal_return_ptr_shift - (new_term.main_internal_return_ptr + FF(1)))); + auto tmp = (new_term.main_sel_op_internal_call * (new_term.main_pc_shift - new_term.main_ia)); tmp *= scaling_factor; std::get<85>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<86, ContainerOverSubrelations>; - auto tmp = - (new_term.main_sel_op_internal_call * (new_term.main_internal_return_ptr - new_term.main_mem_addr_b)); + auto tmp = (new_term.main_sel_op_internal_call * ((new_term.main_pc + FF(1)) - new_term.main_ib)); tmp *= scaling_factor; std::get<86>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<87, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_internal_call * (new_term.main_pc_shift - new_term.main_ia)); + auto tmp = (new_term.main_sel_op_internal_call * (new_term.main_rwb - FF(1))); tmp *= scaling_factor; std::get<87>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<88, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_internal_call * ((new_term.main_pc + FF(1)) - new_term.main_ib)); + auto tmp = (new_term.main_sel_op_internal_call * (new_term.main_sel_mem_op_b - FF(1))); tmp *= scaling_factor; std::get<88>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<89, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_internal_call * (new_term.main_rwb - FF(1))); + auto tmp = (new_term.main_sel_op_internal_return * + (new_term.main_internal_return_ptr_shift - (new_term.main_internal_return_ptr - FF(1)))); tmp *= scaling_factor; std::get<89>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<90, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_internal_call * (new_term.main_sel_mem_op_b - FF(1))); + auto tmp = (new_term.main_sel_op_internal_return * + ((new_term.main_internal_return_ptr - FF(1)) - new_term.main_mem_addr_a)); tmp *= scaling_factor; std::get<90>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<91, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_internal_return * - (new_term.main_internal_return_ptr_shift - (new_term.main_internal_return_ptr - FF(1)))); + auto tmp = (new_term.main_sel_op_internal_return * (new_term.main_pc_shift - new_term.main_ia)); tmp *= scaling_factor; std::get<91>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<92, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_internal_return * - ((new_term.main_internal_return_ptr - FF(1)) - new_term.main_mem_addr_a)); + auto tmp = (new_term.main_sel_op_internal_return * new_term.main_rwa); tmp *= scaling_factor; std::get<92>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<93, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_internal_return * (new_term.main_pc_shift - new_term.main_ia)); + auto tmp = (new_term.main_sel_op_internal_return * (new_term.main_sel_mem_op_a - FF(1))); tmp *= scaling_factor; std::get<93>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<94, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_internal_return * new_term.main_rwa); + auto tmp = ((main_CUR_AND_NEXT_ARE_MAIN * (FF(1) - main_SEL_ALL_CTRL_FLOW)) * + (new_term.main_pc_shift - (new_term.main_pc + FF(1)))); tmp *= scaling_factor; std::get<94>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<95, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_internal_return * (new_term.main_sel_mem_op_a - FF(1))); + auto tmp = ((main_CUR_AND_NEXT_ARE_MAIN * (FF(1) - main_SEL_ALL_CTRL_FLOW)) * + (new_term.main_internal_return_ptr_shift - new_term.main_internal_return_ptr)); tmp *= scaling_factor; std::get<95>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<96, ContainerOverSubrelations>; - auto tmp = ((main_CUR_AND_NEXT_ARE_MAIN * (FF(1) - main_SEL_ALL_CTRL_FLOW)) * - (new_term.main_pc_shift - (new_term.main_pc + FF(1)))); + auto tmp = ((new_term.main_sel_op_internal_call + new_term.main_sel_op_internal_return) * + (new_term.main_space_id - constants_misc_INTERNAL_CALL_SPACE_ID)); tmp *= scaling_factor; std::get<96>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<97, ContainerOverSubrelations>; - auto tmp = ((main_CUR_AND_NEXT_ARE_MAIN * (FF(1) - main_SEL_ALL_CTRL_FLOW)) * - (new_term.main_internal_return_ptr_shift - new_term.main_internal_return_ptr)); + auto tmp = (((FF(1) - new_term.main_sel_op_internal_call) - new_term.main_sel_op_internal_return) * + (new_term.main_call_ptr - new_term.main_space_id)); tmp *= scaling_factor; std::get<97>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<98, ContainerOverSubrelations>; - auto tmp = ((new_term.main_sel_op_internal_call + new_term.main_sel_op_internal_return) * - (new_term.main_space_id - constants_misc_INTERNAL_CALL_SPACE_ID)); + auto tmp = (new_term.main_sel_op_jumpi * + (((new_term.main_id * new_term.main_inv) - FF(1)) + new_term.main_id_zero)); tmp *= scaling_factor; std::get<98>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<99, ContainerOverSubrelations>; - auto tmp = (((FF(1) - new_term.main_sel_op_internal_call) - new_term.main_sel_op_internal_return) * - (new_term.main_call_ptr - new_term.main_space_id)); + auto tmp = ((new_term.main_sel_op_jumpi * new_term.main_id_zero) * (FF(1) - new_term.main_inv)); tmp *= scaling_factor; std::get<99>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<100, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_jumpi * - (((new_term.main_id * new_term.main_inv) - FF(1)) + new_term.main_id_zero)); + auto tmp = (new_term.main_sel_mov_ia_to_ic - (new_term.main_sel_op_mov * (FF(1) - new_term.main_id_zero))); tmp *= scaling_factor; std::get<100>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<101, ContainerOverSubrelations>; - auto tmp = ((new_term.main_sel_op_jumpi * new_term.main_id_zero) * (FF(1) - new_term.main_inv)); + auto tmp = (new_term.main_sel_mov_ia_to_ic * (new_term.main_ia - new_term.main_ic)); tmp *= scaling_factor; std::get<101>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<102, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_mov_ia_to_ic - (new_term.main_sel_op_mov * (FF(1) - new_term.main_id_zero))); + auto tmp = (new_term.main_sel_mov_ib_to_ic * (new_term.main_ib - new_term.main_ic)); tmp *= scaling_factor; std::get<102>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<103, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_mov_ia_to_ic * (new_term.main_ia - new_term.main_ic)); + auto tmp = (new_term.main_sel_op_mov * (new_term.main_r_in_tag - new_term.main_w_in_tag)); tmp *= scaling_factor; std::get<103>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<104, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_mov_ib_to_ic * (new_term.main_ib - new_term.main_ic)); + auto tmp = (new_term.main_sel_alu - + ((main_SEL_ALL_ALU * (FF(1) - new_term.main_tag_err)) * (FF(1) - new_term.main_op_err))); tmp *= scaling_factor; std::get<104>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<105, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_mov * (new_term.main_r_in_tag - new_term.main_w_in_tag)); + auto tmp = (main_SEL_ALU_R_TAG * (new_term.main_alu_in_tag - new_term.main_r_in_tag)); tmp *= scaling_factor; std::get<105>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<106, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_alu - - ((main_SEL_ALL_ALU * (FF(1) - new_term.main_tag_err)) * (FF(1) - new_term.main_op_err))); + auto tmp = (main_SEL_ALU_W_TAG * (new_term.main_alu_in_tag - new_term.main_w_in_tag)); tmp *= scaling_factor; std::get<106>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<107, ContainerOverSubrelations>; - auto tmp = (main_SEL_ALU_R_TAG * (new_term.main_alu_in_tag - new_term.main_r_in_tag)); + auto tmp = (new_term.main_sel_op_l2gasleft * (new_term.main_ia - new_term.main_l2_gas_remaining_shift)); tmp *= scaling_factor; std::get<107>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<108, ContainerOverSubrelations>; - auto tmp = (main_SEL_ALU_W_TAG * (new_term.main_alu_in_tag - new_term.main_w_in_tag)); + auto tmp = (new_term.main_sel_op_dagasleft * (new_term.main_ia - new_term.main_da_gas_remaining_shift)); tmp *= scaling_factor; std::get<108>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<109, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_l2gasleft * (new_term.main_ia - new_term.main_l2_gas_remaining_shift)); - tmp *= scaling_factor; - std::get<109>(evals) += typename Accumulator::View(tmp); - } - { - using Accumulator = typename std::tuple_element_t<110, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_dagasleft * (new_term.main_ia - new_term.main_da_gas_remaining_shift)); - tmp *= scaling_factor; - std::get<110>(evals) += typename Accumulator::View(tmp); - } - { - using Accumulator = typename std::tuple_element_t<111, ContainerOverSubrelations>; auto tmp = ((new_term.main_ib * (FF(1) - new_term.main_tag_err)) * ((new_term.main_sel_op_calldata_copy + new_term.main_sel_op_external_return) - new_term.main_sel_slice_gadget)); tmp *= scaling_factor; - std::get<111>(evals) += typename Accumulator::View(tmp); + std::get<109>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<112, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<110, ContainerOverSubrelations>; auto tmp = (new_term.main_bin_op_id - (new_term.main_sel_op_or + (FF(2) * new_term.main_sel_op_xor))); tmp *= scaling_factor; - std::get<112>(evals) += typename Accumulator::View(tmp); + std::get<110>(evals) += typename Accumulator::View(tmp); } { - using Accumulator = typename std::tuple_element_t<113, ContainerOverSubrelations>; + using Accumulator = typename std::tuple_element_t<111, ContainerOverSubrelations>; auto tmp = (new_term.main_sel_bin - ((new_term.main_sel_op_and + new_term.main_sel_op_or) + new_term.main_sel_op_xor)); tmp *= scaling_factor; - std::get<113>(evals) += typename Accumulator::View(tmp); + std::get<111>(evals) += typename Accumulator::View(tmp); } } }; @@ -807,53 +793,53 @@ template class main : public Relation> { switch (index) { case 0: return "OPCODE_SELECTORS"; - case 76: + case 74: return "OUTPUT_U1"; - case 77: + case 75: return "SUBOP_FDIV"; - case 78: + case 76: return "SUBOP_FDIV_ZERO_ERR1"; - case 79: + case 77: return "SUBOP_FDIV_ZERO_ERR2"; - case 80: + case 78: return "SUBOP_FDIV_R_IN_TAG_FF"; - case 81: + case 79: return "SUBOP_FDIV_W_IN_TAG_FF"; - case 82: + case 80: return "SUBOP_ERROR_RELEVANT_OP"; - case 83: + case 81: return "PC_JUMP"; - case 84: + case 82: return "PC_JUMPI"; - case 85: + case 83: return "RETURN_POINTER_INCREMENT"; - case 91: + case 89: return "RETURN_POINTER_DECREMENT"; - case 96: + case 94: return "PC_INCREMENT"; - case 97: + case 95: return "INTERNAL_RETURN_POINTER_CONSISTENCY"; - case 98: + case 96: return "SPACE_ID_INTERNAL"; - case 99: + case 97: return "SPACE_ID_STANDARD_OPCODES"; - case 100: + case 98: return "JMP_CONDITION_RES_1"; - case 101: + case 99: return "JMP_CONDITION_RES_2"; - case 103: + case 101: return "MOV_SAME_VALUE_A"; - case 104: + case 102: return "MOV_SAME_VALUE_B"; - case 105: + case 103: return "MOV_MAIN_SAME_TAG"; - case 109: + case 107: return "L2GASLEFT"; - case 110: + case 108: return "DAGASLEFT"; - case 112: + case 110: return "BIN_SEL_1"; - case 113: + case 111: return "BIN_SEL_2"; } return std::to_string(index); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/pedersen.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/pedersen.hpp deleted file mode 100644 index 8ca5201e767..00000000000 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/pedersen.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// AUTOGENERATED FILE -#pragma once - -#include "barretenberg/relations/relation_parameters.hpp" -#include "barretenberg/relations/relation_types.hpp" - -namespace bb::Avm_vm { - -template class pedersenImpl { - public: - using FF = FF_; - - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3 }; - - template - void static accumulate(ContainerOverSubrelations& evals, - const AllEntities& new_term, - [[maybe_unused]] const RelationParameters&, - [[maybe_unused]] const FF& scaling_factor) - { - - { - using Accumulator = typename std::tuple_element_t<0, ContainerOverSubrelations>; - auto tmp = (new_term.pedersen_sel_pedersen * (FF(1) - new_term.pedersen_sel_pedersen)); - tmp *= scaling_factor; - std::get<0>(evals) += typename Accumulator::View(tmp); - } - } -}; - -template class pedersen : public Relation> { - public: - static constexpr const char* NAME = "pedersen"; - - static std::string get_subrelation_label(size_t index) - { - switch (index) {} - return std::to_string(index); - } -}; - -} // namespace bb::Avm_vm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/perm_main_keccak.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/perm_main_keccak.hpp new file mode 100644 index 00000000000..642eeacab3f --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/perm_main_keccak.hpp @@ -0,0 +1,57 @@ +// AUTOGENERATED FILE +#pragma once + +#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + +#include +#include + +namespace bb { + +class perm_main_keccak_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 3; + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.main_sel_op_keccak == 1 || in.keccakf1600_sel_keccakf1600 == 1); + } + + template static inline auto get_const_entities(const AllEntities& in) + { + return std::forward_as_tuple(in.perm_main_keccak_inv, + in.main_sel_op_keccak, + in.main_sel_op_keccak, + in.keccakf1600_sel_keccakf1600, + in.main_clk, + in.main_ia, + in.main_ic, + in.keccakf1600_clk, + in.keccakf1600_input, + in.keccakf1600_output); + } + + template static inline auto get_nonconst_entities(AllEntities& in) + { + return std::forward_as_tuple(in.perm_main_keccak_inv, + in.main_sel_op_keccak, + in.main_sel_op_keccak, + in.keccakf1600_sel_keccakf1600, + in.main_clk, + in.main_ia, + in.main_ic, + in.keccakf1600_clk, + in.keccakf1600_input, + in.keccakf1600_output); + } +}; + +template +class perm_main_keccak_relation : public GenericPermutationRelation { + public: + static constexpr const char* NAME = "PERM_MAIN_KECCAK"; +}; +template using perm_main_keccak = GenericPermutation; + +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/perm_main_pedersen.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/perm_main_pedersen.hpp deleted file mode 100644 index 77bd92cea43..00000000000 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/perm_main_pedersen.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// AUTOGENERATED FILE -#pragma once - -#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" - -#include -#include - -namespace bb { - -class perm_main_pedersen_permutation_settings { - public: - // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 2; - - template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) - { - return (in.main_sel_op_pedersen == 1 || in.pedersen_sel_pedersen == 1); - } - - template static inline auto get_const_entities(const AllEntities& in) - { - return std::forward_as_tuple(in.perm_main_pedersen_inv, - in.main_sel_op_pedersen, - in.main_sel_op_pedersen, - in.pedersen_sel_pedersen, - in.main_clk, - in.main_ia, - in.pedersen_clk, - in.pedersen_input); - } - - template static inline auto get_nonconst_entities(AllEntities& in) - { - return std::forward_as_tuple(in.perm_main_pedersen_inv, - in.main_sel_op_pedersen, - in.main_sel_op_pedersen, - in.pedersen_sel_pedersen, - in.main_clk, - in.main_ia, - in.pedersen_clk, - in.pedersen_input); - } -}; - -template -class perm_main_pedersen_relation : public GenericPermutationRelation { - public: - static constexpr const char* NAME = "PERM_MAIN_PEDERSEN"; -}; -template using perm_main_pedersen = GenericPermutation; - -} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/perm_main_sha256.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/perm_main_sha256.hpp new file mode 100644 index 00000000000..f0e43d4388d --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/perm_main_sha256.hpp @@ -0,0 +1,61 @@ +// AUTOGENERATED FILE +#pragma once + +#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + +#include +#include + +namespace bb { + +class perm_main_sha256_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 4; + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.main_sel_op_sha256 == 1 || in.sha256_sel_sha256_compression == 1); + } + + template static inline auto get_const_entities(const AllEntities& in) + { + return std::forward_as_tuple(in.perm_main_sha256_inv, + in.main_sel_op_sha256, + in.main_sel_op_sha256, + in.sha256_sel_sha256_compression, + in.main_clk, + in.main_ia, + in.main_ib, + in.main_ic, + in.sha256_clk, + in.sha256_state, + in.sha256_input, + in.sha256_output); + } + + template static inline auto get_nonconst_entities(AllEntities& in) + { + return std::forward_as_tuple(in.perm_main_sha256_inv, + in.main_sel_op_sha256, + in.main_sel_op_sha256, + in.sha256_sel_sha256_compression, + in.main_clk, + in.main_ia, + in.main_ib, + in.main_ic, + in.sha256_clk, + in.sha256_state, + in.sha256_input, + in.sha256_output); + } +}; + +template +class perm_main_sha256_relation : public GenericPermutationRelation { + public: + static constexpr const char* NAME = "PERM_MAIN_SHA256"; +}; +template using perm_main_sha256 = GenericPermutation; + +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/tests/execution.test.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/tests/execution.test.cpp index e0fefd75bd4..a84763abccf 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/tests/execution.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/tests/execution.test.cpp @@ -945,16 +945,16 @@ TEST_F(AvmExecutionTests, poseidon2PermutationOpCode) + to_hex(OpCode::SET_8) + // opcode SET for indirect dst (output) "00" // Indirect flag + to_hex(AvmMemoryTag::U32) + - "09" // value 9 (i.e. where the ouput will be written to) - "23" // dst_offset 35 - + to_hex(OpCode::POSEIDON2) + // opcode POSEIDON2 - "03" // Indirect flag (first 2 operands indirect) - "0024" // input offset (indirect 36) - "0023" // output offset (indirect 35) - + to_hex(OpCode::RETURN) + // opcode RETURN - "00" // Indirect flag - "0009" // ret offset 256 - "0004"; // ret size 8 + "09" // value 9 (i.e. where the ouput will be written to) + "23" // dst_offset 35 + + to_hex(OpCode::POSEIDON2PERM) + // opcode POSEIDON2 + "03" // Indirect flag (first 2 operands indirect) + "0024" // input offset (indirect 36) + "0023" // output offset (indirect 35) + + to_hex(OpCode::RETURN) + // opcode RETURN + "00" // Indirect flag + "0009" // ret offset 256 + "0004"; // ret size 8 auto bytecode = hex_to_bytes(bytecode_hex); auto instructions = Deserialization::parse(bytecode); @@ -1047,125 +1047,6 @@ TEST_F(AvmExecutionTests, keccakf1600OpCode) validate_trace(std::move(trace), public_inputs, calldata, returndata); } -// Positive test with Keccak. -TEST_F(AvmExecutionTests, keccakOpCode) -{ - // Test vectors from keccak256_test_cases in noir/noir-repo/acvm-repo/blackbox_solver/ - // Input: Uint8Array.from([0xbd]), - // Output: Uint8Array.from([ - // 0x5a, 0x50, 0x2f, 0x9f, 0xca, 0x46, 0x7b, 0x26, 0x6d, 0x5b, 0x78, 0x33, 0x65, 0x19, 0x37, 0xe8, 0x05, 0x27, - // 0x0c, 0xa3, 0xf3, 0xaf, 0x1c, 0x0d, 0xd2, 0x46, 0x2d, 0xca, 0x4b, 0x3b, 0x1a, 0xbf, - // ]), - std::vector expected_output = { - FF(0x5a), FF(0x50), FF(0x2f), FF(0x9f), FF(0xca), FF(0x46), FF(0x7b), FF(0x26), FF(0x6d), FF(0x5b), FF(0x78), - FF(0x33), FF(0x65), FF(0x19), FF(0x37), FF(0xe8), FF(0x05), FF(0x27), FF(0x0c), FF(0xa3), FF(0xf3), FF(0xaf), - FF(0x1c), FF(0x0d), FF(0xd2), FF(0x46), FF(0x2d), FF(0xca), FF(0x4b), FF(0x3b), FF(0x1a), FF(0xbf) - }; - std::string bytecode_hex = to_hex(OpCode::SET_8) + // Initial SET operations to store state and input - "00" // Indirect Flag - + to_hex(AvmMemoryTag::U8) + - "BD" // val 189 - "01" // dst_offset 1 - + to_hex(OpCode::SET_8) + // opcode SET for indirect src (input) - "00" // Indirect flag - + to_hex(AvmMemoryTag::U32) + - "01" // value 1 (i.e. where the src will be read from) - "24" // input_offset 36 - + to_hex(OpCode::SET_8) + // - "00" // Indirect flag - + to_hex(AvmMemoryTag::U8) + - "01" // value 1 (i.e. where the length parameter is stored) - "25" // input_offset 37 - + to_hex(OpCode::SET_16) + // opcode SET for indirect dst (output) - "00" // Indirect flag - + to_hex(AvmMemoryTag::U32) + - "0100" // value 256 (i.e. where the ouput will be written to) - "0023" // dst_offset 35 - + to_hex(OpCode::KECCAK) + // opcode KECCAK - "03" // Indirect flag (first 2 operands indirect) - "00000023" // output offset (indirect 35) - "00000024" // input offset (indirect 36) - "00000025" // length offset 37 - + to_hex(OpCode::RETURN) + // opcode RETURN - "00" // Indirect flag - "0100" // ret offset 256 - "0020"; // ret size 32 - - auto bytecode = hex_to_bytes(bytecode_hex); - auto instructions = Deserialization::parse(bytecode); - - // Assign a vector that we will mutate internally in gen_trace to store the return values; - std::vector calldata = std::vector(); - std::vector returndata = std::vector(); - auto trace = Execution::gen_trace(instructions, returndata, calldata, public_inputs_vec); - - EXPECT_EQ(returndata, expected_output); - - validate_trace(std::move(trace), public_inputs, calldata, returndata); -} - -// Positive test with Pedersen. -TEST_F(AvmExecutionTests, pedersenHashOpCode) -{ - // Test vectors from pedersen_hash in noir/noir-repo/acvm-repo/blackbox_solver/ - // input = [1,1] - // output = 0x1c446df60816b897cda124524e6b03f36df0cec333fad87617aab70d7861daa6 - // hash_index = 5; - FF expected_output = FF("0x1c446df60816b897cda124524e6b03f36df0cec333fad87617aab70d7861daa6"); - std::string bytecode_hex = to_hex(OpCode::SET_8) + // opcode SET - "00" // Indirect flag - + to_hex(AvmMemoryTag::U32) + - "00" // val - "00" // dst_offset - + to_hex(OpCode::SET_8) + // opcode SET - "00" // Indirect flag - + to_hex(AvmMemoryTag::U32) + - "02" // val - "01" // dst_offset - + to_hex(OpCode::CALLDATACOPY) + // Calldatacopy - "00" // Indirect flag - "0000" // cd_offset - "0001" // copy_size - "0000" // dst_offset - + to_hex(OpCode::SET_8) + // opcode SET for direct hash index offset - "00" // Indirect flag - + to_hex(AvmMemoryTag::U32) + - "05" // value 5 - "02" // input_offset 2 - + to_hex(OpCode::SET_8) + // opcode SET for indirect src - "00" // Indirect flag - + to_hex(AvmMemoryTag::U32) + - "00" // value 0 (i.e. where the src will be read from) - "04" // dst_offset 4 - + to_hex(OpCode::SET_8) + // opcode SET for direct src_length - "00" // Indirect flag - + to_hex(AvmMemoryTag::U32) + - "02" // value 2 - "05" // dst_offset - + to_hex(OpCode::PEDERSEN) + // opcode PEDERSEN - "04" // Indirect flag (3rd operand indirect) - "00000002" // hash_index offset (direct) - "00000003" // dest offset (direct) - "00000004" // input offset (indirect) - "00000005" // length offset (direct) - + to_hex(OpCode::RETURN) + // opcode RETURN - "00" // Indirect flag - "0003" // ret offset 3 - "0001"; // ret size 1 - - auto bytecode = hex_to_bytes(bytecode_hex); - auto instructions = Deserialization::parse(bytecode); - - // Assign a vector that we will mutate internally in gen_trace to store the return values; - std::vector returndata = std::vector(); - std::vector calldata = { FF(1), FF(1) }; - auto trace = Execution::gen_trace(instructions, returndata, calldata, public_inputs_vec); - - EXPECT_EQ(returndata[0], expected_output); - - validate_trace(std::move(trace), public_inputs, calldata, returndata); -} -// // Positive test with EmbeddedCurveAdd TEST_F(AvmExecutionTests, embeddedCurveAddOpCode) { @@ -1320,79 +1201,6 @@ TEST_F(AvmExecutionTests, msmOpCode) validate_trace(std::move(trace), public_inputs, calldata, returndata); } -// Positive test with pedersen commitment -TEST_F(AvmExecutionTests, pedersenCommitmentOpcode) -{ - auto expected_result = - grumpkin::g1::affine_element(fr(uint256_t("054aa86a73cb8a34525e5bbed6e43ba1198e860f5f3950268f71df4591bde402")), - fr(uint256_t("209dcfbf2cfb57f9f6046f44d71ac6faf87254afc7407c04eb621a6287cac126"))); - // grumpkin::g1::affine_eleelement; - // grumpkin::g1::affine_element b = grumpkin::g1::affine_element::one(); - - // Remmeber that grumpkin Fq == BN254 Fr => aka FF - grumpkin::g1::Fq scalar_a = grumpkin::g1::Fq::zero(); - grumpkin::g1::Fq scalar_b = grumpkin::g1::Fq::one(); - std::vector expected_output = { expected_result.x, expected_result.y, expected_result.is_point_at_infinity() }; - // Send all the input as Fields and cast them to U8 later - std::vector calldata = { scalar_a, scalar_b }; - std::string bytecode_hex = to_hex(OpCode::SET_8) + // opcode SET - "00" // Indirect flag - + to_hex(AvmMemoryTag::U32) + - "00" // val - "00" // dst_offset - + to_hex(OpCode::SET_8) + // opcode SET - "00" // Indirect flag - + to_hex(AvmMemoryTag::U32) + - "02" // val - "01" + - to_hex(OpCode::CALLDATACOPY) + // Calldatacopy - "00" // Indirect flag - "0000" // cd_offset 0 - "0001" // copy_size (2 elements) - "0000" // dst_offset 0 - + to_hex(OpCode::SET_8) + // opcode SET for indirect input - "00" // Indirect flag - + to_hex(AvmMemoryTag::U32) + - "00" // Input stored at memory 0 - "0b" // dst offset (11) - + to_hex(OpCode::SET_8) + // opcode SET for indirect output - "00" // Indirect flag - + to_hex(AvmMemoryTag::U32) + - "20" // output offset - "0d" // dst offset - + to_hex(OpCode::SET_8) + // opcode SET for input length - "00" // Indirect flag - + to_hex(AvmMemoryTag::U32) + - "02" // scalars length (2) - "02" + // dst offset (2) - to_hex(OpCode::SET_8) + // opcode SET for ctx index - "00" // Indirect flag - + to_hex(AvmMemoryTag::U32) + - "00" // ctx index (0) - "0f" + // dst offset - to_hex(OpCode::PEDERSENCOMMITMENT) + // opcode MSM - "03" // Indirect flag (first 2 indirect) - "0000000b" // inputs offset - "0000000d" // outputs offset - "00000002" // inputs length offset - "0000000f" // gen ctx index offset - + to_hex(OpCode::RETURN) + // opcode RETURN - "00" // Indirect flag - "0020" // ret offset - "0003"; // ret size 3 - - auto bytecode = hex_to_bytes(bytecode_hex); - auto instructions = Deserialization::parse(bytecode); - - // Assign a vector that we will mutate internally in gen_trace to store the return values; - std::vector returndata; - auto trace = Execution::gen_trace(instructions, returndata, calldata, public_inputs_vec); - - EXPECT_EQ(returndata, expected_output); - - validate_trace(std::move(trace), public_inputs, calldata, returndata); -} - // Positive test for Kernel Input opcodes TEST_F(AvmExecutionTests, kernelInputOpcodes) { diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/deserialization.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/deserialization.cpp index 8486677b365..7c5741f8769 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/deserialization.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/deserialization.cpp @@ -160,13 +160,10 @@ const std::unordered_map> OPCODE_WIRE_FORMAT = // Gadgets // Gadgets - Hashing - { OpCode::KECCAK, { OperandType::INDIRECT8, OperandType::UINT32, OperandType::UINT32, OperandType::UINT32 } }, - { OpCode::POSEIDON2, { OperandType::INDIRECT8, OperandType::UINT16, OperandType::UINT16 } }, + { OpCode::POSEIDON2PERM, { OperandType::INDIRECT8, OperandType::UINT16, OperandType::UINT16 } }, { OpCode::SHA256COMPRESSION, { OperandType::INDIRECT8, OperandType::UINT16, OperandType::UINT16, OperandType::UINT16 } }, { OpCode::KECCAKF1600, { OperandType::INDIRECT8, OperandType::UINT16, OperandType::UINT16, OperandType::UINT16 } }, - { OpCode::PEDERSEN, - { OperandType::INDIRECT8, OperandType::UINT32, OperandType::UINT32, OperandType::UINT32, OperandType::UINT32 } }, // TEMP ECADD without relative memory { OpCode::ECADD, { OperandType::INDIRECT16, @@ -179,8 +176,6 @@ const std::unordered_map> OPCODE_WIRE_FORMAT = OperandType::UINT16 } }, // dst_offset { OpCode::MSM, { OperandType::INDIRECT8, OperandType::UINT16, OperandType::UINT16, OperandType::UINT16, OperandType::UINT16 } }, - { OpCode::PEDERSENCOMMITMENT, - { OperandType::INDIRECT8, OperandType::UINT32, OperandType::UINT32, OperandType::UINT32, OperandType::UINT32 } }, // Gadget - Conversion { OpCode::TORADIXLE, { OperandType::INDIRECT8, @@ -189,10 +184,6 @@ const std::unordered_map> OPCODE_WIRE_FORMAT = OperandType::UINT16, OperandType::UINT16, OperandType::UINT8 } }, - // Gadgets - Unused for now - { OpCode::SHA256COMPRESSION, - { OperandType::INDIRECT8, OperandType::UINT16, OperandType::UINT16, OperandType::UINT16 } }, - { OpCode::KECCAKF1600, { OperandType::INDIRECT8, OperandType::UINT16, OperandType::UINT16, OperandType::UINT16 } }, }; const std::unordered_map OPERAND_TYPE_SIZE = { diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/execution.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/execution.cpp index eedeac2f984..e7560783e95 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/execution.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/execution.cpp @@ -693,26 +693,28 @@ std::vector Execution::gen_trace(std::vector const& instructio break; // Gadgets - case OpCode::KECCAK: - trace_builder.op_keccak(std::get(inst.operands.at(0)), - std::get(inst.operands.at(1)), - std::get(inst.operands.at(2)), - std::get(inst.operands.at(3))); - - break; - case OpCode::POSEIDON2: + case OpCode::POSEIDON2PERM: trace_builder.op_poseidon2_permutation(std::get(inst.operands.at(0)), std::get(inst.operands.at(1)), std::get(inst.operands.at(2))); break; - case OpCode::PEDERSEN: - trace_builder.op_pedersen_hash(std::get(inst.operands.at(0)), - std::get(inst.operands.at(1)), - std::get(inst.operands.at(2)), - std::get(inst.operands.at(3)), - std::get(inst.operands.at(4))); + + case OpCode::SHA256COMPRESSION: + trace_builder.op_sha256_compression(std::get(inst.operands.at(0)), + std::get(inst.operands.at(1)), + std::get(inst.operands.at(2)), + std::get(inst.operands.at(3))); break; + + case OpCode::KECCAKF1600: + trace_builder.op_keccakf1600(std::get(inst.operands.at(0)), + std::get(inst.operands.at(1)), + std::get(inst.operands.at(2)), + std::get(inst.operands.at(3))); + + break; + case OpCode::ECADD: trace_builder.op_ec_add(std::get(inst.operands.at(0)), std::get(inst.operands.at(1)), @@ -741,28 +743,6 @@ std::vector Execution::gen_trace(std::vector const& instructio std::get(inst.operands.at(5))); break; - case OpCode::SHA256COMPRESSION: - trace_builder.op_sha256_compression(std::get(inst.operands.at(0)), - std::get(inst.operands.at(1)), - std::get(inst.operands.at(2)), - std::get(inst.operands.at(3))); - break; - - case OpCode::KECCAKF1600: - trace_builder.op_keccakf1600(std::get(inst.operands.at(0)), - std::get(inst.operands.at(1)), - std::get(inst.operands.at(2)), - std::get(inst.operands.at(3))); - - break; - case OpCode::PEDERSENCOMMITMENT: - trace_builder.op_pedersen_commit(std::get(inst.operands.at(0)), - std::get(inst.operands.at(1)), - std::get(inst.operands.at(2)), - std::get(inst.operands.at(3)), - std::get(inst.operands.at(4))); - - break; default: throw_or_abort("Don't know how to execute opcode " + to_hex(inst.op_code) + " at pc " + std::to_string(pc) + "."); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/fixed_gas.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/fixed_gas.cpp index 9f37ad46e98..f2cd4da1506 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/fixed_gas.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/fixed_gas.cpp @@ -83,15 +83,11 @@ const std::unordered_map GAS_COST_TABLE = { { OpCode::REVERT_8, make_cost(AVM_REVERT_BASE_L2_GAS, 0, AVM_REVERT_DYN_L2_GAS, 0) }, { OpCode::REVERT_16, make_cost(AVM_REVERT_BASE_L2_GAS, 0, AVM_REVERT_DYN_L2_GAS, 0) }, { OpCode::DEBUGLOG, make_cost(AVM_DEBUGLOG_BASE_L2_GAS, 0, 0, 0) }, - { OpCode::KECCAK, make_cost(AVM_KECCAK_BASE_L2_GAS, 0, AVM_KECCAK_DYN_L2_GAS, 0) }, - { OpCode::POSEIDON2, make_cost(AVM_POSEIDON2_BASE_L2_GAS, 0, 0, 0) }, + { OpCode::POSEIDON2PERM, make_cost(AVM_POSEIDON2_BASE_L2_GAS, 0, 0, 0) }, { OpCode::SHA256COMPRESSION, make_cost(AVM_SHA256COMPRESSION_BASE_L2_GAS, 0, 0, 0) }, { OpCode::KECCAKF1600, make_cost(AVM_KECCAKF1600_BASE_L2_GAS, 0, 0, 0) }, - { OpCode::PEDERSEN, make_cost(AVM_PEDERSEN_BASE_L2_GAS, 0, AVM_PEDERSEN_DYN_L2_GAS, 0) }, { OpCode::ECADD, make_cost(AVM_ECADD_BASE_L2_GAS, 0, 0, 0) }, { OpCode::MSM, make_cost(AVM_MSM_BASE_L2_GAS, 0, AVM_MSM_DYN_L2_GAS, 0) }, - { OpCode::PEDERSENCOMMITMENT, - make_cost(AVM_PEDERSENCOMMITMENT_BASE_L2_GAS, 0, AVM_PEDERSENCOMMITMENT_DYN_L2_GAS, 0) }, { OpCode::TORADIXLE, make_cost(AVM_TORADIXLE_BASE_L2_GAS, 0, AVM_TORADIXLE_DYN_L2_GAS, 0) }, }; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/keccak.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/keccak.cpp index f998505aa48..d7f90159e63 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/keccak.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/keccak.cpp @@ -42,44 +42,4 @@ std::array AvmKeccakTraceBuilder::keccakf1600(uint32_t clk, std::a return output; } -std::array AvmKeccakTraceBuilder::keccak(uint32_t clk, std::vector input, uint32_t size) -{ - // Pad input to a multiple of 8 bytes - if (!input.empty()) { - input.resize(8 * ((input.size() - 1) / 8 + 1)); - } - - // We treat the input vector as an array of 64-bit integers for the avm (even though keccak takes in bytes). - std::vector vector_input; - for (size_t i = 0; i < input.size(); i += 8) { - auto uint64 = from_buffer(input, i); - vector_input.push_back(uint64); - } - auto result = ethash_keccak256(&input[0], size); - std::vector output_vector = {}; - std::array output_bytes = {}; - // The result encodes each limb in LE, we need to swap them to BE - // If we had C++23 we could use std::byteswap, but instead we write our own - for (size_t i = 0; i < 4; i++) { - std::vector le_bytes = to_buffer(result.word64s[i]); - // Reverse the bytes - std::ranges::reverse(le_bytes); - // Convert the bytes back to a uint64_t - auto be_u64 = from_buffer(le_bytes); - output_vector.push_back(be_u64); - // Copy the bytes to the output - for (size_t j = 0; j < 8; j++) { - output_bytes[i * 8 + j] = le_bytes[j]; - } - } - keccak_trace.push_back(KeccakTraceEntry{ - .clk = clk, - .input = vector_input, - .output = output_vector, - .input_size = size, - .output_size = 4, - }); - return output_bytes; -} - } // namespace bb::avm_trace diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/keccak.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/keccak.hpp index 925feaf3440..621b8985f94 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/keccak.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/keccak.hpp @@ -24,7 +24,6 @@ class AvmKeccakTraceBuilder { std::vector finalize(); std::array keccakf1600(uint32_t clk, std::array input); - std::array keccak(uint32_t clk, std::vector input, uint32_t size); private: std::vector keccak_trace; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/pedersen.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/pedersen.cpp deleted file mode 100644 index 3d94837692b..00000000000 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/pedersen.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "barretenberg/crypto/pedersen_hash/pedersen.hpp" -#include "barretenberg/vm/avm/trace/common.hpp" -#include "barretenberg/vm/avm/trace/gadgets/pedersen.hpp" - -namespace bb::avm_trace { - -std::vector AvmPedersenTraceBuilder::finalize() -{ - return std::move(pedersen_trace); -} - -void AvmPedersenTraceBuilder::reset() -{ - pedersen_trace.clear(); - pedersen_trace.shrink_to_fit(); // Reclaim memory. -} - -FF AvmPedersenTraceBuilder::pedersen_hash(const std::vector& inputs, uint32_t offset, uint32_t clk) -{ - crypto::GeneratorContext ctx; - ctx.offset = offset; - // Use the standard domain separator starting at ctx.offset - FF output = crypto::pedersen_hash::hash(inputs, ctx); - pedersen_trace.push_back({ clk, inputs, output }); - - return output; -} - -} // namespace bb::avm_trace diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/pedersen.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/pedersen.hpp deleted file mode 100644 index 9fce7b70cb7..00000000000 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/pedersen.hpp +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -#include "barretenberg/vm/avm/trace/common.hpp" - -#include -#include - -namespace bb::avm_trace { - -class AvmPedersenTraceBuilder { - public: - struct PedersenTraceEntry { - uint32_t clk = 0; - std::vector input; - FF output; - }; - - AvmPedersenTraceBuilder() = default; - void reset(); - // Finalize the trace - std::vector finalize(); - - // Note that this version of pedersen_hash is defined over Grumpkin (we could make it generic later if we wanted to - // also support BBJubJub) The inputs are Fr_BN254, and the output is Fq_Grumpkin (which is also Fr_BN254 since - // Grumpkin and BN254 form a 2-cycle). - FF pedersen_hash(const std::vector& inputs, uint32_t offset, uint32_t clk); - - private: - std::vector pedersen_trace; -}; - -} // namespace bb::avm_trace diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/sha256.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/sha256.cpp index ff51cbab113..848e4a4eb57 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/sha256.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/sha256.cpp @@ -118,12 +118,4 @@ std::array AvmSha256TraceBuilder::sha256_compression(const std::arr return output; } -std::array AvmSha256TraceBuilder::sha256(const std::vector& input, uint32_t clk) -{ - auto output = crypto::sha256(input); - // Cant push here since we are not using the same format as the sha256_compression - sha256_trace.push_back(Sha256TraceEntry{ clk, {}, {}, {} }); - return output; -} - } // namespace bb::avm_trace diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/sha256.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/sha256.hpp index 38a4272e08a..d52fe438d61 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/sha256.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/sha256.hpp @@ -25,7 +25,6 @@ class AvmSha256TraceBuilder { std::array sha256_compression(const std::array& h_init, const std::array& input, uint32_t clk); - std::array sha256(const std::vector& input, uint32_t clk); private: std::vector sha256_trace; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/opcode.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/opcode.cpp index 724ee32e2cc..2e03e98b91e 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/opcode.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/opcode.cpp @@ -159,16 +159,12 @@ std::string to_string(OpCode opcode) case OpCode::DEBUGLOG: return "DEBUGLOG"; // Gadgets - case OpCode::KECCAK: - return "KECCAK"; - case OpCode::POSEIDON2: + case OpCode::POSEIDON2PERM: return "POSEIDON2"; case OpCode::SHA256COMPRESSION: return "SHA256COMPRESSION"; case OpCode::KECCAKF1600: return "KECCAKF1600"; - case OpCode::PEDERSEN: - return "PEDERSEN"; case OpCode::ECADD: return "ECADD"; case OpCode::MSM: diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/opcode.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/opcode.hpp index feab28e807a..e4d4cfb1da2 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/opcode.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/opcode.hpp @@ -99,14 +99,11 @@ enum class OpCode : uint8_t { DEBUGLOG, // Gadgets - KECCAK, - POSEIDON2, + POSEIDON2PERM, SHA256COMPRESSION, KECCAKF1600, - PEDERSEN, ECADD, MSM, - PEDERSENCOMMITMENT, // Conversions TORADIXLE, diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.cpp index 0f638ca0811..ca6fd5b513d 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.cpp @@ -16,7 +16,6 @@ #include "barretenberg/common/assert.hpp" #include "barretenberg/common/serialize.hpp" #include "barretenberg/common/throw_or_abort.hpp" -#include "barretenberg/crypto/pedersen_commitment/pedersen.hpp" #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" #include "barretenberg/numeric/uint256/uint256.hpp" #include "barretenberg/polynomials/univariate.hpp" @@ -2763,65 +2762,6 @@ std::vector AvmTraceBuilder::op_revert(uint8_t indirect, uint32_t ret_offset * GADGETS **************************************************************************************************/ -/** - * @brief Keccak with direct or indirect memory access. - * Keccak is TEMPORARY while we wait for the transition to keccakf1600, so we do the minimal to store the result - * @param indirect byte encoding information about indirect/direct memory access. - * @param output_offset An index in memory pointing to where the first u8 value of the output array should be - * stored. - * @param input_offset An index in memory pointing to the first u8 value of the input array to be used - * @param input_size offset An index in memory pointing to the size of the input array. - */ -void AvmTraceBuilder::op_keccak(uint8_t indirect, - uint32_t output_offset, - uint32_t input_offset, - uint32_t input_size_offset) -{ - auto clk = static_cast(main_trace.size()) + 1; - - auto [resolved_output_offset, resolved_input_offset, resolved_input_size_offset] = - Addressing<3>::fromWire(indirect, call_ptr) - .resolve({ output_offset, input_offset, input_size_offset }, mem_trace_builder); - - // Read the input length first - auto input_length_read = constrained_read_from_memory( - call_ptr, clk, resolved_input_size_offset, AvmMemoryTag::U32, AvmMemoryTag::U0, IntermRegister::IB); - - // Constrain gas cost - gas_trace_builder.constrain_gas(clk, OpCode::KECCAK, static_cast(input_length_read.val)); - - // Store the clock time that we will use to line up the gadget later - auto keccak_op_clk = clk; - main_trace.push_back(Row{ - .main_clk = clk, - .main_ib = input_length_read.val, // Message Length - .main_ind_addr_b = FF(input_length_read.indirect_address), - .main_internal_return_ptr = FF(internal_return_ptr), - .main_mem_addr_b = FF(input_length_read.direct_address), // length - .main_pc = FF(pc++), - .main_r_in_tag = FF(static_cast(AvmMemoryTag::U32)), - .main_sel_mem_op_b = FF(1), - .main_sel_op_keccak = FF(1), - .main_sel_resolve_ind_addr_b = FF(static_cast(input_length_read.is_indirect)), - .main_tag_err = FF(static_cast(!input_length_read.tag_match)), - }); - clk++; - - std::vector input; - input.reserve(uint32_t(input_length_read.val)); - // Read the slice length from memory - read_slice_from_memory(resolved_input_offset, uint32_t(input_length_read.val), input); - - std::array result = keccak_trace_builder.keccak(keccak_op_clk, input, uint32_t(input_length_read.val)); - // We convert the results to field elements here - std::vector ff_result; - for (uint32_t i = 0; i < 32; i++) { - ff_result.emplace_back(result[i]); - } - // Write the result to memory after - write_slice_to_memory(resolved_output_offset, AvmMemoryTag::U8, ff_result); -} - /** * @brief Poseidon2 Permutation with direct or indirect memory access. * @@ -2844,7 +2784,7 @@ void AvmTraceBuilder::op_poseidon2_permutation(uint8_t indirect, uint32_t input_ // Resolve indirects in the main trace. Do not resolve the value stored in direct addresses. // Constrain gas cost - gas_trace_builder.constrain_gas(clk, OpCode::POSEIDON2); + gas_trace_builder.constrain_gas(clk, OpCode::POSEIDON2PERM); // Main trace contains on operand values from the bytecode and resolved indirects main_trace.push_back(Row{ @@ -2935,55 +2875,162 @@ void AvmTraceBuilder::op_poseidon2_permutation(uint8_t indirect, uint32_t input_ } /** - * @brief Pedersen Hash with direct or indirect memory access. + * @brief SHA256 Compression with direct or indirect memory access. + * * @param indirect byte encoding information about indirect/direct memory access. - * @param gen_ctx_offset An index in memory pointing to where the u32 offset for the pedersen hash generators. - * @param input_offset An index in memory pointing to the first FF value of the input array to be used in the next - * @param input_size offset An index in memory pointing to the size of the input array. + * @param state_offset An index in memory pointing to the first U32 value of the state array to be used in the next + * instance of sha256 compression. + * @param input_offset An index in memory pointing to the first U32 value of the input array to be used in the next + * instance of sha256 compression. + * @param output_offset An index in memory pointing to where the first U32 value of the output array should be + * stored. */ -void AvmTraceBuilder::op_pedersen_hash(uint8_t indirect, - uint32_t gen_ctx_offset, - uint32_t output_offset, - uint32_t input_offset, - uint32_t input_size_offset) +void AvmTraceBuilder::op_sha256_compression(uint8_t indirect, + uint32_t output_offset, + uint32_t state_offset, + uint32_t inputs_offset) { + // The clk plays a crucial role in this function as we attempt to write across multiple lines in the main trace. auto clk = static_cast(main_trace.size()) + 1; - auto [resolved_gen_ctx_offset, resolved_output_offset, resolved_input_offset, resolved_input_size_offset] = - Addressing<4>::fromWire(indirect, call_ptr) - .resolve({ gen_ctx_offset, output_offset, input_offset, input_size_offset }, mem_trace_builder); + // Resolve the indirect flags, the results of this function are used to determine the memory offsets + // that point to the starting memory addresses for the input and output values. + auto [resolved_output_offset, resolved_state_offset, resolved_inputs_offset] = + Addressing<3>::fromWire(indirect, call_ptr) + .resolve({ output_offset, state_offset, inputs_offset }, mem_trace_builder); + + auto read_a = constrained_read_from_memory( + call_ptr, clk, resolved_state_offset, AvmMemoryTag::U32, AvmMemoryTag::U0, IntermRegister::IA); + auto read_b = constrained_read_from_memory( + call_ptr, clk, resolved_inputs_offset, AvmMemoryTag::U32, AvmMemoryTag::U0, IntermRegister::IB); + bool tag_match = read_a.tag_match && read_b.tag_match; + + // Constrain gas cost + gas_trace_builder.constrain_gas(clk, OpCode::SHA256COMPRESSION); + + // Since the above adds mem_reads in the mem_trace_builder at clk, we need to follow up resolving the reads in + // the main trace at the same clk cycle to preserve the cross-table permutation + // + // TODO<#6383>: We put the first value of each of the input, output (which is 0 at this point) and h_init arrays + // into the main trace at the intermediate registers simply for the permutation check, in the future this will + // change. + // Note: we could avoid output being zero if we loaded the input and state beforehand (with a new function that + // did not lay down constraints), but this is a simplification + main_trace.push_back(Row{ + .main_clk = clk, + .main_ia = read_a.val, // First element of state + .main_ib = read_b.val, // First element of input + .main_ind_addr_a = FF(read_a.indirect_address), + .main_ind_addr_b = FF(read_b.indirect_address), + .main_internal_return_ptr = FF(internal_return_ptr), + .main_mem_addr_a = FF(read_a.direct_address), + .main_mem_addr_b = FF(read_b.direct_address), + .main_pc = FF(pc++), + .main_r_in_tag = FF(static_cast(AvmMemoryTag::U32)), + .main_sel_mem_op_a = FF(1), + .main_sel_mem_op_b = FF(1), + .main_sel_op_sha256 = FF(1), + .main_sel_resolve_ind_addr_a = FF(static_cast(read_a.is_indirect)), + .main_sel_resolve_ind_addr_b = FF(static_cast(read_b.is_indirect)), + .main_tag_err = FF(static_cast(!tag_match)), + }); + // We store the current clk this main trace row occurred so that we can line up the sha256 gadget operation at + // the same clk later. + auto sha_op_clk = clk; + // We need to increment the clk + clk++; + // State array input is fixed to 256 bits + std::vector h_init_vec; + // Input for hash is expanded to 512 bits + std::vector input_vec; + // Read results are written to h_init array. + read_slice_from_memory(resolved_state_offset, 8, h_init_vec); + // Read results are written to input array + read_slice_from_memory(resolved_inputs_offset, 16, input_vec); + + // Now that we have read all the values, we can perform the operation to get the resulting witness. + // Note: We use the sha_op_clk to ensure that the sha256 operation is performed at the same clock cycle as the + // main trace that has the selector + std::array h_init = vec_to_arr(h_init_vec); + std::array input = vec_to_arr(input_vec); + + std::array result = sha256_trace_builder.sha256_compression(h_init, input, sha_op_clk); + // We convert the results to field elements here + std::vector ff_result; + for (uint32_t i = 0; i < 8; i++) { + ff_result.emplace_back(result[i]); + } + + // Write the result to memory after + write_slice_to_memory(resolved_output_offset, AvmMemoryTag::U32, ff_result); +} + +/** + * @brief Keccakf1600 with direct or indirect memory access. + * This function temporarily has the same interface as the kecccak opcode for compatibility, when the keccak + * migration is complete (to keccakf1600) We will update this function call as we will not likely need + * input_size_offset + * @param indirect byte encoding information about indirect/direct memory access. + * @param output_offset An index in memory pointing to where the first u64 value of the output array should be + * stored. + * @param input_offset An index in memory pointing to the first u64 value of the input array to be used in the next + * instance of poseidon2 permutation. + * @param input_size offset An index in memory pointing to the size of the input array. Temporary while we maintain + * the same interface as keccak (this is fixed to 25) + */ +void AvmTraceBuilder::op_keccakf1600(uint8_t indirect, + uint32_t output_offset, + uint32_t input_offset, + [[maybe_unused]] uint32_t input_size_offset) +{ + vinfo(indirect); + vinfo(output_offset); + vinfo(input_size_offset); + vinfo(input_offset); + // What happens if the input_size_offset is > 25 when the state is more that that? + auto clk = static_cast(main_trace.size()) + 1; + auto [resolved_output_offset, resolved_input_offset] = + Addressing<2>::fromWire(indirect, call_ptr).resolve({ output_offset, input_offset }, mem_trace_builder); auto input_read = constrained_read_from_memory( - call_ptr, clk, resolved_input_offset, AvmMemoryTag::FF, AvmMemoryTag::U0, IntermRegister::IA); - // auto input_size_read = constrained_read_from_memory( - // call_ptr, clk, resolved_input_size_offset, AvmMemoryTag::U32, AvmMemoryTag::U0, IntermRegister::IB); - // auto gen_ctx_read = constrained_read_from_memory( - // call_ptr, clk, resolved_gen_ctx_offset, AvmMemoryTag::U32, AvmMemoryTag::U0, IntermRegister::IC); - auto input_size_read = unconstrained_read_from_memory(resolved_input_size_offset); - auto gen_ctx_read = unconstrained_read_from_memory(resolved_gen_ctx_offset); + call_ptr, clk, resolved_input_offset, AvmMemoryTag::U64, AvmMemoryTag::U0, IntermRegister::IA); + auto output_read = constrained_read_from_memory( + call_ptr, clk, resolved_output_offset, AvmMemoryTag::U64, AvmMemoryTag::U0, IntermRegister::IC); + bool tag_match = input_read.tag_match && output_read.tag_match; // Constrain gas cost - // TODO(dbanks12): need tag check u32 here on input size - gas_trace_builder.constrain_gas(clk, OpCode::PEDERSEN, static_cast(input_size_read)); + gas_trace_builder.constrain_gas(clk, OpCode::KECCAKF1600); - // We read the input and output addresses in one row as they should contain FF elements main_trace.push_back(Row{ .main_clk = clk, - .main_ia = input_read.val, // First element of input + .main_ia = input_read.val, // First element of input + .main_ic = output_read.val, // First element of output .main_ind_addr_a = FF(input_read.indirect_address), + .main_ind_addr_c = FF(output_read.indirect_address), .main_internal_return_ptr = FF(internal_return_ptr), .main_mem_addr_a = FF(input_read.direct_address), + .main_mem_addr_c = FF(output_read.direct_address), .main_pc = FF(pc++), - .main_r_in_tag = FF(static_cast(AvmMemoryTag::FF)), + .main_r_in_tag = FF(static_cast(AvmMemoryTag::U64)), .main_sel_mem_op_a = FF(1), - .main_sel_op_pedersen = FF(1), + .main_sel_mem_op_c = FF(1), + .main_sel_op_keccak = FF(1), .main_sel_resolve_ind_addr_a = FF(static_cast(input_read.is_indirect)), - .main_tag_err = FF(static_cast(!input_read.tag_match)), + .main_sel_resolve_ind_addr_c = FF(static_cast(output_read.is_indirect)), + .main_tag_err = FF(static_cast(!tag_match)), }); - std::vector inputs; - read_slice_from_memory(resolved_input_offset, static_cast(input_size_read), inputs); - FF output = pedersen_trace_builder.pedersen_hash(inputs, static_cast(gen_ctx_read), clk); - write_slice_to_memory(resolved_output_offset, AvmMemoryTag::FF, std::vector{ output }); + //// Array input is fixed to 1600 bits + std::vector input_vec; + // Read results are written to input array + read_slice_from_memory(resolved_input_offset, 25, input_vec); + std::array input = vec_to_arr(input_vec); + + // Now that we have read all the values, we can perform the operation to get the resulting witness. + // Note: We use the keccak_op_clk to ensure that the keccakf1600 operation is performed at the same clock cycle + // as the main trace that has the selector + std::array result = keccak_trace_builder.keccakf1600(clk, input); + // Write the result to memory after + write_slice_to_memory(resolved_output_offset, AvmMemoryTag::U64, result); } void AvmTraceBuilder::op_ec_add(uint16_t indirect, @@ -3129,43 +3176,6 @@ void AvmTraceBuilder::op_variable_msm(uint8_t indirect, write_to_memory(resolved_output_offset + 2, result.is_point_at_infinity(), AvmMemoryTag::U8); } -void AvmTraceBuilder::op_pedersen_commit(uint8_t indirect, - uint32_t input_offset, - uint32_t output_offset, - uint32_t input_size_offset, - uint32_t gen_ctx_offset) -{ - auto clk = static_cast(main_trace.size()) + 1; - auto [resolved_input_offset, resolved_output_offset, resolved_input_size_offset, resolved_gen_ctx_offset] = - Addressing<4>::fromWire(indirect, call_ptr) - .resolve({ input_offset, output_offset, input_size_offset, gen_ctx_offset }, mem_trace_builder); - - auto input_length_read = unconstrained_read_from_memory(resolved_input_size_offset); - auto gen_ctx_read = unconstrained_read_from_memory(resolved_gen_ctx_offset); - - std::vector inputs; - read_slice_from_memory(resolved_input_offset, uint32_t(input_length_read), inputs); - - grumpkin::g1::affine_element result = crypto::pedersen_commitment::commit_native(inputs, uint32_t(gen_ctx_read)); - - main_trace.push_back(Row{ - .main_clk = clk, - .main_internal_return_ptr = FF(internal_return_ptr), - .main_pc = FF(pc++), - .main_sel_op_pedersen_commit = 1, - .main_tag_err = FF(0), - }); - - // TODO(dbanks12): length needs to fit into u32 here or it will certainly - // run out of gas. Casting/truncating here is not secure. - gas_trace_builder.constrain_gas(clk, OpCode::PEDERSENCOMMITMENT, static_cast(input_length_read)); - - // Write the result back to memory [x, y, inf] with tags [FF, FF, U8] - write_to_memory(resolved_output_offset, result.x, AvmMemoryTag::FF); - write_to_memory(resolved_output_offset + 1, result.y, AvmMemoryTag::FF); - write_to_memory(resolved_output_offset + 2, result.is_point_at_infinity(), AvmMemoryTag::U8); -} - /************************************************************************************************** * CONVERSIONS **************************************************************************************************/ @@ -3254,165 +3264,6 @@ void AvmTraceBuilder::op_to_radix_le(uint8_t indirect, write_slice_to_memory(resolved_dst_offset, w_in_tag, res); } -/************************************************************************************************** - * FUTURE GADGETS -- pending changes in noir - **************************************************************************************************/ - -/** - * @brief SHA256 Compression with direct or indirect memory access. - * - * @param indirect byte encoding information about indirect/direct memory access. - * @param state_offset An index in memory pointing to the first U32 value of the state array to be used in the next - * instance of sha256 compression. - * @param input_offset An index in memory pointing to the first U32 value of the input array to be used in the next - * instance of sha256 compression. - * @param output_offset An index in memory pointing to where the first U32 value of the output array should be - * stored. - */ -void AvmTraceBuilder::op_sha256_compression(uint8_t indirect, - uint32_t output_offset, - uint32_t state_offset, - uint32_t inputs_offset) -{ - // The clk plays a crucial role in this function as we attempt to write across multiple lines in the main trace. - auto clk = static_cast(main_trace.size()) + 1; - - // Resolve the indirect flags, the results of this function are used to determine the memory offsets - // that point to the starting memory addresses for the input and output values. - auto [resolved_output_offset, resolved_state_offset, resolved_inputs_offset] = - Addressing<3>::fromWire(indirect, call_ptr) - .resolve({ output_offset, state_offset, inputs_offset }, mem_trace_builder); - - auto read_a = constrained_read_from_memory( - call_ptr, clk, resolved_state_offset, AvmMemoryTag::U32, AvmMemoryTag::U0, IntermRegister::IA); - auto read_b = constrained_read_from_memory( - call_ptr, clk, resolved_inputs_offset, AvmMemoryTag::U32, AvmMemoryTag::U0, IntermRegister::IB); - bool tag_match = read_a.tag_match && read_b.tag_match; - - // Constrain gas cost - gas_trace_builder.constrain_gas(clk, OpCode::SHA256COMPRESSION); - - // Since the above adds mem_reads in the mem_trace_builder at clk, we need to follow up resolving the reads in - // the main trace at the same clk cycle to preserve the cross-table permutation - // - // TODO<#6383>: We put the first value of each of the input, output (which is 0 at this point) and h_init arrays - // into the main trace at the intermediate registers simply for the permutation check, in the future this will - // change. - // Note: we could avoid output being zero if we loaded the input and state beforehand (with a new function that - // did not lay down constraints), but this is a simplification - main_trace.push_back(Row{ - .main_clk = clk, - .main_ia = read_a.val, // First element of state - .main_ib = read_b.val, // First element of input - .main_ind_addr_a = FF(read_a.indirect_address), - .main_ind_addr_b = FF(read_b.indirect_address), - .main_internal_return_ptr = FF(internal_return_ptr), - .main_mem_addr_a = FF(read_a.direct_address), - .main_mem_addr_b = FF(read_b.direct_address), - .main_pc = FF(pc++), - .main_r_in_tag = FF(static_cast(AvmMemoryTag::U32)), - .main_sel_mem_op_a = FF(1), - .main_sel_mem_op_b = FF(1), - .main_sel_op_sha256 = FF(1), - .main_sel_resolve_ind_addr_a = FF(static_cast(read_a.is_indirect)), - .main_sel_resolve_ind_addr_b = FF(static_cast(read_b.is_indirect)), - .main_tag_err = FF(static_cast(!tag_match)), - }); - // We store the current clk this main trace row occurred so that we can line up the sha256 gadget operation at - // the same clk later. - auto sha_op_clk = clk; - // We need to increment the clk - clk++; - // State array input is fixed to 256 bits - std::vector h_init_vec; - // Input for hash is expanded to 512 bits - std::vector input_vec; - // Read results are written to h_init array. - read_slice_from_memory(resolved_state_offset, 8, h_init_vec); - // Read results are written to input array - read_slice_from_memory(resolved_inputs_offset, 16, input_vec); - - // Now that we have read all the values, we can perform the operation to get the resulting witness. - // Note: We use the sha_op_clk to ensure that the sha256 operation is performed at the same clock cycle as the - // main trace that has the selector - std::array h_init = vec_to_arr(h_init_vec); - std::array input = vec_to_arr(input_vec); - - std::array result = sha256_trace_builder.sha256_compression(h_init, input, sha_op_clk); - // We convert the results to field elements here - std::vector ff_result; - for (uint32_t i = 0; i < 8; i++) { - ff_result.emplace_back(result[i]); - } - - // Write the result to memory after - write_slice_to_memory(resolved_output_offset, AvmMemoryTag::U32, ff_result); -} - -/** - * @brief Keccakf1600 with direct or indirect memory access. - * This function temporarily has the same interface as the kecccak opcode for compatibility, when the keccak - * migration is complete (to keccakf1600) We will update this function call as we will not likely need - * input_size_offset - * @param indirect byte encoding information about indirect/direct memory access. - * @param output_offset An index in memory pointing to where the first u64 value of the output array should be - * stored. - * @param input_offset An index in memory pointing to the first u64 value of the input array to be used in the next - * instance of poseidon2 permutation. - * @param input_size offset An index in memory pointing to the size of the input array. Temporary while we maintain - * the same interface as keccak (this is fixed to 25) - */ -void AvmTraceBuilder::op_keccakf1600(uint8_t indirect, - uint32_t output_offset, - uint32_t input_offset, - [[maybe_unused]] uint32_t input_size_offset) -{ - // What happens if the input_size_offset is > 25 when the state is more that that? - auto clk = static_cast(main_trace.size()) + 1; - auto [resolved_output_offset, resolved_input_offset] = - Addressing<2>::fromWire(indirect, call_ptr).resolve({ output_offset, input_offset }, mem_trace_builder); - auto input_read = constrained_read_from_memory( - call_ptr, clk, resolved_input_offset, AvmMemoryTag::U64, AvmMemoryTag::U0, IntermRegister::IA); - auto output_read = constrained_read_from_memory( - call_ptr, clk, resolved_output_offset, AvmMemoryTag::U64, AvmMemoryTag::U0, IntermRegister::IC); - bool tag_match = input_read.tag_match && output_read.tag_match; - - // Constrain gas cost - gas_trace_builder.constrain_gas(clk, OpCode::KECCAKF1600); - - main_trace.push_back(Row{ - .main_clk = clk, - .main_ia = input_read.val, // First element of input - .main_ic = output_read.val, // First element of output - .main_ind_addr_a = FF(input_read.indirect_address), - .main_ind_addr_c = FF(output_read.indirect_address), - .main_internal_return_ptr = FF(internal_return_ptr), - .main_mem_addr_a = FF(input_read.direct_address), - .main_mem_addr_c = FF(output_read.direct_address), - .main_pc = FF(pc++), - .main_r_in_tag = FF(static_cast(AvmMemoryTag::U64)), - .main_sel_mem_op_a = FF(1), - .main_sel_mem_op_c = FF(1), - .main_sel_op_keccak = FF(1), - .main_sel_resolve_ind_addr_a = FF(static_cast(input_read.is_indirect)), - .main_sel_resolve_ind_addr_c = FF(static_cast(output_read.is_indirect)), - .main_tag_err = FF(static_cast(!tag_match)), - }); - - // Array input is fixed to 1600 bits - std::vector input_vec; - // Read results are written to input array - read_slice_from_memory(resolved_input_offset, 25, input_vec); - std::array input = vec_to_arr(input_vec); - - // Now that we have read all the values, we can perform the operation to get the resulting witness. - // Note: We use the keccak_op_clk to ensure that the keccakf1600 operation is performed at the same clock cycle - // as the main trace that has the selector - std::array result = keccak_trace_builder.keccakf1600(clk, input); - // Write the result to memory after - write_slice_to_memory(resolved_output_offset, AvmMemoryTag::U64, result); -} - /************************************************************************************************** * FINALIZE **************************************************************************************************/ @@ -3435,7 +3286,6 @@ std::vector AvmTraceBuilder::finalize() auto sha256_trace = sha256_trace_builder.finalize(); auto poseidon2_trace = poseidon2_trace_builder.finalize(); auto keccak_trace = keccak_trace_builder.finalize(); - auto pedersen_trace = pedersen_trace_builder.finalize(); auto slice_trace = slice_trace_builder.finalize(); const auto& fixed_gas_table = FixedGasTable::get(); size_t mem_trace_size = mem_trace.size(); @@ -3445,7 +3295,6 @@ std::vector AvmTraceBuilder::finalize() size_t sha256_trace_size = sha256_trace.size(); size_t poseidon2_trace_size = poseidon2_trace.size(); size_t keccak_trace_size = keccak_trace.size(); - size_t pedersen_trace_size = pedersen_trace.size(); size_t bin_trace_size = bin_trace_builder.size(); size_t gas_trace_size = gas_trace_builder.size(); size_t slice_trace_size = slice_trace.size(); @@ -3454,11 +3303,11 @@ std::vector AvmTraceBuilder::finalize() // Range check size is 1 less than it needs to be since we insert a "first row" at the top of the trace at the // end, with clk 0 (this doubles as our range check) size_t const range_check_size = range_check_required ? UINT16_MAX : 0; - std::vector trace_sizes = { mem_trace_size, main_trace_size + 1, alu_trace_size, - range_check_size, conv_trace_size, sha256_trace_size, - poseidon2_trace_size, pedersen_trace_size, gas_trace_size + 1, - KERNEL_INPUTS_LENGTH, KERNEL_OUTPUTS_LENGTH, kernel_trace_size, - fixed_gas_table.size(), slice_trace_size, calldata.size() }; + std::vector trace_sizes = { mem_trace_size, main_trace_size + 1, alu_trace_size, + range_check_size, conv_trace_size, sha256_trace_size, + poseidon2_trace_size, gas_trace_size + 1, KERNEL_INPUTS_LENGTH, + KERNEL_OUTPUTS_LENGTH, kernel_trace_size, fixed_gas_table.size(), + slice_trace_size, calldata.size() }; auto trace_size = std::max_element(trace_sizes.begin(), trace_sizes.end()); // Before making any changes to the main trace, mark the real rows. @@ -3655,15 +3504,6 @@ std::vector AvmTraceBuilder::finalize() dest.keccakf1600_sel_keccakf1600 = FF(1); } - // Add Pedersen Gadget table - for (size_t i = 0; i < pedersen_trace_size; i++) { - auto const& src = pedersen_trace.at(i); - auto& dest = main_trace.at(i); - dest.pedersen_clk = FF(src.clk); - dest.pedersen_input = FF(src.input[0]); - dest.pedersen_sel_pedersen = FF(1); - } - /********************************************************************************************** * SLICE TRACE INCLUSION **********************************************************************************************/ @@ -3856,8 +3696,6 @@ std::vector AvmTraceBuilder::finalize() sha256_trace_size, "\n\tposeidon2_trace_size: ", poseidon2_trace_size, - "\n\tpedersen_trace_size: ", - pedersen_trace_size, "\n\tgas_trace_size: ", gas_trace_size, "\n\tfixed_gas_table_size: ", @@ -3900,7 +3738,6 @@ void AvmTraceBuilder::reset() sha256_trace_builder.reset(); poseidon2_trace_builder.reset(); keccak_trace_builder.reset(); - pedersen_trace_builder.reset(); slice_trace_builder.reset(); external_call_counter = 0; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.hpp index dc8e743c3d1..3a3b275228d 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.hpp @@ -8,7 +8,6 @@ #include "barretenberg/vm/avm/trace/gadgets/conversion_trace.hpp" #include "barretenberg/vm/avm/trace/gadgets/ecc.hpp" #include "barretenberg/vm/avm/trace/gadgets/keccak.hpp" -#include "barretenberg/vm/avm/trace/gadgets/pedersen.hpp" #include "barretenberg/vm/avm/trace/gadgets/poseidon2.hpp" #include "barretenberg/vm/avm/trace/gadgets/range_check.hpp" #include "barretenberg/vm/avm/trace/gadgets/sha256.hpp" @@ -146,11 +145,6 @@ class AvmTraceBuilder { // Gadgets void op_keccak(uint8_t indirect, uint32_t output_offset, uint32_t input_offset, uint32_t input_size_offset); void op_poseidon2_permutation(uint8_t indirect, uint32_t input_offset, uint32_t output_offset); - void op_pedersen_hash(uint8_t indirect, - uint32_t gen_ctx_offset, - uint32_t output_offset, - uint32_t input_offset, - uint32_t input_size_offset); void op_ec_add(uint16_t indirect, uint32_t lhs_x_offset, uint32_t lhs_y_offset, @@ -164,11 +158,6 @@ class AvmTraceBuilder { uint32_t scalars_offset, uint32_t output_offset, uint32_t point_length_offset); - void op_pedersen_commit(uint8_t indirect, - uint32_t output_offset, - uint32_t input_offset, - uint32_t input_size_offset, - uint32_t gen_ctx_offset); // Conversions void op_to_radix_le(uint8_t indirect, uint32_t src_offset, @@ -228,7 +217,6 @@ class AvmTraceBuilder { AvmSha256TraceBuilder sha256_trace_builder; AvmPoseidon2TraceBuilder poseidon2_trace_builder; AvmKeccakTraceBuilder keccak_trace_builder; - AvmPedersenTraceBuilder pedersen_trace_builder; AvmEccTraceBuilder ecc_trace_builder; AvmSliceTraceBuilder slice_trace_builder; AvmRangeCheckBuilder range_check_builder; diff --git a/barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp b/barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp index e86b21518a8..cfd4bb10b28 100644 --- a/barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp @@ -35,7 +35,7 @@ #define PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH 691 #define PUBLIC_CONTEXT_INPUTS_LENGTH 42 #define AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS 86 -#define AVM_PROOF_LENGTH_IN_FIELDS 3848 +#define AVM_PROOF_LENGTH_IN_FIELDS 3823 #define AVM_PUBLIC_COLUMN_MAX_SIZE 1024 #define AVM_PUBLIC_INPUTS_FLATTENED_SIZE 2739 #define MEM_TAG_U1 1 @@ -110,16 +110,12 @@ #define AVM_RETURN_BASE_L2_GAS 28 #define AVM_REVERT_BASE_L2_GAS 28 #define AVM_DEBUGLOG_BASE_L2_GAS 12 -#define AVM_KECCAK_BASE_L2_GAS 3000 #define AVM_POSEIDON2_BASE_L2_GAS 78 -#define AVM_SHA256_BASE_L2_GAS 2610 -#define AVM_PEDERSEN_BASE_L2_GAS 1000 +#define AVM_SHA256COMPRESSION_BASE_L2_GAS 261 +#define AVM_KECCAKF1600_BASE_L2_GAS 300 #define AVM_ECADD_BASE_L2_GAS 62 #define AVM_MSM_BASE_L2_GAS 1000 -#define AVM_PEDERSENCOMMITMENT_BASE_L2_GAS 1000 #define AVM_TORADIXLE_BASE_L2_GAS 46 -#define AVM_SHA256COMPRESSION_BASE_L2_GAS 261 -#define AVM_KECCAKF1600_BASE_L2_GAS 300 #define AVM_CALLDATACOPY_DYN_L2_GAS 6 #define AVM_EMITUNENCRYPTEDLOG_DYN_L2_GAS 146 #define AVM_CALL_DYN_L2_GAS 4 @@ -127,10 +123,6 @@ #define AVM_DELEGATECALL_DYN_L2_GAS 4 #define AVM_RETURN_DYN_L2_GAS 6 #define AVM_REVERT_DYN_L2_GAS 6 -#define AVM_KECCAK_DYN_L2_GAS 100 -#define AVM_SHA256_DYN_L2_GAS 100 -#define AVM_PEDERSEN_DYN_L2_GAS 100 -#define AVM_PEDERSENCOMMITMENT_DYN_L2_GAS 100 #define AVM_MSM_DYN_L2_GAS 100 #define AVM_TORADIXLE_DYN_L2_GAS 20 #define AVM_SSTORE_BASE_DA_GAS 512 diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr index 56498fd6f80..3cea16fec65 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr @@ -333,7 +333,7 @@ global AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS: u32 = 2 + 21 * 4; // `AVM_PROOF_LENGTH_IN_FIELDS` must be updated when AVM circuit changes. // To determine latest value, hover `COMPUTED_AVM_PROOF_LENGTH_IN_FIELDS` // in barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp -global AVM_PROOF_LENGTH_IN_FIELDS: u32 = 3848; +global AVM_PROOF_LENGTH_IN_FIELDS: u32 = 3823; global AVM_PUBLIC_COLUMN_MAX_SIZE : u32 = 1024; global AVM_PUBLIC_INPUTS_FLATTENED_SIZE : u32 = 2 * AVM_PUBLIC_COLUMN_MAX_SIZE + PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH; /** @@ -497,16 +497,13 @@ global AVM_DELEGATECALL_BASE_L2_GAS: u32 = 45 + (2 * L2_GAS_PER_NULLIFIER_READ_R global AVM_RETURN_BASE_L2_GAS: u32 = 28; global AVM_REVERT_BASE_L2_GAS: u32 = 28; global AVM_DEBUGLOG_BASE_L2_GAS: u32 = 12; // Must be equal to AVM_JUMP_BASE_L2_GAS as long as circuit implements debugLog as a jump -global AVM_KECCAK_BASE_L2_GAS: u32 = 3000; global AVM_POSEIDON2_BASE_L2_GAS: u32 = 78; -global AVM_SHA256_BASE_L2_GAS: u32 = 2610; -global AVM_PEDERSEN_BASE_L2_GAS: u32 = 1000; +global AVM_SHA256COMPRESSION_BASE_L2_GAS: u32 = 261; +global AVM_KECCAKF1600_BASE_L2_GAS: u32 = 300; global AVM_ECADD_BASE_L2_GAS: u32 = 62; global AVM_MSM_BASE_L2_GAS: u32 = 1000; -global AVM_PEDERSENCOMMITMENT_BASE_L2_GAS: u32 = 1000; global AVM_TORADIXLE_BASE_L2_GAS: u32 = 46; -global AVM_SHA256COMPRESSION_BASE_L2_GAS: u32 = 261; -global AVM_KECCAKF1600_BASE_L2_GAS: u32 = 300; + // Dynamic L2 GAS global AVM_CALLDATACOPY_DYN_L2_GAS: u32 = 6; // a single increment here corresponds to an entire additional field (hence x32 bytes per field) @@ -516,10 +513,6 @@ global AVM_STATICCALL_DYN_L2_GAS: u32 = 4; global AVM_DELEGATECALL_DYN_L2_GAS: u32 = 4; global AVM_RETURN_DYN_L2_GAS: u32 = 6; global AVM_REVERT_DYN_L2_GAS: u32 = 6; -global AVM_KECCAK_DYN_L2_GAS: u32 = 100; -global AVM_SHA256_DYN_L2_GAS: u32 = 100; -global AVM_PEDERSEN_DYN_L2_GAS: u32 = 100; -global AVM_PEDERSENCOMMITMENT_DYN_L2_GAS: u32 = 100; global AVM_MSM_DYN_L2_GAS: u32 = 100; global AVM_TORADIXLE_DYN_L2_GAS: u32 = 20; @@ -528,6 +521,7 @@ global AVM_SSTORE_BASE_DA_GAS: u32 = DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE; global AVM_EMITNOTEHASH_BASE_DA_GAS: u32 = DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE; global AVM_EMITNULLIFIER_BASE_DA_GAS: u32 = DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE; global AVM_SENDL2TOL1MSG_BASE_DA_GAS: u32 = DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE; + // Dynamic DA Gas // a single increment here corresponds to an entire additional field (hence x32 bytes per field) global AVM_EMITUNENCRYPTEDLOG_DYN_DA_GAS: u32 = DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE; diff --git a/yarn-project/circuits.js/src/constants.gen.ts b/yarn-project/circuits.js/src/constants.gen.ts index 393289635a6..76df7a8856c 100644 --- a/yarn-project/circuits.js/src/constants.gen.ts +++ b/yarn-project/circuits.js/src/constants.gen.ts @@ -217,7 +217,7 @@ export const TUBE_PROOF_LENGTH = 463; export const HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS = 128; export const CLIENT_IVC_VERIFICATION_KEY_LENGTH_IN_FIELDS = 145; export const AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS = 86; -export const AVM_PROOF_LENGTH_IN_FIELDS = 3848; +export const AVM_PROOF_LENGTH_IN_FIELDS = 3823; export const AVM_PUBLIC_COLUMN_MAX_SIZE = 1024; export const AVM_PUBLIC_INPUTS_FLATTENED_SIZE = 2739; export const MEM_TAG_U1 = 1; @@ -292,16 +292,12 @@ export const AVM_DELEGATECALL_BASE_L2_GAS = 2445; export const AVM_RETURN_BASE_L2_GAS = 28; export const AVM_REVERT_BASE_L2_GAS = 28; export const AVM_DEBUGLOG_BASE_L2_GAS = 12; -export const AVM_KECCAK_BASE_L2_GAS = 3000; export const AVM_POSEIDON2_BASE_L2_GAS = 78; -export const AVM_SHA256_BASE_L2_GAS = 2610; -export const AVM_PEDERSEN_BASE_L2_GAS = 1000; +export const AVM_SHA256COMPRESSION_BASE_L2_GAS = 261; +export const AVM_KECCAKF1600_BASE_L2_GAS = 300; export const AVM_ECADD_BASE_L2_GAS = 62; export const AVM_MSM_BASE_L2_GAS = 1000; -export const AVM_PEDERSENCOMMITMENT_BASE_L2_GAS = 1000; export const AVM_TORADIXLE_BASE_L2_GAS = 46; -export const AVM_SHA256COMPRESSION_BASE_L2_GAS = 261; -export const AVM_KECCAKF1600_BASE_L2_GAS = 300; export const AVM_CALLDATACOPY_DYN_L2_GAS = 6; export const AVM_EMITUNENCRYPTEDLOG_DYN_L2_GAS = 146; export const AVM_CALL_DYN_L2_GAS = 4; @@ -309,10 +305,6 @@ export const AVM_STATICCALL_DYN_L2_GAS = 4; export const AVM_DELEGATECALL_DYN_L2_GAS = 4; export const AVM_RETURN_DYN_L2_GAS = 6; export const AVM_REVERT_DYN_L2_GAS = 6; -export const AVM_KECCAK_DYN_L2_GAS = 100; -export const AVM_SHA256_DYN_L2_GAS = 100; -export const AVM_PEDERSEN_DYN_L2_GAS = 100; -export const AVM_PEDERSENCOMMITMENT_DYN_L2_GAS = 100; export const AVM_MSM_DYN_L2_GAS = 100; export const AVM_TORADIXLE_DYN_L2_GAS = 20; export const AVM_SSTORE_BASE_DA_GAS = 512; diff --git a/yarn-project/simulator/src/avm/avm_gas.ts b/yarn-project/simulator/src/avm/avm_gas.ts index ea3e955517c..6f2f8477068 100644 --- a/yarn-project/simulator/src/avm/avm_gas.ts +++ b/yarn-project/simulator/src/avm/avm_gas.ts @@ -118,14 +118,11 @@ const BASE_GAS_COSTS: Record = { [Opcode.REVERT_8]: makeCost(c.AVM_REVERT_BASE_L2_GAS, 0), [Opcode.REVERT_16]: makeCost(c.AVM_REVERT_BASE_L2_GAS, 0), [Opcode.DEBUGLOG]: makeCost(c.AVM_DEBUGLOG_BASE_L2_GAS, 0), - [Opcode.KECCAK]: makeCost(c.AVM_KECCAK_BASE_L2_GAS, 0), [Opcode.POSEIDON2]: makeCost(c.AVM_POSEIDON2_BASE_L2_GAS, 0), [Opcode.SHA256COMPRESSION]: makeCost(c.AVM_SHA256COMPRESSION_BASE_L2_GAS, 0), [Opcode.KECCAKF1600]: makeCost(c.AVM_KECCAKF1600_BASE_L2_GAS, 0), - [Opcode.PEDERSEN]: makeCost(c.AVM_PEDERSEN_BASE_L2_GAS, 0), [Opcode.ECADD]: makeCost(c.AVM_ECADD_BASE_L2_GAS, 0), [Opcode.MSM]: makeCost(c.AVM_MSM_BASE_L2_GAS, 0), - [Opcode.PEDERSENCOMMITMENT]: makeCost(c.AVM_PEDERSENCOMMITMENT_BASE_L2_GAS, 0), [Opcode.TORADIXLE]: makeCost(c.AVM_TORADIXLE_BASE_L2_GAS, 0), }; @@ -138,9 +135,7 @@ const DYNAMIC_GAS_COSTS = new Map([ [Opcode.RETURN, makeCost(c.AVM_RETURN_DYN_L2_GAS, 0)], [Opcode.REVERT_8, makeCost(c.AVM_REVERT_DYN_L2_GAS, 0)], [Opcode.REVERT_16, makeCost(c.AVM_REVERT_DYN_L2_GAS, 0)], - [Opcode.PEDERSEN, makeCost(c.AVM_PEDERSEN_DYN_L2_GAS, 0)], [Opcode.MSM, makeCost(c.AVM_MSM_DYN_L2_GAS, 0)], - [Opcode.PEDERSENCOMMITMENT, makeCost(c.AVM_PEDERSENCOMMITMENT_DYN_L2_GAS, 0)], [Opcode.TORADIXLE, makeCost(c.AVM_TORADIXLE_DYN_L2_GAS, 0)], ]); diff --git a/yarn-project/simulator/src/avm/opcodes/commitment.test.ts b/yarn-project/simulator/src/avm/opcodes/commitment.test.ts deleted file mode 100644 index 810d48a32dc..00000000000 --- a/yarn-project/simulator/src/avm/opcodes/commitment.test.ts +++ /dev/null @@ -1,120 +0,0 @@ -import { pedersenCommit } from '@aztec/foundation/crypto'; - -import { type AvmContext } from '../avm_context.js'; -import { Field, Uint32 } from '../avm_memory_types.js'; -import { initContext, randomMemoryFields } from '../fixtures/index.js'; -import { Addressing, AddressingMode } from './addressing_mode.js'; -import { PedersenCommitment } from './commitment.js'; - -describe('Commitment Opcode', () => { - let context: AvmContext; - - beforeEach(async () => { - context = initContext(); - }); - - describe('Pedersen Commitment', () => { - it('Should (de)serialize correctly', () => { - const buf = Buffer.from([ - PedersenCommitment.opcode, // opcode - 1, // indirect - ...Buffer.from('23456789', 'hex'), // inputOffset - ...Buffer.from('3456789a', 'hex'), // inputSizeOffset - ...Buffer.from('12345678', 'hex'), // outputOffset - ...Buffer.from('00000000', 'hex'), // genIndexOffset - ]); - const inst = new PedersenCommitment( - /*indirect=*/ 1, - /*inputOffset=*/ 0x23456789, - /*inputSizeOffset=*/ 0x3456789a, - /*outputOffset=*/ 0x12345678, - /*genIndexOffset=*/ 0, - ); - - expect(PedersenCommitment.deserialize(buf)).toEqual(inst); - expect(inst.serialize()).toEqual(buf); - }); - - it('Should commit correctly - direct', async () => { - const args = randomMemoryFields(10); - const inputOffset = 0; - const inputSizeOffset = 20; - const outputOffset = 50; - const indirect = 0; - const generatorIndexOffset = 10; - - context.machineState.memory.setSlice(inputOffset, args); - context.machineState.memory.set(inputSizeOffset, new Uint32(args.length)); - context.machineState.memory.set(generatorIndexOffset, new Uint32(0)); - - const expectedCommitment = pedersenCommit(args.map(f => f.toBuffer())).map(f => new Field(f)); - await new PedersenCommitment(indirect, inputOffset, outputOffset, inputSizeOffset, generatorIndexOffset).execute( - context, - ); - - const result = context.machineState.memory.getSlice(outputOffset, 2); - expect(result).toEqual(expectedCommitment); - // Check Inf - expect(0).toEqual(context.machineState.memory.get(outputOffset + 2).toNumber()); - }); - - it('Should commit correctly with a different gen - direct', async () => { - const args = randomMemoryFields(10); - const inputOffset = 0; - const inputSizeOffset = 20; - const outputOffset = 50; - const indirect = 0; - const generatorIndex = 40; - const generatorIndexOffset = 100; - - context.machineState.memory.setSlice(inputOffset, args); - context.machineState.memory.set(inputSizeOffset, new Uint32(args.length)); - context.machineState.memory.set(generatorIndexOffset, new Uint32(generatorIndex)); - - const expectedCommitment = pedersenCommit( - args.map(f => f.toBuffer()), - generatorIndex, - ).map(f => new Field(f)); - await new PedersenCommitment(indirect, inputOffset, outputOffset, inputSizeOffset, generatorIndexOffset).execute( - context, - ); - - const result = context.machineState.memory.getSlice(outputOffset, 2); - expect(result).toEqual(expectedCommitment); - // Check Inf - expect(0).toEqual(context.machineState.memory.get(outputOffset + 2).toNumber()); - }); - - it('Should commit correctly - indirect', async () => { - const args = randomMemoryFields(10); - const indirect = new Addressing([ - /*inputOffset=*/ AddressingMode.INDIRECT, - /*outputOffset*/ AddressingMode.INDIRECT, - /*inputSizeOffset=*/ AddressingMode.DIRECT, - /*generatorIndexOffset=*/ AddressingMode.DIRECT, - ]).toWire(); - const inputOffset = 0; - const inputSizeOffset = 20; - const outputOffset = 50; - const realOutputOffset = 100; - const realInputOffset = 200; - const generatorIndexOffset = 51; - - context.machineState.memory.set(outputOffset, new Uint32(realOutputOffset)); - context.machineState.memory.set(inputOffset, new Uint32(realInputOffset)); - context.machineState.memory.setSlice(realInputOffset, args); - context.machineState.memory.set(inputSizeOffset, new Uint32(args.length)); - context.machineState.memory.set(generatorIndexOffset, new Uint32(0)); - - const expectedCommitment = pedersenCommit(args.map(f => f.toBuffer())).map(f => new Field(f)); - await new PedersenCommitment(indirect, inputOffset, outputOffset, inputSizeOffset, generatorIndexOffset).execute( - context, - ); - - const result = context.machineState.memory.getSlice(realOutputOffset, 2); - expect(result).toEqual(expectedCommitment); - // Check Inf - expect(0).toEqual(context.machineState.memory.get(realOutputOffset + 2).toNumber()); - }); - }); -}); diff --git a/yarn-project/simulator/src/avm/opcodes/commitment.ts b/yarn-project/simulator/src/avm/opcodes/commitment.ts deleted file mode 100644 index a98a21abec2..00000000000 --- a/yarn-project/simulator/src/avm/opcodes/commitment.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { pedersenCommit } from '@aztec/foundation/crypto'; - -import { type AvmContext } from '../avm_context.js'; -import { Field, TypeTag, Uint8 } from '../avm_memory_types.js'; -import { Opcode, OperandType } from '../serialization/instruction_serialization.js'; -import { Addressing } from './addressing_mode.js'; -import { Instruction } from './instruction.js'; - -export class PedersenCommitment extends Instruction { - static type: string = 'PEDERSENCOMMITMENT'; - static readonly opcode: Opcode = Opcode.PEDERSENCOMMITMENT; - - // Informs (de)serialization. See Instruction.deserialize. - static readonly wireFormat: OperandType[] = [ - OperandType.UINT8 /* Opcode */, - OperandType.UINT8 /* Indirect */, - OperandType.UINT32 /* Input Offset*/, - OperandType.UINT32 /* Dst Offset */, - OperandType.UINT32 /* Input Size Offset */, - OperandType.UINT32 /* Generator Index Offset */, - ]; - - constructor( - private indirect: number, - private inputOffset: number, - private outputOffset: number, - private inputSizeOffset: number, - private genIndexOffset: number, - ) { - super(); - } - - public async execute(context: AvmContext): Promise { - const memory = context.machineState.memory.track(this.type); - - const operands = [this.inputOffset, this.outputOffset, this.inputSizeOffset, this.genIndexOffset]; - const addressing = Addressing.fromWire(this.indirect, operands.length); - const [inputOffset, outputOffset, inputSizeOffset, genIndexOffset] = addressing.resolve(operands, memory); - - const inputSize = memory.get(inputSizeOffset).toNumber(); - memory.checkTag(TypeTag.UINT32, inputSizeOffset); - - const inputs = memory.getSlice(inputOffset, inputSize); - memory.checkTagsRange(TypeTag.FIELD, inputOffset, inputSize); - - const generatorIndex = memory.get(genIndexOffset).toNumber(); - memory.checkTag(TypeTag.UINT32, genIndexOffset); - - context.machineState.consumeGas(this.gasCost(inputSize)); - - const inputBuffer: Buffer[] = inputs.map(input => input.toBuffer()); - // TODO: Add the generate index to the pedersenCommit function - const commitment = pedersenCommit(inputBuffer, generatorIndex).map(f => new Field(f)); - // The function doesnt include a flag if the output point is infinity, come back to this - // for now we just check if theyre zero - until we know how bb encodes them - const isInfinity = commitment[0].equals(new Field(0)) && commitment[1].equals(new Field(0)); - - memory.set(outputOffset, commitment[0]); // Field typed - memory.set(outputOffset + 1, commitment[1]); // Field typed - memory.set(outputOffset + 2, new Uint8(isInfinity ? 1 : 0)); // U8 typed - - memory.assert({ reads: inputSize + 2, writes: 3, addressing }); - context.machineState.incrementPc(); - } -} diff --git a/yarn-project/simulator/src/avm/opcodes/hashing.test.ts b/yarn-project/simulator/src/avm/opcodes/hashing.test.ts index ddca0874f6f..26020a6e0c7 100644 --- a/yarn-project/simulator/src/avm/opcodes/hashing.test.ts +++ b/yarn-project/simulator/src/avm/opcodes/hashing.test.ts @@ -1,10 +1,10 @@ -import { keccak256, keccakf1600, pedersenHash, sha256Compression } from '@aztec/foundation/crypto'; +import { keccakf1600, sha256Compression } from '@aztec/foundation/crypto'; import { type AvmContext } from '../avm_context.js'; -import { Field, type Uint8, Uint32, Uint64 } from '../avm_memory_types.js'; -import { initContext, randomMemoryBytes, randomMemoryFields, randomMemoryUint32s } from '../fixtures/index.js'; +import { Field, Uint32, Uint64 } from '../avm_memory_types.js'; +import { initContext, randomMemoryUint32s } from '../fixtures/index.js'; import { Addressing, AddressingMode } from './addressing_mode.js'; -import { Keccak, KeccakF1600, Pedersen, Poseidon2, Sha256Compression } from './hashing.js'; +import { KeccakF1600, Poseidon2, Sha256Compression } from './hashing.js'; describe('Hashing Opcodes', () => { let context: AvmContext; @@ -67,75 +67,6 @@ describe('Hashing Opcodes', () => { }); }); - describe('Keccak', () => { - it('Should (de)serialize correctly', () => { - const buf = Buffer.from([ - Keccak.opcode, // opcode - 1, // indirect - ...Buffer.from('12345678', 'hex'), // dstOffset - ...Buffer.from('23456789', 'hex'), // messageOffset - ...Buffer.from('3456789a', 'hex'), // messageSizeOffset - ]); - const inst = new Keccak( - /*indirect=*/ 1, - /*dstOffset=*/ 0x12345678, - /*messageOffset=*/ 0x23456789, - /*messageSizeOffset=*/ 0x3456789a, - ); - - expect(Keccak.deserialize(buf)).toEqual(inst); - expect(inst.serialize()).toEqual(buf); - }); - - it('Should hash correctly - direct', async () => { - const args = randomMemoryBytes(10); - const indirect = 0; - const messageOffset = 0; - const messageSizeOffset = 15; - const dstOffset = 20; - context.machineState.memory.set(messageSizeOffset, new Uint32(args.length)); - context.machineState.memory.setSlice(messageOffset, args); - - await new Keccak(indirect, dstOffset, messageOffset, messageSizeOffset).execute(context); - - const resultBuffer = Buffer.concat( - context.machineState.memory.getSliceAs(dstOffset, 32).map(byte => byte.toBuffer()), - ); - const inputBuffer = Buffer.concat(args.map(byte => byte.toBuffer())); - const expectedHash = keccak256(inputBuffer); - expect(resultBuffer).toEqual(expectedHash); - }); - - it('Should hash correctly - indirect', async () => { - const args = randomMemoryBytes(10); - const indirect = new Addressing([ - /*dstOffset=*/ AddressingMode.INDIRECT, - /*messageOffset*/ AddressingMode.INDIRECT, - /*messageSizeOffset*/ AddressingMode.INDIRECT, - ]).toWire(); - const messageOffset = 0; - const messageOffsetReal = 10; - const messageSizeOffset = 1; - const messageSizeOffsetReal = 100; - const dstOffset = 2; - const dstOffsetReal = 30; - context.machineState.memory.set(messageOffset, new Uint32(messageOffsetReal)); - context.machineState.memory.set(dstOffset, new Uint32(dstOffsetReal)); - context.machineState.memory.set(messageSizeOffset, new Uint32(messageSizeOffsetReal)); - context.machineState.memory.set(messageSizeOffsetReal, new Uint32(args.length)); - context.machineState.memory.setSlice(messageOffsetReal, args); - - await new Keccak(indirect, dstOffset, messageOffset, messageSizeOffset).execute(context); - - const resultBuffer = Buffer.concat( - context.machineState.memory.getSliceAs(dstOffsetReal, 32).map(byte => byte.toBuffer()), - ); - const inputBuffer = Buffer.concat(args.map(byte => byte.toBuffer())); - const expectedHash = keccak256(inputBuffer); - expect(resultBuffer).toEqual(expectedHash); - }); - }); - describe('Keccakf1600', () => { it('Should (de)serialize correctly', () => { const buf = Buffer.from([ @@ -257,77 +188,4 @@ describe('Hashing Opcodes', () => { expect(outputArray).toEqual(expectedOutput); }); }); - - describe('Pedersen', () => { - it('Should (de)serialize correctly', () => { - const buf = Buffer.from([ - Pedersen.opcode, // opcode - 1, // indirect - ...Buffer.from('02345678', 'hex'), // genIndexOffset - ...Buffer.from('12345678', 'hex'), // dstOffset - ...Buffer.from('23456789', 'hex'), // messageOffset - ...Buffer.from('3456789a', 'hex'), // hashSize - ]); - const inst = new Pedersen( - /*indirect=*/ 1, - /*genIndexOffset=*/ 0x02345678, - /*dstOffset=*/ 0x12345678, - /*messageOffset=*/ 0x23456789, - /*hashSizeOffset=*/ 0x3456789a, - ); - - expect(Pedersen.deserialize(buf)).toEqual(inst); - expect(inst.serialize()).toEqual(buf); - }); - - it('Should hash correctly - direct', async () => { - const args = randomMemoryFields(10); - const messageOffset = 0; - const sizeOffset = 20; - const genIndexOffset = 30; - const indirect = 0; - const genIndex = 20; - - context.machineState.memory.setSlice(messageOffset, args); - context.machineState.memory.set(sizeOffset, new Uint32(args.length)); - context.machineState.memory.set(genIndexOffset, new Uint32(genIndex)); - - const dstOffset = 3; - - const expectedHash = pedersenHash(args, genIndex); - await new Pedersen(indirect, genIndexOffset, dstOffset, messageOffset, sizeOffset).execute(context); - - const result = context.machineState.memory.get(dstOffset); - expect(result).toEqual(new Field(expectedHash)); - }); - - it('Should hash correctly - indirect', async () => { - const args = randomMemoryFields(10); - const indirect = new Addressing([ - /*genIndexOffset=*/ AddressingMode.DIRECT, - /*dstOffset=*/ AddressingMode.DIRECT, - /*messageOffset*/ AddressingMode.INDIRECT, - /*messageSizeOffset*/ AddressingMode.INDIRECT, - ]).toWire(); - const messageOffset = 0; - const sizeOffset = 20; - const realLocation = 4; - const realSizeLocation = 21; - const genIndexOffset = 50; - - context.machineState.memory.set(messageOffset, new Uint32(realLocation)); - context.machineState.memory.set(sizeOffset, new Uint32(realSizeLocation)); - context.machineState.memory.setSlice(realLocation, args); - context.machineState.memory.set(realSizeLocation, new Uint32(args.length)); - context.machineState.memory.set(genIndexOffset, new Uint32(0)); - - const dstOffset = 300; - - const expectedHash = pedersenHash(args); - await new Pedersen(indirect, genIndexOffset, dstOffset, messageOffset, sizeOffset).execute(context); - - const result = context.machineState.memory.get(dstOffset); - expect(result).toEqual(new Field(expectedHash)); - }); - }); }); diff --git a/yarn-project/simulator/src/avm/opcodes/hashing.ts b/yarn-project/simulator/src/avm/opcodes/hashing.ts index a055d0a135e..92e7bfb2a71 100644 --- a/yarn-project/simulator/src/avm/opcodes/hashing.ts +++ b/yarn-project/simulator/src/avm/opcodes/hashing.ts @@ -1,15 +1,9 @@ -import { - keccak256, - keccakf1600, - pedersenHash, - poseidon2Permutation, - sha256Compression, -} from '@aztec/foundation/crypto'; +import { keccakf1600, poseidon2Permutation, sha256Compression } from '@aztec/foundation/crypto'; import { strict as assert } from 'assert'; import { type AvmContext } from '../avm_context.js'; -import { Field, TypeTag, Uint8, Uint32, Uint64 } from '../avm_memory_types.js'; +import { Field, TypeTag, Uint32, Uint64 } from '../avm_memory_types.js'; import { Opcode, OperandType } from '../serialization/instruction_serialization.js'; import { Addressing } from './addressing_mode.js'; import { Instruction } from './instruction.js'; @@ -52,52 +46,6 @@ export class Poseidon2 extends Instruction { } } -export class Keccak extends Instruction { - static type: string = 'KECCAK'; - static readonly opcode: Opcode = Opcode.KECCAK; - - // Informs (de)serialization. See Instruction.deserialize. - static readonly wireFormat: OperandType[] = [ - OperandType.UINT8, - OperandType.UINT8, - OperandType.UINT32, - OperandType.UINT32, - OperandType.UINT32, - ]; - - constructor( - private indirect: number, - private dstOffset: number, - private messageOffset: number, - private messageSizeOffset: number, - ) { - super(); - } - - // pub fn keccak256(input: [u8], message_size: u32) -> [u8; 32] - public async execute(context: AvmContext): Promise { - const memory = context.machineState.memory.track(this.type); - const operands = [this.dstOffset, this.messageOffset, this.messageSizeOffset]; - const addressing = Addressing.fromWire(this.indirect, operands.length); - const [dstOffset, messageOffset, messageSizeOffset] = addressing.resolve(operands, memory); - memory.checkTag(TypeTag.UINT32, messageSizeOffset); - const messageSize = memory.get(messageSizeOffset).toNumber(); - context.machineState.consumeGas(this.gasCost(messageSize)); - - memory.checkTagsRange(TypeTag.UINT8, messageOffset, messageSize); - - const messageData = Buffer.concat(memory.getSlice(messageOffset, messageSize).map(word => word.toBuffer())); - const hashBuffer = keccak256(messageData); - - // We need to convert the hashBuffer because map doesn't work as expected on an Uint8Array (Buffer). - const res = [...hashBuffer].map(byte => new Uint8(byte)); - memory.setSlice(dstOffset, res); - - memory.assert({ reads: messageSize + 1, writes: 32, addressing }); - context.machineState.incrementPc(); - } -} - export class KeccakF1600 extends Instruction { static type: string = 'KECCAKF1600'; static readonly opcode: Opcode = Opcode.KECCAKF1600; @@ -193,53 +141,3 @@ export class Sha256Compression extends Instruction { context.machineState.incrementPc(); } } - -export class Pedersen extends Instruction { - static type: string = 'PEDERSEN'; - static readonly opcode: Opcode = Opcode.PEDERSEN; - - // Informs (de)serialization. See Instruction.deserialize. - static readonly wireFormat: OperandType[] = [ - OperandType.UINT8, - OperandType.UINT8, - OperandType.UINT32, - OperandType.UINT32, - OperandType.UINT32, - OperandType.UINT32, - ]; - - constructor( - private indirect: number, - private genIndexOffset: number, - private dstOffset: number, - private messageOffset: number, - private messageSizeOffset: number, - ) { - super(); - } - - public async execute(context: AvmContext): Promise { - const memory = context.machineState.memory.track(this.type); - const operands = [this.genIndexOffset, this.dstOffset, this.messageOffset, this.messageSizeOffset]; - const addressing = Addressing.fromWire(this.indirect, operands.length); - const [genIndexOffset, dstOffset, messageOffset, messageSizeOffset] = addressing.resolve(operands, memory); - - // We hash a set of field elements - const genIndex = Number(memory.get(genIndexOffset).toBigInt()); - memory.checkTag(TypeTag.UINT32, genIndexOffset); - const messageSize = Number(memory.get(messageSizeOffset).toBigInt()); - memory.checkTag(TypeTag.UINT32, messageSizeOffset); - const hashData = memory.getSlice(messageOffset, messageSize); - - context.machineState.consumeGas(this.gasCost(messageSize)); - - memory.checkTagsRange(TypeTag.FIELD, messageOffset, messageSize); - - // No domain sep for now - const hash = pedersenHash(hashData, genIndex); - memory.set(dstOffset, new Field(hash)); - - memory.assert({ reads: messageSize + 2, writes: 1, addressing }); - context.machineState.incrementPc(); - } -} diff --git a/yarn-project/simulator/src/avm/opcodes/index.ts b/yarn-project/simulator/src/avm/opcodes/index.ts index 9ae06bd08c0..a6169cd9678 100644 --- a/yarn-project/simulator/src/avm/opcodes/index.ts +++ b/yarn-project/simulator/src/avm/opcodes/index.ts @@ -13,4 +13,3 @@ export * from './environment_getters.js'; export * from './accrued_substate.js'; export * from './hashing.js'; export * from './ec_add.js'; -export * from './commitment.js'; diff --git a/yarn-project/simulator/src/avm/serialization/bytecode_serialization.ts b/yarn-project/simulator/src/avm/serialization/bytecode_serialization.ts index 879a25279cb..9528a0553b2 100644 --- a/yarn-project/simulator/src/avm/serialization/bytecode_serialization.ts +++ b/yarn-project/simulator/src/avm/serialization/bytecode_serialization.ts @@ -19,7 +19,6 @@ import { InternalReturn, Jump, JumpI, - Keccak, KeccakF1600, L1ToL2MessageExists, Lt, @@ -30,8 +29,6 @@ import { NoteHashExists, NullifierExists, Or, - Pedersen, - PedersenCommitment, Poseidon2, Return, Revert, @@ -141,12 +138,9 @@ const INSTRUCTION_SET = () => // Gadgets [EcAdd.opcode, Instruction.deserialize.bind(EcAdd)], - [Keccak.opcode, Instruction.deserialize.bind(Keccak)], [Poseidon2.opcode, Instruction.deserialize.bind(Poseidon2)], [Sha256Compression.opcode, Instruction.deserialize.bind(Sha256Compression)], - [Pedersen.opcode, Instruction.deserialize.bind(Pedersen)], [MultiScalarMul.opcode, Instruction.deserialize.bind(MultiScalarMul)], - [PedersenCommitment.opcode, Instruction.deserialize.bind(PedersenCommitment)], // Conversions [ToRadixLE.opcode, Instruction.deserialize.bind(ToRadixLE)], // Future Gadgets -- pending changes in noir diff --git a/yarn-project/simulator/src/avm/serialization/instruction_serialization.ts b/yarn-project/simulator/src/avm/serialization/instruction_serialization.ts index e9ea67945fd..b8a503ef438 100644 --- a/yarn-project/simulator/src/avm/serialization/instruction_serialization.ts +++ b/yarn-project/simulator/src/avm/serialization/instruction_serialization.ts @@ -76,14 +76,11 @@ export enum Opcode { // Misc DEBUGLOG, // Gadgets - KECCAK, POSEIDON2, SHA256COMPRESSION, KECCAKF1600, - PEDERSEN, // temp - may be removed, but alot of contracts rely on it ECADD, MSM, - PEDERSENCOMMITMENT, // Conversion TORADIXLE, }