math/notes_spartan.tex
notes_spartan.texRaw
1\documentclass{article}
2\usepackage[utf8]{inputenc}
3\usepackage{amsfonts}
4\usepackage{amsthm}
5\usepackage{amsmath}
6\usepackage{mathtools}
7\usepackage{enumerate}
8\usepackage{hyperref}
9\usepackage{xcolor}
10\usepackage{pgf-umlsd} % diagrams
11\usepackage{centernot}
12
13
14% prevent warnings of underfull \hbox:
15\usepackage{etoolbox}
16\apptocmd{\sloppy}{\hbadness 4000\relax}{}{}
17
18\theoremstyle{definition}
19\newtheorem{definition}{Def}[section]
20\newtheorem{theorem}[definition]{Thm}
21
22% custom lemma environment to set custom numbers
23\newtheorem{innerlemma}{Lemma}
24\newenvironment{lemma}[1]
25{\renewcommand\theinnerlemma{#1}\innerlemma}
26{\endinnerlemma}
27
28
29\title{Notes on Spartan}
30\author{arnaucube}
31\date{April 2023}
32
33\begin{document}
34
35\maketitle
36
37\begin{abstract}
38 Notes taken while reading about Spartan \cite{cryptoeprint:2019/550}.
39
40 Usually while reading papers I take handwritten notes, this document contains some of them re-written to $LaTeX$.
41
42 The notes are not complete, don't include all the steps neither all the proofs.
43\end{abstract}
44
45\tableofcontents
46
47\section{Encoding R1CS instances as low-degree polynomials}
48\begin{definition}{R1CS}
49 $\exists w \in \mathbb{F}^{m - |io| - 1}$ such that $(A \cdot z) \circ (B \cdot z) = (C \cdot z)$, where $z=(io, 1, w)$.
50\end{definition}
51
52
53\textbf{Thm 4.1} $\forall$ R1CS instance $x = (\mathbb{F}, A, B, C, io, m, n)$, $\exists$ a degree-3 log m-variate polynomial $G$ such that $\sum_{x \in \{0,1\}^{log m}} G(x) = 0$.
54% \begin{theorem}{4.1} // TODO use theorem gadget
55% $\forall$
56% \begin{end}
57\vspace{0.5cm}
58
59For a RCS instance $x$, let $s = \lceil log m \rceil$.
60
61We can view matrices $A, B, C \in \mathbb{F}^{m \times m}$ as functions $\{0,1\}^s \times \{0,1\}^s \rightarrow \mathbb{F}$.
62For a given witness $w$ to $x$, let $z=(io, 1, w)$.
63View $z$ as a function $\{0,1\}^s \rightarrow \mathbb{F}$, so any entry in $z$ can be accessed with a $s$-bit identifier.
64
65$$
66F_{io}(x)=
67$$
68$$
69\left( \sum_{y \in \{0,1\}^s} A(x, y) \cdot Z(y) \right) \cdot \left( \sum_{y \in \{0,1\}^s} B(x, y) \cdot Z(y) \right) - \left( \sum_{y \in \{0,1\}^s} C(x, y) \cdot Z(y) \right)
70$$
71
72\begin{lemma}{4.1}
73 $\forall x \in \{0,1\}^s,~ F_{io}(x)=0$ iff $Sat_{R1CS}(x,w)=1$.
74\end{lemma}
75
76$F_{io}(\cdot)$ is a function, not a polynomial, so it can not be used in the Sum-check protocol.
77
78consider its polynomial extension $\widetilde{F}_{io}(x): \mathbb{F}^s \rightarrow \mathbb{F}$,
79$$\widetilde{F}_{io}(x)=$$
80$$
81\left( \sum_{y \in \{0,1\}^s} \widetilde{A}(x, y) \cdot \widetilde{Z}(y) \right) \cdot \left( \sum_{y \in \{0,1\}^s} \widetilde{B}(x, y) \cdot \widetilde{Z}(y) \right) - \left( \sum_{y \in \{0,1\}^s} \widetilde{C}(x, y) \cdot \widetilde{Z}(y) \right)
82$$
83
84\begin{lemma}{4.2}
85 $\forall x \in \{0,1\}^s,~ \widetilde{F}_{io}(x)=0$ iff $Sat_{R1CS}(x, w)=1$.
86\end{lemma}
87
88(proof: $\forall x \in \{0,1\}^s,~ \widetilde{F}_{io}(x)=F_{io}(x)$, so, result follows from Lemma 4.1.) % TODO link to lemma
89
90\vspace{0.5cm}
91
92$\widetilde{F}_{io}(\cdot)$: low-degree multivariate polynomial over $\mathbb{F}$ in $s$ variables.
93Verifier can check if $\sum_{x \in \{0,1\}^s} \widetilde{F}_{io}(x)=0$ using the Sum-check protocol.
94
95But: $\sum_{x\in \{0,1\}^s} \widetilde{F}_{io}(x)=0 \centernot\Longleftrightarrow F_{io}(x)=0 \forall x \in \{0,1\}^s$.
96Bcs: the $2^s$ terms in the sum might cancel each other even when the individual terms are not zero.
97Solution: consider
98$$Q_{io}(t)= \sum_{x \in \{0,1\}^s} \widetilde{F}_{io}(x) \cdot \widetilde{eq}(t, x)$$
99where $\widetilde{eq}(t, x) = \prod_{i=1}^s (t_i \cdot x_i + (1- t_i) \cdot (1- x_i))$.
100
101Basically $Q_{io}(\cdot)$ is a multivariate polynomial such that
102$$Q_{io}(t) = \widetilde{F}_{io}(t) ~\forall t \in \{0,1\}^s$$
103thus, $Q_{io}(\cdot)$ is a zero-polynomial iff $\widetilde{F}_{io}(x)=0 ~\forall x\in \{0,1\}^s$.
104$\Longleftrightarrow$ iff $\widetilde{F}_{io}(\cdot)$ encodes a witness $w$ such that $Sat_{R1CS}(x, w)=1$.
105
106To check that $Q_{io}(\cdot)$ is a zero-polynomial: check $Q_{io}(\tau)=0,~ \tau \in^R \mathbb{F}^s$ (Schwartz-Zippel-DeMillo–Lipton lemma).
107
108\section{NIZKs with succint proofs for R1CS}
109
110From Thm 4.1: to check R1CS instance $(\mathbb{F}, A, B, C, io, m, n)$ V can check if
111$$\sum_{x \in \{0,1\}^s} G_{io, \tau} (r_x)$$
112where $r_x \in \mathbb{F}^s$.
113
114Recall: $G_{io, \tau}(x) = \widetilde{F}_{io}(x) \cdot \widetilde{eq}(\tau, x)$.
115
116To evaluate $\widetilde{F}_{io}(r_x)$, V needs to evaluate
117$$\forall y \in \{0,1\}^s: \widetilde{A}(r_x, y), \widetilde{B}(r_x, y), \widetilde{C}(r_x, y), \widetilde{Z}(y)$$
118evaluations of $\widetilde{Z}(y) ~\forall y \in \{0,1\}^s ~\Longleftrightarrow (io, 1, w)$.
119
120Solution: combination of 3 protocols:
121\begin{itemize}
122 \item Sum-check protocol
123 \item randomized mini protocol
124 \item polynomial commitment scheme
125\end{itemize}
126
127Observation: let $\widetilde{F}_{io}(r_x) = \bar{A}(r_x) \cdot \bar{B}(r_x) - \bar{C}(r_x)$, where
128$$\bar{A}(r_x) = \sum_{y \in \{0,1\}} \widetilde{A}(r_x, y) \cdot \widetilde{Z}(y)$$
129$$\bar{B}(r_x) = \sum_{y \in \{0,1\}} \widetilde{B}(r_x, y) \cdot \widetilde{Z}(y)$$
130$$\bar{C}(r_x) = \sum_{y \in \{0,1\}} \widetilde{C}(r_x, y) \cdot \widetilde{Z}(y)$$
131
132Prover makes 3 separate claims: $\bar{A}(r_x)=v_A,~ \bar{B}(r_x)=v_B,~ \bar{C}(r_x)=v_C$,
133then V evaluates:
134$$G_{io, \tau}(r_x) = (v_A \cdot v_B - v_C) \cdot \widetilde{eq}(r_x, \tau)$$
135which could be 3 sum-check protocol instances. Instead: combine 3 claims into a single claim:
136
137V samples $r_A, r_B, r_C \in^R \mathbb{F}$, and computes $c= r_A v_A + r_B v_B + r_C v_C$.
138V, P use sum-check protocol to check:
139$$r_A \cdot \bar{A}(r_x) + r_B \cdot \bar{B}(r_x) + r_C \cdot \bar{C}(r_x) == c$$
140
141
142Let $L(r_x) = r_A \cdot \bar{A}(r_x) +r_B \cdot \bar{B}(r_x) +r_C \cdot \bar{C}(r_x)$,
143
144\begin{align*}
145 L(r_x) &= \sum_{y \in \{0,1\}^s}
146 r_A \cdot \widetilde{A}(r_x, y) \cdot \widetilde{Z}(y)
147+ r_B \cdot \widetilde{B}(r_x, y) \cdot \widetilde{Z}(y)
148+ r_C \cdot \widetilde{C}(r_x, y) \cdot \widetilde{Z}(y)\\
149 &= \sum_{y \in \{0,1\}^s} M_{r_x}(y)
150\end{align*}
151
152$M_{r_x}(y)$ is a s-variate polynomial with deg $\leq 2$ in each variable ($\Longleftrightarrow \mu = s,~ l=2,~ T=c$).
153
154
155\begin{align*}
156M_{r_x}(r_y) &=
157r_A \cdot \widetilde{A}(r_x, r_y) \cdot \widetilde{Z}(r_y)
158+ r_B \cdot \widetilde{B}(r_x, r_y) \cdot \widetilde{Z}(r_y)
159+ r_C \cdot \widetilde{C}(r_x, r_y) \cdot \widetilde{Z}(r_y)\\
160 &=
161 (r_A \cdot \widetilde{A}(r_x, r_y)
162+ r_B \cdot \widetilde{B}(r_x, r_y)
163+ r_C \cdot \widetilde{C}(r_x, r_y)) \cdot \widetilde{Z}(r_y)\\
164\end{align*}
165
166only one term in $M_{r_x}(r_y)$ depends on prover's witness: $\widetilde{Z}(r_y)$
167
168P sends a commitment to $\widetilde{w}(\cdot)$ (= MLE of the witness $w$) to V before the first instance of the sum-check protocol.
169
170
171\subsection{Full protocol}
172
173\begin{itemize}
174 \item $pp \leftarrow Setup(1^{\lambda})$: invoke $pp \leftarrow PC.Setup(1^{\lambda}, log m)$; output $pp$
175 \item $b \leftarrow <P(w), V(r)>(\mathbb{F}, A,B,C, io, m, n)$:
176 \begin{enumerate}
177 \item P: $(C, S) \leftarrow PC.Commit(pp, \widetilde{w})$ and send $C$ to V
178 \item V: send $\tau \in^R \mathbb{F}^{log~m}$ to P
179 \item let $T_1=0,~ \mu_1=log~m,~ l_1=3$
180 \item V: set $r_x \in^R \mathbb{F}^{\mu_1}$
181 \item Sum-check 1. $e_x \leftarrow <P_{SC}(G_{io,\tau}), V_{SC}(r_x)>(\mu_1, l_1, T_1)$
182 \item P: compute $v_A=\overline{A}(r_x),~ v_B=\overline{B}(r_x),~ v_C=\overline{C}(r_x)$, send $(v_A, v_B, v_C)$ to V
183 \item V: abort with $b=0$ if $e_x \neq (v_A \cdot v_B - v_C)\cdot \widetilde{eq}(r_x, \tau)$
184 \item V: send $r_A, r_B, r_C \in^R \mathbb{F}$ to P
185 \item let $T_2 = r_A \cdot v_A + r_B \cdot v_B + r_C \cdot v_C,~ \mu_2=log~m,~ l_2=2$
186 \item V: set $r_y \in^R \mathbb{F}^{\mu_2}$
187 \item Sum-check 2. $e_y \leftarrow <P_{SC}(M_{r_x}), V_{SC}(r_y)>(\mu_2, l_2, T_2)$
188 \item P: $v \leftarrow \widetilde{w}(r_y[1..])$, send $v$ to V
189 \item $b_e \leftarrow <P_{PC.Eval}(\widetilde{w}, S), V_{PC.Eval}(r)>(pp, C, r_y, v, \mu_2)$
190 \item V: abourt with $b=0$ if $b_e==0$
191 \item V: $v_z \leftarrow (1 - r_y[0]) \cdot \widetilde{w}(r_y [1..]) + r_y[0] \widetilde{(io, 1)} (r_y[1..])$
192 \item V: $v_1 \leftarrow \widetilde{A}(r_x, r_y),~ v_2 \leftarrow \widetilde{B}(r_x, r_y),~ v_3 \leftarrow \widetilde{C}(r_x, r_y)$
193 \item V: abort with $b=0$ if $e_y \neq (r_A v_1 + r_B v_2 + r_C v_3) \cdot v_z$
194 \item V: output $b=1$
195 \end{enumerate}
196\end{itemize}
197
198\vspace{2cm}
199\framebox{WIP: covered until sec.6}
200
201
202
203\bibliography{paper-notes.bib}
204\bibliographystyle{unsrt}
205
206\end{document}