diff --git a/ph23/ph23-pcs-01.md b/ph23/ph23-pcs-01.md new file mode 100644 index 0000000..7ef33d9 --- /dev/null +++ b/ph23/ph23-pcs-01.md @@ -0,0 +1,640 @@ +# The Missing Protocol PH23-PCS (Part 1) + +In the paper "Improving logarithmic derivative lookups using GKR" ([PH23]), the authors presented an idea to convert MLE into a Univariate Polynomial. Although the paper didn't provide a complete protocol description, this protocol demonstrates advantages in certain aspects, such as supporting Shift Arguments with arbitrary offsets. + +The main advantage of this scheme is its ability to support Shift Arguments with arbitrary offsets (see Appendix A.2 of the paper). Additionally, when interfacing with KZG10, the proof of this PCS Adaptor only includes a constant number of $\mathbb{G}_1$ elements and a logarithmic number of $\mathbb{F}_r$ elements. This is superior to Gemini-PCS and Zeromorph-PCS (KT23), which require a logarithmic number of $\mathbb{G}_1$ elements. + +The approach of this protocol is similar to Virgo-PCS in that they both view MLE polynomial operations as a summation and use the Univariate Sumcheck protocol to complete the "sum proof". However, PH23-PCS also requires the Prover to prove the value of the MLE Lagrange Polynomial at the evaluation point, thus reducing the burden on the Verifier; while Virgo-PCS uses the GKR protocol to achieve this. Another difference is that Virgo-PCS requires the MLE polynomial to be represented in Coefficient Form, so Virgo-PCS uses the GKR circuit to prove the correctness of the computation of converting the MLE polynomial from Evaluation Form to Coefficient Form. + +This article series completes the description of PH23-PCS in the [PH23] paper and provides a simplified protocol for PH23-KZG10 to help everyone understand the basic idea of this protocol. + +This article first introduces the basic principles of PH23-PCS-Adaptor in detail, and then provides a simple protocol implementation of PH23-KZG10. + +## 1. Principle Overview + +Before explaining how the Prover proves the Evaluation of an MLE polynomial $\tilde{f}(\vec{X})$, let's recall the definition of an MLE polynomial: + +$$ +\tilde{f}(X_0, X_1, \ldots, X_{n-1}) = \sum_{i=0}^{N-1} a_i \cdot \overset{\sim}{eq}(\mathsf{bits}(i), (X_0, X_1, \ldots, X_{n-1})) +$$ + +Here $N=2^n$. +When calculating the value of $\tilde{f}(\vec{X})$ at $\vec{X}=(u_0, u_1, \ldots, u_{n-1})$, we need to calculate $\sum_{i=0}^{N-1} a_i \cdot \overset{\sim}{eq}(\mathsf{bits}(i), \vec{u})$. To facilitate explanation, we introduce a new vector $\vec{c}$, where each element $c_i$ = $\overset{\sim}{eq}(\mathsf{bits}(i), \vec{u})$. + +If $n=3$ and $N=8$, then all values of $\vec{c}$ can be enumerated: + +$$ +\begin{array}{cccc} +c_0 &= &(1-u_0)&(1-u_1)&(1-u_2) \\ +c_1 &= &u_0&(1-u_1)&(1-u_2) \\ +c_2 &= &(1-u_0) &u_1 &(1-u_2) \\ +c_3 &= &u_0 &u_1 &(1-u_2) \\ +c_4 &= &(1-u_0)&(1-u_1) & u_2 \\ +c_5 &= &u_0&(1-u_1)&u_2 \\ +c_6 &= &(1-u_0) &u_1 &u_2 \\ +c_7 &= &u_0 &u_1 &u_2 \\ +\end{array} +$$ + +It can be seen that the elements of $\vec{c}$ are defined with certain patterns. For example, $c_i$ is the product of $s$ values, and these values also have certain patterns. Here $(1-u_i)$ represents binary 0, while $u_i$ represents binary 1. For instance, $c_7$ is the product of three numbers, $u_0, u_1, u_2$, which represents `(111)`, exactly the binary representation of 7. Another example is $c_5$, which is the product of three numbers, $u_0, (1-u_1), u_2$, representing `(101)`, which is the binary representation of 5. + +The key idea of PH23 is whether the Prover can first commit to the vector $\vec{c}$, and then prove that each element of $\vec{c}$ is correctly defined according to the binary pattern above. If possible, the Prover can then prove an Inner Product relationship, i.e., prove $\langle \vec{a}, \vec{c} \rangle = v$, which is equivalent to proving $\tilde{f}(\vec{X})=v$. + +Therefore, the proof protocol of PH23 is divided into two parts: + +1. Prove the Well-Formedness of vector $\vec{c}$. +2. Prove $\langle \vec{a}, \vec{c} \rangle = v$. + +## 2. Well-Formedness of $\vec{c}$ + +Continuing with the example of $\vec{c}$ where $s=3$, + +$$ +\begin{array}{cccc} +c_0 &= &(1-u_0)&(1-u_1)&(1-u_2) \\ +c_1 &= &u_0&(1-u_1)&(1-u_2) \\ +c_2 &= &(1-u_0) &u_1 &(1-u_2) \\ +c_3 &= &u_0 &u_1 &(1-u_2) \\ +c_4 &= &(1-u_0)&(1-u_1) & u_2 \\ +c_5 &= &u_0&(1-u_1)&u_2 \\ +c_6 &= &(1-u_0) &u_1 &u_2 \\ +c_7 &= &u_0 &u_1 &u_2 \\ +\end{array} +$$ + +We observe that + +$$ +\frac{c_0}{c_4} = \frac{1-u_2}{u_2} +$$ + +Thus, if $c_0$ is correct, we can prove that $c_4$ is correct by proving the following constraint equation: + +$$ +c_0\cdot u_2 - c_4\cdot (1-u_2) = 0 +$$ + +Next, we observe + +$$ +\frac{c_0}{c_2} = +\frac{c_4}{c_6} = \frac{1-u_1}{u_1} \\ +$$ + +From this, we can infer that if $c_0$ is correct, then the following two constraint equations ensure that $c_2$ and $c_6$ are correct: + +$$ +\begin{split} +c_0\cdot u_1 - c_2\cdot (1-u_1) = 0 \\ +c_4\cdot u_1 - c_6\cdot (1-u_1) = 0 \\ +\end{split} +$$ + +Next, we can prove that $c_1, c_3, c_5, c_7$ are correct because they can be derived from $c_0, c_2, c_4, c_6$, which have been proven correct in the previous step: +$$ +\begin{split} +c_0 \cdot u_0 - c_1 \cdot (1-u_0) = 0 \\ +c_2 \cdot u_0 - c_3 \cdot (1-u_0) = 0 \\ +c_4 \cdot u_0 - c_5 \cdot (1-u_0) = 0 \\ +c_6 \cdot u_0 - c_7 \cdot (1-u_0) = 0 \\ +\end{split} +$$ + +The final conclusion is that through the above $1+2+4$ constraint equations, we can prove that $c_1, c_2, c_3, c_4, c_5, c_6, c_7$ are all correct, assuming $c_0$ is known to be correct. The inference relationship between the elements of vector $\vec{c}$ is shown in the following diagram: + +$$ +\begin{array}{ccccc} +c_4 & & & & \\ +c_2 & c_6 & \\ +c_1& c_3 & c_5& c_7 \\ +\cdots & & \\ +\end{array} +$$ + +Assume $H$ is a multiplicative subgroup of size 8 in the finite field $\mathbb{F}_p$, $H=\{1, \omega, \omega^2, \omega^3, \omega^4, \omega^5, \omega^6, \omega^7\}$, where $\omega\in \mathbb{F}_p$ is an 8th root of unity. And let $\{L_i(X)\}_{i=0}^{N-1}$ denote the Lagrange Basis polynomials on $H$. + +Then we can introduce $c(X)$ as the polynomial encoding of $\vec{c}$ according to the Lagrange Basis: + +$$ +c(X) = \sum_{i=0}^{N-1} c_i \cdot L_i(X) +$$ + +It's easy to verify that $c(\omega^i) = c_i$, where $i=0,1,2,\ldots, N-1$. + +Furthermore, the four constraint equations proving $c_1, c_3, c_5, c_7$ can be combined into one polynomial constraint equation: + +$$ +(X-\omega)(X-\omega^3)(X-\omega^5)(X-\omega^7)\cdot \big(c(X)u_0 - c(\omega\cdot X)(1-u_0)\big) = 0, \quad X\in H +$$ + +We can substitute $X=\omega^2$, and the above constraint equation corresponds to: + +$$ +c(\omega^2) \cdot u_0 - c(\omega^3) \cdot (1-u_0) = c_2 \cdot u_0 - c_3 \cdot (1-u_0) = 0 \\ +$$ + +By substituting $X=\omega, X=\omega^4, X=\omega^6$ respectively, we can obtain the constraint equations proving the correctness of $c_1, c_5, c_7$. + +The polynomial $(X-\omega)(X-\omega^3)(X-\omega^5)(X-\omega^7)$ looks like a Selector polynomial, filtering out $X$ values that don't satisfy the condition. + +Using this method, we can use $n=\log{N}$ polynomial constraints to prove the Well-Formedness of $\vec{c}$. + +For the example of $N=8$, we need to introduce 3 Selector polynomials $s_0(X), s_1(X), s_2(X)$, + +$$ +s_i(X) = \frac{v_H(X)}{v_{H_i}(X)}, \qquad i=0,1,2 +$$ + +where $v_H(X)$ and $v_{H_i}(X)$ are the Vanishing polynomials of Domain $H$ and $H_i$ respectively. And $H_i$ is a subgroup of $H$, satisfying the following Group Tower relationship: + +$$ +\{1\} = H_0 \sub H_1 \sub H_2 \sub H_3 = H +$$ + +They are defined as follows: + +$$ +\begin{split} +H = H_3 &= (1, \omega, \omega^2, \omega^3, \omega^4, \omega^5, \omega^6, \omega^7) \\ +H_2 & = (1, \omega^2, \omega^4, \omega^6)\\ +H_1 & = (1, \omega^4)\\ +H_0 & = (1)\\ +\end{split} +$$ + +Naturally, the representations of Selector polynomials $s_0(X), s_1(X), s_2(X)$ are as follows: + +$$ +\begin{split} +s_0(X) &= (X-\omega)(X-\omega^2)(X-\omega^3)(X+1)(X+\omega)(X+\omega^2)(X+\omega^3) \\ +s_1(X) &= (X-\omega)(X-\omega^2)(X-\omega^3)(X+\omega)(X+\omega^2)(X+\omega^3) \\ +s_2(X) &= (X-\omega)(X-\omega^3)(X+\omega)(X+\omega^3) \\ +\end{split} +$$ + +### Polynomial Constraint Equations + +The constraint equation ensuring the correctness of $c_0$ can be expressed as the following polynomial constraint: + +$$ +s_0(X)\cdot \big(c(X) - (1-u_0)(1-u_1)(1-u_{2})\big) = 0, \quad X\in H +$$ + +The constraint equation ensuring the correctness of $c_4$ can be expressed as the following polynomial constraint: + +$$ +s_0(X)\cdot \big(c(X)u_2 - c(\omega^4\cdot X)(1-u_2)\big) = 0, \quad X\in H +$$ + +The following are the constraint equations ensuring the correctness of $c_2, c_6$: + +$$ +s_1(X)\cdot \big(c(X)u_1 - c(\omega^2\cdot X)(1-u_1)\big) = 0, \quad X\in H +$$ + +Finally, the constraint equation ensuring the correctness of $c_1,c_3,c_5,c_7$: + +$$ +s_2(X)\cdot \big(c(X)u_0 - c(\omega\cdot X)(1-u_0)\big) = 0, \quad X\in H +$$ + +## 3. Proving Inner Product + +The second part of the proof is to prove $\langle \vec{a}, \vec{c} \rangle = v$. Assuming $a(X)$ is the encoding of vector $\vec{a}$, i.e., $a(X)\mid_H=\vec{a}$, then $a(X)$ is committed as $[a(\tau)]_1$, along with the commitment of $c(X)$, $[c(\tau)]_1$, we can use the Univariate Sumcheck protocol to prove the inner product. + +### Univariate Sumcheck + +Let's first look at a theorem (Remark 5.6 in [BCRSVW19], Sec.3 in [RZ21], Sec.5.1 in [CHMMVW19]): For any $P(X)\in \mathbb{F}[X]$, a multiplicative subgroup $H\sub \mathbb{F}$, $P(X)$ can be decomposed as: + +$$ +P(X) = q(X)\cdot v_H(X) + X\cdot g(X) + (v/N) +$$ + +Here $v$ is the sum of $P(X)$ over $H$, i.e., + +$$ +\sum_{\omega\in H}P(\omega)=v +$$ + +Therefore, we can use this theorem to prove the inner product of two vectors. If $a(X)\cdot c(X)$ can be expressed as the following equation, + +$$ +a(X)\cdot c(X) = q(X)\cdot v_H(X) + X\cdot g(X) + (v/N), \quad \deg(g)