Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bytecode_hashing.cpp
Go to the documentation of this file.
1
#include "
barretenberg/vm2/simulation/bytecode_hashing.hpp
"
2
3
#include "
barretenberg/vm2/common/aztec_constants.hpp
"
4
#include "
barretenberg/vm2/simulation/lib/contract_crypto.hpp
"
5
6
namespace
bb::avm2::simulation
{
7
8
FF
BytecodeHasher::compute_public_bytecode_commitment
([[maybe_unused]]
const
BytecodeId
bytecode_id,
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
aztec_constants.hpp
GENERATOR_INDEX__PUBLIC_BYTECODE
#define GENERATOR_INDEX__PUBLIC_BYTECODE
Definition
aztec_constants.hpp:274
bytecode_hashing.hpp
bb::avm2::simulation::BytecodeHasher::hasher
Poseidon2Interface & hasher
Definition
bytecode_hashing.hpp:29
bb::avm2::simulation::BytecodeHasher::compute_public_bytecode_commitment
FF compute_public_bytecode_commitment(const BytecodeId bytecode_id, const std::vector< uint8_t > &bytecode) override
Definition
bytecode_hashing.cpp:8
bb::avm2::simulation::Poseidon2Interface::hash
virtual FF hash(const std::vector< FF > &input)=0
contract_crypto.hpp
hash
void hash(State &state) noexcept
Definition
merkle_tree.bench.cpp:28
bb::avm2::simulation
Definition
address_derivation.cpp:8
bb::avm2::simulation::BytecodeId
FF BytecodeId
Definition
bytecode_events.hpp:16
bb::avm2::simulation::encode_bytecode
std::vector< FF > encode_bytecode(std::span< const uint8_t > bytecode)
Definition
contract_crypto.cpp:11
bb::avm2::FF
AvmFlavorSettings::FF FF
Definition
field.hpp:10
src
barretenberg
vm2
simulation
bytecode_hashing.cpp
Generated by
1.9.8