Decode ZK-SNARKs in Solidity: Privacy, Optimization, and MEV Resistance

Table of Contents
Ethereum, a leading blockchain platform, has opened up exciting possibilities for developers to create smart contracts and DApps. However, as Ethereum has evolved, new challenges have emerged, notably privacy concerns within various applications. This article explores how Zero-Knowledge Succinct Non-Interactive Argument of Knowledge (ZK-SNARKs) can be integrated into Solidity, Ethereum's programming language, to address these issues.

I. Technical Barriers

EVM Smart Contract Multithreading
Currently, Ethereum's smart contracts execute sequentially, leading to performance bottlenecks when dealing with large-scale data. To overcome this limitation, the integration of multithreading is essential. Optimizations like asynchronous calls, event-driven programming, and delegation splitting must be implemented to enable concurrent execution.
Auditable Zero-Knowledge (ZK)
Auditable ZK allows third parties to verify ZK proofs without revealing the specific details of the statement. While enhancing security, it demands more computational resources, putting pressure on performance optimization in Solidity and ZK circuits.
Proof System Scalability
Existing proof systems encounter scalability issues when dealing with large-scale circuits. Solutions like recursive proofs and distributed proofs aim to enhance scalability and address the challenge of proving large-scale circuits.
Proof System Security Risks
Some proof systems, such as Groth16 and Marlin, rely on trusted setups, introducing security concerns. These "toxic waste" setups need to remain private to ensure the system's security.

III. Currently Used ZK-SNARKs Schemes

1. Groth16
   - Small proof size
   - Fast verification
   - Trusted setup bound to the circuit
   - New trusted setup required for different circuits
2. Marlin
   - Support for globally updatable trusted setup
   - Achieves succinct verification
   - High complexity in the proof process
   - Less succinct proof size compared to Groth16
3. Plonk
   - Support for globally updatable trusted setup
   - Fully succinct verification
   - More scalable circuit representation
   - Less succinct proof size compared to Groth16
4. HALO2
   - No need for a trusted setup
   - Introduces recursive proofs for optimized proof speed
   - Less succinct proof size
5. Circom + Snarkjs
   - Smaller proof sizes
   - Faster verification times
   - Independent of computation task size
   - Not the most user-friendly language for developers
Performance comparison:
Source: Mirror -
Different programming languages (Circom, Noir, Halo2) writeto write the same circuit, and then test the proving and verifier time with different numbers of rounds. All experiments run on the Intel Core i5 processor with 16GB RAM and MacOS 10.15.7.

IV. Scenario Demonstrations

1. Privacy Enhancement

One of the most compelling applications of ZK-SNARKs in Solidity is privacy enhancement. It addresses the critical need for confidentiality in Ethereum-based applications, particularly in scenarios involving sensitive financial transactions, anonymous voting, and more. Here's a closer look at how ZK-SNARKs can bolster privacy:
Using Poseidon Hash: To safeguard transaction information, Ethereum developers can utilize ZK-SNARKs along with cryptographic techniques such as Poseidon Hash. This approach allows users to keep transaction details confidential while proving the validity of the transaction to relevant parties. For instance, consider a limit order where the price needs to be concealed from the public but still verified. ZK-SNARKs can be used to prove that the balance required for the order aligns with the hidden price, providing privacy without sacrificing security.
ZK-SNARK Proof: ZK-SNARKs, as mentioned earlier, enable the creation of succinct, privacy-preserving proofs. These proofs can be used to demonstrate the correctness of a statement without revealing any sensitive information. This concept is particularly powerful in applications where the details of a transaction or operation need to remain hidden from public scrutiny. Whether it's a financial transaction, voting process, or any other operation, ZK-SNARKs can be applied to provide both privacy and trust.
By integrating privacy enhancements with ZK-SNARKs, Ethereum-based applications can cater to users' demands for confidentiality without compromising security. This not only empowers users to conduct transactions, share data, and participate in activities privately but also safeguards against any malicious actors attempting to exploit vulnerabilities.

2. Computational Optimization

Beyond privacy enhancements, ZK-SNARKs in Solidity also play a pivotal role in computational optimization. This optimization is crucial for ensuring the efficiency and cost-effectiveness of Ethereum applications, especially those with resource-intensive processes. Let's delve into this area in more detail:
AMM Logic Circuit: Decentralized finance (DeFi) applications, such as Automated Market Makers (AMMs), often involve complex computations. These computations can be resource-intensive and result in high gas costs when executed on the Ethereum blockchain. To address this, developers can move heavy AMM logic off-chain, minimizing on-chain processing. ZK-SNARKs can then be employed to verify the accuracy of these off-chain computations, allowing for significant cost savings.
On-Chain Check Contract: Ethereum applications can create on-chain verification contracts that check the outcomes of off-chain computations. This approach enables applications to maintain the integrity of the process while benefiting from reduced gas costs and improved efficiency. By utilizing ZK-SNARKs for verification, developers ensure that the results of these complex computations are accurate, thus enhancing the overall user experience.
Incorporating computational optimization with ZK-SNARKs enables Ethereum applications to perform resource-intensive operations efficiently and cost-effectively. This is especially beneficial for DeFi platforms, which rely heavily on intricate financial calculations. By offloading some of these calculations off-chain and using ZK-SNARKs for verification, developers can provide users with a seamless and affordable experience.
By incorporating both privacy enhancements and computational optimization, Ethereum applications can deliver improved user experiences while ensuring data privacy and transaction security. These real-world scenario demonstrations showcase the practical application of ZK-SNARKs in Ethereum and highlight their potential to revolutionize the way blockchain-based applications function.

V. Anti-MEV Attacks

In the fast-paced world of blockchain, one of the most significant challenges faced by participants is Maximum Extractable Value (MEV). MEV represents the profit or advantage that miners and other malicious actors can extract by strategically reordering transactions or engaging in front-running. However, the integration of ZK-SNARKs in Ethereum applications offers a robust defense against MEV attacks. Here, we explore how privacy enhancements achieved through ZK-SNARKs impact MEV resistance:
  1. Impact of Privacy Modifications: Privacy modifications, facilitated by ZK-SNARKs, directly impact the effectiveness of MEV attacks. By concealing transaction details and rendering them private, the potential for front-running and other MEV-related exploits is significantly reduced. Here's how privacy enhancements achieved through ZK-SNARKs counteract MEV:
  2. Obfuscating Transaction Information: With ZK-SNARKs, Ethereum applications can conceal sensitive information within transactions. This includes hiding the specific details of a trade, the price, the participants involved, and any other sensitive data. When this information remains hidden, malicious actors find it challenging to gain insights into profitable trades that they can front-run.
  3. Immutable Privacy: ZK-SNARKs ensure that once privacy modifications are applied to a transaction, the privacy remains immutable. This means that even when transactions are executed on the public blockchain, the privacy protections provided by ZK-SNARKs persist, making it extremely difficult for adversaries to exploit or manipulate transactions for their benefit.
  4. Reduced Attack Surface: The introduction of ZK-SNARKs reduces the attack surface for MEV. With sensitive transaction details hidden from prying eyes, there are fewer opportunities for adversaries to engage in front-running or MEV extraction. This improved privacy creates a more level playing field for all participants, promoting fairness and trust in the ecosystem.
  5. MEV Ineffectiveness: As privacy-enhanced transactions become the norm, MEV attacks become less effective. Miners and other malicious actors rely on transparent information to exploit opportunities, and when this information is hidden, their strategies lose their edge. ZK-SNARKs are a powerful tool for ensuring that MEV tactics are met with resistance.
In summary, ZK-SNARKs provide Ethereum applications with a powerful defense against MEV attacks. By concealing sensitive transaction details, maintaining immutable privacy, and reducing the attack surface for malicious actors, ZK-SNARKs enable a more secure and equitable blockchain environment. As a result, the integration of ZK-SNARKs contributes to a healthier and more resilient blockchain ecosystem where participants can transact with confidence.


Integrating ZK-SNARKs into Solidity brings multiple benefits to Ethereum applications. It provides enhanced privacy through features like private transfers, transactions, and voting, optimizes computational processes, and fortifies resistance to MEV attacks. Developers can leverage ZK-SNARKs to boost the privacy, performance, and security of their applications, marking a promising trend in the future of Ethereum development. This integration opens the door to innovative possibilities, enhancing the Ethereum ecosystem as a whole.

About Orochi Network

Orochi Network is a cutting-edge zkOS (An operating system based on zero-knowledge proof) designed to tackle the challenges of computation limitation, data correctness, and data availability in the Web3 industry. With the well-rounded solutions for Web3 Applications, Orochi Network omits the current performance-related barriers and makes ways for more comprehensive dApps hence, becoming the backbone of Web3's infrastructure landscape.
Event Recap
Monthly Report
Verifiable Random Function
Zero-Knowledge Proofs
Top Posts
Introducing Orochi Network - The Operating System For High Performance dApp And Metaverse
10 January 2023
Orosign Wallet 101: How to get started?
03 February 2023
Validity Proofs vs. Fraud Proofs: An Explanation
06 January 2023
Introducing Orosign Multisignature Wallet - A Self-Managing Mobile App For Digital Assets
06 January 2023
Introducing Orand: Your Trustless Source of Randomness
20 February 2023
Partnership Announcement
Layer 2
Event Recap
Immutable Ledger
Verifiable Random Function
Zero-Knowledge Proofs
Multisignature Wallet

Orosign Wallet

Manage all digital assets safely and securely from your mobile devices

zkDatabaseDownload Orosign Wallet
Coming soon

zkOS for Web3

© 2021 Orochi