This repository has been archived on 2026-10-15. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Paul HittandClaude Opus 5 25f343d901 Fix recovering twice, and stop the keyboard editing the passphrase
Recovery minted the replacement code twice — one sent to the account
service, a different one wrapped into the identity record and shown on
screen. The first recovery looked perfect and left the account openable
only with a code nobody had ever seen. It takes a second recovery to
notice, which is to say it would have been noticed by somebody who had
already lost a passphrase twice. One code now reaches both writes.

The passphrase and recovery-code fields never told the keyboard what they
were, so autocorrect was live on both. A passphrase is chosen to be long
and memorable rather than dictionary-shaped, which is exactly the sort of
text autocorrect likes to improve, and an improved passphrase cannot be
recovered — only replaced with the code. The recovery code is twenty-eight
characters of base32 typed once, from paper, under stress. Both now
declare themselves, and the handle no longer gets a capital letter it
never asked for.

The recovery code is also laid out four groups to a line: left to wrap, the
last group split across lines as "…-YR" and "RK", on the one screen
somebody copies by hand with no way to check it afterwards.

Rows this device can read now come before the ones it cannot. An area is
shared by everyone cleared for it, so the listing carries other people's
files as rows without names — showing them is deliberate, but arriving at
a screenful of "Encrypted for another key" with your own folder below the
fold is a poor way to meet the thing.

The instrumented suites are new: registration, sign-in, recovering twice,
folders, upload, share links with the secret asserted to be in the
fragment, switching areas within a clearance, and a visual tour that
photographs each screen. Shared helpers live in one file, because the same
row-finder was copied into three and then fixed in one of them — and the
first version scrolled inside a `waitUntil`, which ran on the main thread
often enough for Android to declare the app unresponsive and kill the run.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-22 20:27:15 -04:00

flamenet-files-android

The Android 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

engine/ The cryptography, in plain Kotlin over JCA. Requires API 33+ — that is where Android exposes X25519. Implements docs/SPEC.md — the lattice, key derivation, the key hierarchy, recovery codes, filename digests, chunked content, share links.
client/ The wire layer: server discovery, the account service, the file API, a session that ties them together, and filesctl, a command-line client.

Both are plain JVM libraries, not Android modules, so gradle test runs them without an emulator or the Android SDK. Cryptography that can only be tested on a device is cryptography that gets tested rarely.

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.

gradle :engine: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

gradle :client:run --args="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".

gradle :client:run --args="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.

Three things worth knowing

  • HKDF is written out here. Neither the JDK nor Android exposes it through JCA. It is extract-then-expand over HMAC and nothing more; thirty lines beats a dependency, and it is covered by the interop vectors rather than trusted.
  • X25519 keys need endian care. JCA's XECPublicKey carries a BigInteger in big-endian order while the wire format is little-endian, so X25519 converts in both directions rather than assuming.
  • Kotlin 2.4, JVM 17 bytecode. No jvmToolchain, deliberately: pinning one demands a JDK that may not be installed, which is a poor trade for a library this size. Earlier Kotlin releases hit an internal compiler error on recent JDKs.

Status

The engine and the wire layer are complete and verified, including against the iOS engine: one uploads, the other downloads, and the bytes match.

The Jetpack Compose app is in progress.

Building the app

app/ is a Jetpack Compose module and needs the Android SDK. The engine and client do not:

./gradlew :engine:test :client:build     # no SDK required
./gradlew :app:assembleDebug             # SDK required

Two things the build needs, and neither is obvious:

  • JDK 21. The Android Gradle Plugin rejects JDK 26, which is what Homebrew installs as openjdk. brew install openjdk@21 and point JAVA_HOME at it for this build only — the engine and client are happy on either.
  • The wrapper, not your gradle. ./gradlew pins Gradle 8.11.1 because AGP 8.7 does not support Gradle 9. A system gradle will be newer and the build will fail in a way that does not mention versions.
export JAVA_HOME=$(brew --prefix openjdk@21)/libexec/openjdk.jdk/Contents/Home
./gradlew :app:assembleDebug

The APK lands in app/build/outputs/apk/debug/. local.properties points at the SDK and is not committed.

A debug APK is around 54 MB and a minified release one is 2.5 MB — R8 is doing almost all of that, so do not read the debug figure as the size of the app.

On-device tests

./gradlew :app:connectedDebugAndroidTest

⚠️ These are not redundant with :engine:test. Android's security provider is Conscrypt, not the JDK's, and the two disagree: the obvious X25519 implementation using NamedParameterSpec and XECPublicKeySpec passes every JVM test and then throws No AlgorithmParameterSpec classes are supported the first time somebody taps Create account on a phone. That happened. The engine now speaks DER to both providers, and the published vectors run on a device as well as on the JVM so the next such difference fails in CI.

S
Description
Open-source Android client for Flamenet Files — end-to-end encrypted, labelled file storage. MIT.
Readme MIT
490 KiB
Languages
Kotlin 100%