# How a pattern becomes an encryption key

What a key derivation function does, why Argon2id is slow on purpose, and how a hardware pepper and no stored check let every pattern open its own vault.

Published 23 November 2026. 8 min read.

A key derivation function, or KDF, is a recipe that turns something you can remember into an encryption key. The same pattern always makes the same key, a pattern that differs by one dot makes an unrelated one, and nobody can run the recipe backwards. In Cachette, your pattern goes through Argon2id, a KDF that is slow and memory-hungry on purpose, and is then mixed with a secret "pepper" kept in your phone's hardware. The result is your vault key. It's never stored anywhere, and that one decision explains how the rest of the app behaves.

Here is each step in plain words, with the real settings.

## Why a pattern can't be the key by itself

Cachette encrypts every file with AES-256, the 256-bit version of the [Advanced Encryption Standard](https://csrc.nist.gov/pubs/fips/197/final). Its key is a 256-bit number, which can run to 78 digits when written out. Nobody remembers that. A pattern is the opposite: a handful of dots, chosen by a person, which means some shapes are far more likely than others.

A KDF closes that gap. Think of it as a very particular recipe:

- **Repeatable.** The same ingredients always make the same dish, so the same pattern always makes the same key.
- **Thorough.** Change one ingredient and the dish is unrecognisable, so a pattern that differs by one dot gives a completely different key.
- **One-way.** You can't unbake a cake to get the eggs back. A key doesn't reveal the pattern that made it.

The only way from a key back to a pattern is to guess patterns and run the recipe forwards, guess after guess. So the rest of the design does two things: it makes each guess expensive, and it makes sure guesses can only happen in one place.

## What a salt does

A salt is a random value mixed in with a password before it's processed. The [OWASP Password Storage Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html) calls it "a unique, randomly generated string that is added to each password as part of the hashing process."

Its job is to make every result unique. Without a salt, the same password produces the same result everywhere, so someone could compute the results for millions of common passwords once and simply look them up. With a salt, those precomputed tables are useless, and two people with the same password end up with different results.

A salt isn't a secret. It's usually stored right next to the result. Argon2id always takes one: [RFC 9106](https://www.rfc-editor.org/rfc/rfc9106.html), the document that specifies Argon2, lists the salt among its inputs and recommends 16 bytes of it for password hashing. What a salt can't do is slow anyone down. With the salt in hand, testing a guess is as quick as ever. That's the job of the next two steps.

## Slow and memory-hungry, on purpose

Argon2 won the [Password Hashing Competition](https://www.password-hashing.net/), an open contest that announced it as the winner in July 2015. RFC 9106, published in September 2021, calls it a "memory-hard function" and says that Argon2id, one of its three variants, "MUST be supported by any implementation." If you aren't sure which variant to use, the RFC's advice is to choose Argon2id.

Three settings decide how much work one run takes:

| Setting | What it controls | Cachette |
|---|---|---|
| Memory | How large a block of memory each run must fill | 128 MiB |
| Passes | How many times the run goes over that block | 3 |
| Lanes | How many strands of work run side by side | 4 |

For comparison, the RFC's second recommended setting is 64 MiB, 3 passes and 4 lanes, so Cachette keeps the passes and lanes and doubles the memory. OWASP's minimum for Argon2id is 19 MiB, 2 passes and 1 lane.

Picture the recipe needing a notebook. Each run fills 128 MiB of memory with numbers, each one computed from earlier ones, and makes three passes over it in all. The result depends on that whole block of memory. You pay the cost once each time you unlock. Someone guessing pays it for every single guess.

Memory is what makes cheating expensive. Specialised cracking hardware is built to run huge numbers of small calculations at once, but every guess needs its own 128 MiB, and memory costs money and space. RFC 9106 says Argon2id "maximizes adversarial costs on dedicated brute-force hardware," and OWASP sums it up: slow, memory-hard algorithms make brute-force attacks "significantly more difficult, expensive, and time-consuming."

## The pepper: a secret that never leaves your phone

Slow is good, but a slow job spread across a rack of rented computers still finishes sooner than a slow job on one phone. So Cachette adds a step that ties every guess to your phone.

After Argon2id, the result goes through [HMAC-SHA256](https://www.rfc-editor.org/rfc/rfc2104), a standard way of mixing data with a secret key, using a second key called the pepper. A salt is public; a pepper is secret. OWASP says a pepper "should not be stored along with the generated hash" and belongs in a secrets vault or a hardware security module. NIST's digital identity guidelines, [SP 800-63B](https://pages.nist.gov/800-63-4/sp800-63b.html), recommend the same idea for stored passwords: an extra keyed step whose secret key is kept separately and ideally used "within a hardware-protected area."

Cachette keeps its pepper in the phone's hardware keystore: in the StrongBox secure element where the phone has one, otherwise in the trusted execution environment (TEE). [Android's keystore documentation](https://developer.android.com/privacy-and-security/keystore) requires StrongBox to have its own CPU, secure storage and a true random-number generator, and phones from Android 9 onwards can include one. The TEE is a protected area that runs on the same processor as Android but, as [Android's Trusty documentation](https://source.android.com/docs/security/features/trusty) puts it, is "isolated from the rest of the system" by hardware and software.

The same keystore documentation describes what that buys. Key material "never enters the application process," and when it's bound to secure hardware, it "is never exposed outside of secure hardware." Even an attacker who can read the phone's internal storage "can't extract them from the device."

Think of the pepper as a stamp locked in a safe that's bolted to your phone. You can pass the safe a sheet to stamp, but nobody can take the stamp out.

In practice:

- **A copy of the vault's files is no use on another computer.** Without the pepper, no guess can be completed anywhere else. Every guess has to run on your phone, and each one costs a full Argon2id.
- **Backups rely on their 24 words.** A backup has to restore on a new phone, so it can't depend on the old phone's pepper. Its contents, and the Argon2id check that lets a restore confirm your pattern, are sealed by its own 24 words, so a copy of the file alone gives nothing to guess against. Keep the words on paper, apart from the file.
- **Your phone's hardware decides where the pepper lives.** StrongBox where the phone has one, otherwise the TEE. On a phone with neither, the pepper is in software, which guards it less well. [StrongBox, TEE and the Android Keystore](https://getcachette.app/blog/android-keystore-strongbox-tee/) shows how to check which your phone has.

## Nothing stored, so nothing to check a guess against

A common way to build a PIN lock is to store something to compare your code with, often a hash of it. That stored check is what lets an app say "wrong PIN", and it's also something to test guesses against.

Cachette stores no copy of your pattern, no hash of it and no check value. Unlocking works like this:

1. You draw a pattern. Only the dots your finger touches are added, and each dot is used once.
2. Cachette derives a key: Argon2id, then the pepper.
3. It tries that key on every stored item. Whatever opens is the vault.

Each item is encrypted with [AES-256-GCM](https://csrc.nist.gov/pubs/sp/800/38/d/final) under its own random key, and that key is sealed under the vault key. GCM is what NIST calls "authenticated encryption": as well as scrambling the data, it can tell whether the key is the right one. A wrong key doesn't produce a garbled photo. The item simply doesn't open.

Three things follow:

- **There's no wrong pattern.** A pattern that has never been used opens an empty vault, which says: "Nothing here yet. Tap + to add photos, videos or files. Every pattern opens its own vault. Go back to draw a different one."
- **Every pattern opens its own vault.** A different pattern makes a different key, and a key opens only what was sealed with it. Add photos to an empty vault and they're sealed under its key, so you've started a new vault.
- **There's no list of vaults.** Nothing on the phone records how many vaults exist. What does stay visible, to someone with a full forensic copy of the phone's storage, is the total amount of encrypted data. [How deniable storage works without an index](https://getcachette.app/blog/deniable-storage-without-index/) goes deeper.

## Why every unlock waits the same second

Timing can give things away. If a full vault took noticeably longer to open than an empty one, anyone watching could learn whether a pattern held anything. So Cachette holds the screen still for one second on every unlock: the same for a full vault, an empty one and a brand-new one.

Think of a lift that always takes exactly the same time to arrive, whichever floor it's coming from. Timing it from the lobby tells you nothing.

## What this means for you

- **Choose a pattern you'll remember, and draw it often.** Because nothing is stored, nobody can reset a forgotten pattern, the developer included.
- **Avoid the obvious shapes.** Setup refuses very common ones, such as straight lines, letters, corner runs and the outer ring, but the strongest pattern is one nobody would guess for you. There are tips in [how to choose a pattern](https://getcachette.app/blog/how-to-choose-a-pattern/).
- **Back up for the phone, not the pattern.** A backup covers a lost, broken or reset phone. It can't help with a forgotten pattern, because restoring takes the backup file, its 24 words and that vault's pattern.

If you'd like the basics first, [encryption explained simply](https://getcachette.app/blog/encryption-explained-simply/) starts from zero. [Inside Cachette's encryption](https://getcachette.app/blog/inside-cachette-encryption/) walks through every layer, [Argon2id vs PBKDF2](https://getcachette.app/blog/argon2id-vs-pbkdf2/) compares Argon2id with the older PBKDF2, and the [security page](https://getcachette.app/security/#key) has the short version.

## Questions

### What is a key derivation function, in simple terms?

It's a recipe that turns a password, PIN or pattern into an encryption key. The same input always gives the same key, a slightly different input gives an unrelated key, and nobody can work backwards from the key to what you typed or drew.

### What is the difference between a salt and a pepper?

A salt is a random value stored next to the result. It isn't secret, but it makes identical passwords give different results and makes precomputed tables useless. A pepper is a secret key kept apart from the data, ideally in hardware, so a copy of the data alone isn't enough to test guesses.

### Why is Argon2id deliberately slow?

You pay its cost once per unlock, while someone guessing pays it for every guess. Argon2id fills a large block of memory and works through it several times, which makes guessing in bulk slow and expensive, especially on hardware built for cracking.

### Can a forgotten Cachette pattern be recovered?

No. The pattern is never stored, so nobody can reset it, the developer included. A backup doesn't replace it either, because restoring takes the backup file, its 24 words and that vault's pattern.

---

Canonical page: https://getcachette.app/blog/how-a-pattern-becomes-a-key/
Last updated: 2026-11-23
