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

#include <to_radix.hpp>

Inheritance diagram for bb::avm2::simulation::ToRadix:
bb::avm2::simulation::ToRadixInterface

Public Member Functions

 ToRadix (ExecutionIdManagerInterface &execution_id_manager, GreaterThanInterface &gt, EventEmitterInterface< ToRadixEvent > &event_emitter, EventEmitterInterface< ToRadixMemoryEvent > &memory_event_emitter)
 
std::pair< std::vector< uint8_t >, bool > to_le_radix (const FF &value, uint32_t num_limbs, uint32_t radix) override
 Performs a little endian radix decomposition of a field element into limbs. This emits a ToRadixEvent.
 
std::pair< std::vector< bool >, bool > to_le_bits (const FF &value, uint32_t num_limbs) override
 Performs a little endian radix decomposition of a field element into bits. This emits a ToRadixEvent.
 
void to_be_radix (MemoryInterface &memory, const FF &value, uint32_t radix, uint32_t num_limbs, bool is_output_bits, MemoryAddress dst_addr) override
 Performs a big endian radix decomposition of a field element into limbs. This directly emits a ToRadixMemoryEvent and indirectly emits a ToRadixEvent if no error different that truncation is encountered. The limbs are written to the memory in big endian order at supplied destination address.
 
- Public Member Functions inherited from bb::avm2::simulation::ToRadixInterface
virtual ~ToRadixInterface ()=default
 

Private Attributes

ExecutionIdManagerInterfaceexecution_id_manager
 
GreaterThanInterfacegt
 
EventEmitterInterface< ToRadixEvent > & events
 
EventEmitterInterface< ToRadixMemoryEvent > & memory_events
 

Detailed Description

Definition at line 17 of file to_radix.hpp.

Constructor & Destructor Documentation

◆ ToRadix()

bb::avm2::simulation::ToRadix::ToRadix ( ExecutionIdManagerInterface execution_id_manager,
GreaterThanInterface gt,
EventEmitterInterface< ToRadixEvent > &  event_emitter,
EventEmitterInterface< ToRadixMemoryEvent > &  memory_event_emitter 
)
inline

Definition at line 19 of file to_radix.hpp.

Member Function Documentation

◆ to_be_radix()

void bb::avm2::simulation::ToRadix::to_be_radix ( MemoryInterface memory,
const FF value,
uint32_t  radix,
uint32_t  num_limbs,
bool  is_output_bits,
MemoryAddress  dst_addr 
)
overridevirtual

Performs a big endian radix decomposition of a field element into limbs. This directly emits a ToRadixMemoryEvent and indirectly emits a ToRadixEvent if no error different that truncation is encountered. The limbs are written to the memory in big endian order at supplied destination address.

Exceptions
ToRadixExceptionif the parameters are invalid:
  • Radix is less than 2 or greater than 256.
  • Num limbs is zero and value is not zero.
  • Radix is not 2 if is_output_bits is true.
  • The memory slice output is out-of-range.
  • Truncation error, i.e., the value cannot be fully decomposed into the given number of limbs. Note that the supplied num_limbs can be greater than the number of limbs that the value decomposes into.
Parameters
memoryThe memory to write the limbs to.
valueThe field element to decompose.
radixThe radix to decompose into. Must be in the range [2, 256].
num_limbsThe number of limbs to decompose into.
is_output_bitsA boolean indicating if the output is U1 or U8.
dst_addrThe address to write the limbs to.

Implements bb::avm2::simulation::ToRadixInterface.

Definition at line 99 of file to_radix.cpp.

◆ to_le_bits()

std::pair< std::vector< bool >, bool > bb::avm2::simulation::ToRadix::to_le_bits ( const FF value,
uint32_t  num_limbs 
)
overridevirtual

Performs a little endian radix decomposition of a field element into bits. This emits a ToRadixEvent.

Parameters
valueThe field element to decompose.
num_limbsThe number of bits to decompose into.
Returns
A pair containing the vector of bits and a boolean indicating if the decomposition was truncated. The bits are converted in a standard way, i.e., from non-zero values to true, zero to false.

Implements bb::avm2::simulation::ToRadixInterface.

Definition at line 66 of file to_radix.cpp.

◆ to_le_radix()

std::pair< std::vector< uint8_t >, bool > bb::avm2::simulation::ToRadix::to_le_radix ( const FF value,
uint32_t  num_limbs,
uint32_t  radix 
)
overridevirtual

Performs a little endian radix decomposition of a field element into limbs. This emits a ToRadixEvent.

Precondition: radix must be in the range [2, 256].

Parameters
valueThe field element to decompose.
num_limbsThe number of limbs to decompose into.
radixThe radix to decompose into. Must be in the range [2, 256].
Returns
A pair containing the vector of limbs and a boolean indicating if the decomposition was truncated.

Implements bb::avm2::simulation::ToRadixInterface.

Definition at line 21 of file to_radix.cpp.

Member Data Documentation

◆ events

EventEmitterInterface<ToRadixEvent>& bb::avm2::simulation::ToRadix::events
private

Definition at line 43 of file to_radix.hpp.

◆ execution_id_manager

ExecutionIdManagerInterface& bb::avm2::simulation::ToRadix::execution_id_manager
private

Definition at line 41 of file to_radix.hpp.

◆ gt

GreaterThanInterface& bb::avm2::simulation::ToRadix::gt
private

Definition at line 42 of file to_radix.hpp.

◆ memory_events

EventEmitterInterface<ToRadixMemoryEvent>& bb::avm2::simulation::ToRadix::memory_events
private

Definition at line 44 of file to_radix.hpp.


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