Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bytecode_hashing.cpp
Go to the documentation of this file.
2
6
7namespace bb::avm2::simulation {
8
10 const std::vector<uint8_t>& bytecode,
11 const FF& public_bytecode_commitment)
12{
13 BB_BENCH_NAME("BytecodeHasher::assert_public_bytecode_commitment");
14 // TODO(MW): Remove bytecode length from event?
15 [[maybe_unused]] auto bytecode_length_in_bytes = static_cast<uint32_t>(bytecode.size());
16
17 std::vector<FF> inputs = { GENERATOR_INDEX__PUBLIC_BYTECODE };
18 auto bytecode_as_fields = encode_bytecode(bytecode);
19 inputs.insert(inputs.end(), bytecode_as_fields.begin(), bytecode_as_fields.end());
20
21 FF hash = hasher.hash(inputs);
22 assert(hash == public_bytecode_commitment);
23 // To please the compiler.
24 (void)hash;
25 (void)public_bytecode_commitment;
26
27 events.emit({ .bytecode_id = bytecode_id,
28 .bytecode_length = bytecode_length_in_bytes,
29 .bytecode_fields = std::move(bytecode_as_fields) });
30}
31
32} // namespace bb::avm2::simulation
#define GENERATOR_INDEX__PUBLIC_BYTECODE
#define BB_BENCH_NAME(name)
Definition bb_bench.hpp:218
void assert_public_bytecode_commitment(const BytecodeId &bytecode_id, const std::vector< uint8_t > &bytecode, const FF &public_bytecode_commitment) override
EventEmitterInterface< BytecodeHashingEvent > & events
virtual FF hash(const std::vector< FF > &input)=0
void hash(State &state) noexcept
std::vector< FF > encode_bytecode(std::span< const uint8_t > bytecode)
AvmFlavorSettings::FF FF
Definition field.hpp:10
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13