|
Barretenberg
The ZK-SNARK library at the core of Aztec
|
#include <memory.hpp>
Public Member Functions | |
| Memory (uint16_t space_id, RangeCheckInterface &range_check, ExecutionIdGetterInterface &execution_id_manager, EventEmitterInterface< MemoryEvent > &event_emitter) | |
| const MemoryValue & | get (MemoryAddress index) const override |
| Reads a tagged value from memory at the given address. | |
| void | set (MemoryAddress index, MemoryValue value) override |
| Writes a tagged value to memory at the given address. | |
| uint16_t | get_space_id () const override |
| const MemoryValue & | unconstrained_get (MemoryAddress index) const |
| Reads a value from memory without emitting an event. | |
Public Member Functions inherited from bb::avm2::simulation::MemoryInterface | |
| virtual | ~MemoryInterface ()=default |
| virtual bool | is_valid_address (const MemoryValue &address) |
Private Member Functions | |
| void | validate_tag (const MemoryValue &value) const |
| Validates that a value fits within its tag's bit-width via a range check. | |
Definition at line 15 of file memory.hpp.
|
inline |
Definition at line 17 of file memory.hpp.
|
overridevirtual |
Reads a tagged value from memory at the given address.
Returns the stored value, or FF(0) with tag FF for uninitialized addresses. Emits a READ memory event for trace generation. No tag validation is needed because stored values were already validated on write.
Implements bb::avm2::simulation::MemoryInterface.
Definition at line 44 of file memory.cpp.
|
inlineoverridevirtual |
Implements bb::avm2::simulation::MemoryInterface.
Definition at line 30 of file memory.hpp.
|
overridevirtual |
Writes a tagged value to memory at the given address.
Validates that the value fits within its tag's bit-width (via a range check for non-FF tags), stores the value, and emits a WRITE memory event for trace generation.
Implements bb::avm2::simulation::MemoryInterface.
Definition at line 24 of file memory.cpp.
| const MemoryValue & bb::avm2::simulation::Memory::unconstrained_get | ( | MemoryAddress | index | ) | const |
Reads a value from memory without emitting an event.
Used only for debug logging and other unconstrained contexts. Does not produce a trace event, so this access is invisible to the prover.
Definition at line 64 of file memory.cpp.
|
private |
Validates that a value fits within its tag's bit-width via a range check.
Only called on writes because reads return previously-validated values. FF-tagged values are unconstrained and skip validation. For all other tags, the value is range-checked against the tag's bit-width. This is "circuit-leaking": in simulation the tag-value pair is always consistent, but the circuit needs an explicit range check to enforce it.
Definition at line 79 of file memory.cpp.
|
private |
Definition at line 42 of file memory.hpp.
|
private |
Definition at line 40 of file memory.hpp.
|
private |
Definition at line 37 of file memory.hpp.
|
private |
Definition at line 39 of file memory.hpp.
|
private |
Definition at line 36 of file memory.hpp.