You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

335 lines
12 KiB

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