Explanation of SNARKs. Mating elliptic curves (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).
In this article it will be shown how using elliptic curves one can get a limited, but sufficient for our purposes, form of a HS, which supports multiplication. Further it will be shown that this limited form of the WAN is also sufficient to convert the protocol into the necessary non-interactive system.
We begin with an introduction to elliptic curves and an explanation of how they allow us to obtain the shape of the HS we need.
Elliptic curves and their pairing
Suppose p is a prime number greater than 3 and take some such that . Consider the equation:
Elliptic curve C is a set of points. that satisfy this equation. These curves give us an interesting way to build groups. The elements of the group will be points which are on the curve, i.e., they satisfy the equation together with the special point O , which is necessary for technical reasons, is sometimes referred to as the “point at infinity” and serves as an element of identity, that is, the zero of the group.
You can ask "A set of points on what?". We mean the set of points with coordinates in the algebraic closure . In addition, the curve has an affine and projective version. When we refer to the projective version, we also include the “point at infinity” O as an element of the curve.
Now the question is how to add up two points to get the third one? The addition rule is obtained from some abstract object called the divisor class group of a curve. For our purposes, all you need to know about this group of divisor classes is that it imposes the following restriction on the definition of the addition operation: the sum of the points on any line must be zero, i.e. O
Let's consider what the rule of addition follows from this restriction. Look at the vertical line defined by the equation of the form. . Suppose that this line intersects the curve at . Since the equation of the curve is , if a is on a curve then there is a point . Moreover, since this is a vertical line, and an equation of a second order curve Y , we can be sure that these are the only points where the line and the curve intersect.
So we have the equation what means In this way is the opposite to in Group.
Now let's analyze the points $ inlineP $ inline and $ inlineQ $ inline, which do not have the first coordinates, i.e. and see how to fold them. Draw a line through P and Q.
Since the curve is defined by a third-degree polynomial X and already crosses this (not vertical) line at two points, it is guaranteed to cross the line at the third point, which we denote and does not cross the line at other points.
Therefore, we obtain what means . We already know that is obtained from using the turn of the second coordinate of at .
Thus, the addition rule for our group is as follows: For the selected points P and Q , it is necessary to draw a line through them, and then take a “mirror” point for the third point of intersection of the line. This will be the result of addition.
We did not consider the case of adding P with itself. This is done using the line that is tangent to the curve at point P , and obtaining R, as the second point of intersection of this line with the curve.
This group is usually called because it consists of points on the $ inlineC $ inline curve with coordinates in . But we will designate it further as . For convenience, we assume that the number of elements in Is a prime r different from p . This applies to many solutions, for example, on a curve that Zcash uses. In this case, any element different from O generates .
The smallest integer k such that r divides called the degree of nesting curve. It is believed that if k is large enough, for example, at least 6, then the problem of discrete logarithm in i.e. finding and of is rather complicated. ( In the BN curves currently used in Zcash, ).
Multiplicative group contains a subgroup of order r which is denoted . We can see the points of the curve with coordinates in and not only in . In accordance with the same addition rule, these points also form a group together with O , which is called . notice, that obviously contains . Besides will contain an additional subgroup order r (in fact, additional subgroups of order r ).
Fix the generators . It turns out that there is an effective map called Tate reduced pairing, which translates a pair of elements from and into the element of such that
for generator ξ of
For a given pair of items performed
The definition of Tate goes a bit beyond the series of these articles and relies on concepts from algebraic geometry, more so on divisors.
In fact, Zcash pairing uses Ate optimal pairing , which is based on Tate's simplified pairing and can be calculated more efficiently than Tate .
For polynomial takes the value zero to the degree at point a , and nowhere else. For point , divisors allow us to prove that there is a function from the curve on which also takes in some exact sense a zero to the power of r for P and nowhere else. then defined as .
Here it may not be completely clear how this definition is associated with the specified properties. In fact, the proof that Tate is associated with these properties is quite complicated.
Defining $ inline $ E_1 (x): = x ⋅ g, E_2 (x): = x ⋅ h, E (x): = x ⋅ ξ $ inline $ we get a weak version of the TOS, which supports both addition and multiplication: are GEs that support addition, and knowing the hiding we can calculate . In other words, if we have the “right” hiding x and y , we can get the (other) hiding xy . But for example, if we have a hide for we won't be able to get the hide .
Let's move on to discuss non-interactive evidence systems. We begin by explaining what we mean by "non-interactive."
Non-interactive evidence in the model of a common referencing string
The strongest and most intuitive definition of non-interactive evidence is probably the following: In order to prove a specific statement, the proving party sends a single message available to all parties without any prior exchange of messages, and anyone who reads this message will be convinced that the statement is true. In most cases this may not be possible to implement.
In terms of computational complexity theory, it can be shown that only languages of the BPP complexity classes implement non-interactive proofs with zero disclosure in full. The type of statements that we need to prove in Zcash transactions, for example, “I know the original for the hash of this line,” corresponds to the complexity class NP , which, as we know, is much more than BPP .
We weaken the definition of non-interactive evidence in order to introduce the notion of a common referencing line - OSS (from the English CRS ). In the OSS model, before any evidence is constructed, there is an installation phase in which a line is created according to a certain random process and passed to all parties. This line is called OSS, and is then used to create and verify evidence. It is assumed that the random data used in the creation of the OSS, is unknown to either party, since knowledge of these data will allow to build false evidence.
Let's take a look at how, in the OSS model, you can convert a valid blind calculation protocol into a non-interactive evidence system. Since this protocol consists of several similar sub-protocols, it can be turned into a non-interactive evidence system in the same way.
Non-interactive calculation protocol
The non-interactive version of the calculation protocol initially consists in publishing Bob’s first message as OSS. Recall that the purpose of the protocol is to obtain homomorphic hiding for Alice's polynomial for randomly selected .
Installation : Selected random and published by the OSS: .
Proof . Alice calculates and using elements of the OSS, and the fact that and support linear combinations.
Check : Accepting for and , Bob computes and , and checks their equality. (If they are equal, it means that .)
As shown in the previous sections, Alice can only create such that will be checked if is a hiding for polynomial order d known to her. The main difference here is that Bob doesn't need to know to test because it can use the pairing function to calculate only from and . Consequently, he does not need to independently create and send the first message, and this message can simply be corrected in the OSS.