Skip to content

Commit

Permalink
feat: bytecode hashing init (#8535)
Browse files Browse the repository at this point in the history
This adds proper computation of the public bytecode commitment (i.e.
pair-wise poseidon hashing of the public bytecode). This hash is also
computed in the witgen although the circuit remains unconstrained.

Follow up PRs will handle:
1) Deriving class id, including tracing and hinting the artifact hash,
etc
2) Deriving the address, including tracing and hinting the contract
instance
3) Merkle path hinting and verification in the AVM
  • Loading branch information
IlyasRidhuan authored Oct 25, 2024
1 parent 831cc66 commit 2bb09e5
Show file tree
Hide file tree
Showing 33 changed files with 1,068 additions and 832 deletions.
13 changes: 13 additions & 0 deletions barretenberg/cpp/pil/avm/bytecode.pil
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace bytecode(256);

pol commit packed;
pol commit length_remaining;
pol commit running_hash;

pol commit end_latch;

// TODO: Come back to this;
// pol commit class_id;
// pol commit contract_address;


1 change: 1 addition & 0 deletions barretenberg/cpp/pil/avm/constants_gen.pil
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace constants(256);
pol MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL = 16;
pol MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL = 16;
pol MAX_UNENCRYPTED_LOGS_PER_CALL = 4;
pol MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS = 3000;
pol MEM_TAG_FF = 0;
pol MEM_TAG_U1 = 1;
pol MEM_TAG_U8 = 2;
Expand Down
1 change: 1 addition & 0 deletions barretenberg/cpp/pil/avm/main.pil
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ include "constants_gen.pil";
include "constants_misc.pil";
include "gas.pil";
include "kernel.pil";
include "bytecode.pil";
include "fixed/powers.pil";
include "gadgets/conversion.pil";
include "gadgets/sha256.pil";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,4 @@ template class ExecutionTrace_<MegaFlavor>;
template class ExecutionTrace_<plonk::flavor::Standard>;
template class ExecutionTrace_<plonk::flavor::Ultra>;

} // namespace bb
} // namespace bb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ AvmCircuitBuilder::ProverPolynomials AvmCircuitBuilder::compute_polynomials() co
polys.binary_op_id.set_if_valid_index(i, rows[i].binary_op_id);
polys.binary_sel_bin.set_if_valid_index(i, rows[i].binary_sel_bin);
polys.binary_start.set_if_valid_index(i, rows[i].binary_start);
polys.bytecode_end_latch.set_if_valid_index(i, rows[i].bytecode_end_latch);
polys.bytecode_length_remaining.set_if_valid_index(i, rows[i].bytecode_length_remaining);
polys.bytecode_packed.set_if_valid_index(i, rows[i].bytecode_packed);
polys.bytecode_running_hash.set_if_valid_index(i, rows[i].bytecode_running_hash);
polys.cmp_a_hi.set_if_valid_index(i, rows[i].cmp_a_hi);
polys.cmp_a_lo.set_if_valid_index(i, rows[i].cmp_a_lo);
polys.cmp_b_hi.set_if_valid_index(i, rows[i].cmp_b_hi);
Expand Down
Loading

0 comments on commit 2bb09e5

Please sign in to comment.