Skip to content

Commit

Permalink
Merge 2fcf252 into 03fa925
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyasRidhuan authored May 29, 2024
2 parents 03fa925 + 2fcf252 commit 90ef856
Show file tree
Hide file tree
Showing 20 changed files with 1,036 additions and 260 deletions.
14 changes: 12 additions & 2 deletions barretenberg/cpp/pil/avm/avm_main.pil
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ include "avm_binary.pil";
include "constants.pil";
include "avm_kernel.pil";
include "gadgets/avm_conversion.pil";
include "gadgets/avm_sha256.pil";

namespace avm_main(256);
//===== CONSTANT POLYNOMIALS ==================================================
Expand Down Expand Up @@ -48,6 +49,7 @@ namespace avm_main(256);

//===== Gadget Selectors ======================================================
pol commit sel_op_radix_le;
pol commit sel_op_sha256;

//===== Fix Range Checks Selectors=============================================
// We re-use the clk column for the lookup values of 8-bit resp. 16-bit range check.
Expand Down Expand Up @@ -202,6 +204,7 @@ namespace avm_main(256);
sel_op_sstore * (1 - sel_op_sstore) = 0;

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

sel_op_add * (1 - sel_op_add) = 0;
sel_op_sub * (1 - sel_op_sub) = 0;
Expand Down Expand Up @@ -354,8 +357,10 @@ namespace avm_main(256);

//===== CONTROL_FLOW_CONSISTENCY ============================================
pol INTERNAL_CALL_STACK_SELECTORS = (first + sel_internal_call + sel_internal_return + sel_halt);
pol OPCODE_SELECTORS = (sel_op_add + sel_op_sub + sel_op_div + sel_op_fdiv + sel_op_mul + sel_op_not
+ sel_op_eq + sel_op_and + sel_op_or + sel_op_xor + sel_op_cast + KERNEL_INPUT_SELECTORS + KERNEL_OUTPUT_SELECTORS);
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_MEMORY_SEL = sel_cmov + sel_mov;
pol OPCODE_SELECTORS = ALU_ALL_SEL + ALL_BINARY_SEL + ALL_MEMORY_SEL + ALL_GADGET_SEL + KERNEL_INPUT_SELECTORS + KERNEL_OUTPUT_SELECTORS;

// Program counter must increment if not jumping or returning
#[PC_INCREMENT]
Expand Down Expand Up @@ -549,6 +554,11 @@ namespace avm_main(256);
is
avm_conversion.to_radix_le_sel {avm_conversion.clk, avm_conversion.input, avm_conversion.radix, avm_conversion.num_limbs};

#[PERM_MAIN_SHA256]
sel_op_sha256 {clk, ia, ib, ic}
is
avm_sha256.sha256_compression_sel {avm_sha256.clk, avm_sha256.state, avm_sha256.input, avm_sha256.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
14 changes: 14 additions & 0 deletions barretenberg/cpp/pil/avm/gadgets/avm_sha256.pil
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
include "../avm_main.pil";

namespace avm_sha256(256);

pol commit clk;

// Selector for Radix Operation
pol commit sha256_compression_sel;
sha256_compression_sel * (1 - sha256_compression_sel) = 0;

// These will all be arrays, but we just store the first element for permutation to the main trace for now
pol commit state;
pol commit input;
pol commit output;
Loading

0 comments on commit 90ef856

Please sign in to comment.