# Architecture Diagram

The DarkVeil protocol is built on a hybrid architecture that intelligently separates on-chain security from off-chain privacy and performance. This diagram provides a high-level overview of the protocol's components and the flow of user interactions, from depositing funds to executing a confidential trade.

This model is designed to provide the absolute security of Ethereum L1 for user funds, while leveraging the power of our AI-driven Secure Enclave network to deliver a private, fair, and high-performance trading experience.

#### DarkVeil Protocol Flow

<figure><img src="/files/LcQM9sEUoPKRwUBvT9Kx" alt="Dark Veil Architecture Diagram"><figcaption></figcaption></figure>

#### Understanding the Architecture

The protocol is comprised of four key areas:

1. **The User Layer:** This is the trader, who interacts with the protocol via their wallet.
2. **The On-Chain Layer (Ethereum L1):** This is the "Trust Layer," comprised of audited smart contracts that hold all user funds and finalize the settlement of all trades.
3. **The Off-Chain Layer (Secure Enclave Network):** This is the "Privacy & Intelligence Layer," where all complex computations—like order matching and margin calculations—happen in complete confidentiality.
4. **External Services:** These are decentralized services, like Oracles, that provide essential, verified data to the protocol.

#### Key Interaction Flows

The diagram illustrates the three primary actions a user takes within the protocol:

* **1. Deposit / Withdraw:** The user interacts directly with the **Vault Contract** on Ethereum L1 to deposit or withdraw their collateral. This flow never touches the off-chain system; it's a direct, non-custodial interaction with the most secure layer.
* **2. Placing a Trade (Private Interaction):**
  * **Remote Attestation:** Before trading, the user's client first "challenges" the **Secure Enclave (TEE)** to prove it is genuine and running the correct, audited code.
  * **Submit Encrypted Order:** Once verified, the user submits their encrypted order directly to the off-chain enclave, completely bypassing the public mempool.
  * **AI Matching:** Inside the enclave, the **AI Matching Engine** reads the **Confidential Order Book** and the verified price from the **Oracle Bridge** to find the optimal, zero-slippage execution path.
* **3. Trade Settlement (On-Chain Proof):**
  * **Proof Generation:** The AI engine generates a signed "Settlement Proof."
  * **Verification & Settlement:** This proof is broadcast to the **Settlement Contract** on-chain. The contract verifies the proof's signature and then instructs the **Vault Contract** to move the assets, finalizing the trade.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.darkveil.io/the-darkveil-protocol/architecture-diagram.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
