Skip to content

Commit

Permalink
Merge b79a9b7 into 7be5bda
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyasRidhuan authored May 22, 2024
2 parents 7be5bda + b79a9b7 commit 97a9178
Show file tree
Hide file tree
Showing 19 changed files with 701 additions and 161 deletions.
10 changes: 9 additions & 1 deletion barretenberg/cpp/pil/avm/avm_main.pil
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ include "constants.pil";
include "avm_kernel.pil";
include "gadgets/avm_conversion.pil";
include "gadgets/avm_sha256.pil";
include "gadgets/avm_poseidon2.pil";

namespace avm_main(256);
// Kernel lookup selector opcodes
Expand All @@ -31,6 +32,7 @@ namespace avm_main(256);
//===== Gadget Selectors ======================================================
pol commit sel_op_radix_le;
pol commit sel_op_sha256;
pol commit sel_op_poseidon2;

//===== CONSTANT POLYNOMIALS ==================================================
pol constant clk(i) { i };
Expand Down Expand Up @@ -181,6 +183,7 @@ namespace avm_main(256);

sel_op_radix_le * (1 - sel_op_radix_le) = 0;
sel_op_sha256 * (1 - sel_op_sha256) = 0;
sel_op_poseidon2 * (1 - sel_op_poseidon2) = 0;

sel_op_add * (1 - sel_op_add) = 0;
sel_op_sub * (1 - sel_op_sub) = 0;
Expand Down Expand Up @@ -327,7 +330,7 @@ namespace avm_main(256);
//===== CONTROL_FLOW_CONSISTENCY ============================================
pol INTERNAL_CALL_STACK_SELECTORS = (first + sel_internal_call + sel_internal_return + sel_halt);
pol ALL_BINARY_SEL = sel_op_and + sel_op_or + sel_op_xor;
pol ALL_GADGET_SEL = sel_op_radix_le + sel_op_sha256;
pol ALL_GADGET_SEL = sel_op_radix_le + sel_op_sha256 + sel_op_poseidon2;
pol ALL_MEMORY_SEL = sel_cmov + sel_mov;
pol OPCODE_SELECTORS = ALU_ALL_SEL + ALL_BINARY_SEL + ALL_MEMORY_SEL + ALL_GADGET_SEL + KERNEL_SELECTORS;

Expand Down Expand Up @@ -485,6 +488,11 @@ namespace avm_main(256);
is
avm_sha256.sha256_compression_sel {avm_sha256.clk, avm_sha256.state, avm_sha256.input, avm_sha256.output};

#[PERM_MAIN_POS2_PERM]
sel_op_poseidon2 {clk, ia, ib}
is
avm_poseidon2.poseidon_perm_sel {avm_poseidon2.clk, avm_poseidon2.input, avm_poseidon2.output};

#[PERM_MAIN_MEM_A]
mem_op_a {clk, space_id, mem_idx_a, ia, rwa
, r_in_tag, w_in_tag, sel_mov_a, sel_cmov}
Expand Down
13 changes: 13 additions & 0 deletions barretenberg/cpp/pil/avm/gadgets/avm_poseidon2.pil
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
include "../avm_main.pil";

namespace avm_poseidon2(256);

pol commit clk;

// Selector for Radix Operation
pol commit poseidon_perm_sel;
poseidon_perm_sel * (1 - poseidon_perm_sel) = 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;
Loading

0 comments on commit 97a9178

Please sign in to comment.