https://mirror.xyz/msfew.eth/Yl64OK3lLG48eJpVB3GxqFEhmWOm6yMlAo9sc1VrQP4
04/2022
An easy-to-understand definition to zero-knowledge proofs:
You are in elementary school. The teacher is the verifier, and you, the student, are the prover. How do you prove that you know the formula for solving a quadratic equation? That would require a math exam.
The teacher will give you 10 random questions related to quadratic equation, and if you have mastered them, you can do them all. In the process, you don’t memorize or write down the exact formula, but the teacher can simply verify your comprehension of quadratic equation.
In fact, this is what Tartaglia and Cardano (yes, that’s the name) did when they were fighting over who was the discoverer of the formula for the solution of third-degree equations of the type x 3 + bx = c. Neither of them wanted to tell the other what their formula was, but by doing the random problem sets, it was easy to verify, without revealing knowledge in the process, that they had that knowledge.
What is the use of zero-knowledge proofs? The use is that the whole process saves computational power and compresses space on the blockchain, while also perserving privacy, in line with the trustless and cryptography nature of blockchain.
The term “zk” in the blockchain space is usually not a true zero-knowledge proof, but often a validity proof. These “misuses” are appeared in some parts of this article to avoid confusion over related terms.
In the current blockchain world, zk is arguably the most cutting-edge and optimal solution for scaling (validity proof without zk) and privacy (true zk). zk is widely used in projects such as Tornado.cash, ZCash, zkSync, zk.money, Filecoin, and Mina.
The current technical solutions are divided into two main categories: SNARK and STARK. The S in STARK stands for scalable, which implies that the statement being proved has repeated structure, whereas SNARKs support arbitrary circuits that are preprocessed to enable succinct proofs. The technical practice of SNARK is more dominant, and STARK is mainly adopted by StarkWare on a large scale in production. Here is a comparison between them:
In terms of meme, STARK is also better than SNARK (😊, Star Wars, Star Trek).
If SNARK is the future of Ethereum 2.0, then STARK will be the future of Ethereum 3.0. In all, STARK’s advantages are:
But the proofs generated by STARK are much larger, and quite a bit larger. Due to some limitations of like WASM, which may require additional operations at build time (this example uses SNARK though). Mir gave an AIR-based STARK practice at Starky before, as part of Plonky2 (the relationship between Plonky2 and Starky is complicated…). Personally, I think the large size can be optimized by various approaches, but the time complexity of the algorithm itself is hard to compress further.
These zero-knowledge proof technologies can be combined to build more powerful applications. For example, Polygon Hermez uses SNARK to verify the correctness of STARK, thereby reducing the gas fee when the proof is finally settled.
To sum up, SNARK and STARK are both excellent zero-knowledge proof technologies, each with its own advantages, and their combination has more potential.
The aforementioned Tornado.cash and zk.money are both similarly zero-knowledge proof applications that only support transfer operations, but not general-purpose computation. By analogy, these applications have only the functionality of Bitcoin, and are nowhere near as Turing-completeness and DApp ecosystem as Ethereum (smart contracts on Bitcoin doesn’t make it well).
zkVM is a virtual machine that guarantees secure and verifiable trustworthiness by zero-knowledge proofs. zkVM is simply the machine that you enter the old state and program, and it return the new state in a trusted manner. It allows all applications to be given the superpower of zero-knowledge proofs.
Miden’s presentation at ETH Amsterdam gave a good overview of what zkVM really is in one chart:
zkVM’s Pro:
zkVM’s Con:
There are three main types of zkVMs, with their instruction sets in parentheses: mainstream (WASM, RISC-V), EVM (EVM bytecode), and ZK-Optimized (new instruction sets optimized for zero-knowledge proofs, such as Cairo and zkSync’s). Below is a comparison of the types based on Miden’s presentation at ETH Amsterdam:
Much of what the zero-knowledge proof development ecosystem does is mostly allow developers to use Circom libraries (and snarkyjs for that matter) or other newly created languages (Leo or Cairo, which have odd limitations) to do zk DApp development, but it’s not as straightforward and easy to learn as using Solidity on Ethereum.
In addition, there are many projects, such as zkSync, Scroll, or several under the Polygon umbrella that are trying to make zkEVM or other zkVMs.
EVM is an Ethereum virtual machine, which can also be understood as the execution environments for running smart contracts.
For several years, various blockchains have been trying to be EVM-compatible to access the Ethereum development ecosystem. For this concept, EVM compatibility, equivalence and some other definitions have been derived.
Let’s take a look at zkEVM. By definition, zkEVM is an EVM-compatible and zero-knowledge proof-friendly virtual machine that guarantees the correctness of programs, operations, and inputs and outputs.
To do zkEVM for general-purpose computing, there are two main difficulties to be solved:
Different contracts require different circuits to be generated, and these circuits are “complex”.
This relies on various optimizations, such as Aleo (but it is not a direct ZK… Just to have an example of the optimizations) to compute proof concurrently through distributed clusters, or to accelerate it through various hardware optimizations.
zkEVM is not only a refactoring of the EVM, but also a refactoring of the entire state transition of the Ethereum using zero-knowledge proof techniques.
When the EVM was designed, it was not expected that zkEVM would be done later, which made it very difficult to implement. The result is that there are two routes. Both of which are in the diagram.
Or in terms of VM architecture, it looks like this (super thanks to Scroll Tech for the original summary!). The Opcode refers to the EVM Opcode. The StarkWare part is to use Warp to convert Solidity to Cairo contracts, or to write contracts directly in Cairo for a good development experience and a better set of tools.
At the developer and user level, I think these solutions are basically indistinguishable, but in terms of infrastructure, the further to the right EVM is, the better the compatibility and seamless access to infrastructure such as Geth, but also the slower the development.
The existence of zkEVM I see as a way to refurbish and patch the Ethereum ecosystem and add to its prosperity, while the existence of zkVM is not necessarily an enhancement to Ethereum, but also has greater potential.
StarkNet’s Cairo VM may not be the perfect zkVM I thought it would be, but it can do a lot more than EVM or zkEVM, and more than just extend the functionality at the EIP level. Machine learning models can be run on Cairo VM, and there is even a machine learning modeling platform being built on StarkNet right now.
Compared to zkEVM, a zkVM is much easier to build (no need to worry about EVM technical debt), much more flexible (no need to worry about EVM updates), and much easier to optimize (hardware and software optimization of circuits and provers is much easier and cheaper than building zkEVM).
Of course, one of the smallest but fatal drawbacks of zkVM is that if zkVM does not support EVM compatibility (at the Solidity language level), then it is very difficult for zkVM to have the most complete and mature Web3 development ecosystem as EVM does.
zkVM is perhaps the bigger trend, allowing vertical optimization of EVM to become a horizontal expansion of the EVM ecosystem, going beyond the limitations of EVM.
What if there was a universal zkVM that would allow smart contracts in all programming languages, not just Solidity, not just Cairo, but Rust, C++, Go, to run with zero knowledge proofs? (Stellar tried, but failed.)
As what @kelvinfichter said: Why zkEVM if zkMIPS? As what @KyleSamani said: EVM is a bug not a feature. Why zkEVM if zkVM?
zkVM like Winterfall, Distaff or Miden VM are not very developer friendly. Nervos has RISC-V VM, but Nervos does not use zero-knowledge proof technology.
The optimal solution is to build a WASM or RISC-V zkVM, preferably with support for Rust, Go, C++, or even Solidity (zkSync can help on that!). If there is such a general zkVM, then it would be a zkEVM killer.
The number of Web3 developers is about 0.07% of all developers, which means that the number of Solidity developers is actually even smaller than 0.07%. The number of Cairo and Leo developers is even smaller. Such a perfect zkVM targets almost 100% of developers, and any developer in almost any language can get a perfect zero-knowledge runtime environment.
If Web3 and Crypto ever rule the world, I don’t think it will be the EVM ecosystem that takes over 100% of all developers, but rather all developers will slowly be convert to Web3 and Crypto developers. This is the beauty of the universal zkVM.
Native zkEVM is the future of the blockchain.
General zkVM is the future of Web3.
原生zkEVM 是區塊鏈的未來,通用zkVM 是Web3 的未來。
零知識證明
不嚴謹但簡單易懂地來介紹一下零知識證明:
你在上小學。老師是驗證者,你作為學生是證明者。你如何證明你掌握了一元二次方程的求解公式呢?那就需要數學考試。
老師會隨機出10 道相關的題目,而你如果掌握了,則可以把他們都做出來。在這個過程中,你沒有背誦或者默寫求解公式的具體內容,但是老師卻可以很簡單地驗證你的知識掌握程度。
其實這就是Tartaglia 與Cardano (對的,就是這個名字) 爭奪誰是一元三次方程發現者時所採用的方法。他們都不想告訴對方自己公式的內容,但是通過做題,就可以很容易地驗證且過程中不透露知識地,判斷他們是否掌握了這一知識。
零知識證明有什麼用呢?用處就是,整個過程可以節省計算算力和壓縮鏈上空間,同時也可以對隱私有保護,符合區塊鏈去信任的特點以及密碼學的基因。
SNARK 和STARK
區塊鏈領域中所用到或者提到的「zk」 通常不是真正的零知識證明,而經常是Validity Proof。由於相關詞彙的混亂,所以本文中的某些地方會延續這些「誤用」。
在目前的區塊鏈版圖中,zk 可以說是區塊鏈擴容(不zk 的Validity Proof) 與隱私技術(真正的zk) 的最前沿與最優解決方案,在Tornado.cash、ZCash、zkSync、zk.money、Filecoin 和Mina 等項目中都有使用。
目前的技術方案主要分為SNARK 以及STARK 兩類。 STARK 中的S 代表可擴展的,意味著被證明的語句有重複的結構,而SNARK 支持任意的電路,這些電路被預處理以實現簡潔的證明。其中對SNARK 的技術實踐佔據了主導地位,STARK 主要有StarkWare 在已上線的產品中大規模採用。以下是它們之間的對比。
從Meme 的角度而言,STARK 比SNARK 優秀(😊,Star Wars,Star Trek)。
如果SNARK 是以太坊2.0 的未來,那麼STARK 就會是以太坊3.0 的未來。正經的來說,STARK 的優勢在於
但是STARK 生成的證明的體積更大,並且還大不少,由於比如WASM 的一些限制,可能會在構建時需要額外的操作(這裡是SNARK)。 Mir 前段時間在Starky 給出了一個AIR-based STARK 的實踐,是Plonky2 的一部分(Plonky2 和Starky 的關係比較複雜。。。)。我個人認為,體積大可以通過各種手法來優化,但是算法本身的時間複雜度是很難再進一步壓縮的。
這些零知識證明技術可以通過合理的結合來構建更強大的應用。比如Polygon Hermez 就通過SNARK 來證實STARK 的正確性,從而減少最終發布證明時的gas fee。
總結來說,SNARK 和STARK 都是優秀的零知識證明技術,各有千秋,而它們的合理結合更加有潛力。
zkVM
前面所說到的Tornado.cash 和zk.money 類似都是僅支持轉賬操作的零知識證明應用,不支持通用的計算。類比來說,這些應用都只有比特幣的功能,遠遠不及以太坊的圖靈完備,更不要說建生態了(比特幣上的智能合約一直沒做出生態來)。
zkVM 就是一個由零知識證明來保證安全可驗證可信特性的虛擬機,簡單來說就是,輸入舊狀態和程序,返回新狀態。它能讓所有的應用都被賦予零知識證明的超能力。
Miden 在ETH Amsterdam 的演講用一張圖很好概括了zkVM 到底是什麼。
zkVM 的優點:
zkVM 的缺點:
現在主流的zkVM 有三大類,括號中是它們的指令集:主流(WASM,RISC-V)、EVM (EVM bytecode)、ZK-Optimized (全新指令集,針對零知識證明所優化,比如Cairo 和zkSync)。以下是根據Miden 在ETH Amsterdam 的演講所整理的類型對比圖:
很多零知識證明開發生態所做的事情大多是讓開發者能用Circom 庫(以及snarkyjs 這種) 或者其他新創造的語言(Leo 或者Cairo 這種語言都有奇奇怪怪的限制) 來做通用zk DApp 的開發,但是沒有像以太坊上用Solidity 那麼直接和易學。
除此之外,還有很多項目,比如zkSync,Scroll,或者Polygon 旗下的好多家都在嘗試做zkEVM 或者其他的zkVM。
EVM