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(klass.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({ DOM_SEP__CONTRACT_CLASS_ID,
21 klass.artifact_hash,
24 // This will throw an unexpected exception if it fails.
25 BB_ASSERT_EQ(computed_class_id, klass.id, "Computed class ID mismatch");
26
27 // Cache this derivation so we don't repeat it
28 cached_derivations.insert(klass.id);
29
30 events.emit({ .klass = klass });
31}
32
33} // namespace bb::avm2::simulation
#define BB_ASSERT_EQ(actual, expected,...)
Definition assert.hpp:93
#define DOM_SEP__CONTRACT_CLASS_ID
EventEmitterInterface< ClassIdDerivationEvent > & events
void assert_derivation(const ContractClassWithCommitment &klass) override
unordered_flat_set< ContractClassId > cached_derivations
static FF hash(const std::vector< FF > &input)
Hashes a vector of field elements.
AvmFlavorSettings::FF FF
Definition field.hpp:10