48c0ad66ac7a

fix: rotate terminally revoked identities during re-pair (v2.17.13)

time
2026-09-09 04:05 UTC · 2 months ago
machine
koh2
agent
gpt-5
session
fix revoked peer repair
parent
f662a0748fed
3 files VERSION+1 −1app/src/main/java/com/peachpasswords/sync/PairedDeviceStore.kt+17 −1app/src/test/java/com/peachpasswords/sync/PairedDeviceRevocationTest.kt+24 −0
VERSION+1 −1
@@ -1 +1 @@1-2.17.121+2.17.13

view file

app/src/main/java/com/peachpasswords/sync/PairedDeviceStore.kt+17 −1
@@ -70,7 +70,8 @@7070             it.longTermPublicKeyHex?.let { key -> CryptoCompare.hex(key, pubkeyHex) } == true7171         }7272 73-    fun hasIdentityCollision(device: PairedDevice): Boolean = get(device.deviceId) != null73+    fun hasIdentityCollision(device: PairedDevice): Boolean =74+        hasAdoptionIdentityConflict(device, getAll(), listRevocations())7475 7576     /** Insert or replace by [PairedDevice.deviceId]. */7677     override fun upsert(device: PairedDevice) {@@ -318,6 +319,21 @@318319     val revocations: List<DeviceRevocation>,319320     val added: DeviceRevocation?,320321 )322+323+/** A fresh pairing ceremony must not reuse terminally revoked identity material. */324+internal fun hasAdoptionIdentityConflict(325+    incoming: PairedDevice,326+    devices: List<PairedDevice>,327+    revocations: List<DeviceRevocation>,328+): Boolean {329+    if (devices.any { it.deviceId == incoming.deviceId }) return true330+    return revocations.any { revoked ->331+        revoked.deviceId == incoming.deviceId ||332+            incoming.longTermPublicKeyHex?.let {333+                CryptoCompare.hex(revoked.longTermPublicKeyHex, it)334+            } == true335+    }336+}321337 322338 /**323339  * Compute one revoke transaction without Android storage so the impossible

view file

app/src/test/java/com/peachpasswords/sync/PairedDeviceRevocationTest.kt+24 −0
@@ -87,4 +87,28 @@8787         assertEquals(listOf(existing), mutation.revocations)8888         assertNull(mutation.added)8989     }90+91+    @Test92+    fun `fresh re-pair rotates a stable profile id already in the revocation ledger`() {93+        val revoked = DeviceRevocation(94+            deviceId = browser.deviceId,95+            longTermPublicKeyHex = browser.longTermPublicKeyHex!!,96+            revokedAt = 1L,97+            revokedByDeviceId = "chrome-1",98+        )99+100+        assertEquals(true, hasAdoptionIdentityConflict(browser, emptyList(), listOf(revoked)))101+    }102+103+    @Test104+    fun `fresh re-pair rotates a stable profile key revoked under an older id`() {105+        val revoked = DeviceRevocation(106+            deviceId = "old-firefox-id",107+            longTermPublicKeyHex = browser.longTermPublicKeyHex!!,108+            revokedAt = 1L,109+            revokedByDeviceId = "chrome-1",110+        )111+112+        assertEquals(true, hasAdoptionIdentityConflict(browser, emptyList(), listOf(revoked)))113+    }90114 }

view file