Every swap you make on a decentralized exchange is public. The token, the amount, the timing and your wallet address are visible to anyone watching the blockchain. That transparency is fundamental to how blockchains work, but it has costs: MEV bots front-run your trades, analysts track your portfolio, and your entire financial history is one click away.
I wanted to fix that. VoidDex is my attempt at a DEX aggregator that keeps the benefits of decentralized trading and adds a cryptographic privacy layer on top.
The Core Problem
Every address you interact with, every token you hold and every trade you make is permanently recorded on the blockchain. Anyone can pull up the whole history on Etherscan.
That is how blockchains work, and it creates serious privacy problems. If you are paid in crypto, your employer can see your salary. A merchant can see your net worth when you pay them. An analyst can track your entire portfolio and your trading patterns.
For individuals and institutions alike, that level of exposure is often unacceptable. Traditional finance does not broadcast your bank transactions to the world, and I do not see why DeFi should.
Private transactions also come with a secondary benefit: protection from MEV extraction. Bots cannot front-run what they cannot see.
The Technical Solution
VoidDex combines two things: DEX aggregation for the best swap rates, and zkSNARK proofs for transaction privacy.
The architecture splits the work between client and server along a strict line. Your browser does everything that touches secrets. It generates your private keys and stores them encrypted, runs the Railgun SDK through WebAssembly, generates the zero-knowledge proofs, and decrypts your balance by scanning the merkle tree. The VoidDex API does everything that does not. It fetches price quotes from multiple DEXes, optimizes routing across liquidity pools, and serves token metadata and network status.
The critical point is that all cryptographic operations happen locally. The server never sees your keys, your balances or your transaction details.
How the Privacy Flow Works
The system runs on a shield and unshield model, and a private swap passes through five stages.
It starts with a shield. Your public ERC-20 tokens enter Railgun's privacy pool and become part of an anonymity set with thousands of other shielded tokens. From then on you hold a private balance that only you can see: the blockchain shows that tokens entered the privacy pool, but not whose private balance they belong to.
When you swap, the Railgun SDK generates a zkSNARK proof that you have a sufficient balance without revealing which specific UTXOs are yours, and that proof is submitted on-chain. In the execution stage, Railgun's contracts verify the proof and call the VoidDex Router, which executes the actual swap on whichever DEX offers the best rate: Uniswap V3, SushiSwap, PancakeSwap, QuickSwap or Camelot. Finally the output tokens return, shielding automatically back into your private balance.
From the blockchain's point of view, tokens moved through Railgun's contracts and a swap happened. The connection between your public address and the swap is cryptographically broken.
The Zero-Knowledge Component
zkSNARK proofs are the core of the privacy model. A private swap proves three things:
- You own tokens in the privacy pool (without revealing which ones)
- The amount is sufficient for the swap (without revealing the exact amount)
- The transaction is authorized by you (without revealing your identity)
The proofs are generated entirely in your browser with WASM-compiled circuits. Generation takes approximately 15 seconds on modern hardware. The proof itself is small, a few hundred bytes, and verifying it on-chain is gas-efficient.
Security Model
The trust assumptions are minimal:
| Component | Trust Requirement |
|---|---|
| Private Keys | None - generated locally, never transmitted |
| ZK Proofs | None - generated locally, verified on-chain |
| Balance Data | None - encrypted, only you can decrypt |
| VoidDex Server | Limited - only provides quotes, no access to private data |
| Railgun Contracts | Smart contract security - audited, battle-tested |
If the VoidDex server were compromised, an attacker could serve bad quotes. They could not access your funds or break transaction privacy, because both of those are enforced cryptographically.
Why Build on Railgun?
I chose Railgun for four reasons. It is proven infrastructure that has processed significant volume without security incidents. It supports any ERC-20 instead of a fixed list of tokens. Its SDK integrates cleanly into browser-based applications. And its design is non-custodial, with no trusted parties and no admin keys.
Building custom zkSNARK circuits would have taken months. Railgun's SDK let me focus on the aggregation layer and build on privacy infrastructure that has already proven itself.
Current Status and Roadmap
VoidDex is live on Sepolia testnet, and the core works there: shielding and unshielding tokens, private swaps across the aggregated DEXes, and client-side proof generation.
Mainnet deployment across Ethereum, Polygon, Arbitrum and BSC is planned once testing is complete.
Technical Challenges
Building this was not straightforward. Three problems took most of the effort.
Proof generation performance. The initial WASM compilation took 30+ seconds. Optimizing the SDK initialization and caching the prover keys brought that down to ~15 seconds.
Merkle tree sync. Private balances require scanning the blockchain for your encrypted notes, which is computationally intensive. I implemented incremental sync so the client does not re-scan the entire tree.
Multi-DEX routing with privacy. Finding optimal routes while respecting the privacy constraints required custom logic. The router has to handle partial fills and slippage across privacy pool interactions.
Conclusion
Privacy in DeFi is not about hiding illicit activity. It is about bringing the financial privacy we already expect from traditional finance to decentralized systems. Your bank does not broadcast your transactions to the world, and your DEX should not either.
VoidDex is my contribution to that: a practical tool that combines the efficiency of DEX aggregation with the privacy of zero-knowledge proofs.
Keep reading
- Privacy Architecture in VoidDex: Integrating Railgun's zkSNARK System
How VoidDex implements private token swaps using Railgun's zero-knowledge proof system, covering the shield/unshield flow, client-side proof generation, and the Waku P2P broadcaster network.
- VoidDex Router: Designing a Multi-DEX Swap Router with Split Routing
Deep dive into VoidDex's smart contract architecture, covering the router design, DEX adapter system, and split routing for optimal execution.
- DEX Aggregation in VoidDex: Building an Optimal Route Finder
How VoidDex's backend finds the best swap routes across multiple DEXes, covering the quote service architecture, route optimization strategies, and fee calculation system.