Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
gt_trace.cpp
Go to the documentation of this file.
1
#include "
barretenberg/vm2/tracegen/gt_trace.hpp
"
2
3
#include <memory>
4
5
#include "
barretenberg/vm2/common/field.hpp
"
6
#include "
barretenberg/vm2/generated/relations/lookups_gt.hpp
"
7
#include "
barretenberg/vm2/tracegen/lib/interaction_def.hpp
"
8
9
namespace
bb::avm2::tracegen
{
10
11
void
GreaterThanTraceBuilder::process
(
12
const
simulation::EventEmitterInterface<simulation::GreaterThanEvent>::Container
& events,
TraceContainer
&
trace
)
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 = ((num_bits_bound - 1) / 16 + 1) * 16;
// round up to multiple of 16
23
trace
.set(row,
24
{ {
25
{ C::gt_sel, 1 },
26
{ C::gt_input_a,
event
.a },
27
{ C::gt_input_b,
event
.b },
28
{ C::gt_res,
event
.result ? 1 : 0 },
29
{ C::gt_abs_diff, abs_diff },
30
{ C::gt_num_bits, num_bits_bound_16 },
31
} });
32
row++;
33
};
34
}
35
36
const
InteractionDefinition
GreaterThanTraceBuilder::interactions
=
37
InteractionDefinition
().
add
<
lookup_gt_gt_range_settings
,
InteractionType::LookupGeneric
>();
38
39
}
// namespace bb::avm2::tracegen
bb::avm2::simulation::EventEmitterInterface::Container
std::vector< Event > Container
Definition
event_emitter.hpp:12
bb::avm2::tracegen::GreaterThanTraceBuilder::process
void process(const simulation::EventEmitterInterface< simulation::GreaterThanEvent >::Container &events, TraceContainer &trace)
Definition
gt_trace.cpp:11
bb::avm2::tracegen::GreaterThanTraceBuilder::interactions
static const InteractionDefinition interactions
Definition
gt_trace.hpp:18
bb::avm2::tracegen::InteractionDefinition
Definition
interaction_def.hpp:29
bb::avm2::tracegen::InteractionDefinition::add
InteractionDefinition & add(auto &&... args)
Definition
interaction_def.hpp:34
bb::avm2::tracegen::TraceContainer
Definition
trace_container.hpp:22
bb::numeric::uint256_t
Definition
uint256.hpp:32
trace
TestTraceContainer trace
Definition
data_copy.test.cpp:59
gt_trace.hpp
interaction_def.hpp
lookups_gt.hpp
bb::avm2::tracegen
Definition
full_row.hpp:10
bb::avm2::tracegen::InteractionType::LookupGeneric
@ LookupGeneric
bb::avm2::lookup_gt_gt_range_settings
lookup_settings< lookup_gt_gt_range_settings_ > lookup_gt_gt_range_settings
Definition
lookups_gt.hpp:31
bb::avm2::Column
Column
Definition
columns.hpp:32
bb::avm2::FF
AvmFlavorSettings::FF FF
Definition
field.hpp:10
bb::numeric::get_msb
constexpr T get_msb(const T in)
Definition
get_msb.hpp:47
event
simulation::PublicDataTreeReadWriteEvent event
Definition
public_data_tree_trace.cpp:20
field.hpp
src
barretenberg
vm2
tracegen
gt_trace.cpp
Generated by
1.9.8