Three things, found while chasing two intermittent failures that turned out
to be the test harness tapping the app.
`ensureLabelKey` put the request label back with
`defer { Task { await api.setLabel(previous) } }`, which reads like a
restore and is not one: the task is detached, so the label goes back at
some later moment of the runtime's choosing. Until then every request
carries the wrong area, and when it lands it can undo a label some other
call has since set. Android and the browser both restore synchronously in
a `finally` — only this port drifted. The label is now not moved at all:
storing a grant carries its own label for that one request, so anything in
flight alongside it still goes out under the area the caller is in.
`currentLabelKey` threw `notCleared` — "You aren't cleared for this" — when
the truth was that this device has not minted a key for the area yet, which
is every account before its first write. In a system built on clearance,
telling a properly cleared newcomer they are not cleared is both wrong and
alarming. It now says what is true and what to do about it.
A folder whose name will not decrypt is now checked the same way a file is.
Opening one navigated into somebody else's folder and then complained about
a missing key, which is a confusing way to say "this is not yours" — and
the file branch has always checked.
Also translates CryptoKit's authentication failures, which reached people
as "(CryptoKit.CryptoKitError error 3.)".
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
flamenet-files-ios
The iOS client for Flamenet Files — private, labelled file storage, encrypted on your device before it is uploaded.
MIT licensed, like the server and web client.
What is here
Sources/FilesEngine |
The cryptography, in CryptoKit. Implements docs/SPEC.md — the lattice, key derivation, the key hierarchy, recovery codes, filename digests, chunked content, share links. |
Sources/FilesClient |
The wire layer: server discovery, the account service, the file API, and a session that ties them together. |
Sources/filesctl |
A command-line client. Runs a full round trip against a real server without an app, a simulator, or a person tapping. |
Tests/FilesEngineTests |
Interop against vectors produced by the browser. |
The engine and the client are a Swift package rather than app code so that
swift test runs from the command line. Requiring Xcode to exercise the
cryptography would mean it gets exercised rarely, and this is the part that must
not be wrong.
Interop is the test suite
The tests do not check that this code is self-consistent — they check that it agrees with the implementation people actually use.
swift test
The vectors are generated by the JavaScript engine in the public repository and copied here verbatim. A file written in the browser must open on a phone, a code printed on one device must work on another, and a divergence should fail here rather than in somebody's hands.
Trying it against a real server
swift run filesctl https://files.flamenet.io probe
One address is enough. The server names its own account service — files.flamenet.io
points at accounts.flamenet.io, a self-hosted box points at the service bundled
alongside it — so there are no build flags and no baked-in list of which
hostnames are "ours".
swift run filesctl http://127.0.0.1:8081 smoke myhandle 'a good passphrase'
smoke registers an account, signs in fresh, creates a folder, uploads 200 KB
across four chunks, decrypts the name back, downloads and compares byte for
byte, makes a password-protected share link, opens it, and checks that the same
link is refused without the password.
Two things worth knowing
- PKCS#8 versus raw. WebCrypto exports an X25519 private key as PKCS#8;
CryptoKit uses the raw 32-byte form.
Identity.rawFromPKCS8converts. Without it, a record written in a browser cannot be opened here at all. - PBKDF2 comes from CommonCrypto. CryptoKit has no password-based KDF, and the derivation has to match WebCrypto byte for byte.
Status
The engine and the wire layer are complete and verified, including against the Android engine: one uploads, the other downloads, and the bytes match.
The SwiftUI app is in progress.
⚠️ There is no release channel yet. No signing team is configured and the export-compliance key is unset. TestFlight needs an Apple Developer Program membership; until there is one, this builds and runs in the simulator and nowhere else.
Building the app
xcodegen generate # the .xcodeproj is generated, not committed
open FlamenetFiles.xcodeproj
AppTests/ drives the real app against a real server, because the interesting
failures up here are wiring rather than cryptography — whether a button is
connected to the thing it claims to do. It expects a stack on
http://127.0.0.1:8081; the simulator shares the host's network, so
docker compose up in the public repository is enough.
xcodebuild -project FlamenetFiles.xcodeproj -scheme FlamenetFiles \
-destination 'platform=iOS Simulator,name=iPhone 17 Pro' test