Skip to content

Commit

Permalink
feat(avm): sha256_compression
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyasRidhuan committed May 16, 2024
1 parent 74e98d4 commit 5d23f5d
Show file tree
Hide file tree
Showing 19 changed files with 916 additions and 148 deletions.
8 changes: 8 additions & 0 deletions barretenberg/cpp/pil/avm/avm_main.pil
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include "avm_alu.pil";
include "avm_binary.pil";
include "avm_kernel.pil";
include "gadgets/avm_conversion.pil";
include "gadgets/avm_sha256.pil";

namespace avm_main(256);
// Kernel lookup selector opcodes
Expand All @@ -28,6 +29,7 @@ namespace avm_main(256);

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

//===== CONSTANT POLYNOMIALS ==================================================
pol constant clk(i) { i };
Expand Down Expand Up @@ -172,6 +174,7 @@ namespace avm_main(256);
sel_op_transaction_fee * (1 - sel_op_transaction_fee) = 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 @@ -462,6 +465,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.output, avm_sha256.state, avm_sha256.input};

#[PERM_MAIN_MEM_A]
mem_op_a {clk, 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 5d23f5d

Please sign in to comment.