Varun Thakore

Circle STARKs: Circles

This is Part II of a four-part series on Circle STARKs; Part I covers Mersenne prime fields. It was written with Mathias Hall-Andersen. The original appeared on the ZK Security blog.


In this post we start our journey into the algebra of Circle STARKs. It’s pretty easy actually.

The Complex Numbers#

You remember the complex numbers C\mathbb{C} from high-school maths, right? Some high-school teachers are better at conveying this than others, but the way to “construct” the complex numbers is as a quotient of the polynomial ring R[X]\mathbb{R}[X] by the ideal generated by the irreducible polynomial X2+1∈R[X]X^2 + 1 \in \mathbb{R}[X]:

C=R[X]/(X2+1) \mathbb{C} = \mathbb{R}[X] / (X^2 + 1)

In other words, polynomials plus/minus multiples of X2+1X^2 + 1. The more common way to think about the complex numbers is as a+b⋅i a + b \cdot i where ii and −i-i are the roots of the polynomial X2+1X^2 + 1, i.e. i2+1=0i^2 + 1 = 0 and (−i)2+1=0(-i)^2 + 1 = 0. These two views are isomorphic (the same) via:

ϕ:a+b⋅i↦a+b⋅X\phi: a + b \cdot i \mapsto a + b \cdot X

For completeness, let’s briefly recall the algebra of complex numbers:

You add complex numbers “coordinate-wise”:

(a+b⋅i)+(c+d⋅i)=(a+c)+(b+d)⋅i (a + b \cdot i) + (c + d \cdot i) = (a + c) + (b + d) \cdot i

This is because, as we saw, they are really just (equivalence classes of) polynomials in disguise and this is how you add polynomials. Similarly, you multiply complex numbers like this:

(a+b⋅i)⋅(c+d⋅i)=(a⋅c−b⋅d)+(a⋅d+b⋅c)⋅i (a + b \cdot i) \cdot (c + d \cdot i) = (a \cdot c - b \cdot d) + (a \cdot d + b \cdot c) \cdot i

This is equivalent to multiplication of polynomials in F[X]\mathbb{F}[X], followed by reduction modulo X2+1X^2 + 1. Finally, as a result, if you multiply a complex number by itself you get:

(a+b⋅i)⋅(a+b⋅i)=(a2−b2)+2⋅a⋅b⋅i (a + b \cdot i) \cdot (a + b \cdot i) = (a^2 - b^2) + 2 \cdot a \cdot b \cdot i

Because, you know, i2=−1i^2 = -1. We also have the “complex conjugate” of a complex number zˉ\bar{z}, defined by flipping the imaginary component i.e. (x+iy)‾=x−iy\overline{(x + i y)} = x - i y. This distributes over multiplication and addition: z1⋅z2‾=z1ˉ⋅z2ˉ\overline{z_1 \cdot z_2} = \bar{z_1} \cdot \bar{z_2} and z1+z2‾=z1ˉ+z2ˉ\overline{z_1 + z_2} = \bar{z_1} + \bar{z_2}. Recall that both ii and −i-i are roots of the polynomial X2+1X^2 + 1, so one can think of conjugation as switching between the arbitrary choice of ii and −i-i. If you feel fancy you can call such a map a field automorphism: it maps from the field to itself and preserves the field operations.

Nothing Special About The Reals#

In the section above we constructed the complex numbers as a quotient of the polynomial ring R[X]\mathbb{R}[X] by the ideal generated by the irreducible polynomial X2+1∈R[X]X^2 + 1 \in \mathbb{R}[X]. Exactly the same works for any field F\mathbb{F} (F=R\mathbb{F} = \mathbb{R} in the above example), in particular, for finite fields: suppose we have a finite field F=Fq\mathbb{F} = \mathbb{F}_q, then you can consider the polynomial X2+1∈Fq[X]X^2 + 1 \in \mathbb{F}_q[X] and extend the field with a root of this polynomial. i.e. form the “degree 2 extension” of Fq\mathbb{F}_q as:

Fq2=Fq[X]/(X2+1)\mathbb{F}_{q^2} = \mathbb{F}_q[X] / (X^2 + 1)

Note that X2+1X^2 + 1 needs to be irreducible in the field Fq\mathbb{F}_q e.g. F=F2\mathbb{F} = \mathbb{F}_2 won’t work, since:

(X+1)2=X2+1+2X=X2+1(X + 1)^2 = X^2 + 1 + 2 X = X^2 + 1

The Unit Circle as a Group#

Do you also remember the real unit circle from high-school maths? Sure you do, here it is:

S1={(x,y)∣x2+y2=1}⊂R2 \mathbb{S}^1 = \{ (x, y) \mid x^2 + y^2 = 1 \} \subset \mathbb{R}^2

This just means every element of “l2l^2-norm 1” in R\mathbb{R}: every point at “distance 1” from the origin or every vector of length one if you will.

If we consider the complex numbers with norm 1, we get the unit circle in the complex plane:

S1={z∈C∣∣z∣=1}={z=x+iy∈C∣z⋅zˉ=1} \begin{aligned} \mathbb{S}^1 &= \left\{ z \in \mathbb{C} \mid \left|z\right| = 1 \right\} \\ &= \left\{ z = x + i y \in \mathbb{C} \mid z \cdot \bar{z} = 1 \right\} \end{aligned}

By looking at the circle like this, we can see that it is a group under multiplication, if you multiply two complex numbers z1,z2∈Cz_1, z_2 \in \mathbb{C} of norm 1, you get a complex number z1⋅z2z_1 \cdot z_2 of norm 1, as shown below:

(z1⋅z2)⋅z1⋅z2‾=(z1⋅zˉ1)⋅(z2⋅zˉ2)=1⋅1=1 \begin{aligned} (z_1 \cdot z_2) \cdot \overline{z_1 \cdot z_2} &= (z_1 \cdot \bar{z}_1) \cdot (z_2 \cdot \bar{z}_2) \\ &= 1 \cdot 1 = 1 \end{aligned}

If you were really paying attention in high-school, you might even remember Euler’s formula, which is an alternate representation of complex numbers with norm 1:

eiθ=cos⁡(θ)+isin⁡(θ)∈S1 e^{i \theta} = \cos(\theta) + i \sin(\theta) \in \mathbb{S}^1

This is useful because it translates between angles θ\theta and points on the unit circle, as shown in the animation below:

So we can also write it as:

S1={(x,y)∣x2+y2=1}={z∈C∣∣z∣=1}={eiθ∣θ∈R} \begin{aligned} \mathbb{S}^1 &= \{ (x, y) \mid x^2 + y^2 = 1 \} \\ &= \{ z \in \mathbb{C} \mid |z| = 1 \} \\ &= \{ e^{i \theta} \mid \theta \in \mathbb{R} \} \end{aligned}

And therefore, the unit circle has a group structure, that we can view in a couple of ways:

  • As multiplication of complex numbers:

    (x1+iy1)⋅(x2+iy2)=(x1x2−y1y2)+i(x1y2+x2y1) (x_1 + i y_1) \cdot (x_2 + i y_2) = (x_1 x_2 - y_1 y_2) + i (x_1 y_2 + x_2 y_1)
  • As addition of angles θ1+θ2\theta_1 + \theta_2:

    eiθ1⋅eiθ2=ei(θ1+θ2) e^{i \theta_1} \cdot e^{i \theta_2} = e^{i (\theta_1 + \theta_2)}

The identity element is the point at angle θ=0\theta = 0, which is the point (x,y)=(1,0)(x, y)=(1,0) or 1∈C1 \in \mathbb{C}:

1+0i=ei0=11 + 0i = e^{i 0} = 1

The inverse of z=x+iy=eiθz = x + i y = e^{i \theta} is the point with the same angle, but opposite direction:

J(z)=ei(−θ)=x−iy J(z) = e^{i (- \theta)} = x - i y

This point always lies exactly opposite the point zz on the circle, so all we have to do is flip the y-coordinate: the complex conjugate of zz. This is illustrated below with a point and its inverse moving around the circle:

This is clear from both interpretations of the group structure:

  • As multiplication of complex numbers:

    z⋅J(z)=(x+iy)⋅(x−iy)=x2+y2=1 \begin{aligned} z \cdot J(z) &= (x + i y) \cdot (x - i y) \\ &= x^2 + y^2 = 1 \end{aligned}
  • As addition of angles:

    eiθ⋅J(eiθ)=eiθ⋅e−iθ=eiθ−iθ=ei⋅0=1 e^{i\theta} \cdot J(e^{i\theta}) = e^{i\theta} \cdot e^{-i\theta} = e^{i \theta - i \theta} = e^{i \cdot 0} = 1

Since we have a group, it is natural to look at maps from the group to itself. The most central of which is going to be the humble “squaring” or “doubling” map, depending on which perspective we choose:

π:S1→S1 \pi: \mathbb{S}^1 \to \mathbb{S}^1

Which simply:

  • Squares the complex number z=x+iyz = x + iy of norm 11: π(x+iy)=(x+iy)⋅(x+iy)=(x2−y2)+i(2xy)=2x2−1+i(2xy) \begin{aligned} \pi(x + iy) &= (x + iy) \cdot (x + iy) \\ &= (x^2 - y^2) + i (2xy) \\ &= 2 x^2 - 1 + i (2xy) \end{aligned}
  • Or, equivalently, doubles the angle of the point z=eiθz = e^{i\theta}: π(eiθ)=eiθ⋅eiθ=ei⋅2θ \pi(e^{i\theta}) = e^{i\theta} \cdot e^{i\theta} = e^{i \cdot 2\theta}

Because we have x2+y2=1x^2 + y^2 = 1, we can replace y2y^2 with 1−x21 - x^2 and write π(x+iy)=2x2−1+i(2xy)\pi(x + i y) = 2 x^2 - 1 + i (2xy). Note that the x-coordinate (“real part”) of the doubled point, 2x2−12 x^2 - 1, does not depend on yy, this means that we can compute the x-coordinate (“real part”) of repeated doubling using just the x-coordinate and the formula xn+1=2⋅xn2−1x_{n+1} = 2 \cdot x_n^2 - 1, a nice optimization that will come in handy later.

How “Big” is The Circle?#

We just saw that the circle is a subgroup of the multiplicative group of the complex numbers, we also saw earlier that there is nothing “special” about a degree-2 extension of the reals as opposed to any other field: notably finite fields.

The next natural question is: How “large” is this circle group that we introduced? i.e. what is its order? i.e. how many points are there on the unit circle over an arbitrary field? In order to figure this out, we create a bijective map from the circle to the projective line with an “extra point”. To explore this consider the “stereographic projection” onto the y-axis with center (−1,0)(-1, 0): the intersection between the line ((−1,0),(x,y))((-1, 0), (x, y)) and the y-axis. This is illustrated below:

So as we move the point around the circle we can “hit” every value on the y-axis AND a special value “at infinity” when (x,y)=(−1,0)(x, y) = (-1, 0): it sends any point on the circle to R∪{∞}\mathbb{R} \cup \{ \infty \}.

It is also easy to see that the mapping is injective, i.e. every point R∪{∞}\mathbb{R} \cup \{ \infty \} corresponds to a unique point on the circle. So there is an isomorphism between the unit circle and the projective line with a point at infinity. When x≠−1x \neq -1, the explicit mapping and inverse is given by:

t=yx+1,(x,y)=(1−t21+t2,2t1+t2) t = \frac{y}{x + 1}, \quad (x, y) = \left( \frac{1 - t^2}{1 + t^2}, \frac{2t}{1 + t^2} \right)

Although the illustration above is only meaningful for the real numbers, the mapping (the equations above) works for any field F\mathbb{F}. This means that the number of points on the unit circle over a field F\mathbb{F} is ∣F∣+1|\mathbb{F}| + 1, corresponding to the projective line F\mathbb{F} AND a point at infinity. When ∣F∣=2k−1|\mathbb{F}| = 2^k - 1 (Mersenne prime) the unit circle has 2k2^k points i.e. it is a smooth group that we can use for FFTs and FRI as discussed in part one of this series.

As a sanity check: suppose we have an arbitrary field F\mathbb{F} (e.g. some prime field Fp\mathbb{F}_p), the total number of elements in the degree two extension C=F[X]/(X2+1)\mathbb{C} = \mathbb{F}[X] / (X^2 + 1) is ∣C∣=∣F∣2|\mathbb{C}| = |\mathbb{F}|^2 and the number of elements in the multiplicative group C∗\mathbb{C}^{*} is therefore ∣C∗∣=∣F∣2−1|\mathbb{C}^*| = |\mathbb{F}|^2 - 1, everything except 00 has an inverse. And hence ∣S1∣=∣F∣+1|\mathbb{S}_1| = |\mathbb{F}| + 1 divides ∣C∗∣=∣F∣2−1|\mathbb{C}^{*}| = |\mathbb{F}|^2 - 1 as expected: since the circle is a subgroup of the multiplicative group C∗\mathbb{C}^{*}, this is required by Lagrange’s theorem.

Now that we know that the unit circle is a cyclic group of order 2k2^k, let’s look a bit more at its subgroups and cosets.

Subgroups of the Unit Circle#

In the previous section we established that the number of points on the unit circle are ∣F∣+1|\mathbb{F}| + 1 i.e. the unit circle is a cyclic group of order ∣F∣+1|\mathbb{F}| + 1. A cyclic group of order ∣F∣+1|\mathbb{F}| + 1 has a subgroup of order NN for every divisor NN of ∣F∣+1|\mathbb{F}| + 1.

In the case of complex numbers, since there are 2π2\pi radians in a circle, it follows that ω=eiθ\omega = e^{i \theta}, where θ=2πN\theta = \frac{2\pi}{N}, generates a cyclic subgroup of order NN. We will denote a cyclic subgroup of size N=2nN = 2^n by GnG_n. In the STARK protocol, the computation trace is encoded as a low-degree polynomial over some domain DD using the FFT algorithm. For Circle STARKs, the domain DD is a set of points on the circle curve. We will now explore suitable domains for the circle FFT.

Consider Gn−1G_{n-1}, the cyclic subgroup of size 2n−12^{n-1} and its two cosets Q⋅Gn−1Q \cdot G_{n-1} and Q−1⋅Gn−1Q^{-1} \cdot G_{n-1}. The union of the two cosets D=Q⋅Gn−1∪Q−1⋅Gn−1D = Q \cdot G_{n-1} \cup Q^{-1} \cdot G_{n-1} such that Q⋅Gn−1∩Q−1⋅Gn−1=∅Q \cdot G_{n-1} \cap Q^{-1} \cdot G_{n-1} = \emptyset is called the twin-coset of size N=2nN=2^n. In case of circle group defined over Mersenne prime, the twin-coset DD is a coset of the subgroup GnG_n given by

D=Q⋅Gn=Q⋅Gn−1∪Q−1⋅Gn−1, D = Q \cdot G_n = Q \cdot G_{n-1} \cup Q^{-1} \cdot G_{n-1},

we call DD as the standard position coset of size N=2nN=2^n. This set DD forms the trace domain for our circle FFT. We will understand the structure of the twin-coset and the standard position coset using the following example.

The animation illustrates G2G_2, a subgroup of size 4, represented by orange points. It then shows two cosets: Q⋅G2Q \cdot G_2 and Q−1⋅G2Q^{-1} \cdot G_2.

  1. Rotation by QQ: Multiplication of G2G_2 by QQ corresponds to rotating G2G_2 in the counterclockwise direction by an angle δ\delta. This is visualized as the rotated orange points representing Q⋅G2Q \cdot G_2.

  2. Rotation by Q−1Q^{-1}: Similarly, multiplication of G2G_2 by Q−1Q^{-1} rotates G2G_2 in the clockwise direction by δ\delta. This is shown as the rotated blue points representing Q−1⋅G2Q^{-1} \cdot G_2.

The union of both sets, D=Q⋅G2∪Q−1⋅G2D = Q \cdot G_2 \cup Q^{-1} \cdot G_2, forms the twin-coset, which has size 8. The different values of QQ correspond to rotations by different angles δ\delta. For a specific choice of QQ (e.g., rotation by δ=π/8=0.125π\delta = \pi / 8 = 0.125 \pi), the twin-coset DD becomes a coset of the subgroup G8G_8. In this case, DD is the standard position coset of size 8.

Note that the points of a standard position coset (rotation by δ=0.125π\delta = 0.125 \pi) are symmetric about the center (0,0)(0, 0) as well as equally spaced around the circle. In contrast, for a twin-coset (rotation by δ≠0.125π\delta \neq 0.125 \pi), the points are only symmetric about (0,0)(0, 0).

We will now look into the polynomials which are interpolated over the standard position coset (trace domain for Circle STARKs).

Polynomials Over The Circle#

In the context of STARKs, the computation trace is interpolated as polynomials over a specified domain. For traditional STARKs, this domain is the coset of a smooth additive/multiplicative subgroup, and the resulting interpolation yields univariate polynomials. Whereas, in case of Circle STARKs, the domain is formed by points on the circle curve (specifically the standard position coset). Here, interpolation results in bivariate polynomials because the points on the circle curve are represented by two variables: x and y.

Let F[x,y]\mathbb{F}[x, y] represent the ring of bivariate polynomials with coefficients in F\mathbb{F}. Since interpolation occurs over points on the circle curve, the resulting polynomials belong to the quotient of the polynomial ring F[x,y]\mathbb{F}[x, y] by the ideal (X2+Y2−1)\left(X^2 + Y^2 - 1\right). The space of these bivariate polynomials over the circle curve of total degree ≤N/2\leq N/2 is denoted by LN(F)L_N(\mathbb{F}).

LN(F)=F[X,Y]/(X2+Y2−1) L_N(\mathbb{F}) = \mathbb{F}\left[X, Y\right] / \left(X^2 + Y^2 - 1\right)

where (X2+Y2−1)\left(X^2 + Y^2 - 1\right) denotes the ideal generated by the polynomial X2+Y2−1X^2 + Y^2 - 1 i.e.

(X2+Y2−1)={p(X,Y)⋅(X2+Y2−1)∣p(X,Y)∈F[X,Y]} \left(X^2 + Y^2 - 1\right) = \{ p(X, Y) \cdot \left(X^2 + Y^2 - 1\right) \mid p(X, Y) \in \mathbb{F}\left[X, Y\right] \}

Now let us look at another representation of these polynomials. For any p(X,Y)∈LN(F)p(X, Y) \in L_N(\mathbb{F}), we can substitute all the higher degree terms of YY with the equation of circle Y2=1−X2Y^2 = 1 - X^2 and reduce p(X,Y)p(X, Y) to the form,

p(X,Y)=p0(X)+Y⋅p1(X), p(X, Y) = p_0(X) + Y \cdot p_1(X),

Since p(X,Y)p(X, Y) is of total degree ≤N/2\leq N/2, p0p_0 has degree ≤N/2\leq N/2 and p1p_1 has degree ≤N/2−1\leq N/2 - 1. From the above representation we can see that the space LN(F)L_N(\mathbb{F}) is spanned by the following monomial basis:

1,X,…,XN/2,Y,Y⋅X,…,Y⋅XN/2−1 1, X, \ldots, X^{N/2}, Y, Y \cdot X, \ldots, Y \cdot X^{N/2 - 1}

The dimension of LN(F)L_N(\mathbb{F}) is the number of monomial basis elements, which is N+1N + 1. Now we will understand vanishing polynomial, which belongs to the space LN(F)L_N(\mathbb{F}).

Vanishing Polynomial#

A vanishing polynomial is a non-zero polynomial that evaluates to zero over a specific set of points. In STARKs, we define polynomial constraints over the computation trace. These constraints are satisfied when the corresponding polynomial evaluates to zero over points on the trace domain. Thus the constraint polynomial must be a multiple of a polynomial which vanishes (or evaluates to zero) over the trace domain. Therefore, we are particularly interested in vanishing polynomials over the trace domain, which is a twin-coset (or standard position coset).

Before diving into vanishing polynomial, let us first understand some properties of the squaring map, which will be used to express these vanishing polynomials.

The squaring map π\pi is a 2-to-1 map that reduces the twin-coset (or standard position coset) DD of size NN to a twin-coset (or standard position coset) of size N/2N / 2. This property of π\pi is essential for halving the domain during the circle FFT. The squaring map corresponds to doubling the angle of each point on the unit circle.

eiθ⋅eiθ=ei(2θ) e^{i \theta} \cdot e^{i \theta} = e^{i (2\theta)}

The following animation shows the squaring map being applied to each point in the coset one by one, which is equivalent to doubling the angle of each point (represented by rotation). The process begins with the coset represented by blue points. By doubling the angle of each point, we obtain a coset of half the size, represented by red points. Similarly, applying the squaring map to the coset represented by orange points results in a coset of half the size, represented by purple points.

Thus applying the squaring map once to a twin-coset of size 8 (represented by blue and orange points) produces a twin-coset of size 4 (represented by red and purple points). More generally, applying the squaring map n−1n-1 times to a twin coset DD of size N=2nN=2^n gives a twin-coset of size 2, which is shown as follows:

πn−1(D)={(XD,YD),(XD,−YD)} \pi^{n-1}(D) = \{(X_D, Y_D), (X_D, -Y_D)\}

If we project the points onto the xx-axis, we will end up with their xx-coordinate XDX_D.

πx∘πn−1(D)=XD \pi_x \circ \pi^{n-1}(D) = X_D

where πx\pi_x is the projection onto the xx-axis. We can express the vanishing polynomial over the twin-coset DD as

vD(X,Y)=πx∘πn−1(D)−XD v_D(X, Y) = \pi_x \circ \pi^{n-1}(D) - X_D

The squaring map is itself a polynomial, given by π(x+iy)=(2x2−1)+i(2xy) \pi(x + i y) = (2x^2 - 1) + i (2xy) Therefore, when it is iteratively composed with itself and the x-projection, the result is also a polynomial: the vanishing polynomial vD(X,Y)v_D(X, Y). Note that vD(X,Y)v_D(X, Y) evaluates to 00 on all points of the twin-coset DD.

As discussed earlier, the squaring map applied to a standard position coset gives a standard position coset of half the size. The following example illustrates the squaring map applied to a standard position coset of size N=8N=8.

However, in the case of a standard position coset, after applying the squaring map n−1n-1 times, the final points lie on the y-axis i.e. XD=0X_D = 0. Thus, the vanishing polynomial over a standard position coset DD of size N=2nN=2^n is

vD(X,Y)=πx∘πn−1(D) v_D(X, Y) = \pi_x \circ \pi^{n-1}(D)

Conclusion#

In this post, we explored the circle curve, the trace domain used in Circle STARKs (i.e. standard position coset or more generally the twin-coset), and the bivariate polynomials interpolated over this domain. In the next post, we will build on these concepts and delve into the circle FFT.