The story, with the bad news left in
From 32 ms to 3 ms. Mostly by removing things.
This started as a bash script that took 32 ms to read one secret. We rewrote the reader in Rust, a language built for fast, safe programs, and now it takes 3 ms on an M5 Mac. AI agents did a lot of the building, and we kept notes like anthropologists, mistakes included.
Timeline
- First commit: age-encrypted env files in git, one file per scope (age is a small, widely used open-source file encryption tool).
- A bash tool, version 2.0:
run,verify, logins, time limits, Secure Enclave keys. - Round 1. The bash tool spawned
agefor every read: 46 to 48 ms. A first Rust reader, the start of fastsecrets, read the same store in 5.78 ms with a software key and 11.38 ms through the chip. - age 1.4.0 shipped that same day with a new chip-key format older readers could not read. We caught it on dummy data before any machine upgraded, pinned age and added native support for both formats.
- Round 2. A native Rust
run: 6.3 ms software, 11.8 ms chip, against 46 to 61 ms for the bashrun. - The public benchmark: 3.24 ms software, 9.05 ms chip on the M5 (all results).
Research footnote
The December 2 numbers come from benchmark protocol v0.3.1, 5 sessions per kind per machine.
What changed, step by step
- Stop spawning
age. The reader decrypts the store itself, Secure Enclave keys included. Noageprocess, no plugin process, no shell. With this reader, round 1 went from 46 to 48 ms to 5.78 ms. - One decrypt per scope. Five names cost what one name costs. On the M5 chip path, five secrets take 9.06 ms and one takes 9.05 ms.
- A names-only index. It records which scope holds which name, so a warm read decrypts one scope instead of all of them. No values, no keys.
- No PATH search. The reader never runs a binary it finds on PATH. That closed a security hole (see the lessons).
- Native
run. The reader puts values in the program's environment and, without--mask, becomes the program itself, so no parent holding the values stays alive. With--maskit stays as a filter on the program's output.
Where it started, where it ended
Same machine, same protocol, bash tool versus Rust reader (M5, software key).
| bash tool | fastsecrets | |
|---|---|---|
| read one secret | 32.07 ms | 3.24 ms |
| start a program with one secret | 45.44 ms | 4.70 ms |
| start a program with five secrets | 174.53 ms | 4.75 ms |
We did not measure each step's saving in isolation. The table shows where it started and where it ended.
Research footnote
Round 1 timed the bash read at 46 to 48 ms; under the final protocol, its software-key read measured 32.07 ms. The 0.34 ms in the diagram's top note below is one sandbox trace on the M5, not a benchmark figure.
What we learned
- Compare mode to mode. Our first comparison set our chip mode against a rival's software mode, and it looked like a loss. Mode for mode we were ahead: 6.3 vs 9.8 ms in software, 11.8 vs 20.8 ms on the chip.
- The chip has a fixed price. About 4.5 ms of every chip read is the Secure Enclave itself. No code removes it. We budget for it.
- The language is not the speedup. Rivals are written in Rust too. The time came out of three removals: the
agespawn, the shell and the extra decrypts. - We chased the outright chip win, and parked it. We built a helper that keeps a connection to the chip, measured it and had it reviewed. At best it tied. It also opened an offline leak path. We shelved it. The fast path we recommend is batching: one call per agent step.
- Our worst hole came from our own fallback. A fallback in the reader ran whatever
agewas first on PATH. A planted program there could return a forged value with exit 0. Our own security detectors found it. Version 0.2.0 removed it. - Pin your upstream. age 1.4.0 changed the chip-key format on our release day. A pin and a dummy-data compatibility matrix turned a breaking change into a planned upgrade.
- The benchmark needed adversaries too. An outside review found that our round-1 runner timed only successful samples, had no timeout and let entrants read the fixture. All three were fixed before the numbers above.
The agents' mistakes
Digital anthropology with AI. We ran this project with AI agents and wrote rules for them. They still broke some.
- One let a keychain test hang for 8 minutes in a sandbox.
- One ran a safety wrapper that hashed values from the real store and keychain.
- One ran a downloaded binary outside the sandbox.
- On the Linux box, one agent blamed slow sessions on host cron, then on zombie processes. Checking the timings showed the real cause: other tenants on the shared host were taking CPU.
- In the voice-agent test, an agent's first process sampler used the wrong
psflag and reported zero leaks. The result was invalid. It caught the error, fixed the flag and ran again.
The first three were self-reported, and all three were checked afterward. Written rules help. Checking the work catches the rest.
Where to go from here
The benchmark
Every table, every non-win and the fnox daemon row.
The guide
Install, store, read, sync, recover and uninstall.
For agents
The rules, a copy-paste SKILL.md and the voice-agent pattern.