Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::avm2::simulation::BytecodeHasher Class Reference

#include <bytecode_hashing.hpp>

Inheritance diagram for bb::avm2::simulation::BytecodeHasher:
bb::avm2::simulation::BytecodeHashingInterface

Public Member Functions

 BytecodeHasher (Poseidon2Interface &hasher, EventEmitterInterface< BytecodeHashingEvent > &events)
 
void assert_public_bytecode_commitment (const BytecodeId &bytecode_id, const std::vector< uint8_t > &bytecode) override
 Verify that the given bytecode_id matches the expected bytecode commitment which is a Poseidon2 hash of the bytecode prepended by metadata information.
 
- Public Member Functions inherited from bb::avm2::simulation::BytecodeHashingInterface
virtual ~BytecodeHashingInterface ()=default
 

Private Attributes

EventEmitterInterface< BytecodeHashingEvent > & events
 
Poseidon2Interfacehasher
 

Detailed Description

Definition at line 14 of file bytecode_hashing.hpp.

Constructor & Destructor Documentation

◆ BytecodeHasher()

bb::avm2::simulation::BytecodeHasher::BytecodeHasher ( Poseidon2Interface hasher,
EventEmitterInterface< BytecodeHashingEvent > &  events 
)
inline

Definition at line 16 of file bytecode_hashing.hpp.

Member Function Documentation

◆ assert_public_bytecode_commitment()

void bb::avm2::simulation::BytecodeHasher::assert_public_bytecode_commitment ( const BytecodeId bytecode_id,
const std::vector< uint8_t > &  bytecode 
)
overridevirtual

Verify that the given bytecode_id matches the expected bytecode commitment which is a Poseidon2 hash of the bytecode prepended by metadata information.

Encodes the bytecode as field elements, prepends a domain-separated length field, and hashes via Poseidon2. Asserts the result matches the expected bytecode_id and emits a BytecodeHashingEvent for tracegen.

Parameters
bytecode_idUnique identifier for this bytecode in the trace (commitment value).
bytecodeRaw bytecode bytes to hash.
Exceptions
Assertionfailure if the computed hash does not match bytecode_id.

Implements bb::avm2::simulation::BytecodeHashingInterface.

Definition at line 24 of file bytecode_hashing.cpp.

Member Data Documentation

◆ events

EventEmitterInterface<BytecodeHashingEvent>& bb::avm2::simulation::BytecodeHasher::events
private

Definition at line 25 of file bytecode_hashing.hpp.

◆ hasher

Poseidon2Interface& bb::avm2::simulation::BytecodeHasher::hasher
private

Definition at line 26 of file bytecode_hashing.hpp.


The documentation for this class was generated from the following files: