You can also reach us over Tor:5tz2mhkg25tgniifrtxpvzf6xfnpogckdt2j2ele7aqtzsr2nvjbbgyd.onion

The protocol, written down

Key sizes, KDF inputs, wire layouts and the limits of each construction, taken from the design documents the app is built against. What each part does for you is on the security page.

Each section below names the construction the Android app runs, in the notation of the specification it follows, and then lists what it does not protect against. Under the notation of most sections is the function that implements it, cut from the source file at the line numbers shown each time this site is built, with the comments left out. When a function is renamed or removed the build fails, so every excerpt matches the code this site was built from. The app on your phone may come from a newer or an older build than that.

The labels inside the KDF calls are the app's own domain-separation strings and are reproduced verbatim, so an independent implementation can derive the same keys.

Identity

Three keypairs and an id you cannot be handed

An identity is generated on the phone at first launch: an X25519 key for key agreement, an Ed25519 key that signs every prekey the identity publishes, and an ML-KEM-1024 key for the sealed-sender envelope. The user id is a UUID derived from the two public keys, and registration is refused when the id does not match the keys or when the registrant cannot sign a proof that names the relay it is registering with. A relay cannot therefore issue an id for keys it does not hold.

Alongside the identity, the app publishes prekeys for people who want to start a conversation while it is offline: a signed X25519 prekey, a pool of one-time X25519 prekeys, a signed ML-KEM-1024 prekey and a pool of signed one-time ML-KEM-1024 prekeys. The relay stores public keys. Every private key lives in the vault.

identity_key     X25519        key agreement
signing_key      Ed25519       signs every prekey this identity publishes
sealed_kem_key   ML-KEM-1024   long-lived, targets the sealed-sender envelope
user_id          UUIDv8( SHA-256(identity_pk ‖ signing_pk)[0..16] )
                 identity_pk = 01 02 … 20, signing_pk = 21 22 … 40  →  20a7ec84-684f-8fe1-a4cb-3727d049734a
prekeys          SPK X25519 (signed) · OPK X25519 · PQSPK ML-KEM-1024 (signed) · PQOPK ML-KEM-1024 (signed)
From the source server/src/user_id.rs · lines 36–46
pub fn derive_user_id(identity_public_key: &[u8], identity_signing_key: &[u8]) -> Uuid {
    let mut h = Sha256::new();
    h.update(identity_public_key);
    h.update(identity_signing_key);
    let digest = h.finalize();
    let mut bytes = [0u8; 16];
    bytes.copy_from_slice(&digest[..16]);
    bytes[6] = (bytes[6] & 0x0F) | 0x80;
    bytes[8] = (bytes[8] & 0x3F) | 0x80;
    Uuid::from_bytes(bytes)
}

Limits

  • The signatures are Ed25519 and hold against a classical forger. An attacker with a quantum computer online, at the time of the handshake, could forge them; the same attacker could break the X25519 identity key, so both sit at one level. Moving the signature slot to ML-DSA is planned.
  • First contact is trust-on-first-use: the app trusts the id it was given. Every key fetched for that id must hash to it, or the app refuses the session. The safety numbers cover the whole key exchange for a manual check over another channel.

Implemented in X25519.kt · Ed25519.kt · MLKEM.kt · KeyManager.kt

Handshake

PQXDH with ML-KEM-1024

The initiator fetches the peer's prekey bundle, verifies every signature under the peer's signing key and refuses the bundle when a signature fails or no ML-KEM prekey is present. The handshake takes the post-quantum material as a non-nullable argument, so a session without it does not compile, and a relay that strips the ML-KEM prekey from a bundle gets a refusal.

Four X25519 agreements (three when the pool of one-time prekeys is empty) and one ML-KEM-1024 encapsulation go into one HKDF-SHA-512 call. The initiator encapsulates to a one-time ML-KEM prekey when the bundle has one and to the signed last-resort prekey otherwise. The 32-byte output is the first root key of the ratchet.

The first message carries the ephemeral key, the ids of the prekeys used, the KEM ciphertext and a first ratchet message. The responder builds the session in memory and only once that message decrypts does it install the session, spend the one-time prekeys and archive the previous session, in one vault transaction. A handshake whose message fails to open, because a one-time prekey was consumed by a retry, lost in a restore, or the whole thing was forged, leaves the current session, the archive and every prekey as they were. A handshake the responder has already answered is decrypted on the session it built, and the same message a second time is a duplicate.

DH1 = X25519(IK_A, SPK_B)
DH2 = X25519(EK_A, IK_B)
DH3 = X25519(EK_A, SPK_B)
DH4 = X25519(EK_A, OPK_B)               when a one-time prekey was available
(CT, SS) = ML-KEM-1024.Encaps(PQPK_B)     one-time PQ prekey preferred, else the signed one

SK = HKDF-SHA-512( salt = 0⁶⁴,
                   ikm  = 0xFF³² ‖ DH1 ‖ DH2 ‖ DH3 [‖ DH4] ‖ SS,
                   info = "Aphotic_CURVE25519_SHA-512_ML-KEM-1024",
                   L    = 32 )
From the source app/android/crypto/X3DHManager.kt · lines 50–96
fun initiateSession(
    ourIdentityPrivate: PrivateKey,
    ourIdentityPublic: ByteArray,
    theirIdentityPublic: PublicKey,
    theirSignedPrekey: PublicKey,
    theirOneTimePrekey: PublicKey?,
    theirPqPrekey: ByteArray,
): X3DHResult {
    val ephemeral = X25519.generateKeyPair()

    val dh1 = X25519.dh(ourIdentityPrivate, theirSignedPrekey)
    val dh2 = X25519.dh(ephemeral.private, theirIdentityPublic)
    val dh3 = X25519.dh(ephemeral.private, theirSignedPrekey)

    val dhConcat: ByteArray
    if (theirOneTimePrekey != null) {
        val dh4 = X25519.dh(ephemeral.private, theirOneTimePrekey)
        dhConcat = dh1 + dh2 + dh3 + dh4
        CryptoUtils.zeroize(dh4)
    } else {
        dhConcat = dh1 + dh2 + dh3
    }

    val (kemCiphertext, ss) = MLKEM1024.encapsulate(theirPqPrekey)
    val ikm = KDF_F + dhConcat + ss
    CryptoUtils.zeroize(ss)

    val sharedSecret = CryptoUtils.hkdfSha512(HKDF_SALT, ikm, HKDF_INFO_PQ, 32)

    CryptoUtils.zeroize(dh1)
    CryptoUtils.zeroize(dh2)
    CryptoUtils.zeroize(dh3)
    CryptoUtils.zeroize(ikm)
    CryptoUtils.zeroize(dhConcat)

    return X3DHResult(
        sharedSecret = sharedSecret,
        ephemeralKeyPair = ephemeral,
        kemCiphertext = kemCiphertext,
    )
}

Limits

  • SK is recoverable only by an attacker who breaks X25519 and ML-KEM-1024 both. A quantum computer built later cannot recover SK from traffic recorded today.
  • PQXDH protects the setup. What happens to the keys afterwards is the ratchet's job, below.

Implemented in X3DHManager.kt · SessionManager.kt

Ratchet

Triple Ratchet: a KEM step on every DH step

Every session runs the Double Ratchet: a symmetric chain that gives each message its own key and destroys it after use, and a DH ratchet that replaces the root key whenever the conversation changes direction. A third ratchet runs in lockstep with the second. On every DH step the sender generates a fresh ML-KEM-768 keypair, encapsulates to the peer's current one, and the KEM secret goes into the root KDF beside the DH output.

Every message carries the sender's current ML-KEM public key and, on any chain that follows a step, the ciphertext for the peer. Any single message of a chain can therefore drive the peer's step; nothing is split across messages or reassembled. A message may arrive up to 2,000 positions ahead of the last one received. The keys it skips are kept for 7 days, up to 500 per session, so late messages still decrypt. At 2²⁴ messages a chain ends and the session is re-established.

State is written to the vault only after a decryption verifies. A failed decrypt leaves the session as it was. A duplicate is recognised before any DH step, on the current receiving chain and on the last five retired ones, and changes nothing; the last five sessions with a contact stay archived, so a straggler from one of them still decrypts. A session that has diverged, a gap past the skip window on the current chain or three undecryptable messages in a row, is re-established from a fresh bundle at most once per contact per 24 hours, and only for a contact, never for a stranger. The old session goes to the archive.

chain step    MK  = HMAC-SHA-256(CK, 0x01)      CK' = HMAC-SHA-256(CK, 0x02)
message       AES-256-GCM(MK, plaintext, AD)
AD            IK_sender ‖ IK_receiver ‖ 0x03 ‖ dhPub ‖ counter ‖ prev ‖ flags ‖ kemGen ‖ kemPub [‖ ctTargetGen ‖ kemCt]

root step     (RK', CK) = HKDF-SHA-256( salt = RK,
                                       ikm  = DH(32) ‖ SS(32),
                                       info = "Aphotic_TripleRatchet",
                                       L    = 64 )
              DH: X25519 between the new ratchet key and the peer's
              SS: ML-KEM-768, Encaps to the peer's current key on send, Decaps on receive

wire          0x03 ‖ flags ‖ kemGen(u32) ‖ kemPub(1184 B) [‖ ctTargetGen(u32) ‖ kemCt(1088 B)] ‖ AEAD output
              +1190 B on every message, +2282 B on a chain that follows a step
From the source app/android/crypto/TripleRatchet.kt · lines 56–64
fun kdfRk3(rootKey: ByteArray, dh: ByteArray, ss: ByteArray?): Pair<ByteArray, ByteArray> {
    val ikm = if (ss != null) dh + ss else dh
    val output = CryptoUtils.hkdf(rootKey, ikm, TRIPLE_RATCHET_INFO, 64)
    val newRootKey = output.copyOfRange(0, 32)
    val chainKey = output.copyOfRange(32, 64)
    if (ss != null) CryptoUtils.zeroize(ikm)
    CryptoUtils.zeroize(output)
    return Pair(newRootKey, chainKey)
}

Limits

  • With no compromise, a passive attacker holding the full transcript and a quantum computer learns nothing: every root transition after setup mixes in a KEM secret it cannot recover, and the setup is PQXDH.
  • After a one-time read-out of a phone's state, the victim's sending direction heals at their next DH step and the receiving direction one round trip later, against a passive quantum attacker.
  • An attacker who holds a full copy of the state and actively sits in the path defeats every ratchet in this family, this one included.
  • The ratchet format is fixed at session setup from a native capability and never read off the wire. A peer the app has pinned as running the KEM ratchet is refused any session without it, in both directions.

Implemented in DoubleRatchet.kt · TripleRatchet.kt · RatchetSession.kt

Direct messages

Sealed sender, post-quantum

A direct message is posted to the recipient's relay without an Authorization header. The request names the recipient and carries one opaque blob; the sender's id is inside the encryption. The seal key comes from an ephemeral X25519 key and an ML-KEM-1024 encapsulation to the recipient's long-lived sealed-KEM key, with the ephemeral key, the recipient's identity key and the recipient's KEM key bound into the HKDF info.

Inside the encryption the sender puts its user id as 16 raw bytes, the two public keys that id is the hash of, and a tag keyed by an X25519 agreement between its identity key and the recipient's. The recipient goes no further unless the id is the hash of those keys and the tag verifies, so nobody can make a message look as if it came from someone else, and a message that fails either check is dropped before any contact, lookup or session is touched. The recipient can compute the same tag, which makes it a MAC rather than a signature: the sender stays deniable. The tag sits inside the post-quantum encryption, so it cannot later serve as an oracle for who sent what.

The zero nonce is safe because both inputs to the seal key are fresh per message. The recipient's KEM key is signed under their Ed25519 signing key and rides the prekey bundle, so a relay cannot substitute its own. An envelope without the ML-KEM leg or without the sender check is refused on decrypt, and a missing KEM key fails the send; either fallback would let a relay strip a protection by deleting one field. Without the ML-KEM leg, an attacker recording direct messages today and breaking X25519 later would recover the sender of every one of them.

Sending proves a license with a random handle that rotates every hour, over a Tor circuit of its own (see license tokens below). The relay pads every stored envelope to a fixed-size bucket.

(eph_sk, eph_pk) = X25519.KeyGen()
dh       = X25519(eph_sk, IK_recipient)
(ct, ss) = ML-KEM-1024.Encaps(SealedKEM_recipient)
wake     = 64 random bytes, or on a call offer / hangup:            64 B
           nonce ‖ AES-256-GCM( HKDF-SHA-256(salt = 0³², ikm = ring_key, info = "Aphotic_Wake_v1", L = 32),
                                kind ‖ call_id ‖ sent_at ‖ 0¹¹,
                                aad = "Aphotic_Wake_v1" ‖ 0x04 ‖ eph_pk )
header   = 0x04 ‖ wake ‖ eph_pk ‖ ct                                1 + 64 + 32 + 1568 B
seal_key = HKDF-SHA-256( salt = 0³², ikm = dh ‖ ss,
                         info = "Aphotic_SealedSender_v4" ‖ eph_pk ‖ IK_recipient ‖ SealedKEM_recipient,
                         L = 32 )
uid      = UUIDv8( SHA-256(IK_sender ‖ SK_sender) )                 16 B
tag      = HKDF-SHA-256( salt = 0³², ikm = X25519(IK_sender, IK_recipient),
                         info = "Aphotic_SealedSender_v4_auth" ‖ eph_pk ‖ SHA-256(ct) ‖ uid
                                ‖ IK_sender ‖ SK_sender ‖ IK_recipient ‖ SHA-256(ratchet message),
                         L = 32 )
body     = uid ‖ IK_sender ‖ SK_sender ‖ tag ‖ ratchet message
blob     = header ‖ AES-256-GCM(seal_key, nonce = 0¹², aad = header, body)
From the source app/android/crypto/SealedSender.kt · lines 160–219
fun seal(
    recipientIdentityKey: ByteArray,
    recipientSealedKemKey: ByteArray,
    sender: Sender,
    innerCiphertext: String,
    wake: WakeSpec? = null,
): ByteArray {
    require(recipientIdentityKey.size == IDENTITY_KEY_LEN) {
        "recipient identity key must be $IDENTITY_KEY_LEN bytes, got ${recipientIdentityKey.size}"
    }
    require(recipientSealedKemKey.size == MLKEM1024.PUBLIC_KEY_LEN) {
        "recipient sealed-sender KEM key must be ${MLKEM1024.PUBLIC_KEY_LEN} bytes, " +
            "got ${recipientSealedKemKey.size}"
    }
    require(sender.identityPublic.size == IDENTITY_KEY_LEN) {
        "sender identity key must be $IDENTITY_KEY_LEN bytes, got ${sender.identityPublic.size}"
    }
    require(sender.signingPublic.size == SIGNING_KEY_LEN) {
        "sender signing key must be $SIGNING_KEY_LEN bytes, got ${sender.signingPublic.size}"
    }

    val recipientPub = X25519.publicKeyFromBytes(recipientIdentityKey)
    val ephemeral = X25519.generateKeyPair()
    val ephPubBytes = X25519.publicKeyToBytes(ephemeral.public)

    val dh = X25519.dh(ephemeral.private, recipientPub)
    val (kemCt, kemSecret) = MLKEM1024.encapsulate(recipientSealedKemKey)

    val wakeBytes = wake?.let { WakeHeader.seal(it.key, it.kind, it.callId, it.sentAtMs, ephPubBytes) }
        ?: WakeHeader.random()
    val header = byteArrayOf(VERSION_V4) + wakeBytes + ephPubBytes + kemCt
    val key = deriveSealKey(dh, kemSecret, ephPubBytes, recipientIdentityKey, recipientSealedKemKey)
    CryptoUtils.zeroize(dh)
    CryptoUtils.zeroize(kemSecret)

    val uid = UserId.derive(sender.identityPublic, sender.signingPublic)
    val innerBytes = innerCiphertext.toByteArray(Charsets.UTF_8)

    val staticDh = X25519.dh(sender.identityPrivate, recipientPub)
    val tag = authTag(
        staticDh, ephPubBytes, kemCt, uid, sender.identityPublic, sender.signingPublic,
        recipientIdentityKey, innerBytes,
    )
    CryptoUtils.zeroize(staticDh)

    val body = uid + sender.identityPublic + sender.signingPublic + tag + innerBytes
    val aead = CryptoUtils.aesGcmEncryptWithNonce(key, ZERO_NONCE, body, header)

    CryptoUtils.zeroize(key)
    CryptoUtils.zeroize(body)
    CryptoUtils.zeroize(uid)
    CryptoUtils.zeroize(tag)
    CryptoUtils.zeroize(innerBytes)

    return header + aead
}
From the source app/android/crypto/SealedSender.kt · lines 235–316
fun open(
    envelope: ByteArray,
    ourIdentityPrivate: PrivateKey,
    ourIdentityPublic: ByteArray,
    ourSealedKemPrivate: ByteArray,
    ourSealedKemPublic: ByteArray,
): Opened {
    require(envelope.size > HEADER_LEN) { "sealed envelope too short: ${envelope.size} bytes" }
    require(envelope[0] == VERSION_V4) {
        "unsupported sealed envelope version 0x${(envelope[0].toInt and 0xFF).toString(16)}"
    }

    val ephPubBytes = envelope.copyOfRange(EPH_OFFSET, EPH_OFFSET + EPH_PUB_LEN)
    val kemCt = envelope.copyOfRange(EPH_OFFSET + EPH_PUB_LEN, HEADER_LEN)
    val header = envelope.copyOfRange(0, HEADER_LEN)
    val aead = envelope.copyOfRange(HEADER_LEN, envelope.size)

    val dh = X25519.dh(ourIdentityPrivate, X25519.publicKeyFromBytes(ephPubBytes))
    val kemSecret = MLKEM1024.decapsulate(ourSealedKemPrivate, kemCt)

    val key = deriveSealKey(dh, kemSecret, ephPubBytes, ourIdentityPublic, ourSealedKemPublic)
    CryptoUtils.zeroize(dh)
    CryptoUtils.zeroize(kemSecret)

    val body = CryptoUtils.aesGcmDecryptWithNonce(key, ZERO_NONCE, aead, header)
    CryptoUtils.zeroize(key)

    try {
        if (body.size < SENDER_BLOCK_LEN) {
            throw SealedUnauthenticatedException("sealed body too short for the sender block")
        }
        var off = 0
        val uid = body.copyOfRange(off, off + UID_LEN).also { off += UID_LEN }
        val senderIk = body.copyOfRange(off, off + IDENTITY_KEY_LEN).also { off += IDENTITY_KEY_LEN }
        val senderSk = body.copyOfRange(off, off + SIGNING_KEY_LEN).also { off += SIGNING_KEY_LEN }
        val tag = body.copyOfRange(off, off + TAG_LEN).also { off += TAG_LEN }
        val inner = body.copyOfRange(off, body.size)

        try {
            if (!MessageDigest.isEqual(UserId.derive(senderIk, senderSk), uid)) {
                throw SealedUnauthenticatedException("sealed sender uid does not derive from its keys")
            }

            val senderIkPub = try {
                X25519.publicKeyFromBytes(senderIk)
            } catch (e: IllegalArgumentException) {
                throw SealedUnauthenticatedException("sealed sender identity key is not a valid X25519 key", e)
            }
            val staticDh = try {
                X25519.dh(ourIdentityPrivate, senderIkPub)
            } catch (e: GeneralSecurityException) {
                throw SealedUnauthenticatedException("sealed sender identity key is degenerate", e)
            }
            val expected = authTag(
                staticDh, ephPubBytes, kemCt, uid, senderIk, senderSk, ourIdentityPublic, inner,
            )
            CryptoUtils.zeroize(staticDh)
            val tagOk = MessageDigest.isEqual(expected, tag)
            CryptoUtils.zeroize(expected)
            if (!tagOk) throw SealedUnauthenticatedException("sealed sender authentication tag mismatch")

            return Opened(
                senderId = UserId.toCanonicalString(uid),
                senderUid = uid,
                senderIdentityKey = senderIk,
                senderSigningKey = senderSk,
                innerCiphertext = String(inner, Charsets.UTF_8),
            )
        } finally {
            CryptoUtils.zeroize(tag)
            CryptoUtils.zeroize(inner)
        }
    } finally {
        CryptoUtils.zeroize(body)
    }
}
From the source app/android/crypto/SealedSender.kt · lines 345–358
private fun authTag(
    staticDh: ByteArray,
    ephPub: ByteArray,
    kemCt: ByteArray,
    uid: ByteArray,
    senderIdentityKey: ByteArray,
    senderSigningKey: ByteArray,
    recipientIdentityKey: ByteArray,
    inner: ByteArray,
): ByteArray {
    val info = AUTH_INFO + ephPub + CryptoUtils.sha256(kemCt) + uid + senderIdentityKey +
        senderSigningKey + recipientIdentityKey + CryptoUtils.sha256(inner)
    return CryptoUtils.hkdf(HKDF_SALT, staticDh, info, TAG_LEN)
}

Limits

  • This layer has no forward secrecy: it encrypts to long-term recipient keys. The ratchet message inside supplies it.
  • Like any authentication built on key agreement, the sender check does not survive the recipient's own identity key: whoever holds it can make messages to that recipient appear to come from anyone. Whoever holds it has the phone's vault already.
  • The recipient is plaintext, because the relay has to route. A relay sees who receives what and when, and since it picks the instant it wakes the recipient's waiting request, it can pair a send with a receive as it happens. Sealed sender hides the sender's identity from the relay. It does not stop a relay from correlating the two ends of a conversation by timing, and with few devices rotating handles in the same hour the crowd a sender hides in is small.

Implemented in SealedSender.kt

On the phone

A random key under two wraps

Messages, contacts, sessions and the long-term private keys are one SQLCipher database. Its key is a random 256-bit value that is never derived from the PIN. It sits under two AES-256-GCM layers: an inner one keyed from the PIN through Argon2id, and an outer one keyed by a non-exportable AES key in the Android Keystore, in StrongBox on phones that have it.

Photos, videos and voice notes are files of their own, each one segmented AES-256-GCM under a key derived from a media master key that lives in the database. A file that was cut, extended, reordered or bit-flipped is refused. Deleting the database therefore shreds every media file before one of them is unlinked, and that order is what the wipe, a view-once, an expiry and a message delete all follow. Received media is never written out decrypted; the one exit is the gallery export you switch on yourself.

The vault locks on a timer that runs on the phone's uptime clock, so a sleeping phone locks on time, and whenever the app goes to the background. A lock closes the database, drops every decrypted message from memory and restarts the app's JavaScript runtime so its heap goes with it; while the vault is locked, background delivery runs in native code and the notification names nobody.

A wrong PIN fails a GCM tag; there is no separate verification value in the metadata to attack. Five wrong attempts wipe the database, its metadata and every media file. The panic PIN is a second wrapped blob holding a sentinel. The two PINs derive different keys, so at most one blob ever opens, and a valid decrypt of the sentinel runs the same wipe with no prompt, after which the app shows its setup screen.

With the optional master passphrase enabled, the key is re-wrapped under Argon2id of the passphrase at 128 MiB, and a time-limited Keystore key opens a PIN window (8 hours to 7 days, 48 hours by default) in which the six-digit PIN alone unlocks. The window is enforced by the Keystore's own validity period, an app-side expiry and a monotonic clock guard against rollback. A reboot asks for the passphrase again.

Backups are one file re-encrypted under Argon2id at 128 MiB of a secret: by default a 260-bit recovery key the app generates for each export, shows once as 52 characters and never stores, or a passphrase of at least 12 characters. Moving phones is a direct device-to-device transfer. The app opts out of Android backup.

K_pin        = Argon2id( PIN, salt; m = 64 MiB, t = 4, p = 1 )
K_hw         = AES-256 in Android Keystore, non-exportable, StrongBox preferred
wrapped_dek  = AES-256-GCM( K_hw, AES-256-GCM( K_pin, DEK ) )

unlock       strip the outer layer with K_hw (this phone only), then the inner with K_pin
             the GCM tag is the PIN check

panic        AES-256-GCM( K_hw, AES-256-GCM( K_panic, SENTINEL ) )    a valid decrypt wipes
passphrase   K_master = Argon2id( passphrase ≥ 12 chars, salt; m = 128 MiB, t = 4 )
backup       Argon2id( recovery key (260 bit, new per export) or passphrase ≥ 12 chars, salt; m = 128 MiB, t = 4 ), AES-256-GCM
media        K_file = HMAC-SHA-256( K_media, r ),  K_media in the vault, r random per file
             AES-256-GCM over 64 KiB segments, header as AAD, the last segment marked
From the source app/android/crypto/PinManager.kt · lines 1348–1352
private fun wrap(payload: ByteArray, kPin: ByteArray): String {
    val inner = CryptoUtils.aesGcmEncrypt(kPin, payload)
    val outer = hw.wrapEncrypt(inner)
    return CryptoUtils.toBase64(outer)
}

Limits

  • A copied vault file is useless without K_hw, which is what makes a six-digit PIN acceptable. Code running as the app on a rooted phone can ask the Keystore to strip the outer layer and then guess the PIN offline. The master passphrase exists for that threat.
  • When the Keystore key is gone (factory reset, cleared app data), the vault cannot be opened. A backup file is the only way back, and without its recovery key or passphrase the file stays shut.
  • Argon2id uses 64 MiB for the daily PIN because low-end phones run out of memory above that. The hardware wrap is the primary barrier there; the KDF cost is the second.

Implemented in PinManager.kt · VaultDatabase.kt · VaultKeyStore.kt · VaultBackup.kt · Argon2id.kt · MediaCipher.kt · EncryptedMediaStore.kt · AppLockManager.kt

Licensing

Blind-signed license tokens

The shop knows the license and the payment. The chat relay knows the identity. No one may join the two, the operator included. A license proves itself with RSA blind signatures: the app generates random 32-byte token ids, blinds them and sends the blinded values to the licensing service, which signs them with a key that exists for one hour and counts how many it signed per license. It never sees an unblinded id.

The app unblinds the signatures and later spends a token at the relay, which verifies it under that hour's public key, records a hash of the id against replay and marks the identity licensed until the hour ends. The relay learns that the holder is licensed this hour and nothing about which license.

The hourly keys are published 72 hours ahead under a commitment signed with the relay-directory key. The app pins each key the first time it sees it, refuses any later change to a pinned key, and mints only under a key it has seen twice at least 15 minutes apart, so a key tailored to one device cannot be used to tag its tokens. A mint covers a window of up to 48 hours, and a random gap of 45 to 180 seconds separates every licensing request that names the license from every spend at the relay, with one exception listed under the limits.

The sealed-sender handle is licensed by a second token on a route with no authentication at all, so a handle and an identity are never in one request. The client runs three Tor SOCKS ports (licensing service, identity session, sealed sends) so the three never share a circuit, and a fourth for guest identities on other relays. When the handle rotates, the pooled connections of its circuit are dropped so one connection cannot chain two pseudonyms.

suite        RSA-2048, RSASSA-PSS, SHA-256, salt 32           (RFC 9474)
epoch        floor(unix_time / 3600); one signing keypair per epoch, pruned when it ages out
issue        licensed request: blinded ids → blind signatures; ≤ 10 × seats + 2 per license per epoch
keys         published 72 epochs ahead, under a commitment signed with the relay-directory key
mint         up to 48 epochs at once, only under keys seen twice ≥ 15 min apart
spend        no credentials: (epoch, token_id, signature); 45–180 s after any request that named the license, except the first registration
             verify → INSERT (epoch, SHA-256(token_id)) INTO spent_tokens, refused if present → licensed until the epoch ends
two spends   one for the identity's session, one for the sealed-sender handle
From the source server/src/token_verify.rs · lines 179–215
pub async fn verify_and_spend(
    state: &AppState,
    epoch: i64,
    token_id: &[u8],
    signature: &[u8],
) -> Result<i64, AppError> {
    let cur = current_epoch();
    if epoch < cur - 1 || epoch > cur + 1 {
        return Err(AppError::LicenseInvalid(
            "redeem_required: token epoch out of range".into(),
        ));
    }
    if token_id.len() != 32 {
        return Err(AppError::BadRequest("token_id must be 32 bytes".into()));
    }

    let key = get_key(state, epoch).await?;

    let sig = Signature(signature.to_vec());
    sig.verify(&key.pk, None, token_id, &opts())
        .map_err(|_| AppError::LicenseInvalid("redeem_required: invalid token".into()))?;

    if !record_spend(state, epoch, token_id).await? {
        return Err(AppError::LicenseInvalid(
            "redeem_required: token already redeemed".into(),
        ));
    }

    Ok(epoch_end(epoch))
}

Limits

  • A license shared beyond its seats runs its hourly allowance dry mid-hour. That is the whole enforcement; a patched app gains nothing, because the relay's verdict can only be set by an unspent, correctly signed token.
  • A device's two redemptions happen in the same hour, jittered by 20 seconds. The crowd a device hides in is the number of devices redeeming in that window. At a small user count, timing correlation of the two is practical.
  • A fresh install can send only once it has seen the current key twice, which takes 15 to 30 minutes after the first launch.
  • The first registration after a license is activated mints one token and spends it at once, with no gap. Someone running both services can pair that one moment by timing.

Implemented in blindToken.ts · token_verify.rs · token_keys.rs

Communities

MLS with a hybrid KEM

Communities of up to 5,000 members run RFC 9420 MLS with TreeKEM, from a clean-room implementation gated by the RFC's test vectors. Communities use a private-use ciphersuite, 0xF043: the KEM is X25519 combined with ML-KEM-768 through a combiner that binds both ciphertexts, so the hybrid holds if either component does; the AEAD is AES-256-GCM, the hash SHA-256, the signature Ed25519.

Each leaf credential carries the member's user id, the two public keys that id is the hash of, and an Ed25519 signature over the leaf key, the ciphersuite and the founder's key. It is checked wherever a leaf is seated, so a seat belongs to one identity and rank enforcement keys on the authenticated sender that MLS decryption returns. The founder's key is the trust anchor and rides the invite link. An invite card admits the one person it was sent to. A member who leaves is removed by the next admin's device on the leaver's own signed leave request, never on the relay's word.

A Welcome carries the tree by SHA-256 reference, with the tree itself sent once alongside the commit, so a Welcome stays flat in size at any member count. Commits also go to a durable log, so a member who was offline past the 7-day stream replays them in order under its existing leaf. Any member may issue a self-update commit; that is how the tree fills and each commit stays logarithmic in the member count.

suite 0xF043   KEM = X25519 + ML-KEM-768 (combined over both ciphertexts) · AES-256-GCM · SHA-256 · Ed25519
leaf           credential = uid ‖ IK ‖ SK ‖ Ed25519( leaf key ‖ suite ‖ founder key ), verified wherever the leaf is seated
welcome        GroupInfo + GroupSecrets; tree by SHA-256 reference, sent once with the commit
history        commits in a durable log; content on a 7-day stream
From the source app/android/mls-core/HybridKem.kt · lines 173–179
private fun combine(ssM: ByteArray, ssX: ByteArray, ctX: ByteArray, pkX: ByteArray): ByteArray {
    val d = SHA3Digest(256)
    for (part in arrayOf(ssM, ssX, ctX, pkX, LABEL)) d.update(part, 0, part.size)
    val out = ByteArray(SHARED)
    d.doFinal(out, 0)
    return out
}

Limits

  • The relay sees the roster and the epoch number of each community.
  • Everyday groups of up to 20 stay pairwise: each message is encrypted separately for every member with the ratchet above and sent as sealed legs under a handle kept for group traffic, so no group key exists on the relay. Who is in the group is decided by its admins: the roster is an admin's snapshot inside the encryption, the group id is derived from the creator's key, and an invite link carries a join secret that only the admin who minted it can confirm. The relay stores nothing about the group itself. For each invite link it holds one rendezvous row: hashes of the link's token and of a manage secret, a constant-size encrypted blob that only the link's secret opens, and an expiry rounded up to the hour. A link the operator takes down leaves only its token hash behind, for at least a year, so it cannot be published again.
  • Every group send includes one leg to the sender's own queue, and every leg of one send is padded to the same length, so the relay sees the whole roster as recipients and never the roster minus the sender. The number of legs is visible to it, and a bucket gives the size of a message to within a factor of two.

Implemented in CipherSuite.kt · HybridKem.kt · MlsGroup.kt · Welcome.kt · KeySchedule.kt

On the relay

What is stored, and for how long

The relay is a Tor hidden service with no clearnet endpoint. It stores public keys, the user id derived from them, community rosters, one rendezvous row per group invite link, and queued ciphertext for at most 7 days. A lookup of another user's keys carries no session token, so the relay serves it without learning who asked. A stored attachment sits beside the hash of a download token and nothing else; the token travels inside the encrypted message, and the download presents it without a session. Every stored envelope is padded to a bucket of 256, 512, 1024, 2048, 4096 or 8192 bytes and in 4 KiB steps above that, with a 256 KB ceiling. The tables have no columns for sign-up or last-seen times. Typing indicators and presence do not exist on the wire. Read receipts are optional, off by default and limited to one-to-one chats. With them on, the client puts a read_up_to field inside the sealed envelope: the peer's own sent_at stamp of the newest message read, which covers every message up to it. The field rides on the next message to that contact; if nothing goes out, one sealed envelope with an empty body carries it after a random 15 to 30 seconds.

Replies carry no server or version header. Traffic reaches the relay from the local Tor process, so no request carries a client IP address to log.

From the source server/src/padding.rs · lines 28–37
pub fn padded_size(actual: usize) -> usize {
    for &bucket in BUCKETS {
        if actual <= bucket {
            return bucket;
        }
    }
    let last = *BUCKETS.last().unwrap();
    last + ((actual - last + LARGE_BOUNDARY - 1) / LARGE_BOUNDARY) * LARGE_BOUNDARY
}

Limits

  • Timing is left to Tor. A watcher who sees both first hops at once can correlate them, and Tor states that limit openly; a delay added inside the app would shift both ends equally.
  • A read receipt sent on its own is one more sealed send the relay can line up with the reader's last fetch. The random delay blurs that, a receipt riding on a message removes it, and with receipts off the client sends none.

Implemented in padding.rs · sealed.rs · longpoll.rs

Calls

Voice calls through our own relay

Tor carries no UDP, so the audio of a call leaves Tor and travels the ordinary internet through a TURN relay we run. Before every call, placed or answered, the app asks the user to confirm that the call leaves Tor, and only a contact the user has accepted can ring. Setting the call up stays inside the chat: the offer and the answer are sealed direct messages under the Triple Ratchet. Each carries one side's 32-byte share of the call secret and its DTLS fingerprint, so the relay cannot sit in the middle of the handshake.

Each phone fetches TURN credentials from the chat relay over Tor, on a request with no session token that proves a license with the sealed-sender handle. The username is an expiry and a random nonce, never a user id, and the credentials last 10 minutes. libwebrtc runs with relay-only ICE against our TURN servers and no STUN server, and every candidate that is not a relay candidate is stripped from both session descriptions, so neither phone ever sees the other's address.

The audio is Opus at a constant bitrate with discontinuous transmission off, inside two layers: DTLS-SRTP with the AES-GCM suites, and a frame layer keyed from the two shares. libwebrtc's frame cryptor derives 128-bit keys, so the frame layer is AES-128-GCM, below the AES-256 the rest of the app uses.

ICE         iceTransportPolicy = relay, our TURN servers only, no STUN; non-relay candidates stripped from both SDPs
TURN        POST /v1/calls/turn-credentials over Tor: no session, X-Sealed-Handle
            username = expiry ‖ ":" ‖ hex(16 random bytes),  password = Base64( HMAC-SHA1(secret, username) ),  TTL 600 s
signalling  offer { k_c, SDP }, answer { k_r, SDP }: sealed direct messages under the Triple Ratchet
            k_c, k_r = 32 random bytes each; the DTLS fingerprint rides in the SDP

secret      S   = HKDF-SHA-256( salt = "aphotic-call-v1", ikm = k_c ‖ k_r, info = call_id, L = 32 )
frame keys  K_i = HKDF-SHA-256( salt = "aphotic-call-key", ikm = S, info = call_id ‖ "|" ‖ i, L = 32 )    i = 0..15, the next one every 5 min
frames      libwebrtc FrameCryptor, AES-GCM, per-frame keys derived at 128 bits
transport   DTLS-SRTP, AES-GCM suites
audio       Opus, cbr = 1, usedtx = 0, 32 kbit/s

Limits

  • The call relay sees both IP addresses, that the two are talking, when the call starts and ends, and how many bytes pass. It sees them while the call runs. We keep no log of them, and that rests on our word.
  • The chat relay and the call relay have the same operator. Whoever runs both could match a call offer delivered to a recipient with the relay allocations it causes seconds later, and so learn the recipient's IP address. Neither keeps a record that would allow this afterwards.
  • The key agreement of DTLS-SRTP is classical. The frame layer's shares travel inside the Triple Ratchet, which mixes in ML-KEM, so recorded audio stays protected by AES-128-GCM against a later quantum attacker. That is NIST's lowest post-quantum security category.
  • Your network provider sees UDP or TLS traffic to a known Aphotic address, so it can tell that you are on a call.
  • A call longer than 80 minutes stays on the last frame key.

Implemented in CallManager.kt · SdpMunge.kt · CallFrameFormat.kt · callFrameKeys.ts · callSession.ts · calls.rs

Checking

What the constructions are tested against

Each construction ships with executable tests, and the ones that follow a public specification are pinned to that specification's vectors.

  • PQXDH: HKDF-SHA-512 vectors from the specification's own construction, plus seed-to-public-key pins for ML-KEM
  • Double and Triple Ratchet: round trip, out-of-order delivery, post-compromise healing and restart survival, on the JVM and on a phone
  • Sealed sender: round trip, an envelope without the KEM leg refused, tamper detection on every header field
  • X25519: rejection of a set high bit, u ≥ p and each small-order point, with a hand-built key for each case
  • Argon2id: known-answer tests against the reference output
  • MLS: the official RFC 9420 vectors for tree math, crypto basics, key schedule, secret tree, tree validation and Welcome, plus multi-member round trips
  • Blind tokens: the TypeScript client verified byte for byte against the audited Rust crate the services use

Found a gap?

Every message through the contact page reaches the operator as one email. A finding that holds up gets an answer and a line on the transparency page.

This site sets no cookies and does not track you. On your device it remembers your language choice and which notices you closed, and keeps checkout data only while the tab is open. Privacy policy