Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::avm2::tracegen::FieldGreaterThanTraceBuilder Class Referencefinal

#include <field_gt_trace.hpp>

Public Member Functions

void process (const simulation::EventEmitterInterface< simulation::FieldGreaterThanEvent >::Container &events, TraceContainer &trace)
 Processes FieldGreaterThanEvent events and generates trace rows for the ff_gt gadget.
 

Static Public Attributes

static const InteractionDefinition interactions
 

Detailed Description

Definition at line 11 of file field_gt_trace.hpp.

Member Function Documentation

◆ process()

void bb::avm2::tracegen::FieldGreaterThanTraceBuilder::process ( const simulation::EventEmitterInterface< simulation::FieldGreaterThanEvent >::Container &  events,
TraceContainer trace 
)

Processes FieldGreaterThanEvent events and generates trace rows for the ff_gt gadget.

This function handles two flavors of FieldGreaterThanEvent:

  1. GT Operation (operation == GREATER_THAN):
    • Generates 5 rows total (1 initial + 4 shift rows)
    • First row: Sets sel_gt=1, populates all fields (a, b, result, decompositions, witnesses)
    • Rows 2-5: Shift rows with sel_shift_rng=1, performing pairwise range checks via shifting
    • All event fields are populated (a_limbs, b_limbs, p_sub_a_witness, p_sub_b_witness, res_witness)
    • cmp_rng_ctr initialized to 4 and decrements to 0
  2. Canonical Decomposition (operation == CANONICAL_DECOMPOSITION):
    • Generates 2 rows total (1 initial + 1 shift row)
    • First row: Sets sel_dec=1, populates a-related fields (a, a_limbs, p_sub_a_witness)
    • Row 2: Shift row with sel_shift_rng=1, performs remaining range checks
    • Only a-related fields are meaningful; b-related and result fields have default values
    • cmp_rng_ctr initialized to 1 and decrements to 0

The shifting mechanism ensures all 128-bit limbs are range-checked:

  • Each row performs 2 x 128-bit range checks on a_lo and a_hi columns
  • Values shift left across columns: p_sub_a → a, b → p_sub_a, p_sub_b → b, res → p_sub_b
  • After all shifts, all 10 limbs (GT) or 4 limbs (decomp) have been range-checked
Parameters
eventsContainer of FieldGreaterThanEvent to process.
traceThe trace container to populate with generated rows.
Note
Row indices start at 1 (row 0 is always empty when there are shifts).
The sel column is set to 1 for all rows in a gadget block (initial + shift rows).
Selectors sel_gt and sel_dec are only set on the first row of each gadget invocation.

Definition at line 44 of file field_gt_trace.cpp.

Member Data Documentation

◆ interactions

const InteractionDefinition bb::avm2::tracegen::FieldGreaterThanTraceBuilder::interactions
static
Initial value:
=
InteractionDefinition()
.add<lookup_ff_gt_a_hi_range_settings, InteractionType::LookupGeneric>()
lookup_settings< lookup_ff_gt_a_lo_range_settings_ > lookup_ff_gt_a_lo_range_settings

Definition at line 16 of file field_gt_trace.hpp.


The documentation for this class was generated from the following files: