Plookups Last time I wrote about the purpose of lookups and specifically about the Halo2 lookups.
However, the first scheme for checking that the values of a committed polynomial are contained in some table was introduced in
plookup: A simplified polynomial protocol for lookup tables (opens new window) .
As last time, let’s have:
A = ( a ( 1 ) a ( ω ) a ( ω 2 ) a ( ω 3 ) a ( ω 4 ) a ( ω 5 ) a ( ω 6 ) a ( ω 7 ) ) = ( 3 1 3 3 1 1 1 3 1 3 3 3 ) A = \begin{pmatrix} a(1) \\ a(\omega) \\ a(\omega^2) \\ a(\omega^3) \\ a(\omega^4) \\ a(\omega^5) \\ a(\omega^6) \\ a(\omega^7) \end{pmatrix} = \begin{pmatrix} 3 \\ 13 \\ 3 \\ 11 \\ 13 \\ 13 \\ 3 \\ 3 \end{pmatrix}
A = ⎝ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎛ a ( 1 ) a ( ω ) a ( ω 2 ) a ( ω 3 ) a ( ω 4 ) a ( ω 5 ) a ( ω 6 ) a ( ω 7 ) ⎠ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎞ = ⎝ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎛ 3 1 3 3 1 1 1 3 1 3 3 3 ⎠ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎞
We need to prove that all elements of
A A A
are in
S = { 3 , 4 , 1 1 , 1 3 } . S = \{3, 4, 11, 13\}. S = { 3 , 4 , 1 1 , 1 3 } .
We can pad
S S S
with repetitions of the last element:
S = ( 3 4 1 1 1 3 1 3 1 3 1 3 1 3 ) S = \begin{pmatrix} 3 \\ 4 \\ 11 \\ 13 \\ 13 \\ 13 \\ 13 \\ 13 \end{pmatrix}
S = ⎝ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎛ 3 4 1 1 1 3 1 3 1 3 1 3 1 3 ⎠ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎞
The original lookup doesn’t permute
S S S
as
halo2 (opens new window)
does to have the same values as
A 1 A_1 A 1
at the positions where the value in
A 1 A_1 A 1
changes.
Instead, it uses the following trick.
I will make a few simplifications here, this is just a sketch, not the whole protocol.
Also, for easier demonstration, let’s have
A = { 1 , 1 , 5 } A = \{1, 1, 5\} A = { 1 , 1 , 5 }
and
S = { 1 , 2 , 5 } S = \{1, 2, 5\} S = { 1 , 2 , 5 } .
And let’s completely ignore that
n n n
has to be a power of
2 2 2 .
And let’s assume the length of
A A A
and
S S S
is the same.
Let’s observe:
F 1 = Π i < n ( 1 + β ) ( γ + a i ) = ( 1 + β ) 3 ( γ + 1 β ) ( γ + 1 β ) ( γ + 5 β ) F_1 = \Pi_{i < n} (1 + \beta) (\gamma + a_i) = (1 + \beta)^3 (\gamma + 1 \beta) (\gamma + 1 \beta) (\gamma + 5 \beta)
F 1 = Π i < n ( 1 + β ) ( γ + a i ) = ( 1 + β ) 3 ( γ + 1 β ) ( γ + 1 β ) ( γ + 5 β )
F 2 = Π i < n ( γ ( 1 + β ) + s i + β s i + 1 ) = ( γ ( 1 + β ) + 1 + β 2 ) ( γ ( 1 + β ) + 2 + β 5 ) F_2 = \Pi_{i < n} (\gamma (1 + \beta) + s_i + \beta s_{i+1}) = (\gamma (1 + \beta) + 1 + \beta 2) (\gamma (1 + \beta) + 2 + \beta 5)
F 2 = Π i < n ( γ ( 1 + β ) + s i + β s i + 1 ) = ( γ ( 1 + β ) + 1 + β 2 ) ( γ ( 1 + β ) + 2 + β 5 )
And:
F = F 1 F 2 = Π i < n ( 1 + β ) ( γ + a i ) Π i < n ( γ ( 1 + β ) + s i + β s i + 1 ) = F = F_1 F_2 = \Pi_{i < n} (1 + \beta) (\gamma + a_i) \Pi_{i < n} (\gamma (1 + \beta) + s_i + \beta s_{i+1}) =
F = F 1 F 2 = Π i < n ( 1 + β ) ( γ + a i ) Π i < n ( γ ( 1 + β ) + s i + β s i + 1 ) =
= ( 1 + β ) 3 ( γ + 1 β ) ( γ + 1 β ) ( γ + 5 β ) ( γ ( 1 + β ) + 1 + β 2 ) ( γ ( 1 + β ) + 2 + β 5 ) = (1 + \beta)^3 (\gamma + 1 \beta) (\gamma + 1 \beta) (\gamma + 5 \beta) (\gamma (1 + \beta) + 1 + \beta 2) (\gamma (1 + \beta) + 2 + \beta 5)
= ( 1 + β ) 3 ( γ + 1 β ) ( γ + 1 β ) ( γ + 5 β ) ( γ ( 1 + β ) + 1 + β 2 ) ( γ ( 1 + β ) + 2 + β 5 )
When
s i = s i + 1 s_i = s_{i+1} s i = s i + 1
we have:
γ ( 1 + β ) + s i + β s i + 1 = ( 1 + β ) ( γ + s i ) . \gamma (1 + \beta) + s_i + \beta s_{i+1} = (1 + \beta) (\gamma + s_i).
γ ( 1 + β ) + s i + β s i + 1 = ( 1 + β ) ( γ + s i ) .
Let
C = { c 1 , c 2 , c 3 , c 4 , c 5 , c 6 } C = \{c_1, c_2, c_3, c_4, c_5, c_6\} C = { c 1 , c 2 , c 3 , c 4 , c 5 , c 6 }
be the sorted version of the concatenation of
A A A
and
S S S .
So:
C = { 1 , 1 , 1 , 2 , 5 , 5 } C = \{1, 1, 1, 2, 5, 5\}
C = { 1 , 1 , 1 , 2 , 5 , 5 }
Let’s have:
G = Π i < 2 n ( γ ( 1 + β ) + c i + β c i + 1 ) G = \Pi_{i < 2n} (\gamma (1 + \beta) + c_i + \beta c_{i+1})
G = Π i < 2 n ( γ ( 1 + β ) + c i + β c i + 1 )
It holds that
F = G F = G F = G
if and only if
C = { c 1 , c 2 , c 3 , c 4 , c 5 , c 6 } C = \{c_1, c_2, c_3, c_4, c_5, c_6\} C = { c 1 , c 2 , c 3 , c 4 , c 5 , c 6 }
is
A ∪ S A \cup S A ∪ S
sorted by
S S S .
That means
F = G F = G F = G
if and only if
C = { 1 , 1 , 1 , 2 , 5 , 5 } C = \{1, 1, 1, 2, 5, 5\} C = { 1 , 1 , 1 , 2 , 5 , 5 } .
The proof of the equivalence is in the paper, but the intuition behind is that
when the element
c i c_i c i
is from
A , A, A ,
we have the element
c i + 1 c_{i+1} c i + 1
from
S S S
such that
c i = c i + 1 , c_i = c_{i+1}, c i = c i + 1 ,
so
γ ( 1 + β ) + c i + β c i + 1 = ( 1 + β ) ( γ + c i ) . \gamma (1 + \beta) + c_i + \beta c_{i+1} = (1 + \beta) (\gamma + c_i).
γ ( 1 + β ) + c i + β c i + 1 = ( 1 + β ) ( γ + c i ) .
So we have a factor of
F 1 F_1 F 1
which is the same as some factor of
G G G .
When
c i c_i c i
is not from
A , A, A ,
we have two factors
( γ ( 1 + β ) + c i − 1 + β c i ) ( γ ( 1 + β ) + c i + β c i + 1 ) (\gamma (1 + \beta) + c_{i-1} + \beta c_i)(\gamma (1 + \beta) + c_i + \beta c_{i+1})
( γ ( 1 + β ) + c i − 1 + β c i ) ( γ ( 1 + β ) + c i + β c i + 1 )
of
G G G
that appear in
F 2 . F_2. F 2 .
What was at first surprising to me in this scheme is that we don’t need to prove that
C C C
contains some prescribed values, we just prove that the polynomial
G G G
is properly constructed (has the correct number of factors and factors of the
correct form), but nothing about its values (we prove nothing about
c i c_i c i ). It follows from the equivalence above
that if
F = G , F = G, F = G ,
we have
A ⊆ S . A \subseteq S. A ⊆ S .
To encode the values
c i c_i c i
into a polynomial, we actually need two polynomials because there are
2 n 2n 2 n
values and we only have
ω , ω 2 , . . . , ω n \omega, \omega^2, ..., \omega^n ω , ω 2 , . . . , ω n
that can be used to encode the values.
So we construct
h 1 h_1 h 1
and
h 2 h_2 h 2
such that:
h 1 ( ω ) = c 1 h_1(\omega) = c_1
h 1 ( ω ) = c 1
h 1 ( ω 2 ) = c 2 h_1(\omega^2) = c_2
h 1 ( ω 2 ) = c 2
h 1 ( ω 3 ) = c 3 h_1(\omega^3) = c_3
h 1 ( ω 3 ) = c 3
h 1 ( ω n + 1 ) = h 1 ( 1 ) = c 4 h_1(\omega^{n+1}) = h_1(1) = c_4
h 1 ( ω n + 1 ) = h 1 ( 1 ) = c 4
h 2 ( ω ) = c 4 h_2(\omega) = c_4
h 2 ( ω ) = c 4
h 2 ( ω 2 ) = c 5 h_2(\omega^2) = c_5
h 2 ( ω 2 ) = c 5
h 2 ( ω 3 ) = c 6 h_2(\omega^3) = c_6
h 2 ( ω 3 ) = c 6
Note that
ω n + 1 = 1 \omega^{n+1} = 1
ω n + 1 = 1
and
h 1 ( ω n + 1 ) = h 1 ( 1 ) = h 2 ( ω 1 ) = c n + 1 . h_1(\omega^{n+1}) = h_1(1) = h_2(\omega^1) = c_{n+1}.
h 1 ( ω n + 1 ) = h 1 ( 1 ) = h 2 ( ω 1 ) = c n + 1 .
This is needed, otherwise one factor is missing.
Now we construct for
2 ≤ j ≤ n 2 \leq j \leq n 2 ≤ j ≤ n :
z ( ω j ) = Π i < j ( 1 + β ) ( γ + a ( ω i ) ) Π i < j ( γ ( 1 + β ) + s ( ω i ) + s ( ω i + 1 ) β ) Π i < j ( γ ( 1 + β ) + h 1 ( ω i ) + h 1 ( ω i + 1 ) β ) Π i < j ( γ ( 1 + β ) + h 2 ( ω i ) + h 2 ( ω i + 1 ) β ) z(\omega^j) = \frac{\Pi_{i < j}(1 + \beta) (\gamma + a(\omega^i)) \Pi_{i < j}(\gamma (1 + \beta) + s(\omega^i) + s(\omega^{i+1}) \beta)}{\Pi_{i < j}(\gamma (1 + \beta) + h_1(\omega^i) + h_1(\omega^{i+1}) \beta) \Pi_{i < j}(\gamma (1 + \beta) + h_2(\omega^i) + h_2(\omega^{i+1}) \beta) }
z ( ω j ) = Π i < j ( γ ( 1 + β ) + h 1 ( ω i ) + h 1 ( ω i + 1 ) β ) Π i < j ( γ ( 1 + β ) + h 2 ( ω i ) + h 2 ( ω i + 1 ) β ) Π i < j ( 1 + β ) ( γ + a ( ω i ) ) Π i < j ( γ ( 1 + β ) + s ( ω i ) + s ( ω i + 1 ) β )
It needs to hold:
z ( ω ) = 1 z(\omega) = 1
z ( ω ) = 1
z ( ω n + 1 ) = z ( 1 ) = 1 . z(\omega^{n+1}) = z(1) = 1.
z ( ω n + 1 ) = z ( 1 ) = 1 .
Note that the concept of the proof is the same as in the permutation argument .
We need to prove the following relations.
z(ω) is 1 z ( ω ) z(\omega) z ( ω )
needs to be
1 1 1
so that we have the starting point for the next check (polynomial
z z z
is constructed properly).
Polynomial z is constructed properly We need to ensure that the polynomial
z z z
is constructed properly:
z ( ω x ) ( γ ( 1 + β ) + h 1 ( x ) + h 1 ( ω x ) β ) ( γ ( 1 + β ) + h 2 ( x ) + h 2 ( ω x ) β ) = z(\omega x) (\gamma (1 + \beta) + h_1(x) + h_1(\omega x) \beta) (\gamma (1 + \beta) + h_2(x) + h_2(\omega x) \beta) =
z ( ω x ) ( γ ( 1 + β ) + h 1 ( x ) + h 1 ( ω x ) β ) ( γ ( 1 + β ) + h 2 ( x ) + h 2 ( ω x ) β ) =
= z ( x ) ( 1 + β ) ( γ + a ( x ) ) ( γ ( 1 + β ) + s ( x ) + s ( ω x ) β ) . = z(x) (1 + \beta) (\gamma + a(x)) (\gamma (1 + \beta) + s(x) + s(\omega x) \beta).
= z ( x ) ( 1 + β ) ( γ + a ( x ) ) ( γ ( 1 + β ) + s ( x ) + s ( ω x ) β ) .
Correct transition in h We need to ensure that:
h 1 ( 1 ) = h 2 ( ω ) . h_1(1) = h_2(\omega).
h 1 ( 1 ) = h 2 ( ω ) .
That means the last value of
h 1 h_1 h 1
is the same as the first value of
h 2 h_2 h 2 .
Note that
ω n + 1 = 1 \omega^{n+1} = 1 ω n + 1 = 1
and the first value of the set is stored at
ω . \omega. ω .
Grand product is 1 We need to ensure that the grand product is
1 1 1 :
z ( ω n + 1 ) = z ( 1 ) = 1 . z(\omega^{n+1}) = z(1) = 1.
z ( ω n + 1 ) = z ( 1 ) = 1 .
Note that:
z ( ω 2 ) = ( a ( ω 1 ) + a ( ω 2 ) β ) ( s ( ω 1 ) + s ( ω 2 ) β ) ( h 1 ( ω 1 ) + h 1 ( ω 2 ) β ) ( h 2 ( ω 1 ) + h 2 ( ω 2 ) β ) z(\omega^2) = \frac{(a(\omega^1) + a(\omega^2) \beta) (s(\omega^1) + s(\omega^2) \beta)}{(h_1(\omega^1) + h_1(\omega^{2}) \beta) (h_2(\omega^1) + h_2(\omega^{2}) \beta)}
z ( ω 2 ) = ( h 1 ( ω 1 ) + h 1 ( ω 2 ) β ) ( h 2 ( ω 1 ) + h 2 ( ω 2 ) β ) ( a ( ω 1 ) + a ( ω 2 ) β ) ( s ( ω 1 ) + s ( ω 2 ) β )
. . . . ....
. . . .
z ( ω n ) = ( a ( ω 1 ) + a ( ω 2 ) β ) ( s ( ω 1 ) + s ( ω 2 ) β ) ⋅ ⋅ ⋅ ( a ( ω n − 1 ) + a ( ω n ) β ) ( s ( ω n − 1 ) + s ( ω n ) β ) ( h 1 ( ω 1 ) + h 1 ( ω 2 ) β ) ( h 2 ( ω 1 ) + h 2 ( ω 2 ) β ) ⋅ ⋅ ⋅ ( h 1 ( ω n − 1 ) + h 1 ( ω n ) β ) ( h 2 ( ω n − 1 ) + h 2 ( ω n ) β ) . z(\omega^n) = \frac{(a(\omega^1) + a(\omega^2) \beta) (s(\omega^1) + s(\omega^2) \beta) \cdot \cdot \cdot (a(\omega^{n-1}) + a(\omega^n) \beta) (s(\omega^{n-1}) + s(\omega^n) \beta)}{(h_1(\omega^1) + h_1(\omega^{2}) \beta) (h_2(\omega^1) + h_2(\omega^{2}) \beta) \cdot \cdot \cdot (h_1(\omega^{n-1}) + h_1(\omega^{n}) \beta) (h_2(\omega^{n-1}) + h_2(\omega^{n}) \beta)}.
z ( ω n ) = ( h 1 ( ω 1 ) + h 1 ( ω 2 ) β ) ( h 2 ( ω 1 ) + h 2 ( ω 2 ) β ) ⋅ ⋅ ⋅ ( h 1 ( ω n − 1 ) + h 1 ( ω n ) β ) ( h 2 ( ω n − 1 ) + h 2 ( ω n ) β ) ( a ( ω 1 ) + a ( ω 2 ) β ) ( s ( ω 1 ) + s ( ω 2 ) β ) ⋅ ⋅ ⋅ ( a ( ω n − 1 ) + a ( ω n ) β ) ( s ( ω n − 1 ) + s ( ω n ) β ) .
So only at
ω n + 1 \omega^{n+1} ω n + 1
we get all the factors we need (note that, for example,
h 1 ( ω n + 1 ) = c 4 h_1(\omega^{n+1}) = c_4 h 1 ( ω n + 1 ) = c 4 ).