diff --git a/engine/src/main/kotlin/io/flamenet/e2e/KeyLog.kt b/engine/src/main/kotlin/io/flamenet/e2e/KeyLog.kt index 6f92e8e..08ba927 100644 --- a/engine/src/main/kotlin/io/flamenet/e2e/KeyLog.kt +++ b/engine/src/main/kotlin/io/flamenet/e2e/KeyLog.kt @@ -40,11 +40,21 @@ object KeyLog { */ fun canonicalLeaf( kind: String, - userId: Long, + subject: String, deviceId: String, ikSigB64: String, ikDhB64: String, - ): ByteArray = "v1|$kind|$userId|$deviceId|$ikSigB64|$ikDhB64".toByteArray(Charsets.UTF_8) + ): ByteArray = "v2|$kind|$subject|$deviceId|$ikSigB64|$ikDhB64".toByteArray(Charsets.UTF_8) + + /** + * The subject a leaf names — the account's fnid where one has been + * published, and the relay-qualified row number where it has not. + * + * Shared rather than rebuilt per call site, so the three engines cannot + * drift on the fallback format. + */ + fun logSubject(fnid: String?, audience: String, userId: Long): String = + if (!fnid.isNullOrEmpty()) fnid else "local:$audience/$userId" /** * Recompute the root from a leaf and its audit path. diff --git a/engine/src/test/kotlin/io/flamenet/e2e/PublishedVectorsTest.kt b/engine/src/test/kotlin/io/flamenet/e2e/PublishedVectorsTest.kt index 2cc6de5..bb87599 100644 --- a/engine/src/test/kotlin/io/flamenet/e2e/PublishedVectorsTest.kt +++ b/engine/src/test/kotlin/io/flamenet/e2e/PublishedVectorsTest.kt @@ -91,7 +91,7 @@ class PublishedVectorsTest { val encoded = KeyLog.canonicalLeaf( kind = input.getString("kind"), - userId = input.getLong("userId"), + subject = input.getString("subject"), deviceId = input.getString("deviceId"), ikSigB64 = input.getString("ikSigB64"), ikDhB64 = input.getString("ikDhB64"),