Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
class_id_derivation.cpp
Go to the documentation of this file.
2
3#include <cassert>
4
8
9namespace bb::avm2::simulation {
10
12{
13 // Check if we've already derived this class_id
14 if (cached_derivations.contains(class_id)) {
15 // Already processed this class_id - cache hit, don't emit event
16 return;
17 }
18
19 // First time seeing this class_id - do the actual derivation
20 FF computed_class_id = poseidon2.hash({ GENERATOR_INDEX__CONTRACT_LEAF,
21 klass.artifact_hash,
24 (void)computed_class_id; // Silence unused variable warning when assert is stripped out
25 assert(computed_class_id == class_id);
26
27 // Cache this derivation so we don't repeat it
28 cached_derivations.insert(class_id);
29
30 events.emit({ .class_id = class_id, .klass = klass });
31}
32
33} // namespace bb::avm2::simulation
#define GENERATOR_INDEX__CONTRACT_LEAF
EventEmitterInterface< ClassIdDerivationEvent > & events
void assert_derivation(const ContractClassId &class_id, const ContractClass &klass) override
std::unordered_set< ContractClassId > cached_derivations
static FF hash(const std::vector< FF > &input)
Hashes a vector of field elements.
FF ContractClassId
AvmFlavorSettings::FF FF
Definition field.hpp:10