# Privacy

Evolu encrypts the data an app syncs and the databases it stores on the device. Relays store and forward changes they can't read, but they see some metadata, such as when changes were made. This page describes what Evolu protects and what stays visible.

## End-to-end encryption

Evolu encrypts and authenticates every change before it leaves the device, with keys derived from the owner's secret, which users see as a mnemonic. Relays never get those keys, so data taken from a relay or intercepted in transit can't be read or forged. Whoever has the mnemonic can read and change all of the owner's data, so show it only to its user.

No option marks data public or turns off encryption, of synced changes or of databases on the device, though the key of the database that keeps the AppOwners' secrets can be public, as [Encryption on the device](#encryption-on-the-device) describes.

Evolu sends data only to the relays the app sets. An app that omits `transports` syncs through `free.evoluhq.com`, a [testing relay](https://evolu.dev/docs/relay#hosting-evolu-relay) that admits anyone, so set your own relays before release.

## Encryption on the device

Evolu encrypts every database an app stores on the device with AES-256, on the web and in Electron, in React Native and Expo, and in Node.js, because programs that can read the user's files, such as malware, can read what an app stores: a browser doesn't protect localStorage, IndexedDB, or OPFS from them. The Evolu Relay's database isn't encrypted, because the changes it stores already are.

Each AppOwner's database is encrypted with a key derived from the AppOwner's secret. An app created with `createEvoluApp` keeps those secrets in one more database, the device database, so its key decides how safe the data on the device is. With a `DeviceSecret`, from the iOS Keychain, the Android Keystore, or a passkey, anything that can only read the app's storage can't read the secrets. With `InstantStart`, the key is public, so anything that can read the app's storage can read them, and with them every AppOwner's data. [Local auth](https://evolu.dev/docs/local-auth) explains which mode to choose and how to set it up. An app that supplies its own AppOwners keeps their secrets itself.

Exports leave encryption: `exportDatabase` returns the database as a plain SQLite file that users can open in any SQLite tool, so treat exported files as sensitive.

A database kept in memory stores nothing on the device and is gone when its instance ends. Its changes still sync, so an instance of the same owner that stores its database on the device, now or later, keeps them. [Will my data stay on the device?](https://evolu.dev/docs/faq#will-my-data-stay-on-the-device) says when Evolu keeps a database in memory.

## Post-quantum resistance

In a "harvest now, decrypt later" attack, an adversary collects encrypted data today and waits for a quantum computer to decrypt it. Evolu is designed so that the changes in such data stay encrypted, as long as the owner secret has enough entropy.

### Why symmetric encryption

A large quantum computer could break public-key cryptography, such as RSA and elliptic curves. Evolu doesn't use it to encrypt changes: they're encrypted with a 256-bit symmetric key, which keeps about 128 bits of security against a quantum computer.

Relay connections use TLS, which relies on public-key cryptography. Whoever records that traffic today and breaks TLS later can learn the metadata [relays see](#what-relays-see), but not the data.

### How much entropy is enough

All of an owner's keys derive from its owner secret, so they're only as strong as that secret: anyone who knows the OwnerId can test guesses offline. `createOwnerSecret` generates 32 random bytes, which apps show users as a 24-word mnemonic. Against a quantum computer, that leaves about 128 bits of security, NIST's highest post-quantum category, which Evolu targets because local-first data may need to stay private for decades.

| Owner secret | Mnemonic | Classical security | Quantum security |
| ------------ | -------- | ------------------ | ---------------- |
| 32 bytes     | 24 words | 256 bits           | about 128 bits   |
| 16 bytes     | 12 words | 128 bits           | about 64 bits    |

Evolu also accepts shorter secrets, such as 12-word mnemonics from other apps. They still resist any classical attack but leave less margin against a quantum computer, which can be the right trade-off when a shorter backup matters more than decades of privacy.

Length alone isn't entropy: a secret derived from a smaller root is no stronger than the root. When data must stay private long term, create owner secrets with `createOwnerSecret`, or derive them from a root of at least 256 bits, such as a 24-word BIP-39 mnemonic or a 33-word SLIP-39 share.

## What relays see

A relay can't read changes, but it sees what it needs to sync them:

- **OwnerId**: The identifier under which relays store the owner's data. It doesn't tell a relay who the owner is, unless the relay identifies its users itself, for example for billing.
- **Timestamps**: When each change was made, which relays need to sync.
- **NodeId**: Every timestamp includes a random ID of the session that wrote the change. A session lasts while the app uses its database, on the web across its open tabs, so it can last days. Within a session, the NodeId is the same for every owner its database writes for, such as an AppOwner and the shared owners its instance syncs, so a relay can link those owners, even across IP addresses. A new session gets a new NodeId, though connections, IP addresses, and changes uploaded later can still link sessions.
- **Change sizes**: Evolu pads every change with [PADMÉ](https://lbarman.ch/blog/padme/) before encrypting it, so a relay sees only its approximate size.
- **IP addresses**: Owners synced over one connection are linked to each other, and by default an app syncs all its owners over one connection per relay.

A relay stores the OwnerId, timestamps, and NodeIds as they are, because it needs them to sync, the owner's [write key](https://evolu.dev/docs/relay#access-control), which every write must carry, and the changes, which are already encrypted. Whether IP addresses are logged depends on how the relay and any proxy in front of it are deployed.

Every relay the owner uses and everyone the owner shares data with know its OwnerId. Keep it from anyone else: whoever knows it and can connect to one of the owner's relays can download the owner's encrypted changes and subscribe to new ones, and so see the owner's timestamps, NodeIds, and change sizes.

A relay keeps an owner's data until its operator deletes it. Evolu can't delete an owner's data from relays yet.

## Deleting data

Deleting a row in a synced table marks it deleted, and every device and relay keeps its history, encrypted on relays, as [Time travel](https://evolu.dev/docs/time-travel) shows. Tables whose names start with `_` don't sync and delete rows for good.

Deleting a database or an owner's data, or removing an AppOwner, deletes only this device's copy. Relays keep the owner's data, and encrypted copies in device backups and in freed storage remain.