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

#include <class_id_derivation.hpp>

Inheritance diagram for bb::avm2::simulation::ClassIdDerivation:
bb::avm2::simulation::ClassIdDerivationInterface

Public Member Functions

 ClassIdDerivation (Poseidon2Interface &poseidon2, EventEmitterInterface< ClassIdDerivationEvent > &events)
 
void assert_derivation (const ContractClassWithCommitment &klass) override
 Computes the contract class ID and emits a ClassIdDerivationEvent. Corresponds to the subtrace class_id_derivation.pil.
 
- Public Member Functions inherited from bb::avm2::simulation::ClassIdDerivationInterface
virtual ~ClassIdDerivationInterface ()=default
 

Private Attributes

EventEmitterInterface< ClassIdDerivationEvent > & events
 
Poseidon2Interfaceposeidon2
 
unordered_flat_set< ContractClassIdcached_derivations
 

Detailed Description

Definition at line 12 of file class_id_derivation.hpp.

Constructor & Destructor Documentation

◆ ClassIdDerivation()

bb::avm2::simulation::ClassIdDerivation::ClassIdDerivation ( Poseidon2Interface poseidon2,
EventEmitterInterface< ClassIdDerivationEvent > &  events 
)
inline

Definition at line 14 of file class_id_derivation.hpp.

Member Function Documentation

◆ assert_derivation()

void bb::avm2::simulation::ClassIdDerivation::assert_derivation ( const ContractClassWithCommitment klass)
overridevirtual

Computes the contract class ID and emits a ClassIdDerivationEvent. Corresponds to the subtrace class_id_derivation.pil.

If the class ID has already been derived, an event has already been emitted and we skip repeating the computation and emission. Otherwise, we call the poseidon trace to perform the hash defining the class ID, given as: Poseidon2(DOM_SEP__CONTRACT_CLASS_ID, artifact_hash, private_functions_root, public_bytecode_commitment) and we add the output to the local cache.

Exceptions
Unexpectedexception if
  • the calculated class ID does not match that stored in the klass itself.
Parameters
klassThe contract class.

Implements bb::avm2::simulation::ClassIdDerivationInterface.

Definition at line 25 of file class_id_derivation.cpp.

Member Data Documentation

◆ cached_derivations

unordered_flat_set<ContractClassId> bb::avm2::simulation::ClassIdDerivation::cached_derivations
private

Definition at line 26 of file class_id_derivation.hpp.

◆ events

EventEmitterInterface<ClassIdDerivationEvent>& bb::avm2::simulation::ClassIdDerivation::events
private

Definition at line 22 of file class_id_derivation.hpp.

◆ poseidon2

Poseidon2Interface& bb::avm2::simulation::ClassIdDerivation::poseidon2
private

Definition at line 23 of file class_id_derivation.hpp.


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