Why ?
The key advantage is extremely cheap modular reduction after a 31-bit multiplication. Consider computing , where . This operation involves a 31-bit integer multiplication, producing a 62-bit intermediate result, which is then reduced modulo . Suppose then we can decompose into two 31-bit values and , such that , as shown in the following figure.reduce is a function which performs efficient reduction of the resulting number modulo .
Why We Need Extensions ?
We cannot instantiate our STARK protocols using since it is not FFT-friendly field, meaning it does not contain a multiplicative subgroup of order that is a large power of two (commonly referred to as a smooth subgroup). The multiplicative group of has the following order: As shown above, the multiplicative group of lacks a smooth subgroup of size that is a large power of two because there is no large power of two that divides . In other words, there does not exist a sufficiently large such that . To make compatible with STARKs, we will work over extensions of it.Field Operations
S-two avoids code duplication by providing two Rust macros,impl_field! and impl_extension_field!, for implementing field and extension field operations.
For example, field operations for are implemented using the Rust macro impl_field!, which takes as argument the field and the size of the field , as follows:
BaseField, as follows:
Extensions of Mersenne Prime Field
This section describes two extensions of : complex extension and quartic extension.Complex Extension
We construct the degree-2 extension of denoted by using the polynomial which is irreducible over . This extension forms a field of size , where elements can be represented as or where and is the root of the polynomial i.e. . This is implemented as follows:impl_field! and impl_extension_field! (which takes as argument the field and the field to be extended i.e. ). These are implemented as follows:
P2 is the size of i.e. .
Quartic Extension
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 , 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 denoted by , which is equivalent to degree-2 extension of , denoted as Here the polynomial is irreducible over . The elements of can be represented as or where and is the root of the polynomial i.e. . This is implemented as follows:SecureField.
Alternatively, the elements of can also be represented as four elements of i.e. or
where . With four elements from , the challenge space consists of 124-bit values, offering a sufficiently large possibilities to sample a random challenge.
Similar to , the operations of are defined using the macros impl_field! and impl_extension_field!, implemented as follows:
P4 is the size of i.e. .
In the next section, we will explore the circle group, which is used to instantiate the STARK protocol.