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.

496 lines
17 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{An overview on folding schemes,\\and an introduction to Sonobe}
  28. \author{
  29. % Folding polynomials and proving it onchain.\\
  30. % \small{Sonobe: experimental folding schemes library implemented jointly by \href{https://0xparc.org}{0xPARC} and \href{https://pse.dev/}{PSE.}}\\
  31. \vspace{0.2cm}
  32. \includegraphics[width=3cm]{sonobe}
  33. }
  34. \date{\vspace{0.1cm}\scriptsize{2024-08-08\\San Francisco 0xPARC Summer}}
  35. \begin{document}
  36. \frame{\titlepage}
  37. \section[Motivation]{Motivation}
  38. \begin{frame}{Polynomials and SNARKs}
  39. \begin{itemize}
  40. \item define the 'program' that we want to be able to prove as a set of constraints
  41. \item encode the constraints as polynomials
  42. \\eg. R1CS: $Az \circ Bz - Cz == 0$
  43. \\~~~~~~~~~~$A(X) \cdot B(X) - C(X) == 0$
  44. \item and then use some scheme to prove that those polynomials satisfy the relation. eg. Groth16, Spartan, etc
  45. \end{itemize}
  46. tl;dr: want to prove polynomial relations
  47. \end{frame}
  48. \begin{frame}{Why folding}
  49. \begin{itemize}
  50. \item Repetitive computations take big circuits $\longrightarrow$ large proving time
  51. \begin{itemize}
  52. \item and in some cases takes too much memory and can not be even computed
  53. \item eg. prove a chain of 10k sha256 hashes (>600M R1CS constraints, not feasible with most traditional SNARK proving systems)
  54. \end{itemize}
  55. % \pause
  56. \item Traditional recursion: verify (in-circuit) a proof of the correct execution of the same circuit for the previous input
  57. \begin{itemize}
  58. \item issue: in-circuit proof verification is expensive (constraints)
  59. \begin{itemize}
  60. \item ie. verify a Groth16 proof inside a R1CS circuit
  61. \end{itemize}
  62. \end{itemize}
  63. \end{itemize}
  64. % DRAW: G16 proof being verified inside a circuit for which a new proof is generated
  65. \end{frame}
  66. \begin{frame}{IVC - Incremental Verifiable Computation}
  67. {\tiny Valiant'08}\\
  68. Folding schemes efficitently achieve IVC, where the prover recursively proves the correct execution of the incremental computations.
  69. \vspace{0.5cm}
  70. % For a function $F$, with initial input $z_0$, an IVC scheme allows a prover to produce a proof $\pi_i$ for the statement $z_i=F^{(i)}(z_0)$, given a proof $\pi_{i-1}$ for the statementkj
  71. \emph{Prove that applying $n$ times the $F$ function (the circuit being folded) to the initial state ($z_0$) results in the final state ($z_n$).}
  72. \includegraphics[width=\textwidth]{folding-main-idea-diagram}
  73. 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})$.
  74. \end{frame}
  75. \begin{frame}{Folding idea}
  76. % DRAW of 2 instances being folded into a single one
  77. % then add other instances to show k-to-1 folding
  78. \end{frame}
  79. % \section[Folding]{Folding}
  80. % \begin{frame}{Fold polynomials - a simple example}
  81. % TODO example folding poly
  82. % \end{frame}
  83. \begin{frame}{Random linear combination of homomorphic commitments}
  84. \small{
  85. We rely on homomorphic commitments, eg. Pedersen commitments\\
  86. }
  87. Let $g \in \mathbb{G}^n,~ v \in \mathbb{F}_r^n$,\\
  88. $$Com(v) = \langle g, v \rangle =g_1 \cdot v_1 + g_2 \cdot v_2 + \ldots + g_n \cdot v_n \in \mathbb{G}$$
  89. RLC:\\
  90. Let $v, w \in \mathbb{F}_r^n$,
  91. \\set $cm_v = Com(v),~ cm_w=Com(w) \in \mathbb{G}$.
  92. \\then,
  93. \begin{align*}
  94. y &= v + r \cdot w\\
  95. cm_{y} &=cm_v + r \cdot cm_w
  96. \end{align*}
  97. \\so that
  98. $$cm_y = Com(y)$$
  99. \end{frame}
  100. \begin{frame}{Relaxed R1CS}
  101. % TODO: think if maybe remove this slide and the next one (NIFS)\\
  102. R1CS instance: $(\{A, B, C\} \in \mathbb{F}^{n \times n},~ n,~ l)$, such that for $z=(1, io \in \mathbb{F}^l, w \in \mathbb{F}^{n-l-1}) \in \mathbb{F}^n$,
  103. $$Az \circ Bz = Cz$$
  104. % \pause
  105. Relaxed R1CS:
  106. $$Az \circ Bz = uCz + E$$
  107. for $u \in \mathbb{F},~~ E \in \mathbb{F}^n$.
  108. \vspace{1cm}
  109. Committed Relaxed R1CS instance: $CI = (\overline{E}, u, \overline{W}, x)$\\
  110. Witness of the instance: $WI=(E, W)$
  111. \end{frame}
  112. \begin{frame}{Relaxed R1CS}
  113. % \vspace{-1cm}
  114. \scriptsize{
  115. $u=u_1+r u_2,~~ z=z_1+r z_2,~~ x=x_1+r x_2$\\
  116. $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$\\
  117. \text{Relaxed R1CS:} $Az \circ Bz = uCz + E,~~ with~ z=(u,~x,~W)$
  118. \begin{align*}
  119. Az \circ Bz
  120. &= A(z_1 + r \cdot z_2) \circ B(z_1 + r \cdot z_2)\\
  121. &= 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)\\
  122. &= (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)\\
  123. &= 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\\
  124. &= u_1 C z_1 + r^2 u_2 C z_2 + E\\
  125. &= (u_1 + r u_2) \cdot C \cdot (z_1 + r z_2) + E\\
  126. &= uCz + E
  127. \end{align*}
  128. For R1CS matrices $(A,~B,~C)$, the folded witness $W$ is a satisfying witness for the folded instance $(E,~u,~x)$, following the Relaxed R1CS relation: $Az \circ Bz - uCz - E ==0$.
  129. Since we don't want that the Verifier learning about the witness, we commit to it, and the Verifier will run the RLC on the commitment (not on the witness), obtaining the 'folded' commitment.
  130. \\\tiny{Full details at Nova's paper, pages 13-15 ("first attempt, second attempt, third attempt")}
  131. }
  132. \end{frame}
  133. % \begin{frame}{NIFS - Non Interactive Folding Scheme (in Nova)}
  134. % \vspace{-0.5cm}
  135. % \scriptsize{
  136. % \begin{align*}
  137. % 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)\\
  138. % CI_2 &=(\overline{E}_2, u_2, \overline{W}_2, x_2) ~~~~~~WI_2=(E_2, W_2)
  139. % \end{align*}
  140. % where $\overline{V}=Com(V)$
  141. %
  142. %
  143. %
  144. % \begin{align*}
  145. % T &= Az_1 \circ Bz_1 + Az_2 \circ Bz_2 - u_1 C z_1 - u_2 C z_2\\
  146. % \overline{T}&=Com(T)
  147. % \end{align*}
  148. %
  149. % \begin{minipage}[t]{.45\textwidth}
  150. % NIFS.P
  151. % \begin{align*}
  152. % E &= E_1 + r \cdot T + r^2 \cdot E_2\\
  153. % W &= W_1 + r \cdot W
  154. % \end{align*}
  155. % \end{minipage}
  156. % \hfill\vline\hfill
  157. % \begin{minipage}[t]{.45\textwidth}
  158. % NIFS.V
  159. % \begin{align*}
  160. % \overline{E} &= \overline{E}_1 + r \cdot \overline{T} + r^2 \cdot \overline{E}_2\\
  161. % u &= u_1 + r \cdot u_2\\
  162. % \overline{W} &= \overline{W}_1 + r \cdot \overline{W}\\
  163. % x &= x_1 + r \cdot x_2
  164. % \end{align*}
  165. % \end{minipage}
  166. %
  167. % New folded Committed Instance: $(\overline{E}, u, \overline{W}, x)$\\
  168. % New folded witness: $(E, W)$
  169. % }
  170. % \vspace{0.3cm}\\
  171. % \tiny{Nova's paper, pages 13-15 ("first attempt, second attempt, third attempt")}
  172. % \end{frame}
  173. \begin{frame}{NIFS - Non Interactive Folding Scheme (in Nova)}
  174. \scriptsize{
  175. Main idea:
  176. \begin{itemize}
  177. \item interactive protocol between P and V
  178. \item where V obtains the 'folded' commitment that corresponds to the 'folded' witness that P computes
  179. \item so V does not know the witness
  180. \end{itemize}
  181. We make it non-interactive with Fiat-Shamir.
  182. }
  183. \includegraphics[width=\textwidth]{./imgs/interactive-FS-nova-diagram}
  184. Relation check:
  185. \begin{align*}
  186. &z=(1,x,W)\\
  187. &\begin{cases}
  188. Az \circ Bz - uCz - E \stackrel{?}{=} 0\\
  189. \overline{W} \stackrel{?}{=} Com(W)\\
  190. \overline{E} \stackrel{?}{=} Com(E)
  191. \end{cases}
  192. \end{align*}
  193. \end{frame}
  194. \begin{frame}{HyperNova NIMFS}
  195. \includegraphics[width=8cm]{./imgs/hypernova-screenshot}
  196. \end{frame}
  197. \begin{frame}{ProtoGalaxy Folding}
  198. \includegraphics[width=8cm]{./imgs/protogalaxy-screenshot}
  199. \end{frame}
  200. \section[IVC]{IVC}
  201. \begin{frame}{IVC}
  202. \includegraphics[width=\textwidth]{folding-main-idea-diagram}
  203. \begin{itemize}
  204. \item We have our folding protocol, in which P \& V 'fold' the instances (witness \& commitments)
  205. \item Will use it in the IVC setting
  206. \item at each IVC step, need to ensure that the 'folding' of the previous step was done correctly
  207. \item we 'augment' the circuit with extra checks that compute the folding Verifier
  208. \end{itemize}
  209. \end{frame}
  210. \begin{frame}{IVC - Nova example}
  211. \small{
  212. $U_i$ (\emph{running instance}): committed instance for the correct execution of invocations $1, \ldots, i-1$ of $F'$\\
  213. $u_i$ (\emph{incoming instance}): committed instance for the correct execution of invocation $i$ of $F'$
  214. }
  215. % draw: sketch of the Augmented F Circuit
  216. % big box for F', inside small box for F. NIFS.V box, how things connect to next iteration
  217. \vspace{4cm}
  218. \small{
  219. F':\\
  220. i) execute a step of the incremental computation, $z_{i+1} = F(z_i)$\\
  221. ii) invoke the NIFS.V to fold $U_i, u_i$ into $U_{i+1}$\\
  222. iii) other checks to ensure that the IVC is done properly
  223. }
  224. \end{frame}
  225. \begin{frame}{Cycle of curves}
  226. \small{
  227. NIFS.V involves $\mathbb{G}$ point operation, which are not native over $\mathbb{F}_r$ of $\mathbb{G}$.
  228. \\$\longrightarrow$ delegate them into a circuit over a 2nd curve
  229. We use:
  230. \begin{itemize}
  231. \item $\mathbb{G}_1.\mathbb{F}_r = \mathbb{G}_2.\mathbb{F}_q$
  232. \item $\mathbb{G}_1.\mathbb{F}_q = \mathbb{G}_2.\mathbb{F}_r$
  233. \item eg. for Ethereum compatibility:\\
  234. $\mathbb{G}_1$: BN254, $\mathbb{G}_2$: Grumpkin.
  235. \end{itemize}
  236. \vspace{0.3cm}
  237. We 'mirror' the main $F'$ circuit into the 2nd curve\\
  238. each circuit computes natively the point operations of the other curve
  239. }
  240. % DRAW:
  241. % 1st the Nova with duplicated F' circuits over 2 curves
  242. % 2nd the Nova with CycleFold circuits sketch
  243. \end{frame}
  244. \begin{frame}{Augmented F Circuit + CycleFold Circuit}
  245. \includegraphics[width=\textwidth]{cyclefold-nova-diagram}
  246. % mention TODO folding overhead - num constraints of overhead, so for small circuits it is not worth
  247. explain: circuit overhead
  248. \end{frame}
  249. \begin{frame}{Adding zk to the IVC}
  250. \begin{itemize}
  251. \item fold the original witness with a randomized instance
  252. \item then we can delegate the rest of the computation to a third party server
  253. \end{itemize}
  254. \end{frame}
  255. \section{Decider (Final compressed proof)}
  256. \begin{frame}{Decider (Final compressed proof)}
  257. \includegraphics[width=\textwidth]{cyclefold-paper-diagram}
  258. With Prover knowing the respective witnesses for $U_n, u_n, U_{EC,n}$
  259. \vspace{1cm}
  260. Issue: IVC proof is not succinct
  261. \end{frame}
  262. \begin{frame}{Decider}
  263. Original Nova: generate a zkSNARK proof with Spartan for $U_n, u_n, U_{EC, n}$\\
  264. $\longrightarrow$ 2 Spartan proofs, one on each curve\\
  265. (not EVM-friendly)
  266. % DRAW of the 2 circuits over the curves, and how we generate a Spartan proof for each one
  267. \end{frame}
  268. \begin{frame}{Decider}
  269. checks (simplified)
  270. \begin{enumerate}
  271. \item $(U_{n+1}, W_{n+1})$ satisfy Relaxed R1CS relation of AugmentedFCircuit
  272. \item verify commitments of $U_{n+1}.\{\overline{E}, \overline{W}\}$ w.r.t. $W_{n+1}.\{E,W\}$
  273. \item $(U_{EC,n}, W_{EC,n})$ satisfy Relaxed R1CS relation of CycleFoldCircuit
  274. \item verify commitments of $U_{EC,n}.\{\overline{E}, \overline{W}\}$ w.r.t. $W_{EC,n}.\{E,W\}$
  275. \item $u_n.E==0,~ u_n.u==1$, ie. $u_n$ is a fresh not-relaxed instance
  276. \item $u_n.x_0==H(n, z_0, z_n, U_n)$\\
  277. $u_n.x_1==H(U_{EC,n})$
  278. \item $NIFS.V(U_n, u_n)==U_{n+1}$
  279. \end{enumerate}
  280. % DRAW; by draw show which are native and not native
  281. % and that the NIFS.V we do it in Solidity
  282. \end{frame}
  283. \begin{frame}{Decider}
  284. \includegraphics[width=\textwidth]{decider-onchain-flow-diagram}
  285. % DRAW of the full flow: from inputting the circuit, to folding to generating the Decider proof to verifying in Ethereum
  286. \end{frame}
  287. \section{Sonobe}
  288. \begin{frame}{Sonobe}
  289. \footnotesize{
  290. Experimental folding schemes library implemented jointly by 0xPARC and PSE.\\
  291. \href{https://github.com/privacy-scaling-explorations/sonobe}{https://github.com/privacy-scaling-explorations/sonobe}
  292. \\Modular library,
  293. \begin{itemize}
  294. \item Be able to
  295. \begin{itemize}
  296. \item Add and test new folding schemes
  297. \item Compare schemes 'apples-to-apples'
  298. \item Researchers can easily add their own schemes (eg. Mova paper)
  299. \end{itemize}
  300. \item Make it easy for devs to use folding
  301. \begin{itemize}
  302. \item minimal code to fold your circuits ('plug-and-fold')
  303. \item easy to switch between folding schemes and curves
  304. \item support of multiple zk-circuit languages
  305. \end{itemize}
  306. \end{itemize}
  307. }
  308. \end{frame}
  309. \begin{frame}{Sonobe - Dev experience}
  310. \footnotesize{
  311. Dev flow:
  312. \begin{enumerate}
  313. \item Define a circuit to be folded
  314. \item Set which folding scheme to be used (eg. Nova with CycleFold)
  315. \item Set a final decider to generate the final proof (eg. Groth16 over BN254 curve)
  316. \item Generate the the decider verifier (EVM Solidity contract)
  317. \end{enumerate}
  318. }
  319. \vspace{1cm}
  320. \includegraphics[width=\textwidth]{sonobe-lib-pipeline}
  321. \end{frame}
  322. \begin{frame}{Status of Sonobe - dev experience}
  323. \begin{itemize}
  324. \item Verify in Ethereum
  325. \begin{itemize}
  326. \item solidity verifier contract generator
  327. \end{itemize}
  328. \item Frontends - how can the dev define a circuit to be folded
  329. \begin{itemize}
  330. \item Arkworks \href{https://github.com/arkworks-rs/}{https://github.com/arkworks-rs/}
  331. \item Circom \href{https://github.com/iden3/circom}{https://github.com/iden3/circom}
  332. \item Noir \href{https://noir-lang.org/}{https://noir-lang.org/}
  333. \item Noname \href{https://github.com/zksecurity/noname}{https://github.com/zksecurity/noname}
  334. \end{itemize}
  335. \end{itemize}
  336. \end{frame}
  337. \begin{frame}{Status of Sonobe - schemes implemented}
  338. \scriptsize{
  339. Implemented:
  340. \begin{itemize}
  341. \item \textbf{Nova}: Recursive Zero-Knowledge Arguments from Folding Schemes\\ \href{https://eprint.iacr.org/2021/370.pdf}{https://eprint.iacr.org/2021/370.pdf}, Abhiram Kothapalli, Srinath Setty, Ioanna Tzialla. 2021
  342. \item \textbf{CycleFold}: Folding-scheme-based recursive arguments over a cycle of elliptic curves\\ \href{https://eprint.iacr.org/2023/1192.pdf}{https://eprint.iacr.org/2023/1192.pdf}, Abhiram Kothapalli, Srinath Setty. 2023
  343. \item \textbf{HyperNova}: Recursive arguments for customizable constraint systems\\ \href{https://eprint.iacr.org/2023/573.pdf}{https://eprint.iacr.org/2023/573.pdf}, Abhiram Kothapalli, Srinath Setty. 2023
  344. \end{itemize}
  345. Almost finished:
  346. \begin{itemize}
  347. \item \textbf{ProtoGalaxy}: Efficient ProtoStar-style folding of multiple instances\\ \href{https://eprint.iacr.org/2023/1106.pdf}{https://eprint.iacr.org/2023/1106.pdf}, Liam Eagen, Ariel Gabizon. 2023
  348. \end{itemize}
  349. Soon:
  350. \begin{itemize}
  351. \item \textbf{Mova}: Nova folding without committing to error terms\\ \href{https://eprint.iacr.org/2024/1220.pdf}{https://eprint.iacr.org/2024/1220.pdf}, Nikolaos Dimitriou, Albert Garreta, Ignacio Manzur, Ilia Vlasov. 2024
  352. \end{itemize}
  353. Temptative:
  354. \begin{itemize}
  355. \item \textbf{LatticeFold}: A Lattice-based Folding Scheme and its Applications to Succinct Proof Systems\\ \href{https://eprint.iacr.org/2024/257.pdf}{https://eprint.iacr.org/2024/257.pdf}, Dan Boneh, Binyi Chen. 2024
  356. \item Parallel folding
  357. \end{itemize}
  358. }
  359. \end{frame}
  360. \begin{frame}{Code example}
  361. [show code with a live demo]
  362. \end{frame}
  363. \begin{frame}{Code example}
  364. \footnotesize{
  365. Some numbers (still optimizations pending):
  366. \begin{itemize}
  367. \item AugmentedFCircuit (Nova): $\sim 50k$ R1CS constraints
  368. \item DeciderEthCircuit: $\sim 10M$ R1CS constraints
  369. \begin{itemize}
  370. \item $<3$ minutes in a 32GB RAM 16 core laptop
  371. \end{itemize}
  372. \item gas costs (DeciderEthCircuit proof): $\sim 800k$ gas
  373. \begin{itemize}
  374. \item mostly from G16, KZG10, public inputs processing
  375. \item will be reduced by hashing the public inputs
  376. \item expect to get it down to $< 500k$ gas.
  377. \end{itemize}
  378. \end{itemize}
  379. }
  380. \vspace{0.6cm}
  381. 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$.
  382. \vspace{0.4cm}
  383. In Srinath Setty words, you can prove practically unbounded computation onchain by 800k gas (and soon $< 500k$).
  384. \end{frame}
  385. \begin{frame}{Wrappup}
  386. \begin{itemize}
  387. \item \href{https://github.com/privacy-scaling-explorations/sonobe}{https://github.com/privacy-scaling-explorations/sonobe}
  388. \item \href{https://privacy-scaling-explorations.github.io/sonobe-docs/}{https://privacy-scaling-explorations.github.io/sonobe-docs/}
  389. \end{itemize}
  390. \begin{center}
  391. \includegraphics[width=5cm]{./imgs/sonobe-link-qrcode}
  392. \end{center}
  393. \tiny{
  394. $$\text{2024-08-08}$$
  395. $$\text{\href{https://0xparc.org}{0xPARC}~\&~\href{https://pse.dev/}{PSE.}}$$
  396. }
  397. \end{frame}
  398. \end{document}