VeilForge
Optimal DEX routing while keeping swaps, balances, and trading intent private.
What it is
VeilForge is a privacy-preserving DEX aggregator that discovers and executes optimal token swap routes across decentralized exchanges while keeping user identity, balances, and trading intent private.
In most existing DeFi systems, every swap publicly exposes a user’s wallet address, token balances, and trading strategy. This transparency creates opportunities for MEV extraction, copy trading, and user profiling. Additionally, many DEX aggregators rely on centralized routing engines that determine the best swap route through proprietary APIs. Users must trust these centralized services to provide fair routing and remain censorship-resistant. VeilForge addresses these issues by combining private wallet commitments, anonymous identity verification, and deterministic routing into a single architecture.
Users begin by creating a private identity in the frontend, where a UUID and secret are generated locally and used to compute an identity commitment. The user then scans the World ID QR code and sends the World ID proof along with the identity commitment to a relayer. The relayer triggers a Chainlink CRE workflow, which verifies the World ID proof by calling the official World ID verification API. Once the proof is validated, the identity commitment is inserted into an identity Merkle tree on-chain. This process ensures that each participant is a verified human while keeping their identity anonymous, since future interactions only require proving membership in the Merkle tree through zero-knowledge proofs.
After establishing an identity, users can create private wallets within the protocol. Instead of exposing addresses and balances, VeilForge represents wallets as cryptographic commitments generated from a nullifier, a secret, and the wallet balance. These commitments are inserted into a wallet Merkle tree managed by the pool contract. Because balances are stored as commitments rather than publicly visible values, users can prove ownership and authorize transactions without revealing sensitive information on-chain.
When a user wants to perform a swap, the frontend generates a zero-knowledge proof showing that the user controls a wallet commitment with sufficient balance. This proof is submitted to the relayer, which triggers another Chainlink CRE workflow responsible for route discovery. The CRE workflow fetches liquidity data from supported decentralized exchanges using the CoinGecko API and evaluates prices, fees, and liquidity depth to determine the most efficient swap path.
At this stage, VeilForge uses an LLM within the CRE workflow as an execution intelligence layer. The LLM helps interpret DEX router interfaces, identify the correct swap function for the selected exchange, and construct the precise router calldata required for execution. Because different DEXs expose different router contracts and parameter structures, the LLM assists in dynamically identifying the correct interface and parameters while the routing decision itself remains deterministic. This allows VeilForge to support multiple exchanges without relying on a centralized routing backend or manually hardcoded integrations.
After selecting the best exchange, the workflow constructs the router calldata required to execute the trade.
The settlement contract then executes the swap using the selected router while updating the user’s wallet commitment in the Merkle tree. Because the transaction is authorized through zero-knowledge proofs and executed using commitment updates, the swap occurs without revealing the user’s identity, wallet address, or balance. The result is a fully private swap where optimal routing is computed automatically and executed securely.
By combining anonymous identity verification, private wallet commitments, and deterministic routing workflows, VeilForge enables users to access the best liquidity across decentralized exchanges while protecting their financial privacy.
This architecture removes the need for centralized routing engines and prevents sensitive trading information from being exposed on-chain, enabling a new model of private and trust-minimized DeFi execution.
How it Works
VeilForge is built as a modular system composed of six core components that work together to enable private identity verification, wallet commitments, and optimal swap execution across decentralized exchanges.
The smart contracts, written in Solidity, form the core settlement and state management layer of the protocol. These contracts manage the private liquidity pool, wallet commitments, and swap execution. Wallets are represented as cryptographic commitments stored in on-chain Merkle trees, allowing balances to remain private while still enabling verifiable state transitions.
The frontend, built with Next.js, provides the user interface for interacting with the protocol. It allows users to create private identities, generate wallet commitments, and initiate swaps. The frontend also generates zero-knowledge proofs locally and interacts with the blockchain through wallet connections and contract calls.
A MerkleTreeManager service, implemented as an Express server, maintains an off-chain mirror of the Merkle trees used by the protocol. It tracks commitments inserted on-chain and generates Merkle proofs required for zero-knowledge circuits. This ensures users can efficiently obtain the correct Merkle paths for proof generation while staying consistent with the on-chain tree state.
The relayer, also implemented as an Express server, acts as the transaction submission layer. It receives requests from the frontend, triggers CRE workflows when necessary, and submits the final transactions to the blockchain. This component enables users to interact with the protocol without directly managing complex transaction logic.
Chainlink CRE workflows handle off-chain computation required by the protocol. CRE is responsible for verifying World ID proofs by interacting with the official World ID verification API and for computing optimal swap routes across decentralized exchanges. It evaluates liquidity data and determines the most efficient execution path before returning the necessary router calldata.
Finally, the protocol uses zero-knowledge circuits written in Noir to implement private wallet functionality. These circuits generate proofs that allow users to demonstrate ownership of wallet commitments and sufficient balances without revealing the underlying values. The proofs are generated using the Barretenberg proving system and verified by the on-chain verifier contracts.
Together, these six components enable VeilForge to provide private identity verification, commitment-based wallets, and optimal DEX routing while preserving user privacy.
Links
Created by
- Pushkar Kumar