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.
Files
Paul Hitt 51396b6f23 X25519 in DER form, because Android is not the JVM
Running the app on a phone threw "No AlgorithmParameterSpec classes are
supported" the first time anyone tapped Create account. Android's provider
is Conscrypt, not the JDK's, and its XDH key-pair generator rejects every
parameter spec while its key factory does not speak the XEC* specs at all
— none of which the JVM suite could see, because it passes there.

X25519 now goes through PKCS#8 and X.509 encodings, which both providers
already speak. That also removes the RFC 7748 little-endian BigInteger
conversion entirely, and with it a class of byte-order bug that produces
plausible keys agreeing with nothing.

An instrumented suite runs the published vectors on a device, so the next
provider difference fails in CI rather than in someone's hands.

Three consequences worth stating plainly:

minSdk is 33, not 26. Android exposes XDH from API 33; below that a
provider has to be registered at startup and nothing here does that, so
claiming 26 was claiming something untrue.

Cleartext is refused with a reason rather than failing as an unexplained
connection error. Bearer tokens ride every request, so a plain-http server
would put an account on a café network.

material-icons-extended is gone. It generates a class per icon and added
44 MB of dex for the five glyphs this app uses; three hand-written vector
paths replace it.
2026-08-21 21:07:25 -04:00

4.8 KiB

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.