|
Barretenberg
The ZK-SNARK library at the core of Aztec
|
ROM/RAM logic handler for UltraCircuitBuilder. More...
#include <rom_ram_logic.hpp>
Public Types | |
| using | FF = typename ExecutionTrace::FF |
| using | CircuitBuilder = UltraCircuitBuilder_< ExecutionTrace > |
Public Member Functions | |
| RomRamLogic_ ()=default | |
| size_t | create_ROM_array (const size_t array_size) |
| Create a new read-only memory region. | |
| void | set_ROM_element (CircuitBuilder *builder, const size_t rom_id, const size_t index_value, const uint32_t value_witness) |
Initialize a rom cell to equal value_witness | |
| void | set_ROM_element_pair (CircuitBuilder *builder, const size_t rom_id, const size_t index_value, const std::array< uint32_t, 2 > &value_witnesses) |
| Initialize a ROM array element with a pair of witness values. | |
| uint32_t | read_ROM_array (CircuitBuilder *builder, const size_t rom_id, const uint32_t index_witness) |
| Read a single element from ROM. | |
| std::array< uint32_t, 2 > | read_ROM_array_pair (CircuitBuilder *builder, const size_t rom_id, const uint32_t index_witness) |
| Read a pair of elements from ROM. | |
| void | create_ROM_gate (CircuitBuilder *builder, RomRecord &record) |
| Gate that'reads' from a ROM table, i.e., the table index is a witness not precomputed. | |
| void | create_sorted_ROM_gate (CircuitBuilder *builder, RomRecord &record) |
| Gate that performs consistency checks to validate that a claimed ROM read value is correct. | |
| void | process_ROM_array (CircuitBuilder *builder, const size_t rom_id) |
| Compute additional gates required to validate ROM reads. Called when generating the proving key. | |
| void | process_ROM_arrays (CircuitBuilder *builder) |
| Process all of the ROM arrays. | |
| size_t | create_RAM_array (const size_t array_size) |
| Create a new updatable memory region. | |
| void | init_RAM_element (CircuitBuilder *builder, const size_t ram_id, const size_t index_value, const uint32_t value_witness) |
Initialize a RAM cell to equal value_witness | |
| uint32_t | read_RAM_array (CircuitBuilder *builder, const size_t ram_id, const uint32_t index_witness) |
| void | write_RAM_array (CircuitBuilder *builder, const size_t ram_id, const uint32_t index_witness, const uint32_t value_witness) |
| void | create_RAM_gate (CircuitBuilder *builder, RamRecord &record) |
| Gate that performs a read/write operation into a RAM table, i.e. table index is a witness not precomputed. | |
| void | create_sorted_RAM_gate (CircuitBuilder *builder, RamRecord &record) |
| Gate that performs consistency checks to validate that a claimed RAM read/write value is correct. | |
| void | create_final_sorted_RAM_gate (CircuitBuilder *builder, RamRecord &record, const size_t ram_array_size) |
| Performs consistency checks to validate that a claimed RAM read/write value is correct. Used for the final gate in a list of sorted RAM records. | |
| void | process_RAM_array (CircuitBuilder *builder, const size_t ram_id) |
| Compute additional gates required to validate RAM read/writes. Called when generating the proving key. | |
| void | process_RAM_arrays (CircuitBuilder *builder) |
| bool | operator== (const RomRamLogic_ &other) const noexcept |
Public Attributes | |
| std::vector< RamTranscript > | ram_arrays |
Each entry in ram_arrays represents an independent RAM table. RamTranscript tracks the current table state, as well as the 'records' produced by each read and write operation. Used in compute_prover_instance to generate consistency check gates required to validate the RAM read/write history. | |
| std::vector< RomTranscript > | rom_arrays |
Each entry in ram_arrays represents an independent ROM table. RomTranscript tracks the current table state, as well as the 'records' produced by each read operation. Used in compute_prover_instance to generate consistency check gates required to validate the ROM read history. | |
ROM/RAM logic handler for UltraCircuitBuilder.
Definition at line 107 of file rom_ram_logic.hpp.
| using bb::RomRamLogic_< ExecutionTrace >::CircuitBuilder = UltraCircuitBuilder_<ExecutionTrace> |
Definition at line 110 of file rom_ram_logic.hpp.
| using bb::RomRamLogic_< ExecutionTrace >::FF = typename ExecutionTrace::FF |
Definition at line 109 of file rom_ram_logic.hpp.
|
default |
| void bb::RomRamLogic_< ExecutionTrace >::create_final_sorted_RAM_gate | ( | CircuitBuilder * | builder, |
| RamRecord & | record, | ||
| const size_t | ram_array_size | ||
| ) |
Performs consistency checks to validate that a claimed RAM read/write value is correct. Used for the final gate in a list of sorted RAM records.
| builder | |
| record | Stores details of this read operation. Mutated by this fn! |
Definition at line 389 of file rom_ram_logic.cpp.
| size_t bb::RomRamLogic_< ExecutionTrace >::create_RAM_array | ( | const size_t | array_size | ) |
Create a new updatable memory region.
Creates a transcript object, where the inside memory state array is filled with "uninitialized memory" and empty memory record array. Puts this object into the vector of ROM arrays.
| array_size | The size of region in elements |
Definition at line 259 of file rom_ram_logic.cpp.
| void bb::RomRamLogic_< ExecutionTrace >::create_RAM_gate | ( | CircuitBuilder * | builder, |
| RamRecord & | record | ||
| ) |
Gate that performs a read/write operation into a RAM table, i.e. table index is a witness not precomputed.
| builder | |
| record | Stores details of this read operation. Mutated by this fn! |
Definition at line 357 of file rom_ram_logic.cpp.
| size_t bb::RomRamLogic_< ExecutionTrace >::create_ROM_array | ( | const size_t | array_size | ) |
Create a new read-only memory region.
Creates a transcript object, where the inside memory state array is filled with "uninitialized memory" and empty memory record array. Puts this object into the vector of ROM arrays.
| array_size | The size of region in elements |
Definition at line 8 of file rom_ram_logic.cpp.
| void bb::RomRamLogic_< ExecutionTrace >::create_ROM_gate | ( | CircuitBuilder * | builder, |
| RomRecord & | record | ||
| ) |
Gate that'reads' from a ROM table, i.e., the table index is a witness not precomputed.
| builder | |
| record | Stores details of this read operation. Mutated by this fn! |
Definition at line 136 of file rom_ram_logic.cpp.
| void bb::RomRamLogic_< ExecutionTrace >::create_sorted_RAM_gate | ( | CircuitBuilder * | builder, |
| RamRecord & | record | ||
| ) |
Gate that performs consistency checks to validate that a claimed RAM read/write value is correct.
sorted RAM gates are generated sequentially, each RAM record is sorted first by index then by timestamp
| builder | |
| record | Stores details of this read operation. Mutated by this fn! |
Definition at line 376 of file rom_ram_logic.cpp.
| void bb::RomRamLogic_< ExecutionTrace >::create_sorted_ROM_gate | ( | CircuitBuilder * | builder, |
| RomRecord & | record | ||
| ) |
Gate that performs consistency checks to validate that a claimed ROM read value is correct.
sorted ROM gates are generated sequentially, each ROM record is sorted by index
| builder | |
| record | Stores details of this read operation. Mutated by this fn! |
Definition at line 150 of file rom_ram_logic.cpp.
| void bb::RomRamLogic_< ExecutionTrace >::init_RAM_element | ( | CircuitBuilder * | builder, |
| const size_t | ram_id, | ||
| const size_t | index_value, | ||
| const uint32_t | value_witness | ||
| ) |
Initialize a RAM cell to equal value_witness
| builder | |
| ram_id | The index of the RAM array, which cell we are initializing |
| index_value | The index of the cell within the array (an actual index, not a witness index) |
| value_witness | The index of the witness with the value that should be in the |
Definition at line 270 of file rom_ram_logic.cpp.
|
inlinenoexcept |
Definition at line 278 of file rom_ram_logic.hpp.
| void bb::RomRamLogic_< ExecutionTrace >::process_RAM_array | ( | CircuitBuilder * | builder, |
| const size_t | ram_id | ||
| ) |
Compute additional gates required to validate RAM read/writes. Called when generating the proving key.
| ram_id | The id of the RAM table |
| gate_offset_from_public_inputs | Required to track the gate position of where we're adding extra gates |
Definition at line 426 of file rom_ram_logic.cpp.
| void bb::RomRamLogic_< ExecutionTrace >::process_RAM_arrays | ( | CircuitBuilder * | builder | ) |
Definition at line 557 of file rom_ram_logic.cpp.
| void bb::RomRamLogic_< ExecutionTrace >::process_ROM_array | ( | CircuitBuilder * | builder, |
| const size_t | rom_id | ||
| ) |
Compute additional gates required to validate ROM reads. Called when generating the proving key.
| builder | |
| rom_id | The id of the ROM table |
| gate_offset_from_public_inputs | Required to track the gate position of where we're adding extra gates |
Definition at line 165 of file rom_ram_logic.cpp.
| void bb::RomRamLogic_< ExecutionTrace >::process_ROM_arrays | ( | CircuitBuilder * | builder | ) |
Process all of the ROM arrays.
Definition at line 252 of file rom_ram_logic.cpp.
| uint32_t bb::RomRamLogic_< ExecutionTrace >::read_RAM_array | ( | CircuitBuilder * | builder, |
| const size_t | ram_id, | ||
| const uint32_t | index_witness | ||
| ) |
Definition at line 296 of file rom_ram_logic.cpp.
| uint32_t bb::RomRamLogic_< ExecutionTrace >::read_ROM_array | ( | CircuitBuilder * | builder, |
| const size_t | rom_id, | ||
| const uint32_t | index_witness | ||
| ) |
Read a single element from ROM.
| builder | |
| rom_id | The index of the array to read from |
| index_witness | The witness with the index inside the array |
Definition at line 77 of file rom_ram_logic.cpp.
| std::array< uint32_t, 2 > bb::RomRamLogic_< ExecutionTrace >::read_ROM_array_pair | ( | CircuitBuilder * | builder, |
| const size_t | rom_id, | ||
| const uint32_t | index_witness | ||
| ) |
Read a pair of elements from ROM.
| rom_id | The id of the ROM array |
| index_witness | The witness containing the index in the array |
Definition at line 104 of file rom_ram_logic.cpp.
| void bb::RomRamLogic_< ExecutionTrace >::set_ROM_element | ( | CircuitBuilder * | builder, |
| const size_t | rom_id, | ||
| const size_t | index_value, | ||
| const uint32_t | value_witness | ||
| ) |
Initialize a rom cell to equal value_witness
| builder | |
| rom_id | The index of the ROM array, which cell we are initializing |
| index_value | The index of the cell within the array (an actual index, not a witness index) |
| value_witness | The index of the witness with the value that should be in the |
Initialize a ROM cell to equal value_witness index_value is a RAW VALUE that describes the cell index. It is NOT a witness When intializing ROM arrays, it is important that the index of the cell is known when compiling the circuit. This ensures that, for a given circuit, we know with 100% certainty that EVERY rom cell is initialized
Definition at line 25 of file rom_ram_logic.cpp.
| void bb::RomRamLogic_< ExecutionTrace >::set_ROM_element_pair | ( | CircuitBuilder * | builder, |
| const size_t | rom_id, | ||
| const size_t | index_value, | ||
| const std::array< uint32_t, 2 > & | value_witnesses | ||
| ) |
Initialize a ROM array element with a pair of witness values.
| builder | |
| rom_id | ROM array id |
| index_value | Index in the array |
| value_witnesses | The witnesses to put in the slot |
Definition at line 52 of file rom_ram_logic.cpp.
| void bb::RomRamLogic_< ExecutionTrace >::write_RAM_array | ( | CircuitBuilder * | builder, |
| const size_t | ram_id, | ||
| const uint32_t | index_witness, | ||
| const uint32_t | value_witness | ||
| ) |
Definition at line 327 of file rom_ram_logic.cpp.
| std::vector<RamTranscript> bb::RomRamLogic_< ExecutionTrace >::ram_arrays |
Each entry in ram_arrays represents an independent RAM table. RamTranscript tracks the current table state, as well as the 'records' produced by each read and write operation. Used in compute_prover_instance to generate consistency check gates required to validate the RAM read/write history.
Definition at line 120 of file rom_ram_logic.hpp.
| std::vector<RomTranscript> bb::RomRamLogic_< ExecutionTrace >::rom_arrays |
Each entry in ram_arrays represents an independent ROM table. RomTranscript tracks the current table state, as well as the 'records' produced by each read operation. Used in compute_prover_instance to generate consistency check gates required to validate the ROM read history.
Definition at line 127 of file rom_ram_logic.hpp.