Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
calldata_hashing.cpp
Go to the documentation of this file.
1
#include "
barretenberg/vm2/simulation/gadgets/calldata_hashing.hpp
"
2
3
#include "
barretenberg/vm2/common/aztec_constants.hpp
"
4
#include "
barretenberg/vm2/simulation/events/calldata_event.hpp
"
5
#include "
barretenberg/vm2/simulation/lib/contract_crypto.hpp
"
6
7
namespace
bb::avm2::simulation
{
8
9
FF
CalldataHasher::compute_calldata_hash
(
std::span<const FF>
calldata
)
10
{
11
// todo(ilyas): this probably simulates faster at the cost of re-work in tracegen
12
std::vector<FF> calldata_with_sep = {
GENERATOR_INDEX__PUBLIC_CALLDATA
};
13
for
(
const
auto
&
value
:
calldata
) {
14
// Note: Using `insert` breaks GCC.
15
calldata_with_sep.push_back(
value
);
16
}
17
FF
output_hash =
hasher
.
hash
(calldata_with_sep);
18
19
events
.emit({
20
.context_id =
context_id
,
21
.calldata_size =
static_cast<
uint32_t
>
(
calldata
.size()),
22
.
calldata
= {
calldata
.begin(),
calldata
.end() },
23
});
24
return
output_hash;
25
}
26
27
}
// namespace bb::avm2::simulation
aztec_constants.hpp
GENERATOR_INDEX__PUBLIC_CALLDATA
#define GENERATOR_INDEX__PUBLIC_CALLDATA
Definition
aztec_constants.hpp:258
calldata_event.hpp
bb::avm2::calldata
Definition
calldata.hpp:33
bb::avm2::simulation::CalldataHasher::events
EventEmitterInterface< CalldataEvent > & events
Definition
calldata_hashing.hpp:25
bb::avm2::simulation::CalldataHasher::context_id
uint32_t context_id
Definition
calldata_hashing.hpp:24
bb::avm2::simulation::CalldataHasher::hasher
Poseidon2Interface & hasher
Definition
calldata_hashing.hpp:26
bb::avm2::simulation::CalldataHasher::compute_calldata_hash
FF compute_calldata_hash(std::span< const FF > calldata) override
Definition
calldata_hashing.cpp:9
bb::avm2::simulation::Poseidon2Interface::hash
virtual FF hash(const std::vector< FF > &input)=0
contract_crypto.hpp
bb::avm2::simulation
Definition
address_derivation_event.hpp:6
bb::avm2::FF
AvmFlavorSettings::FF FF
Definition
field.hpp:10
std::get
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition
tuple.hpp:13
value
FF value
Definition
public_data_tree.test.cpp:97
calldata_hashing.hpp
src
barretenberg
vm2
simulation
gadgets
calldata_hashing.cpp
Generated by
1.9.8