Technical

Ethereum Proofs - Noir Library Use Cases

July 11, 2024
Rafal Klich
linkedin logo

Recently, vlayer partnered with Aztec Labs, the creators of the first privacy-preserving Layer 2 on Ethereum, and Noir, a domain-specific language for zk-SNARK proofs. This collaboration resulted in the creation of a library written in Noir, which allows developers to access Ethereum on-chain data inside private computation.

This simple but powerful functionality has a wide range of applications. Keep reading as we explore a few real-world use cases.

The Library

Our Ethereum Proofs Noir library is designed to facilitate access to verified building blocks of Ethereum easily. Here's what it offers:

  • Account State (aka State Proofs): State of an account at any given block, including balance, nonce, code hash, and storage root.
  • Smart Contracts Variables (aka Storage Proofs): Retrieve values stored in specific slots within a contract.
  • Transactions: Confirm the inclusion of a specific transaction in a block.
  • Receipts: Verify a transaction's success status and gas usage.
  • Emitted Events: Check for log entries for a specific event within a transaction or block.

Our codebase also supports fundamental Ethereum structures and algorithms in Noir, including:

  • Decoding RLP format.
  • Ethereum Merkle Patricia Trie proofs.
  • A DSL for encoding slots (allowing access to smart contracts variables).
  • Basic Ethereum data types in Noir: uint256, address, bytes32, hash.
  • Fragment data structure, similar to Rust's slice, used for parsing data.

Additionally, we provide smart contracts that verify inclusion blocks in the chain for the most recent 256 blocks.

With these features, our library enables developers to build a variety of interesting applications on Ethereum. Here are some ideas.

Privacy-Preserving DeFi Protocols 

Privacy-preserving blockchains and Layer 2 solutions are some of the most anticipated innovations in web3 infra. Examples include Aleo, Aztec, and AlephZero. These platforms support DeFi protocols that hide specific metrics from public view, enabling customizable privacy settings that allow selective disclosure of information while keeping user balances and transactions private.

Privacy is crucial, but transparency in DeFi helps monitor the health of protocols and respond to potentially undesirable activities. This is where zero-knowledge proofs of reserves come into play. They provide essential information about DeFi applications while keeping user balances private.

Imagine a DEX built on the Aztec, leveraging Aztec's dual-state feature that offers both public and private states on one chain. Such a DEX would require access to external liquidity pools or the construction of an OTC private transaction. In either scenario, it would need to obtain information from another blockchain to retrieve price data or ensure that funds for transactions are secured.

vlayer's Verifiable Data Infrastructure and ecosystem integration

How about a lending protocol? It keeps certain information private, so alternative methods are required to prove the protocol’s trustworthiness and attract more users. High-level metrics like TVL and loan-to-value ratios could be public, while more nuanced data—the number of users, transactions, or protocol revenue—set as private. The protocol might want to verify this information trustlessly when requested by potential market makers or other actors interested in detailed protocol health information.

Proving reserves locked in a private DeFi protocol is also important from a user's perspective. For example, if the user wants to demonstrate that they have a certain amount of funds locked in the protocol on in a matter that Aztec that doesn't disclose balances and transactions, zero-knowledge proofs can enable this. This proof could support undercollateralized lending based on private credit score models, allowing the assessment of the borrower’s creditworthiness without revealing specific amounts locked in the protocol.

Cross-Chain Interoperability

One of the most pressing issues in Ethereum’s rollup-centric roadmap is liquidity fragmentation. Rollups operate independently, preventing applications from accessing the entire capital locked across the Ethereum ecosystem. 

The benefits of zk-interoperability can be realized in several ways:

  • Cross-Chain Lending: Imagine locking ether in a lending protocol on Arbitrum and wanting to borrow USDC on Base. A cross-chain proof verified on Base, along with a short delayed collateral release mechanism on the lending chain implemented for security reasons, can facilitate this process. This approach avoids using cumbersome and expensive bridges.
  • DAO Voting: Many protocols, like Uniswap, primarily operate on Ethereum but have a significant presence on other chains. If these protocols offer DAO governance voting through tokens on Ethereum, any tokens bridged to other chains would be excluded from voting. Using zk-proofs, vlayer can collect votes from different chains according to the governance protocol, aggregate them, and send the results to Ethereum with proof of their validity.
  • Data Feeds: Various chain-to-chain storage or transaction inclusion proofs can be generated and verified. For instance, vlayer can aggregate price data from multiple DEXes across different L2s. This data can be used to find the most accurate prices if there is low liquidity on a particular chain. Similarly, cross-chain airdrops can be deployed transparently and trustlessly based on activity on multiple chains. Additionally, insurance payouts can be processed based on liquidations that occur on another chain.

By leveraging zk-proofs, we can create a more interconnected and efficient Ethereum ecosystem, even as we await more permanent solutions to chain fragmentation.

New Wave of DeFi

It might seem, the era of easy innovation in DeFi is behind us. Now, protocols must introduce more sophisticated, modular, and customizable updates. Uniswap v4 with Hooks is a prime example of this advancement, allowing developers to deploy smart contracts that trigger actions at different points in a liquidity pool's lifecycle. This enables market makers to implement advanced strategies, often requiring historical on-chain data.

Our Noir library facilitates the extraction of this data and, through v4 Hooks, enables features such as reducing impermanent loss by implementing dynamic fees or calculating average asset prices over specified timeframes.

Minimizing impermanent loss is crucial for market makers, especially in volatile conditions. While waiting for market stability is not always feasible, adjusting swap fees is a viable strategy. Defining volatility and stability varies for each trading pair. In such an environment access to historical data is essential to determine if a 10% swing is volatile for a specific pair within a given timeframe and to set fees accordingly.

The library helps access this data and perform the necessary computations. This process can be triggered periodically to provide updated metrics based on your requirements. Your Hooks contract will receive results verified by zero-knowledge proof, validating their accuracy.

Summary

Zero-knowledge proofs of reserves and transaction inclusions open up a range of use cases that were not previously available without significant trust assumptions and infrastructure overhead. Zk-proofs transform this landscape by unlocking new blockchain possibilities, and while they won't solve all problems, it is a significant step forward.

At vlayer, we focus on developer experience and tackling blockchain's most pressing problems. Our Ethereum ecosystem storage proofs library was created with this specific goal in mind. You can access it here and start using it right away. If you have any questions, reach out to us on our Discord.

This is just the beginning - stay tuned for more developments, as we have exciting advancements in the pipeline that we cannot wait to share!

Share the article
linkedin logo