pub struct Assertion<E>where
    E: FieldElement,
{ /* private fields */ }
Expand description

An assertion made against an execution trace.

An assertion is always placed against a single column of an execution trace, but can cover multiple steps and multiple values. Specifically, there are three kinds of assertions:

  1. Single assertion - which requires that a value in a single cell of an execution trace is equal to the specified value.
  2. Periodic assertion - which requires that values in multiple cells of a single column are equal to the specified value. The cells must be evenly spaced at intervals with lengths equal to powers of two. For example, we can specify that values in a column must be equal to 0 at steps 0, 8, 16, 24, 32 etc. Steps can also start at some offset - e.g., 1, 9, 17, 25, 33 is also a valid sequence of steps.
  3. Sequence assertion - which requires that multiple cells in a single column are equal to the values from the provided list. The cells must be evenly spaced at intervals with lengths equal to powers of two. For example, we can specify that values in a column must be equal to a sequence 1, 2, 3, 4 at steps 0, 8, 16, 24. That is, value at step 0 should be equal to 1, value at step 8 should be equal to 2 etc.

Note that single and periodic assertions are succinct. That is, a verifier can evaluate them very efficiently. However, sequence assertions have liner complexity in the number of asserted values. Though, unless many thousands of values are asserted, practical impact of this linear complexity should be negligible.

Implementations

Returns an assertion against a single cell of an execution trace.

The returned assertion requires that the value in the specified column at the specified step is equal to the provided value.

Returns an single-value assertion against multiple cells of a single column.

The returned assertion requires that values in the specified column must be equal to the specified value at steps which start at first_step and repeat in equal intervals specified by stride.

Panics

Panics if:

  • stride is not a power of two, or is smaller than 2.
  • first_step is greater than stride.

Returns a multi-value assertion against multiple cells of a single column.

The returned assertion requires that values in the specified column must be equal to the provided values at steps which start at first_step and repeat in equal intervals specified by stride until all values have been consumed.

Panics

Panics if:

  • stride is not a power of two, or is smaller than 2.
  • first_step is greater than stride.
  • values is empty or number of values in not a power of two.

Returns index of the column against which this assertion is placed.

Returns the first step of the execution trace against which this assertion is placed.

For single value assertions this is equivalent to the assertion step.

Returns the interval at which the assertion repeats in the execution trace.

For single value assertions, this will be 0.

Returns asserted values.

For single value and periodic assertions this will be a slice containing one value.

Returns true if this is a single-value assertion (one value, one step).

Returns true if this is a periodic assertion (one value, many steps).

Returns true if this is a sequence assertion (many values, many steps).

Checks if this assertion overlaps with the provided assertion.

Overlap is defined as asserting a value for the same step in the same column.

Panics if the assertion cannot be placed against an execution trace of the specified width.

Checks if the assertion is valid against an execution trace of the specified length.

Errors

Returns an error if:

  • trace_length is not a power of two.
  • For single assertion, first_step >= trace_length.
  • For periodic assertion, stride > trace_length.
  • For sequence assertion, num_values * stride != trace_length;

Executes the provided closure for all possible instantiations of this assertions against a execution trace of the specified length.

Panics

Panics if the specified trace length is not valid for this assertion.

Returns the number of steps against which this assertion will be applied given an execution trace of the specified length.

  • For single-value assertions, this will always be one.
  • For periodic assertions this will be equal to trace_length / stride.
  • For sequence assertions this will be equal to the number of asserted values.
Panics

Panics if the specified trace length is not valid for this assertion.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more

We define ordering of assertions to be first by stride, then by first_step, and finally by column in ascending order.

This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.