Core Security Properties
These four properties are enforced at every layer of the stack — cryptographic, application, and database.
- Server never sees plaintext. All encryption and decryption happens client-side.
- Closed, invite-only enrollment. No public discovery. Every device is explicitly approved by the owner.
- Device-bound keys. Private keys are generated locally and never leave the device.
- Strict tenant isolation via RLS. Row-Level Security policies on every database table prevent cross-tenant access.
System Architecture
Components
Clients
AgentVault supports three client types, all sharing the same cryptographic library (@agentvault/crypto):
Owner App (Expo Universal)
Owner App (Expo Universal)
The owner app runs on iOS, Android, and web from a single Expo codebase. It handles:
- Authentication via Clerk (JWT issuance, session management)
- Key generation (Ed25519 identity + X25519 ephemeral keypairs)
- MLS/Double Ratchet encryption for every outbound message
- Device management (invite, approve, revoke)
- Key storage in platform-appropriate secure storage (SecureStore on native, IndexedDB on web)
Agent Plugin (@agentvault/agentvault)
Agent Plugin (@agentvault/agentvault)
The Node.js plugin integrates with OpenClaw and other agent frameworks:
- 3-line configuration in the agent’s config file
- Automatic enrollment on first run (key generation, invite consumption, fingerprint display)
- Persistent encrypted state on disk for subsequent runs
- WebSocket connection for real-time bidirectional messaging
- Message handler that decrypts inbound messages, passes them to agent logic, and encrypts responses
Client SDK (@agentvault/client)
Client SDK (@agentvault/client)
A standalone TypeScript SDK for third-party integrations:
- API key authentication (no Clerk dependency)
- TOFU key exchange (Trust On First Use)
- MLS/Double Ratchet E2E encryption via the shared crypto library
- Programmatic access to all AgentVault APIs
Backend (FastAPI)
The backend is a Python FastAPI application that handles:Database (PostgreSQL)
All data is stored in PostgreSQL 18 with Row-Level Security enabled on every tenant-scoped table:- tenants — Tenant identity and status
- users — Clerk-authenticated users with RBAC roles
- devices — Device identity keys (public only), fingerprints, status
- invites — BLAKE2b hashed tokens (raw tokens never stored)
- conversations — Owner-to-agent session metadata
- messages —
header_blob(BYTEA) +ciphertext(BYTEA). No plaintext columns exist.
Cache and Pub/Sub (Redis)
Redis 7 serves two functions:- WebSocket relay — Redis pub/sub routes messages between connected clients, enabling horizontal scaling across multiple backend instances.
- Rate limiting — Sliding window counters for enrollment, polling, and messaging endpoints.
Cryptographic Primitives
XChaCha20-Poly1305 was chosen over AES-256-GCM specifically because its 192-bit nonce is safe to generate randomly with negligible collision probability. In a high-volume messaging system, AES-GCM’s 96-bit nonce creates a reuse risk that would result in full plaintext recovery. If FIPS compliance is later required, AES-256-GCM is a swap, not a rewrite.
Protocol Stack
Encryption: MLS Primary, Double Ratchet Fallback
AgentVault uses MLS (Messaging Layer Security, RFC 9420) as the primary encryption protocol for all conversation types — 1:1, rooms, and A2A channels. MLS provides scalable group key agreement with per-epoch forward secrecy via a ratchet tree structure. The Double Ratchet protocol (with X3DH key exchange) remains as a fallback for legacy 1:1 sessions and backward compatibility with older clients. Both protocols use XChaCha20-Poly1305 as the underlying AEAD cipher. MLS flow:- Key package upload during enrollment establishes the device’s MLS credentials
- Group creation builds a ratchet tree for all conversation participants
- Commit messages advance the group epoch on membership changes
- Per-epoch forward secrecy — old epoch secrets are deleted after processing
- X3DH key agreement during enrollment establishes a shared secret
- Symmetric ratchet advances the chain key with every message
- DH ratchet rotates the key agreement with every reply
- Forward secrecy — old message keys are deleted after decryption
Message Flow
Infrastructure
Monorepo Structure
What’s Next
Zero-Knowledge Architecture
Deep dive into what the server can and cannot see.
Threat Model
Security goals, threat actors, and mitigations.
Protocol Flows
Visual sequence diagrams for enrollment, messaging, and device management.