The Hybrid Model (L1 + Enclave)
The architecture of DarkVeil is fundamentally a hybrid system, engineered to achieve what neither a purely on-chain nor a purely off-chain system can accomplish alone: provably secure trading with absolute privacy and high performance.
This model intelligently separates responsibilities, assigning each task to the environment best suited for it.
The On-Chain Layer: The Foundation of Trust
This layer is the bedrock of the protocol, built directly on Ethereum Layer 1. Its role is not to be fast, but to be an unimpeachable source of truth and the ultimate guarantor of asset security.
Think of it as the protocol's Vault and Judge.
The Vault Contract: This is a non-custodial smart contract that holds all user collateral. It is programmed with a simple but unbreakable rule: it will only move funds when instructed by a valid, cryptographically signed message from the trusted off-chain enclave network.
The Settlement Contract: This contract acts as the judge. It receives the results of trades and liquidations from the off-chain layer. Its sole job is to verify the cryptographic signature on these results. If the signature is valid, it finalizes the trade and instructs the Vault Contract to settle the assets.
The Oracle Bridge: This contract serves as a secure on-chain gateway for the price oracle (e.g., Chainlink). It ensures the price data used by the off-chain system is transparent and verifiable.
Characteristics: Maximally secure, decentralized, and transparent, but slower and more expensive. It is used only for the most critical functions: deposits, withdrawals, and final settlement.
The Off-Chain Layer: The Engine of Privacy
This layer is where the "dark pool" magic happens. It is a decentralized network of nodes, each running the DarkVeil software inside a Secure Enclave (TEE).
Think of it as the protocol's Confidential Engine.
Confidential Order Book: All open orders are stored and matched here, completely shielded from public view, node operators, and even developers.
Private Matching Engine: This engine runs inside the enclave, matching buy and sell orders based on fair oracle pricing without leaking any pre-trade data.
Encrypted Margin Engine: For futures trading, this component continuously calculates the margin and health of every position in complete privacy.
Characteristics: Extremely fast, scalable, and fully private. Its trustworthiness is guaranteed not by social consensus, but by the hardware-level cryptography of the enclaves and the remote attestation process.
The Bridge: How They Work Together
The true innovation of DarkVeil lies in the seamless and secure communication between these two layers.
The Flow:
A user deposits collateral on-chain into the Vault Contract.
The user submits an encrypted trade order off-chain to the Enclave Network.
The trade is matched off-chain inside an enclave.
The enclave generates a signed message (a "proof") detailing the result of the trade.
This proof is broadcast on-chain to the Settlement Contract.
The Settlement Contract verifies the proof and finalizes the asset transfer on-chain.
This model ensures that user funds never leave the security of Ethereum, while the sensitive details of their trading activity never touch a public ledger.
Next, we will explore how this model is applied to our first product in the Confidential Spot DEX.
Last updated