Struct MemoryOpSolver

Source
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>

Source

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>

Source

pub(crate) fn new( init: &[Witness], initial_witness: &WitnessMap<F>, ) -> Result<Self, OpcodeResolutionError<F>>

Creates a new MemoryOpSolver with the values given in init.

Source

pub(crate) fn len(&self) -> u32

Source

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

Source

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.

Source

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.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more