findfamily: fingerprints
- Commit
6d6c7150d860eac7b0d53b4902937b5954f9a777- Author
- vayun-mathur <[email protected]>
- When
- 2026-08-23 19:12 UTC (3 months ago)
- Parents
e8d957c
Diff
findfamily/src/main/java/com/vayunmathur/findfamily/MainActivity.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/MainActivity.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/MainActivity.ktindex 297a6d72cf..d0d3a24813 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/MainActivity.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/MainActivity.kt@@ -75,15 +75,15 @@ class MainActivity : ComponentActivity() { } /**- * Pending `findfamily://add/<base26>` invite id (already decoded), set on cold+ * Pending `findfamily://add/<base26>` invite (already decoded), set on cold * start and via [onNewIntent] for warm starts. Read from Compose so a tap routes * to the prefilled Add Person dialog; cleared once consumed. */- private val deepLinkAddId = mutableStateOf<Long?>(null)+ private val deepLinkAddInvite = mutableStateOf<AddInvite?>(null) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState)- deepLinkAddId.value = parseAddDeepLink(intent)+ deepLinkAddInvite.value = parseAddDeepLink(intent) // FIRST_PARTY: api.vayunmathur.com + data.vayunmathur.com + findfamily.cc (Cloudflare ISRG+GTS) NetworkClient.init(this, TrustBundle.FIRST_PARTY) enableEdgeToEdge()@@ -124,8 +124,8 @@ class MainActivity : ComponentActivity() { ffViewModel, ffViewModel.missingFeatures, deepLinkPeerId,- deepLinkAddId.value,- onDeepLinkAddConsumed = { deepLinkAddId.value = null },+ deepLinkAddInvite.value,+ onDeepLinkAddConsumed = { deepLinkAddInvite.value = null }, ) } }@@ -137,22 +137,29 @@ class MainActivity : ComponentActivity() { // singleTop: warm-start links arrive here. Keep getIntent() in sync and // surface the invite so Compose routes to the prefilled dialog. setIntent(intent)- parseAddDeepLink(intent)?.let { deepLinkAddId.value = it }+ parseAddDeepLink(intent)?.let { deepLinkAddInvite.value = it } } /**- * Decodes a `findfamily://add/<base26Userid>` invite to a numeric user id, or- * null for any other intent. The link carries only the sender's public id.+ * Decodes a `findfamily://add/<base26Userid>[?k=<fingerprint>]` invite, or null for any+ * other intent. `k` is a truncated hash of the sender's public bundle, which the connect+ * flow checks the relay's key against; links from builds before it existed have no `k`. */- private fun parseAddDeepLink(intent: Intent?): Long? {+ private fun parseAddDeepLink(intent: Intent?): AddInvite? { val data = intent?.data ?: return null if (data.scheme != "findfamily" || data.host != "add") return null val segment = data.lastPathSegment?.trim()?.uppercase() ?: return null if (segment.isEmpty() || segment.any { it !in 'A'..'Z' }) return null- return runCatching { segment.decodeBase26() }.getOrNull()+ val id = runCatching { segment.decodeBase26() }.getOrNull() ?: return null+ val fingerprint = runCatching { data.getQueryParameter("k")?.trim() }.getOrNull()+ ?.takeIf { it.isNotEmpty() && it.all { c -> c.isLetterOrDigit() || c == '-' || c == '_' } }+ return AddInvite(id, fingerprint) } } +/** A tapped invite link: the sender's id, plus the bundle fingerprint it vouched for. */+data class AddInvite(val id: Long, val fingerprint: String?)+ @Composable fun NoPermissionsScreen( hasFine: Boolean,@@ -291,7 +298,7 @@ sealed interface Route: NavKey { data class UserPageHistoryDatePicker(val initialDate: LocalDate): Route @Serializable- data class AddPersonDialog(val id: Long? = null): Route+ data class AddPersonDialog(val id: Long? = null, val fingerprint: String? = null): Route @Serializable data object AddLinkDialog: Route@@ -314,7 +321,7 @@ fun Navigation( ffViewModel: FindFamilyViewModel, showMissingFeatures: Boolean, deepLinkUwbPeerId: Long? = null,- deepLinkAddId: Long? = null,+ deepLinkAddInvite: AddInvite? = null, onDeepLinkAddConsumed: () -> Unit = {}, ) { val backStack = rememberNavBackStack<Route>(Route.MainPage())@@ -333,9 +340,9 @@ fun Navigation( // A tapped invite prefills the Add Person dialog; the user still explicitly // accepts, so the connection/crypto flow is unchanged.- LaunchedEffect(deepLinkAddId) {- if (deepLinkAddId != null) {- backStack.add(Route.AddPersonDialog(deepLinkAddId))+ LaunchedEffect(deepLinkAddInvite) {+ if (deepLinkAddInvite != null) {+ backStack.add(Route.AddPersonDialog(deepLinkAddInvite.id, deepLinkAddInvite.fingerprint)) onDeepLinkAddConsumed() } }@@ -349,7 +356,7 @@ fun Navigation( TimeZone.currentSystemDefault()).date) } entry<Route.AddPersonDialog>(metadata = DialogPage()) {- AddPersonDialog(backStack, ffViewModel, platform, it.id)+ AddPersonDialog(backStack, ffViewModel, platform, it.id, it.fingerprint) } entry<Route.AddLinkDialog>(metadata = DialogPage()) { AddLinkDialog(backStack, ffViewModel)
findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/AddPersonDialog.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/AddPersonDialog.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/AddPersonDialog.ktindex 5f784413ec..31c9a69fa3 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/AddPersonDialog.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/AddPersonDialog.kt@@ -44,6 +44,7 @@ fun AddPersonDialog( ffViewModel: FindFamilyViewModel, platform: Platform, id: Long?,+ fingerprint: String? = null, ) { val usersByID by ffViewModel.usersById.collectAsState() @@ -58,6 +59,11 @@ fun AddPersonDialog( val userStatus = usersByID[userid.decodeBase26()]?.requestStatus val context = LocalContext.current var showOutdatedPeer by remember { mutableStateOf(false) }+ var showKeyMismatch by remember { mutableStateOf(false) }++ // The fingerprint only vouches for the id that arrived in the link, so it stops applying+ // if the field gets edited to a different one.+ val inviteFingerprint = fingerprint?.takeIf { id != null && userid.decodeBase26() == id } Dialog({backStack.pop()}) { Card {@@ -78,13 +84,16 @@ fun AddPersonDialog( ) // Share sheet instead of copy/paste: sends an https link that bounces to- // findfamily://add/<myId>, which prefills the recipient's Add Person dialog.- // The web hop exists because many messengers won't linkify a bare custom- // scheme. The id rides in the fragment, which browsers never send, so the- // server sees only that some share page was opened.+ // findfamily://add/<myId>?k=<fingerprint>, which prefills the recipient's Add+ // Person dialog. The web hop exists because many messengers won't linkify a bare+ // custom scheme. Both values ride in the fragment, which browsers never send, so+ // the server sees only that some share page was opened. `k` is a 22-character+ // hash of our public bundle, not the bundle itself (~4 kB base64) — the recipient+ // fetches the key from the relay and checks it against this. OutlinedButton( {- val link = "https://ma.vayunmathur.com/ff/share#id=${Networking.userid.encodeBase26()}"+ val base = "https://ma.vayunmathur.com/ff/share#id=${Networking.userid.encodeBase26()}"+ val link = Networking.myInviteFingerprint()?.let { "$base&k=$it" } ?: base ExternalIntents.shareText( context, link,@@ -135,7 +144,9 @@ fun AddPersonDialog( ) ffViewModel.connectUser( userToAdd,+ inviteFingerprint = inviteFingerprint, onNeedsUpdate = { showOutdatedPeer = true },+ onKeyMismatch = { showKeyMismatch = true }, onDone = { backStack.pop() }, ) },@@ -154,6 +165,10 @@ fun AddPersonDialog( if (showOutdatedPeer) { OutdatedPeerDialog(onDismiss = { showOutdatedPeer = false }) }++ if (showKeyMismatch) {+ KeyMismatchDialog(onDismiss = { showKeyMismatch = false })+ } } fun String.decodeBase26(): Long = fold(0uL) { acc, c ->
findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/KeyMismatchDialog.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/KeyMismatchDialog.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/KeyMismatchDialog.ktnew file mode 100644index 0000000000..89c2b6ce6d--- /dev/null+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/dialogs/KeyMismatchDialog.kt@@ -0,0 +1,25 @@+package com.vayunmathur.findfamily.ui.dialogs++import androidx.compose.runtime.Composable+import androidx.compose.ui.res.stringResource+import com.vayunmathur.library.ui.AlertDialog+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TextButton+import com.vayunmathur.library.ui.R as UiR+import com.vayunmathur.findfamily.R++/**+ * Shown when the key the relay returned for a peer doesn't match the fingerprint their+ * invite link carried. Either the link was copied incompletely, or the key isn't the one+ * the sender published — so the connection is refused rather than made with a key nothing+ * vouches for.+ */+@Composable+fun KeyMismatchDialog(onDismiss: () -> Unit) {+ AlertDialog(+ onDismissRequest = onDismiss,+ title = { Text(stringResource(R.string.key_mismatch_title)) },+ text = { Text(stringResource(R.string.key_mismatch_body)) },+ confirmButton = { TextButton(onClick = onDismiss) { Text(stringResource(UiR.string.done)) } }+ )+}
findfamily/src/main/java/com/vayunmathur/findfamily/util/FindFamilyViewModel.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/util/FindFamilyViewModel.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/util/FindFamilyViewModel.ktindex bfee03eab9..f745d8b5c5 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/util/FindFamilyViewModel.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/util/FindFamilyViewModel.kt@@ -154,16 +154,31 @@ class FindFamilyViewModel( * on an outdated (classic-only) app, invokes [onNeedsUpdate] and does NOT add them. * Unknown (not-yet-registered) peers are allowed through — they may register with PQC * once they install the app.+ *+ * [inviteFingerprint] is the `k=` value of the invite link this started from, if any. The+ * relay's key must hash to it, otherwise [onKeyMismatch] fires and the peer is not added. */- fun connectUser(user: User, onNeedsUpdate: () -> Unit, onDone: () -> Unit) {+ fun connectUser(+ user: User,+ inviteFingerprint: String? = null,+ onNeedsUpdate: () -> Unit,+ onKeyMismatch: () -> Unit = {},+ onDone: () -> Unit,+ ) { viewModelScope.launch(Dispatchers.IO) {- val status = Networking.peerCryptoStatus(user.id)- if (status == Networking.PeerCrypto.NEEDS_UPDATE) {- withContext(Dispatchers.Main) { onNeedsUpdate() }- } else {- repository.upsertUser(user)- LocationServiceController.syncServiceState(ctx)- withContext(Dispatchers.Main) { onDone() }+ val check = Networking.peerCryptoStatus(user.id, inviteFingerprint)+ when (check.status) {+ Networking.PeerCrypto.NEEDS_UPDATE -> withContext(Dispatchers.Main) { onNeedsUpdate() }+ Networking.PeerCrypto.KEY_MISMATCH -> withContext(Dispatchers.Main) { onKeyMismatch() }+ else -> {+ // Store the fingerprint-checked key with the row itself, so the key that was+ // verified is the one used from here on rather than a fresh relay lookup.+ repository.upsertUser(+ check.verifiedBundleB64?.let { user.copy(pqcEncryptionKey = it) } ?: user+ )+ LocationServiceController.syncServiceState(ctx)+ withContext(Dispatchers.Main) { onDone() }+ } } } }
findfamily/src/main/java/com/vayunmathur/findfamily/util/Networking.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/util/Networking.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/util/Networking.ktindex 957f1d6cd6..bb9283a209 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/util/Networking.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/util/Networking.kt@@ -605,6 +605,18 @@ object Networking { data class PqcLinkKey(val seedB64Url: String, val publicBundleB64: String) + /**+ * This device's invite fingerprint, as the unpadded base64url `k=` value of a share link.+ * Null when PQC is unavailable — the link then goes out without it and the recipient simply+ * has nothing to pre-verify against, exactly as before this parameter existed.+ */+ fun myInviteFingerprint(): String? {+ if (!pqcReady) return null+ return runCatching {+ Base64.UrlSafe.encode(Pqc.inviteFingerprint(userid, pqcIdentity.publicBundle)).trimEnd('=')+ }.onFailure { Log.w(TAG, "invite fingerprint failed", it) }.getOrNull()+ }+ /** * Generates a full PQC identity (ML-KEM + ML-DSA) for a device we own but that cannot * run keygen itself — currently only UWB trackers, whose private bundle we hold on@@ -680,19 +692,54 @@ object Networking { /** Peer is not registered, or the lookup couldn't complete (socket down/timeout). */ UNKNOWN,++ /** The relay's bundle doesn't match the fingerprint the invite link vouched for. */+ KEY_MISMATCH, } + /**+ * Outcome of the connect-time key check. [verifiedBundleB64] is set only when an invite+ * fingerprint was supplied and matched, and is meant to go straight onto the [User] row being+ * created — pinning the key that was checked, so [peerPqcBundle] prefers it and a later lookup+ * can't swap in one the fingerprint never covered.+ */+ data class PeerKeyCheck(val status: PeerCrypto, val verifiedBundleB64: String? = null)+ /** * Checks a peer's post-quantum capability "when connecting", over the socket. PQC bundle → * [PeerCrypto.PQC]; only a classic key → [PeerCrypto.NEEDS_UPDATE] (show the update dialog); * neither, or the socket is down/times out → [PeerCrypto.UNKNOWN].+ *+ * [expectedFingerprint] is the `k=` value of the invite link this connection came from, when+ * there was one. The relay's bundle has to hash to it, or the result is+ * [PeerCrypto.KEY_MISMATCH] — this is what stops the relay handing out a key it controls+ * instead of the sender's. */- suspend fun peerCryptoStatus(userId: Long): PeerCrypto {- val res = wsGetKey(userId) ?: return PeerCrypto.UNKNOWN+ suspend fun peerCryptoStatus(userId: Long, expectedFingerprint: String? = null): PeerKeyCheck {+ val res = wsGetKey(userId) ?: return PeerKeyCheck(PeerCrypto.UNKNOWN) return when (res.status) {- WS_KEY_PQC -> PeerCrypto.PQC- WS_KEY_CLASSIC -> PeerCrypto.NEEDS_UPDATE- else -> PeerCrypto.UNKNOWN+ WS_KEY_PQC -> {+ if (expectedFingerprint == null) return PeerKeyCheck(PeerCrypto.PQC)+ val bundle = res.bundle ?: return PeerKeyCheck(PeerCrypto.UNKNOWN)+ if (!fingerprintMatches(userId, bundle, expectedFingerprint)) {+ Log.w(TAG, "invite fingerprint mismatch for ${userId.toULong()}")+ return PeerKeyCheck(PeerCrypto.KEY_MISMATCH)+ }+ PeerKeyCheck(PeerCrypto.PQC, Base64.encode(bundle))+ }+ WS_KEY_CLASSIC -> PeerKeyCheck(PeerCrypto.NEEDS_UPDATE)+ else -> PeerKeyCheck(PeerCrypto.UNKNOWN) } }++ /**+ * Whether [bundle] is the one [expected] (unpadded base64url) names. A malformed or truncated+ * value fails rather than being skipped, so a mangled link is treated as unverified instead of+ * silently trusting whatever the relay returned.+ */+ private fun fingerprintMatches(userId: Long, bundle: ByteArray, expected: String): Boolean {+ val padded = if (expected.length % 4 == 0) expected else expected + "=".repeat(4 - expected.length % 4)+ val want = runCatching { Base64.UrlSafe.decode(padded) }.getOrNull() ?: return false+ return want.contentEquals(Pqc.inviteFingerprint(userId, bundle))+ } }
findfamily/src/main/res/values/strings.xml
diff --git a/findfamily/src/main/res/values/strings.xml b/findfamily/src/main/res/values/strings.xmlindex 0e6ce3f9ef..862a039f6e 100644--- a/findfamily/src/main/res/values/strings.xml+++ b/findfamily/src/main/res/values/strings.xml@@ -278,6 +278,11 @@ <!-- OutdatedPeerDialog: Body telling the user the other person must update their app before sharing can work. Sentence --> <string name="outdated_peer_body">This person is using an older version of FindFamily that doesn\'t support quantum-safe encryption. Ask them to update their app, then try connecting again.</string> + <!-- KeyMismatchDialog: Title shown when a peer's encryption key doesn't match the one their invite link vouched for. Noun phrase -->+ <string name="key_mismatch_title">Couldn\'t verify this person</string>+ <!-- KeyMismatchDialog: Body explaining the key check failed and the connection was refused. Sentence -->+ <string name="key_mismatch_body">The encryption key for this person doesn\'t match the one their invite link listed, so they weren\'t added. Check that you opened the whole link, and ask them to send a new one.</string>+ <!-- TrackingTileService: Quick Settings tile label. Short noun phrase --> <string name="tile_label">FindFamily tracking</string> <!-- TrackingTileService: tile subtitle when tracking is on. Short status -->
library/e2ee-p2p/src/main/java/com/vayunmathur/e2ee/InviteFingerprint.kt
diff --git a/library/e2ee-p2p/src/main/java/com/vayunmathur/e2ee/InviteFingerprint.kt b/library/e2ee-p2p/src/main/java/com/vayunmathur/e2ee/InviteFingerprint.ktnew file mode 100644index 0000000000..7c9aef3c0d--- /dev/null+++ b/library/e2ee-p2p/src/main/java/com/vayunmathur/e2ee/InviteFingerprint.kt@@ -0,0 +1,39 @@+package com.vayunmathur.e2ee++import java.security.MessageDigest++/**+ * Short fingerprint of a public bundle, small enough to ride along in an invite link.+ *+ * A [Pqc] bundle is ~3.1 kB (ML-KEM-768 + ML-DSA-65 SPKIs), so the key itself cannot+ * travel in a URL. An invite instead carries this truncated digest; the recipient still+ * fetches the full bundle from the relay and checks that it hashes to what the link said.+ * That removes the relay's ability to substitute a key of its own, since matching a given+ * digest means a second-preimage search over [LENGTH] bytes rather than a birthday+ * collision — 2^128 work, versus the 2^64 a same-length collision bound would give.+ *+ * The user id is hashed in so a fingerprint lifted from one invite cannot be presented as+ * some other user's, and the domain string keeps these digests from colliding with any+ * other use of SHA-256 over the same bundles.+ */+object InviteFingerprint {+ /** Truncated digest length. 16 bytes encodes to 22 unpadded base64url characters. */+ const val LENGTH = 16++ private const val DOMAIN = "ff-invite-v1"++ /** `SHA-256(DOMAIN || u64be(userId) || publicBundle)`, truncated to [LENGTH]. */+ fun compute(userId: Long, publicBundle: ByteArray): ByteArray {+ val md = MessageDigest.getInstance("SHA-256")+ md.update(DOMAIN.encodeToByteArray())+ md.update(u64be(userId))+ md.update(publicBundle)+ return md.digest().copyOf(LENGTH)+ }++ private fun u64be(v: Long): ByteArray {+ val out = ByteArray(8)+ for (i in 0 until 8) out[i] = (v ushr (56 - i * 8)).toByte()+ return out+ }+}
library/e2ee-p2p/src/main/java/com/vayunmathur/e2ee/Pqc.kt
diff --git a/library/e2ee-p2p/src/main/java/com/vayunmathur/e2ee/Pqc.kt b/library/e2ee-p2p/src/main/java/com/vayunmathur/e2ee/Pqc.ktindex 96482caa43..31c1bdd84f 100644--- a/library/e2ee-p2p/src/main/java/com/vayunmathur/e2ee/Pqc.kt+++ b/library/e2ee-p2p/src/main/java/com/vayunmathur/e2ee/Pqc.kt@@ -82,6 +82,10 @@ object Pqc { fun securityCode(myBundle: ByteArray, peerBundle: ByteArray): String = SecurityCode.compute(myBundle, peerBundle) + /** Short fingerprint of a bundle for invite links (see [InviteFingerprint]). */+ fun inviteFingerprint(userId: Long, publicBundle: ByteArray): ByteArray =+ InviteFingerprint.compute(userId, publicBundle)+ // --- helpers --- private fun lenPrefix(a: ByteArray, b: ByteArray): ByteArray {
library/e2ee-p2p/src/test/java/com/vayunmathur/e2ee/InviteFingerprintTest.kt
diff --git a/library/e2ee-p2p/src/test/java/com/vayunmathur/e2ee/InviteFingerprintTest.kt b/library/e2ee-p2p/src/test/java/com/vayunmathur/e2ee/InviteFingerprintTest.ktnew file mode 100644index 0000000000..defd8967f3--- /dev/null+++ b/library/e2ee-p2p/src/test/java/com/vayunmathur/e2ee/InviteFingerprintTest.kt@@ -0,0 +1,73 @@+package com.vayunmathur.e2ee++import kotlin.io.encoding.Base64+import kotlin.io.encoding.ExperimentalEncodingApi+import kotlin.test.Test+import kotlin.test.assertEquals+import kotlin.test.assertFalse+import kotlin.test.assertTrue++class InviteFingerprintTest {+ private val bundle = ByteArray(3184) { it.toByte() }++ @Test+ fun deterministic_and_truncated_to_length() {+ val fp = InviteFingerprint.compute(12345L, bundle)+ assertEquals(InviteFingerprint.LENGTH, fp.size)+ assertTrue(fp.contentEquals(InviteFingerprint.compute(12345L, bundle)), "same inputs, same digest")+ }++ @Test+ fun bound_to_the_user_id() {+ val fp = InviteFingerprint.compute(12345L, bundle)+ assertFalse(+ fp.contentEquals(InviteFingerprint.compute(12346L, bundle)),+ "a fingerprint must not carry over to another user's id",+ )+ }++ @Test+ fun changes_with_the_bundle() {+ val substituted = bundle.copyOf().also { it[1000] = (it[1000] + 1).toByte() }+ assertFalse(+ InviteFingerprint.compute(12345L, bundle).contentEquals(+ InviteFingerprint.compute(12345L, substituted)+ ),+ "a substituted key must not match the link's fingerprint",+ )+ }++ @Test+ fun length_delimits_the_id_from_the_bundle() {+ // Without the fixed-width id, id||bundle could be re-split: a shifted boundary+ // between the two would hash the same and let one invite's digest name another pair.+ assertFalse(+ InviteFingerprint.compute(0x0000000000000001L, byteArrayOf(2, 3)).contentEquals(+ InviteFingerprint.compute(0x0000000000000102L, byteArrayOf(3))+ )+ )+ }++ /**+ * Known-answer vectors shared with the Swift implementation (see `InviteFingerprint` in+ * Find-Family-iOS/FindFamilyiOS/Crypto/Crypto.swift). A link minted on one platform has to+ * verify on the other, and nothing else in either test suite would catch a divergence in+ * the domain string, the id width, or the truncation length.+ */+ @Test+ fun matches_the_cross_platform_test_vector() {+ assertEquals(+ "iXVzYL2J4imtjXPgh-dmtw",+ b64Url(InviteFingerprint.compute(12345L, bundle)),+ )+ // Negative ids exist in the wild (the iOS client generates them), so the id must be+ // hashed as its unsigned 64-bit bit pattern rather than sign-extended or formatted.+ assertEquals(+ "rjnCvl7blekCiZv2q9QJOA",+ b64Url(InviteFingerprint.compute(-2L, bundle)),+ )+ }++ @OptIn(ExperimentalEncodingApi::class)+ private fun b64Url(bytes: ByteArray): String = Base64.UrlSafe.encode(bytes).trimEnd('=')+}