AirContext

Struct AirContext 

Source
pub struct AirContext<B>
where B: StarkField,
{ /* private fields */ }
Expand description

STARK parameters and trace properties for a specific execution of a computation.

Implementations§

Source§

impl<B> AirContext<B>
where B: StarkField,

Source

pub fn new( trace_info: TraceInfo, transition_constraint_degrees: Vec<TransitionConstraintDegree>, num_assertions: usize, options: ProofOptions, ) -> AirContext<B>

Returns a new instance of AirContext instantiated for computations which require a single execution trace segment.

The list of transition constraint degrees defines the total number of transition constraints and their expected degrees. Constraint evaluations computed by Air::evaluate_transition() function are expected to be in the order defined by this list.

§Panics

Panics if

  • transition_constraint_degrees is an empty vector.
  • num_assertions is zero.
  • Blowup factor specified by the provided options is too small to accommodate degrees of the specified transition constraints.
  • trace_info describes a multi-segment execution trace.
Source

pub fn new_multi_segment( trace_info: TraceInfo, main_transition_constraint_degrees: Vec<TransitionConstraintDegree>, aux_transition_constraint_degrees: Vec<TransitionConstraintDegree>, num_main_assertions: usize, num_aux_assertions: usize, options: ProofOptions, ) -> AirContext<B>

Returns a new instance of AirContext instantiated for computations which require multiple execution trace segments.

The lists of transition constraint degrees defines the total number of transition constraints and their expected degrees. Constraint evaluations computed by Air::evaluate_transition() function are expected to be in the order defined by main_transition_constraint_degrees list. Constraint evaluations computed by Air::evaluate_aux_transition() function are expected to be in the order defined by aux_transition_constraint_degrees list.

§Panics

Panics if

  • main_transition_constraint_degrees is an empty vector.
  • num_main_assertions is zero.
  • trace_info.is_multi_segment() == true but:
    • aux_transition_constraint_degrees is an empty vector.
    • num_aux_assertions is zero.
  • trace_info.is_multi_segment() == false but:
    • aux_transition_constraint_degrees is a non-empty vector.
    • num_aux_assertions is greater than zero.
  • Blowup factor specified by the provided options is too small to accommodate degrees of the specified transition constraints.
Source

pub fn trace_info(&self) -> &TraceInfo

Returns the trace info for an instance of a computation.

Source

pub fn trace_len(&self) -> usize

Returns length of the execution trace for an instance of a computation.

This is guaranteed to be a power of two greater than or equal to 8.

Source

pub fn trace_poly_degree(&self) -> usize

Returns degree of trace polynomials for an instance of a computation.

The degree is always trace_length - 1.

Source

pub fn ce_domain_size(&self) -> usize

Returns size of the constraint evaluation domain.

This is guaranteed to be a power of two, and is equal to trace_length * ce_blowup_factor.

Source

pub fn lde_domain_size(&self) -> usize

Returns the size of the low-degree extension domain.

This is guaranteed to be a power of two, and is equal to trace_length * lde_blowup_factor.

Source

pub fn num_transition_constraints(&self) -> usize

Returns the number of transition constraints for a computation.

The number of transition constraints is defined by the total number of transition constraint degree descriptors (for both the main and the auxiliary trace constraints). This number is used to determine how many transition constraint coefficients need to be generated for merging transition constraints into a constraint composition polynomial.

Source

pub fn num_main_transition_constraints(&self) -> usize

Returns the number of transition constraints placed against the main trace segment.

Source

pub fn num_aux_transition_constraints(&self) -> usize

Returns the number of transition constraints placed against the auxiliary trace segment.

Source

pub fn num_assertions(&self) -> usize

Returns the total number of assertions defined for a computation.

The number of assertions consists of the assertions placed against the main segment of an execution trace as well as assertions placed against the auxiliary trace segment.

Source

pub fn num_transition_exemptions(&self) -> usize

Returns the number of rows at the end of an execution trace to which transition constraints do not apply.

This is guaranteed to be at least 1 (which is the default value), but could be greater. The maximum number of exemptions is determined by a combination of transition constraint degrees and blowup factor specified for the computation.

Source

pub fn num_constraint_composition_columns(&self) -> usize

Returns the number of columns needed to store the constraint composition polynomial.

This is the maximum of:

  1. The maximum evaluation degree over all transition constraints minus the degree of the transition constraint divisor divided by trace length.
  2. 1, because the constraint composition polynomial requires at least one column.

Since the degree of a constraint C(x) can be computed as

[constraint.base + constraint.cycles.len()] * [trace_length - 1]

the degree of the constraint composition polynomial can be computed as:

([constraint.base + constraint.cycles.len()] * [trace_length - 1] - [trace_length - n])

where constraint is the constraint attaining the maximum and n is the number of exemption points. In the case n = 1, the expression simplifies to:

[constraint.base + constraint.cycles.len() - 1] * [trace_length - 1]

Thus, if each column is of length trace_length, we would need

[constraint.base + constraint.cycles.len() - 1]

columns to store the coefficients of the constraint composition polynomial. This means that if the highest constraint degree is equal to 5, the constraint composition polynomial will require four columns and if the highest constraint degree is equal to 7, it will require six columns to store.

Source

pub fn set_num_transition_exemptions(self, n: usize) -> AirContext<B>

Sets the number of transition exemptions for this context.

§Panics

Panics if:

  • The number of exemptions is zero.
  • The number of exemptions exceeds half of the trace length.
  • Given the combination of transition constraints degrees and the blowup factor in this context, the number of exemptions is too larger for a valid computation of the constraint composition polynomial.

Trait Implementations§

Source§

impl<B> Clone for AirContext<B>
where B: Clone + StarkField,

Source§

fn clone(&self) -> AirContext<B>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<B> PartialEq for AirContext<B>
where B: PartialEq + StarkField,

Source§

fn eq(&self, other: &AirContext<B>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<B> Eq for AirContext<B>
where B: Eq + StarkField,

Source§

impl<B> StructuralPartialEq for AirContext<B>
where B: StarkField,

Auto Trait Implementations§

§

impl<B> Freeze for AirContext<B>
where B: Freeze,

§

impl<B> RefUnwindSafe for AirContext<B>
where B: RefUnwindSafe,

§

impl<B> Send for AirContext<B>

§

impl<B> Sync for AirContext<B>

§

impl<B> Unpin for AirContext<B>
where B: Unpin,

§

impl<B> UnwindSafe for AirContext<B>
where B: 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.

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> 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.