Skip to main content

ValueVec

Struct ValueVec 

Source
pub struct ValueVec { /* private fields */ }
Expand description

The vector of values used in constraint evaluation and proof generation.

ValueVec is the concrete instantiation of values that satisfy (or should satisfy) a ConstraintSystem. It is the primary data structure for both constraint evaluation and polynomial commitment.

The words are the public values followed by the private ones, stored back to back with no padding. A vector built with Self::new carries the circuit’s scratch tail past them; one built with Self::new_from_data ends with the private values.

The words live in a buffer that starts on a 16-byte boundary. That keeps the frequent bulk copies of the vector on the aligned SIMD memcpy path.

§Addressing

A ValueIndex names a word by its segment and its position within that segment, and the vector stores the two counts that place each segment in the buffer.

These are storage positions, and they are deliberately not the positions the proving protocol reads a word at: the protocol pads the public segment to a power of two and the hidden segment to at least that width, so it addresses the same word further along. Its addresses come from ConstraintSystem::word_offset instead. Nothing needs both, because the prover pads each segment as it packs it into field elements.

Implementations§

Source§

impl ValueVec

Source

pub fn new(layout: &ValueVecLayout) -> ValueVec

Creates a zero-filled value vector holding the sections of the given circuit layout, including its scratch tail.

Source

pub fn new_from_data( n_const: usize, public: &[Word], private: &[Word], ) -> ValueVec

Creates a value vector from the words of its public and private values.

The vector has no scratch tail; scratch words only exist while a circuit is evaluated.

n_const splits the public words into the constants and the inout values, which is what resolves an InOut index. Rebuilding a vector from serialized segments therefore needs the system describing them, so prefer ConstraintSystem::value_vec_from_data, which passes it for you.

Source

pub fn word(&self, offset: u32) -> Word

Returns one word by its flat position, counting the scratch tail.

This is the view for the few readers that address whole segments rather than named values: the evaluation form, whose bytecode holds one register per position, and the batch witness, which copies a segment across including its padding. Everything else names words by ValueIndex, which cannot reach a padding word.

Source

pub fn word_mut(&mut self, offset: u32) -> &mut Word

Returns a mutable reference to one word by its flat position, counting the scratch tail.

This is the mutable counterpart of Self::word, which documents when to reach for it.

Source

pub const fn size(&self) -> usize

The number of values the vector holds, excluding scratch.

Source

pub fn public(&self) -> &[Word]

Returns the public values: the constants followed by the inout values.

These are the words as the circuit declares them, unpadded. The prover pads them up to the public segment width as it packs them.

Source

pub fn inout(&self) -> &[Word]

Returns the inout values: the public values past the constants.

Source

pub fn non_public(&self) -> &[Word]

Returns the private values, unpadded and without scratch space.

Source

pub fn combined_witness(&self) -> &[Word]

Returns the combined values vector.

Source

pub fn eval_operand(&self, operand: &[ShiftedValueIndex]) -> Word

Evaluates an operand against this witness.

An operand is the XOR of its shifted-value terms. An empty operand evaluates to the zero word, the XOR identity.

Trait Implementations§

Source§

impl Clone for ValueVec

Source§

fn clone(&self) -> ValueVec

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ValueVec

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Index<ValueIndex> for ValueVec

Source§

type Output = Word

The returned type after indexing.
Source§

fn index(&self, index: ValueIndex) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl IndexMut<ValueIndex> for ValueVec

Source§

fn index_mut(&mut self, index: ValueIndex) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<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