KZG Commitments - theory, applications
Kate, Zaverucha and Goldberg (KZG) commitments serve as both a vector and functional commitment scheme. Using it, you can commit to a vector of values using a polynomial's coefficients or evaluations. Additionally, by enabling the revelation of arbitrary polynomial evaluations later, it can also work as a functional commitment scheme.
KZG proofs have the advantage of being constant size: it is independent of the polynomial's degree or of the number of evaluations we prove - using "multiproofs". Thus, KZG makes commmunication costs between a prover and a verifier quite low. The tradeoff is the requirement to carry out a (re-usable) trusted setup.
Some of the steps laid out here can be followed with accompanying toy arkworks code here. If you want to jump to the cool stuff directly, we review KZG in an applied context at the end of this post.
Algorithm
Recall that a pairing is a bilinear function such that and two elements of groups (of order ) and , we have:
.
where is the scalar field of .
KZG can be instantiated with any type of pairing group (type 1, type 2 or type 3). Most of recent pairing-based protocols use type 3 curves though. This is today's recommended way of designing things.
In the literature, a polynomial commitment scheme is often defined as a collection of six distinct algorithms: , , , , and . Let's go through each of them.
1.
Select a pairing friendly curve consisting of groups , . Choose public generators and . Sample at random a secret value . We will commit to a univariate polynomial of degree , taken from ; i.e. a polynomial with coefficients in the integers modulo .
Compute the trusted setup parameters:
where . We note . Hence, will be equal to ).
Set the verification key:
Where is . Finally, get rid of .
2.
Compute the commitment to with:
This is possible to compute without knowing since:
Elements are from the trusted setup. The commitment is a single group element in .
3.
The prover outputs a polynomial . The verifier can run to ensure that this opened polynomial corresponds to the commitment .
4.
This algorithm is run by the verifier. It takes as input the commitment and a polynomial sent by the prover. It checks:
where each is a coefficient of . Outputs if the equality holds, otherwise.
5.
Creates the evalution proof, proving evaluations of at a point . The prover computes a new univariate polynomial :
where is the evaluation of at . The proof is . The prover does not need to know to compute since:
where each is a coefficient of . It outputs the tuple .
6.
The verifier wants to check whether the claimed is true. The verifier does not have access to , but only to the commitment , the value , the claimed and the proof .
The verifier checks whether this equality holds:
To see why, the verifier's check actually boils down to:
Applications
Here is a quick list of interesting KZG applications.
1. Credentials
This is detailed in section 4.3 of the seminal paper, along with other cool applications. The idea is to have a trusted authority sign a commitment to a polynomial. Evaluations of this polynomial would correspond to the vector of information which build up a credential's content. Using this signed commitment, a user can then selectively prove a value or a subset of values of his/her credentials information. The verifier will only have to check that the signature of the commmitted polynomial it receives is valid and that the evaluation proof is correct.
2. Proto-danksharding
Ethereum uses the BLS12-381 type-3 pairing friendly curve for EIP-4844 which leverages KZG commitments under the hood. Blob data consists in a vector of 4096 field elements from the scalar field . This vector of field elements is interpreted as coefficients of a polynomial and committed to using KZG. To this end, a point evaluation precompile is being introduced in the EVM. Its use is mainly intended for L2 rollups. Given the large application surface of KZG, I would not be surprised if this precompile were to deviate from its initial purpose in the near future, though.
3. Halo2
Scroll L2 switched Halo2's initial polynomial commitment scheme (a variant of IPA) for KZG. Roughly, KZG is used to commit to witness values and to a quotient polynomial attesting to the fact that the constraint systems is satisfied with this witness. There is a nice post here going over the nitty-gritty.
4. Proof of solvency protocols
V. Buterin described a proof of solvency protocol where a CEX's users and balances would be committed to using KZG. Users would then be able to verify that they have been included into the commitment using evaluation proofs. An additional auxiliary polynomial is used to also prove properties of the exchange's balance sheet - namely that it is solvent. Summa is a project working on this. We also did a simpler example implementation here.
5. Extractable Witness Encryption
As I'm currently updating this blog, let me add this more recent application. In this paper, the authors show how to encrypt a message so that only someone with the knowledge of a valid KZG opening can decrypt it. There is a nice presentation done by Nils Fleischhacker himself here.