ConstraintDivisor

Struct ConstraintDivisor 

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

The denominator portion of boundary and transition constraints.

A divisor is described by a combination of a sparse polynomial, which describes the numerator of the divisor and a set of exemption points, which describe the denominator of the divisor. The numerator polynomial is described as multiplication of tuples where each tuple encodes an expression $(x^a - b)$. The exemption points encode expressions $(x - a)$.

For example divisor $(x^a - 1) \cdot (x^b - 2) / (x - 3)$ can be represented as: numerator: [(a, 1), (b, 2)], exemptions: [3].

A divisor cannot be instantiated directly, and instead must be created either for an Assertion or for a transition constraint.

Implementations§

Source§

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

Source

pub fn from_transition( constraint_enforcement_domain_size: usize, num_exemptions: usize, ) -> ConstraintDivisor<B>

Builds a divisor for transition constraints.

For transition constraints, the divisor polynomial $z(x)$ is always the same:

$$ z(x) = \frac{x^n - 1}{ \prod_{i=1}^k (x - g^{n-i})} $$

where, $n$ is the length of the execution trace, $g$ is the generator of the trace domain, and $k$ is the number of exemption points. The default value for $k$ is $1$.

The above divisor specifies that transition constraints must hold on all steps of the constraint enforcement domain except for the last $k$ steps.

Source

pub fn from_assertion<E>( assertion: &Assertion<E>, trace_length: usize, ) -> ConstraintDivisor<B>
where E: FieldElement<BaseField = B>,

Builds a divisor for a boundary constraint described by the assertion.

For boundary constraints, the divisor polynomial is defined as:

$$ z(x) = x^k - g^{a \cdot k} $$

where $g$ is the generator of the trace domain, $k$ is the number of asserted steps, and $a$ is the step offset in the trace domain. Specifically:

  • For an assertion against a single step, the polynomial is $(x - g^a)$, where $a$ is the step on which the assertion should hold.
  • For an assertion against a sequence of steps which fall on powers of two, it is $(x^k - 1)$ where $k$ is the number of asserted steps.
  • For assertions against a sequence of steps which repeat with a period that is a power of two but don’t fall exactly on steps which are powers of two (e.g. 1, 9, 17, … ) it is $(x^k - g^{a \cdot k})$, where $a$ is the number of steps by which the assertion steps deviate from a power of two, and $k$ is the number of asserted steps. This is equivalent to $(x - g^a) \cdot (x - g^{a + j}) \cdot (x - g^{a + 2 \cdot j}) … (x - g^{a + (k - 1) \cdot j})$, where $j$ is the length of interval between asserted steps (e.g. 8).
§Panics

Panics of the specified trace_length is inconsistent with the specified assertion.

Source

pub fn numerator(&self) -> &[(usize, B)]

Returns the numerator portion of this constraint divisor.

Source

pub fn exemptions(&self) -> &[B]

Returns exemption points (the denominator portion) of this constraints divisor.

Source

pub fn degree(&self) -> usize

Returns the degree of the divisor polynomial

Source

pub fn evaluate_at<E>(&self, x: E) -> E
where E: FieldElement<BaseField = B>,

Evaluates the divisor polynomial at the provided x coordinate.

Source

pub fn evaluate_exemptions_at<E>(&self, x: E) -> E
where E: FieldElement<BaseField = B>,

Evaluates the denominator of this divisor (the exemption points) at the provided x coordinate.

Trait Implementations§

Source§

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

Source§

fn clone(&self) -> ConstraintDivisor<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> Debug for ConstraintDivisor<B>
where B: Debug + StarkField,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<B> Display for ConstraintDivisor<B>
where B: StarkField,

Source§

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

Formats the value using the given formatter. Read more
Source§

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

Source§

fn eq(&self, other: &ConstraintDivisor<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 ConstraintDivisor<B>
where B: Eq + StarkField,

Source§

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

Auto Trait Implementations§

§

impl<B> Freeze for ConstraintDivisor<B>

§

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

§

impl<B> Send for ConstraintDivisor<B>

§

impl<B> Sync for ConstraintDivisor<B>

§

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

§

impl<B> UnwindSafe for ConstraintDivisor<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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.