> ## Documentation Index
> Fetch the complete documentation index at: https://docs.delphai.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Security Overview

> How delphAI ensures secure and trustless oracle resolution

## Security Architecture

delphAI's security model is built on **Trusted Execution Environments (TEE)**, ensuring that AI resolution happens in a secure, verifiable, and tamper-proof environment.

## Trusted Execution Environment (TEE)

### What is TEE?

A Trusted Execution Environment is a secure area of a processor that guarantees:

<CardGroup cols={2}>
  <Card title="Code Integrity" icon="shield-check">
    AI resolution logic cannot be modified or tampered with during execution
  </Card>

  <Card title="Data Confidentiality" icon="lock">
    Data fetched from APIs and used in resolution is protected from unauthorized access
  </Card>

  <Card title="Isolation" icon="cube">
    AI processes run isolated from the host system and other applications
  </Card>

  <Card title="Attestation" icon="certificate">
    Cryptographic proof that code is running in a genuine TEE environment
  </Card>
</CardGroup>

### How delphAI Uses TEE

```mermaid theme={null}
graph TB
    A[Resolution Request] --> B[TEE Environment]
    B --> C[Load AI Agent]
    C --> D[Fetch Data Securely]
    D --> E[Process in Isolation]
    E --> F[Generate Proof]
    F --> G[Sign Result]
    G --> H[Submit Onchain]

    style B fill:#D4AF37
    style E fill:#D4AF37
    style F fill:#D4AF37
```

**Key Security Features:**

1. **Isolated Execution**: AI agent runs in TEE, isolated from external interference
2. **Secure Data Fetching**: API calls happen within TEE, protecting data integrity
3. **Verifiable Computation**: Every resolution includes attestation proof
4. **Tamper-Proof**: Impossible to modify AI logic or manipulate results
5. **Private Keys**: Oracle signing keys never leave TEE

## Security Guarantees

### What TEE Protects Against

<AccordionGroup>
  <Accordion title="Malicious Operators" icon="user-secret">
    Even if the server operator is malicious, they **cannot**:

    * Modify the AI resolution logic
    * Tamper with data fetched from APIs
    * Fake resolution outcomes
    * Access private keys used for signing

    The TEE ensures that only the verified AI code can execute.
  </Accordion>

  <Accordion title="Data Manipulation" icon="database">
    Data fetched from external sources is protected:

    * API responses are processed within TEE
    * Cannot be intercepted or modified in transit
    * Cryptographic proofs ensure data authenticity
    * Source tampering is detectable
  </Accordion>

  <Accordion title="Code Tampering" icon="code">
    The AI resolution code is protected:

    * Verified before execution in TEE
    * Cannot be modified at runtime
    * Updates require new attestation
    * Users can verify which code version is running
  </Accordion>

  <Accordion title="Side-Channel Attacks" icon="wifi">
    TEE provides protection against:

    * Memory access attacks
    * Cache timing attacks
    * Power analysis
    * Other side-channel exploits
  </Accordion>
</AccordionGroup>

### What TEE Does NOT Protect Against

<Warning>
  **Important Limitations:**

  * **Garbage Data In**: If ALL data sources provide false information, TEE cannot detect this (oracle relies on source honesty)
  * **Smart Contract Bugs**: TEE protects resolution logic, not the oracle smart contract itself
  * **Network Attacks**: DDoS on data sources could delay resolution (fallback mechanisms help)
  * **Hardware Vulnerabilities**: Extremely rare, but TEE hardware could have undiscovered vulnerabilities
</Warning>

## Attestation & Verification

### Remote Attestation

Every resolution includes a **remote attestation** proving:

1. **Code Identity**: Hash of the exact AI code that ran
2. **TEE Authenticity**: Cryptographic proof of genuine TEE
3. **Execution Environment**: No tampering or modifications
4. **Timestamp**: When the resolution occurred

### How to Verify

Anyone can verify a delphAI resolution:

```javascript theme={null}
// Pseudo-code for verification
function verifyResolution(marketId, resolution) {
    // 1. Check attestation signature
    const attestation = resolution.attestation;
    const isValidTEE = verifyTEESignature(attestation);

    // 2. Verify code hash matches known AI version
    const codeHash = attestation.codeHash;
    const isKnownVersion = verifyCodeHash(codeHash);

    // 3. Check data source proofs
    const dataProofs = resolution.dataProofs;
    const areSourcesValid = verifyDataSources(dataProofs);

    return isValidTEE && isKnownVersion && areSourcesValid;
}
```

### Transparency

<CardGroup cols={2}>
  <Card title="Open Source AI Logic" icon="code-branch">
    AI resolution logic is open source and auditable by anyone
  </Card>

  <Card title="Public Attestations" icon="eye">
    All attestation proofs are published onchain for verification
  </Card>

  <Card title="Data Source Logs" icon="list">
    Complete logs of data fetched during resolution are available
  </Card>

  <Card title="Reproducible Results" icon="arrows-rotate">
    Anyone can verify that the same inputs produce the same output
  </Card>
</CardGroup>

## Multi-Layer Security

delphAI implements defense-in-depth:

### Layer 1: TEE Hardware

* Intel SGX or AMD SEV secure enclaves
* Hardware-level isolation and encryption
* Attestation built into silicon

### Layer 2: Smart Contract Security

* Audited by leading security firms
* Multi-signature for critical operations
* Time-locks on upgrades
* Emergency pause mechanism

### Layer 3: Cryptographic Proofs

* Every resolution cryptographically signed
* Data sources include integrity proofs
* Onchain verification of signatures

### Layer 4: Operational Security

* Redundant data sources
* Automated monitoring and alerts
* Regular security audits

## Trust Model

### What You Need to Trust

<AccordionGroup>
  <Accordion title="TEE Hardware Manufacturers" icon="microchip">
    You must trust that Intel SGX / AMD SEV hardware works as specified.

    **Mitigation**: Multiple TEE providers can be used (Intel, AMD, ARM TrustZone)
  </Accordion>

  <Accordion title="Data Sources" icon="database">
    You must trust that the specified data sources provide accurate information.

    **Mitigation**: Use multiple reputable sources; AI cross-verifies
  </Accordion>

  <Accordion title="Smart Contract Code" icon="file-contract">
    You must trust the oracle smart contract (after audit).

    **Mitigation**: Contracts are audited, open source, and time-locked
  </Accordion>
</AccordionGroup>

### What You DON'T Need to Trust

✅ **Oracle operators** - TEE ensures they can't cheat
✅ **delphAI team** - Cannot manipulate resolutions
✅ **Server infrastructure** - TEE protects even if servers are compromised
✅ **Network intermediaries** - Data integrity verified cryptographically

## Threat Model

### Attack Scenarios & Defenses

| Attack                         | How TEE Protects                        | Additional Defenses               |
| ------------------------------ | --------------------------------------- | --------------------------------- |
| Operator modifies AI code      | TEE verifies code hash before execution | Attestation proves code integrity |
| Man-in-the-middle on API calls | Data fetched within TEE, encrypted      | TLS + cryptographic source proofs |
| Fake resolution submission     | Private keys only in TEE                | Onchain signature verification    |
| Reorg attack on blockchain     | Resolution includes block height        | Multiple confirmations required   |
| Data source compromise         | Multi-source verification               | Reputation system for sources     |
| TEE vulnerability discovered   | Distributed across TEE types            | Can migrate to new TEE tech       |

## Best Practices for Integrators

Platforms integrating delphAI should:

<AccordionGroup>
  <Accordion title="Verify Attestations" icon="check-double">
    Always verify the TEE attestation proof before trusting resolution results
  </Accordion>

  <Accordion title="Use Multiple Data Sources" icon="layer-group">
    Specify multiple reputable data sources in resolution criteria
  </Accordion>

  <Accordion title="Set Confidence Thresholds" icon="gauge-high">
    Only accept resolutions above a certain confidence score
  </Accordion>

  <Accordion title="Implement Disputes" icon="gavel">
    Allow users to dispute resolutions with stake (reduces false positive acceptance)
  </Accordion>

  <Accordion title="Monitor Attestations" icon="bell">
    Set up alerts if attestation patterns change or become suspicious
  </Accordion>
</AccordionGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Audits" icon="magnifying-glass-chart" href="/security/audits">
    Review security audit reports
  </Card>

  <Card title="Best Practices" icon="star" href="/security/best-practices">
    Learn integration security best practices
  </Card>

  <Card title="Oracle Contract" icon="file-contract" href="/contracts/oracle-contract">
    Understand the smart contract security
  </Card>

  <Card title="FAQ" icon="circle-question" href="/resources/faq">
    Common security questions answered
  </Card>
</CardGroup>
