> 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/ai-engine.md).

# Ai engine

## 5.1 Overview

Artificial intelligence is ONEx's primary competitive advantage. ONEx is architected around AI at every layer — with a critical addition: **Zero-Knowledge Machine Learning (zkML)**, which allows the system to prove the correctness of AI computations without revealing the underlying data or model.

This is the first time zkML has been applied to financial services at consumer scale.

## 5.2 Edge AI — On-Device Intelligence

All sensitive data processing happens on the user's device. Raw financial data never leaves the device without explicit consent.

### 5.2.1 Transaction Categorization Engine

A distilled Transformer model (<50MB on-device) classifies every transaction in real time:

* Automatic merchant category recognition
* Subscription detection and tracking
* Unusual pattern flagging
* Multi-language support (15+ languages)
* Works fully offline — no network required

### 5.2.2 Biometric Authentication

Multi-modal biometric processing entirely within the device secure enclave:

| Biometric   | Method                                        | Notes                             |
| ----------- | --------------------------------------------- | --------------------------------- |
| Fingerprint | Secure enclave                                | Never leaves device               |
| Face scan   | 3D liveness detection                         | Prevents photo/deepfake spoofing  |
| Voice       | Whisper-small, on-device                      | Audio never uploaded              |
| Behavioral  | Keystroke dynamics, touch pressure, gyroscope | Continuous passive authentication |

**Behavioral Biometrics** provide continuous authentication without user friction — the system knows it's you from how you hold your phone, how you type, and how you navigate.

### 5.2.3 Anomaly Detection

User-specific autoencoder model that:

* Learns individual spending patterns
* Improves accuracy over 30 days
* Optimizes false positive rate through user feedback
* Operates fully offline
* Flags unusual transactions before they execute

## 5.3 Cloud AI — Collective Intelligence with Gradient Attack Defense

**Federated Learning Architecture:**

* Each user's model trains locally on their own device
* Only mathematical gradient updates (not data) are transmitted
* Secure Aggregation Protocol: server only ever sees the summed gradient across all users, never individual gradients
* Differential Privacy (ε ≤ 1.0 per epoch): mathematical guarantee that no individual's data can be reconstructed from the global model

**Protection against Gradient Inversion Attacks:**

Gradient inversion attacks can potentially reconstruct raw data from gradients. ONEx counters this with:

1. Gradient compression (reducing information content of each update)
2. Secure aggregation (server sees only the sum, not individual updates)
3. Differential privacy noise injection
4. Gradient clipping (prevents single-sample dominance)

## 5.4 zkML — Zero-Knowledge Machine Learning

This is ONEx's most significant technical innovation.

Traditional AI credit scoring requires the user to reveal their data, and the institution to reveal (or hide) their model. **zkML eliminates both requirements:**

* The user proves their creditworthiness without revealing their financial data
* The model proves its computation was correct without revealing its weights
* Both proofs are verifiable by any third party on-chain

**Technical implementation:** ezkl framework compiles ONNX ML models into ZK circuits. The circuit generates a proof that:

1. The model ran correctly on the claimed inputs
2. The output (credit score) is the mathematically correct result
3. No tampering occurred between inference and output

**Why this matters for financial inclusion:** A borrower in rural India can prove to a lender in London that they have a 780 credit score based on their transaction history — without revealing a single transaction. The lender can verify the proof on-chain in seconds.

## 5.5 AI Credit Scoring Engine

The ONEx Credit Engine uses an ensemble of models operating on alternative data, making credit accessible to populations excluded by traditional bureaus.

### Alternative Data Sources (ZK-proven)

| Data Category           | Signals Used                                      |
| ----------------------- | ------------------------------------------------- |
| Transaction history     | Payment frequency, consistency, amount trends     |
| Wallet behavior         | Age, diversity, protocol interactions             |
| Staking patterns        | Lock duration, consistency, amount                |
| On-chain reputation     | DAO participation, governance votes, attestations |
| Social graph (optional) | DID attestations from trusted community members   |
| Mobile usage patterns   | App behavior, location patterns (on-device only)  |

**Technical note:** The credit engine uses Mamba (State Space Models, 2024) rather than LSTM for financial time series. Mamba achieves equivalent or superior performance with 5x less compute — critical for on-device zkML proofs where computation must be minimized.

### 5.5.1 zkML Credit Score Output

```
Credit Score: 742 / 850
ZK Proof: 0x7f4a... (on-chain, verifiable by any party)
Proof Generation: 45 seconds (on-device)
Proof Verification: <1 second (on-chain)
Data Disclosed: NONE (zero knowledge)
```

## 5.6 On-Chain AI Agents — Autonomous Finance

Seven specialized agents operate autonomously within user-defined bounds. Every action is executed via time-limited session keys and recorded immutably on-chain.

### Agent Capability Matrix

| Agent            | What It Can Do                            | Hard Limits                          |
| ---------------- | ----------------------------------------- | ------------------------------------ |
| Savings Agent    | Deposit to yield protocols, rebalance     | Max per transaction set by user      |
| Payment Agent    | Execute scheduled transfers               | Only to pre-approved addresses       |
| Credit Agent     | Apply for credit, schedule repayment      | Max loan amount set by user          |
| Investment Agent | Rebalance portfolio                       | Max per-asset % set by user          |
| Security Agent   | Pause suspicious transactions, alert user | Cannot move funds, only pause        |
| Compliance Agent | Screen transactions, generate reports     | Advisory only — cannot block         |
| Tax Agent        | Track events, generate Form 8949          | Advisory only — estimate, not advice |

**CRITICAL SECURITY PROPERTY:**

* User can pause or revoke any agent **instantly** from any device
* No action outside user-defined policy is **cryptographically possible**
* Session key scope is enforced at the smart contract level
* All agent actions are **publicly logged on-chain** — full audit trail at all times
