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/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
if
(
calldata
.empty()) {
12
// Based on the noir short circuit, if the calldata is empty we return 0
13
// There is no need to emit an event.
14
return
0;
15
}
16
// todo(ilyas): this probably simulates faster at the cost of re-work in tracegen
17
std::vector<FF> calldata_with_sep = {
GENERATOR_INDEX__PUBLIC_CALLDATA
};
18
for
(
const
auto
&
value
:
calldata
) {
19
// Note: Using `insert` breaks GCC.
20
calldata_with_sep.push_back(
value
);
21
}
22
FF
output_hash =
hasher
.
hash
(calldata_with_sep);
23
24
events
.emit({
25
.context_id =
context_id
,
26
.calldata_length =
static_cast<
uint32_t
>
(
calldata
.size()),
27
.
calldata
= {
calldata
.begin(),
calldata
.end() },
28
.output_hash = output_hash,
29
});
30
return
output_hash;
31
}
32
33
}
// namespace bb::avm2::simulation
aztec_constants.hpp
GENERATOR_INDEX__PUBLIC_CALLDATA
#define GENERATOR_INDEX__PUBLIC_CALLDATA
Definition
aztec_constants.hpp:272
calldata_event.hpp
bb::avm2::calldata
Definition
calldata.hpp:33
bb::avm2::simulation::CalldataHasher::events
EventEmitterInterface< CalldataEvent > & events
Definition
calldata_hashing.hpp:30
bb::avm2::simulation::CalldataHasher::context_id
uint32_t context_id
Definition
calldata_hashing.hpp:29
bb::avm2::simulation::CalldataHasher::hasher
Poseidon2Interface & hasher
Definition
calldata_hashing.hpp:31
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.cpp:8
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:96
calldata_hashing.hpp
src
barretenberg
vm2
simulation
calldata_hashing.cpp
Generated by
1.9.8