Struct winter_verifier::Assertion [−][src]
pub struct Assertion<B> where
B: StarkField, { /* fields omitted */ }Expand description
An assertion made against an execution trace.
An assertion is always placed against a single register of an execution trace, but can cover multiple steps and multiple values. Specifically, there are three kinds of assertions:
- Single assertion - which requires that a value in a single cell of an execution trace is equal to the specified value.
- Periodic assertion - which requires that values in multiple cells of a single register 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 register 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.
- Sequence assertion - which requires that multiple cells in a single register 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 register 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 register at the specified
step is equal to the provided value.
Returns an single-value assertion against multiple cells of a single register.
The returned assertion requires that values in the specified register 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:
strideis not a power of two, or is smaller than 2.first_stepis greater thanstride.
Returns a multi-value assertion against multiple cells of a single register.
The returned assertion requires that values in the specified register 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:
strideis not a power of two, or is smaller than 2.first_stepis greater thanstride.valuesis empty or number of values in not a power of two.
Returns index of the register 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 register.
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_lengthis 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
We define ordering of assertions to be first by stride, then by first_step, and finally by register in ascending order.
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
Auto Trait Implementations
impl<B> RefUnwindSafe for Assertion<B> where
B: RefUnwindSafe,
impl<B> UnwindSafe for Assertion<B> where
B: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
type Output = T
type Output = T
Should always be Self