以动物园为例,硬核科普zkSync电路工作原理

Odaily星球日报Publicado em 2024-03-04Última atualização em 2024-03-04

Resumo

一个复杂电路就是形形色色的逻辑门和规则共同构建。

原文作者:Haotian(X:@tme l0 211)

不少人看了@zkSync 新发的动物园科普图文大呼懵圈,把动物园比做电路 circuit,把拥有特殊技能的动物视为「逻辑门 Gate」,把动物们都开心的合影当成「证明 Proof」,这样输入电路的数据在不透露具体内容的前提下,经过一系列复杂计算,生成一个 Proof,就完成一次零知识证明过程。来,我试着硬核科普一下:

1)动物园对应的是「电路」,电路其实是一系列逻辑门约束(加、减、乘、除等公式)的聚合,相当于所有动物们能力的一次集中表现,它也是构成计算机的基本元素。因此传入电路的「数据」一定可被套进各种公式内被执行运算。

在 layer 2 环境都是一些交易哈希值、账户、数据余额之类的数据,这些数据可以转变成公式进行计算,若不能公式化则需进行其他编码转化让其原始数据可以变成公式,这是电路执行处理的前提。

2)各种动物对应电路里的逻辑门,在动物园模式里,分别有:木箱——代表不公开显示的数字,被称之为「变量」;玻璃箱——代表公开显示的数字,为「公开输入」;石头——代表无法移动的数字,被视为「常数」;

斑马具有比较两个数是否「相等」的能力,结果相等斑马就开心;鳄鱼则表示「小于」,只有右边的数小于左边的数,鳄鱼才会开心;蜘蛛代表更复杂的多选择门,输入 0 则返回一定是 true,输入 1 则返回是 false;此外还可以让河狸表示除法、松鼠指代百分比;毛毛虫代表加法等等。不同的动物代表不同的加减乘除运算公式,动物们开心或伤心代表公式运算的结构。

很多个动物 + 不同种类的箱子组合起来就是一个电路,比如:要计算一个公式 2 x + 3 = Y,x 代表木箱,Y 代表石头, 2 个木箱 和毛毛虫、斑马等前来工作,最后来验证该公式是否成立。注意,不用纠结为啥不同动物具备不同能力,这就是电路元素工作基础原理,是计算机执行计算的基本规则。

一个复杂电路就是形形色色的动物(逻辑门)和箱子(规则)共同构建。

3)假设刚才输入的公式 2 x+ 3 =Y 成立了,相当于斑马 毛毛虫等动物都开心了,然后就会为该公式生成一个「Proof」,需要有一个角色能识别这个 Proof 是否准确才行。因此,为了确保证明的可信性,动物园管理员即电路的构建者,模拟了一个特别的动物叫 Zeek,Zeek 能看出其他动物是否开心,在 layer 2 系统中相当于 Verifier。

Zeek 观察动物是否开心的过程其实就是 Prover 系统的验证过程,都开心了则验证通过,Proof 证明才会真正通过上传到主网,并最终确认。当然,动物园成千上万的动物,产生大量证明,Zeek 不可能挨个看,因此 Zeek 也可以观察千千万万个 Zeek 自己的分身状态是否开心,这个过程就叫 Recursive Proof 递归证明。

4)拍照的过程相当于生成 SNARK 证明或 KZG 承诺的过程,而打印的底片则相当于 STARK\SNARK 证明本身,动物园的游客相当于一个个进入的 Transaction 交易,只有动物开心合照才会完成并生成 Proof 证明,最终游客拿着照片出了动物园留底证明才能被上链最终确定。

一个动物园有很多动物,不可能同时都开心并按照预定规则工作,有很多逻辑门,也难免会出现掉线等情况。这样就会出现一些,拥堵卡顿以及报错的情况,因此会产生无效的状态转化,Under- Constrained,也就无法通过最终的验证。

原文链接

Leituras Relacionadas

Commerce Ministry's Latest Export Controls Target 10 US Companies: Three Market-Moving Threads Explained

China's Ministry of Commerce placed 10 U.S. entities, including MP Materials, USA Rare Earth, Red Cat Holdings, and Teal Drones, on an export control list, banning the export of dual-use items. This move is seen as part of an ongoing countermeasure in the rare earth sector. The analysis suggests the primary impact is on U.S. companies within the **military, drone, and rare earth** sectors, aiming to restrict their access to critical Chinese materials and technology. For the Chinese market, the event is interpreted as reinforcing the **strategic value and pricing power** of domestic rare earth suppliers. However, the potential stock market reactions are nuanced: 1. **Chinese Rare Earth Upstream:** Companies like Northern Rare Earth are near yearly highs, indicating this event's "beneficiary" logic is largely priced in. It may confirm the trend but is unlikely to be a new major catalyst. 2. **Chinese Rare Earth Mid/Downstream & Drones:** Sectors like magnetic materials (e.g., Da Di Bear, Zhenghai Magnetic) and military drones (e.g., China Aerospace) are relatively undervalued. While the drone listing highlights sectoral competition, it doesn't directly translate to new orders for Chinese firms. 3. **Impact on Listed U.S. Companies:** The effect on stocks like MP Materials is ambiguous. While Chinese restrictions pose a challenge, these companies are also core to U.S. supply chain security efforts and may receive increased government support, potentially offsetting negative impacts. Their pre-announcement stock prices did not indicate panic selling. In summary, the export controls strengthen China's position in the global rare earth supply chain but have uneven effects across related stock market segments, with upstream Chinese gains likely priced in and downstream/drone sectors receiving more indirect, sentiment-driven attention. The outcome for the targeted U.S. stocks depends on the balance between restriction impacts and potential compensatory U.S. policy support.

marsbitHá 7m

Commerce Ministry's Latest Export Controls Target 10 US Companies: Three Market-Moving Threads Explained

marsbitHá 7m

Uniswap v4 Hook Analysis: Architecture Design, Common Vulnerabilities, and Protection Practices

Uniswap v4's Hook mechanism is a major innovation, enabling custom logic injection into liquidity pool lifecycle events like swaps and liquidity provisioning. This transforms the AMM into programmable infrastructure, shifting the security model from protocol-level to pool-level, as each pool's safety now depends on its bound Hook contract. The core architecture revolves around the singleton PoolManager contract, which manages all pools via a flash accounting system. State changes are tracked in transient storage and must be settled by the end of a transaction. Hook contracts are permanently bound to pools via a PoolKey, with their permissions encoded directly into their address via specific low-order bits. This design introduces unique security considerations and challenges for future upgrades. Key vulnerabilities and best practices identified include: - **Access Control Gaps:** Early versions of the BaseHook abstract contract only protect `unlockCallback()`, leaving other lifecycle functions (`beforeSwap`, `afterSwap`, etc.) exposed unless explicitly secured by developers. - **Unrestricted Pool Binding:** The `initialize()` function does not validate if a Hook "consents" to a new pool. Hooks must implement their own whitelisting in `beforeInitialize` to prevent unauthorized pool creation. - **Async/Custom Curve Hooks:** These high-risk Hooks can completely replace Uniswap's swap logic. Their security depends entirely on their own implementation, as they operate outside the native protocol's pricing safeguards. - **Delta Accounting Risks:** The system ensures final balance (NonzeroDeltaCount == 0) but cannot guarantee the *correctness* of intermediate delta states, which attackers could manipulate. - **Token Confusion:** Protocols must implement semantic validation for tokens in user-created markets, not just interface checks, to prevent cross-market confusion attacks. The article emphasizes that Hook auditing requires a "sub-protocol" approach due to extended interaction chains, highlighting a significant shift in security methodology for the v4 ecosystem.

marsbitHá 59m

Uniswap v4 Hook Analysis: Architecture Design, Common Vulnerabilities, and Protection Practices

marsbitHá 59m

Chips, Open-Source Models, and $50 Trillion: Joe Tsai Reassesses Alibaba Once Again

Alibaba Executive Chairman Joe Tsai recently outlined the company's comprehensive AI strategy in a public discussion. He believes AI represents a massive opportunity, estimating its potential economic impact at up to $50 trillion, stemming from the automation of human intelligence and productivity. Tsai detailed Alibaba's four-layer investment approach across the AI stack: starting from the chip level, moving to cloud infrastructure (Alibaba Cloud), then the model layer with its open-source Qwen model, and finally applications within its vast digital ecosystem (e-commerce, logistics, etc.). The company avoids the energy layer due to China's efficient infrastructure. This broad strategy is designed to ensure Alibaba captures value regardless of where it ultimately concentrates in the AI value chain. He dismissed concerns about an AI investment bubble, pointing to the enormous $50 trillion opportunity. While acknowledging U.S. cloud giants' higher capital expenditure, he argued Chinese firms, including Alibaba (funded by its cash-generative e-commerce core), need to invest more in AI infrastructure. A key theme was technological sovereignty. Tsai positioned open-source models like Qwen as a solution for companies, especially in Europe, seeking independence from proprietary U.S. models and greater data privacy control. He contrasted this with the trend of U.S. giants keeping their models closed-source. Tsai highlighted Alibaba's collaborations with European manufacturers like Bosch and Siemens, using AI for design and quality control. He concluded with an optimistic vision of AI agents enhancing productivity, ultimately freeing up human time for leisure, family, and experiences like live entertainment.

marsbitHá 1h

Chips, Open-Source Models, and $50 Trillion: Joe Tsai Reassesses Alibaba Once Again

marsbitHá 1h

Trading

Spot
Futuros
活动图片