arnaucube
arnaucube/mathPublic Self-hosted repository
math/notes_hypernova.tex
notes_hypernova.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{centernot}
 11\usepackage{algorithm}
 12\usepackage{algpseudocode}
 13
 14\usepackage{pgf-umlsd} % diagrams
 15
 16% message between threads. From https://tex.stackexchange.com/a/174765
 17% Example:
 18% \bloodymess[delay]{sender}{message content}{receiver}{DIR}{start note}{end note}
 19\newcommand{\bloodymess}[7][0]{
 20  \stepcounter{seqlevel}
 21  \path
 22  (#2)+(0,-\theseqlevel*\unitfactor-0.7*\unitfactor) node (mess from) {};
 23  \addtocounter{seqlevel}{#1}
 24  \path
 25  (#4)+(0,-\theseqlevel*\unitfactor-0.7*\unitfactor) node (mess to) {};
 26  \draw[->,>=angle 60] (mess from) -- (mess to) node[midway, above]
 27  {#3};
 28
 29  \if R#5
 30  \node (\detokenize{#3} from) at (mess from) {\llap{#6~}};
 31  \node (\detokenize{#3} to) at (mess to) {\rlap{~#7}};
 32  \else\if L#5
 33  \node (\detokenize{#3} from) at (mess from) {\rlap{~#6}};
 34  \node (\detokenize{#3} to) at (mess to) {\llap{#7~}};
 35       \else
 36       \node (\detokenize{#3} from) at (mess from) {#6};
 37       \node (\detokenize{#3} to) at (mess to) {#7};
 38       \fi
 39  \fi
 40}
 41
 42
 43% prevent warnings of underfull \hbox:
 44\usepackage{etoolbox}
 45\apptocmd{\sloppy}{\hbadness 4000\relax}{}{}
 46
 47\theoremstyle{definition}
 48\newtheorem{definition}{Def}[section]
 49\newtheorem{theorem}[definition]{Thm}
 50
 51% custom lemma environment to set custom numbers
 52\newtheorem{innerlemma}{Lemma}
 53\newenvironment{lemma}[1]
 54{\renewcommand\theinnerlemma{#1}\innerlemma}
 55{\endinnerlemma}
 56
 57
 58\title{Notes on HyperNova}
 59\author{arnaucube}
 60\date{May 2023}
 61
 62\begin{document}
 63
 64\maketitle
 65
 66\begin{abstract}
 67	Notes taken while reading about HyperNova \cite{cryptoeprint:2023/573} and CCS\cite{cryptoeprint:2023/552}.
 68
 69	Usually while reading papers I take handwritten notes, this document contains some of them re-written to $LaTeX$.
 70
 71	The notes are not complete, don't include all the steps neither all the proofs.
 72\end{abstract}
 73
 74\tableofcontents
 75
 76
 77\section{CCS}
 78\subsection{R1CS to CCS overview}
 79
 80\begin{description}
 81	\item[R1CS instance] $S_{R1CS} = (m, n, N, l, A, B, C)$\\
 82		where $m, n$ are such that $A \in \mathbb{F}^{m \times n}$, and $l$ such that the public inputs $x \in \mathbb{F}^l$. Also $z=(w, 1, x) \in \mathbb{F}^n$, thus $w \in \mathbb{F}^{n-l-1}$.
 83	\item[CCS instance] $S_{CCS} = (m, n, N, l, t, q, d, M, S, c)$\\
 84		where we have the same parameters than in $S_{R1CS}$, but additionally:\\
 85		$t=|M|$, $q = |c| = |S|$, $d$= max degree in each variable.
 86	\item[R1CS-to-CCS parameters] $n=n,~ m=m,~ N=N,~ l=l,~ t=3,~ q=2,~ d=2$, $M=\{A,B,C\}$, $S=\{\{0,~1\},~ \{2\}\}$, $c=\{1,-1\}$
 87\end{description}
 88
 89The CCS relation check:
 90$$\sum_{i=0}^{q-1} c_i \cdot \bigcirc_{j \in S_i} M_j \cdot z ==0$$
 91
 92where $z=(w, 1, x) \in \mathbb{F}^n$.
 93
 94In our R1CS-to-CCS parameters is equivalent to
 95
 96\begin{align*}
 97	&c_0 \cdot ( (M_0 z) \circ (M_1 z) ) + c_1 \cdot (M_2 z) ==0\\
 98	\Longrightarrow &1 \cdot ( (A z) \circ (B z) ) + (-1) \cdot (C z) ==0\\
 99	\Longrightarrow &( (A z) \circ (B z) ) - (C z) ==0
100\end{align*}
101
102which is equivalent to the R1CS relation: $Az \circ Bz == Cz$
103
104An example of the conversion from R1CS to CCS implemented in SageMath can be found at\\
105\href{https://github.com/arnaucube/math/blob/master/r1cs-ccs.sage}{https://github.com/arnaucube/math/blob/master/r1cs-ccs.sage}.
106
107Similar relations between Plonkish and AIR arithmetizations to CCS are shown in the CCS paper \cite{cryptoeprint:2023/552}, but for now with the R1CS we have enough to see the CCS generalization idea and to use it for the HyperNova scheme.
108
109\subsection{Committed CCS}
110$R_{CCCS}$ instance: $(C, \mathsf{x})$, where $C$ is a commitment to a multilinear polynomial in $s'-1$ variables.
111
112Sat if:
113\begin{enumerate}[i.]
114	\item $\text{Commit}(pp, \widetilde{w}) = C$
115	\item $\sum_{i=1}^q c_i \cdot \left( \prod_{j \in S_i} \left( \sum_{y \in \{0,1\}^{\log m}} \widetilde{M}_j(x, y) \cdot \widetilde{z}(y) \right) \right)$\\
116		where $\widetilde{z}(y) = \widetilde{(w, 1, \mathsf{x})}(x) ~\forall x \in \{0, 1\}^{s'}$
117\end{enumerate}
118
119
120\subsection{Linearized Committed CCS}
121$R_{LCCCS}$ instance: $(C, u, \mathsf{x}, r, v_1, \ldots, v_t)$, where $C$ is a commitment to a multilinear polynomial in $s'-1$ variables, and $u \in \mathbb{F},~ \mathsf{x} \in \mathbb{F}^l,~ r \in \mathbb{F}^s,~ v_i \in \mathbb{F} ~\forall i \in [t]$.
122
123Sat if:
124\begin{enumerate}[i.]
125	\item $\text{Commit}(pp, \widetilde{w}) = C$
126	\item $\forall i \in [t],~ v_i = \sum_{y \in \{0,1\}^{s'}} \widetilde{M}_i(r, y) \cdot \widetilde{z}(y)$\\
127		where $\widetilde{z}(y) = \widetilde{(w, u, \mathsf{x})}(x) ~\forall x \in \{0, 1\}^{s'}$
128\end{enumerate}
129
130
131\section{Multifolding Scheme for CCS}
132Recall sum-check protocol notation: \underline{$C \leftarrow \langle P, V(r) \rangle (g, l, d, T)$} means
133$$T=\sum_{x_1 \in \{0,1\}} \sum_{x_2 \in \{0,1\}} \cdots \sum_{x_l \in \{0,1\}} g(x_1, x_2, \ldots, x_l)$$
134where $g$ is a $l$-variate polynomial, with degree at most $d$ in each variable, and $T$ is the claimed value.
135
136\vspace{1cm}
137
138Let $s= \log m,~ s'= \log n$.
139
140\begin{enumerate}
141	\item $V \rightarrow P: \gamma \in^R \mathbb{F},~ \beta \in^R \mathbb{F}^s$
142	\item $V: r_x' \in^R \mathbb{F}^s$
143	\item $V \leftrightarrow P$: sum-check protocol:
144		$$c \leftarrow \langle P, V(r_x') \rangle (g, s, d+1, \underbrace{\sum_{j \in [t]} \gamma^j \cdot v_j}_\text{T})$$
145		(in fact, $T=(\sum_{j \in [t]} \gamma^j \cdot v_j) \underbrace{+ \gamma^{t+1} \cdot Q(x)}_{=0}) = \sum_{j \in [t]} \gamma^j \cdot v_j$)\\
146		where:
147		\begin{align*}
148			g(x) &:= \underbrace{\left( \sum_{j \in [t]} \gamma^j \cdot L_j(x) \right)}_\text{LCCCS check} + \underbrace{\gamma^{t+1} \cdot Q(x)}_\text{CCCS check}\\
149			\text{for LCCCS:}~ L_j(x) &:= \widetilde{eq}(r_x, x) \cdot \left(
150				\underbrace{\sum_{y \in \{0,1\}^{s'}} \widetilde{M}_j(x, y) \cdot \widetilde{z}_1(y)}_\text{this is the check from LCCCS}
151			\right)\\
152				\text{for CCCS:}~ Q(x) := &\widetilde{eq}(\beta, x) \cdot \left(
153				\underbrace{ \sum_{i=1}^q c_i \cdot \prod_{j \in S_i} \left( \sum_{y \in \{0, 1\}^{s'}} \widetilde{M}_j(x, y) \cdot \widetilde{z}_2(y) \right) }_\text{this is the check from CCCS}
154			\right)
155		\end{align*}
156		Notice that
157		$$v_j= \sum_{y\in \{0,1\}^{s'}} \widetilde{M}_j(r, y) \cdot \widetilde{z}(y) = \sum_{x\in \{0,1\}^s} L_j(x)$$
158	\item $P \rightarrow V$: $\left( (\sigma_1, \ldots, \sigma_t), (\theta_1, \ldots, \theta_t) \right)$, where $\forall j \in [t]$,
159		$$\sigma_j = \sum_{y \in \{0,1\}^{s'}} \widetilde{M}_j(r_x', y) \cdot \widetilde{z}_1(y)$$
160		$$\theta_j = \sum_{y \in \{0, 1\}^{s'}} \widetilde{M}_j(r_x', y) \cdot \widetilde{z}_2(y)$$
161		where $\sigma_j,~\theta_j$ are the checks from LCCCS and CCCS respectively with $x=r_x'$.
162	\item V: $e_1 \leftarrow \widetilde{eq}(r_x, r_x')$, $e_2 \leftarrow \widetilde{eq}(\beta, r_x')$\\
163		check:
164		$$c = \left( \sum_{j \in [t]} \gamma^j e_1 \sigma_j + \gamma^{t+1} e_2 \left( \sum_{i=1}^q c_i \cdot \prod_{j \in S_i} \sigma \right) \right)$$
165		which should be equivalent to the $g(x)$ computed by $V,P$ in the sum-check protocol.
166	\item $V \rightarrow P: \rho \in^R \mathbb{F}$
167	\item $V, P$: output the folded LCCCS instance $(C', u', \mathsf{x}', r_x', v_1', \ldots, v_t')$, where $\forall i \in [t]$:
168		\begin{align*}
169			C' &\leftarrow C_1 + \rho \cdot C_2\\
170			u' &\leftarrow u + \rho \cdot 1\\
171			\mathsf{x}' &\leftarrow \mathsf{x}_1 + \rho \cdot \mathsf{x}_2\\
172			v_i' &\leftarrow \sigma_i + \rho \cdot \theta_i
173		\end{align*}
174	\item $P$: output folded witness: $\widetilde{w}' \leftarrow \widetilde{w}_1 + \rho \cdot \widetilde{w}_2$.
175\end{enumerate}
176
177
178\vspace{1cm}
179Multifolding flow:
180\begin{center}
181	\begin{sequencediagram}
182		\newinst[1]{p}{Prover}
183		\newinst[3]{v}{Verifier}
184
185		\bloodymess[1]{v}{$\gamma,~\beta,~r_x'$}{p}{L}{
186			\shortstack{
187				$\gamma \in \mathbb{F},~ \beta \in \mathbb{F}^s$\\
188				$r_x' \in \mathbb{F}^s$
189			}
190		}{}
191		\bloodymess[1]{p}{$c,~ \pi_{SC}$}{v}{R}{sum-check prove}{sum-check verify}
192		\bloodymess[1]{p}{$\{\sigma_j\},~\{\theta_j\}$}{v}{R}{compute $\{\sigma_j\}, \{\theta_j\}~ \forall j \in [t]$}{verify $c$ with $\{\sigma_j\}, \{\theta_j\}$ relation}
193		\bloodymess[1]{v}{$\rho$}{p}{L}{$\rho \in^R \mathbb{F}$}{}
194		\callself[0]{p}{fold LCCCS instance}{p}
195		\prelevel
196		\callself[0]{v}{fold LCCCS instance}{v}
197		\callself[0]{p}{fold $\widetilde{w}$}{p}
198	\end{sequencediagram}
199\end{center}
200
201\vspace{1cm}
202
203Now, to see the verifier check from step 5, observe that in LCCCS, since $\widetilde{w}$ satisfies,
204\begin{align*}
205	v_j &= \sum_{y \in \{0,1\}^{s'}} \widetilde{M}_j(r_x, y) \cdot \widetilde{z}_1(y)\\
206	    &= \sum_{x \in \{0,1\}^s}
207		\underbrace{
208			\widetilde{eq}(r_x, x) \cdot \left( \sum_{y \in \{0,1\}^{s'}} \widetilde{M}_j(x, y) \cdot \widetilde{z}_1(y) \right)
209		}_{L_j(x)}\\
210	    &= \sum_{x \in \{0,1\}^s} L_j(x)
211\end{align*}
212
213Observe also that in CCCS, since $\widetilde{w}$ satisfies,
214$$
2150=\sum_{i=1}^q c_i \cdot \prod_{j \in S_i} \left( \sum_{y \in \{0, 1\}^{s'}} \widetilde{M}_j(x, y) \cdot \widetilde{z}_2(y) \right)
216$$
217for $\beta$,
218\begin{align*}
219	0&=\sum_{i=1}^q c_i \cdot \prod_{j \in S_i} \left( \sum_{y \in \{0, 1\}^{s'}} \widetilde{M}_j(\beta, y) \cdot \widetilde{z}_2(y) \right)\\
220	 &= \sum_{x \in \{0,1\}^s}
221	 \underbrace{\widetilde{eq}(\beta , x) \cdot
222		\sum_{i=1}^q c_i \cdot \prod_{j \in S_i} \left( \sum_{y \in \{0, 1\}^{s'}} \widetilde{M}_j(x, y) \cdot \widetilde{z}_2(y) \right)
223	}_{Q(x)}\\
224	 &= \sum_{x \in \{0,1\}^s} Q(x)
225\end{align*}
226
227Then we can see that
228
229\begin{align*}
230	c &= g(r_x')\\
231	  &= \left( \sum_{j \in [t]} \gamma^j \cdot L_j(r_x') \right) + \gamma^{t+1} \cdot Q(r_x')\\
232	  &= \left( \sum_{j \in [t]} \gamma^j \cdot \overbrace{e_1 \cdot \sigma_j}^{L_j(r_x')} \right) + \gamma^{t+1} \cdot \overbrace{e_2 \cdot \sum_{i \in [q]} c_i \prod_{j \in S_i} \theta_j}^{Q(x)}
233\end{align*}
234
235where $e_1 = \widetilde{eq}(r_x, r_x')$ and $e_2=\widetilde{eq}(\beta, r_x')$.
236
237Which is the check that $V$ performs at step $5$.
238
239
240
241%%%%%% APPENDIX
242\appendix
243\section{Appendix: Some details}
244This appendix contains some notes on things that don't specifically appear in the paper, but that would be needed in a practical implementation of the scheme.
245
246\subsection{Matrix and Vector to Sparse Multilinear Extension}
247
248Let $M \in \mathbb{F}^{m \times n}$ be a matrix. We want to compute its MLE
249$$\widetilde{M}(x_1, \ldots, x_l) = \sum_{e \in \{0, 1 \}^l} M(e) \cdot \widetilde{eq}(x, e)$$
250
251We can view the matrix $M \in \mathbb{F}^{m \times n}$ as a function with the following signature:
252$$M(\cdot): \{0,1\}^s \times \{0,1\}^{s'} \rightarrow \mathbb{F}$$
253where $s = \lceil \log m \rceil,~ s' = \lceil \log n \rceil$.
254
255An entry in $M$ can be accessed with a $(s+s')$-bit identifier.
256
257eg.:
258$$
259M = \begin{pmatrix}
2601 & 2 & 3\\
2614 & 5 & 6\\
262\end{pmatrix}
263\in \mathbb{F}^{3 \times 2}
264$$
265
266$m = 3,~ n = 2,~~~ s = \lceil \log 3 \rceil = 2,~ s' = \lceil \log 2 \rceil = 1$
267
268So, $M(x, y) = x$, where $x \in \{0,1\}^s,~ y \in \{0,1\}^{s'},~ x \in \mathbb{F}$
269
270$$
271M = \begin{pmatrix}
272M(00,0) & M(01,0) & M(10,0)\\
273M(00,1) & M(01,1) & M(10,1)\\
274\end{pmatrix}
275\in \mathbb{F}^{3 \times 2}
276$$
277
278This logic can be defined as follows:
279
280\begin{algorithm}[H]
281\caption{Generating a Sparse Multilinear Polynomial from a matrix}
282\begin{algorithmic}
283	\State set empty vector $v \in (\text{index:}~ \mathbb{Z}, x: \mathbb{F}^{s \times s'})$
284	\For {$i$ to $m$}
285	\For {$j$ to $n$}
286		\If {$M_{i,j} \neq 0$}
287			\State $v.\text{append}( \{ \text{index}: i \cdot n + j,~ x: M_{i,j} \} )$
288		\EndIf
289	\EndFor
290	\EndFor
291	\State return $v$    \Comment {$v$ represents the evaluations of the polynomial}
292\end{algorithmic}
293\end{algorithm}
294
295Once we have the polynomial, its MLE comes from
296$$\widetilde{M}(x_1, \ldots, x_{s+s'}) = \sum_{e \in \{0,1\}^{s+s'}} M(e) \cdot \widetilde{eq}(x, e)$$
297
298$$M(X) \in \mathbb{F}[X_1, \ldots, X_s]$$
299
300\paragraph{Multilinear extensions of vectors}
301Given a vector $u \in \mathbb{F}^m$, the polynomial $\widetilde{u}$ is the MLE of $u$, and is obtained by viewing $u$ as a function mapping ($s=\log m$)
302$$u(x): \{0,1\}^s \rightarrow \mathbb{F}$$
303$\widetilde{u}(x, e)$ is the multilinear extension of the function $u(x)$
304$$\widetilde{u}(x_1, \ldots, x_s) = \sum_{e \in \{0,1\}^s} u(e) \cdot \widetilde{eq}(x, e)$$
305
306\bibliography{paper-notes.bib}
307\bibliographystyle{unsrt}
308
309\end{document}