arnaucube
arnaucube/mathPublic Self-hosted repository
math/notes_fri.tex
notes_fri.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
 11% prevent warnings of underfull \hbox:
 12\usepackage{etoolbox}
 13\apptocmd{\sloppy}{\hbadness 4000\relax}{}{}
 14
 15\theoremstyle{definition}
 16\newtheorem{definition}{Def}[section]
 17\newtheorem{theorem}[definition]{Thm}
 18
 19% custom lemma environment to set custom numbers
 20\newtheorem{innerlemma}{Lemma}
 21\newenvironment{lemma}[1]
 22{\renewcommand\theinnerlemma{#1}\innerlemma}
 23{\endinnerlemma}
 24
 25
 26\title{Notes on FRI}
 27\author{arnaucube}
 28\date{February 2023}
 29
 30\begin{document}
 31
 32\maketitle
 33
 34\begin{abstract}
 35	Notes taken from \href{https://sites.google.com/site/vincenzoiovinoit/}{Vincenzo Iovino} \cite{vincenzoiovino} explainations about FRI \cite{fri}, \cite{cryptoeprint:2022/1216}, \cite{cryptoeprint:2019/1020}.
 36
 37	These notes are for self-consumption, are not complete, don't include all the steps neither all the proofs.
 38
 39	An implementation of FRI can be found at\\ \href{https://github.com/arnaucube/fri-commitment}{https://github.com/arnaucube/fri-commitment} \cite{fri-impl}.
 40\end{abstract}
 41
 42\tableofcontents
 43
 44\section{Preliminaries}
 45\subsection{General degree d test}
 46
 47Query at points $\{ x_i \}_0^{d+1},~z$ (with rand $z \overset{R}{\in} \mathbb{F}$).
 48Interpolate $p(x)$ at $\{f(x_i)\}_0^{d+1}$ to reconstruct the unique polynomial $p$ of degree $d$ such that $p(x_i)=f(x_i)~\forall i=1, \ldots, d+1$.
 49
 50V checks $p(z)=f(z)$, if the check passes, then V is convinced with high probability.
 51
 52This needs $d+2$ queries, is linear, $\mathcal{O}(n)$. With FRI we will have the test in $\mathcal{O}(\log{}d)$.
 53
 54\section{FRI protocol}
 55Allows to test if a function $f$ is a poly of degree $\leq d$ in $\mathcal{O}(\log{}d)$.
 56
 57Note: "P \emph{sends} $f(x)$ to V", "\emph{sends}", in the ideal IOP model means that all the table of $f(x)$ is sent, in practice is sent a commitment to $f(x)$.
 58
 59\subsection{Intuition}
 60V wants to check that two functions $g,~h$ are both polynomials of degree $\leq d$.
 61
 62Consider the following protocol:
 63
 64\begin{enumerate}
 65	\item V sends $\alpha \in \mathbb{F}$ to P. P sends $f(x) = g(x) + \alpha h(x)$ to V.
 66	\item P sends $f(x)=g(x) + \alpha h(x)$ to V.
 67	\item V queries $f(r), ~g(r), ~h(r)$ for rand $r \in \mathbb{F}$.
 68	\item V checks $f(r)=g(r) + \alpha h(r)$. (Schwartz-Zippel lema).
 69		If holds, V can be certain that $f(x)=g(x)+ \alpha h(x)$.
 70	\item P proves that $deg(f) \leq d$. 
 71	\item If V is convinced that $deg(f) \leq d$, V belives that both $g, h$ have $deg \leq d$.
 72\end{enumerate}
 73
 74%/// TODO tabulate this next lines
 75With high probablility, $\alpha$ will not cancel the coeffs with $deg \geq d+1$. % TODO check which is the name of this theorem or why this is true
 76
 77Let $g(x)=a \cdot x^{d+1}, ~~ h(x)=b \cdot x^{d+1}$, and set $f(x) = g(x) + \alpha h(x)$.
 78Imagine that P can chose $\alpha$ such that $a x^{d+1} + \alpha \cdot b x^{d+1} = 0$, then, in $f(x)$ the coefficients of degree $d+1$ would cancel.
 79%///
 80
 81\quad
 82
 83Here, P proves $g,~h$ both have $deg \leq d$, but instead of doing $2 \cdot (d+2)$ queries ($d+2$ for $g$, and $d+2$ for $h$), it is done in $d+2$ queries (for $f$).
 84So we halved the number of queries.
 85
 86
 87\subsection{FRI-LDT}\label{sec:fri-ldt}
 88FRI low degree testing.\\
 89Both P and V have oracle access to function $f$.
 90
 91V wants to test if $f$ is polynomial with $deg(f) \leq d$.
 92
 93Let $f_0(x)=f(x)$.
 94
 95Each polynomial $f(x)$ of degree that is a power of $2$, can be written as
 96$$f(x) = f^L(x^2) + x f^R(x^2)$$
 97for some polynomials $f^L,~f^R$ of degree $\frac{deg(f)}{2}$, each one containing the even and odd degree coefficients as follows:
 98
 99% $f^L(x)$ is built from the even degree coefficients divided by $x$, and $f^R(x)$ from the odd degree coefficients divided by $x$.
100
101$$f^L(x)= \sum_0^{\frac{d+1}{2}-1} c_{2i} x^i ,~~ f^R(x)= \sum_0^{\frac{d+1}{2}-1} c_{2i+1} x^i$$
102
103eg. for $f(x)=x^4+x^3+x^2+x+1$,
104\begin{align*}
105	\begin{rcases}
106	f^L(x)=x^2+x+1\\
107	f^R(x)=x+1
108	\end{rcases}
109	~f(x) = f^L(x^2) &+ x \cdot f^R(x^2)\\
110	= (x^2)^2 + (x^2) + 1 &+ x \cdot ((x^2) + 1)\\
111	= x^4 + x^2 + 1 &+ x^3 + x
112\end{align*}
113
114% \begin{enumerate}
115%         \item V sends to P some $\alpha_0 \in \mathbb{F}$.
116%                 Let
117%                 \begin{equation}\tag{$A_0$}
118%                         f_0(x) = f_0^L(x^2) + x f_0^R(x^2)
119%                 \end{equation}
120%         \item P sends
121%                 \begin{equation}\tag{$B_0$}
122%                         f_1(x) = f_0^L(x) + \alpha_0 f_0^R(x)
123%                 \end{equation}
124%                 to V.
125% 
126%                 (remember that "sends" in IOP model is that P commits to it)
127%         \item V sends to P some $\alpha_1 \in \mathbb{F}$.
128%                 Let
129%                 \begin{equation}\tag{$A_1$}
130%                         f_1(x) = f_1^L(x^2) + x f_1^R(x^2)
131%                 \end{equation}
132%         \item P sends
133%                 \begin{equation}\tag{$B_1$}
134%                         f_2(x) = f_1^L(x) + \alpha_1 f_1^R(x)
135%                 \end{equation}
136%                 to V.
137%         \item Keep repeating the process, eg. let
138%                 \begin{equation}\tag{$A_2$}
139%                         f_2(x) = f_2^L(x^2) + x f_2^R(x^2)
140%                 \end{equation}
141%                 until $f_i^L,~ f_i^R$ are constant (degree 0 polynomials).
142%         \item Once $f_i^L,~ f_i^R$ are constant, P sends them to V.
143% \end{enumerate}
144% 
145% Notice that at each step, $deg(f_i)$ halves.
146
147
148\vspace{30px}
149
150\paragraph{Proof generation}
151
152\emph{(Commitment phase)}
153P starts from $f(x)$, and for $i=0$ sets $f_0(x)=f(x)$.
154\begin{enumerate}
155	\item $\forall~i \in \{0, log(d)\}$, with $d = deg~f(x)$,\\
156		P computes $f_i^L(x),~ f_i^R(x)$ for which
157		\begin{equation}\tag{eq. $A_i$}
158			f_i(x) = f_i^L(x^2) + x f_i^R(x^2)
159		\end{equation}
160		holds.
161	\item V sends challenge $\alpha_i \in \mathbb{F}$
162	\item P commits to the random linear combination $f_{i+1}$, for
163		\begin{equation}\tag{eq. $B_i$}
164		f_{i+1}(x) = f_i^L(x) + \alpha_i f_i^R(x)
165	\end{equation}
166	\item P sets $f_i(x) := f_{i+1}(x)$ and starts again the iteration.
167\end{enumerate}
168Notice that at each step, $deg(f_i)$ halves.
169
170This is done until the last step, where $f_i^L(x),~ f_i^R(x)$ are constant (degree 0 polynomials). For which P does not commit but gives their values directly to V.
171
172\emph{(Query phase)}
173P would receive a challenge $z \in D$ set by V (where $D$ is the evaluation domain, $D \in \mathbb{F}$), and P would open the commitments at $\{z^{2^i}, -z^{2^i}\}$ for each step $i$.
174(Recall, "opening" means that would provide a proof (MerkleProof) of it).
175
176\paragraph{Data sent from P to V}
177\begin{itemize}
178	\item[] Commitments: $\{Comm(f_i)\}_0^{log(d)}$\\
179		{\scriptsize eg. $\{Comm(f_0),~ Comm(f_1),~ Comm(f_2),~ ...,~ Comm(f_{log(d)})\}$ }
180	\item[] Openings: $\{ f_i(z^{2^i}),~f_i(-(z^{2^i})) \}_0^{log(d)}$\\
181		for a challenge $z \in D$ set by V\\
182		{\scriptsize eg. $f_0(z),~ f_0(-z),~ f_1(z^2),~ f_1(-z^2),~ f_2(z^4),~ f_2(-z^4),~ f_3(z^8),~ f_3(-z^8),~ \ldots$}
183	\item[] Constant values of last iteration: $\{f_k^L,~f_k^R\}$, for $k=log(d)$
184\end{itemize}
185
186\paragraph{Verification}
187
188V receives:
189\begin{align*}
190	\text{Commitments:}~ &Comm(f_i),~ \forall i \in \{0, log(d)\}\\
191	\text{Openings:}~ &\{o_i, o_i'\}=\{ f_i(z^{2^i}),~f_i(-(z^{2^i})) \},~ \forall i \in \{0, log(d)\}\\
192	\text{Constant vals:}~ &\{f_k^L,~f_k^R\}
193\end{align*}
194
195\vspace{20px}
196
197For all $i \in \{0, log(d)\}$, V knows the openings at $z^{2^i}$ and $-(z^{2^i})$ for\\
198$Comm(f_i(x))$, which are $o_i=f_i(z^{2^i})$ and $o_i'=f_i(-(z^{2^i}))$ respectively.
199
200V, from (eq. $A_i$), knows that
201$$f_i(x)=f_i^L(x^2) + x f_i^R(x^2)$$
202should hold, thus
203$$f_i(z)=f_i^L(z^2) + z f_i^R(z^2)$$
204where $f_i(z)$ is known, but $f_i^L(z^2),~f_i^R(z^2)$ are unknown.
205But, V also knows the value for $f_i(-z)$, which can be represented as
206$$f_i(-z)=f_i^L(z^2) - z f_i^R(z^2)$$
207(note that when replacing $x$ by $-z$, it loses the negative in the power, not in the linear combination).
208
209Thus, we have the system of independent linear equations
210\begin{align*} % TODO add braces on left
211	f_i(z)&=f_i^L(z^2) + z f_i^R(z^2)\\
212	f_i(-z)&=f_i^L(z^2) - z f_i^R(z^2)
213\end{align*}
214for which V will find the value of $f_i^L(z^{2^i}),~f_i^R(z^{2^i})$.
215Equivalently it can be represented by
216$$
217\begin{pmatrix}
218	1 & z\\
219	1 & -z
220\end{pmatrix}
221\begin{pmatrix}
222	f_i^L(z^2)\\
223	f_i^R(z^2)
224\end{pmatrix}
225=
226\begin{pmatrix}
227	f_i(z)\\
228	f_i(-z)
229\end{pmatrix}
230$$
231where V will find the values of $f_i^L(z^{2^i}),~f_i^R(z^{2^i})$ being
232\begin{align*}
233	f_i^L(z^{2^i})=\frac{f_i(z) + f_i(-z)}{2}\\
234	f_i^R(z^{2^i})=\frac{f_i(z) - f_i(-z)}{2z}\\
235\end{align*}
236
237Once, V has computed $f_i^L(z^{2^i}),~f_i^R(z^{2^i})$, can use them to compute the linear combination of
238$$
239f_{i+1}(z^{2^i}) = f_i^L(z^{2^i}) + \alpha_i f_i^R(z^{2^i})
240$$
241obtaining then $f_{i+1}(z^{2^i})$. This comes from (eq. $B_i$).
242
243Now, V checks that the obtained $f_{i+1}(z^{2^i})$ is equal to the received opening $o_{i+1}=f_{i+1}(z^{2^i})$ from the commitment done by P.
244V checks also the commitment of $Comm(f_{i+1}(x))$ for the opening $o_{i+1}=f_{i+1}(z^{2^i})$.\\
245If the checks pass, V is convinced that $f_1(x)$ was committed honestly.
246
247Now, sets $i := i+1$ and starts a new iteration.
248
249For the last iteration, V checks that the obtained $f_i^L(z^{2^i}),~f_i^R(z^{2^i})$ are equal to the constant values $\{f_k^L,~f_k^R\}$ received from P.
250
251\vspace{10px}
252It needs $log(d)$ iterations, and the number of queries (commitments + openings sent and verified) needed is $2 \cdot log(d)$.
253
254\subsection{Parameters}
255
256P commits to $f_i$ restricted to a subfield $F_0 \subset \mathbb{F}$.
257Let $0<\rho<1$ be the \emph{rate} of the code, such that
258$$|F_0| = \rho^{-1} \cdot d$$
259
260\begin{theorem}
261	For $\delta \in (0, 1-\sqrt{\rho})$, we have that if V accepts, then w.v.h.p. (with very high probability) $\Delta(f_0,~ p^d) \leq \delta$.
262\end{theorem}
263
264\section{FRI as polynomial commitment scheme}
265This section overviews the trick from \cite{cryptoeprint:2019/1020} to convert FRI into a polynomial commitment.
266
267Want to check that the evaluation of $f(x)$ at $r$ is $f(r)$, which is equivalent to proving that $\exists ~Q \in \mathbb{F}[x]$ with $deg(Q)=d-1$, such that
268
269$$
270f(x)-f(r) = Q(x) \cdot (x-r)
271$$
272
273note that $f(x)-f(r)$ evaluated at $r$ is $0$, so $(x-r) | (f(x)-f(r))$, in other words
274$(f(x)-f(r))$ is a multiple of $(x-r)$ for a polynomial $Q(x)$.
275
276Let us define $g(x) = \frac{f(x)-f(r)}{x-r}$.
277
278Prover uses FRI-LDT \ref{sec:fri-ldt} to commit to $g(x)$, and then prove w.v.h.p that $deg(g) \leq d-1$ ($\Longleftrightarrow \Delta(g,~ p^{d-1} \leq \delta$).
279
280Prover was already proving that $deg(f) \leq d$.
281
282Now, the missing thing to prove is that $g(x)$ has the right shape. We can relate $g$ to $f$ as follows:
283V does the normal FRI-LDT, but in addition, at the first iteration:
284V has $f(z)$ and $g(z)$ openings, so can verify
285$$g(z) = (f(z)-f(r))\cdot (z-r)^{-1}$$
286
287
288\bibliography{paper-notes.bib}
289\bibliographystyle{unsrt}
290
291\end{document}