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.
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.
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.
The privacy transaction model in this project uses zero-knowledge proofs (zk-SNARKs) to protect user transaction privacy, ensuring transaction authenticity and fund security:
- UTXO State Storage: All user funds are stored on-chain as encrypted Commitments (UTXOs) in a Merkle Tree.
- Precompile Execution: When a privacy transaction (e.g.,
shieldortransact) is initiated, the request is routed to our newly added Rust precompile contract. - 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.
- Wallet Integration: Users interact via the existing
@kohaku-eth/railgunwallet infrastructure. The wallet uses the user'sspendingKeyandviewingKeyto locally construct transactions, encrypt data, and generate zk-proofs.
./src/: Core Rust implementation../src/precompiles/privacy_pay/privacy_wallet.rs: Entry point for the privacy precompile, implementing core functions such asshield(depositing funds into a private address) andtransact(transactions between private addresses)../src/precompiles/: Specific precompile logic related to privacy transactions../src/contracts/: Interfaces and parameter types defined usingalloy_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.
To get started with this project, follow these steps:
-
Clone the repository:
git clone https://github.com/anylots/priv-eth.git cd priv-eth -
Run the node:
cargo run --no-default-features -- --dev
-
Init PrivacyPay Precompile:
cast send 0x0000000000000000000000000000000000000a16 "initialize()" --rpc-url http://127.0.0.1:8545 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 -
Interact with the PrivacyPay precompile:
- Use the
@kohaku-eth/railgunwallet 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
- Use the
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).
This project is for personal technical research only and should not be applied to any actual user-facing or third-party scenarios.
- No production use
- No user-facing deployment