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;
// Provided method
fn iter_twiddles(
&self,
layer: usize,
log_step_by: usize,
) -> impl Iterator<Item = 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§
Sourcefn log_domain_size(&self) -> usize
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.
Sourcefn subspace(&self, i: usize) -> BinarySubspace<Self::Field>
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
imust be less than or equal toself.log_domain_size()
Sourcefn twiddle(&self, layer: usize, block: usize) -> Self::Field
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.
Let $i$ be layer, and $j$ be block. This returns
$$ S^{(\ell - i - 1)}{2j} = \hat{W}{\ell - i - 1}\left( \sum_{b = 0}^{i-1} j_b \beta_{\ell - i + b} \right) $$
The equality above is a consequence of Corollary 4.5 from DP24.
§Preconditions
layer < self.log_domain_size()block < 2^layer
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<T: DomainContext> DomainContext for &T
Make it so that references to a [DomainContext implement DomainContext themselves.
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.