Back Home

How Do We Encrypt Your Data?

Local File Encrypt offers independent password v3 and USB security-key v4 methods; keep the password for password files and the original WebAuthn credential on the original external USB security key for v4 files.

Bobby Li avatar
  • Bobby Li
How Do We Encrypt Your Data?
Your data is always under your control

Local File Encrypt now offers two independent encryption methods:

  • The password method creates version 3 (v3). Keep the encrypted file and remember its original password.
  • The external USB FIDO2 security-key method creates numeric version 4 (v4). Keep the original external security key and the original WebAuthn credential that this app created on it.

WebAuthn is neither a replacement for nor a recovery method for password encryption. Choosing password leaves the existing password flow unchanged, and historical v1/v2/v3 files remain readable. A v4 file has no password, recovery key, default recovery password, or cloud key copy.

1. Public Container Header and Automatic Version Dispatch

Every version uses the same outer structure:

[8 bytes: ASCII "l0kfd3e1"]
[4 bytes: unsigned metadata length N, big-endian]
[N bytes: UTF-8 JSON metadata]
[ciphertext and authentication tags]

N is a UTF-8 byte length, not a character count. Metadata is public, but v2/v3/v4 authenticate the original header bytes. A decoder must use the bytes stored in the file instead of parsing and reserializing them.

The web app and Python program dispatch automatically by version; there is no --method. Only JSON number 4 (including 4.0 and 4e0) selects v4. Strings, booleans, missing versions, and unknown values retain the historical v1 dispatch rule. If a recognized v2/v3/v4 file has invalid parameters or fails authentication, it fails directly and never downgrades to another algorithm.

2. Password Method: v3

v3 generates a fresh 16-byte salt and 8-byte nonce prefix for every file. It encodes the password unchanged as UTF-8 and derives a 256-bit AES-GCM key with PBKDF2-HMAC-SHA-256 and 100,000 iterations.

Plaintext is split into 4 MiB chunks. Each chunk nonce is the 8-byte prefix followed by its big-endian uint32 index. Its AAD is the complete original file header followed by the same index, and each chunk carries a 16-byte GCM tag. Even an empty file has one authenticated chunk. A Worker streams output into browser-local OPFS, and the result is offered only after every chunk authenticates.

The password path continues to create v3. Adding v4 did not change password encoding, derivation parameters, reading, or error semantics for v1/v2/v3.

3. USB Security-Key Method: v4

v4 uses WebAuthn PRF; it does not export the security key’s private key. Every file gets fresh random values:

  • a 32-byte prfInput;
  • a 32-byte HKDF salt;
  • an 8-byte nonce prefix.

These values and the full credential ID are stored in the public, authenticated header. The original credential reproduces the same 32-byte PRF output for the same prfInput. The program then reconstructs the same AES-256-GCM file key with HKDF-SHA256, the stored salt, and fixed info local-file-encrypt/v4/webauthn/file-key. Decryption therefore uses the random parameters stored in the file; it does not generate new ones.

v4 also uses 4 MiB chunks, with the same chunked nonce and AAD structure as v3, and it requires OPFS. The file does not store the PRF output, derived file key, PIN, password, signature, recovery key, or recovery file.

4. Initial Setup, Later Use, and the Browser Index

Initial setup has three explicit WebAuthn ceremonies: credential create, verification 1/2, and verification 2/2. The two verifications use the same PRF input with different challenges. Encryption starts only when the credential matches and both 32-byte PRF results are identical. Risk acknowledgement is user consent, not device verification.

Later encryption or decryption with the same credential normally needs one assertion per operation. Inserting the security key does not decrypt automatically: complete the security-key PIN, device fingerprint, touch, or other step requested by the system. The website neither sets nor manages the PIN.

The browser stores only a public credential index and risk-text version, never a PRF output or key. Only the security-key encryption flow saves the public index, for reuse by later encryption. v4 decryption always uses the credential named in the file header; it never reads, saves, or replaces the index, and the success page does not show record status. Existing v4 files remain decryptable after site state is cleared. The current, unrefreshed tab may still reuse an in-memory session credential; after a refresh, page reopen, or new profile, the next security-key encryption creates a new credential and repeats initial setup.

5. No-Recovery Risk and Password Independence

v4 has no backup unlock path. A new security key of the same model, the same PIN, or a newly created credential cannot replace the original credential. Resetting the security key, deleting this app’s credential, or permanently locking the PIN makes the corresponding old files permanently unrecoverable.

First test both web and Python decryption with a non-important file. You can instead keep choosing password encryption independently; v4’s no-recovery risk does not change how password files are read.

6. Historical v1/v2/v3 Compatibility

Valid historical v1, v2, and v3 files remain readable permanently. v1’s deterministic salt/IV and unauthenticated metadata remain only for compatibility and should not be used for new encryption. v2 introduced random salt/IV and authenticated the original header. v3 added 4 MiB chunks, a random nonce prefix, and streamed OPFS output.

A new format does not retroactively add its security properties to old ciphertext. You may decrypt and re-encrypt an old file, but migration is not a condition for recovering its original bytes. The image below is only the historical v1 layout for text 123 and password 123; it is not a current v3 or v4 example:

Historical version 1 file layout

7. Decrypting with Python Without the Web App

The Python example program detects the file version automatically and has no --method. Password files require a password; v4 must omit it:

python3 decrypt.py encrypted-password.lfe "original password"
python3 decrypt.py encrypted-webauthn.lfe

The password path requires Python 3 and cryptography and does not import fido2. v4 requires Python >=3.10,<4, cryptography==50.0.2, and fido2==2.2.1. It uses a fixed production RP profile, one 60-second deadline, hidden interactive PIN input, and no automatic retry. It publishes v4 output without overwriting an existing file, and only after every chunk authenticates.

8. Current Evidence Boundaries

There are three distinct evidence layers; none substitutes for another:

  1. The first real interoperability run on 2026-10-07 used a temporary DevTools probe on the production origin, Chrome, a TrustKey T120, and offline Python to recover a 54-byte public plaintext. It was not a current product-page acceptance run.
  2. The current product UI, Service, Worker, WebCrypto, OPFS, v4 container, and download path run in synthetic composition on Chromium, Firefox, and WebKit. Only the WebAuthn device boundary is replaced by a public deterministic adapter. This does not prove a real USB device, system PIN UI, production RP, or deployed page.
  3. Real-device closure on the current final product page, cleared-site-state decryption without index writes, error scenarios, offline Python rerun, v4 4 GiB + 1, deployment, and remote CI remain release-acceptance work.

Touch ID, Windows Hello, phone QR flows, and cloud-synced passkeys are outside this phase’s supported scope. WebAuthn/FIDO2 behavior on Windows and Linux is also not yet verified.

9. Update Log

  • 2026/10/10: Decryption no longer saves, replaces, or displays the browser credential index; that index is only reused by the encryption flow.
  • 2026/10/08: Added independent password v3 and USB security-key v4 methods, no-recovery risk, automatic version dispatch, conditional Python dependencies, and evidence boundaries.
  • 2026/10/01: Documented version 2 random salt/IV, the authenticated header, and historical-file compatibility.
  • 2025/01/31: Added the version 1 encryption process.

Recommended For You

Why Do We Use AES-256-GCM to Encrypt Your Data?

Why Do We Use AES-256-GCM to Encrypt Your Data?

This is why we chose the AES-256-GCM encryption algorithm.

how-we-work
Author: Bobby Li