Polynomial Commitment Scheme Prover
In this section, we will see the implementation of the commitment scheme prover. We will start by looking at the building blocks.Commitment Tree Prover
TheCommitmentTreeProver struct represents the data for a single Merkle tree commitment. As we have seen in the Merkle tree section, we can commit to multiple polynomials of different degrees in the same Merkle tree. It is implemented as follows:
pub type ColumnVec<T> = Vec<T>. It contains the following fields:
polynomials: The set of polynomials committed in a single Merkle tree.evaluations: The evaluations of these polynomials over their respective domains.commitment: TheMerkleProverstruct as described in the Merkle tree section.
polynomials, we evaluate them on the evaluation domain using circle FFT to compute evaluations. Then we commit to those evaluations using the MerkleProver struct. Finally, we create and output the CommitmentTreeProver struct.
Commitment Scheme Prover
TheCommitmentSchemeProver struct is the key struct which maintains a vector of commitment trees. It implements functionalities to open the committed polynomials, compute quotients, and then apply the FRI protocol. It contains the following fields:
tree: This contains a vector of commitment trees. Here,pub struct TreeVec<T>(pub Vec<T>).config: This is thePcsConfig, which contains thefri_configandpow_bits.
twiddles: This contains precomputed twiddle factors.
CommitmentSchemeProver struct.
Commit
Thecommit function, given a batch of polynomials, computes the CommitmentTreeProver struct which commits to the input polynomials and then appends the tree struct to the vector of stored trees.
Trace
Thetrace function returns a Trace struct containing all polynomials and their evaluations corresponding to all the commitment trees. It is implemented as follows:
Commitment Tree Builder
Thetree_builder function outputs the TreeBuilder struct.
TreeBuilder struct is a helper for aggregating polynomials and evaluations before committing them in a Merkle tree. It allows the prover to collect columns (polynomials) and then commit them together as a batch. It is implemented as follows:
Prove
Theprove_values function is central to the protocol, handling the opening of committed polynomials at specified sample points and integrating with the FRI protocol for low-degree testing. It is implemented as follows:
-
Evaluate Polynomials at Sample Points:
- For each committed polynomial and each sample point (including out-of-domain points and mask points which contain constraint offsets), the function evaluates the polynomials and collects the results in
samples. - The
sampled_valuesare mixed into the channel, ensuring they are bound to the proof and used for subsequent randomness generation.
- For each committed polynomial and each sample point (including out-of-domain points and mask points which contain constraint offsets), the function evaluates the polynomials and collects the results in
-
Compute FRI Quotients:
- The function computes FRI quotient polynomials using
compute_fri_quotientsto open the committed polynomials at sampled points insamples. This follows the same quotienting process as described in the overview section.
- The function computes FRI quotient polynomials using
-
FRI Commitment Phase:
- The FRI protocol is run on the quotient polynomials, committing to their evaluations in Merkle trees and initializing the
fri_prover. For more details, refer to the FRI prover section.
- The FRI protocol is run on the quotient polynomials, committing to their evaluations in Merkle trees and initializing the
-
Proof of Work:
- A proof-of-work step is performed, with the result mixed into the channel.
-
FRI Decommitment Phase:
- The function generates random query positions using the channel and decommits the FRI layers at those positions, providing Merkle decommitments for all queried values. For more details, refer to the FRI prover section.
-
Decommitment of Committed Trees:
- For each commitment tree, the function decommits the Merkle tree at the FRI query positions, providing the queried values and authentication paths.
-
Return Proof Object:
- The function returns a
CommitmentSchemeProofobject containing:- Merkle roots of all commitments
- Sampled values at all sample points
- Merkle decommitments for all queries
- Queried values
- Proof-of-work result
- FRI proof
- Protocol configuration
- The function returns a