PLONK

In this note we describe PLONK, a recent zero-knowledge proof system. The goal is to walk through the scheme step by step and explain the cryptographic primitives at play.

Arithmetization

The arithmetization a program consists in expressing a program as a sequence of constraint which have a simple mathematic form. There are lots of ways to do this, but in this post we will look at a variation of Rank 1 Constraint System (R1CS).

Namely, the

ith constraint binds variables
(wi)
by relations of this form:

(qL)iwia+(qR)iwib+(qM)iwiawib+di=(qc)iwic

Any instance of NP-complete problem can be represented as a system of constraints of this sort. For instance the function

f(x):xx3 can be expressed as:

x×x=w0w0×x=y

w0 is called an intermediate variable, because it's neither part of the input set {
x
} nor the output set {
y
}.

This constraint system has an intuitive matrice representation. We note

qL,qR,qM,d the vectors
(qL)i,(qR)i,(qM)i,(di)
and
w
the vector
(wi)
.

There are pseudo permutation matrices

A,B,C (meaning that
A,B,C
have exactly one non zero entry per row, equal to
1
), such that the arithmetization can be expressed as
qL(Aw)+qR(Bw)+qM(AwBw)+d=qc(Cw)
where
denotes the entrywise product.

Our function

f(x):xx3 can be represented using
3
variables
x,w0,y
and
3
matrices, in the following way:
(100100)(xw0y)(100010)(xw0y)=(010001)(xw0y)

Here

qL=qR=d=0,qM=qc=(1,1)t, and

A=(100100),
B=(100010)
,
C=(010001)

The number of lines in the matrices

A,B,C, equal to the size of
qM,qc,qL,qR,d
, correspond to the number of constraints.

If

y was a public input, the role of a "prover" would be to find
x
such that
x3=y
, that is find
x,w0
such that the equality above holds.

If one replaces

f by a more complicated function, like SHA-
256
, one would have a lot more variables
wi
and the R1CS would be much more complicated. Solving the corresponding constraint system would boil down to finding
x
such that SHA-
256(x)=y
: it's the job that the prover has to do, and it's supposedly impossible to do unless the prover actually knows
x
.

For the next sections,

p is a big prime number, we place ourselves in a finite field
Fp
of high characteristic
p
, and the variables
(wi)
, the matrices
(aij),(bij),(cij)
all live in
Fp
.

The cryptographic toolbox

We describe fundamental tools that are used in most flavors of snarks, especially for the succintness part.

Schwartz Zippel lemma

The first tool is the Schwartz-Zippel lemma:

Take a non zero polynomial

Q of degree
d
<<
p
in
Fp[X1,,Xn]
. If one picks randomly
τFpn
, then
Q(τ)
, is almost surely not zero.

In practice, with the parameters chosen for crypto, you can translate "almost surely" by "surely". The probability that

Q is not
0
is actually at most
d/p
, and for cryptographic purposes
p
is typically a
256
bits number, while
d
ranges at most in the billion (about
30
bits number).

To justify this lemma, we proceed by induction on

n, the number of variables. For
n=1
, we know that on
Fp[X]
, a non zero polynomial
P
of degree
d
has at most
d
zeros, so sampling
τ
in the set of zeros of
P
happens with a probability of at most
d/p
. Now for
n>1
, write
P
, a non zero
n
-variate polynomial, as
P=idPi(X1,,Xn1)Xni
, with
Pi
of degree at most
di
. Let
i0
the largest
i
such that
Pi0
. Let
(τ1,,τn1,μ)=(τ,μ)Fpn
be a random element. Either
Pi(τ)=0
for all
i
, which by induction happens with probability
dp×d1p××di0pdi0p
and then
P(τ,μ)=0
no matter
μ
, or there is a
i
such that
Pi(τ)0
, which happens with a probability bounded by
1
, and
P=idPi(τ)Xni
is a univariate polynomial of degree at most
i0
, so by the case
n=1
the probability that
P(μ)=0
is less than
i0p
. Averaging the
2
cases using our bounds, we have that the probability that
P(τ,μ)=0
is less than
(di0p)×1+1×i0p=dp
.

For the various flavors of snarks that we will describe, the converse of the Schwartz-Zippel is equally useful:

Let

QFp[X1,,Xn] be a polynomial of degree
d
. If one picks randomly
τFpn
and
Q(τ)=0
,
Q
is almost surely the zero polynomial.

Chosing

τ at random is crucial here, otherwise one just has to pick a root (if it exists) of
Q
to obtain
Q(τ)=0
.

Low degree extension (LDE)

The second is known as Low Degree Extension (or LDE) of a vector. In fact, this is just an interpolation of a vector: if one has a vector

uFpn with
n<<p
, and a set
SFp
with
|S|=n
, the LDE of
u
, which we name
u~
, is the interpolation of
u
on
S
. Concretely it means that
u~
is a polynomial of degree
n1
, and with a correct indexing of the elements
si
of
S
, one has
ui=u~(si)
.

Kate commitment

The Kate commitment scheme is a polynomial commitment scheme, meaning that it allows one to create a digest out of a polynomial that is binding to the polynomial and hiding.

We describe shortly how it works. Let

(G,+) be a group of
p
elements in which the discret log is hard, and suppose that a trusted setup have been performed so that a sequence
(g,γg,,γn1g)
, with
n<p
, is publicly available, but nobody knows
γ
.

Given a degre

n1 polynomial
P=in1aiXiFp[X]
, where
n<<p
, the Kate commitment of
P
is the element
KP=iaiγigG
.

Binding property Note that

KP=P(γ)g. To find a collision, either one has to solve the discrete log to find the value of
P(γ)
, which is supposedly hard, or one has to pick a polynomial
Q
such that
Q(γ)=P(γ)
. But since
γ
is unknown, the Schwartz Zippel lemma tells us that this happens with probability less than
np
.
Hiding porperty It stems from the fact that
γ
is unknown.

Note that

KP+KQ=KP+Q.

In what follows, the group

G needs an extra feature, called a pairing, which is a non degenerate bilinear application
e:G×GGT
, where
(GT,×)
is another group (the
T
stands for target, as
GT
is often called the target group). It allows to "multiply"
2
elements in
G
(but only
2
).

This feature allows a prover to open a commitment at a given value of the choice of a verifier:

  • Prover computes
    H=PP(α)Xα
    , which is in
    Fp[X]
    , and gives
    KH
    and the claimed value
    P(α)
    to the verifier
  • The verifier checks that
    e(KH,αgγg)=e(KPP(α)g,g)
    (remember that
    g,γg
    are public outputs from the trusted setup).

Completeness: it stems from the bilienarity and non degeneracy of the pairing.
Soundness: Since

γ is unknown under the hardness of discrete log property, if the claimed evaluation is wrong, call it
w
, the prover has to send a random
K(H)=rg
, such that by luck
γ
is a root of
PwXαr
. The degree of
H
is at most
n1
due to the trusted setup. The overall expression is at most of degree
n
, so according to the Schwartz Zippel lemma the probability of that
γ
is a root of it is at most
n/p
.

There is a way to batch reveal values of different commitments

K1,,Kn at a single point
z
using a round of interaction with a verifier:

Let

KP1,,KPn a list of Kate commitments to
P1,,Pn
. To query the values of these polynomial at
zFp
:

  • the prover sends the supposed evaluations
    (si)i[n]
    of
    (Pi)i[n]
    to the verifier
  • the verifier sends a random challenge
    vFp
    to the prover
  • the prover computes the proof
    KH
    , where
    H=i[n]viPi/(Xz)
    and sends it to the verifier
  • the verifier computes
    s=i[n]visi
    and checks if
    e(KH,KXz)=e(i[n]vi(KPiKsi),g)

    If the last check holds, the claimed values are, with very high probability, corrects.

Since the commitments

(KPi) are given prior to the challenge
v
, it's exactly the same argument as above.

Finally, we describe how to open different commitments at different points.

Let

(KPi)i[n] be a set of commitments and
(z1,,zn)
a set of points in
Fp
. To open the commitments on the
zi
:

  • a prover sends the individual proofs
    (KHi)i[n]
    as well as the evaluations
    (si)i[n]
  • a verifier choses random numbers
    (ri)i[n]
    , and computes
    K=i[n]riKHi
    and checks that
    e(K,Ki[n]ri(Xzi))=e(i[n]ri(KPiKri),K1)

Note: this method is fine as long as there are not too many points, because computing

K is expensive (usually
G
is a subgroup of the
Fp
rational points of an elliptic curve over
Fp
, and computing
K
requires a multi exponentiation on this group).

PLONK

We have a constraint system such that the

i-th constraint looks like this:
(qL)iwia+(qR)iwib+(qM)iwiawib+di=(qc)iwic

and the whole system has the matrix representation
qL(Aw)+qR(Bw)+d+qM(AwBw)=qc(Cw)

where

A,B,C are pseudo permutation matrices.

The goal of PLONK is to get rid of

A,B,C by encoding the corresponding permutations using polynomials, so they can be commited using the Kate commitment scheme. A circuit is represented by
qLa+qRb+d+qM(ab)=qcc

with the condition that
a,b,c
are permutations of set
(wi)i
.

Example: Imagine a program computing

w05 where
w0
is a given input. The arithmetization of this circuit consists of the following set of constraints:
w0×w0=w1w1×w0=w2w2×w2=w3w3×w0=w4

The result is
w4
. With matrices, we have (we omit
qM
and
qc
, containing only
1
):
(10000010000010000010)(w0w1w2w3w4)(10000100000010010000)(w0w1w2w3w4)=(01000001000001000001)(w0w1w2w3w4)

Notice that there is exactly

1 non zero entry in each line of the matrices.

To take the PLONK version of this, we get rid of the matrices

A,B,C by applying the matrix multiplications, corresponding to permutations, and we end up with:
(1111)(w0w1w2w3)(w0w0w2w0)=(1111)(w1w2w3w4)

Here
qM=qc=(1,1,1,1)t
.

The general PLONK representation is therefore

qMab=qcca=(w0,w1,w2,w3)b=(w0,w0,w2,w0)c=(w1,w2,w3,w4)

We need a compact way to encode that

a,b,c are of this form, so a prover can convince the verifier of this.

If we concatenate

a,b,c in that order, we obtain a vector
d
of size
12
, and we observe that
d
is invariant under certain permutations of
12
elements. In fact,
d=a||b||c
should look like this:
(w0,w1,w2,w3,w0,w0,w2,w0,w1,w2,w3,w4)
. The first, fourth, fifth, eighth entries are the same, equal to
w0
, so for instance d is invariant when the cycle
15681
acts on the entries. Identifying all the cycles that leave
d
invariant (those cycles shift the entries of the duplicated variable, like
w0
in the example), we end up with a permutation
σ
which completely characterize a circuit-compliant solution.

To prove the knowledge of a solution

a,b,c to the system, he needs to:

  • claim 1: prove that
    qLa+qRb+qMab+d=qcc
  • claim 2: prove that
    a||b||c
    is invariant under the action of
    σ
    .

In what follows, we drop

qL,qR and
d
to simplify the notations. So claim 1 becomes
qab=oc

Without this shortcut the notations are overloaded and it's harder to read, and it changes nothing to the explanations.

claim 1

To prove the first claim, prover and verifier agree on a set

SFp of size
n
, and the prover computes the LDE
a~,b~,c~
of
a,b,c
on
S
.

If

IS=Πi[n](Xsi)Fp[X], we have
qab=ocq~a~b~o~c~=hIS

where
h=(q~a~b~o~c~)/IS
.

The general strategy to prove that an algebraic relation

A(P1,,Pl) between polynomials
(Pi)i[l]
holds is:

  • Verifier asks the prover the commitments
    (KPi)i[l]
  • Verifier choses
    ζ
    at random, and queries the values
    (Pi(ζ))
    for all but one polynomial (say
    P1
    )
  • Verifier computes
    P1(ζ)
    by finding
    x
    such that
    A(x,P2(ζ),,Pl(ζ))
    holds
  • Verifier asks a proof for the opening of all
    (Pi)i[l]
    at
    ζ
  • Verifier cheks that the proof is correct, and that
    x=P1(ζ)

To how this works, since the commitments

(KPi)i[l] are sent prior evaluating them at
ζ
, the Schwartz Zippel lemma tells us that the chances that
P1
opens correctly at
x
such that
A(x,P2(ζ),,Pl(ζ))
are negligible if
A(P1,,Pl)
does not hold.

In what we need to prove,

A(a~,b~,c~,q~,o~,h,IS):q~a~b~o~c~=hIS
The role of
P1
in the example is played by
h
.

So the procedure is the following, where

q~,o~,IS are public:

  • The prover sends
    Ka~,Kb~,Kc~,Kh
    to the verifier
  • Verifier queries
    a~(ζ),b~(ζ),c~(ζ)
    (but not
    h(ζ)
    ) at a random challenge
    ζ
  • Verifier computes
    h=q~(ζ)a~(ζ)b~(ζ)o~(ζ)c~(ζ)/IS(ζ)
  • verify checks a batch opening proof of
    Ka~+vKb~+v2Kc~+v3Kh
    at
    ζ
    to check that it opens correctly to
    a~(ζ)+vb~(ζ)+v2c~(ζ)+v3h

We mention that there are ways to modify this protocol to use commitments of the public data

Kq~,Ko~ instead of directly using
q~,o~
for memory bounded verifiers.

claim 2

The goal is to prove that

σ.d=d where
d=a||b||c
, by characterizing it in term of divisibility by
IS
, so a similar strategy as in the first claim can be used.

The solution stems from the following property:

Let

d a vector in
Fpn
, where
n<<p
, let
SFp{0}
be a set of
n
distincts elements
s1,,sn
and
σ
a permutation of
n
elements. We have the following equivalence:
σ.d=dΠi[n](di+siX+Y)=Πi[n](di+sσ(i)X+Y)

where the left hand side is in
Fp[X,Y]
.

() is obvious.
()
Since
Fp[X,Y]
is a unique factorization domain, meaning there is a unique way of decomposing polynomials in irreducible components, and the
di+siX+Y
are irreducible components, for each
i
there is a
j
such that
di+siX+Y=dj+sσ(j)X+Y
and therefore (with the same argument) that
di=dj
and
σ(j)=i
.

Now we assume that

X,Y are replaced by random challenges
β
and
γ
, chosen by the verifier. The Schwart Zippel lemma ensures that there is no loss of information.

To apply this property to

d=a||b||c, we would like to have the LDE of
a||b||c
, but the problems are that

  • this vector is of size
    3n
    , and computing its LDE of
    d
    would require a set
    S
    of interpolation of size
    3n
  • we don't reuse the LDE
    a~,b~,c~
    of
    a,b,c
    on
    S={s1,,sn}
    that the prover aleady computed.

Encoding the permutation

σ:

One thing not avoidable is to extend the set

S={s1,,sn}Fp so that it becomes a set of
3n
elements for encoding the permutation.

To extend

S, pick
k1FpS
and add the set
S1=k1S
, then pick
k2Fp(SS1)
and build the set
k2S
. Those
3
sets are disjoints (it stems from the fact that
(F,×)
is a group).

Now that the set

S is extended to
S=SS1S2
, we interpret
σ
as a permutation of
S
, and we can rewrite the products in the property by grouping the entries of
a,b,c
:

σ.d=dΠi[n](a~(si)+siβ+γ)(b~(si)+k1siβ+γ)(c~(si)+k2siX+γ)=Πi[n](a~(si)+σ(si)β+γ)(b~(si)+σ(kisi)β+γ)(c~(si)+σ(k2s2)β+γ)

This grouping allows to compute the LDE of

σ, and
Id
on
S
only
, and not on something
3
times bigger. Namely

  • Id
    is encoded as
    Id1=X,Id2=k1X=k1Id1,Id3=k2X=k2Id1
  • σ
    is encoded
    (σ1,σ2,σ3)
    where
    σ1
    is the LDE of
    (σ(si))i[n]
    ,
    σ2
    the LDE of
    (σ(k1si)i[n]
    , and
    σ3
    the LDE of
    (σ(k2si)i[n]

Now we can write the previous equivalence in this way:

σ.d=dΠi[n](a~(si)+Id1(si)β+γ)(b~(si)+Id2(si)β+γ)(c~(si)+Id3(si)β+γ)=Πi[n](a~(si)+σ1(si)β+γ)(b~(si)+σ2(si)β+γ)(c~(si)+σ3(si)β+γ)

Everything is in polynomial form, and the polynomials involved are LDE on

S, so it is a huge step forward.

From now on we require that the domain of interpolation

S is a multiplicative subgroup of
Fp
, in particular it's a cyclic subgroup generated by
μ
of size
n
, its elements are (in that order)
{s1,s2,,sn}={1,μ,,μn1}
.

We also set the following notations:

  • Call
    f=(a~+Id1β+γ)(b~+Id2β+γ)(c~+Id3β+γ)
  • Call
    g=(a~+σ1β+γ)(b~+σ2β+γ)(c~+σ3β+γ)
  • Call
    fi=f(si)
    and
    gi=g(si)
    .

The key idea to encode the permutation using polynomials is to take the LDE

Z of the vector
(1,f1g1,f1f2g1g2,,f1fn1g1gn1)

, so
Z(si)=1
is
i=1
, otherwise
Z(si)=f1fi1g1gi1
for
1<in
.
The term
(f1fn)/(g1gn)
is not taken.

Observe that

Z(si+1)=Z(si)figi for
i
from
1
to
n1
. Since
si+1=μ×si
, we almost have a relation on all
S
which is
Z(μX)=Z(X)f(X)/g(X)
. The only possibilty of failure if when
i=n
.

In fact, on

X=sn, since
S
is a cyclic group, we have
μsn=μn=1
. On the other hand,
Z(sn)fngn=(f1fn1g1gn1)fngn
should be
1
if (and only if up to a to a negligible soudness error)
σ.d=d
.

So the relation

Z(μX)=Z(X)f(X)/g(X) and
Z(s0)=1
is true on all
S
iff
σ.d=d
.

Since

Z(s0)=1 is characterized by
Ls0(X)(Z(X)1)=0
on
S
, where
Ls0
is the LDE of
(1,0,,0)
, we have

σ.d=dZ(μX)g(X)Z(X)f(X)=h1(X)IS(X) and
Ls0(X)Z(X)=h2(X)IS(X)

We finally have a characterization of

σ.d=d in term of divisibility by
IS
involving
a~,b~,c~
(since
Z
depends on those).

Since the permutations describe the circuit, there are part of the public data, and we suppose that

(Kσi)i=1,2,3 are precomputed. Note that
(KIdi)i=1,2,3
are directly available since
Id1=X
,
Id2=k1Id1
,
Id3=k2Id1
.

The

2 divisibility claims can be collapsed into one if the verifier checks that a random linear combination
Z(μX)g(X)Z(X)f(X)+αLs0(X)(Z(X)1)
is divisible by
IS
, call the quotient
h
.

We apply exactly the same strategy as in claim 1, where

A(a~,b~,c~,σ1,σ2,σ3,Z,h,IS,Ls0):Z(μX)g(X)Z(X)f(X)+αLs0(X)(Z(X)1)=h(X)IS(X)
and the role of
P1
is played by
h
.

Here is a description of the proof of claim 2, where

σ1,σ2,σ3,Ls0,IS are public:

claim 2:

  • Prover sends
    Ka~,Kb~,Kc~
  • Verifier sends challenges
    β,γ
    (used to compute
    Z
    )
  • Prover sends
    KZ
    (computed with
    β,γ
    )
  • Verifier sends a random
    α
    to the prover (used to collapse the
    2
    divisibility claims)
  • Prover computes
    h
    and sends
    Kh
    to the verifier
  • Verifier queries
    a~(ζ),b~(ζ),c~(ζ),Z(ζ),Z(μζ)
    at a random
    ζ
  • Verifier computes
    σ1(ζ),σ2(ζ),σ3(ζ),IS(ζ),Ls0(ζ)
  • verifier computes
    h=(Z(μζ)g(ζ)Z(ζ)f(ζ)+αLs0(ζ)(Z(ζ)1))/IS(ζ)
  • The verifier sends a random challenge
    v
    to the prover
  • The prover sends a proof for the batch opening of
    K=Ka~+vkb~+v2Kc~+v3KZ+v4Kh
    at
    ζ
    and for the opening of
    KZ
    at
    μζ
  • The verifier choses a random
    u
    and verifies the opening of
    K+uKZ
    (using the Kate reveal at different points).

Note that claim 1 and claim 2 can be collapsed into

1 claim. Namely, the
α
used to check that
Z(μX)g(X)Z(X)f(X)+αLs0(X)(Z(X)1)
is divisible by
IS
can be reused to incorporate the first claim, so the final protocol checks that
Z(μX)g(X)Z(X)f(X)+αLs0(X)(Z(X)1)+α2(q~a~b~o~c~)

is divisible by
IS
.

There are ways to customize this protocol to use commitments of the public data

(σi) instead of their raw values, for memory bounded verifiers.

Conclusion

There are a lot of small variations to PLONK. Since PLONK relies on general polynomial commitment schemes (here only the Kate commitment scheme was presented), it is quite flexible and can be used for proof carrying data constructions such as Halo.


Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
Author: Thomas Piellard.

I'm part of a research team at ConsenSys. If you are interested in our work (fast finite field arithmetic, elliptic curve pairings, and zero-knowledge proofs), give us a shout.