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
3#include <vector>
4
7
8namespace bb::avm2::simulation {
9
21{
22 std::vector<FF> calldata_with_sep = { DOM_SEP__PUBLIC_CALLDATA };
23 calldata_with_sep.reserve(calldata.size() + 1);
24
25 for (const auto& value : calldata) {
26 // Note: Using `insert` breaks GCC.
27 calldata_with_sep.push_back(value);
28 }
29
30 // Right-hand term is required to emit poseidon2 hash/permutation events.
31 FF computed_hash = hasher.hash(calldata_with_sep);
32 BB_ASSERT_EQ(computed_hash, cd_hash);
33
34 events.emit({
35 .context_id = context_id,
36 .calldata = { calldata.begin(), calldata.end() },
37 .calldata_hash = cd_hash,
38 });
39}
40
41} // namespace bb::avm2::simulation
#define BB_ASSERT_EQ(actual, expected,...)
Definition assert.hpp:83
#define DOM_SEP__PUBLIC_CALLDATA
EventEmitterInterface< CalldataEvent > & events
void assert_calldata_hash(const FF &cd_hash, std::span< const FF > calldata) override
Assert that the given calldata hashes to the expected hash, and emit a calldata event.
virtual FF hash(const std::vector< FF > &input)=0
AVM range check gadget for witness generation.
AvmFlavorSettings::FF FF
Definition field.hpp:10
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13