Try   HackMD

PLONK Arithmetization

PLONK v.s. Halo

Similarities: proofs systems, use polynomial commitment schemes, same constraint system (constraint polynomial, BG12 permutations, lookup tables, custom gates)

Differences: PLONK requires a trusted-setup, PLONK uses pairings, Halo has proof recursion (2-cycle of elliptic curve groups), PLONK uses a Kate-like PCS, Halo uses a Hyrax-like PCS

Timeline:

[Standard] PLONK (Aug-2019) - proof system via polynomial commitments using a single updateable trusted-setup. Uses pairings, a non-R1CS constraint-system, BG12 permutation proofs, and Kate-like polynomial commitments.

Halo (Sep-2019) - proof recursion via elliptic curve cycles, no pairings, no trusted setup, Hyrax-like PCS.

TurboPLONK (late-2019/early-2020) - PLONK with custom gates/constraints.

plookup (Nov-2020) - extends PLONK with lookup tables (replace expensive computations with key-value maps to lookup a computation's output on an input, currently lookup tables focus on replacing bitwise operations such as bitwise AND and XOR).

UltraPLONK (late-2020) - PLONK with custom gates and lookup tables, i.e. combines TurboPLONK and plookup (makes many algorithms that are SNARK unfriendly, more friendly). Side note: using lookup tables and custom gates allows for efficient modular arithmetic in a field smaller than the PLONK field, which could allow for recursive proofs without cycles of elliptic curves (i.e. multiple base and scalar fields). Side note #2: Pedersen hashing within UltraPLONK is roughly as efficient as Poseidon.

Halo2 (late-2020) - combines UltraPLONK, a PCS that does not require a trusted-setup, and cycles of elliptic curves for recursion.

Question: Verification time is constant in PLONK, but is not in Halo/Halo2 because Halo's proof size varies with computation size? Zcash will rely on batch transaction verification to achieve something close to succinctness.

Standard PLONK Arithmetization

Arithmetization - breaks a general computation into a sequence of steps.

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 →

Example:
ab+23==100
:
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 →

Arithmetization converts a general computation into a system of polynomials (a set of interdependent polynomials) where each is constrained to a value. A general computation's set of polynomials is its constraint system. Every polynomial is of the same form.

Standard PLONK uses the constraint polynomial:

slxl+srxr+smxlxr=soxo+c

  • sl,sr,so,sm{0,1}
    are boolean selectors
  • xl,xr,xoF
    are values used in arithmetic
  • cF
    is an optional constant used to assign constraint system values to a constant (public input)

which can encode addition, multiplication, and constant assignment.

Constraint
Addition
l+r=o
1xl+1xr+0xlxr=1xo+0
Multiplication
lr=o
0xl+0xr+1xlxr=1xo+0
Assign Constant
(Public Input)
l=5

r=5

l+r=5

lr=5
1xl+0x0+0xlxr=0xo+5

0xl+1xr+0xlxr=0xo+5

1xl+1xr+0xlxr=0x0+5

0xl+0xr+1xlxr=0xo+5
Exponentiation
(lr)r=o
(0)  0xl+0xr+1xlxr=1xo(1)  0xl+0xr+1xo(0)xr=1xo

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 →

Note: a constraint may reference a value from another constraint, e.g. exponentiation. This is enforced via a permutation argument, not using constraint.

TODO: The

sl,sr,so,sm,c values define a computation. The
xl,xr,xo
values are filled in by someone who knows how the computation proceeds (the inputs and outputs at each gate).

We can think of a computation's constraint system as a matrix:

xl
xr
xo
sl
sr
sm
so
c
xl(1)
xr(1)
xo(1)
sl(1)
xr(1)
sm(1)
so(1)
c(1)
xl(n)
xr(n)
xo(n)
sl(n)
xr(n)
sm(n)
so(n)
c(n)

where the prover fills in the columns

xl,
xr
, and
xo
with values (the witnesses) such that every constraint is satisfied.


Example:

ab+23==100 (cont.)

The

s's and equality constraints define a computation, the
c
's give an instance of the computation; the prover fills in
x
values to show that they know how a computation proceeds.

xl
xr
xo
sl
sr
sm
so
c
ab=c
xl(1)
xr(1)
xo(1)
0
0
1
1
0
d=23
xl(2)
xr(2)
xo(2)
1
0
0
0
23
c+d=e
xl(3)
xr(3)
xo(3)
1
1
0
1
0
f=100
xl(4)
xr(4)
xo(4)
1
0
0
0
100

Equality Constraints:xo(1)=xl(3)xl(1)=xr(3)xo(3)=xo(4)

Compressing Constraint Checks

We would like to replace

n constraint checks (i.e.
i[n]
is the
ith
constraint satisfied?) with a single check of some form. We do this by transforming the constraint system into a polynomial expression that is true if and only if the constraint system is satisfied.

Lagrange Interpolation

Lagrange interpolation converts a function's evaluation form

{(x1,y1),,(xn,yn)} into a passing through each point.

Lagrange interpolation is used to represent each column as a polynomial:

xl(X),xr(X),xo(X),sl(X),sr(X),sm(X),so(X),c(X), where each column's polynomial on the
ith
input outputs the column's value in row
i
.

We associate each matrix row

i[n] with a unique value
ωi
where the set of values associated with all rows is
H={ω1,,ωn}
. Zipping this set of inputs with a column
zip(H,column)={(ω1,a1),,(ωn,an)}
gives the evaluation form for a polynomial that outputs the
ith
column value on row
i
's input
ωi
. Performing Lagrange interpolation on each column's evaluation form produces the polynomial that maps each row's input
ωi
to the value in the column at that row
ai
. For example, to interpolate column
xl
as
xl(X)
we use the evaluation form
{(ω1,xl(1)),,(ωn,xl(1))}
.

H
xl
xr
xo
sl
sr
sm
so
c
ω1
xl(1)
xr(1)
xo(1)
sl(1)
xr(1)
sm(1)
so(1)
c(1)
ωn
xl(n)
xr(n)
xo(n)
sl(n)
xr(n)
sm(n)
so(n)
c(n)

Rewriting Constraint Checks as a Polynomial Expression

Given the set of interpolating polynomials, we use the constraint equation to write an expression that holds for every input

ωiH:
sl(ωi)xl(ωi)+sl(ωi)xl(ωi)+sm(ωi)xl(ωi)xr(ωi)=so(ωi)xo(ωi)+c(ωi)
moving the right hand side to the left, we rewrite the above as:
sl(ωi)xl(ωi)+sl(ωi)xl(ωi)+sm(ωi)xl(ωi)xr(ωi)so(ωi)xo(ωi)c(ωi)=0.
We can write the left hand side of the above equation as a polynomial:
sl(X)xl(X)+sl(X)xl(X)+sm(X)xl(X)xr(X)so(X)xo(X)c(X)
which that outputs
0
on every input
ωi
, i.e. has roots
ω1,,ωn
. We know some of the polynomial's roots, therefore we know part of its linear factorization contains the degree-1 terms
(Xω1)(Xωn)
:
sl(X)xl(X)+sl(X)xl(X)+sm(X)xl(X)xr(X)so(X)xo(X)c(X)=(Xω1)(Xωn)h(X).
We call
(Xω1)(Xωn)
the vanishing polynomial
V(X)
which outputs
0
on every input
ωi
:
V(X)=i[n](Xωi)
which in a cyclic multiplicative group of order
n
simplifies to:
V(X)=Xn1 V(ωi)=(ωi)n1=ωin mod n1=ω01=11=0
and
h(X)
its cofactor polynomial. Thus, we can write the constraint system polynomial as as equality:
sl(X)xl(X)+sl(X)xl(X)+sm(X)xl(X)xr(X)so(X)xo(X)c(X)=V(X)h(X).

The constraint system is satisfied if its polynomial representation

sl(X)xl(X)+c(X) is divisible by
V(X)
without remainder.
V(X)|sl(X)xl(X)+sl(X)xl(X)+sm(X)xl(X)xr(X)so(X)xo(X)c(X)
Thus we can perform
n
constraint checks using a single polynomial division check.

Permutation Notation

A permutation

σ that shuffles an array of
n
elements
σ((a1,,an))=(b1,,bn)
can be written:
σ=(σ1,,σn)
where
σ1=2
means that
a2b1
.
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 →

Equality Constraints

The polynomial division check ensures that the prover knows satisfying inputs and outputs for each gate, but does not ensure a correct wiring, e.g. the output of one gate is the input to another.


Example: I know

(a,b) such that
a+b=ab
.

Applying the division check on the two gates proves that I know satisfying inputs and outputs for each gate in isolation, i.e. I know

(a,b,c,d,e,f) such that
a+b=e
and
cd=f
:
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 →

adding copy constraints proves that the left inputs are equal, the right inputs are equal and the outputs are equal, i.e. I know
(a,b)
such that
a+b=ab
:
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 →


To prove equality of wires we apply a permutation check across the constraint system values

xl,xr,xo. We join each of the three columns into a single array of length
3n
:
u=xlxrxo=(xl(1),,xl(n),xr(1),,xr(n),xo(1),,xo(n)).
and create a permutation
σS3n
that acts on
u
to produce an array
v=σ(u)=(uσ1,,uσ3n)
. We choose
σ
such that each subset of copied values forms a cycle, i.e. copied values are permuted with only their copies.

Side Note: permutation cycles

Given a permutation

σS6 where:
σ=[123456214653]
we can write
σ
in cycle notation:
σ=(1 2)(3 4 6)(5)
or simply
(1 2)(3 4 6)
. An
m
-cycle is a subset of
m
elements that repeat after
m
applications of
σ
, e.g. the
2
-cycle
(1 2)
maps
12
then
21
.


Example: permutation of constraint system values

Given a constraint system of

n=3 constraints:
xl=(xl(1),xl(2),xl(3))xr=(xr(1),xr(2),xr(3))xl=(xo(1),xo(2),xo(3)) u=xlxrxl=(xl(1),xl(2),xl(3),xr(1),xr(2),xr(3),xo(1),xo(2),xo(3))123456789
and wiring:
xl(1)=xl(2)xo(1)=xr(2)=xl(3)
we create a permutation
σ
, which operates on a set containing
|u|=3n
elements, such that each set of copied constraint system values forms a cycle:
σ=(xl(1) xl(2))(xl(3) xr(2) xo(1))
written in a less cumbersome way using indices in
u
as:
σ=(1 2)(3 5 7).
The permuted vector
v=σ(u)=(uσ1,,uσ3n)
is:
v=(xl(2),xl(1),xo(1),xr(1),xl(3),xr(3),xr(2),xo(2),xo(3))217436589.
Permutation Example


The unpermuted array

u is encoded into the polynomial:
u(X)=i[3n](iX+ui)
and the permuted array
v
is encoded into the polynomial:
v(X)=i[3n](σiX+vi).
where
σi
is the index in
u
that permutes into
vi
, i.e.
vi=uσi
and
v=σ(u)=(uσ1,,uσ3n)
. Also let
ui(X)
and
vi(X)
denote the
ith
terms of
u(X)
and
v(X)
respectively:
ui(X)=(iX+ui)vi(X)=(σiX+vi).

Notice that for each term

vi(X) in
v(X)
there is an identical term
uσi(X)
in
u(X)
, thus the polynomials
u(X)
and
v(X)
are the same, despite their
ith
terms possibly being different:
ui(X)vi(X)if iσiuσi(X)=vi(X)i[3n]ui(X)=i[3n]vi(X)
thus the following relation holds:
u(X)v(X)=i[3n](iX+ui)(σiX+vi)=i[3n]ui(X)vi(X)=1.

This relation between a polynomial representing an array and a polynomial representing a permutation of the array can be tested using Schwartz-Zippel: given a random input

β the probability the
u(β)=v(β)
, or
u(β)v(β)=1
, is negligible.


Side Note: PLONK uses a slightly different relation.

PLONK actually defines

u(X)=i[3n](iX+ui+γ) and
v(X)=i[3n](σiX+vi+γ)
where the verifier chooses a random
γ
and sends it to the prover (which are equivalent via the right-shift Schwartz-Zippel lemma), thus in reality the above expression is:
u(X)v(X)=i[3n](iX+ui+γ)(σiX+vi+γ)=1.


Side Note: the trace of a running product.

The trace of a running product is an array

s whose first element is
1
an contains the value of the product after each multiplicand, e.g.
i[3]xis=(1,1x1,1xx2,1xx2x3)


The verifier chooses a random

β for the prover to evaluate
u(β)v(β)
and the prover constructs a grand product array
s=(s1,,s3n)
that represents
u(β)v(β)
, i.e.
s
is the trace of the product
u(β)v(β)
:
s1=1s2=s1u1(β)v1(β)=(1)u1(β)v1(β)s3=s2u2(β)v2(β)=(1u1(β)v1(β))u2(β)v2(β)s3n=s3n1u3n1(β)v3n1(β)=(1u1(β)v1(β)u3n2(β)v3n2(β))u3n1(β)v3n1(β)

s is recursive in that its
ith
element is equal to the previous element times
ui1(β)vi1(β)
:
si=si1ui1(β)vi1(β)where: i[2,3n].

Notice that the

u(β)v(β) can be computed from
s
by multiplying its last element by the last product term in
u(β)v(β)
:
u(β)v(β)=i[3n]ui(β)vi(β)=s3nu3n(β)v3n(β)=s3n+1

The prover creates a polynomial

s(X) using Lagrange interpolation on a publicly known set of
3n
inputs
H=ω={ω1,,ω3n}F
and image
s
such that:
i[3n]:s(ωi)=si.
Notice that the following relation holds for a pair of neighboring inputs
ωi
and
ωi+1
:
si+1=siui(β)vi(β)s(ωi+1)=s(ωi)ui(β)vi(β).

Given

s(X), the verifier wants to check that
v
is a permutation of
u
according to
σ
. The verifier checks that the permutation identity holds at the last element in
s
:
u(β)v(β)=?1s(ω3n)u3n(β)v3n(β)=?1
and that
s
is a correctly constructed running product
si=si1ui1(β)vi1(β)
:
s(ω3n)=?s(ω3n1)u3n1(β)v3n1(β) s(ω2)=?s(ω1)u1(β)v1(β)s(ω1)=?1.

If

u(β)v(β)=1 at the random challenge
β
then
u(X)=v(X)
, which implies
v=σ(u)
.

Proving Subarrays via Randomized Set Differences (Not Done)

Note: "ordered multiset" == "array"
Note: "subarray" == "order preserving subset of an array"

PLONK defines an ordered multiset's

a=(a1,,an) set difference
a
as the difference between adjacent elements of
a
:
a=(ai+1ai)i[n1] e.g. a=(2,6,4)a=(62,46)=(4,2).

Given arrays

a and
b
, if
b
is a subarray of
a
, then the set difference of
sorted(ab)
contains
|b|
number of zeros because each
bi
is inserted next to an
aj
having the same value:
e.g. a=(1,3,4,7)b=(1,7)c=sorted(ab)=(1,1,3,4,7,7)c=(0,2,1,3,0)ccontains |b|=2 zeros.
However, this alone does not prove that an array is a subarray of
bolda
because we can find an array
fa
where the set difference of
sorted(af)
contains
|f|
number of zeros:
e.g. a=(1,1)f=(3,3)g=sorted(af)=(1,1,3,3)g=(0,0)gcontains |f|=2 zeros.

However, given a random value

γ, we can test (w.h.p.) that an array
b
is subarray of an array
a
by shifting all elements by
γ
:

e.g. a+γ=(a1+γ,,an+γ)b+γ=(b1+γ,,bm+γ)c=sorted(ab)=(1,1,3,4,7,7)c=(0,2,1,3,0)ccontains |b|=2 zeros.







Multiset Checks (Right-Shift Schwartz-Zippel)

Given two arrays

a and
b
of equal length
n
, if both
a
and
b
contain the same elements, regardless of their ordering, then the products of the arrays' elements will be equal:
a=(x,y,z)  b=(x,z,y)=σ(a)  a1a2a3=b1b2b3.
However, the products of two [equally lengthed] arrays' elements being equal does not guarantee that
a
and
b
contain the same elements, e.g.
a=(x,y,z)b=(x2,z2,4y)σ(a)i[n]ai=i[n]bi.
We can use a product equality check on the elements of two arrays to guarantee that the arrays contain the same elements by right-shifting every element of each array by a random value
γ
:
a=(x,y,z)b=(x,z,y)(a1+γ)(a2+γ)(a3+γ)=(b1+γ)(b2+γ)(b3+γ)b=σ(a).

Background

Linear Factors Contain Roots

A univariate polynomial

f(X) having
n
roots
{a1,,an}
can be written uniquely as
n
degree-
1
polynomials:
f(X)=c(Xa1)(Xan)roots(f)={a1,,an}
where
c
is a constant. If we don't care about the sign of the roots we can write:
f(X)=c(X+a1)(X+an)roots(f)={a1,,an}.

A polynomial that has a linear factor

(iXa) has a root at
ai
:
f(X)=i[n](iXai)=c(Xa11)(Xann)where: c=1nroots(f)={a11,,ann}.

Encoding Sets and Arrays into Polynomials

We can encode a set of values

{a1,,an} into a unique polynomial:
f(X)=i[n](Xai)roots(f)={a1,,an}.


We can encode an array

(a1,,an) into a unique polynomial where each root encodes an array element and its position:
f(X)=i[n](iXai)roots(f)={a11,,ann}.


Side Note: if an array is a permutation of another, e.g.

a=(a1,,an) and
b=(b1,,bn)=σ(a)
where
σ=(σ1,σn)
is a permutation, then the following equality holds:
i[n](iXai)=i[n](σiXbi)
e.g.
a=(5,6,7)
and
b=(6,7,5)=σ(a)
:
a1b3(σ3=1)a2b1(σ1=2)a3b2(σ2=3) i[n](iXai)=i[n](σiXbi)(1Xa1)(2Xa2)(3Xa3)=(σ1Xb1)(σ2Xb2)(σ3Xb3)(1X5)(2X6)(3X7)=(2X6)(3X7)(1X5)

Schwartz-Zippel

Given two univariate polynomials:

f(X)=(X+a1)(X+an)g(X)=(X+b1)(X+bn) Schwartz-Zippel says that for a random input
γF
the probability that different polynomials
f(X)g(X)
evaluate to the same value
f(γ)=g(γ)
is very low.
Pr[f(γ)=g(γ)f(X)g(X)]max(df,dg)|F|

This allows us to test polynomial equivalency, i.e. is

f(X) the same polynomial as
g(X)
.

Schwartz-Zippel holds if every root of

f(X) and
g(X)
is shifted by the a randomly chosen constant
δF
:
f(X)=(X+a1+δ)(X+an+δ)g(X)=(X+b1+δ)(X+bn+δ)Pr[f(γ)=g(γ)f(X)g(X)]max(df,dg)|F|
because shifting two polynomials by the same value along the x-axis does not affect their equality.

We can encode the elements of a set

{a1,,an} into a polynomial
f(X)=(Xa1)(Xan)
and the set
{a1,,an}
into a polynomial
g(X)=(Xb1)(Xbn)
and use Schwartz-Zippel to test set equality (i.e. do sets
{a1,,an}
and
{b1,,bn}
contain the same elements).

We can encode an array

(a1,,an) as a polynomial whose roots contains the array elements and their positions:
f(X)=(1Xa1)(nXan)roots(f)={a11,,ann}
thus, we can use Schwartz-Zippel to test array equality (i.e.
i[n]:ai=bi
).

PLONK uses Schwartz-Zippel (on random input

λF) with a random right-shift
δF
to check array equality:
f(X)=(1Xa1+δ)(nXan+δ)g(X)=(1Xb1+δ)(nXbn+δ)Pr[f(λ)=g(λ)f(X)g(X)]max(df,dg)|F|.

Multivariate Variant

The Schwartz-Zippel probability is the same for an

n-variate polynomial
f(X1,,Xn)
and a randomly selected evaluation point
(x1,,xn)Fn

Pr[f(x1,,xn)=0]d|F|.

Zero-Polynomial Variant

Given a random evaluation point such that

f(x1,,xn)=0, the probability that
f(X1,,Xn)
is the zero-polynomial (always a zero-function) is the converse of the Schwartz-Zippel probability
Pr[f(X1,,Xn) is the zero-polynomial]=1Pr[f(x1,,xn)=0].

Low-Degree Extension

Given an array

a=(a1,,an)Fn and a subset
S={s1,,sn}F
, then the low-degree extension of
a
is the interpolation polynomial
a(X)
of degree
d=n1
that passes through the points
{(s1,a1),,(sn,an)}
:
i[n]:a(si)=ai.

Cosets (todo)

We associate each value in the constraint system with a unique value in

F:
xlH1i[n]:xl(i)ωixrH2i[n]:xr(i)2ωixoH3i[n]:xo(i)3ωi
where
H1,H2,H3<F
are disjoint subgroups and
ωiH
, . We then join the labels into an array of length
3n
:
u=(ω1,,ωn,2ω1,,2ωn,3ω1,,3ωn)