Here I do not describe multi proofs, this is another thing. In this doc we only talk about vector commitments and proof for a value in the position. It corresponds to a node in the verkle trie (Edited)
The *trusted setup* is public, i.e. it does not contain any secrets. It is computationally non-feasible neither to re-construct $s$ from the given $T$ nor to create another valid $T'(d, \omega, s') = T(d, \omega, s)$ for some other $s'\not=s$.
That is not true, the trusted setup is updatable. You can take T(.,.,s), another secret t, and multiply all the monomials with it, so you get an updated trusted setup for s' = t*s (Edited)
Precalculation of $TA_{mj}$ could take a lot, $O(d^2)$, of memory, so probably not worth it when $d$ is large. Pre-calculation of $A'(\omega^i)$ would be enough.
If you use 0,1,2,3,... as your domain instead of omega^i, then you can simplify this as the denominator simply becomes m-j, so you only need to invert 2n numbers in your precomputation instead of n^2. (Edited)
The *trusted setup* is public, i.e. it does not contain any secrets. It is computationally non-feasible neither to re-construct $s$ from the given $T$ nor to create another valid $T'(d, \omega, s') = T(d, \omega, s)$ for some other $s'\not=s$.
You are right. Does it change something security-wise? (Edited)
Precalculation of $TA_{mj}$ could take a lot, $O(d^2)$, of memory, so probably not worth it when $d$ is large. Pre-calculation of $A'(\omega^i)$ would be enough.
Agreed. 1,2 etc can be used. Just wanted to stick to \omega thing, closer to the original. Why then we need powers and root of unity at all? (Edited)
The *trusted setup* is public, i.e. it does not contain any secrets. It is computationally non-feasible neither to re-construct $s$ from the given $T$ nor to create another valid $T'(d, \omega, s') = T(d, \omega, s)$ for some other $s'\not=s$.
Btw, the updated trusted setup still will be another trusted setup T’ \not= T. So, the statements still holds (Edited)
Evaldas Drąsutis IOTA Foundation
Formulas for polynomial KZG commitments in Lagrange basis
Summary
This post describes an experimental implementation of polynomial KZG commitments, aka Kate commitments. The implementation uses the trusted setup completely in Lagrange basis calculated upon secret , non-secret value and its powers. All computations are performed in the evaluation form. The powers of a secret on the curve nor any FFT operations are not needed in any stage.
The math mostly follows articles on KZG by Dankrad Feist, specifically this and this. We assume the reader is familiar with the content of it.
is a global constant which defines maximum length of the vector we want to commit to. The shorter vectors can be commited by providing zeroes as values, however we can't commit vectors longer than .
The value
The is a scalar in the underlying field with the property of .
We use values to calculate the Lagrange basis. The Lagrange polynomial is defined the following way: Any vector on the field corresponds to the polynomial . It makes for .
The auxiliarly polynomial has its roots at
The formal derivate has the following values at these roots:
We could assume , i.e to be a primitive root of unity Then we'll have and , . It would make some calculation below more economic, however in this implementation we aim to avoid this assumption due to reasons explained below.
We can always assume where is the number of elements of the scalar field and is a field element selected so that the is a primitive root of unity of degree (any non-zero and non-one would give a root of unity but not any would give a primitive root of unity, which is needed in our case, because we need . In practice we can keep trying random elements until is a primitive. See code in the experimental implementation).
However, the above implies is a divisor of . Since is an essential constant of the setup, the assumption significantly limits possible values of and this, in turn, has consequences in performance. For example, in the BLS suite we use in this implementation, smallest divisor of after is . If we want to create commitments of vectors of size ( children plus terminal value in the node of a 257-ary verkle trie), we would still have to use .
So, we want to provide setup for calculations for arbitrary and therefore avoid assumption of .
Trusted setup
The Lagrange basis for a secret is a collection of values on the curve:
Note that also depends on . The trusted setup is a collection of public values on and which includes:
.
We assume is a scalar value on the field not known to anyone, a secret. The secret value and public values and are used to compute all the values in the trusted setup. The secret value is destroyed immediately after the generation of so that noone in the world should know it.
The trusted setup is public, i.e. it does not contain any secrets. It is computationally non-feasible neither to re-construct from the given nor to create another valid for some other .
What do we want to achieve?
We aim to commit to vectors of scalar values on the underlying field and to prove inclusion of value in a position by providing the commitment to the whole vector (polynomial) and the proof (no need for the vector itself).
The commitment to the vector is a commitment to the polynomial such that . The KZG commitment to the polynomial is . It is calculated by the prover.
The proof is a value on . It is calculated by the prover to prove the fact that vector contains at the index .
The condition is practically impossible to satisfy when . The function is calculated by verifier. It uses bilinear pairing and the following equation to check the validity of the proof: where is the generator of the group
Calculating commitment to the vector
KZG commitment to the vector is: we calculate it from the trusted setup, i.e. not knowing the secret : Note that once we have constants precalculated, the can be calulated in multiplications to scalar and additions on the curve. If the vector is sparse, i.e. with just few non-zero elements, the number of operations on curve is equal to the number of non-zero values.
Setting a new value at some position in the vector does not require complete re-calculation of , two operations on the curve is enough to update . Let's say the old value is replaced with the new value . The commitment to the updated vector can be calculated as .
Calculating the proof
How do we calulate the proof that value is in the position of the vector?
The simple but naive and wrong approach can be found below in the Annex. Calculating the proof. Naive approach (wrong).
To calculate correctly we have to perform true division of polynomials. The function is a polynomial because is a factor of . The latter is a polynomial which has root by the very construction of .
The KZG proof of is .
Just like we calculate in Lagrange basis: we aim to calculate in Lagrange basis too:
So, we only need to calculate the for each but how? The problem is, in the direct calculation it leads to zero denominator, even if we know it has value there because is a polynomial.
To calculate , we follow formulas in the article mentioned above, the chapter Dividing when one of the points is zero. We adjust formulas to our use of and to be more clear for our implementation.
Calculating with
Almost there. Now we only have to figure out how to calculate .
Calculating
We can rewrite formulas for the Lagrange polynomial: Note that the formulas above are defined for any . Let's assume in the above: The following pre-calculated values would improve performace:
Final formulas to calculate KZG proof
Note that we assume trusted setup is completely in Lagrange basis: where
Precalculation of allows significantly speed up calculation of when is sparse.
Precalculation of could take a lot, , of memory, so probably not worth it when is large. Pre-calculation of would be enough.
Some observations
1. The formulas above are valid for arbitrary , i.e. not constrained by the condition . We chose to (pre)calculate values instead
2. Funny enough, it is not clear how, using the trusted setup, we could even calculate a fake proof which would state (wrongly) for arbitrary .
3. We can provide proof of the absense of a key in the verkle tree. For this we just need to provide proof of i.e. .
4. Since are all non-zero, calculation of requires operations on the curve. So, calculating the proof is an expensive operation and it does not look like it is possible to optimize it.
5. It turns out, we can update any trusted setup with the additional secret by multiplying its public values without knowing the underlying secret. This property can be used to increase security of the trusted setup the following way:
let's say we have unrelated parties
party generates trusted setup for its secret , destroys it and passes to the party .
And so on: party receives trusted setup from the previous party, generates it own secret , multiplies previous trusted setup to get the next: and destroys the secret .
the last trusted setup is secure if any one of parties were honest, i.e. it destroyed and forgot its secret.
Using other domain than
Since we do not use the property of being a root of unity on the field, i.e. , the domain where Lagrange polynomials are calculated can be almost any collection of different values on the field.
For example, in the above we could replace with , i.e we'd be using on the field as points to calculate the Lagrange basis. The pre-calculated values would become simpler and (pre) calculations faster:
Annex. Calculating the proof. Naive approach (wrong)
The proof that vector (the committed polynomial) has value in the i-th position is calculated the following way: is a point on , just like . How do we calculate it? Let's expand the formula.
So, we only need to pracalculate values and and make it a part of the trusted setup, after that we can calculate for any .Right? No!
As it was pointed out by Dankrad Feist in private email, after exposing value in public we make fakeable:
for any .
The above means pairing equation is always satisfied for any value we want. It does not make any sense, so, the approach is wrong.