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 than truncation is encountered. The limbs are written to the memory in big endian order at the 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 18 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 20 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 than truncation is encountered. The limbs are written to the memory in big endian order at the supplied destination address.

Exceptions
ToRadixExceptionon input validation errors (checked first, all grouped):
  • The destination memory slice is out-of-range (dst_addr + num_limbs > AVM_MEMORY_SIZE).
  • Radix is less than 2.
  • Radix is greater than 256.
  • Radix is not 2 while is_output_bits is true.
  • Num limbs is zero while value is not zero.
ToRadixExceptionon truncation error (checked after input validation and decomposition):
  • 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 102 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 67 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.

Note
Asserts that radix is in 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 22 of file to_radix.cpp.

Member Data Documentation

◆ events

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

Definition at line 44 of file to_radix.hpp.

◆ execution_id_manager

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

Definition at line 42 of file to_radix.hpp.

◆ gt

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

Definition at line 43 of file to_radix.hpp.

◆ memory_events

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

Definition at line 45 of file to_radix.hpp.


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