KZG Encoder Backend
It is important that the encoding and commitment tasks are able to be performed in seconds and that the dominating complexity of the computation is nearly linear in the degree of the polynomial. This is achieved using algorithms based on the Fast Fourier Transform (FFT) and amortized kzg multi-reveal generation.
This document describes how the KZG-FFT encoder backend implements the Encode(data [][]byte, params EncodingParams) (BlobCommitments, []*Chunk, error)
interface, which
transforms the blob into a list of
params.NumChunks
Chunks
, where each chunk is of lengthparams.ChunkLength
.produces the associated polynomial commitments and proofs.
We will also highlight the additional constraints on the Encoding interface which arise from the KZG-FFT encoder backend.
Deriving the polynomial coefficients and commitment
As described in the Encoding Module Specification, given a blob of data, we convert the blob to a polynomial by simply slicing the data into a string of symbols, and interpreting this list of symbols as the tuple .
Given this polynomial representation, the KZG commitment can be calculated as in KZG polynomial commitments.
Polynomial Evaluation with the FFT
In order to use a Discrete Fourier Transform (DFT) to evaluate a polynomial, the indices of the polynomial evaluations which will make up the Chunks must be members of a cyclic group, which we will call . A cyclic group is the group generated by taking all of the integer powers of some generator , i.e., (For this reason, the elements of a cyclic group of order will sometimes be referred to as the ’th roots of unity). Notice that since our polynomial lives on the BN254 field, the group must be a subgroup of that field (i.e. all if its elements must lie within that field).
Given a cyclic group of order , we can evaluate a polynomial of order at the indices contained in via the DFT,
where gives the evaluation of the polynomial at . Letting denote the vector of polynomial coefficients and the vector of polynomial evaluations, we can use the shorthand . The inverse relation also holds, i.e., .
To evaluate the DFT programmatically, we want . Notice that we can achieve this when by simply padding with zeros to be of length .
The use of the FFT can levy an additional requirement on the size of the group . In our implementation, we require the size of to be a power of . For this, we can make use of the fact that the prime field associated with BN-254 contains a subgroup of order , which in turn contains subgroups of orders spanning every power of 2 less than .
As the encoding interface calls for the construction of Chunks of length , our application requires that be of size , which in turn must be a power of .
Amortized Multireveal Proof Generation with the FFT
The construction of the multireveal proofs can also be performed using a DFT (as in "Fast Amortized Kate Proofs"). Leaving the full details of this process to the referenced document, we describe here only 1) the index-assignment the scheme used by the amortized multiproof generation approach and 2) the constraints that this creates for the overall encoder interface.
Given the group corresponding to the indices of the polynomial evaluations and a cyclic group which is a subgroup of , the cosets of in are given by
Each coset has size , and there are unique and disjoint cosets.
Given a polynomial and the groups and , the Amortized Kate Proofs approach generates different KZG multi-reveal proofs, where each proof is associated with the evaluation of at the indices contained in a single coset for . Because the Amortized Kate Proofs approach uses the FFT under the hood, itself must have an order which is a power of .
For the purposes of the KZG-FFT encoder, this means that we must choose to be of size and to be of size , each of which must be powers of .
Worked Example
As a simple illustrative example, suppose that AssignmentCoordinator
provides the following parameters in order to meet the security requirements of given blob:
Supplied with these parameters, Encoder.GetEncodingParams
will upgrade to the next highest power of , i.e., , and leave unchanged. The following figure illustrates how the indices will be assigned across the chunks in this scenario.
Last updated