Skip to main content

ValueTable

Struct ValueTable 

Source
pub struct ValueTable<Data = Vec<Word>> { /* private fields */ }
Expand description

The witness for a batch of 2^k independent instances of one circuit, in wire-major order.

Each wire’s values across all instances are grouped together, one wire per row (wire-major):

                instance 0   instance 1   ...   instance K-1
  wire 0       [   w        |   w        | ... |   w        ]   <- one row
  wire 1       [   w        |   w        | ... |   w        ]
       ...

Each row is one wire and each column is one instance. So a batched interpreter can advance every instance of a wire in a single pass.

This is the batched counterpart of ValueVec: one instance read back out with Self::instance_value_vec is bit-for-bit the value vector populating that instance on its own would produce.

This table is specialized for the M4 accelerator setting, where the value vector splits with the inout values on the hidden side (InoutSegment::Hidden):

  1. Inout wires are committed. Every instance chooses its own inout words, so they are not one set of shared values a verifier can evaluate. They are committed with the private values instead, at the front of the hidden segment.
  2. Constants are not stored. The constants live once on the constraint system as a Vec<Word>, not replicated per instance. Only the hidden segment — the inout, witness and internal words — is stored here. Reading an instance back takes the constants as an argument.

So the stored data holds exactly the hidden segment of every instance: n_hidden_words rows by 2^log_instances columns.

The committed inout words are not tied to any value the verifier knows, so the statement a proof over this table makes is that some inout values complete every instance.

Populating one is the circuit frontend’s business, since it takes a circuit to evaluate — see Circuit::populate_batch.

Data is the buffer backing the words. It defaults to Vec<Word>, but the prover populates a table straight into a buffer drawn from its pool, so any Deref<Target = [Word]> will do.

Implementations§

Source§

impl<Data: Deref<Target = [Word]>> ValueTable<Data>

Source

pub fn from_hidden_words( layout: ValueVecLayout, log_instances: usize, data: Data, ) -> Self

Builds a table from the hidden words of every instance, in wire-major order.

data is what Self::as_words returns: the rows of the hidden segment laid out contiguously, each holding one wire’s value in every instance. The row count follows from the layout, so it is not passed separately.

This is the seam the frontend populates through; nothing in this crate can evaluate a circuit to produce the words.

§Panics

Panics if data is not n_hidden_words << log_instances words long.

Source

pub const fn log_instances(&self) -> usize

The base-2 logarithm of the number of instances.

Source

pub const fn n_instances(&self) -> usize

The number of instances in the batch.

Source

pub const fn layout(&self) -> &ValueVecLayout

The per-instance value layout shared by every instance.

Source

pub const fn n_hidden_words(&self) -> usize

The number of hidden-word rows per instance, including the protocol’s zero padding.

Source

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

The whole batch as one flat, wire-major word buffer.

Row r (hidden wire r) occupies data[r << log_instances .. (r + 1) << log_instances], holding that wire’s value in every instance.

Source

pub fn instance_value_vec( &self, instance: usize, constants: &[Word], ) -> ValueVec

Reconstructs one instance as a standalone single-instance value vector.

Because the constants are not stored in the table, the caller supplies them (they live on the constraint system). The result is bit-for-bit what populating this instance on its own would produce, so it can be fed directly to single-instance constraint checking.

§Panics

Panics if the index is not below the instance count, or if constants does not match the layout’s constant count.

Trait Implementations§

Source§

impl<Data: Clone> Clone for ValueTable<Data>

Source§

fn clone(&self) -> ValueTable<Data>

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<Data: Debug> Debug for ValueTable<Data>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Data> Freeze for ValueTable<Data>
where Data: Freeze,

§

impl<Data> RefUnwindSafe for ValueTable<Data>
where Data: RefUnwindSafe,

§

impl<Data> Send for ValueTable<Data>
where Data: Send,

§

impl<Data> Sync for ValueTable<Data>
where Data: Sync,

§

impl<Data> Unpin for ValueTable<Data>
where Data: Unpin,

§

impl<Data> UnsafeUnpin for ValueTable<Data>
where Data: UnsafeUnpin,

§

impl<Data> UnwindSafe for ValueTable<Data>
where Data: 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> 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