FRI Verifier
In this section, we describe the implementation of the FRI verifier in S-two, continuing the example from the technical overview and prover documentation. The verifier’s role is to check that all folding steps have been performed correctly by the prover. TheFriVerifier struct verifies the FRI proof generated by the prover.
- config: The
FriConfigcontaining protocol parameters. - first_layer: The first layer verifier, which checks Merkle decommitments for all initial circle polynomials (i.e., , , ).
- inner_layers: A vector of inner layer verifiers, each corresponding to a folding round and its Merkle decommitment (i.e., two layers, corresponding to and ).
- last_layer_domain: The “line” domain for the final layer polynomial (i.e., ).
- last_layer_poly: The final “line” polynomial sent in clear by the prover.
- queries: The set of queries used for spot-checking the folding identities.
Initialization
Thecommit function initializes the FriVerifier using the FRI proof, the Fiat-Shamir channel, and protocol parameters. It sets up the verifier for the query phase.
channel: The Fiat-Shamir channel for randomness and transcript hashing.config: TheFriConfigwith protocol parameters.proof: TheFriProofstruct containing Merkle decommitments and the last layer polynomial.column_bounds: The degree bounds for each committed circle polynomial, in descending order.
- Initializes the first layer verifier with the Merkle decommitments for circle polynomials , , , their respective domains , , , their degree bounds, and folding randomness .
- Initializes each inner layer verifier with its Merkle decommitment, domain, degree bounds, and folding randomness. For our example:
- The first inner FRI verifier layer will store decommitments for , its domain , degree bound, and folding randomness .
- Similarly, the second inner FRI verifier layer will store decommitments for , its domain , degree bound, and folding randomness .
- Stores the last layer polynomial and its domain .
- Initializes the
queriesasNoneand prepares the verifier for the query phase. - Outputs the
FriVerifierstruct.
Query generation
The functionsample_query_positions uses the Fiat-Shamir channel to generate random query positions for checking the folding equations. It maps each domain size to its respective query positions, ensuring that queries are adapted to the domain of each polynomial.
&mut self: This will be used to update thequeriesinFriVerifier, which was initialized toNone.channel: The Fiat-Shamir channel.
- Samples
n_queriesrandom positions on the largest domain using thechannel. - Returns a mapping from domain log sizes to their respective query positions using the function
query_positions_by_log_size.
Verification
The functiondecommit verifies the FriVerifier after it has been initialized with the FriProof by verifying the Merkle decommitments and folding equations for all layers. It ensures that the prover’s folding steps were performed correctly and that the final polynomial is close to the expected polynomial space.
mut self: TheFriVerifierstruct after initialization using thecommitfunction.first_layer_query_evals: The evaluations of the circle polynomials at the sampled query points.
-
First Layer Verification:
- Verifies Merkle decommitments for , , at the queried points , , and , respectively.
- Extracts the necessary evaluations for folding into the next layer.
-
Inner Layer Verification:
- For each inner layer, verifies Merkle decommitments for , at the folded query points and , respectively.
- Checks the following two folding equations using the folding randomness and the evaluations from previous layers.
-
Last Layer Verification:
- Checks that the final polynomial matches the evaluations at the last layer’s query positions.
- Returns success if all checks pass; otherwise, returns an error indicating which layer failed.