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.

344 lines
13 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. % message between threads
  12. % Example:
  13. % \bloodymess[delay]{sender}{message content}{receiver}{DIR}{start note}{end note}
  14. \newcommand{\bloodymess}[7][0]{
  15. \stepcounter{seqlevel}
  16. \path
  17. (#2)+(0,-\theseqlevel*\unitfactor-0.7*\unitfactor) node (mess from) {};
  18. \addtocounter{seqlevel}{#1}
  19. \path
  20. (#4)+(0,-\theseqlevel*\unitfactor-0.7*\unitfactor) node (mess to) {};
  21. \draw[->,>=angle 60] (mess from) -- (mess to) node[midway, above]
  22. {#3};
  23. \if R#5
  24. \node (\detokenize{#3} from) at (mess from) {\llap{#6~}};
  25. \node (\detokenize{#3} to) at (mess to) {\rlap{~#7}};
  26. \else\if L#5
  27. \node (\detokenize{#3} from) at (mess from) {\rlap{~#6}};
  28. \node (\detokenize{#3} to) at (mess to) {\llap{#7~}};
  29. \else
  30. \node (\detokenize{#3} from) at (mess from) {#6};
  31. \node (\detokenize{#3} to) at (mess to) {#7};
  32. \fi
  33. \fi
  34. }
  35. % prevent warnings of underfull \hbox:
  36. \usepackage{etoolbox}
  37. \apptocmd{\sloppy}{\hbadness 4000\relax}{}{}
  38. \theoremstyle{definition}
  39. \newtheorem{definition}{Def}[section]
  40. \newtheorem{theorem}[definition]{Thm}
  41. % custom lemma environment to set custom numbers
  42. \newtheorem{innerlemma}{Lemma}
  43. \newenvironment{lemma}[1]
  44. {\renewcommand\theinnerlemma{#1}\innerlemma}
  45. {\endinnerlemma}
  46. \title{Notes on Nova}
  47. \author{arnaucube}
  48. \date{March 2023}
  49. \begin{document}
  50. \maketitle
  51. \begin{abstract}
  52. Notes taken while reading Nova \cite{cryptoeprint:2021/370} paper.
  53. Usually while reading papers I take handwritten notes, this document contains some of them re-written to $LaTeX$.
  54. The notes are not complete, don't include all the steps neither all the proofs.
  55. Thanks to \href{https://twitter.com/levs57}{Levs57}, \href{https://twitter.com/nibnalin}{Nalin Bhardwaj} and \href{https://twitter.com/cperezz19}{Carlos Pérez} for clarifications on the Nova paper.
  56. \end{abstract}
  57. \tableofcontents
  58. \section{NIFS}
  59. \subsection{R1CS modification}
  60. \paragraph{R1CS}
  61. R1CS instance: $(A, B, C, io, m, n)$, where $io$ denotes the public input and output, $A, B, C \in \mathbb{F}^{m \times n}$, with $m \geq |io|+1$.
  62. R1CS is satisfied by a witness $w \in \mathbb{F}^{m-|io|-1}$ such that
  63. $$Az \circ Bz = Cz$$
  64. where $z=(io, 1, w)$.
  65. \vspace{0.5cm}
  66. \textbf{Want}: merge 2 instances of R1CS with the same matrices into a single one. Each instance has $z_i = (W_i,~ x_i)$ (public witness, private values resp.).
  67. \paragraph{traditional R1CS}
  68. Merged instance with $z=z_1 + r z_2$, for rand $r$. But, since R1CS is not linear $\longrightarrow$ can not apply.
  69. eg.
  70. \begin{align*}
  71. Az \circ Bz &= A(z_1 + r z_2) \circ B (z_1 + r z_2)\\
  72. &= A z_1 \circ B z_1 + r(A z_1 \circ B z_2 + A z_2 \circ B z_1) + r^2 (A z_2 \circ B z_2)\\
  73. &\neq Cz
  74. \end{align*}
  75. $\longrightarrow$ introduce error vector $E \in \mathbb{F}^m$, which absorbs the cross-temrs generated by folding.
  76. $\longrightarrow$ introduce scalar $u$, which absorbs an extra factor of $r$ in $C z_1 + r^2 C z_2$ and in $z=(W, x, 1+r\cdot 1)$.
  77. \paragraph{Relaxed R1CS}
  78. \begin{align*}
  79. &u=u_1+r u_2\\
  80. &E=E_1 + r (A z_1 \circ B z_2 + A z_2 \circ B z_1 - u_1 C z_2 - u_2 C z_1) + r^2 E_2\\
  81. &Az \circ Bz = uCz + E,~~ with~ z=(W,~x,~u)
  82. \end{align*}
  83. where R1CS set $E=0,~u=1$.
  84. \begin{align*}
  85. Az \circ Bz &= A z_1 \circ B z_1 + r(A z_1 \circ B z_2 + A z_2 \circ B z_1) + r^2 (A z_2 \circ B z_2)\\
  86. &= (u_1 C z_1 + E_1) + r (A z_1 \circ B z_2 + A z_2 \circ B z_1) + r^2 (u_2 C z_2 + E_2)\\
  87. &= u_1 C z_1 + \underbrace{E_1 + r(A z_1 \circ B z_2 + A z_2 \circ B z_1) + r^2 E_2}_\text{E} + r^2 u_2 C z_2\\
  88. &= u_1 C z_1 + r^2 u_2 C z_2 + E\\
  89. &= (u_1 + r u_2) \cdot C \cdot (z_1 + r z_2) + E\\
  90. &= uCz + E
  91. \end{align*}
  92. For R1CS matrices $(A,~B,~C)$, the folded witness $W$ is a satisfying witness for the folded instance $(E,~u,~x)$.
  93. \vspace{20px}
  94. Problem: not non-trivial, and not zero-knowledge. Solution: use polynomial commitment with hiding, binding, succintness and additively homomorphic properties.
  95. \paragraph{Committed Relaxed R1CS}
  96. Instance for a Committed Relaxed R1CS\\
  97. $(\overline{E}, u, \overline{W}, x)$, satisfied by a witness $(E, r_E, W, r_W)$ such that
  98. \begin{align*}
  99. &\overline{E} = Com(E, r_E)\\
  100. &\overline{W} = Com(E, r_W)\\
  101. &Az \circ Bz = uCz+E,~~ where~z=(W, x, u)
  102. \end{align*}
  103. \subsection{Folding scheme for committed relaxed R1CS}
  104. V and P take two \emph{committed relaxed R1CS} instances
  105. \begin{align*}
  106. \varphi_1&=(\overline{E}_1, u_1, \overline{W}_1, x_1)\\
  107. \varphi_2&=(\overline{E}_2, u_2, \overline{W}_2, x_2)
  108. \end{align*}
  109. P additionally takes witnesses to both instances
  110. \begin{align*}
  111. (E_1, r_{E_1}, W_1, r_{W_1})\\
  112. (E_2, r_{E_2}, W_2, r_{W_2})
  113. \end{align*}
  114. Let $Z_1 = (W_1, x_1, u_1)$ and $Z_2 = (W_2, x_2, u_2)$.
  115. % \paragraph{Protocol}
  116. \begin{enumerate}
  117. \item P send $\overline{T} = Com(T, r_T)$,\\
  118. where $T=A z_1 \circ B z_1 + A z_2 \circ B z_2 - u_1 C z_1 - u_2 C z_2$\\
  119. and rand $r_T \in \mathbb{F}$
  120. \item V sample random challenge $r \in \mathbb{F}$
  121. \item V, P output the folded instance $\varphi = (\overline{E}, u, \overline{W}, x)$
  122. \begin{align*}
  123. &\overline{E}=\overline{E}_1 + r \overline{T} + r^2 \overline{E}_2\\
  124. &u = u_1 + r u_2\\
  125. &\overline{W} = \overline{W}_1 + r \overline{W}_2\\
  126. &x = x_1 + r x_2
  127. \end{align*}
  128. \item P outputs the folded witness $(E, r_E, W, r_W)$
  129. \begin{align*}
  130. &E = E_1 + r T + r^2 E_2\\
  131. &r_E = r_{E_1} + r \cdot r_T + r^2 r_{E_2}\\
  132. &W=W_1 + r W_2\\
  133. &r_W = r_{W_1} + r \cdot r_{W_2}
  134. \end{align*}
  135. \end{enumerate}
  136. P will prove that knows the valid witness $(E, r_E, W, r_W)$ for the committed relaxed R1CS without revealing its value.
  137. \begin{center}
  138. \begin{sequencediagram}
  139. \newinst[1]{p}{Prover}
  140. \newinst[3]{v}{Verifier}
  141. \bloodymess[1]{p}{$\overline{T}$}{v}{R}{
  142. \shortstack{
  143. $T=A z_1 \circ B z_1 + A z_2 \circ B z_2 - u_1 C z_2 - u_2 C z_2$\\
  144. $\overline{T}=Commit(T, r_T)$
  145. }
  146. }{
  147. \shortstack{
  148. $r \in^R \mathbb{F}_p$\\
  149. $\overline{E} = \overline{E}_1 + r \overline{T} + r^2 \overline{E}_2$\\
  150. $u= u_1 + r u_2$\\
  151. $\overline{W} = \overline{W}_1 + r \overline{W}_2$\\
  152. $\overline{x} = \overline{x}_1 + r \overline{x}_2$\\
  153. $\varphi=(\overline{E}, u, \overline{W}, x)$
  154. }
  155. }
  156. \bloodymess[1]{v}{$r$}{p}{L}{}{
  157. \shortstack{
  158. $E = E_1 + r T + r^2 E_2$\\
  159. $u= u_1 + r u_2$\\
  160. $W = W_1 + r W_2$\\
  161. $r_{W} = r_{W_1} + r r_{W_2}$\\
  162. $(E, r_E, W, r_W)$
  163. }
  164. }
  165. \end{sequencediagram}
  166. \end{center}
  167. The previous protocol achieves non-interactivity via Fiat-Shamir transform, obtaining a \emph{Non-Interactive Folding Scheme for Committed Relaxed R1CS}.
  168. Note: the paper later uses $\mathsf{u}_i,~ \mathsf{U}_i$ for the two inputted $\varphi_1,~ \varphi_2$, and later $\mathsf{u}_{i+1}$ for the outputted $\varphi$. Also, the paper later uses $\mathsf{w},~ \mathsf{W}$ to refer to the witnesses of two folded instances (eg. $\mathsf{w}=(E, r_E, W, r_W)$).
  169. \subsection{NIFS}
  170. \underline{fold witness, $(pk, (u_1, w_1), (u_2, w_2))$}:
  171. \begin{enumerate}
  172. \item $T=A z_1 \circ B z_1 + A z_2 \circ B z_2 - u_1 C z_2 - u_2 C z_2$
  173. \item $\overline{T}=Commit(T, r_T)$
  174. % \item output the folded instance $\varphi = (\overline{E}, u, \overline{W}, x)$
  175. % \begin{align*}
  176. % &\overline{E}=\overline{E}_1 + r \overline{T} + r^2 \overline{E}_2\\
  177. % &u = u_1 + r u_2\\
  178. % &\overline{W} = \overline{W}_1 + r \overline{W}_2\\
  179. % &x = x_1 + r x_2
  180. % \end{align*}
  181. \item output the folded witness $(E, r_E, W, r_W)$
  182. \begin{align*}
  183. &E = E_1 + r T + r^2 E_2\\
  184. &r_E = r_{E_1} + r \cdot r_T + r^2 r_{E_2}\\
  185. &W=W_1 + r W_2\\
  186. &r_W = r_{W_1} + r \cdot r_{W_2}
  187. \end{align*}
  188. \end{enumerate}
  189. \underline{fold instances $(\varphi_1, \varphi_2) \rightarrow \varphi$, $(vk, u_1, u_2, \overline{E}_1, \overline{E}_2, \overline{W}_1, \overline{W}_2, \overline{T})$}:\\
  190. V compute folded instance $\varphi = (\overline{E}, u, \overline{W}, x)$
  191. \begin{align*}
  192. &\overline{E}=\overline{E}_1 + r \overline{T} + r^2 \overline{E}_2\\
  193. &u = u_1 + r u_2\\
  194. &\overline{W} = \overline{W}_1 + r \overline{W}_2\\
  195. &x = x_1 + r x_2
  196. \end{align*}
  197. \section{Nova}
  198. IVC (Incremental Verifiable Computation) scheme for a non-interactive folding scheme.
  199. \subsection{IVC proofs}
  200. Allows prover to show $z_n = F^{(n)}(z_0)$, for some count $n$, initial input $z_0$, and output $z_n$.\\
  201. $F$: program function (polynomial-time computable)\\
  202. $F'$: augmented function, invokes $F$ and additionally performs fold-related stuff.
  203. \vspace{0.5cm}
  204. Two committed relaxed R1CS instances:\\
  205. $\mathsf{U}_i$: represents the correct execution of invocations $1, \ldots, i-1$ of $F'$\\
  206. $\mathsf{u}_i$: represents the correct execution of invocations $i$ of $F'$
  207. \paragraph{Simplified version of $F'$ for intuition}
  208. \vspace{0.5cm}
  209. $F'$ performs two tasks:
  210. \begin{enumerate}[i.]
  211. \item execute a step of the incremental computation:
  212. instance $\mathsf{u}_i$ contains $z_i$, used to output $z_{i+1}=F(z_i)$
  213. \item invokes the verifier of the non-interactive folding scheme to fold the task of checking $\mathsf{u}_i$ and $\mathsf{U}_i$ into the task of checking a single instance $\mathsf{U}_{i+1}$
  214. \end{enumerate}
  215. \vspace{0.5cm}
  216. $F'$ proves that:
  217. \begin{enumerate}
  218. \item $\exists ( (i, z_0, z_i, \mathsf{u}_i, \mathsf{U}_i), \mathsf{U}_{i+1}, \overline{T})$ such that
  219. \begin{enumerate}[i.]
  220. \item $\mathsf{u}_i.x = H(vk, i, z_0, z_i, \mathsf{U}_i)$
  221. \item $h_{i+1} = H(vk, i+1, z_0, F(z_i), \mathsf{U}_{i+1})$
  222. \item $\mathsf{U}_{i+1} = NIFS.V(vk, \mathsf{U}_i, \mathsf{u}_i, \overline{T})$
  223. \end{enumerate}
  224. \item $F'$ outputs $h_{i+1}$
  225. \end{enumerate}
  226. $F'$ is described as follows:\\
  227. \underline{$F'(vk, \mathsf{U}_i, \mathsf{u}_i, (i, z_0, z_i), w_i, \overline{T}) \rightarrow x$}:\\
  228. if $i=0$, output $H(vk, 1, z_0, F(z_0, w_i), \mathsf{u}_{\bot})$\\
  229. otherwise
  230. \begin{enumerate}
  231. \item check $\mathsf{u}_i.x = H(vk, i, z_0, z_i, \mathsf{U}_i)$
  232. \item check $(\mathsf{u}_i.\overline{E}, \mathsf{u}_i.u) = (\mathsf{u}_{\bot}.\overline{E}, 1)$
  233. \item compute $\mathsf{U}_{i+1} \leftarrow NIFS.V(vk, U, u, \overline{T})$
  234. \item output $H(vk, i+1, z_0, F(z_i, w_i), \mathsf{U}_{i+1})$
  235. \end{enumerate}
  236. % TODO add diagram
  237. \paragraph{IVC Proof}
  238. iteration $i+1$: prover runs $F'$ and computes $\mathsf{u}_{i+1},~ \mathsf{U}_{i+1}$, with corresponding witnesses $\mathsf{w}_{i+1},~ \mathsf{W}_{i+1}$.
  239. $(\mathsf{u}_{i+1},~ \mathsf{U}_{i+1})$ attest correctness of $i+1$ invocations of $F'$, the IVC proof is $\pi_{i+1} = ( (\mathsf{U}_{i+1}, \mathsf{W}_{i+1}), (\mathsf{u}_{i+1}, \mathsf{w}_{i+1}))$.
  240. \vspace{0.5cm}
  241. \underline{$P(pk, (i, z_0, z_i), \mathsf{w}_i, \pi_i) \rightarrow \pi_{i+1}$}:\\
  242. Parse $\pi_i = ( (\mathsf{U}_i, \mathsf{W}_i), (\mathsf{u}_i, \mathsf{w}_i))$, then
  243. \begin{enumerate}
  244. \item if $i=0$: $(\mathsf{U}_{i+1}, \mathsf{W}_{i+1}, \overline{T}) \leftarrow (\mathsf{u}_{\perp}, \mathsf{w}_{\perp}, \mathsf{u}_{\perp}.{\overline{E}})$\\
  245. otherwise: $(\mathsf{U}_{i+1}, \mathsf{W}_{i+1}, \overline{T}) \leftarrow NIFS.P(pk, (\mathsf{U}_i, \mathsf{W}_i), (\mathsf{u}_i, \mathsf{w}_i))$
  246. \item compute $(\mathsf{u}_{i+1}, \mathsf{w}_{i+1}) \leftarrow trace(F', (vk, \mathsf{U}_i, \mathsf{u}_i, (i, z_0, z_i), \mathsf{w}_i, \overline{T}))$
  247. \item output $\pi_{i+1} \leftarrow ((\mathsf{U}_{i+1}, \mathsf{W}_{i+1}), (\mathsf{u}_{i+1}, \mathsf{w}_{i+1}))$
  248. \end{enumerate}
  249. \underline{$V(vk, (i, z_0, z_i), \pi_i) \rightarrow \{0,1\}$}:
  250. if $i=0$: check that $z_i=z_0$\\
  251. otherwise, parse $\pi_i = ( (\mathsf{U}_i, \mathsf{W}_i), (\mathsf{u}_i, \mathsf{w}_i))$, then
  252. \begin{enumerate}
  253. \item check $\mathsf{u}_i.x = H(vk, i, z_0, z_i, \mathsf{U}_i)$
  254. \item check $(\mathsf{u}_i.{\overline{E}}, \mathsf{u}_i.u) = (\mathsf{u}_{\perp}.{\overline{E}}, 1)$
  255. \item check that $\mathsf{W}_i,~ \mathsf{w}_i$ are satisfying witnesses to $\mathsf{U}_i,~ \mathsf{u}_i$ respectively
  256. \end{enumerate}
  257. \vspace{0.5cm}
  258. \paragraph{A zkSNARK of a Valid IVC Proof} prover and verifier:\\
  259. \underline{$P(pk, (i, z_0, z_i), \Pi) \rightarrow \pi$}:\\
  260. if $i=0$, output $\perp$, otherwise:\\
  261. parse $\Pi$ as $((\mathsf{U}, \mathsf{W}), (\mathsf{u}, \mathsf{w}))$
  262. \begin{enumerate}
  263. \item compute $(\mathsf{U}', \mathsf{W}', \overline{T}) \leftarrow NIFS.P(pk_{NIFS}, (\mathsf{U,~W}), (\mathsf{u,~w}))$
  264. \item compute $\pi_{\mathsf{u}'} \leftarrow zkSNARK.P(pk_{zkSNARK}, \mathsf{U}', \mathsf{W}')$
  265. \item output $(\mathsf{U,~ u}, \overline{T}, \pi_{\mathsf{u}'})$
  266. \end{enumerate}
  267. \underline{$V(vk, (i, z_0, z_i), \pi) \rightarrow \{0,1\}$}:\\
  268. if $i=0$: check that $z_i=z_0$\\
  269. parse $\pi$ as $(\mathsf{U}, \mathsf{u}, \overline{T}, \pi_{\mathsf{u}'})$
  270. \begin{enumerate}
  271. \item check $\mathsf{u}.x = H(vk_{NIFS}, i, z_0, z_i, \mathsf{U})$
  272. \item check $(\mathsf{u}.{\overline{E}}, \mathsf{u}.u) = (\mathsf{u}_{\perp}.{\overline{E}}, 1)$
  273. \item compute $\mathsf{U}' \leftarrow NIFS.V(vk_{NIFS}, \mathsf{U}, \mathsf{u}, \overline{T})$
  274. \item check $zkSNARK.V(vk_{zkSNARK}, \mathsf{U}', \pi_{\mathsf{u}'})=1$
  275. \end{enumerate}
  276. \bibliography{paper-notes.bib}
  277. \bibliographystyle{unsrt}
  278. \end{document}