Explanation of SNARKs. Homomorphic hiding and blind computation of polynomials (translation)
Hi, Habr! I present to your attention the translation of ZCash blog articles, which describe the mechanism of the evidence system with zero disclosure of SNARKs used in the ZCash cryptocurrency (and not only).
My previous translations are from this area. I advise you first to familiarize yourself with them in order to better understand what will be discussed:
In this part, we consider the homomorphic concealment and blind computation of polynomials. Go…
Homomorphic Hiding
The designs of zk-SNARKs include a harmonious combination of several components. To fully understand how these components work together, it will take plenty of time. ')
If I had to choose only one component, the role of which is most noticeable, then I would single out the Homomorphic Hiding (HH). In this part of the article we will explain what a HS is, and then we will give an example of why it is useful and analyze how it works.
Homomorphic concealment is not a term formally used in cryptography, and is introduced here for didactic purposes. By properties, it is similar, but weaker, than the well-known concept of a “ commitment scheme ”. The difference is that the CG is a function that defines the argument, while the obligation uses additional randomness. As a result, homomorphic concealments essentially “hide most of x”, while commitments “hide every x”.
HS the numbers x is a function that satisfies the following properties:
For most x, with a known value finding x is a difficult task.
Different argument values result in different function values. Therefore, if then
If anyone knows and , then it can generate the HS from arithmetic operations for x and y . For example, it can calculate knowing and .
A simple example of why a TOS is useful for evidence with zero disclosure: suppose Alice wants to prove to Bob that she knows the numbers x, y such that (Of course, it is not particularly interesting to know such x and y , but this is a good example for explaining the concept).
Alice sends and Bob.
Bob calculates from these values (he can do this because is gs).
Bob also calculates and now checks whether . He accepts Alice’s evidence only if equality is fulfilled.
Because different argument values correspond to different concealments (function values . Note translator), Bob really only accepts the proof if Alice sent the hide for such that . Bob, on the other hand, doesn't get the value. , because he has access only to their hide.
Yet Bob received some information about and . For example, he may choose random and check whether the equality holds by calculation . For this reason, the above protocol is not really a Zero-Knowledge protocol, and is used here only to clarify the schema. In fact, as we will see later, the TOS is ultimately used in SNARKs to mask the verifier’s requests, and not the proving secrets.
Now let's look at an example of how such hiding is arranged. In fact, we cannot build them for regular integers with regular additions, instead we need to consider finite groups :
Let n be some integer. When spelled for integer A , it means taking the remainder of dividing A by n . For example, and . You can also use to define the addition operation on the set {0, ..., n - 1} . First, the usual addition is performed, but then to the result to get the number included in the set {0, ..., n - 1} . Sometimes is written to the right of the expression, specifying that this type of addition is used. For example, . We will call the set of elements {0, ..., n - 1} together with the operation of addition the group .
For the prime number p , you can use , to define the multiplication operation on the set {1, ..., p - 1} , so that the result of the multiplication also always belongs to the set {1, ..., p - 1} . This is achieved by simply multiplying the integers, and then applying to the result . For example, .
When p is not simple, it is problematic to determine the multiplication in this way. One of the problems is that the multiplication result can be zero, even if both arguments are not zero. For example, when p = 4 , we can get .
A set of elements along with this operation is called a group . This group has the following useful properties:
This is a cyclic group. This means that there is some element g in called a generator such that all the elements can be written as for some a from the set {0, ..., p - 2} , where
Discrete logarithm should be hard to accomplish for . This means that when p is large enough, and the element h of , it is difficult to find an integer a from the set {0, ..., p - 2} , such that
Since the degrees are added when multiplying elements with the same base, we obtain for a, b from the set {0, ..., p - 2} :
Using these properties, we now construct a homomorphic hiding that “supports addition”, which means that it is possible to calculate knowing and . Suppose the argument x is for belongs to a group therefore it is in the range {0, ..., p - 2} . Define for each such x , and prove that is HS: it follows from the first property that it is different of will correspond to different values of the function. From the second property it follows that for hard to find x ; Finally, using the third property, for given and we can calculate as .
Blind calculation of polynomials
Now let's remember what the concept of a polynomial is, introduce the concept of “blind computation” of a polynomial and how it is implemented with the help of homomorphic concealment (HS). In the following, we will see that “blind computation” is the central tool in SNARK constructions.
Denote by field size p , i.e. elements belong to the set {0, ..., p - 1} , where addition and multiplication operations are performed with as explained above.
Polynomials and linear combinations
Recall that a polynomial P of order d on the field is an expression of the form:
for some ,
We can calculate the P point value substituting s as X , and calculating the resulting sum:
For who knows what meaning is a linear combination of values where a linear combination is a “weighted sum”, in the case of "Weights" are
Above, we have defined a TOS from as where g is a generator of a group with a heavy discrete logarithm problem. We mentioned that this GS "supports addition" in the sense that can be calculated knowing and . Note also that it "supports linear combinations." This means that for given we can calculate This can easily be shown:
Blind calculation of polynomials
Suppose Alice has a polynomial P of order d , and Bob has the value which he chose randomly. Bob wants to know i.e. value of HS P at s . There are two easy ways to do this:
Alice sends P to Bob, and he calculates myself.
Bob sends s to Alice and she calculates and sends it to bob.
However, in the case of a blind calculation, we want Bob to know without receiving - which excludes the first option. And most importantly, we do not want Alice to know s , which excludes the second option.
The main reason we don’t want to send Bob, simply is that he is great - he contains elements, where d ~ 2000000 in the current Zcash protocol. In essence, this is due to the “limited” part of SNARK.
Using the GE, we can perform a blind calculation as follows:
Bob sends Alice to hide
Alice calculates of items sent in the first stage and sends Bob. (Alice can do this because supports linear combinations, and is a linear combination )
Of course, it’s true that the sequence of hiding that Bob sends to Alice is as long as the polynomial itself, but it turns out that this sequence can be “hard coded” in the system parameters, and Alice’s messages will differ for each SNARK evidence
Note that only the hide were sent, and Alice did not recognize s , and Bob did not recognize P.
In fact, the hide property guarantees only that s cannot be obtained, given the knowledge . At the same time, we also need that s cannot be obtained, knowing the sequence , which potentially contains much more information about s . The solution to this problem follows from the D-order Diffie – Hellman solution, which is used in several SNARK security proofs. (complexity of discrete logarithm. Approx. translator)
Why is this useful?
The following sections will take a closer look at how blind computations are used in SNARK. If we talk about, then the verifier has an idea of the "correct" polynomial and wants to check what the prover knows. When a proving performs blind computations at a random point not known to them both, it ensures that the proving will give the wrong answer with a high probability if their polynomial is incorrect. This, in turn, is based on the Schwarz-Zippel lemma that “different polynomials are different at most points”.