Marlin
Sumcheck
- Aim: Given a polynomial \(g: \mathbb{F}^m \rightarrow \mathbb{F}\) and \(X = \{x_i\}_{i \in [m]}\) compute the sum
- Intuition: evaluation on a boolean hypercube
- Naively, a verifier would require \(2^m\) evaluations of \(g(.)\)
- Sumcheck protocol requires \(\mathcal{O}(m + \lambda)\) verifier work
- Here \(\lambda\) is the cost to evaluate \(g(.)\) at some \(r \in \mathbb{F}^{m}\)
- Prover's work is only a constant factor more than mere computation of \(H\)
\(g(x,y) = \frac{-4x}{(x^2+y^2+1)}\)
Sumcheck
- Honest prover starts by computing \(C = \sum_{X \in \{0,1\}^m}g(x_1, x_2, \dots, x_m)\)
\(g_1(\textcolor{orange}{X_1}) := \sum_{X \setminus x_1}g(\textcolor{orange}{X_1},x_2, \dots, x_m)\)
\(g_2(\textcolor{orange}{X_2}) := \sum_{X \setminus x_2}g(\textcolor{green}{r_1}, \textcolor{orange}{X_2}, x_3, \dots, x_m)\)
\(C \stackrel{?}{=} g_1(0) + g_1(1)\)
\(g_1(\textcolor{green}{r_1}) \stackrel{?}{=} g_2(0) + g_2(1)\)
\(g_3(\textcolor{orange}{X_3}) := \sum_{X \setminus x_3}g(\textcolor{green}{r_1}, \textcolor{green}{r_2}, \textcolor{orange}{X_3}, x_4, \dots, x_m)\)
\(g_m(\textcolor{orange}{X_m}) := g(\textcolor{green}{r_1}, \textcolor{green}{r_2}, \dots, \textcolor{green}{r_{m-1}}, \textcolor{orange}{X_m})\)
\(g_2(\textcolor{green}{r_2}) \stackrel{?}{=} g_3(0) + g_3(1)\)
\(g_{m-1}(\textcolor{green}{r_{m-1}}) \stackrel{?}{=} g_m(0) + g_m(1)\)
\(g_{m}(\textcolor{green}{r_{m}}) \stackrel{?}{=} g(\textcolor{green}{r_1}, \textcolor{green}{r_2}, \dots, \textcolor{green}{r_m})\)
Prover \(\mathcal{P}\)
Verifier \(\mathcal{V}\)
\(g_1\)
\(r_1\)
\(g_2\)
\(g_3\)
\(g_m\)
\(r_{m-1}\)
\(r_2\)
\(\vdots\)
\(\vdots\)
\(\vdots\)
Low-degree Extensions
- An \(m\)-variate polynomial \(\hat{f}\) over \(\mathbb{F}\) is an extension of a function \(f: \{0,1\}^m \rightarrow \mathbb{F}\) if \(\hat{f}(x) = f(x)\) on the boolean hypercube \(\{0,1\}^m\)
- A low-degree extension can be thought of as error-correcting encoding of \(f\)
Univariate Sumcheck
- On a multiplicative subgroup \(H\) of \(\mathbb{F}\), a polynomial \(f\) with \(\text{deg}(f) < |H|\) sums to
\(\sum_{a \in H}f(a) = f(0) \cdot |H|\)
\(f(a^1) = c_0 \ + \ c_1a^1 \ + \ c_2a^2 \ + \ \dots \ + \ c_da^d\)
\(f(a^2) = c_0 \ + \ c_1a^2 \ + \ c_2a^4 \ + \ \dots \ + \ c_da^{2d}\)
\(f(a^3) = c_0 \ + \ c_1a^3 \ + \ c_2a^6 \ + \ \dots \ + \ c_da^{3d}\)
\(f(a^n) = c_0 \ + \ c_1a^n \ + \ c_2a^{2n} \ + \ \dots \ + c_da^{nd}\)
\(\vdots\)
\(\sum_{a \in H}f(a) =c_0\cdot |H|\)
- If \(\text{deg}(f) > |H|\), we can write \(f\) in terms of polynomials \(g \in \mathbb{F}^{< (|H|-1)}, h \in \mathbb{F}^{<|H|}\)
\(f(X) = Xg(X) + v_h(X)h(X) + \sigma/|H|\)
- Here \(v_H(X) = \prod_{a \in H}(X - a)\) is the vanishing polynomial on \(H\)
- To prove that the sum of \(f\) over \(H\) is \(\sigma\), the prover sends \(g, h\) and the alleged sum \(\sigma\)
- The verifier can check the equality at a random \(r \in \mathbb{F}\)
\(\sum_{a\in H}f(a) = \sigma\)
\(\iff\)
\(f(r) \stackrel{?}{=} rg(r) + v_h(r)h(r) + \frac{\sigma}{|H|}\)
Algebraic Holographic Proof
Prover
\(\textsf{AHP} = (\textsf{k, s, d}, \ \textbf{I},\ \textbf{P},\ \textbf{V})\)
Verifier
\(f:\{0,1\}^{\ast} \rightarrow \mathbb{N}\)
\(\underbrace{\hspace{1.2cm}}\)
Indexer
- Offline phase: Indexer \(\textbf{I}\) encodes the given index \(\textmd{i}\) in round \(0\)
\(\textbf{I}(\mathbb{F}, \textmd{i}) \longrightarrow \mathbb{I} = \left(p_{0,1} \in \mathbb{F}^{<d(0,1)},\ \dots,\ p_{0,s(0)} \in \mathbb{F}^{<d(0,s(0))}\right)\)
- Online phase: In round \(i \in [k]\) of interaction between \(\textbf{P}\) and \(\textbf{V}\):
\(\mathbf{P}(\mathbb{F}, \textmd{i}, \textmd{x}, \textmd{w})\)
\(\mathbf{V}^{\mathbb{I}}(\mathbb{F}, \textmd{x})\)
\(r_i\)
\(\left(p_{i,1} \in \mathbb{F}^{<d(i,1)},\ \dots,\ p_{i,s(i)} \in \mathbb{F}^{<d(i,s(i))}\right)\)
AHP for Lincheck
- Given polynomials \(f_1, f_2 \in \mathbb{F}^{<d}[X]\), we need to verify if for each \(a \in H\), we have
\(f_1(a) = \sum_{b \in H}M_{a,b}f_2(b)\)
- Matrix \(M \in \mathbb{F}^{|H| \times |H|}\) encodes the linear relationship between \(f_1\) and \(f_2\)
\(0\)
\(4\)
\(\nu_1\)
\(\textsf{row}\)
\(\textsf{col}\)
\(\textsf{val}\)
AHP for Lincheck
- Given polynomials \(f_1, f_2 \in \mathbb{F}^{<d}[X]\), we need to verify if for each \(a \in H\), we have
\(f_1(a) = \sum_{b \in H}M_{a,b}f_2(b)\)
- Matrix \(M \in \mathbb{F}^{|H| \times |H|}\) encodes the linear relationship between \(f_1\) and \(f_2\)
\(0\)
\(4\)
\(\nu_1\)
\(2\)
\(2\)
\(\nu_2\)
\(\textsf{row}\)
\(\textsf{col}\)
\(\textsf{val}\)
AHP for Lincheck
- Given polynomials \(f_1, f_2 \in \mathbb{F}^{<d}[X]\), we need to verify if for each \(a \in H\), we have
\(f_1(a) = \sum_{b \in H}M_{a,b}f_2(b)\)
- Matrix \(M \in \mathbb{F}^{|H| \times |H|}\) encodes the linear relationship between \(f_1\) and \(f_2\)
\(0\)
\(4\)
\(\nu_1\)
\(2\)
\(2\)
\(\nu_2\)
\(3\)
\(6\)
\(\nu_3\)
\(\textsf{row}\)
\(\textsf{col}\)
\(\textsf{val}\)
AHP for Lincheck
- Given polynomials \(f_1, f_2 \in \mathbb{F}^{<d}[X]\), we need to verify if for each \(a \in H\), we have
\(f_1(a) = \sum_{b \in H}M_{a,b}f_2(b)\)
- Matrix \(M \in \mathbb{F}^{|H| \times |H|}\) encodes the linear relationship between \(f_1\) and \(f_2\)
\(0\)
\(4\)
\(\nu_1\)
\(2\)
\(2\)
\(\nu_2\)
\(3\)
\(6\)
\(\nu_3\)
\(5\)
\(1\)
\(\nu_4\)
\(\textsf{row}\)
\(\textsf{col}\)
\(\textsf{val}\)
AHP for Lincheck
- Given polynomials \(f_1, f_2 \in \mathbb{F}^{<d}[X]\), we need to verify if for each \(a \in H\), we have
\(f_1(a) = \sum_{b \in H}M_{a,b}f_2(b)\)
- Matrix \(M \in \mathbb{F}^{|H| \times |H|}\) encodes the linear relationship between \(f_1\) and \(f_2\)
\(0\)
\(4\)
\(\nu_1\)
\(2\)
\(2\)
\(\nu_2\)
\(3\)
\(6\)
\(\nu_3\)
\(5\)
\(1\)
\(\nu_4\)
\(5\)
\(4\)
\(\nu_5\)
\(\textsf{row}\)
\(\textsf{col}\)
\(\textsf{val}\)
AHP for Lincheck
- Given polynomials \(f_1, f_2 \in \mathbb{F}^{<d}[X]\), we need to verify if for each \(a \in H\), we have
\(f_1(a) = \sum_{b \in H}M_{a,b}f_2(b)\)
- Matrix \(M \in \mathbb{F}^{|H| \times |H|}\) encodes the linear relationship between \(f_1\) and \(f_2\)
\(0\)
\(4\)
\(\nu_1\)
\(\textsf{row}\)
\(\textsf{col}\)
\(\textsf{val}\)
\(2\)
\(2\)
\(\nu_2\)
\(3\)
\(6\)
\(\nu_3\)
\(5\)
\(1\)
\(\nu_4\)
\(5\)
\(4\)
\(\nu_5\)
\(7\)
\(3\)
\(\nu_6\)
AHP for Lincheck
- Given polynomials \(f_1, f_2 \in \mathbb{F}^{<d}[X]\), we need to verify if for each \(a \in H\), we have
\(f_1(a) = \sum_{b \in H}M_{a,b}f_2(b)\)
- Matrix \(M \in \mathbb{F}^{|H| \times |H|}\) encodes the linear relationship between \(f_1\) and \(f_2\)
- The indexer outputs the polynomials \(\hat{\textsf{row}}, \hat{\textsf{col}}, \hat{\textsf{val}} \in \mathbb{F}^{< |K|}\)
- A low-degree extension of \(M\) over \(K \subseteq \mathbb{F}, \ |K| \ge \|M\| > 0\) is:
AHP for Lincheck
- Given polynomials \(f_1, f_2 \in \mathbb{F}^{<d}[X]\), we need to verify if for each \(a \in H\), we have
\(f_1(a) = \sum_{b \in H}M_{a,b}f_2(b)\)
- Converted lincheck to sumcheck! Note that \(r_M(X,Y) = \sum_{b \in H} \textcolor{orange}{r(X, b)}\hat{M}(b,Y)\)
AHP for Lincheck
\(g_1, h_1\)
\(\alpha\)
\(\beta_1\)
\(\sigma_2, g_2, h_2\)
\(\beta_2\)
\(\sigma_3, g_3, h_3\)
Towards Marlin
- Rank-1 Constraint System: \((\textmd{i} = (\mathbb{F}, H,K,A, B, C), \textmd{x} = x, \textmd{w} = w)\)
- We have \(A, B, C \in \mathbb{F}^{|H|\times |H|},\) \(|K| \ge \text{max}\{ \|A\|, \|B\|, \|C\| \}\) and \(z := (x, w) \in \mathbb{F}^{|H|}\) s.t.
- Prover \(\textbf{P}\) defines \(z_M := Mz\) for all \(M \in \{A,B,C\}\) and needs to prove:
- Entrywise product: \(\forall a \in H, \quad \hat{z}_A(a)\hat{z}_B(a) - \hat{z}_C(a) = 0\)
- Linear relationship: \(\forall M \in \{A,B,C\}, \ \forall a \in H, \quad \hat{z}_{M}(a) = \sum_{b\in H} M[a,b]\hat{z}(b) \)
- Offline phase: Indexer \(\textbf{I}\) outputs \(\{\hat{\textsf{row}}_M, \hat{\textsf{col}}_M, \hat{\textsf{val}}_M\}_{M \in \{A,B,C\}}\)
- \(\textbf{P}\) starts by computing shifted witness \(\bar{w}: H[>|x|] \rightarrow \mathbb{F}\) and low-degree extensions:
- Note that \(\hat{z}(X) = \hat{w}(X)v_{H[\le |x|]}(X) + \hat{x}(X)\)
Towards Marlin
\(\alpha,\eta_A, \eta_B, \eta_C\)
\(\sigma_1, \hat{w}, s\)
\(\hat{z}_A, \hat{z}_B, \hat{z}_C, h_0\)
Towards Marlin
\(\alpha,\eta_A, \eta_B, \eta_C\)
\(\beta_1\)
\(\sigma_1, \hat{w}, s\)
\(\hat{z}_A, \hat{z}_B, \hat{z}_C, h_0\)
\(g_1, h_1\)
\(\sigma_2, g_2, h_2\)
\(\beta_2\)
Towards Marlin
\(\beta_1\)
\(g_1, h_1\)
\(\sigma_2, g_2, h_2\)
\(\beta_2\)
\(\hat{z}_A, \hat{z}_B, \hat{z}_C, h_0\)
\(\alpha,\eta_A, \eta_B, \eta_C\)
\(\sigma_1, \hat{w}, s\)
\(\sigma_3, g_3, h_3\)
Optimizations
- Removing \(h_0, \hat{z}_C:\) replace \(\hat{z}_C\) with \((\hat{z}_A \cdot \hat{z}_B)\)
- Minimal query bound: set \(\textsf{b} = 1\)
- Eliminating \(\sigma_1\): sample \(s(X)\) such that \(\sum_{a\in H}s(a) = 0\)
- More efficient holographic lincheck from Fractal
\(r_M(X,Y) = M^{\star}(Y,X) := M_{x,y}u_H(X,X)\)
- Linear combinations of matrices \(A^{\star}, B^{\star}, C^{\star}\) to get a single \(\hat{\textsf{row}}, \hat{\textsf{col}}\)
- Reducing the number of hiding commitments: \(\hat{w}, \hat{z}_A, \hat{z}_B, \hat{z}_C, s, g_1, h_1\)
- Batching pairing equations
- Linearisation trick:
\(p_1(X) + p_2(X)p_3(X) = p_4(X)\)
\(\implies \ p_2(z) = v_2, \quad p_5(X) := p_1(X) + v_2p_3(X) - p_4(X) = 0\)
Marlin
\(\alpha,\eta_A, \eta_B, \eta_C\)
\(\textsf{cm}_{\hat{w}}, \textsf{cm}_{\hat{z}_A}, \textsf{cm}_{\hat{z}_B}, \textsf{cm}_{\hat{s}}\)
\(\beta\)
\(\textsf{cm}_{t},\textsf{cm}_{g_1}, \textsf{cm}_{h_1}\)
\(v_{g_1}, v_{\hat{z}_B}, v_t\)
\(\textsf{cm}_{g_3}, \textsf{cm}_{h_3}\)
Summary
- Marlin AHP coupled with a polynomial commitment scheme gives a zk-SNARK
- The core idea is simple but the math is heavy
- A lot more to learn from analysing the prover and verifier work
- Lots of straightforward optimisations used in practice
Marlin & More
By Suyash Bagad
Marlin & More
Explaining Marlin zkSNARK.
- 116