Circle STARKs: Circle FFT
Contents
This is Part III of a four-part series on Circle STARKs. The original appeared on the ZK Security blog.
Recap#
In Part I of this series, we explored efficient field arithmetic over Mersenne primes and a key challenge in instantiating the STARK protocol using them, specifically the absence of a smooth multiplicative subgroup.
In Part II, we examined how this issue can be addressed using the circle group. We introduced the structure of its cosets, i.e., twin-coset and standard position coset, which can be used to instantiate STARK protocols. We also discussed the space of polynomials defined over the circle group, and the construction of vanishing polynomial over these cosets.
Introduction#
There are two common ways to represent a univariate polynomial of degree less than :
Monomial Basis:
where are the coefficients and are the monomial basis polynomials such that:
Lagrange Basis:
where is the evaluation of at point and is the Lagrange basis polynomial satisfying:
- for all
The Lagrange basis polynomial is defined as:
In general, the FFT algorithm performs a transformation from one polynomial basis to another. For example, it can convert a polynomial from the monomial basis to the Lagrange basis, and vice versa. This change of basis is useful because certain operations, such as polynomial multiplication, become significantly more efficient in the Lagrange basis.
In STARK protocols, the computation trace is usually represented as a set of polynomial evaluations at the points in a multiplicative subgroup, which means the coefficients of the polynomial can be computed using a Cooley-Tukey style FFT.
In Circle STARKs, the multiplicative subgroup is replaced by a twin-coset: not a group, but rather a union of cosets of the unit circle. The elements follow the “addition of angles” or “complex multiplication” group law, and each element corresponds to a point on the circle. In the Circle FFT, given evaluations over a twin-coset, we interpolate a bivariate polynomial.
In this post, we develop an intuitive understanding of the Circle FFT by drawing parallels to the classical Cooley–Tukey FFT. Throughout the post, we use FFT to refer to interpolation, moving from the Lagrange basis to a monomial basis, and inverse FFT to refer to evaluation, moving from the monomial basis to the Lagrange basis.
Cooley-Tukey FFT#
In this section, we present a generic version of the Cooley–Tukey FFT algorithm. This general version will eventually help us understand the Circle FFT as a concrete instance of the generic construct. To build intuition, we’ll walk through a concrete example alongside the general description.
Problem Statement#
Given the polynomial evaluations over a domain of size , our goal is to compute the polynomial’s coefficients with respect to some basis polynomials such that:
Here, are the coefficients we wish to compute and denotes the basis polynomials.
Example
Cooley–Tukey FFT with ,
Given the evaluations of a polynomial over a multiplicative subgroup of size , the goal is to compute the coefficients of a polynomial with degree .
For this example, let be a multiplicative subgroup of generated by . Then:
Suppose the evaluations of the polynomial over are:
Algorithm#
The Cooley–Tukey FFT algorithm follows a classic divide-and-conquer strategy. It proceeds as follows:
Step 1: Decompose the polynomial into a collection of lower-degree polynomials and find the evaluations of those lower-degree polynomials over a smaller domain.
Step 2: Recursively apply FFT to each of the lower-degree polynomials to compute their coefficients.
Step 3: Combine the coefficients of the lower-degree polynomials to compute the coefficients of the original polynomial .
At each recursive layer of the FFT algorithm, we decompose a polynomial using the following key components:
: The polynomial map is a -to- map, meaning that it maps elements of the domain to a single element in the smaller domain .
Since , this implies . A common example of such a map over a multiplicative subgroup is: .
: The twiddles are polynomials which map elements from the domain to the field , i.e., for
For a fixed , the fiber of under the map consists of all elements in that map to . Let denote the fiber of an element under the polynomial map , that is:
Since is a -to-1 map, the fiber of each is a subset of , containing exactly elements. The restriction of to the fiber is a polynomial with the following evaluations:
Thus is of degree less than and it lies in a polynomial space of dimension at most . The twiddles must be chosen to span this -dimensional polynomial space. This ensures that the polynomial can be correctly expressed in terms of the twiddles. Thus the twiddles must form a basis of a -dimensional polynomial space over a fiber. This requirement will become clearer as we work through the algorithm and the example.
The polynomial map and the twiddles need not be same across all layers of the FFT algorithm. We now describe each of the steps in more detail.
Step 1: Decompose and compute evaluations of sub-polynomials#
We decompose the polynomial into smaller-degree polynomials as follows:
Each is a polynomial of lower degree than , specifically:
Next, we compute the evaluations of each over using the evaluations of over . Let denote the fiber of an element under the polynomial map . Since it has elements, let us denote it as follows:
Such that for all , . Substituting all , into the decomposition of gives:
Note that since for all , , the are same across all the equations. This gives us a system of linear equations in the unknowns . Solving this system allows us to determine the values of each . Since the system has a constant size , so solving it using e.g. Gaussian elimination takes constant time.
Note
Solving the above system of linear equations reduces to inverting the twiddle matrix, i.e.,
The requirement that the twiddles form a basis of a -dimensional polynomial space over a fiber of size ensures that the twiddle matrix is invertible and thus the above system of linear equations has a unique solution.
Also note that the twiddles are initialized before the start of the algorithm and therefore the corresponding matrix inversions can be precomputed, making it a as oppose to operations.
By repeating this process for every , we obtain the full set of evaluations for all the polynomials over the domain , enabling us to recursively apply the FFT on each of them.
Example
Step 1: All calculations are over , i.e, modulo . First, decompose the polynomial using the map and twiddles :
Given the evaluations of over the domain
we aim to compute the evaluations of and over the smaller domain
For , the preimage set is , since and .
Substitute the values from set into the decomposition equation we get:
Solving this system of equations yields:
Repeating this process for all , we obtain:
Step 2: Recursively apply FFT to sub-polynomials#
Now that we have the evaluations of each over the domain , the next step is to compute their coefficients. This brings us back to the same problem as before, but for polynomials of smaller degree i.e. and over a smaller domain . We apply the same divide-and-conquer strategy.
The polynomial map induces a sequence of progressively smaller domains:
where each domain for , and . We have assumed that the polynomial map is the same across all layers, but in general, each layer may use a different map.
We recursively apply FFT over smaller domains until we reach the base case: a constant polynomial, where all the evaluations over the domain are equal. In this case, interpolating gives a constant polynomial whose sole coefficient is the evaluation value itself. Thus, we simply return this evaluation value as the coefficient.
Once the base case is resolved, we work backward through the recursive calls, using the decomposition equation at each level to reconstruct the coefficients of the original .
Example
Step 2: Given the evaluations of and over :
we recursively apply the FFT algorithm to compute the coefficients of and .
At each layer, we decompose the polynomial using the same polynomial map and the same twiddles as before. For example, the decomposition of is:
Omitting the intermediate steps of the recursive calls, we eventually obtain the coefficients of and as follows:
Step 3: Combine the coefficients#
Finally, we combine the coefficients of the polynomials to compute the coefficients of the original polynomial using the decomposition equation.
Example
Step 3: Given the coefficients of and :
we reconstruct the original polynomial using the decomposition:
Substituting the expressions for and , we get:
Sequence of Domains for Circle FFT#
In Circle FFT, the map is instantiated by a 2-to-1 map tailored for the circle group setting. The domain used here is the twin-coset:
where is a subgroup of the circle group of size and , hence the cosets and are disjoint and . This section describes two specific 2-to-1 maps on that are central to the Circle FFT construction:
- Quotient map : This map sends each point in to an element of the quotient set : where denotes the inversion map . Quotient map maps two distinct points and from to a single element in . This can be interpreted as saying that two points are considered equivalent if they differ only by sign. This is same as the projection map that projects the points and to the same -coordinate: Since or map two points from to a single element in , the size of will be half the size of .
- Squaring map : This map was introduced in Part II. When applied to the twin-coset of size , it produces a smaller twin-coset of size . This is also a 2-to-1 map which halves the size of . By recursively applying this map: we generate a sequence of twin-cosets, until we reach (twin-coset of size 2). Each in this sequence corresponds to a twin-coset associated with the subgroup , and has size .
In Circle FFT, we use both the projection map and the squaring map to construct the sequence of domains. A key property to note is that the maps and commute, meaning:
Intuitively, this means that projecting to the -coordinate and then squaring is the same as squaring first and then projecting to the -coordinate. This is further illustrated by the following two animations.
The following animation shows applying the projection map to a twin-coset followed by the squaring map to get the quotient domain .
The following animation shows applying the squaring map to a twin-coset followed by the projection map to get the quotient domain .
By applying these maps at each layer, we obtain a sequence of domains for the Circle FFT, similar to the domains in the Cooley–Tukey FFT. The key difference lies in the choice of maps: in Cooley–Tukey, we applied a single polynomial map at each layer, whereas in Circle FFT, we apply in the first layer, followed by in subsequent layers.
Let denote the quotient of the twin-coset under the involution . The map is a 2-to-1 map, defined by:
This is obtained using the doubling map and the equality to compute the -coordinate:
The sequence of domains for Circle FFT is shown as follows:
We will now describe the Circle FFT algorithm over these sequence of domains.
Circle FFT#
Let be a Mersenne prime field with , and let denote its algebraic closure.
Given evaluations over a twin-coset , the Circle FFT interpolates a bivariate polynomial from the space . This space consists of bivariate polynomials over the circle curve of total degree :
Let’s walk through the Circle FFT algorithm. As in the Cooley–Tukey case, we’ll also work through a concrete example alongside the algorithm.
Example
Circle FFT on the twin-coset over Mersenne prime
Given the evaluations of a bivariate polynomial over the twin-coset of size , the goal is to compute the coefficients of .
Consider the following twin-coset and the evaluations of over :
Algorithm#
Circle FFT follows the same divide-and-conquer strategy as the Cooley–Tukey FFT. The bivariate polynomial is first decomposed into lower-degree polynomials. We then recursively compute the coefficients of these smaller polynomials and finally combine them to compute the coefficients of the original polynomial.
The key difference lies in how the polynomial is split. In Cooley–Tukey FFT, a single map is applied recursively at every level. In contrast, Circle FFT uses two distinct 2-to-1 maps: the projection map is applied in the first step, and the squaring map is used in all subsequent recursive steps.
Effectively, Circle FFT mirrors Cooley–Tukey, but with a split using initially, followed by recursive splits using . We now walk through each step in detail.
Step 1: Decompose and compute evaluations of sub-polynomials#
In the first step, we split the bivariate polynomial over using the projection map and twiddles , :
Given the evaluations of over , our goal is to compute the evaluations of and over the domain .
For any pair of points and its conjugate in that project to the same , substituting into the decomposition gives:
This system yields two equations in the unknowns and , which can be solved directly.
Applying this to all pairs of points in , gives the evaluations of and over the domain .
Example
Step 1: All calculations are over , i.e, modulo . First, decompose the polynomial using twiddles , and map :
Given the evaluations of over the twin-coset
we aim to compute the evaluations of and over the smaller domain
For and in which have the same projection under , substituting them into the decomposition equation gives:
Solving this system of equations yields:
Repeating this process for all pairs and in , we obtain:
Step 2: Recursively apply FFT to sub-polynomials#
Given the evaluations of and over , we now compute their coefficients.
This step mirrors the recursive structure of the Cooley–Tukey FFT. Each polynomial is recursively split using the squaring map , and the process continues over successively smaller domains.
We begin by decomposing using the squaring map and twiddles , :
We compute the evaluations of and over by solving a system of linear equations, as before.
This recursive process continues until we reach the base case: all evaluations of the polynomial over the domain are same. At that level, the coefficient is simply the evaluation of the constant polynomial.
Finally, we reconstruct the coefficients of by working backward through the recursive calls, using the decomposition equation at each level. The same process applies to compute the coefficients of .
Example
Step 2: Given the evaluations of and over :
we recursively apply the FFT algorithm to compute the coefficients of and .
At each layer, we decompose the polynomial using the polynomial map and the twiddles as before. For example, the decomposition of is:
Omitting the intermediate steps of the recursive calls, we eventually obtain the coefficients of and as follows:
Step 3: Combine the coefficients#
Finally, we combine the coefficients of and to compute the coefficients of the original bivariate polynomial , using the decomposition:
Example
Step 3: Given the coefficients of and :
we reconstruct the original polynomial using the decomposition:
Substituting the expressions for and , we get:
Implementation#
Here’s the Circle FFT implementation written in SageMath.
def cfft(evals, D):
n = len(evals)
assert (n & (n - 1)) == 0
# Step 1: Split using map \pi_x
S = pi_x(D)
eval0 = []
eval1 = []
for e0, e1, P in zip(evals[:n//2], evals[n//2:], D):
eval0.append((e0 + e1) / 2)
eval1.append((e0 - e1) / (2 * get_y(P)))
# Step 2: Recursively apply FFT using map \pi
coeffs0 = cfft_pi(eval0, S)
coeffs1 = cfft_pi(eval1, S)
# Step 3: Recombine to compute coefficients
coeffs = to_natural_order(coeffs0 + coeffs1)
return coeffs
def cfft_pi(evals, S):
n = len(evals)
assert (n & (n - 1)) == 0
if n == 1:
return [evals[0]]
S_next = pi(S)
eval0 = []
eval1 = []
for e0, e1, x in zip(evals[:n//2], evals[n//2:], S):
eval0.append((e0 + e1) / 2)
eval1.append((e0 - e1) / (2 * x))
coeffs0 = cfft_pi(eval0, S_next)
coeffs1 = cfft_pi(eval1, S_next)
return coeffs0 + coeffs1
Basis for FFT#
The FFT algorithm computes the coefficients with respect to some basis polynomials. For example, the Cooley-Tukey algorithm computes the coefficients with respect to basis polynomials such that
The basis with respect to which the coefficients are computed depend on the choice of the polynomial map and the twiddles used at each layer of the FFT algorithm.
To see this in action, let us walk through a simple example. Consider the Cooley–Tukey FFT algorithm over a domain of size 4 to compute the coefficients of a polynomial of degree at most 3. First, we decompose the original polynomial :
Then, we decompose the two sub-polynomials and :
Suppose , , and are constant polynomials. Then
Substitute the above values in decomposition of :
Thus the above algorithm computes the coefficients with respect to the basis: , , and .
Thus depending on the choice of polynomial map and twiddles , the FFT algorithm outputs the coefficients with respect to a particular basis.
Choice 1: We use the polynomial map and twiddles . This gives us coefficients with respect to the monomial basis as follows:
Choice 2: We use the polynomial map and twiddles . This gives us coefficients with respect to the following basis:
Similarly, circle FFT outputs coefficients with respect to some basis such that:
And the basis with respect to which the coefficients are computed depends on the choice of the polynomial map and the twiddles. In the concrete example of Circle FFT over twin-coset , we saw that the algorithm computed the coefficient with respect to the following basis:
Using induction on , we can show that the Circle FFT algorithm outputs coefficients with respect to the following basis [Theorem 2, Circle STARKs]:
where and is the binary representation of , i.e.,
Note
In the paper, the elements of the basis are defined as:
Here, each (for ) is the vanishing polynomial of the standard position coset of size , as described in Part II.
This aligns with our earlier definition of the basis, using the substitution:
Dimension Gap#
Let the space spanned by the basis polynomials in be . The basis has a total elements and thus the dimension of the space is . However, the space of bivariate polynomials over the circle curve is which has dimension , as discussed in Part II.
We can identify the missing highest total degree element in by examining the basis. The highest total degree element in basis is:
Using , the highest degree of in the above term is:
Since the highest degree of in is , we can represent the space as follows:
where represents polynomials of degree at most with coefficients in . Similarly, we can represent the space as:
Thus the space does not include the monomial , which lies in the space . Therefore,
Since the space spanned by is same as the space spanned by the vanishing polynomial which has degree , we can also write:
A consequence of this dimension gap is that we cannot interpolate some polynomials over the circle i.e. those with . We will see how to handle this in the next part of this series.
Conclusion#
In this blog post, we explored the Circle FFT and its structural similarity to the classical Cooley–Tukey FFT. We also discussed the dimension gap between the space of polynomials over the circle curve and the space spanned by the basis of the Circle FFT.
We did not cover the inverse FFT, i.e., evaluating a polynomial at a given set of points. However, the approach is conceptually similar and all operations can be run in reverse. This is left as an exercise to the reader.
In the next part, we’ll address how this dimension gap is handled within the FRI protocol and see how all the ideas from the previous posts come together to build the Circle STARK.