Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::avm2::simulation::GreaterThan Class Reference

#include <gt.hpp>

Inheritance diagram for bb::avm2::simulation::GreaterThan:
bb::avm2::simulation::GreaterThanInterface

Public Member Functions

 GreaterThan (FieldGreaterThanInterface &field_gt, RangeCheckInterface &range_check, EventEmitterInterface< GreaterThanEvent > &event_emitter)
 
bool gt (const FF &a, const FF &b) override
 Computes whether a > b for field elements, delegating to the ff_gt gadget.
 
bool gt (const uint128_t &a, const uint128_t &b) override
 Computes whether a > b for uint128 values.
 
bool gt (const MemoryValue &a, const MemoryValue &b) override
 Computes whether a > b for memory values, dispatching by tag.
 
- Public Member Functions inherited from bb::avm2::simulation::GreaterThanInterface
virtual ~GreaterThanInterface ()=default
 

Private Attributes

FieldGreaterThanInterfacefield_gt
 
RangeCheckInterfacerange_check
 
EventEmitterInterface< GreaterThanEvent > & events
 

Detailed Description

Definition at line 14 of file gt.hpp.

Constructor & Destructor Documentation

◆ GreaterThan()

bb::avm2::simulation::GreaterThan::GreaterThan ( FieldGreaterThanInterface field_gt,
RangeCheckInterface range_check,
EventEmitterInterface< GreaterThanEvent > &  event_emitter 
)
inline

Definition at line 16 of file gt.hpp.

Member Function Documentation

◆ gt() [1/3]

bool bb::avm2::simulation::GreaterThan::gt ( const FF a,
const FF b 
)
overridevirtual

Computes whether a > b for field elements, delegating to the ff_gt gadget.

Parameters
aThe first field element.
bThe second field element.
Returns
true if a > b (as canonical field integers), false otherwise.

Implements bb::avm2::simulation::GreaterThanInterface.

Definition at line 15 of file gt.cpp.

◆ gt() [2/3]

bool bb::avm2::simulation::GreaterThan::gt ( const MemoryValue a,
const MemoryValue b 
)
overridevirtual

Computes whether a > b for memory values, dispatching by tag.

Field-tagged values are compared via the ff_gt gadget. All other types (u8, u16, u32, u64, u128) are compared as uint128 integers.

Parameters
aThe first memory value.
bThe second memory value.
Returns
true if a > b, false otherwise.
Note
Asserts that neither input has FF tag when taking the integer comparison path.

Implements bb::avm2::simulation::GreaterThanInterface.

Definition at line 58 of file gt.cpp.

◆ gt() [3/3]

bool bb::avm2::simulation::GreaterThan::gt ( const uint128_t a,
const uint128_t b 
)
overridevirtual

Computes whether a > b for uint128 values.

Computes the absolute difference: (a - b - 1) if a > b, or (b - a) if a <= b. Range-checks this difference to prove the subtraction did not underflow, which in turn proves the comparison result is correct. See gt.pil for the full argument.

Parameters
aThe first uint128 value.
bThe second uint128 value.
Returns
true if a > b, false otherwise.

Implements bb::avm2::simulation::GreaterThanInterface.

Definition at line 31 of file gt.cpp.

Member Data Documentation

◆ events

EventEmitterInterface<GreaterThanEvent>& bb::avm2::simulation::GreaterThan::events
private

Definition at line 31 of file gt.hpp.

◆ field_gt

FieldGreaterThanInterface& bb::avm2::simulation::GreaterThan::field_gt
private

Definition at line 29 of file gt.hpp.

◆ range_check

RangeCheckInterface& bb::avm2::simulation::GreaterThan::range_check
private

Definition at line 30 of file gt.hpp.


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