撰写: HashKey Capital 研究总监郑嘉梁 Jupiter Zheng
如今,区块链行业的零知识证明项目(“ZKP”)越来越多,尤其是在扩容和隐私保护层面的零知识证明应用的出现,让我们接触到各种各样的零知识证明项目。由于 ZKP 的数学性质,深入理解 ZK 变得更加困难。因此,我们计划从零开始梳理 ZKP 理论和应用层面的一些变化,与读者一起探讨对加密行业的影响和价值,并从几份报告中共同学习,形成我们的见解总结。本文是系列文章的第1篇,主要介绍 ZKP 的发展历程、应用和一些基本原理。
现代零知识证明 ZKP 系统最早是由 Goldwasser、Micali 和 Rackoff 在他们的论文 The Knowledge Complexity of Interactive Proof Systems(即 GMR85)中提出的,该论文于 1985 年提出,1989 年发表。该论文主要说明了需要多少知识才能被证明。在交互系统中经过 K 轮交互后交换以证明一个陈述是正确的。如果交换的知识可以为零,则它被归类为零知识证明 ZKP。假设证明者拥有无限的资源,而验证者只有有限的资源。交互式系统的问题在于证明在数学上并不完全可证明,但在概率上是正确的,尽管概率很小 (1/2^n)。
因此,交互系统并不完美,只是近似完备,而在此基础上出现的非交互系统(NP)系统则具有完备性,是零知识证明 ZKP 系统的完美选择。
早年的零知识证明 ZKP 系统效率不高,可用性不高,所以只存在于理论层面,近 10 年才开始蓬勃发展。随着密码学的出现,ZKP被推上了风口浪尖,成为至关重要的方向。特别是,开发一个通用的、非交互式的、证明大小有限的零知识证明 ZKP 协议是一个重要的探索方向。
基本上,零知识证明 ZKP 的目标是在证明速度、验证速度和证明量的大小之间进行权衡。理想的协议具有证明和验证快速、证明量小的特点。前者的数量由受信任的设置决定。
零知识证明 ZKP 技术最重大的突破是Groth在2010年发表的论文Short Pairing-based Non-interactive Zero-Knowledge Arguments,被认为是ZKP中最重要的一组zk-SNARKs (简明非交互零知识证明) 的理论先驱。
零知识证明 ZKP应用最重要的进展是Zcash在2015年使用的ZKP系统,实现了交易和金额相关的隐私保护。之后,zk-SNARK 和智能合约的概念相结合,zk-SNARK 本身发展到非常广泛的应用场景。其中,一些重要的学术成果包括:
Pinocchio (PGHR13): 2013年 Nearly Practical Verifiable Computation,将证明和验证时间压缩到适用范围。这也是 Zcash 使用的基本协议。
Groth16: 在 2016 年的 Size of Pairing-based Non-interactive Arguments,简化了证明的大小,提高了验证效率。这是目前使用最广泛的ZK基础算法。
Bulletproofs (BBBPWM17): 2017年的 Short Proofs for Confidential Transactions and More,提出了Bulletproof算法,一种非常短的非交互式 ZKP,不需要可信设置。它在 6 个月后应用于 Monero,这是理论到应用的非常快速的组合。
zk-STARKs (BBHR18): 2018 年的 Scalable, transparent, and post-quantum secure computational integrity 其中提出了不需要可信设置的 ZK-STARK 算法协议。这也是ZK发展的另一个吸引眼球的方向。最重要的 ZK 项目 StarkWare 就是基于此诞生的。
包括 PLONK、HALO2 等在内的其他发展也至关重要,它们改进了 zk-SNARKs 的某些方面。
零知识证明 ZKP 最广泛的两个应用是隐私保护和扩容。随着早期隐私交易和Zcash、门罗币等几个知名项目的推出,隐私交易再次成为一个非常重要的品类,但隐私交易的必要性并没有像业界预期的那样突出; 至此,此类代表项目开始逐步进入二三线阵营(并未退出历史舞台)。在应用程序级别,扩展的必要性从未被重视过。但随着 2020 年以太坊 2.0(已更名为共识层 Consensus Layer)向以 rollup 为中心的路线转型,ZK 系列正式引起了业界的关注。
隐私交易: 实现隐私交易的项目有很多,包括使用SNARK的Zcash和Tornado,使用防弹的Monero,还有Dash。 Dash严格意义上并没有使用ZKP,而是一个简单的只能隐藏地址不能隐藏数量的混币系统。我们不打算在这里详细讨论这个问题。
Zcash的交易步骤如下:
• 在系统设置阶段,证明密钥(加密证明多项式)和验证密钥是在 KeyGen 函数的帮助下生成的
• CPA阶段采用ECIES加密方式(Elliptic Curve Integrated Encryption Scheme)生成公钥和私钥
• 铸币阶段,产生新币数量,用于公网地址和币种的承诺
• 在 Pouring 阶段,生成一个 zk-SNARK proof,添加到 pour transaction ledger
• 在验证阶段,验证者验证 Mint 和 Pour 交易量是否正确
Zcash 使用零知识证明 ZK 还是有局限性的:由于它是基于 UTXO 的,一些交易信息只是被屏蔽,而不是完全被掩盖。由于基于比特币设计的独立网络,它也很难扩展(与其他应用程序结合)。屏蔽(即隐私交易)的实际使用率不到 10%,意味着隐私交易尚未成功扩展。
Tornado 通过使用单个大型混合池得到更广泛的使用,并且基于像以太坊这样久经考验的网络。 Tornado 本质上是一个使用 zk-SNARK 的混合池,可信设置基于 Groth16 论文。 Tornado Cash 的特点如下:
• 只能提取存入的加密货币
• 没有币可以提两次
• 证明过程和币的Nullifier是绑定的,证明相同但Nullifier不同的哈希不允许提现
• 具有126位安全性,不会因合成而降级
Vitalik Buterin 曾提到,与扩容相比,隐私相对容易实现。如果能建立一些扩容协议,隐私基本上就不是问题了。
扩容 Scaling: ZKs 零知识证明技术的扩容,可以在第一层网络(如 Mina)或第二层网络(即 ZK-rollup)上实现。 ZK-rollups 的最初概念可能来自 Vitalik 在 2018 年的文章: “On-chain scaling to potentially ~500 tx/sec through mass tx validation”。
ZK-rollup有两个作用,一个是Sequencer,一个是Aggregator。 Sequencer负责打包交易,而Aggregator则负责将大量交易合并并创建rollup,最终形成SNARK证明(或基于其他算法的ZKP)。这个证明会与之前的 Layer1 状态进行比较,然后在以太坊的 Merkle Tree 上更新以计算新的状态树。
ZK-rollup 的优点和缺点
优点: 低成本; 不像 Optimistic rollup 可以在经济上受到攻击; 无需延迟交易; 可以保护隐私; 可以快速达成最终结果。
缺点: 形成ZK零知识证明需要大量的计算; 安全问题(SNARK 需要可信设置); 不能抵抗量子攻击(SNARK 和 STARK 可以); 交易顺序可能会改变。
根据数据可用性和证明的方式,Starkware 对第二层网络 L2 有一个经典的分类(Volition 的数据可用性层可以选择链上和链下):
目前市场上最具竞争力的ZK-rollup项目有:Starkware的Starknet、Matterlabs的zkSync和Aztec的Aztec connect、Polygon的Hermez和Miden、Loopring、Scroll等。
基本上,技术路线在于 SNARK(及其改进版本)和 STARK 的选择,以及支持以太坊虚拟机 EVM(包括兼容性或任何等效项)。
• Aztec 开发了一个通用的 SNARK 协议——Plonk 协议; 运行中的 Aztec3 可能支持 EVM,但隐私优先于 EVM 兼容性
• Starknet 使用 zk-STARK,一种不需要可信设置的 ZKP,但目前不支持 EVM,有自己的编译器和语言开发者
• zkSync 还使用支持 EVM 的 Plonk。 zkSync 2.0 与 EVM 兼容并拥有自己的 zkEVM
• Scroll 是一个 EVM 兼容的 ZK-rollup; 它的团队也是以太坊基金会 zkEVM 项目的主要贡献者
浅谈以太坊虚拟机 EVM兼容性问题:
零知识 ZK 系统与EVM的兼容性一直是个让人头疼的问题,一般的项目一般都会在两者之间做出折衷。强调ZK的可能会在自己的系统中做一个虚拟机,有自己的ZK语言和编译器,但是会增加开发者的学习难度,而且基本不开源,会变成黑盒。
总的来说,目前业界有两种选择:一种是完全兼容Solidity的操作码,另一种是设计一种新的ZK友好型虚拟机,兼容Solidity。业界一开始没有预料到这么快的集成,但近一两年技术的快速迭代,将EVM的兼容性提升到了一个很高的水平,开发者可以实现一定程度的无缝迁移(即 以太坊主链到 ZK-rollup)。这是一个非常激动人心的发展,将影响ZK的发展生态和竞争格局。我们将在以后的报告中详细讨论这个问题。
Goldwasser、Micali 和 Rackoff 提出零知识证明技术 ZKP 应该具有三个属性:
• 完整性: 每个有合理见证者的陈述都可以被验证者验证
• 可靠性: 不合理见证者的陈述不应由验证者验证
• 零知识: 验证过程采用零知识模式进行
因此,要了解ZKP,我们必须从zk-SNARK说起,因为目前很多区块链应用都是从SNARK说起的。让我们来看看 zk-SNARK。
zk-SNARK代表:Zero-knowledge Succinct Non-interactive Arguments of Knowledge; Zero-knowledge 零知识:证明过程零知识,不会暴露冗余信息;Succinct简洁:验证很少; Non-interactive:非交互过程;Arguments论点:计算是合理的; 即有限算力的证明者不能伪造证明,无限算力的证明者可以伪造证明; of Knowledge:证明者无法在不知道有效信息的情况下构造参数和证明。
证明者不可能在不知道证明的情况下构造一组参数和证明(Witness,例如哈希函数的输入或确定 Merkle 树节点的路径)。
Groth16的zk-SNARK的证明原理如下:
步骤如下:
1. 将问题转化为电路。
2. 将电路编译成R1CS的形式。
3. 将 R1CS 转换为 QAP(二次算术程序)格式。
4. 设置可信设置,生成随机参数,包括PK(证明密钥)和VK(验证密钥)。
5. zk-SNARK 的证明生成和验证
在下一篇文章中,我们将开始研究zk-SNARK的原理、发展和应用,通过几个案例探讨zk-SNARK的发展,以及与zk-STARK的关系等。
参考资料:
关于 HashKey Capital
HashKey Capital 是 HashKey 集团的风险投资业务,是一家专门投资于区块链技术、数字资产和加密货币金融基础设施的机构资产管理公司。 HashKey Capital 为合格投资者和专业投资者提供安全访问和多元化的数字资产敞口。 HashKey Capital 结合传统风险投资公司的敏捷性和独立风险管理力,同时发挥全球最大型工业、金融综合企业集团之一的独到网络资源优势。
capital.hashkey.com | ir@hashkey.com
Notes and Disclaimer
Views, information and opinions expressed in this material are those of the individuals involved and do not necessarily represent that of the HashKey Group (including any of its affiliates). While we make every effort to ensure that the information we are sharing is accurate, we welcome any comments, suggestions, or correction of errors.
This material should not be considered as an offer or solicitation to sell, buy or subscribe to any financial instruments or product, securities or any derivative instrument, or any other rights pertaining thereto. We are not acting as a financial adviser, consultant or fiduciary to you with respect to any information provided in this material. We do not express any opinion or recommendation whatsoever as to any strategies, products or any other information presented in the materials.
Any decision made by a party after accessing to this material shall be on the basis of its own research and not be influenced or based on any view expressed in this material or otherwise. This material does not address all risks. This material does not constitute investment advice or a recommendation and has been prepared without regard to individual financial circumstances, objectives or particular needs of you. You should seek their own financial, tax, legal, regulatory and other advice regarding the appropriateness or otherwise of investing in any investments and/or pursuing any investment strategies. The HashKey Group does not express any opinion as to the present or future value or price of any instruments referred to in this material.
By accessing this material, you acknowledge that the HashKey Group makes no warranty, guarantee, or representation as to the accuracy or sufficiency of the information featured in this material. The information, opinions, and recommendations presented in this material are for general information only and any reliance on the information provided in this material is done at your own risk. This material should not be considered professional advice. Moreover, the HashKey Group makes no warranty that this material, or the medium that makes it available, is free of viruses, worms, or other elements or codes that manifest contaminating or destructive properties.
By accessing this material, you acknowledge that the entire contents and design of this material, are the property of the HashKey Group, or used by the HashKey Group with permission, and are protected under applicable copyright and trademark laws. Except as otherwise provided herein, users of this material may save and use information contained in this material only for personal or other non-commercial, educational purposes. No other use, including, without limitation, reproduction, retransmission or editing, of this material may be made without the prior written permission of the HashKey Group.
Unless specifically stated otherwise, the HashKey Group does not endorse, approve, recommend, or certify any information, product, process, service, or organisation presented or mentioned in this material, and information from this material should not be referenced in any way to imply such approval or endorsement. The third party materials or content of any third party site referenced in this material do not necessarily reflect the opinions, standards or policies of the HashKey Group. The HashKey Group assumes no responsibility or liability for the accuracy or completeness of the content contained in third party materials or on third party sites referenced in this material or the compliance with applicable laws of such materials and/or links referenced herein.
The HashKey Group expressly disclaims any and all liability or responsibility for any direct, indirect, incidental, special, consequential or other damages arising out of any individual’s use of, reference to, reliance on, or inability to use, this material or the information presented in this material.