# Liso Vault v2 Cryptography & Zero-Knowledge Security Architecture

> Last updated: 2026-12-03 | Canonical URL: https://lisovault.com/cryptography | Spec: https://github.com/Liso-Vault/liso/blob/main/packages/crypto-spec/SPEC.md

Liso Vault v2 (`liso-crypto-v2`, Apache-2.0) uses exclusively standard, published cryptographic primitives via **libsodium** across both Dart (`liso_crypto`) and TypeScript (`@liso/crypto-ts`), verified byte-for-byte against shared JSON test vectors.

## Primitives & Parameters

| Layer | Primitive | Specification |
| --- | --- | --- |
| Vault records & key wraps | XChaCha20-Poly1305-IETF (libsodium crypto_aead_xchacha20poly1305_ietf) | 256-bit key, 24-byte random nonce per encryption, 16-byte Poly1305 tag, canonical length-prefixed AAD binding (domain label, vault_id, record_id, record_type, key_epoch, rev). Max record ciphertext 256 KiB. |
| Encrypted file storage | Chunked 64 KiB streaming XChaCha20-Poly1305 AEAD | Per-file random 256-bit DEK wrapped by HKDF('liso/v2/file-wrap'). Binary header LISO2F\x00\x01 || file_id(16) || chunk_size_u32 bound into every chunk's AAD with chunk_idx_u64 and is_final_u8 to detect truncation, reordering, or splicing. |
| Master password KDF | Argon2id v1.3 via libsodium crypto_pwhash | Default 64 MiB memory (m=65536 KiB), t=3 passes, p=1 parallelism, 16-byte random salt, 32-byte Password KEK stored with per-slot parameters so parameters can upgrade without breaking older slots. |
| Recovery phrase & key hierarchy | BIP-39 (12 words default / 24 optional) → PBKDF2-HMAC-SHA512 (2048) → HKDF-SHA256 | Derives Recovery KEK ('liso/v2/recovery-kek') and Recovery Auth Ed25519 key ('liso/v2/recovery-auth'). Account Master Key (AMK), Identity Ed25519 key, and Sharing X25519 key are random so recovery phrases can be rotated without changing your Liso ID, shared vaults, or Safety Numbers. |
| Device enrollment & sessions | Per-device Ed25519 keypair + signed challenge → 5-minute HMAC access token | Enrollment statement signed by account Identity Ed25519 key and verified by AccountDO. Short-lived 5-minute tokens with no refresh tokens; revoking a device closes its WebSocket with code 4001 and blocks all vault writes immediately. |
| Shared vaults & Safety Numbers | X25519 crypto_box_seal + Ed25519 signed invites + SHA-256 Safety Numbers | Vault keys are sealed directly to each member's X25519 public key. Clients refuse new keys if a member's identity key changes until re-verified. Removing a member increments key_epoch and rotates the vault key. |
| Quick unlock (device-local, never synced) | Hardware Keychain/Keystore biometrics, Argon2id PIN (6–12 digits), WebAuthn PRF passkeys | iOS/macOS kSecAccessControlBiometryCurrentSet, Android Keystore BiometricPrompt CryptoObject, 5-attempt wiping PIN slot, and WebAuthn PRF HKDF ('liso/v2/passkey-kek'). Master password required every 14 days for PIN/passcode. |
| Hardened QR device pairing | Ephemeral X25519 channel (PairingDO, 120s TTL) + 6-digit HMAC confirmation | Existing device re-authenticates, inspects new device platform and approximate location, shows a 6-digit code typed on the new device, and verifies HMAC(code, transcript) (3 attempts max) before sealing the AMK. |
| Cross-platform verification | Single C libsodium core across Dart (liso_crypto) and TypeScript (@liso/crypto-ts) | Both implementations pass 100% of shared JSON test vectors in packages/crypto-spec/vectors/, including AAD tamper, truncation, reordering, and legacy Liso v1 known-answer tests. |

## Threat Model & Metadata Disclosure

- **Never visible to the server:** master password, BIP-39 recovery phrase, PINs, biometric keys, AMK, vault keys, file DEKs, item titles, passwords, URLs, notes, tags, 2FA secrets, file names, file contents, local RAM previews, local MCP audit logs, or email addresses.
- **Visible operational metadata:** random UUIDv7 account/vault/record IDs, public Liso ID, public Ed25519/X25519 keys, record types, ciphertext byte sizes, revision counts and timestamps, device names/platforms/last-seen/revocation, shared-vault membership graph, and transient pairing city/country hint (held max 2 minutes, never persisted).
- **Audit Status:** Internal security self-audit completed with all High issues fixed. An independent external cryptographic and protocol audit of `packages/crypto-spec` and `server/sync` is scheduled before general availability, and the report will be published publicly.

## Cryptography FAQ

### Why does Liso use XChaCha20-Poly1305 instead of AES-GCM?

XChaCha20-Poly1305-IETF uses 192-bit (24-byte) random nonces instead of AES-GCM's 96-bit (12-byte) nonces, eliminating practical nonce-collision risk during distributed multi-device sync, avoiding software AES timing side channels on devices without AES-NI, and shipping consistently across every platform via libsodium.

### Can I rotate my recovery phrase without breaking shared vaults or changing my Liso ID?

Yes. Unlike architectures that deterministically derive identity keys from a seed phrase, Liso generates a random 256-bit Account Master Key (AMK) and random Ed25519/X25519 identity and sharing keys. The BIP-39 recovery phrase only wraps the AMK and derives a Recovery Auth key—so rotating an exposed phrase re-wraps the AMK without altering your Liso ID, shared vaults, or Safety Numbers.

### Has Liso 2 undergone an independent external security audit?

Not yet. Liso 2 has completed a thorough internal security self-audit covering cryptography, QR pairing, autofill clickjacking, MCP isolation, server authorization, and client hardening (all High findings fixed). An independent external review of packages/crypto-spec and server/sync is planned before general availability, and its full report will be published publicly.

### How are encrypted files protected against server truncation or chunk swapping?

Every file receives a random 256-bit DEK and a binary header (LISO2F\x00\x01 || file_id || chunk_size). Files are split into 64 KiB chunks encrypted with XChaCha20-Poly1305 where each chunk's AAD cryptographically binds ('liso/v2/file', file_id, chunk_idx_u64, is_final_u8, SHA256(header)). Reordering, duplicating, swapping across files, or truncating before the final chunk fails AEAD verification immediately.
