FRI Prover
In this section, we examine the FRI prover implementation, beginning with the FRI protocol configuration.FRI Protocol Configuration
We configure the FRI protocol using the following parameters:- Log of blowup factor
- Log of last layer degree bound (determines the number of rounds in the FRI protocol)
- Number of queries made by the verifier in the query phase
Proving
Let us look into how the FRI prover struct is implemented.FriOps is a trait which implements functionality for the commit phase of FRI, such as folding the evaluations, and MerkleOps is the trait used in the Merkle commitment scheme. The generic B refers to a specific backend, for example either CpuBackend or SimdBackend, which implements the FriOps and MerkleOps traits.
We described FRI as an interactive protocol between the prover and the verifier. To make the protocol non-interactive, we use the Fiat-Shamir transform, where both the prover and verifier use a channel to hash the transcript and generate random challenges. These functionalities are defined by the MerkleChannel trait. In the non-interactive protocol, oracles to functions are replaced by Merkle commitments to their evaluations, and queries to the oracle by the verifier are replaced by Merkle decommitments, which the prover appends to the channel.
The FRIProver struct is composed of several layers. Each layer contains a Merkle tree that commits to the evaluations of a polynomial for that layer. The main components are:
• config: The FriConfig discussed in the previous section, which holds protocol parameters.
• first_layer: The first layer of the FRI protocol, containing the commitment to the initial set of columns.
channel: The Merkle channel used for the Fiat-Shamir transform to generate random challenges and maintain the transcript.config: TheFriConfigcontaining protocol parameters.columns: The array of evaluations of the functions. For our example, this will contain over their respective domains .twiddles: The precomputed twiddle values needed for folding.
-
First Layer Commitment (
commit_first_layer):- Takes the input functions and creates a Merkle commitment to all of them using a single Merkle tree.
- Commits to the root of the Merkle tree by appending it to the channel as part of the transcript.
- Returns the
FriFirstLayerProvercontaining the columns and their Merkle commitment.
-
Inner Layers Commitment (
commit_inner_layers):- Performs the folding rounds as described in the protocol.
- In each round :
- Decomposes the previous round “line” polynomial into and .
- Decomposes the current round “circle” polynomial into and .
- Receives random challenge from the channel.
- Folds the decomposed functions to compute over domain .
- Creates Merkle commitment to and adds the root of the Merkle tree to the channel.
- For our example with , this creates two inner layers containing and .
- Returns the following two objects:
- Two
FriInnerLayerProvercorresponding to and . - Final
last_layer_evaluation, i.e., evaluations of over the domain .
- Two
-
Last Layer Commitment (
commit_last_layer):- Takes the final evaluation (which will be sent to the verifier in clear).
- Interpolates it to coefficient form and appends the coefficients into the channel as protocol transcript.
- For our example, this converts to polynomial coefficient representation.
- Returns the
last_layer_poly.
FriProver struct containing all layers, which will be used later for decommitment during the query phase.
Decommitment
Now we will look at the decommit function. It is implemented as follows:self: TheFriProvercontaining the Merkle tree commitments to all the FRI layers.channel: The Fiat-Shamir channel used to hash the transcript and generate the random query points.
- Setup Query Generation: Use the Fiat-Shamir channel to generate
n_queriesrandom positions on the maximum domain. - Map Query Positions by Domain Size: The function
get_query_positions_by_log_sizetakesqueriesandcolumn_log_sizesas input and maps each domain size to its respective query position in the column. - Generate Proof: The function
decommit_on_queriesgenerates the proofFriProofusing the queries. The structFriProofcontains the Merkle decommitments for each layer with respect to the query positions.
FriProof will be as follows:
first_layer: The decommitments to query positions for , , and .inner_layers: There will be two inner layer proofs, i.e., one for the decommitments of and another for decommitments of .last_layer_poly: This will be the polynomial represented in coefficient form.
- Return the following objects:
proof: TheFriProofstruct with all layer decommitments.query_positions_by_log_size: The query mapping from domain log sizes to their respective query positions.
decommit_on_queries in detail.
decommit_on_queries generates the FriProof struct by decommitting all layers. Suppose there is a single query corresponding to point and let .
- Decommit First Layer: This provides Merkle tree decommitments for queried positions with respect to the first layer. This provides evaluations , , and along with their Merkle decommitments in the Merkle tree containing the first layer.
- Process Inner Layers with Folding: We process the decommitment layer by layer. For our example, this proceeds as follows:
- For the first inner layer: Provide the evaluation along with their Merkle decommitments.
- For the second inner layer: Provide the evaluation along with their Merkle decommitments.
- Assemble Final Proof: Combines all layer decommitments with the last layer polynomial into
FriProof.