# Security & Cryptography

Liso encrypts everything on your device before it is synced. The server stores ciphertext and
the public keys it needs to route data; it never sees your master password, recovery phrase,
vault keys or item contents.

Liso follows one versioned specification, `liso-crypto-v2` (currently v2.2), in
`packages/crypto-spec/SPEC.md`. Two independent implementations follow it: Dart
(`dart/liso_crypto`) and TypeScript (`packages/liso-crypto-ts`). Both must pass the same
cross-language test vectors and the NIST ML-DSA-65 known-answer tests before a release.

## Post-quantum by default

Liso is **post-quantum only**. Every account, device, share, invite, device pairing and signed
message uses hybrid post-quantum cryptography. A hybrid scheme combines a well-studied classical
algorithm with a NIST post-quantum algorithm, so an attacker has to break **both**:

- **Key exchange: X-Wing** = X25519 + ML-KEM-768 (NIST FIPS 203). Used whenever one device or
  person sends a key to another: shared vaults, emergency access and QR device pairing. This
  protects against "record now, decrypt later": ciphertext captured today stays safe even if a
  large quantum computer appears later.
- **Signatures: Ed25519 + ML-DSA-65** (NIST FIPS 204). Every signed request, device enrollment,
  key binding, vault invite and signed message carries both signatures, and both must verify.
- **Classical-only data is refused.** Servers and clients reject requests, keys, invites and
  messages that are missing the post-quantum half. There is no fallback to classical-only formats.

Symmetric encryption (XChaCha20-Poly1305 with 256-bit keys) and Argon2id are already considered
safe against quantum computers at these sizes.

## Cryptographic primitives

No custom ciphers or bespoke constructions. Everything uses published standards from libsodium,
the NIST post-quantum standards, and audited libraries:

| Purpose | Primitive | Parameters |
| --- | --- | --- |
| Authenticated encryption | XChaCha20-Poly1305-IETF | 32-byte key, 24-byte random nonce, 16-byte tag |
| Password key derivation | Argon2id (v1.3) | 64 MiB memory, 3 passes, `p = 1`, 16-byte random salt. Writers refuse anything below 64 MiB / 2 passes; clients refuse server-supplied values above 256 MiB / 6 passes |
| Subkey derivation | HKDF-SHA256 | Domain-separated labels (`liso/v2/...`, `liso/v3/...`) |
| Key exchange (post-quantum) | X-Wing: X25519 + ML-KEM-768 (FIPS 203) + SHA3-256 | libsodium 1.0.22 `crypto_kem_xwing`; 1216-byte public key, 1120-byte ciphertext |
| Sealed key delivery | `SealPQ`: X-Wing + HKDF-SHA256 + XChaCha20-Poly1305 | Fresh encapsulation per message, bound to the recipient key and context |
| Signatures (hybrid) | Ed25519 + ML-DSA-65 (FIPS 204) | Both over the same canonical bytes; ML-DSA signing is hedged (fresh randomness) |
| Recovery phrase | BIP-39 (English) | **24 words** (256-bit) by default; 12-word phrases are still accepted when recovering |

Libraries: libsodium (via `package:sodium` in Dart and `libsodium-wrappers-sumo` in TypeScript)
for X-Wing, XChaCha20-Poly1305, Argon2id and Ed25519; `pqcrypto` (Dart) and
`@noble/post-quantum` (TypeScript) for ML-DSA-65. The sync server verifies ML-DSA-65 with the
Cloudflare Workers runtime's native WebCrypto support and falls back to `@noble/post-quantum`
only where the runtime does not support it.

## Keys and unlock slots

1. **Account Master Key (AMK):** 32 random bytes generated on your device.
2. **Unlock slots:** the AMK is wrapped separately for each way you can unlock, and each wrap is
   bound to its slot type and your account ID:
   - `recovery` (synced): wrapped by a key derived from your recovery phrase.
   - `password` (synced): wrapped by a key derived from your master password with Argon2id.
   - `biometric`, `pin`, `passkey` (device-only): never leave the device.
3. **Account keyset:** three random 32-byte seeds wrapped under the AMK:
   - an Ed25519 identity key,
   - an ML-DSA-65 identity key,
   - an X-Wing sharing key.

   Your public keys are tied together by a key binding signed with both identity keys.
4. **Device keys:** each device has its own Ed25519 + ML-DSA-65 key pair, kept in the operating
   system's secure storage where available. Signing in signs a server challenge with both.
5. **Vault keys:** each vault has a random 32-byte key per key epoch. Record and file keys are
   derived from it with HKDF-SHA256. Removing a member from a shared vault starts a new epoch.

The recovery phrase only unlocks the AMK and signs recovery logins. Your identity and sharing
keys are random, so you can rotate the phrase without changing your identity or your shared
vaults.

## Sharing, Safety Numbers and Liso ID

- Shared vault keys are delivered as `SealPQ` grants to the member's X-Wing key, signed by the
  inviter with both Ed25519 and ML-DSA-65. Both signatures are checked before the grant is opened.
- Your device remembers ("pins") the identity keys of the people you share with. If the server
  ever presents different keys for someone, Liso marks them as **changed** and refuses keys they
  signed until you verify them again.
- **Safety Numbers** (8 groups of 5 digits) are computed from both people's Ed25519 and ML-DSA-65
  identity keys. Compare them in person or over a channel you trust to confirm nobody is in the
  middle.
- Your **Liso ID** (`XXXX-XXXX-XXXX-XXXX`) is a short handle derived from both of your identity
  keys. It helps people find you; it is not a security check (Safety Numbers are).

## Device pairing

Pairing a new device by QR code uses a fresh X-Wing key on the new device. The QR code carries a
hash of that key, the approving device checks the hash and a 6-digit code you type, and only then
sends your account key sealed to the new device with `SealPQ`. The server relays the exchange
but cannot read it or substitute its own key.

## Transport

The Liso Cloud endpoints negotiate post-quantum TLS (the hybrid `X25519MLKEM768` key exchange)
with clients that support it. This is a second layer: vault content is already end-to-end
encrypted before it is sent. Self-hosters can check their own server with the steps in
`selfhost/tls-pqc.md`.

## What the server can see

End-to-end encryption hides your content, not every fact about it. To sync and secure your
account, the server stores or sees:

- Your random account ID, your Liso ID, and your public keys (identity, sharing and recovery
  sign-in keys, classical and post-quantum) with their key-binding signatures.
- Vault IDs, record IDs, each record's type (for example "item" or "folder"), sizes, revision
  numbers and timestamps, deletion markers, file sizes, and which device last changed a record.
- Shared-vault membership: who belongs to which vault, their roles, and who invited whom.
- For each device: its ID, public keys, platform, the **device name** (stored in plain text),
  when it was added, when it was **last seen**, and whether it was revoked.
- During QR pairing only: the new device's platform, name and approximate **city and country**
  (from the network), shown to your approving device. This is deleted when pairing ends (at most
  2 minutes).
- Emergency access: who granted access to whom, the waiting period, its status and timestamps
  (the keys themselves are sealed).
- Liso Send: the encrypted payload, whether it has a password, view limits and expiry.
- Daily usage totals per account (bytes and number of changes) and hashes of invite codes.
- Your IP address, used in memory for rate limiting. Liso's server code does not store it.

The server could withhold or roll back data. Clients keep the highest revision they have seen
for each record and warn on regressions.

## Zero telemetry

Liso clients ship with **zero telemetry**:

- No analytics SDKs
- No crash-reporting SDKs
- No advertising or attribution frameworks
- Plaintext secrets, keys and recovery phrases are never logged or sent to any server

---
Source: https://docs.lisovault.com/guide/security-and-crypto · Canonical site: https://lisovault.com/
