pub(crate) struct MemoryOpSolver<F> {
pub(super) block_value: Vec<F>,
}Expand description
Maintains the state for solving [MemoryInit][acir::circuit::Opcode::MemoryInit] and [MemoryOp][acir::circuit::Opcode::MemoryOp] opcodes.
Fields§
§block_value: Vec<F>Known values of the memory block, based on the index This vec starts as big as it needs to, when initialized, then evolves as we process the opcodes.
Implementations§
Source§impl<F: AcirField> MemoryOpSolver<F>
impl<F: AcirField> MemoryOpSolver<F>
pub(crate) fn check_memory_op( &mut self, op: &MemOp<F>, witness_map: &WitnessMap<F>, opcode_index: usize, ) -> Result<(), OpcodeResolutionError<F>>
Source§impl<F: AcirField> MemoryOpSolver<F>
impl<F: AcirField> MemoryOpSolver<F>
Sourcepub(crate) fn new(
init: &[Witness],
initial_witness: &WitnessMap<F>,
) -> Result<Self, OpcodeResolutionError<F>>
pub(crate) fn new( init: &[Witness], initial_witness: &WitnessMap<F>, ) -> Result<Self, OpcodeResolutionError<F>>
Creates a new MemoryOpSolver with the values given in init.
pub(crate) fn len(&self) -> u32
Sourcepub(crate) fn index_from_field(
&self,
index: F,
) -> Result<u32, OpcodeResolutionError<F>>
pub(crate) fn index_from_field( &self, index: F, ) -> Result<u32, OpcodeResolutionError<F>>
Convert a field element into a memory index Only 32 bits values are valid memory indices
Sourcepub(crate) fn write_memory_index(
&mut self,
index: u32,
value: F,
) -> Result<(), OpcodeResolutionError<F>>
pub(crate) fn write_memory_index( &mut self, index: u32, value: F, ) -> Result<(), OpcodeResolutionError<F>>
Update the ‘block_value’ map with the provided index/value Returns an ‘IndexOutOfBounds’ error if the index is outside the block range.
Sourcepub(crate) fn read_memory_index(
&self,
index: u32,
) -> Result<F, OpcodeResolutionError<F>>
pub(crate) fn read_memory_index( &self, index: u32, ) -> Result<F, OpcodeResolutionError<F>>
Returns the value stored in the ‘block_value’ map for the provided index Returns an ‘IndexOutOfBounds’ error if the index is not in the map.
Sourcepub(crate) fn solve_memory_op(
&mut self,
op: &MemOp<F>,
initial_witness: &mut WitnessMap<F>,
) -> Result<(), OpcodeResolutionError<F>>
pub(crate) fn solve_memory_op( &mut self, op: &MemOp<F>, initial_witness: &mut WitnessMap<F>, ) -> Result<(), OpcodeResolutionError<F>>
Update the ‘block_values’ by processing the provided Memory opcode The opcode ‘op’ contains the index and value of the operation and the type of the operation. They are all stored as an [acir::native_types::Expression] The type of ‘operation’ is ‘0’ for a read and ‘1’ for a write. It must be a constant expression. Index is not required to be constant but it must reduce to a known value for processing the opcode. This is done by doing the (partial) evaluation of its expression, using the provided witness map.
READ: read the block at index op.index and update op.value with the read value
- ‘op.value’ must reduce to a witness (after the evaluation of its expression)
- the value is updated in the provided witness map, for the ‘op.value’ witness
WRITE: update the block at index ‘op.index’ with ‘op.value’
- ‘op.value’ must reduce to a known value
If a requirement is not met, it returns an error.
Auto Trait Implementations§
impl<F> Freeze for MemoryOpSolver<F>
impl<F> RefUnwindSafe for MemoryOpSolver<F>where
F: RefUnwindSafe,
impl<F> Send for MemoryOpSolver<F>where
F: Send,
impl<F> Sync for MemoryOpSolver<F>where
F: Sync,
impl<F> Unpin for MemoryOpSolver<F>where
F: Unpin,
impl<F> UnwindSafe for MemoryOpSolver<F>where
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more