Try   HackMD

IPA Commitment Scheme Specification

tags: aztec-3, honk

In this document, we try to answer the following questions:

  1. How the Inner Product Argument (IPA) Polynoimial Commitment Scheme (PCS) works?
  2. How are we going to use IPA PCS in Aztec 3?

How Does the IPA PCS Work?

We consider the IPA PCS described in Section 3 of the Halo paper. We don't need it to be zero-knowledge. In high level, this is because the IPA PCS will be used at the last stage of Aztec 3 (similar to the smart contract/root verifier as in Aztec connect).

Notation: We denote vectors by bold letters, group elements by capital letters, and scalars by small letters. Multiplication of a scalar

m with a group element
G
i.e.,
G
added to itself
m
times, is denoted by
[m]G
.

Now we describe the IPA PCS.

Let

p(X)=i=0d1a[i]Xi be a polynopmial of degree
d1
where
d=2k
for some integer
k
. The vector
a
stores the coefficients of the polynomial
p(x)
. Let
xFp
be a random evaluation point and
v
the evaluation of
p(X)
at
x
. Let the vector
b
represent the consecutive powers of
x
i.e.,
b(1,x,x2,,xd1)
. Then we have
v=a,b
.

Let

G(G0,G1,,Gd1) denote the publicly known vector of group elements (srs points to be precise). Then the commitment to the polynomial
p(x)
is defined as (we are ignoring the blinding factor as we do not need zero-knowledge)
Ca,G.

Given

(C,x,v) as public input (
G,b
are also known publicly), the IPA PCS enables a prover to convince the verifier that
C
is indeed the commitment to the polynomial
p(x)
and
v
is indeed the evaluation of
p(x)
on the challenge point
x
i.e. it is a perfect special honest verifier zero-knowledge argument of knowledge for the relation:
{((C,x,v);a):C=a,Gv=a,b}.

The steps of the protocol is described below.

  1. First, the verifier sends a random group element

    U (referred as aux_generator in the code) to the prover. Both prover and verifier compute the quantity
    C=C+[v]U.

    We are coupling the commitment of the polynomial with the evaluation of the polynomial to simultaneously show that
    C
    and
    v
    are computed correctly. Notice that
    C
    can be alternatively expressed as
    (1)C=a,G+[a,b]U.

    IPA PCS is an argument of knowledge where the prover proves the knowledge of a vector
    a
    such that equation (1) holds with a communication cost logarithmic to the length of
    a
    . As the prover does not know
    U
    in advance, this proves that
    (a)
    C
    is the commitment to the polynomial
    p(x)
    at the srs points
    G
    i.e.,
    C=a,G
    and
    (b)
    v
    is the evaluation of
    p(x)
    at
    x
    i.e.
    v=a,b
    . The next steps are as follows.

  2. Let

    d=2k. We shall iterate over
    j
    starting from
    k
    to 1. We initialize
    G(k)G,a(k)a,b(k)b.

    The prover computes the quantities
    Lj=alo(j),Ghi(j)+[alo(j),bhi(j)]U,Rj=ahi(j),Glo(j)+[ahi(j),blo(j)]U,

    and sends to the verifier. Here, the vector
    alo(j)
    denotes the lower half over the vector
    a(j)
    and the vector
    ahi(j)
    denotes the upper half of the vector
    a(j)
    . The verifier generates a Fiat-Shamir challenge
    uj
    and sends to the prover. For the next
    (j1)
    th round, the prover computes the following quantities
    a(j1)=alo(j)uj+ahi(j)uj1,b(j1)=blo(j)uj1+bhi(j)uj,G(j1)=Glo(j)uj1+Ghi(j)uj.

    At the end (
    j=1
    ), the prover has computed the following quantities
    (L,R,G(0),a(0),b(0)),

    where the vectors
    L,R
    contain respectively the elements
    L0,,Lk,R0,,Rk
    ,
    k
    group elements each.
    G(0),a(0),b(0)
    represent the
    k
    times folded versions of
    G
    ,
    a
    ,
    b
    and are a group and a couple of field elements respectively.

  3. At the begining, the verifier has computed

    (2)C=a,G+[a,b]U=C+[v]U.
    We have
    C(k)=C
    ,
    a(k)=a
    ,
    b(k)=b
    ,
    G(k)=G
    as initialized above. For the
    (k1)
    th round, we have
    C(k1)=a(k1),G(k1)+[a(k1),b(k1)]U=alo(k)uk+ahi(k)uk1,Glo(k)uk1+Ghi(k)uk+[alo(k)uk+ahi(k)uk1,blo(k)uk1+bhi(k)uk]U=(alo(k),Glo(k)+ahi(k),Ghi(k))+uk2(alo(k),Ghi(k)+[alo(k),bhi(k)]U)+uk2(ahi(k),Glo(k)+[ahi(k),blo(k)]U)+[alo(k),blo(k)+ahi(k),bhi(k)]U=a(k),G(k)+[uk2]Lk+[uk2]Rk+[a(k),b(k)]U=C(k)+[uk2]Lk+[uk2]Rk.

    Following the same approach, we can inductively write,
    (3)C(0)=C+j=1k([uj2]Lj)+j=1k([uj2]Rj).

Following equation (2), we can alternatively express

C(0) as,
C(0)=[a(0)]G(0)+[a(0)b(0)]U,=[a(0)](G(0)+[b(0)]U).

Suppose, the prover provides

G(0) and
b(0)
along with
L
and
R
to the verifier. The verification proceeds as follows.
(i) The verifier computes
C(0)
as in equation (3).
(ii) The verifier checks if
b(0)
provided by the prover is computed correctly.
(iii) The verifier checks if
G(0)
provided by the prover is computed correctly.
(iv) The prover proves knowledge of
a(0)
such that
(4)C(0)=[a(0)](G(0)+[b(0)]U),

holds. Below we describe steps (ii), (iii), and (iv) in more details.

Steps (ii) and (iii)

From the section 3.1 of the Halo paper, we define the vector

s as
s=(u11u21uk1,u1u21uk1,u11u2uk1,u1u2uk1,u1u2uk).

Because of the binary structure of the folding of
G,b
, we have
b(0)=s,b,G(0)=s,G.

As observed in the Halo paper (Equation 3, https://eprint.iacr.org/2019/1021.pdf, we notice that the equation
g(X,u1,u2,,uk)=i=1k(ui+ui1X2i1)
is wrong),
b(0)
can be efficiently computed by the verifier by defining the polynomial,
g(X,u1,u2,,uk)=i=1k(ui1+uiX2i1),

and evaluating it at x, i.e.,
b(0)=s,b=g(x,u1,u2,,uk).

The above can be computed in logarithmic time. However, computing
G(0)=s,G
still requires a linear-time (
O(d)
) multiscalar multiplication (MSM). However as discussed in the paper, this cost can be amortized by delegating all these step (iv) verifications at the last step of
m
IPA verifications. We discuss more on this in the subsequent section.

Q: How to check

b(0)=s,b=g(x,u1,u2,,uk)?
A: Rather than giving a formal inductive proof, we give a small example for a better intuition. Let
d=4
,
b=b(2)=(b0,b1,b2,b3)
. The round challenges are
u2
and
u1
. Then for the first round,
b(1)=blo(2)u21+bhi(2)u2,=(b0,b1)u21+(b2,b3)u2,=(b0u21+b2u2,b1u21+b3u2).

And for the next and the last round we have,
b(0)=blo(1)u11+bhi(1)u1,=(b0u21+b2u2)u11+(b1u21+b3u2)u1,=b0u11u21+b1u1u21+b2u11u2+b3u1u2,=(u11u21,u1u21,u11u2,u1u2),(b0,b1,b2,b3),=s,b.

Similarly we can show that
G(0)=s,G
. Next lets verify
b(0)=g(x,u1,u2,,uk)
.
g(x,u1,u2)=i=12(ui1+uix2i1)=(u11+u1x)(u21+u2x2)=u11u21+u1u21x+u11u2x2+u1u2x3.

Given
x
the evaluation point, we have
b=(b0,b1,b2,b3)=(1,x,x2,x3)
, which verifies the claim.

Step (iv)

In step (iv), the prover proves knowledge of

a(0) such that
C(0)=[a(0)](G(0)+[b(0)]U),

holds. The paper uses a generalized Schnorr protocol to achieve this.
(a) The prover samples random
dFp
. Then she computes
R[d](G(0)+[b(0)]U)
. The prover sends
R
to the verifier.
(b) The verifier samples a random challenge
c
from
Fp
and sends it to the prover.
( c) The prover computes
z=a(0)c+d
and sends it to the verifier. The verifier accepts if
[c]C(0)+R=?[z](G(0)+[b(0)]U).

However, as we are not concerned with zero knowledge, in code the prover directly reveals
a(0)
as a part of the proof.

Summary of IPA-PCS

Let the underlying field be

Fp, the number of points on the curve is
r
.

  • Public inputs:
    G
    ,
    b
    ,
    (C,x,v)
    .
  • Prover's witness:
    a
    .
  • Proof:
    (L,R,a(0))
    .
  • Verifier's work:
  1. Compute:
    C=C+[v]U
    .
  2. Compute:
    C(0)=C+j=1k([uj2]Lj)+j=1k([uj2]Rj)
    .
  3. Check:
    b(0)=?g(x,u1,u2,,uk)=i=1k(ui1+uix2i1)
    (field operation in
    Fr
    as we need to check modulo
    r
    for all quantities).
  4. Check:
    G(0)=?s,G
    (group operation in
    Fp
    as the underlying
    x
    and
    y
    co-ordinates are the elements of the field
    Fp
    ).
  5. Check:
    C(0)=?[a(0)](G(0)+[b(0)]U)
    .

Accumulation of IPA-PCS and Recursive Process in Aztec 3

The below idea was described by Zac in Istanbul.

In the diagram below, we sketch the idea of recursive process in Aztec 3. Suppose circuit

A and
B
operate over the BN254 curve and circuit
C
operates over the Grumpkin curve. As depicted in the diagram, let the BN254 curve be designed over
Fp
and the number of points in the elliptic curve group is
r
. As a result, operations over
Fp
is expensive and operations over
Fr
is cheap.

For the Grumkin curve, the opposite is true, i.e., it is designed over

Fr and the number of points in the elliptic curve group is
p
. As a result, operations over
Fr
is expensive and operations over
Fp
is cheap.

Note: In the code, we refer a scalar in the field

Fr as barretenberg::fr or grumpkin::fq. Also a scalar in the field
Fq
is referred as barretenberg::fq or grumpkin::fr.

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 →

Suppose circuit

A produces a IPA proof
ΠA
and circuit
B
verifies it i.e., it produces a proof
ΠB
which attests that
ΠA
is verified successfully. As discussed in the previous section, to verify
ΠA
, circuit
B
needs to perform

  1. Field opeartions in
    Fr
    (step 3 in the above section).
  2. Group operations in
    Fp
    (step 4 in the above section).
    As mentioned above, the second operation is very expensive for circuit
    B
    . The idea is to delegate step 2 in the following way.

We construct another circuit

C over the Grumpkin curve, which accumulates
m
(say)
ΠA
proofs and produces another IPA proof that linear MSMs of all
ΠA
s are computed correctly. To elaborate on this, let
G1(0),G2(0),,Gm(0)
be the
m
group elements of
m
IPA proofs. As described in Section 3.2 of the Halo paper, checking the correctness of these quantities can be batched by taking a linear combination of these elements and calling the IPA once.

Now circuit

B needs to fully verify
ΠC
. However as circuit
C
is defined over the Grumpkin curve instead of the BN254 curve, circuit
B
needs to do,

  1. Field opeartions in
    Fp
    (step 3 in the above section),
  2. Group operations in
    Fr
    (step 4 in the above section),
    which are cheaper than group operations in
    Fp
    for circuit
    B
    as it is designed over the BN254 curve (designed over
    Fp
    , # points
    =r
    ).

Optimizations:

There can be some optimizations over the above protocol which follows the Halo paper. We write them below.

(1)

In the above protocol, in the

k rounds, the prover computes
a(j1)=alo(j)uj+ahi(j)uj1,b(j1)=blo(j)uj1+bhi(j)uj,G(j1)=Glo(j)uj1+Ghi(j)uj.

Instead of the above, we define the quantities for the next round as
a(j1)=alo(j)+ahi(j)uj,b(j1)=blo(j)+bhi(j)uj1,G(j1)=Glo(j)+Ghi(j)uj1.

This was originally proposed in Figure 3 of the Halo Infinite paper. As we can see, this reduces the number of scalar multiplication by the prover. As a result, For the
(k1)
th round, we have
C(k1)=a(k1),G(k1)+[a(k1),b(k1)]U=alo(k)+ahi(k)uk,Glo(k)+Ghi(k)uk(1)+[alo(k)+ahi(k)uk,blo(k)+bhi(k)uk1]U=(alo(k),Glo(k)+ahi(k),Ghi(k))+uk1(alo(k),Ghi(k)+[alo(k),bhi(k)]U)+uk(ahi(k),Glo(k)+[ahi(k),blo(k)]U)+[alo(k),blo(k)+ahi(k),bhi(k)]U=a(k),G(k)+[uk1]Lk+[uk]Rk+[a(k),b(k)]U=C(k)+[uk1]Lk+[uk]Rk.

Following the same approach, we can inductively write,
(5)C(0)=C+j=1k([uj1]Lj)+j=1k([uj]Rj).

Note: It also changes the
s
and
g(X)
. Below we compute them.

To compute

s and
g(X,u1,u2,,uk)
such that
b(0)=s,b=g(x,u1,u2,,uk)
. Again, rather than giving a formal inductive proof, we give a small example for a better intuition.
Let
d=4
,
b=b(2)=(b0,b1,b2,b3)
. The round challenges are
u2
and
u1
. Then for the first round,
b(1)=blo(2)+bhi(2)u21,=(b0,b1)+(b2,b3)u21,=(b0+b2u21,b1+b3u21).

And for the next and the last round we have,
b(0)=blo(1)+bhi(1)u11,=(b0+b2u21)+(b1+b3u21)u11,=b0+b1u11+b2u21+b3u11u21,=(1,u11,u21,u11u21),(b0,b1,b2,b3).

From this we have
s=(1,u11,u21,u11u21)
. For general
k
, we get,
s=(u10u20uk0,u11u20uk0,u10u21uk0,u11u21uk0,u11u21uk1).

Next lets compute

g(x,u1,u2,,uk) such that
b(0)=g(x,u1,u2,,uk)
. By observation we have (by change in variable in the previous equation)
g(x,u1,u2)=i=1k(1+ui1x2i1)
. For the example, we verify this below,
g(x,u1,u2)=i=12(1+ui1x2i1)=(1+u11x)(1+u21x2)=1+u11x+u21x2+u11u21x3.

Given
x
the evaluation point, we have
b=(b0,b1,b2,b3)=(1,x,x2,x3)
, which verifies the claim.

References

  1. Halo paper (https://eprint.iacr.org/2019/1021.pdf).
  2. Halo Infinite paper (https://eprint.iacr.org/2020/1536.pdf)
  3. ZK Hack whiteboard session (https://www.youtube.com/watch?v=RaEs5mnXIhY)