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
5
6namespace bb::avm2::simulation {
7
9 const std::vector<uint8_t>& bytecode)
10{
11 [[maybe_unused]] auto bytecode_length_in_bytes = static_cast<uint32_t>(bytecode.size());
12
13 std::vector<FF> inputs = { GENERATOR_INDEX__PUBLIC_BYTECODE };
14 auto bytecode_as_fields = encode_bytecode(bytecode);
15 inputs.insert(inputs.end(), bytecode_as_fields.begin(), bytecode_as_fields.end());
16
17 FF hash = hasher.hash(inputs);
18
19 // TODO(dbanks12): re-enable once C++ and PIL use standard poseidon2 hashing for bytecode commitments.
20 // events.emit({ .bytecode_id = bytecode_id,
21 // .bytecode_length = bytecode_length_in_bytes,
22 // .bytecode_fields = std::move(bytecode_as_fields) });
23 return hash;
24}
25
26} // namespace bb::avm2::simulation
#define GENERATOR_INDEX__PUBLIC_BYTECODE
FF compute_public_bytecode_commitment(const BytecodeId bytecode_id, const std::vector< uint8_t > &bytecode) override
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