Proof systems typically rely on finite field operations, where efficient field arithmetic is crucial for optimizing proof generation.
In STARK protocols, there is no direct dependency between the security level of the proof system and the field size.
This allows the use of small fields with highly efficient arithmetic, such as Mersenne prime fields.A Mersenne prime is defined as a prime number that is one less than a power of two, expressed as p=2k−1.Consider the Mersenne prime field Fp where p=231−1.
Our objective is to perform field multiplication a⋅b, where a,b∈Fp.
This operation involves a 31-bit integer multiplication, producing a 62-bit intermediate result, which is then reduced modulo p.
Let x=a⋅b, where a,b are 31-bit values, resulting in a 62-bit product x.
We can decompose x into two 31-bit values b and s, such that x=231⋅b+s, as shown in the following figure.
Mersenne Prime Multiplication
To perform modular reduction, we start with:x≡(231⋅b+s)mod(231−1)Substituting 231≡1mod(231−1) gives:x≡(b+s)mod(231−1)Since b and s are both 31-bit values, they can be directly represented as field elements.
Consequently, modular reduction is performed with a single field addition.
This makes arithmetic over Mersenne primes exceptionally fast, making them an ideal choice for our STARK protocol.However, we instantiate STARK protocols over an FFT-friendly field, meaning a field that contains a multiplicative subgroup of order that is a large power of two (commonly referred to as a smooth subgroup).∣Fp∗∣=p−1=2k−2As shown above, Mersenne prime fields lack a smooth subgroup of size that is a large power of two because there is no large power of two that divides ∣Fp∗∣.
In other words, there does not exist a sufficiently large n such that 2n∣p−1.To make Mersenne prime fields compatible with STARKs, we use a degree-2 extension of Fp, defined as follows:Fp2=Fp[X]/(X2+1)This extension forms a field of size p2, where elements can be represented as (a,b) ora+i⋅bwhere a,b∈Fp and i is the root of the polynomial X2+1 i.e. i2+1=0.The order of the multiplicative group of this extended field is calculated as follows:∣Fp2∗∣=p2−1=(p−1)⋅(p+1)For Mersenne primes of the form p=2k−1, this becomes:∣Fp2∗∣=(2k−2)⋅(2k)As shown above, 2k∣∣Fp2∗∣ i.e. Fp2∗ contains a subgroup of size that is a large power of two.
This makes it suitable for instantiating STARKs.
This subgroup is what we refer to as the Circle group (explored further in the next section).
For the soundness of the protocol, it is crucial that the verifier samples random challenges from a sufficiently large field to ensure that an adversary cannot guess or brute-force the challenges and generate a proof that passes verification without knowledge of the witness.
If we use p=231−1, then 31-bit random challenges are not sufficient to maintain the security of the protocol.
To address this, the verifier draws random challenges from a degree-4 extension of Fp, which is equivalent to degree-2 extension of Fp2, denoted as
Fp4=Fp2[X]/(X2−2−i)
The elements of Fp4 can be represented as (r,s) orr+u⋅swhere r,s∈Fp2 and u is the root of the polynomial X2−2−i i.e. u2−2−i=0.Alternatively, the elements of Fp4 can also be represented as four elements of Fp i.e. ((a,b),(c,d)) or(a+i⋅b)+(c+i⋅d)⋅uwhere a,b,c,d∈Fp.
With four elements from F_p, the challenge space consists of 124-bit values, offering a sufficiently large 2124 possibilities to sample a random challenge.