Skip to content

anylots/priv-eth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Native privacy payments for Ethereum

A single stateful precompile added to the EVM enables native private payments on Ethereum's Execution Layer (EL).

Supports Scalable Compliant Privacy — operators hold view keys and run permissioned relayers to meet compliance requirements without compromising user privacy.

It remains compatible with the @kohaku-eth/railgun core wallet and any standard ERC-20 token, while fully reusing the existing user-experience infrastructure.

Technical Philosophy

Fully EVM-equivalent. Without breaking the original EVM functionality, and based on the "EVM Plus" philosophy, this project achieves high-performance privacy features:

  • Modular Extension (based on unforked Reth): Leverages Reth's modularity and abstraction capabilities to integrate privacy features as an extension, without modifying the core codebase.
  • Stateful Precompiles: Moves the core logic of privacy payments down into precompiles, achieving higher execution efficiency while maintaining EVM compatibility.
  • Native Privacy & Cryptography: Integrates zero-knowledge proof verification at the protocol layer to provide native privacy capabilities at lower cost, while remaining compatible with the existing EVM ecosystem.
  • Built for specialized Layer 2s (EVM Plus): Provides a strong foundation for constructing privacy-focused or application-specific Layer 2 networks.

Architecture Overview

Ethereum State Trie with PrivacyPay Precompile

The diagram above shows a simplified model of the Ethereum State Trie. PrivacyPay, as a stateful precompile account, coexists with ordinary contracts such as ERC20 and Dex in the same state trie. A slot in its Storage Trie stores the UTXO Merkle Tree Root, and all encrypted Commitments are organized as leaf nodes under this UTXO tree.

How It Works

The privacy transaction model in this project uses zero-knowledge proofs (zk-SNARKs) to protect user transaction privacy, ensuring transaction authenticity and fund security:

  1. UTXO State Storage: All user funds are stored on-chain as encrypted Commitments (UTXOs) in a Merkle Tree.
  2. Precompile Execution: When a privacy transaction (e.g., shield or transact) is initiated, the request is routed to our newly added Rust precompile contract.
  3. State Update: The precompile contract efficiently verifies the user-provided zk-proof (proving ownership of a valid UTXO in the Merkle Tree without double-spending). Upon successful verification, new leaf nodes are inserted and the Merkle Tree Root is updated, completing the state transition.
  4. Wallet Integration: Users interact via the existing @kohaku-eth/railgun wallet infrastructure. The wallet uses the user's spendingKey and viewingKey to locally construct transactions, encrypt data, and generate zk-proofs.

Directory Structure

  • ./src/: Core Rust implementation.
    • ./src/precompiles/privacy_pay/privacy_wallet.rs: Entry point for the privacy precompile, implementing core functions such as shield (depositing funds into a private address) and transact (transactions between private addresses).
    • ./src/precompiles/: Specific precompile logic related to privacy transactions.
    • ./src/contracts/: Interfaces and parameter types defined using alloy_sol_types, enabling type-safe interaction in Rust.

Note: This project is currently in the PoC stage. The primary goal is to run through the main flow and validate the architectural feasibility.

Getting Started

To get started with this project, follow these steps:

  1. Clone the repository:

    git clone https://github.com/anylots/priv-eth.git
    cd priv-eth
  2. Run the node:

    cargo run --no-default-features -- --dev
  3. Init PrivacyPay Precompile:

    cast send 0x0000000000000000000000000000000000000a16 "initialize()"   --rpc-url http://127.0.0.1:8545   --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
  4. Interact with the PrivacyPay precompile:

    • Use the @kohaku-eth/railgun wallet to interact with the privacy precompile.
    • Refer to the wallet documentation for detailed usage instructions.
    • You can also experience the privacy payment feature using the demo wallet below: https://github.com/anylots/priv-eth-wallet.git

Acknowledgements

This project draws inspiration from Zcash and kohaku-eth/railgun, whose cryptographic designs were studied extensively. In particular, the key-derivation hierarchy (spending key / view key separation) follows the Zcash Sapling construction, and the shielded UTXO model with zk-SNARK proof generation is adapted from the Railgun protocol(To ensure compatibility with existing wallet SDKs).

License

This project is for personal technical research only and should not be applied to any actual user-facing or third-party scenarios.

Restrictions

  • No production use
  • No user-facing deployment

About

Native privacy payments for Ethereum

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors