Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
calldata_hashing.cpp
Go to the documentation of this file.
2
6
7namespace bb::avm2::simulation {
8
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
#define GENERATOR_INDEX__PUBLIC_CALLDATA
EventEmitterInterface< CalldataEvent > & events
FF compute_calldata_hash(std::span< const FF > calldata) override
virtual FF hash(const std::vector< FF > &input)=0
AvmFlavorSettings::FF FF
Definition field.hpp:10
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13