PLONK at its technical heart is based on the following primitive - The grand product check: given commitments to polynomials over a finite field , and a subset check that the product of values of and over agree. That is, whether where and . The PLONK paper shows this check can be performed with great efficiency when is a multiplicative subgroup.
Polynomials and Vectors
Throughout this post, whenever we discuss a vector of length , we assume in the actual protocol the prover has sent a commitment to a polynomial with as above. Thus, we can allow operations like adding vectors coordinate wise, that will be emulated in the real protocol by applying the same operation on the polynomial commitments.
Grand products to multiset checks
One reason a grand product check is useful, is that with a little randomness it translates to a more powerful primitive - the multiset equality check: Given two vectors check they contain the same elements, counting repetitions, possibly in different order.
For example, is multiset-equal to but not multiset-equal to or .
Let's see the reduction from multiset equality to grand product. The verifier simply chooses a random , and runs the grand product check on the randomly shifted vectors ( is added to all coordinates). This grand product check corresponds to
Thinking of both sides as polynomials in , the Schwarz-Zippel Lemma implies that the grand product check fails with high probability unless are mutliset-equal.
Permutations via Multiset checks
Given a permutation suppose we want to check that , in the sense that for each , . See the PLONK paper (and other SNARK papers) as to why permutation checks are central to SNARKs. To reduce this to a multiset check, look first at the vectors of pairs
Thinking about it for a minute, you can see that they are multiset-equal if and only if . But we wish to reduce to a mutliset check on vectors of elements, rather than vectors of pairs. For this we choose random , and define vectors by
If the above vectors of pairs are not multiset equal, then with high probability and aren't either. Thus, it suffices to do the multiset check between and .
Table lookups via Multiset checks
The XOR example
Another very useful operation for zk-SNARKs is the table lookup operation. For example, suppose we had three vectors of field elements ; and we want to check that for each , correspond to -bit strings, and where is a bitwise XOR. A traditional SNARK approach would require many arithmetic constraints for each tuple to decompose the inputs into bits and perform the bitwise XORs.
Lookup tables are an alternative approach to operations requiring many constraints. We start by precomputting the truth table corresponding to the XOR operation. So consists of three vectors/columns of length such that the rows of , , go over all legal input/output combinations for 8-bit XOR.
Remark:In the SNARK context, typically correspond to witness polynomials for which only for some 's we wish to check a XOR relation; combining different tables and gates can be achieved with "selectors", see e.g. Section 4.1 of the plookup paper.
Reducing tuples to single elements
We thus wish to show that each tuple is equal to some row of . The first thing we do is use randomness to reduce checking tuples to checking single elements: We choose a random and look at the vector with for each . We similarly create a randomly compressed version of the table with . The Schwarz-Zippel Lemma can show that if some tuple was not in , then with very high probability is not an element of .
The plookup protocol - sort and compare differences
So it now suffices to check that every element of is an element of . Let's denote this by . The plookup protocol reduces this to one multiset equality check. The protocol is based on the following observation: Suppose we have sorted versions of two vectors, and further know they start at the same element. Then, they contain the same distinct elements if and only if they contain the same sequence of non-zero differences between adjacent elements.
Let's describe this on a concrete example: . The prover will create an additional vector - which is a "sorted by " version of the concatenation of and . Sorted by means elements appear in in the same order they appear in . In our example, we have .
Now the point is to look at the difference vectors of and ; i.e. the vectors consisting of the differences of adjacent elements. We have .
Note that when , contains exactly the same non-zero elements as . Let us denote by the vector concatenated with zeroes. At this point, let's first describe a simpler reduction using two multiset checks:
Between and .
Between and .
We claim these two checks suffice: The first check implies in particular that . Thus, after the first check it suffices to verify that .
The first check also implies that . Thus, if contained a value outside of , it would have to contain more than distinct values. But the second check implies has at most non-zeroes, and so has at most distinct values.
A more efficient version using randomness
Now, let's see the plookup reduction that uses only one multiset check. The verifier chooses random , and we define to be the "randomized difference vectors" of and . That is , and is defined analogously. We now claim that it suffices to do a single multiset check between and . To see this most easily, it will be convenient to think of our elements as formal polynomials in , rather than field elements. Using this viewpoint, the elements of are the degree one polynomials . When this cannot match with an element of which will have the same coefficient for and , and so this element must match with one from of the form . This means that whenever "changes" the new value is contained in , and so . From the other side, each polynomial must match with an element of . It can only match with an element with . So, for some , ; hence , and so .
Finally, the Schwarz-Zippel Lemma tells us that these comparisons between formal polynomials in with high probability will not differ from the comparisons of the actual elements for the random choice of .
Summary:
Describing protocols via primitives like multiset checks abstracts away many details and let's us more easily see what's going on at a high level.
References/Acknowledgements: The reduction from permutations to grand products appeared first in a paper by Bayer and Groth. We thank Tom Walton-Pocock for a review and suggestions