Trait DomainContext

Source
pub trait DomainContext {
    type Field: BinaryField;

    // Required methods
    fn log_domain_size(&self) -> usize;
    fn subspace(&self, i: usize) -> BinarySubspace<Self::Field>;
    fn twiddle(&self, layer: usize, block: usize) -> Self::Field;
}
Expand description

Provides information about the domains $S^{(i)}$ and the associated twiddle factors.

Needed by the NTT and by FRI.

Required Associated Types§

Required Methods§

Source

fn log_domain_size(&self) -> usize

Base 2 logarithm of the size of $S^{(0)}$, i.e., $\ell$.

In other words: Index of the first layer that can not be computed anymore. I.e., number of the latest layer that can be computed, plus one. Layers are indexed starting from 0.

If you intend to call the NTT with skip_late = 0, then this should be equal to the base 2 logarithm of the number of scalars in the input.

Source

fn subspace(&self, i: usize) -> BinarySubspace<Self::Field>

Returns the binary subspace with dimension $i$.

In DP24, this subspace is referred to as $S^{(\ell - i)}$, where $\ell$ is the maximum domain size of the NTT, i.e., self.log_domain_size(). We choose to reverse the indexing order with respect to the paper because it is more natural in code that the $i$th subspace has dimension $i$.

§Preconditions
  • i must be less than or equal to self.log_domain_size()
Source

fn twiddle(&self, layer: usize, block: usize) -> Self::Field

Returns the twiddle of a certain block in a certain layer.

The layer numbers start from 0, i.e., the earliest layer is layer 0.

§Preconditions
  • layer < self.log_domain_size()
  • block < 2^layer

Implementations on Foreign Types§

Source§

impl<T: DomainContext> DomainContext for &T

Make it so that references to a [DomainContext implement DomainContext themselves.

This is useful, for example, if you need two objects that each want to own a DomainContext, but you don’t want to clone the DomainContext.

Source§

type Field = <T as DomainContext>::Field

Source§

fn log_domain_size(&self) -> usize

Source§

fn subspace(&self, i: usize) -> BinarySubspace<Self::Field>

Source§

fn twiddle(&self, layer: usize, block: usize) -> Self::Field

Implementors§