> For the complete documentation index, see [llms.txt](https://onex-3.gitbook.io/onex-document/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://onex-3.gitbook.io/onex-document/architecture.md).

# Architecture

## 4.1 Design Principles

ONEx is built on seven architectural principles that are never traded off against features:

| Principle                      | Implementation                                                                 |
| ------------------------------ | ------------------------------------------------------------------------------ |
| **No Single Point of Failure** | No single company, regulator, server, or key controls the system               |
| **Post-Quantum by Design**     | Hybrid PQC+ECC ensures security against both classical and quantum adversaries |
| **Privacy by Architecture**    | User data does not leave the device without explicit cryptographic consent     |
| **Composable and Upgradeable** | Every module upgrades independently with zero downtime                         |
| **Crypto-Optional for Users**  | Blockchain is infrastructure, never imposed as UX                              |
| **Compliance-First**           | Embedded at architectural level, not added as afterthought                     |
| **Supply Chain Secured**       | npm package integrity verification, SBOM published quarterly                   |

***

## 4.2 The 12-Layer Architecture — Detailed

### Layer 1: User Experience Layer

* iOS Native App
* Android Native App
* Web App (PWA)
* Browser Extension
* Conversational AI Interface
* Multi-Language NLU (15+ languages)
* Progressive UX
* Accessibility Engine (WCAG 2.1 AA)
* WebAuthn Passkey Integration

### Layer 2: AI Agent Layer

* Autonomous Financial Agents (7 Types including Tax & Compliance Agent)
* Session Key Execution Engine
* Agent Policy Manager
* On-Chain Action Logger
* Agent Pause/Revoke Controls

### Layer 3: Edge AI Layer (On-Device)

* Transaction Categorization (Distilled Transformer <50MB)
* Biometric Auth + 3D Liveness Detection
* Anomaly Detection (Autoencoder, user-specific)
* Voice Processing (Whisper-small, on-device)
* Offline-First Design
* Behavioral Biometrics (keystroke dynamics, touch pressure, device motion)

### Layer 4: Cloud AI & zkML Layer

* Federated Learning Engine with Differential Privacy (ε-DP, ε ≤ 1.0 per epoch)
* Gradient Compression + Secure Aggregation (against gradient inversion attacks)
* zkML Credit Scoring (ezkl framework — ZK-proven ONNX model inference)
* Model Registry with version control and audit trail
* Explainability Engine (SHAP values for all decisions)

### Layer 5: Post-Quantum Identity & Privacy Layer

* W3C DID Infrastructure
* Verifiable Credentials (VC Data Model v2.0)
* ZK-Proof Engine: Groth16 (Circom/SnarkJS) + Plonky2/STARKs (no trusted setup)
* Selective Disclosure
* CGGMP21 MPC-TSS Key Management
* CRYSTALS-Kyber (key exchange) + CRYSTALS-Dilithium (signatures)

### Layer 6: Smart Account Layer

* ERC-4337 Account Abstraction
* ERC-7579 Modular Plugin System
* EIP-7702 EOA Temporary Upgrade
* WebAuthn Passkey Signer
* Guardian Recovery Manager
* Session Key Controller
* Programmable Spending Rules

### Layer 7: Compliance & Risk Layer

* Geo-Adaptive Regulation Engine (with mandatory legal review before rule deployment)
* Real-Time Sanctions Screening (OFAC/EU/UN)
* FATF Travel Rule (≥$1,000 USD equivalent, jurisdiction-adjusted)
* AML/KYC Tier System
* Risk Scoring Engine
* Reporting Suite (MiCA, Form 8949, SWIFT-compatible)

### Layer 8: Blockchain Settlement Layer

* Multi-Chain: EVM / Solana / Cosmos / L2s
* Chain Abstraction Middleware
* Intent-Based Execution (ERC-7683 cross-chain intents)
* MEV Protection (Flashbots Protect, Flashbots SUAVE)
* Atomic Cross-Chain Swaps
* Gas Optimization Engine

### Layer 9: Liquidity Engine

* JIT Liquidity Sourcing
* Stablecoin Hubs (USDC, EURC, USDT, XSGD)
* AMM Routing Engine (Uniswap V4, Curve, Orca)
* Solver Network with Slashing Mechanism
* AI Route Optimizer
* LP Incentive Model
* Cross-Chain Liquidity Aggregation

### Layer 10: Fiat & Banking Rails

* Licensed Partner Network (minimum 2 per jurisdiction)
* Fiat On/Off Ramps
* Card Issuance Infrastructure
* ATM Network Access (50M+ ATMs)
* Mobile Money Integration
* UPI/SWIFT/SEPA/ACH
* PromptPay/GoPay/M-Pesa integration

### Layer 11: Data Sovereignty Layer

* User-Owned Encrypted Vault (AES-256-GCM)
* IPFS/Filecoin/Arweave Storage
* Lit Protocol Access Control
* Consent Manager
* Data Portability Engine
* Revenue Share for Opted-In Data
* Homomorphic Encryption (for cloud computations on encrypted data)

### Layer 12: Hardware Security Module (HSM) Layer

* FIPS 140-3 Level 3 certified HSMs for server-side MPC share operations
* Trusted Execution Environment (Intel TDX / AMD SEV-SNP) for sensitive cloud computations
* Attestation-based proof of TEE execution
* No plaintext key material ever exists in standard memory

***

## 4.3 Technology Stack

| Component           | Technology                                                      |
| ------------------- | --------------------------------------------------------------- |
| Mobile              | React Native (iOS/Android)                                      |
| Web                 | Next.js PWA                                                     |
| Smart Contracts     | Solidity (EVM), Rust (Solana)                                   |
| ZK Proofs           | Circom/SnarkJS (Groth16), Plonky2/STARKs                        |
| zkML                | ezkl framework (ZK-proven ONNX inference)                       |
| Federated Learning  | Flower framework + differential privacy (Opacus)                |
| MPC Key Management  | CGGMP21 protocol (Lit Protocol infrastructure)                  |
| Post-Quantum Crypto | CRYSTALS-Kyber + CRYSTALS-Dilithium (NIST 2024 standard)        |
| Storage             | IPFS/Filecoin/Arweave (decentralized) + AES-256-GCM (encrypted) |
| Account Abstraction | ERC-4337 (Alchemy/Biconomy infrastructure)                      |
| Intent Execution    | ERC-7683 cross-chain intents                                    |
| MEV Protection      | Flashbots Protect + SUAVE                                       |
| Oracle              | Chainlink TWAP (30-minute minimum window)                       |

***

## 4.4 Security Verification Standards

* Two independent external audits (Certik, Trail of Bits, OpenZeppelin, Consensys Diligence)
* Formal verification using Certora Prover and K Framework for critical invariants
* $1,000,000+ maximum bug bounty reward (Immunefi platform)
* 48-hour minimum timelock between deployment and activation
* Multi-sig governance for upgrades: M-of-N core team + timelock
* ERC-4337 specific audit: paymaster contracts, bundler interaction, session key bounds
* Third-party audit specifically for PQC hybrid signature scheme
