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.

336 lines
9.5 KiB

  1. \documentclass[t]{beamer}
  2. \usefonttheme[onlymath]{serif}
  3. \mode<presentation>
  4. {
  5. \usetheme{Frankfurt}
  6. \usecolortheme{dove} %% grey scale
  7. \useinnertheme{circles}
  8. % \setbeamercovered{transparent}
  9. }
  10. \hypersetup{
  11. colorlinks,
  12. citecolor=black,
  13. filecolor=black,
  14. linkcolor=black,
  15. urlcolor=blue
  16. }
  17. \usepackage{graphicx}
  18. \graphicspath{ {../folding/sonobe-docs/src/imgs} }
  19. \usepackage{listings} % embed code
  20. \setbeamertemplate{itemize}{$\circ$}
  21. \setbeamertemplate{itemize items}{$\circ$}
  22. \beamertemplatenavigationsymbolsempty %% no navigation bar
  23. \setbeamertemplate{footline}{\hspace*{.1cm}\scriptsize{
  24. \hspace*{50pt} \hfill\insertframenumber/\inserttotalframenumber\hspace*{.1cm}\vspace*{.1cm}}}
  25. \setbeamertemplate{caption}[numbered]
  26. \setbeamerfont{caption}{size=\tiny}
  27. \title{Anatomy of a folding scheme}
  28. \author{\small{Sonobe, experimental folding schemes library implemented jointly by \href{https://0xparc.org}{0xPARC} and \href{https://pse.dev/}{PSE.}}}
  29. \date{\vspace{1cm}\\\scriptsize{2024-04-22\\Barcelona zkDay}}
  30. \begin{document}
  31. \frame{\titlepage}
  32. % To mention at the beginning:
  33. % we would need more than 2h to show a bit of more detail, but we only have 20min
  34. \section[Motivation]{Motivation}
  35. \begin{frame}{Why folding}
  36. \begin{itemize}
  37. \item Repetitive computations take big circuits $\longrightarrow$ large proving time
  38. \begin{itemize}
  39. \item ie. prove a chain of 10k sha256 hashes
  40. \end{itemize}
  41. % \pause
  42. \item Traditional recursion: verify (in-circuit) a proof of the correct execution of the same circuit for the previous input
  43. \begin{itemize}
  44. \item issue: in-circuit proof verification is expensive (constraints)
  45. \begin{itemize}
  46. \item ie. verify a Groth16 proof inside a R1CS circuit
  47. \end{itemize}
  48. \end{itemize}
  49. \end{itemize}
  50. % draw: G16 proof being verified inside a circuit for which a new proof is generated
  51. \end{frame}
  52. \begin{frame}{IVC - Incremental Verifiable Computation}
  53. Folding schemes efficitently achieve IVC, where the prover recursively proves the correct execution of the incremental computations.
  54. \includegraphics[width=\textwidth]{folding-main-idea-diagram}
  55. In other words, it allows to prove efficiently that $z_n = F(...~F(F(F(F(z_0, w_0), w_1), w_2), ...), w_{n-1})$.
  56. \end{frame}
  57. \begin{frame}{Folding idea}
  58. % draw of 2 instances being folded into a single one
  59. % then add other instances to show k-to-1 folding
  60. \end{frame}
  61. \section[Folding]{Folding}
  62. \begin{frame}{Homomorphic commitments and RLC}
  63. We rely on homomorphic commitments\\
  64. ie. Pedersen commitments\\
  65. Let $g \in \mathbb{G}^n,~ v \in \mathbb{F}_r^n$,\\
  66. $$Com(v) = \langle g, v \rangle =g_1 \cdot v_1 + g_2 \cdot v_2 + \ldots + g_n \cdot v_n$$
  67. % \pause
  68. RLC:\\
  69. Let $v_1, v_2 \in \mathbb{F}_r^n$, set $cm_1 = Com(v_1),~ cm_2=Com(v_2)$.
  70. \\then,
  71. \begin{align*}
  72. v_3 &= v_1 + r \cdot v_2\\
  73. cm_3 &=cm_1 + r \cdot cm_2
  74. \end{align*}
  75. \\so that
  76. $$cm_3 = Com(v_3)$$
  77. \end{frame}
  78. \begin{frame}{Relaxed R1CS}
  79. R1CS instance: $(\{A, B, C\} \in \mathbb{F}^{n \times n},~ io,~ n,~ l)$, such that for $z=(io \in \mathbb{F}^l, 1, w \in \mathbb{F}^{n-l-1}) \in \mathbb{F}^n$,
  80. $$Az \circ Bz = Cz$$
  81. % \pause
  82. Relaxed R1CS:
  83. $$Az \circ Bz = uCz + E$$
  84. for $u \in \mathbb{F},~~ E \in \mathbb{F}^n$.
  85. \vspace{1cm}
  86. Committed Relaxed R1CS instance: $CI = (\overline{E}, u, \overline{W}, x)$\\
  87. Witness of the instance: $WI=(E, W)$
  88. \vspace{0.5cm}
  89. \footnotesize{(We don't have time for it now, but there is a simple reasoning for the RelaxedR1CS usage explained in Nova paper)}
  90. \end{frame}
  91. \begin{frame}{NIFS - Non Interactive Folding Scheme}
  92. \scriptsize{
  93. \begin{align*}
  94. CI_1 &=(\overline{E}_1 \in \mathbb{G}, u_1 \in \mathbb{F}, \overline{W}_1 \in \mathbb{G}, x_1 \in \mathbb{F}^n) ~~~~~~WI_1=(E_1 \in \mathbb{F}^n, W_1 \in \mathbb{F}^n)\\
  95. CI_2 &=(\overline{E}_2, u_2, \overline{W}_2, x_2) ~~~~~~WI_2=(E_2, W_2)
  96. \end{align*}
  97. where $\overline{V}=Com(V)$
  98. % \pause
  99. \begin{align*}
  100. T &= Az_1 \circ Bz_1 + Az_2 \circ Bz_2 - u_1 C z_1 - u_2 C z_2\\
  101. \overline{T}&=Com(T)
  102. \end{align*}
  103. % \pause
  104. \begin{minipage}[t]{.45\textwidth}
  105. NIFS.P
  106. \begin{align*}
  107. E &= E_1 + r \cdot T + r^2 \cdot E_2\\
  108. W &= W_1 + r \cdot W
  109. \end{align*}
  110. \end{minipage}
  111. \hfill\vline\hfill
  112. \begin{minipage}[t]{.45\textwidth}
  113. NIFS.V
  114. \begin{align*}
  115. \overline{E} &= \overline{E}_1 + r \cdot \overline{T} + r^2 \cdot \overline{E}_2\\
  116. u &= u_1 + r \cdot u_2\\
  117. \overline{W} &= \overline{W}_1 + r \cdot \overline{W}\\
  118. x &= x_1 + r \cdot x_2
  119. \end{align*}
  120. \end{minipage}
  121. New folded Committed Instance: $(\overline{E}, u, \overline{W}, x)$\\
  122. New folded witness: $(E, W)$
  123. }
  124. \end{frame}
  125. \begin{frame}{IVC}
  126. \small{
  127. $U_i$: committed instance for the correct execution of invocations $1, \ldots, i-1$ of $F'$\\
  128. $u_i$: committed instance for the correct execution of invocation $i$ of $F'$
  129. }
  130. % draw: sketch of the Augmented F Circuit
  131. % big box for F', inside small box for F. NIFS.V box, how things connect to next iteration
  132. \vspace{4cm}
  133. \small{
  134. F':\\
  135. i) execute a step of the incremental computation, $z_{i+1} = F(z_i)$\\
  136. ii) invoke the NIFS.V to fold $U_i, u_i$ into $U_{i+1}$\\
  137. iii) other checks to ensure that the IVC is done properly
  138. }
  139. \end{frame}
  140. \begin{frame}{Cycle of curves}
  141. \small{
  142. NIFS.V involves $\mathbb{G}$ point scalar mults, which are not native over $\mathbb{F}_r$.
  143. \\$\longrightarrow$ delegate them into a circuit over a 2nd curve.
  144. \vspace{0.3cm}
  145. We 'mirror' the main $F'$ circuit into the 2nd curve\\
  146. each circuit computes natively the point operations of the other curve
  147. }
  148. % draw:
  149. % 1st the Nova with duplicated F' circuits over 2 curves
  150. % 2nd the Nova with CycleFold circuits sketch
  151. \end{frame}
  152. \begin{frame}{Augmented F Circuit + CycleFold Circuit}
  153. \includegraphics[width=\textwidth]{cyclefold-nova-diagram}
  154. \end{frame}
  155. \begin{frame}{Other Folding Schemes}
  156. % TODO
  157. % HyperNova
  158. % ProtoGalaxy
  159. % ProtoStar
  160. % LatticeFold
  161. % etc
  162. % mention a bit the different characteristics and folding techniques
  163. \end{frame}
  164. \section{Decider (Final Proof)}
  165. \begin{frame}{Decider}
  166. \includegraphics[width=\textwidth]{cyclefold-paper-diagram}
  167. With Prover knowing the respective witnesses for $U_n, u_n, U_{EC,n}$
  168. \vspace{1cm}
  169. Issue: IVC proof is not succinct
  170. \end{frame}
  171. \begin{frame}{Decider}
  172. Original Nova: generate a zkSNARK proof with Spartan for $U_n, u_n, U_{EC, n}$\\
  173. $\longrightarrow$ 2 Spartan proofs, one on each curve (with CycleFold is 1 Spartan proof)\\
  174. (not EVM-friendly)
  175. % draw of the 2 circuits over the curves, and how we generate a Spartan proof for each one
  176. \end{frame}
  177. \begin{frame}{Decider}
  178. checks (simplified)
  179. \begin{enumerate}
  180. \item $(U_{n+1}, W_{n+1})$ satisfy Relaxed R1CS relation of AugmentedFCircuit
  181. \item verify commitments of $U_{n+1}.\{\overline{E}, \overline{W}\}$ w.r.t. $W_{n+1}.\{E,W\}$
  182. \item $(U_{EC,n}, W_{EC,n})$ satisfy Relaxed R1CS relation of CycleFoldCircuit
  183. \item verify commitments of $U_{EC,n}.\{\overline{E}, \overline{W}\}$ w.r.t. $W_{EC,n}.\{E,W\}$
  184. \item $u_n.E==0,~ u_n.u==1$, ie. $u_n$ is a fresh not-relaxed instance
  185. \item $u_n.x_0==H(n, z_0, z_n, U_n)$\\
  186. $u_n.x_1==H(U_{EC,n})$
  187. \item $NIFS.V(U_n, u_n)==U_{n+1}$
  188. \end{enumerate}
  189. % by draw show which are native and not native
  190. % and that the NIFS.V we do it in Solidity
  191. \end{frame}
  192. \begin{frame}{Decider}
  193. \includegraphics[width=\textwidth]{decider-onchain-flow-diagram}
  194. % draw of the full flow: from inputting the circuit, to folding to generating the Decider proof to verifying in Ethereum
  195. \end{frame}
  196. \section{Sonobe}
  197. \begin{frame}{Sonobe}
  198. \footnotesize{
  199. Experimental folding schemes library implemented jointly by 0xPARC and PSE.
  200. \vspace{0.3cm}
  201. Dev flow:
  202. \begin{enumerate}
  203. \item Define a circuit to be folded
  204. \item Set which folding scheme to be used (eg. Nova with CycleFold)
  205. \item Set a final decider to generate the final proof (eg. Spartan over Pasta curves)
  206. \item Generate the the decider verifier
  207. \end{enumerate}
  208. }
  209. \vspace{1cm}
  210. \includegraphics[width=\textwidth]{sonobe-lib-pipeline}
  211. \end{frame}
  212. \begin{frame}{Code example}
  213. [show code with a live demo]
  214. \vspace{0.5cm}
  215. Some numbers (still optimizations pending):
  216. \begin{itemize}
  217. \item AugmentedFCircuit: $\sim 80k$ R1CS constraints
  218. \item DeciderEthCircuit: $\sim 9.6M$ R1CS constraints
  219. \begin{itemize}
  220. \item $<3$ minutes in a 32GB RAM 16 core laptop
  221. \end{itemize}
  222. \item gas costs (DeciderEthCircuit proof): $\sim 800k$ gas
  223. \begin{itemize}
  224. \item mostly from G16, KZG10, public inputs processing
  225. \item will be reduced by hashing the public inputs
  226. \item expect to get it down to $< 600k$ gas.
  227. \end{itemize}
  228. \end{itemize}
  229. \vspace{0.3cm}
  230. Recall, this proof is proving that applying $n$ times the function $F$ (the circuit that we're folding) to an initial state $z_0$ results in the state $z_n$.
  231. \\In Srinath Setty words, you can prove practically unbounded computation onchain by 800k gas (and soon $< 600k$).
  232. \end{frame}
  233. \begin{frame}
  234. \frametitle{Wrappup}
  235. \begin{itemize}
  236. \item \href{https://github.com/privacy-scaling-explorations/sonobe}{https://github.com/privacy-scaling-explorations/sonobe}
  237. \item \href{https://privacy-scaling-explorations.github.io/sonobe-docs/}{https://privacy-scaling-explorations.github.io/sonobe-docs/}
  238. \end{itemize}
  239. \begin{center}
  240. \includegraphics[width=4cm]{qr-sonobe-repo-link}
  241. \end{center}
  242. \tiny{
  243. $$\text{2024-04-22}$$
  244. $$\text{\href{https://0xparc.org}{0xPARC}~\&~\href{https://pse.dev/}{PSE.}}$$
  245. }
  246. \end{frame}
  247. \end{document}