Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
gt_trace.cpp
Go to the documentation of this file.
2
3#include <memory>
4
8
9namespace bb::avm2::tracegen {
10
13{
14 using C = Column;
15
16 uint32_t row = 0;
17 for (const auto& event : events) {
18 FF a_ff = FF(event.a);
19 FF b_ff = FF(event.b);
20 FF abs_diff = event.result ? a_ff - b_ff - 1 : b_ff - a_ff;
21 const uint8_t num_bits_bound = static_cast<uint8_t>(static_cast<uint256_t>(abs_diff).get_msb() + 1);
22 const uint8_t num_bits_bound_16 =
23 static_cast<uint8_t>(((num_bits_bound - 1) / 16 + 1) * 16); // round up to multiple of 16
24 trace.set(row,
25 { {
26 { C::gt_sel, 1 },
27 { C::gt_input_a, event.a },
28 { C::gt_input_b, event.b },
29 { C::gt_res, event.result ? 1 : 0 },
30 { C::gt_abs_diff, abs_diff },
31 { C::gt_num_bits, num_bits_bound_16 },
32 } });
33 row++;
34 };
35}
36
39
40} // namespace bb::avm2::tracegen
void process(const simulation::EventEmitterInterface< simulation::GreaterThanEvent >::Container &events, TraceContainer &trace)
Definition gt_trace.cpp:11
static const InteractionDefinition interactions
Definition gt_trace.hpp:18
InteractionDefinition & add(auto &&... args)
TestTraceContainer trace
lookup_settings< lookup_gt_gt_range_settings_ > lookup_gt_gt_range_settings
AvmFlavorSettings::FF FF
Definition field.hpp:10
constexpr T get_msb(const T in)
Definition get_msb.hpp:47
simulation::PublicDataTreeReadWriteEvent event