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
impl ValueVec
Sourcepub fn new(layout: &ValueVecLayout) -> ValueVec
pub fn new(layout: &ValueVecLayout) -> ValueVec
Creates a zero-filled value vector holding the sections of the given circuit layout, including its scratch tail.
Sourcepub fn new_from_data(
n_const: usize,
public: &[Word],
private: &[Word],
) -> ValueVec
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.
Sourcepub fn word(&self, offset: u32) -> Word
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.
Sourcepub fn word_mut(&mut self, offset: u32) -> &mut Word
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.
Sourcepub fn public(&self) -> &[Word]
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.
Sourcepub fn non_public(&self) -> &[Word]
pub fn non_public(&self) -> &[Word]
Returns the private values, unpadded and without scratch space.
Sourcepub fn combined_witness(&self) -> &[Word]
pub fn combined_witness(&self) -> &[Word]
Returns the combined values vector.
Sourcepub fn eval_operand(&self, operand: &[ShiftedValueIndex]) -> Word
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 Index<ValueIndex> for ValueVec
impl Index<ValueIndex> for ValueVec
Auto Trait Implementations§
impl Freeze for ValueVec
impl RefUnwindSafe for ValueVec
impl Send for ValueVec
impl Sync for ValueVec
impl Unpin for ValueVec
impl UnsafeUnpin for ValueVec
impl UnwindSafe for ValueVec
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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