diff --git a/composeApp/schemas/com.machankura.bennu.compose.database.BennuDatabase/27.json b/composeApp/schemas/com.machankura.bennu.compose.database.BennuDatabase/27.json
new file mode 100644
index 00000000..ab7e8977
--- /dev/null
+++ b/composeApp/schemas/com.machankura.bennu.compose.database.BennuDatabase/27.json
@@ -0,0 +1,6185 @@
+{
+ "formatVersion": 1,
+ "database": {
+ "version": 27,
+ "identityHash": "daabaf0818bccb5c97f884214e88674b",
+ "entities": [
+ {
+ "tableName": "BroadcastNostrEventReceipt",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `nostrEventId` TEXT NOT NULL, `unsignedNostrEventId` INTEGER, `isAccepted` INTEGER NOT NULL, `isSync` INTEGER NOT NULL, `relayURL` TEXT NOT NULL, `messages` TEXT, FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`unsignedNostrEventId`) REFERENCES `UnsignedNostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "unsignedNostrEventId",
+ "columnName": "unsignedNostrEventId",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "isAccepted",
+ "columnName": "isAccepted",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isSync",
+ "columnName": "isSync",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "messages",
+ "columnName": "messages",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_BroadcastNostrEventReceipt_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_BroadcastNostrEventReceipt_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_BroadcastNostrEventReceipt_isAccepted",
+ "unique": false,
+ "columnNames": [
+ "isAccepted"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_BroadcastNostrEventReceipt_isAccepted` ON `${TABLE_NAME}` (`isAccepted`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "UnsignedNostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "unsignedNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "BroadcastNostrEventRequest",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `nostrEventId` TEXT NOT NULL, `unsignedNostrEventId` INTEGER, `status` TEXT NOT NULL, `relayURL` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`unsignedNostrEventId`) REFERENCES `UnsignedNostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "unsignedNostrEventId",
+ "columnName": "unsignedNostrEventId",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_BroadcastNostrEventRequest_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_BroadcastNostrEventRequest_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_BroadcastNostrEventRequest_status",
+ "unique": false,
+ "columnNames": [
+ "status"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_BroadcastNostrEventRequest_status` ON `${TABLE_NAME}` (`status`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "UnsignedNostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "unsignedNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "Connection",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sourcePublicKey` TEXT NOT NULL, `destinationPublicKey` TEXT NOT NULL, `nostrEventId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`sourcePublicKey`, `destinationPublicKey`), FOREIGN KEY(`sourcePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`destinationPublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sourcePublicKey",
+ "columnName": "sourcePublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "destinationPublicKey",
+ "columnName": "destinationPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "sourcePublicKey",
+ "destinationPublicKey"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "sourcePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "destinationPublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "ChatMessage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `senderPublicKey` TEXT NOT NULL, `isUserMessage` INTEGER NOT NULL, `giftWrapPayloadId` TEXT, `marmotGroupEventId` TEXT, `marmotInnerEventId` TEXT, `chatRoomId` TEXT NOT NULL, `replyToMessageId` INTEGER, `quotedMessageId` INTEGER, `content` TEXT NOT NULL, `messageType` TEXT NOT NULL, `directMessageRecipientPublicKey` TEXT, `frostSigningSessionId` TEXT, `dkgSessionId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`giftWrapPayloadId`) REFERENCES `GiftWrapPayload`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`marmotGroupEventId`) REFERENCES `MarmotGroupEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`marmotInnerEventId`) REFERENCES `MarmotInnerEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "senderPublicKey",
+ "columnName": "senderPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isUserMessage",
+ "columnName": "isUserMessage",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "giftWrapPayloadId",
+ "columnName": "giftWrapPayloadId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotInnerEventId",
+ "columnName": "marmotInnerEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "replyToMessageId",
+ "columnName": "replyToMessageId",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "quotedMessageId",
+ "columnName": "quotedMessageId",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "messageType",
+ "columnName": "messageType",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "directMessageRecipientPublicKey",
+ "columnName": "directMessageRecipientPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "frostSigningSessionId",
+ "columnName": "frostSigningSessionId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "dkgSessionId",
+ "columnName": "dkgSessionId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_ChatMessage_chatRoomId",
+ "unique": false,
+ "columnNames": [
+ "chatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_ChatMessage_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "GiftWrapPayload",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "giftWrapPayloadId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "MarmotGroupEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "marmotGroupEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "MarmotInnerEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "marmotInnerEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "ChatMessageBroadcastNostrEventRequestRelation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `chatMessageId` INTEGER NOT NULL, `broadcastNostrEventRequestId` INTEGER NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, FOREIGN KEY(`chatMessageId`) REFERENCES `ChatMessage`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`broadcastNostrEventRequestId`) REFERENCES `BroadcastNostrEventRequest`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatMessageId",
+ "columnName": "chatMessageId",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "broadcastNostrEventRequestId",
+ "columnName": "broadcastNostrEventRequestId",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "ChatMessage",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatMessageId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "BroadcastNostrEventRequest",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "broadcastNostrEventRequestId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "ChatMessageBroadcastNostrEventReceiptRelation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `chatMessageId` INTEGER NOT NULL, `broadcastNostrEventReceiptId` INTEGER NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, FOREIGN KEY(`chatMessageId`) REFERENCES `ChatMessage`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`broadcastNostrEventReceiptId`) REFERENCES `BroadcastNostrEventReceipt`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatMessageId",
+ "columnName": "chatMessageId",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "broadcastNostrEventReceiptId",
+ "columnName": "broadcastNostrEventReceiptId",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "ChatMessage",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatMessageId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "BroadcastNostrEventReceipt",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "broadcastNostrEventReceiptId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "ChatMessageNostrEventRelation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `chatMessageId` INTEGER NOT NULL, `nostrEventId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, FOREIGN KEY(`chatMessageId`) REFERENCES `ChatMessage`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatMessageId",
+ "columnName": "chatMessageId",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "ChatMessage",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatMessageId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "ChatRoom",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `subject` TEXT, `description` TEXT, `mlsGroupState` TEXT, `initialGiftWrapPayloadId` TEXT, `leftGroupAt` INTEGER, `joinedGroupAt` INTEGER, `chronicleRequestedAt` INTEGER, `parentChatRoomId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`userPublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`initialGiftWrapPayloadId`) REFERENCES `GiftWrapPayload`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userPublicKey",
+ "columnName": "userPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "subject",
+ "columnName": "subject",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "description",
+ "columnName": "description",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "mlsGroupState",
+ "columnName": "mlsGroupState",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "initialGiftWrapPayloadId",
+ "columnName": "initialGiftWrapPayloadId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "leftGroupAt",
+ "columnName": "leftGroupAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "joinedGroupAt",
+ "columnName": "joinedGroupAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "chronicleRequestedAt",
+ "columnName": "chronicleRequestedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "parentChatRoomId",
+ "columnName": "parentChatRoomId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "userPublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "GiftWrapPayload",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "initialGiftWrapPayloadId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "DkgParticipantMessage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sessionId` TEXT NOT NULL, `participantPublicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `payload` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`sessionId`, `participantPublicKey`, `kind`), FOREIGN KEY(`sessionId`) REFERENCES `DkgSession`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "sessionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participantPublicKey",
+ "columnName": "participantPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "payload",
+ "columnName": "payload",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "sessionId",
+ "participantPublicKey",
+ "kind"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_DkgParticipantMessage_sessionId",
+ "unique": false,
+ "columnNames": [
+ "sessionId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_DkgParticipantMessage_sessionId` ON `${TABLE_NAME}` (`sessionId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "DkgSession",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "sessionId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "DkgSession",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `coordinatorPublicKey` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `threshold` INTEGER NOT NULL, `participantCount` INTEGER NOT NULL, `participantPublicKeys` TEXT, `subject` TEXT, `stage` TEXT NOT NULL, `hostPublicKey` TEXT NOT NULL, `round1Random` TEXT NOT NULL, `round2AuxRandom` TEXT NOT NULL, `coordinatorRound1` TEXT, `certificate` TEXT, `thresholdPublicKey` TEXT, `secretShare` TEXT, `publicShares` TEXT, `recoveryData` TEXT, `failureReason` TEXT, `hostKeyApprovedAt` INTEGER, `round1ApprovedAt` INTEGER, `round2ApprovedAt` INTEGER, `approvalRequestedThrough` TEXT, `parentChatRoomId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "coordinatorPublicKey",
+ "columnName": "coordinatorPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userPublicKey",
+ "columnName": "userPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "threshold",
+ "columnName": "threshold",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participantCount",
+ "columnName": "participantCount",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participantPublicKeys",
+ "columnName": "participantPublicKeys",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "subject",
+ "columnName": "subject",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "stage",
+ "columnName": "stage",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "hostPublicKey",
+ "columnName": "hostPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "round1Random",
+ "columnName": "round1Random",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "round2AuxRandom",
+ "columnName": "round2AuxRandom",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "coordinatorRound1",
+ "columnName": "coordinatorRound1",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "certificate",
+ "columnName": "certificate",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "thresholdPublicKey",
+ "columnName": "thresholdPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "secretShare",
+ "columnName": "secretShare",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "publicShares",
+ "columnName": "publicShares",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "recoveryData",
+ "columnName": "recoveryData",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "failureReason",
+ "columnName": "failureReason",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "hostKeyApprovedAt",
+ "columnName": "hostKeyApprovedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "round1ApprovedAt",
+ "columnName": "round1ApprovedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "round2ApprovedAt",
+ "columnName": "round2ApprovedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "approvalRequestedThrough",
+ "columnName": "approvalRequestedThrough",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "parentChatRoomId",
+ "columnName": "parentChatRoomId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_DkgSession_chatRoomId",
+ "unique": false,
+ "columnNames": [
+ "chatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_DkgSession_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "FrostSignerMessage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sessionId` TEXT NOT NULL, `signerPublicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `payload` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`sessionId`, `signerPublicKey`, `kind`), FOREIGN KEY(`sessionId`) REFERENCES `FrostSigningSession`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "sessionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signerPublicKey",
+ "columnName": "signerPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "payload",
+ "columnName": "payload",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "sessionId",
+ "signerPublicKey",
+ "kind"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_FrostSignerMessage_sessionId",
+ "unique": false,
+ "columnNames": [
+ "sessionId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_FrostSignerMessage_sessionId` ON `${TABLE_NAME}` (`sessionId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "FrostSigningSession",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "sessionId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "FrostSigningItem",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sessionId` TEXT NOT NULL, `itemIndex` INTEGER NOT NULL, `unsignedEventJson` TEXT NOT NULL, `eventId` TEXT NOT NULL, `nonceRandom` TEXT NOT NULL, `aggregatedNonce` TEXT, `signature` TEXT, `inputIndex` INTEGER, PRIMARY KEY(`sessionId`, `itemIndex`), FOREIGN KEY(`sessionId`) REFERENCES `FrostSigningSession`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "sessionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "itemIndex",
+ "columnName": "itemIndex",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "unsignedEventJson",
+ "columnName": "unsignedEventJson",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "eventId",
+ "columnName": "eventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nonceRandom",
+ "columnName": "nonceRandom",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "aggregatedNonce",
+ "columnName": "aggregatedNonce",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "inputIndex",
+ "columnName": "inputIndex",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "sessionId",
+ "itemIndex"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_FrostSigningItem_sessionId",
+ "unique": false,
+ "columnNames": [
+ "sessionId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_FrostSigningItem_sessionId` ON `${TABLE_NAME}` (`sessionId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "FrostSigningSession",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "sessionId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "FrostSigningSession",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `coordinatorPublicKey` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `dkgSessionId` TEXT NOT NULL, `threshold` INTEGER NOT NULL, `participantCount` INTEGER NOT NULL, `signerId` INTEGER NOT NULL, `derivationPath` TEXT, `stage` TEXT NOT NULL, `signerIds` TEXT, `failureReason` TEXT, `signApprovedAt` INTEGER, `signDeclinedAt` INTEGER, `approvalRequestedAt` INTEGER, `resentAt` INTEGER, `subject` TEXT NOT NULL DEFAULT 'EVENTS', `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "coordinatorPublicKey",
+ "columnName": "coordinatorPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userPublicKey",
+ "columnName": "userPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "dkgSessionId",
+ "columnName": "dkgSessionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "threshold",
+ "columnName": "threshold",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participantCount",
+ "columnName": "participantCount",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signerId",
+ "columnName": "signerId",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "derivationPath",
+ "columnName": "derivationPath",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "stage",
+ "columnName": "stage",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signerIds",
+ "columnName": "signerIds",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "failureReason",
+ "columnName": "failureReason",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "signApprovedAt",
+ "columnName": "signApprovedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "signDeclinedAt",
+ "columnName": "signDeclinedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "approvalRequestedAt",
+ "columnName": "approvalRequestedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "resentAt",
+ "columnName": "resentAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "subject",
+ "columnName": "subject",
+ "affinity": "TEXT",
+ "notNull": true,
+ "defaultValue": "'EVENTS'"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_FrostSigningSession_chatRoomId",
+ "unique": false,
+ "columnNames": [
+ "chatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_FrostSigningSession_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
+ },
+ {
+ "name": "index_FrostSigningSession_dkgSessionId",
+ "unique": false,
+ "columnNames": [
+ "dkgSessionId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_FrostSigningSession_dkgSessionId` ON `${TABLE_NAME}` (`dkgSessionId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "GiftWrapMessage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `receiverPublicKey` TEXT NOT NULL, `receiverRelayHit` TEXT, `content` TEXT NOT NULL, `signature` TEXT NOT NULL, `nostrEventId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "receiverPublicKey",
+ "columnName": "receiverPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "receiverRelayHit",
+ "columnName": "receiverRelayHit",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "GiftWrapSeal",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `signature` TEXT NOT NULL, `giftWrapMessageId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`giftWrapMessageId`) REFERENCES `GiftWrapMessage`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tags",
+ "columnName": "tags",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "giftWrapMessageId",
+ "columnName": "giftWrapMessageId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "GiftWrapMessage",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "giftWrapMessageId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "GiftWrapPayload",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `quotedEventId` TEXT, `giftWrapSealId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`giftWrapSealId`) REFERENCES `GiftWrapSeal`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tags",
+ "columnName": "tags",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "quotedEventId",
+ "columnName": "quotedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "giftWrapSealId",
+ "columnName": "giftWrapSealId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "GiftWrapSeal",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "giftWrapSealId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "GroupKeyState",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`chatRoomId` TEXT NOT NULL, `dkgSessionId` TEXT NOT NULL, `thresholdPublicKey` TEXT NOT NULL, `derivationPath` TEXT NOT NULL, `announcedBy` TEXT NOT NULL, `announcedAt` INTEGER NOT NULL, `parentChatRoomId` TEXT, `birthCertificateJson` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`chatRoomId`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "dkgSessionId",
+ "columnName": "dkgSessionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "thresholdPublicKey",
+ "columnName": "thresholdPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "derivationPath",
+ "columnName": "derivationPath",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "announcedBy",
+ "columnName": "announcedBy",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "announcedAt",
+ "columnName": "announcedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "parentChatRoomId",
+ "columnName": "parentChatRoomId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "birthCertificateJson",
+ "columnName": "birthCertificateJson",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "chatRoomId"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_GroupKeyState_dkgSessionId",
+ "unique": false,
+ "columnNames": [
+ "dkgSessionId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_GroupKeyState_dkgSessionId` ON `${TABLE_NAME}` (`dkgSessionId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "GroupSignedEvent",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `signature` TEXT NOT NULL, `derivationPath` TEXT, `frostSigningSessionId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tags",
+ "columnName": "tags",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "derivationPath",
+ "columnName": "derivationPath",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "frostSigningSessionId",
+ "columnName": "frostSigningSessionId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_GroupSignedEvent_chatRoomId",
+ "unique": false,
+ "columnNames": [
+ "chatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_GroupSignedEvent_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
+ },
+ {
+ "name": "index_GroupSignedEvent_kind",
+ "unique": false,
+ "columnNames": [
+ "kind"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_GroupSignedEvent_kind` ON `${TABLE_NAME}` (`kind`)"
+ },
+ {
+ "name": "index_GroupSignedEvent_frostSigningSessionId",
+ "unique": false,
+ "columnNames": [
+ "frostSigningSessionId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_GroupSignedEvent_frostSigningSessionId` ON `${TABLE_NAME}` (`frostSigningSessionId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "GroupTransaction",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`frostSigningSessionId` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `chain` TEXT NOT NULL, `account` INTEGER NOT NULL, `psbt` TEXT NOT NULL, `txid` TEXT NOT NULL, `signedTransaction` TEXT, `broadcastAt` INTEGER, `seenAt` INTEGER, `confirmedAt` INTEGER, `replacedByTxid` TEXT, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`frostSigningSessionId`), FOREIGN KEY(`frostSigningSessionId`) REFERENCES `FrostSigningSession`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "frostSigningSessionId",
+ "columnName": "frostSigningSessionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chain",
+ "columnName": "chain",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "account",
+ "columnName": "account",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "psbt",
+ "columnName": "psbt",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "txid",
+ "columnName": "txid",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signedTransaction",
+ "columnName": "signedTransaction",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "broadcastAt",
+ "columnName": "broadcastAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "seenAt",
+ "columnName": "seenAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "confirmedAt",
+ "columnName": "confirmedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "replacedByTxid",
+ "columnName": "replacedByTxid",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "frostSigningSessionId"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_GroupTransaction_chatRoomId",
+ "unique": false,
+ "columnNames": [
+ "chatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_GroupTransaction_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
+ },
+ {
+ "name": "index_GroupTransaction_txid",
+ "unique": false,
+ "columnNames": [
+ "txid"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_GroupTransaction_txid` ON `${TABLE_NAME}` (`txid`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "FrostSigningSession",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "frostSigningSessionId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "IcebergKeySession",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `coordinatorPublicKey` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `threshold` INTEGER NOT NULL, `participantCount` INTEGER NOT NULL, `participantPublicKeys` TEXT NOT NULL, `onchainDkgSessionId` TEXT NOT NULL, `stage` TEXT NOT NULL, `root` TEXT, `share` TEXT, `groupPublicKey` TEXT, `publicShares` TEXT, `joinApprovedAt` INTEGER, `revealApprovedAt` INTEGER, `confirmApprovedAt` INTEGER, `approvalRequestedThrough` TEXT, `failureReason` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "coordinatorPublicKey",
+ "columnName": "coordinatorPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userPublicKey",
+ "columnName": "userPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "threshold",
+ "columnName": "threshold",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participantCount",
+ "columnName": "participantCount",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participantPublicKeys",
+ "columnName": "participantPublicKeys",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "onchainDkgSessionId",
+ "columnName": "onchainDkgSessionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stage",
+ "columnName": "stage",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "root",
+ "columnName": "root",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "share",
+ "columnName": "share",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupPublicKey",
+ "columnName": "groupPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "publicShares",
+ "columnName": "publicShares",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "joinApprovedAt",
+ "columnName": "joinApprovedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "revealApprovedAt",
+ "columnName": "revealApprovedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "confirmApprovedAt",
+ "columnName": "confirmApprovedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "approvalRequestedThrough",
+ "columnName": "approvalRequestedThrough",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "failureReason",
+ "columnName": "failureReason",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_IcebergKeySession_chatRoomId",
+ "unique": false,
+ "columnNames": [
+ "chatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_IcebergKeySession_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "IcebergParticipantMessage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sessionId` TEXT NOT NULL, `participantPublicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `payload` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`sessionId`, `participantPublicKey`, `kind`), FOREIGN KEY(`sessionId`) REFERENCES `IcebergKeySession`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "sessionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participantPublicKey",
+ "columnName": "participantPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "payload",
+ "columnName": "payload",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "sessionId",
+ "participantPublicKey",
+ "kind"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_IcebergParticipantMessage_sessionId",
+ "unique": false,
+ "columnNames": [
+ "sessionId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_IcebergParticipantMessage_sessionId` ON `${TABLE_NAME}` (`sessionId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "IcebergKeySession",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "sessionId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "InReplyToRelation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`replyingNostrEventId` TEXT NOT NULL, `inReplyToNostrEventId` TEXT NOT NULL, `inReplyToProfilePublicKey` TEXT, `inReplyToRootNostrEventId` TEXT, `inReplyToRootProfilePublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`replyingNostrEventId`, `inReplyToNostrEventId`), FOREIGN KEY(`inReplyToProfilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`inReplyToRootProfilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`replyingNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`inReplyToNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`inReplyToRootNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "replyingNostrEventId",
+ "columnName": "replyingNostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "inReplyToNostrEventId",
+ "columnName": "inReplyToNostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "inReplyToProfilePublicKey",
+ "columnName": "inReplyToProfilePublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "inReplyToRootNostrEventId",
+ "columnName": "inReplyToRootNostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "inReplyToRootProfilePublicKey",
+ "columnName": "inReplyToRootProfilePublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "replyingNostrEventId",
+ "inReplyToNostrEventId"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "inReplyToProfilePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "inReplyToRootProfilePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "replyingNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "inReplyToNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "inReplyToRootNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MantraArtifact",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `name` TEXT NOT NULL, `url` TEXT NOT NULL, `visibility` TEXT NOT NULL, `dialectId` TEXT NOT NULL, `license` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `signature` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`dialectId`) REFERENCES `MantraDialect`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "url",
+ "columnName": "url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "visibility",
+ "columnName": "visibility",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "dialectId",
+ "columnName": "dialectId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "license",
+ "columnName": "license",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupSignedEventId",
+ "columnName": "groupSignedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "MantraDialect",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "dialectId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MantraArtifactVersion",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `artifactId` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `versionLabel` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`artifactId`) REFERENCES `MantraArtifact`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "artifactId",
+ "columnName": "artifactId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "versionLabel",
+ "columnName": "versionLabel",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupSignedEventId",
+ "columnName": "groupSignedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "MantraArtifact",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "artifactId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MantraChapter",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `artifactVersionId` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `name` TEXT NOT NULL, `originalText` TEXT NOT NULL, `index` INTEGER NOT NULL, `wordCount` INTEGER NOT NULL, `characterCount` INTEGER NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`artifactVersionId`) REFERENCES `MantraArtifactVersion`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "artifactVersionId",
+ "columnName": "artifactVersionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "originalText",
+ "columnName": "originalText",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "index",
+ "columnName": "index",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "wordCount",
+ "columnName": "wordCount",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "characterCount",
+ "columnName": "characterCount",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupSignedEventId",
+ "columnName": "groupSignedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "MantraArtifactVersion",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "artifactVersionId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MantraChunk",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chapterId` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `text` TEXT NOT NULL, `index` INTEGER NOT NULL, `wordCount` INTEGER NOT NULL, `characterCount` INTEGER NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chapterId`) REFERENCES `MantraChapter`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chapterId",
+ "columnName": "chapterId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "text",
+ "columnName": "text",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "index",
+ "columnName": "index",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "wordCount",
+ "columnName": "wordCount",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "characterCount",
+ "columnName": "characterCount",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupSignedEventId",
+ "columnName": "groupSignedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "MantraChapter",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chapterId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MantraDialect",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `name` TEXT NOT NULL, `country` TEXT NOT NULL, `language` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "country",
+ "columnName": "country",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "language",
+ "columnName": "language",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupSignedEventId",
+ "columnName": "groupSignedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MantraTranslation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `translationChunkId` TEXT NOT NULL, `translationArtifactVersionId` TEXT NOT NULL, `text` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationChunkId`) REFERENCES `MantraTranslationChunk`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`translationArtifactVersionId`) REFERENCES `MantraTranslationArtifactVersion`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "translationChunkId",
+ "columnName": "translationChunkId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "translationArtifactVersionId",
+ "columnName": "translationArtifactVersionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "text",
+ "columnName": "text",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupSignedEventId",
+ "columnName": "groupSignedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "MantraTranslationChunk",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "translationChunkId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "MantraTranslationArtifactVersion",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "translationArtifactVersionId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MantraTranslationArtifactVersion",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `artifactVersionId` TEXT NOT NULL, `dialectId` TEXT NOT NULL, `name` TEXT NOT NULL, `visibility` TEXT NOT NULL, `license` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`artifactVersionId`) REFERENCES `MantraArtifactVersion`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`dialectId`) REFERENCES `MantraDialect`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "artifactVersionId",
+ "columnName": "artifactVersionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "dialectId",
+ "columnName": "dialectId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "visibility",
+ "columnName": "visibility",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "license",
+ "columnName": "license",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupSignedEventId",
+ "columnName": "groupSignedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "MantraArtifactVersion",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "artifactVersionId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "MantraDialect",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "dialectId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MantraTranslationArtifactVersionContributor",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `translationArtifactVersionId` TEXT NOT NULL, `editorPublicKey` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationArtifactVersionId`) REFERENCES `MantraTranslationArtifactVersionContributor`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "translationArtifactVersionId",
+ "columnName": "translationArtifactVersionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "editorPublicKey",
+ "columnName": "editorPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupSignedEventId",
+ "columnName": "groupSignedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "MantraTranslationArtifactVersionContributor",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "translationArtifactVersionId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MantraTranslationChapter",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chapterId` TEXT NOT NULL, `translationArtifactVersionId` TEXT NOT NULL, `index` INTEGER NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationArtifactVersionId`) REFERENCES `MantraTranslationArtifactVersion`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chapterId`) REFERENCES `MantraChapter`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chapterId",
+ "columnName": "chapterId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "translationArtifactVersionId",
+ "columnName": "translationArtifactVersionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "index",
+ "columnName": "index",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupSignedEventId",
+ "columnName": "groupSignedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "MantraTranslationArtifactVersion",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "translationArtifactVersionId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "MantraChapter",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chapterId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MantraTranslationChapterContributor",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `translationChapterId` TEXT NOT NULL, `translatorPublicKey` TEXT NOT NULL, `role` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationChapterId`) REFERENCES `MantraTranslationChapter`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "translationChapterId",
+ "columnName": "translationChapterId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "translatorPublicKey",
+ "columnName": "translatorPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "role",
+ "columnName": "role",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupSignedEventId",
+ "columnName": "groupSignedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "MantraTranslationChapter",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "translationChapterId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MantraTranslationChunk",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chunkId` TEXT NOT NULL, `translationChapterId` TEXT NOT NULL, `text` TEXT NOT NULL, `index` INTEGER NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chunkId`) REFERENCES `MantraChunk`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`translationChapterId`) REFERENCES `MantraTranslationChapter`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chunkId",
+ "columnName": "chunkId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "translationChapterId",
+ "columnName": "translationChapterId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "text",
+ "columnName": "text",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "index",
+ "columnName": "index",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupSignedEventId",
+ "columnName": "groupSignedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "MantraChunk",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chunkId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "MantraTranslationChapter",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "translationChapterId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MantraTranslationContributor",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `dTag` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `translationId` TEXT NOT NULL, `translatorPublicKey` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationId`) REFERENCES `MantraTranslation`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "dTag",
+ "columnName": "dTag",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "translationId",
+ "columnName": "translationId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "translatorPublicKey",
+ "columnName": "translatorPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupSignedEventId",
+ "columnName": "groupSignedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "MantraTranslation",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "translationId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MarmotCommitResult",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `peerKeyPackageEventId` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `isOneMemberInitialGroupCreation` INTEGER NOT NULL, `commitBytes` BLOB NOT NULL, `welcomeBytes` BLOB, `groupInfoBytes` BLOB, `framedCommitBytes` BLOB NOT NULL, `preCommitExporterSecret` BLOB NOT NULL, `obligationId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`))",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userPublicKey",
+ "columnName": "userPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "peerKeyPackageEventId",
+ "columnName": "peerKeyPackageEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isOneMemberInitialGroupCreation",
+ "columnName": "isOneMemberInitialGroupCreation",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "commitBytes",
+ "columnName": "commitBytes",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "welcomeBytes",
+ "columnName": "welcomeBytes",
+ "affinity": "BLOB"
+ },
+ {
+ "fieldPath": "groupInfoBytes",
+ "columnName": "groupInfoBytes",
+ "affinity": "BLOB"
+ },
+ {
+ "fieldPath": "framedCommitBytes",
+ "columnName": "framedCommitBytes",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "preCommitExporterSecret",
+ "columnName": "preCommitExporterSecret",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "obligationId",
+ "columnName": "obligationId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ }
+ },
+ {
+ "tableName": "MarmotGroupEvent",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `signature` TEXT NOT NULL, `encryptedContent` TEXT NOT NULL, `expiresAt` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`id`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userPublicKey",
+ "columnName": "userPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "encryptedContent",
+ "columnName": "encryptedContent",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "expiresAt",
+ "columnName": "expiresAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MarmotInnerEvent",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `quotedEventId` TEXT, `payloadEventId` TEXT, `marmotGroupEventId` TEXT, `directMessageRecipientPublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`marmotGroupEventId`) REFERENCES `MarmotGroupEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tags",
+ "columnName": "tags",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "quotedEventId",
+ "columnName": "quotedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "payloadEventId",
+ "columnName": "payloadEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "directMessageRecipientPublicKey",
+ "columnName": "directMessageRecipientPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "MarmotGroupEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "marmotGroupEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MarmotKeyPackage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `tlsEncodedMarmotKeyPackage` BLOB NOT NULL, `profile` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`publicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tlsEncodedMarmotKeyPackage",
+ "columnName": "tlsEncodedMarmotKeyPackage",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "profile",
+ "columnName": "profile",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "publicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MarmotKeyPackageBundle",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `tlsEncodedMarmotKeyPackage` BLOB NOT NULL, `ncryptsecInitPrivateKey` TEXT NOT NULL, `ncryptsecEncryptionPrivateKey` TEXT NOT NULL, `ncryptsecSignaturePrivateKey` TEXT NOT NULL, `consumed` INTEGER NOT NULL, `rotated` INTEGER NOT NULL, `profile` TEXT, `dTag` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`))",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tlsEncodedMarmotKeyPackage",
+ "columnName": "tlsEncodedMarmotKeyPackage",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "ncryptsecInitPrivateKey",
+ "columnName": "ncryptsecInitPrivateKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "ncryptsecEncryptionPrivateKey",
+ "columnName": "ncryptsecEncryptionPrivateKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "ncryptsecSignaturePrivateKey",
+ "columnName": "ncryptsecSignaturePrivateKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "consumed",
+ "columnName": "consumed",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rotated",
+ "columnName": "rotated",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "profile",
+ "columnName": "profile",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "dTag",
+ "columnName": "dTag",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_MarmotKeyPackageBundle_publicKey",
+ "unique": false,
+ "columnNames": [
+ "publicKey"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_MarmotKeyPackageBundle_publicKey` ON `${TABLE_NAME}` (`publicKey`)"
+ }
+ ]
+ },
+ {
+ "tableName": "MarmotRouting",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`routingId` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `activeFromEpoch` INTEGER NOT NULL, `retiredAtEpoch` INTEGER, PRIMARY KEY(`routingId`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "routingId",
+ "columnName": "routingId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "activeFromEpoch",
+ "columnName": "activeFromEpoch",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retiredAtEpoch",
+ "columnName": "retiredAtEpoch",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "routingId"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_MarmotRouting_chatRoomId",
+ "unique": false,
+ "columnNames": [
+ "chatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_MarmotRouting_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MarmotPublishObligation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`obligationId` TEXT NOT NULL, `bytes` BLOB NOT NULL, PRIMARY KEY(`obligationId`))",
+ "fields": [
+ {
+ "fieldPath": "obligationId",
+ "columnName": "obligationId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "bytes",
+ "columnName": "bytes",
+ "affinity": "BLOB",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "obligationId"
+ ]
+ }
+ },
+ {
+ "tableName": "MarmotOutboundGate",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`groupId` TEXT NOT NULL, `gate` TEXT NOT NULL, PRIMARY KEY(`groupId`))",
+ "fields": [
+ {
+ "fieldPath": "groupId",
+ "columnName": "groupId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "gate",
+ "columnName": "gate",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "groupId"
+ ]
+ }
+ },
+ {
+ "tableName": "MarmotRetainedEpochSecret",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`chatRoomId` TEXT NOT NULL, `epoch` INTEGER NOT NULL, `senderDataSecret` BLOB NOT NULL, `encryptionSecret` BLOB NOT NULL, `leafCount` INTEGER NOT NULL, `exporterSecret` BLOB NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`chatRoomId`, `epoch`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epoch",
+ "columnName": "epoch",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "senderDataSecret",
+ "columnName": "senderDataSecret",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "encryptionSecret",
+ "columnName": "encryptionSecret",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "leafCount",
+ "columnName": "leafCount",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "exporterSecret",
+ "columnName": "exporterSecret",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "chatRoomId",
+ "epoch"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "Mention",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `mentionedPublicKey` TEXT NOT NULL, `mentioningNostrEventId` TEXT, `relayUrl` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, FOREIGN KEY(`mentionedPublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`mentioningNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "mentionedPublicKey",
+ "columnName": "mentionedPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "mentioningNostrEventId",
+ "columnName": "mentioningNostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "relayUrl",
+ "columnName": "relayUrl",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "mentionedPublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "mentioningNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "NegentropySynchronizeRequest",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `uuid` TEXT NOT NULL, `purpose` TEXT NOT NULL, `status` TEXT NOT NULL, `relayURL` TEXT NOT NULL, `isRecommendedRelay` INTEGER NOT NULL, `level` INTEGER NOT NULL, `synchronizationFilter` TEXT NOT NULL, `ownerPublicKey` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "uuid",
+ "columnName": "uuid",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "purpose",
+ "columnName": "purpose",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isRecommendedRelay",
+ "columnName": "isRecommendedRelay",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "level",
+ "columnName": "level",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "synchronizationFilter",
+ "columnName": "synchronizationFilter",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "ownerPublicKey",
+ "columnName": "ownerPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_NegentropySynchronizeRequest_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NegentropySynchronizeRequest_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_NegentropySynchronizeRequest_status",
+ "unique": false,
+ "columnNames": [
+ "status"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NegentropySynchronizeRequest_status` ON `${TABLE_NAME}` (`status`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "NegentropySynchronizeResult",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `relayURL` TEXT NOT NULL, `status` TEXT NOT NULL, `negentropySynchronizeRequestId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`negentropySynchronizeRequestId`) REFERENCES `SynchronizeNostrEventResult`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "negentropySynchronizeRequestId",
+ "columnName": "negentropySynchronizeRequestId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "SynchronizeNostrEventResult",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "negentropySynchronizeRequestId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "NostrEvent",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `pubKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `sig` TEXT NOT NULL, `relayUrl` TEXT, `quotedNostrEventId` TEXT, `quotedAuthorPublicKey` TEXT, `inReplyToNostrEventId` TEXT, `inReplyToAuthorPublicKey` TEXT, `inReplyToRootNostrEventId` TEXT, `inReplyToRootAuthorPublicKey` TEXT, `repostedNostrEventId` TEXT, `repostedAuthorPublicKey` TEXT, `unsignedNostrEventId` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`))",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "pubKey",
+ "columnName": "pubKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tags",
+ "columnName": "tags",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "sig",
+ "columnName": "sig",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayUrl",
+ "columnName": "relayUrl",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "quotedNostrEventId",
+ "columnName": "quotedNostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "quotedAuthorPublicKey",
+ "columnName": "quotedAuthorPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "inReplyToNostrEventId",
+ "columnName": "inReplyToNostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "inReplyToAuthorPublicKey",
+ "columnName": "inReplyToAuthorPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "inReplyToRootNostrEventId",
+ "columnName": "inReplyToRootNostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "inReplyToRootAuthorPublicKey",
+ "columnName": "inReplyToRootAuthorPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "repostedNostrEventId",
+ "columnName": "repostedNostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "repostedAuthorPublicKey",
+ "columnName": "repostedAuthorPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "unsignedNostrEventId",
+ "columnName": "unsignedNostrEventId",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_NostrEvent_kind",
+ "unique": false,
+ "columnNames": [
+ "kind"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NostrEvent_kind` ON `${TABLE_NAME}` (`kind`)"
+ },
+ {
+ "name": "index_NostrEvent_pubKey",
+ "unique": false,
+ "columnNames": [
+ "pubKey"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NostrEvent_pubKey` ON `${TABLE_NAME}` (`pubKey`)"
+ },
+ {
+ "name": "index_NostrEvent_quotedNostrEventId",
+ "unique": false,
+ "columnNames": [
+ "quotedNostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NostrEvent_quotedNostrEventId` ON `${TABLE_NAME}` (`quotedNostrEventId`)"
+ },
+ {
+ "name": "index_NostrEvent_inReplyToNostrEventId",
+ "unique": false,
+ "columnNames": [
+ "inReplyToNostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NostrEvent_inReplyToNostrEventId` ON `${TABLE_NAME}` (`inReplyToNostrEventId`)"
+ },
+ {
+ "name": "index_NostrEvent_inReplyToRootNostrEventId",
+ "unique": false,
+ "columnNames": [
+ "inReplyToRootNostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NostrEvent_inReplyToRootNostrEventId` ON `${TABLE_NAME}` (`inReplyToRootNostrEventId`)"
+ }
+ ]
+ },
+ {
+ "tableName": "NostrEventRelay",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`relayURL` TEXT NOT NULL, `nostrEventId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`nostrEventId`, `relayURL`), FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "nostrEventId",
+ "relayURL"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_NostrEventRelay_relayURL",
+ "unique": false,
+ "columnNames": [
+ "relayURL"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NostrEventRelay_relayURL` ON `${TABLE_NAME}` (`relayURL`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "Participant",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `participantPublicKey` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `adminAt` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, FOREIGN KEY(`participantPublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participantPublicKey",
+ "columnName": "participantPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "adminAt",
+ "columnName": "adminAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "participantPublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "Post",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `repostId` TEXT, `quote` TEXT, `content` TEXT NOT NULL, `nostrEventId` TEXT NOT NULL, `replyToId` TEXT, `profilePublicKey` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`profilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`replyToId`) REFERENCES `Post`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`repostId`) REFERENCES `Post`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "repostId",
+ "columnName": "repostId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "quote",
+ "columnName": "quote",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "replyToId",
+ "columnName": "replyToId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "profilePublicKey",
+ "columnName": "profilePublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_Post_profilePublicKey",
+ "unique": false,
+ "columnNames": [
+ "profilePublicKey"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Post_profilePublicKey` ON `${TABLE_NAME}` (`profilePublicKey`)"
+ },
+ {
+ "name": "index_Post_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Post_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_Post_replyToId",
+ "unique": false,
+ "columnNames": [
+ "replyToId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Post_replyToId` ON `${TABLE_NAME}` (`replyToId`)"
+ },
+ {
+ "name": "index_Post_repostId",
+ "unique": false,
+ "columnNames": [
+ "repostId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Post_repostId` ON `${TABLE_NAME}` (`repostId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "profilePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "Post",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "replyToId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "Post",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "repostId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "Profile",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`publicKey` TEXT NOT NULL, `userName` TEXT, `displayName` TEXT, `picture` TEXT, `banner` TEXT, `website` TEXT, `about` TEXT, `bot` INTEGER, `pronouns` TEXT, `nip05` TEXT, `domain` TEXT, `lud06` TEXT, `lud16` TEXT, `twitter` TEXT, `nostrEventId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`publicKey`), FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userName",
+ "columnName": "userName",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "displayName",
+ "columnName": "displayName",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "picture",
+ "columnName": "picture",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "banner",
+ "columnName": "banner",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "website",
+ "columnName": "website",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "about",
+ "columnName": "about",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "bot",
+ "columnName": "bot",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "pronouns",
+ "columnName": "pronouns",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nip05",
+ "columnName": "nip05",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "domain",
+ "columnName": "domain",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lud06",
+ "columnName": "lud06",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lud16",
+ "columnName": "lud16",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "twitter",
+ "columnName": "twitter",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "publicKey"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_Profile_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Profile_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "QuotedRelation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`quotingNostrEventId` TEXT NOT NULL, `quotedNostrEventId` TEXT NOT NULL, `quotedProfilePublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`quotingNostrEventId`, `quotedNostrEventId`), FOREIGN KEY(`quotedProfilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`quotingNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`quotedNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "quotingNostrEventId",
+ "columnName": "quotingNostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "quotedNostrEventId",
+ "columnName": "quotedNostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "quotedProfilePublicKey",
+ "columnName": "quotedProfilePublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "quotingNostrEventId",
+ "quotedNostrEventId"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "quotedProfilePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "quotingNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "quotedNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "Reaction",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `content` TEXT NOT NULL, `nostrEventId` TEXT NOT NULL, `replyToId` TEXT NOT NULL, `profilePublicKey` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`profilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`replyToId`) REFERENCES `Post`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "replyToId",
+ "columnName": "replyToId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "profilePublicKey",
+ "columnName": "profilePublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_Reaction_profilePublicKey",
+ "unique": false,
+ "columnNames": [
+ "profilePublicKey"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Reaction_profilePublicKey` ON `${TABLE_NAME}` (`profilePublicKey`)"
+ },
+ {
+ "name": "index_Reaction_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Reaction_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_Reaction_replyToId",
+ "unique": false,
+ "columnNames": [
+ "replyToId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Reaction_replyToId` ON `${TABLE_NAME}` (`replyToId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "profilePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "Post",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "replyToId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "RecentSearch",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`query` TEXT NOT NULL, `synchronizationFilters` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`query`))",
+ "fields": [
+ {
+ "fieldPath": "query",
+ "columnName": "query",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "synchronizationFilters",
+ "columnName": "synchronizationFilters",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "query"
+ ]
+ }
+ },
+ {
+ "tableName": "Relay",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`publicKey` TEXT NOT NULL, `type` TEXT NOT NULL, `url` TEXT NOT NULL, `read` INTEGER NOT NULL, `write` INTEGER NOT NULL, PRIMARY KEY(`publicKey`, `type`, `url`))",
+ "fields": [
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "type",
+ "columnName": "type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "url",
+ "columnName": "url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "read",
+ "columnName": "read",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "write",
+ "columnName": "write",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "publicKey",
+ "type",
+ "url"
+ ]
+ }
+ },
+ {
+ "tableName": "RepostedRelation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`repostingNostrEventId` TEXT NOT NULL, `repostedNostrEventId` TEXT NOT NULL, `repostedProfilePublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`repostingNostrEventId`, `repostedNostrEventId`), FOREIGN KEY(`repostedProfilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`repostedNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`repostingNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "repostingNostrEventId",
+ "columnName": "repostingNostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "repostedNostrEventId",
+ "columnName": "repostedNostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "repostedProfilePublicKey",
+ "columnName": "repostedProfilePublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "repostingNostrEventId",
+ "repostedNostrEventId"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "repostedProfilePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "repostedNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "repostingNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "SynchronizeNostrEventRequest",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `purpose` TEXT NOT NULL, `status` TEXT NOT NULL, `relayURL` TEXT NOT NULL, `isRecommendedRelay` INTEGER NOT NULL, `level` INTEGER NOT NULL, `synchronizationFilters` TEXT NOT NULL, `ownerPublicKey` TEXT, `nostrEventId` TEXT, `unsignedNostrEventId` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`unsignedNostrEventId`) REFERENCES `UnsignedNostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "purpose",
+ "columnName": "purpose",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isRecommendedRelay",
+ "columnName": "isRecommendedRelay",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "level",
+ "columnName": "level",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "synchronizationFilters",
+ "columnName": "synchronizationFilters",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "ownerPublicKey",
+ "columnName": "ownerPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "unsignedNostrEventId",
+ "columnName": "unsignedNostrEventId",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_SynchronizeNostrEventRequest_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_SynchronizeNostrEventRequest_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_SynchronizeNostrEventRequest_status",
+ "unique": false,
+ "columnNames": [
+ "status"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_SynchronizeNostrEventRequest_status` ON `${TABLE_NAME}` (`status`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "UnsignedNostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "unsignedNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "SynchronizeNostrEventResult",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `relayURL` TEXT NOT NULL, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_SynchronizeNostrEventResult_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_SynchronizeNostrEventResult_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "UnsignedNostrEvent",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `pubKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `privateTags` TEXT, `content` TEXT NOT NULL, `signedAt` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "pubKey",
+ "columnName": "pubKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tags",
+ "columnName": "tags",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "privateTags",
+ "columnName": "privateTags",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signedAt",
+ "columnName": "signedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_UnsignedNostrEvent_pubKey",
+ "unique": false,
+ "columnNames": [
+ "pubKey"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_UnsignedNostrEvent_pubKey` ON `${TABLE_NAME}` (`pubKey`)"
+ },
+ {
+ "name": "index_UnsignedNostrEvent_kind",
+ "unique": false,
+ "columnNames": [
+ "kind"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_UnsignedNostrEvent_kind` ON `${TABLE_NAME}` (`kind`)"
+ }
+ ]
+ },
+ {
+ "tableName": "Zap",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `postId` TEXT NOT NULL, `senderPublicKey` TEXT NOT NULL, `receiverPublicKey` TEXT NOT NULL, `message` TEXT, `invoice` TEXT, `amountInMillisatoshis` INTEGER, `nostrEventId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`senderPublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`receiverPublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`postId`) REFERENCES `Post`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "postId",
+ "columnName": "postId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "senderPublicKey",
+ "columnName": "senderPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "receiverPublicKey",
+ "columnName": "receiverPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "message",
+ "columnName": "message",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "invoice",
+ "columnName": "invoice",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "amountInMillisatoshis",
+ "columnName": "amountInMillisatoshis",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_Zap_senderPublicKey",
+ "unique": false,
+ "columnNames": [
+ "senderPublicKey"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Zap_senderPublicKey` ON `${TABLE_NAME}` (`senderPublicKey`)"
+ },
+ {
+ "name": "index_Zap_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Zap_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_Zap_postId",
+ "unique": false,
+ "columnNames": [
+ "postId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Zap_postId` ON `${TABLE_NAME}` (`postId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "senderPublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "receiverPublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "Post",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "postId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ }
+ ],
+ "setupQueries": [
+ "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
+ "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'daabaf0818bccb5c97f884214e88674b')"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/composeResources/values/strings.xml b/composeApp/src/commonMain/composeResources/values/strings.xml
index 4128301c..c61c6419 100644
--- a/composeApp/src/commonMain/composeResources/values/strings.xml
+++ b/composeApp/src/commonMain/composeResources/values/strings.xml
@@ -687,4 +687,26 @@
Sent again
Couldn't bump the fee: there isn't enough left over to pay it.
While the wallet is new, a spend on mainnet can send at most %1$s sats.
+ Lightning wallet key
+ This group has no key for a Lightning wallet yet.
+ A Lightning wallet closes to the group's onchain wallet. Open one on %1$s first.
+ A Lightning wallet needs at least four members who hold the onchain wallet's key.
+ The key is made by everyone who holds the onchain wallet's key. Every payment will need %1$s of their devices online.
+ Start a key ceremony
+ Signers needed: %1$s of %2$s
+ Waiting for everyone to join
+ Waiting for everyone's contributions
+ Waiting for everyone to confirm
+ The group has a key for a Lightning wallet.
+ Abandoned: %1$s
+ Join the ceremony
+ Send your contributions
+ Confirm what you saw
+ Joining publishes commitments to your contributions. Nothing secret leaves this device.
+ Each contribution is encrypted to the members who will hold it. Your randomness starts shaping the key here.
+ Confirming publishes your public share and a hash of every commitment you saw, so the group can check it agrees.
+ %1$s of 3 steps
+ Couldn't start the key ceremony.
+ Couldn't approve this step.
+ Your share of this key is stored unencrypted on this device, as the onchain wallet's is.
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/BennuDatabase.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/BennuDatabase.kt
index 812bc2ff..957c324f 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/BennuDatabase.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/BennuDatabase.kt
@@ -1,5 +1,8 @@
package com.machankura.bennu.compose.database
+import com.machankura.bennu.compose.database.dao.IcebergKeySessionDao
+import com.machankura.bennu.compose.database.model.IcebergParticipantMessage
+import com.machankura.bennu.compose.database.model.IcebergKeySession
import com.machankura.bennu.compose.database.model.GroupTransaction
import com.machankura.bennu.compose.database.dao.GroupTransactionDao
import androidx.room3.ColumnTypeConverters
@@ -150,6 +153,8 @@ val GENESIS_AT = Instant.fromEpochMilliseconds(1231006505000L)
GroupKeyState::class,
GroupSignedEvent::class,
GroupTransaction::class,
+ IcebergKeySession::class,
+ IcebergParticipantMessage::class,
InReplyToRelation::class,
MantraArtifact::class,
MantraArtifactVersion::class,
@@ -190,7 +195,7 @@ val GENESIS_AT = Instant.fromEpochMilliseconds(1231006505000L)
UnsignedNostrEvent::class,
Zap::class
],
- version = 26,
+ version = 27,
autoMigrations = [
// v2 only adds the DkgSession/DkgParticipantMessage tables, so Room can
// generate the migration itself — nothing existing changes shape.
@@ -378,6 +383,10 @@ val GENESIS_AT = Instant.fromEpochMilliseconds(1231006505000L)
// nothing is rebuilt; a rebuild of either signing table would fire the
// cascades from FrostSigningSession, see docs/frost-batch-signing.md.
AutoMigration(from = 25, to = 26),
+ // v27 is the group Lightning wallet's key ceremony (docs/group-lightning-wallet.md,
+ // Phase 5): the IcebergKeySession and IcebergParticipantMessage tables. Two new
+ // tables and nothing else, which Room migrates itself.
+ AutoMigration(from = 26, to = 27),
]
)
@ConstructedBy(BennuDatabaseConstructor::class)
@@ -450,6 +459,8 @@ abstract class BennuDatabase: RoomDatabase() {
abstract fun mantraTranslationContributorDao(): MantraTranslationContributorDao
+ abstract fun icebergKeySessionDao(): IcebergKeySessionDao
+
abstract fun marmotCommitResultDao(): MarmotCommitResultDao
abstract fun marmotGroupEventDao(): MarmotGroupEventDao
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/IcebergKeySessionDao.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/IcebergKeySessionDao.kt
new file mode 100644
index 00000000..825d9539
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/IcebergKeySessionDao.kt
@@ -0,0 +1,39 @@
+package com.machankura.bennu.compose.database.dao
+
+import androidx.room3.Dao
+import androidx.room3.Query
+import androidx.room3.Upsert
+import com.machankura.bennu.compose.database.model.IcebergKeySession
+import com.machankura.bennu.compose.database.model.IcebergParticipantMessage
+import com.vitorpamplona.quartz.nip01Core.core.HexKey
+import kotlinx.coroutines.flow.Flow
+
+@Dao
+interface IcebergKeySessionDao {
+ @Query("SELECT * FROM IcebergKeySession WHERE id = :sessionId")
+ suspend fun getSessionById(sessionId: String): IcebergKeySession?
+
+ @Query("SELECT * FROM IcebergKeySession WHERE id = :sessionId")
+ fun observeSessionById(sessionId: String): Flow
+
+ @Query("SELECT * FROM IcebergKeySession WHERE chatRoomId = :chatRoomId ORDER BY createdAt DESC")
+ suspend fun getSessionsForChatRoom(chatRoomId: String): List
+
+ @Query("SELECT * FROM IcebergKeySession WHERE chatRoomId = :chatRoomId ORDER BY createdAt DESC")
+ fun observeSessionsForChatRoom(chatRoomId: String): Flow>
+
+ @Upsert
+ suspend fun upsert(session: IcebergKeySession)
+
+ @Upsert
+ suspend fun upsert(message: IcebergParticipantMessage)
+
+ @Query("SELECT * FROM IcebergParticipantMessage WHERE sessionId = :sessionId AND kind = :kind")
+ suspend fun getMessagesByKind(sessionId: String, kind: Int): List
+
+ @Query("SELECT * FROM IcebergParticipantMessage WHERE sessionId = :sessionId AND kind = :kind AND participantPublicKey = :participantPublicKey")
+ suspend fun getMessage(sessionId: String, kind: Int, participantPublicKey: HexKey): IcebergParticipantMessage?
+
+ @Query("SELECT COUNT(*) FROM IcebergParticipantMessage WHERE sessionId = :sessionId AND kind = :kind")
+ suspend fun countMessagesByKind(sessionId: String, kind: Int): Int
+}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/NostrDao.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/NostrDao.kt
index ac1381d7..e32eafcb 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/NostrDao.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/NostrDao.kt
@@ -1,5 +1,7 @@
package com.machankura.bennu.compose.database.dao
+import com.machankura.bennu.compose.nostr.lightning.GroupLightningEvents
+import com.machankura.bennu.compose.managers.IcebergRitualManager
import androidx.room3.Dao
import androidx.room3.Transaction
import com.machankura.bennu.compose.database.GENESIS_AT
@@ -1593,6 +1595,17 @@ abstract class NostrDao(
userPublicKey = activeKeyPair.pubKey.toHex(),
nostrPrivateKey = activeKeyPair.privKey!!
)
+
+ // The group Lightning wallet's key ceremony. Marmot only:
+ // it runs where the onchain wallet it closes to already is.
+ innerEvent.kind in GroupLightningEvents.CEREMONY ->
+ IcebergRitualManager.processCeremonyPayload(
+ database = database,
+ localChatRoom = localChatRoom,
+ innerEvent = innerEvent,
+ userPublicKey = activeKeyPair.pubKey.toHex(),
+ nostrPrivateKey = activeKeyPair.privKey!!
+ )
}
}
}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/ChatMessage.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/ChatMessage.kt
index dcfc8dac..816bd5b2 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/ChatMessage.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/ChatMessage.kt
@@ -265,6 +265,48 @@ data class ChatMessage(
* A finished ceremony is the exception, and has no actor: the group ends up
* with a key, nobody hands it to them.
*/
+ /**
+ * An Iceberg key ceremony -- the group Lightning wallet's key -- as lines in the group's
+ * chat. The same shape as the ChillDKG ceremony's, and kept apart from [DKG_TYPES] because a
+ * line has to open the ceremony it is about, and the two ceremonies have different screens.
+ * [dkgSessionId] carries the Iceberg session's id on these lines.
+ */
+ const val TYPE_ICEBERG_STARTED = "icebergStarted"
+ const val TYPE_ICEBERG_COMMITTED = "icebergCommitted"
+ const val TYPE_ICEBERG_REVEALED = "icebergRevealed"
+ const val TYPE_ICEBERG_CONFIRMED = "icebergConfirmed"
+ const val TYPE_ICEBERG_COMPLETE = "icebergComplete"
+ const val TYPE_ICEBERG_FAILED = "icebergFailed"
+ const val TYPE_ICEBERG_APPROVAL_NEEDED_JOIN = "icebergApprovalNeededJoin"
+ const val TYPE_ICEBERG_APPROVAL_NEEDED_REVEAL = "icebergApprovalNeededReveal"
+ const val TYPE_ICEBERG_APPROVAL_NEEDED_CONFIRM = "icebergApprovalNeededConfirm"
+
+ val ICEBERG_REQUEST_FULFILMENTS = mapOf(
+ TYPE_ICEBERG_APPROVAL_NEEDED_JOIN to TYPE_ICEBERG_COMMITTED,
+ TYPE_ICEBERG_APPROVAL_NEEDED_REVEAL to TYPE_ICEBERG_REVEALED,
+ TYPE_ICEBERG_APPROVAL_NEEDED_CONFIRM to TYPE_ICEBERG_CONFIRMED,
+ )
+
+ val ICEBERG_REQUEST_TYPES = ICEBERG_REQUEST_FULFILMENTS.keys
+
+ val ICEBERG_TYPES = setOf(
+ TYPE_ICEBERG_STARTED,
+ TYPE_ICEBERG_COMMITTED,
+ TYPE_ICEBERG_REVEALED,
+ TYPE_ICEBERG_CONFIRMED,
+ TYPE_ICEBERG_COMPLETE,
+ TYPE_ICEBERG_FAILED,
+ ) + ICEBERG_REQUEST_TYPES
+
+ /** As [DKG_AUTHORED_TYPES]: content written to follow the actor's name. A finished key has no actor. */
+ val ICEBERG_AUTHORED_TYPES = setOf(
+ TYPE_ICEBERG_STARTED,
+ TYPE_ICEBERG_COMMITTED,
+ TYPE_ICEBERG_REVEALED,
+ TYPE_ICEBERG_CONFIRMED,
+ TYPE_ICEBERG_FAILED,
+ )
+
/**
* A FROST signing session, as lines in the group's chat.
*
@@ -670,7 +712,7 @@ data class ChatMessage(
*/
fun answeredRequests(messages: List): Set = messages
.mapNotNull { request ->
- val published = (DKG_REQUEST_FULFILMENTS + FROST_REQUEST_FULFILMENTS)[request.messageType]
+ val published = (DKG_REQUEST_FULFILMENTS + FROST_REQUEST_FULFILMENTS + ICEBERG_REQUEST_FULFILMENTS)[request.messageType]
?: return@mapNotNull null
val done = messages.any {
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/IcebergKeySession.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/IcebergKeySession.kt
new file mode 100644
index 00000000..6d7a71ca
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/IcebergKeySession.kt
@@ -0,0 +1,107 @@
+package com.machankura.bennu.compose.database.model
+
+import androidx.room3.Entity
+import androidx.room3.ForeignKey
+import androidx.room3.Index
+import androidx.room3.PrimaryKey
+import com.machankura.bennu.compose.database.model.types.IcebergApprovalStep
+import com.machankura.bennu.compose.database.model.types.IcebergRitualStage
+import com.vitorpamplona.quartz.nip01Core.core.HexKey
+import kotlin.time.Clock
+import kotlin.time.Instant
+
+/**
+ * One Iceberg key ceremony, as this device took part in it: the key a group's Lightning wallet signs
+ * its channels with (`docs/group-lightning-wallet.md`, Phase 5).
+ *
+ * Like [DkgSession] it stores the ceremony's *inputs* -- the random root this device's contributions
+ * come from, and every message received in [IcebergParticipantMessage] -- rather than its state, so
+ * every step can be recomputed after a restart.
+ *
+ * [share] is the member's Iceberg share, plaintext, which is the same decision the onchain wallet
+ * made for ChillDKG shares (`docs/group-chain-wallet.md`, Phase 0) and the same cost: a stolen phone
+ * plus `t - 1` colluders signs.
+ */
+@Entity(
+ foreignKeys = [
+ ForeignKey(
+ entity = ChatRoom::class,
+ parentColumns = ["id"],
+ childColumns = ["chatRoomId"],
+ onDelete = ForeignKey.CASCADE,
+ )
+ ],
+ indices = [Index("chatRoomId")],
+)
+data class IcebergKeySession(
+ /** Minted by whoever proposed the ceremony, carried on every message as `iceberg_session`. */
+ @PrimaryKey
+ val id: String,
+ val chatRoomId: String,
+ val coordinatorPublicKey: HexKey,
+ /** Whose device this row belongs to. */
+ val userPublicKey: HexKey,
+ val threshold: Int,
+ val participantCount: Int,
+ /** The participants' nostr keys, sorted, comma-separated: the set and its order. */
+ val participantPublicKeys: String,
+ /**
+ * The ChillDKG ceremony whose key the onchain wallet is, and whose participants these are
+ * (decision D1): a Lightning wallet signed by different people from the wallet it closes to would
+ * answer to a different quorum.
+ */
+ val onchainDkgSessionId: String,
+ val stage: IcebergRitualStage = IcebergRitualStage.COLLECTING_COMMITMENTS,
+ /** 32 random bytes, hex, that this device's contributions are derived from. Dropped once [share] exists. */
+ val root: HexKey? = null,
+ /** The serialised Iceberg share, hex. Secret. */
+ val share: HexKey? = null,
+ /** The group's Iceberg public key, compressed hex, once the ceremony completes. */
+ val groupPublicKey: HexKey? = null,
+ /** Every participant's public share, in participant order, comma-separated hex. */
+ val publicShares: String? = null,
+ val joinApprovedAt: Instant? = null,
+ val revealApprovedAt: Instant? = null,
+ val confirmApprovedAt: Instant? = null,
+ /** The furthest step this device has asked its owner about, so each request is written once. */
+ val approvalRequestedThrough: IcebergApprovalStep? = null,
+ val failureReason: String? = null,
+ val createdAt: Instant = Clock.System.now(),
+ val updatedAt: Instant = createdAt,
+) {
+ fun participants(): List = participantPublicKeys.split(",").map { it.trim() }.filter { it.isNotEmpty() }
+
+ fun isCoordinator(): Boolean = coordinatorPublicKey == userPublicKey
+
+ fun publicShareList(): List? = publicShares?.split(",")?.map { it.trim() }?.filter { it.isNotEmpty() }
+
+ override fun toString(): String = "IcebergKeySession(id=$id, chatRoomId=$chatRoomId, $threshold-of-$participantCount, stage=$stage)"
+
+ companion object {
+ fun formatParticipants(publicKeys: Collection): String = publicKeys.map { it.lowercase() }.distinct().sorted().joinToString(",")
+ }
+}
+
+/** One protocol message of an Iceberg ceremony, as received or sent, keyed so a redelivery is absorbed. */
+@Entity(
+ primaryKeys = ["sessionId", "participantPublicKey", "kind"],
+ foreignKeys = [
+ ForeignKey(
+ entity = IcebergKeySession::class,
+ parentColumns = ["id"],
+ childColumns = ["sessionId"],
+ onDelete = ForeignKey.CASCADE,
+ )
+ ],
+ indices = [Index("sessionId")],
+)
+data class IcebergParticipantMessage(
+ val sessionId: String,
+ /** The sender's nostr key, as the MLS frame vouched for it. */
+ val participantPublicKey: HexKey,
+ /** One of `GroupLightningEvents.CEREMONY`. */
+ val kind: Int,
+ /** The message's content, as received: JSON for every round. */
+ val payload: String,
+ val createdAt: Instant = Clock.System.now(),
+)
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/intermdiate/LocalChatRoom.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/intermdiate/LocalChatRoom.kt
index 4fc0a0fb..93e542f1 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/intermdiate/LocalChatRoom.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/intermdiate/LocalChatRoom.kt
@@ -139,6 +139,7 @@ data class LocalChatRoom(
val lastChatMessage = lastChatMessage ?: return null
if (lastChatMessage.messageType in ChatMessage.DKG_TYPES ||
+ lastChatMessage.messageType in ChatMessage.ICEBERG_TYPES ||
lastChatMessage.messageType in ChatMessage.FROST_TYPES ||
lastChatMessage.messageType in ChatMessage.CHRONICLE_TYPES ||
lastChatMessage.messageType in ChatMessage.MEMBERSHIP_TYPES ||
@@ -146,6 +147,7 @@ data class LocalChatRoom(
lastChatMessage.messageType in ChatMessage.GROUP_IDENTITY_TYPES
) {
val isAuthored = lastChatMessage.messageType in ChatMessage.DKG_AUTHORED_TYPES ||
+ lastChatMessage.messageType in ChatMessage.ICEBERG_AUTHORED_TYPES ||
lastChatMessage.messageType in ChatMessage.FROST_AUTHORED_TYPES
return if (isAuthored) {
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/types/IcebergApprovalStep.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/types/IcebergApprovalStep.kt
new file mode 100644
index 00000000..d66f3dff
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/types/IcebergApprovalStep.kt
@@ -0,0 +1,26 @@
+package com.machankura.bennu.compose.database.model.types
+
+/**
+ * The three things an Iceberg ceremony asks a member before their device publishes anything of
+ * theirs, in order. The same three gates the ChillDKG ceremony has, for the same reasons.
+ */
+enum class IcebergApprovalStep {
+ /**
+ * Publish this device's commitments, which puts its owner in the ceremony. Joining then going
+ * quiet holds the ceremony open for everybody, since every seed needs all of its holders.
+ */
+ JOIN,
+
+ /**
+ * Send this device's contributions to the seeds it holds, each encrypted to the other holders.
+ * From here the member's own randomness is shaping a key they will help sign with.
+ */
+ REVEAL,
+
+ /**
+ * Publish this device's public share and the hash of the transcript it saw. A real check: two
+ * members shown different commitments sign different transcripts, and the ceremony refuses to
+ * finish on transcripts that disagree.
+ */
+ CONFIRM,
+}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/types/IcebergRitualStage.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/types/IcebergRitualStage.kt
new file mode 100644
index 00000000..67d4ebed
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/types/IcebergRitualStage.kt
@@ -0,0 +1,17 @@
+package com.machankura.bennu.compose.database.model.types
+
+/**
+ * Where an Iceberg key ceremony has got to, for the screen. Declared in the order the ceremony runs,
+ * so a label moves forward and never back; the ritual itself decides what to do from what it has
+ * stored, as the ChillDKG one does, and never from this.
+ */
+enum class IcebergRitualStage {
+ /** Waiting on every participant's commitments. */
+ COLLECTING_COMMITMENTS,
+ /** Waiting on every contribution addressed to this device. */
+ COLLECTING_REVEALS,
+ /** Waiting on every participant's public share and transcript. */
+ COLLECTING_CONFIRMATIONS,
+ COMPLETE,
+ FAILED,
+}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/repository/DatabaseGroupLightningRepository.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/repository/DatabaseGroupLightningRepository.kt
new file mode 100644
index 00000000..469de69c
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/repository/DatabaseGroupLightningRepository.kt
@@ -0,0 +1,44 @@
+package com.machankura.bennu.compose.database.repository
+
+import com.machankura.bennu.compose.database.BennuDatabase
+import com.machankura.bennu.compose.database.model.IcebergKeySession
+import com.machankura.bennu.compose.database.model.IcebergParticipantMessage
+import com.machankura.bennu.compose.database.model.intermdiate.LocalChatRoom
+import com.machankura.bennu.compose.database.model.types.IcebergApprovalStep
+import com.machankura.bennu.compose.managers.FrostSigningManager
+import com.machankura.bennu.compose.managers.GroupWalletManager
+import com.machankura.bennu.compose.managers.IcebergRitualManager
+import com.machankura.bennu.compose.nostr.lightning.GroupLightningEvents
+import com.machankura.bennu.compose.repository.GroupLightningRepository
+import com.vitorpamplona.quartz.nip01Core.core.HexKey
+import fr.acinq.bitcoin.Chain
+import kotlinx.coroutines.flow.Flow
+
+class DatabaseGroupLightningRepository(private val database: BennuDatabase) : GroupLightningRepository {
+ override fun observeCeremony(sessionId: String): Flow =
+ database.icebergKeySessionDao().observeSessionById(sessionId)
+
+ override fun observeCeremonies(chatRoomId: String): Flow> =
+ database.icebergKeySessionDao().observeSessionsForChatRoom(chatRoomId)
+
+ override suspend fun ceremonyMessages(sessionId: String): List =
+ GroupLightningEvents.CEREMONY.flatMap { database.icebergKeySessionDao().getMessagesByKind(sessionId, it) }
+
+ override suspend fun pendingApproval(session: IcebergKeySession): IcebergApprovalStep? =
+ IcebergRitualManager.pendingApproval(database, session)
+
+ override suspend fun ceremonyThresholds(chatRoomId: String): List =
+ FrostSigningManager.completedKey(database, chatRoomId)?.let(IcebergRitualManager::thresholdsFor).orEmpty()
+
+ override suspend fun keyHolderCount(chatRoomId: String): Int =
+ FrostSigningManager.completedKey(database, chatRoomId)?.participantPublicKeySet()?.size ?: 0
+
+ override suspend fun hasOnchainWallet(chatRoomId: String, chain: Chain): Boolean =
+ GroupWalletManager.walletFor(database, chatRoomId, chain) != null
+
+ override suspend fun proposeCeremony(localChatRoom: LocalChatRoom, userPublicKey: HexKey, nostrPrivateKey: ByteArray, threshold: Int, chain: Chain): IcebergKeySession =
+ IcebergRitualManager.proposeCeremony(database, localChatRoom, userPublicKey, nostrPrivateKey, threshold, chain)
+
+ override suspend fun approveCeremony(localChatRoom: LocalChatRoom, sessionId: String, step: IcebergApprovalStep, nostrPrivateKey: ByteArray) =
+ IcebergRitualManager.approve(database, localChatRoom, sessionId, step, nostrPrivateKey)
+}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/IcebergDkg.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/IcebergDkg.kt
index 5e8f591c..c97325b4 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/IcebergDkg.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/IcebergDkg.kt
@@ -42,7 +42,7 @@ import fr.acinq.bitcoin.utils.Either
* A contributor who reveals something other than what it committed to is named
* ([Fault.BadReveal]). One who commits to two different values in front of two
* different members is not caught here; the transcript signature is what catches
- * that, because the two members then sign different transcripts.
+ * that, because the two members then publish different transcript hashes.
*
* ### Repair, which RSS gives away
*
@@ -231,21 +231,23 @@ object IcebergDkg {
}
/**
- * The hash every participant signs once it has its share: the parameters,
- * every commitment and every public share. Two members who were shown
- * different commitments, or different public shares, sign different hashes,
- * and the ritual refuses to finish on signatures that do not all agree.
+ * The hash every participant publishes beside its public share: the parameters and every
+ * commitment. Two members who were shown different commitments publish different hashes, and the
+ * ritual refuses to finish on hashes that do not all agree.
+ *
+ * It cannot cover the public shares, which are published in the same message. Those are held
+ * together by [groupPublicKey], which refuses a set that does not lie on one polynomial, and by
+ * the wallet statement the group signs over the key they make (Phase 6), which a member whose
+ * device computed a different key refuses to sign.
*/
- fun transcriptHash(params: Params, commitments: Map, publicShares: List, groupPublicKey: PublicKey): ByteVector32 {
- require(publicShares.size == params.n && commitments.size == params.n)
+ fun transcriptHash(params: Params, commitments: Map): ByteVector32 {
+ require(commitments.size == params.n)
val bytes = buildList {
addAll(params.sessionId.toByteArray().asList())
for (j in 1..params.n) {
val c = commitments.getValue(j)
for (rank in params.heldRanks(j)) addAll(c.byRank.getValue(rank).toByteArray().asList())
}
- publicShares.forEach { addAll(it.toByteArray().asList()) }
- addAll(groupPublicKey.value.toByteArray().asList())
}
return Crypto.taggedHash(bytes.toByteArray(), TAG_TRANSCRIPT)
}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/IcebergRitualManager.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/IcebergRitualManager.kt
new file mode 100644
index 00000000..02983d1a
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/IcebergRitualManager.kt
@@ -0,0 +1,533 @@
+package com.machankura.bennu.compose.managers
+
+import co.touchlab.kermit.Logger
+import com.machankura.bennu.compose.database.BennuDatabase
+import com.machankura.bennu.compose.database.model.ChatMessage
+import com.machankura.bennu.compose.database.model.DkgSession
+import com.machankura.bennu.compose.database.model.IcebergKeySession
+import com.machankura.bennu.compose.database.model.IcebergParticipantMessage
+import com.machankura.bennu.compose.database.model.MarmotInnerEvent
+import com.machankura.bennu.compose.database.model.intermdiate.LocalChatRoom
+import com.machankura.bennu.compose.database.model.types.IcebergApprovalStep
+import com.machankura.bennu.compose.database.model.types.IcebergRitualStage
+import com.machankura.bennu.compose.extensions.toHex
+import com.machankura.bennu.compose.network.serialization.CommonJson
+import com.machankura.bennu.compose.nostr.lightning.GroupLightningEvents
+import com.vitorpamplona.quartz.nip01Core.core.Event
+import com.vitorpamplona.quartz.nip01Core.core.HexKey
+import com.vitorpamplona.quartz.nip01Core.core.Kind
+import com.vitorpamplona.quartz.nip01Core.core.hexToByteArray
+import com.vitorpamplona.quartz.nip01Core.crypto.EventHasher
+import com.vitorpamplona.quartz.nip01Core.tags.people.PTag
+import com.vitorpamplona.quartz.nip01Core.tags.people.taggedUsers
+import com.vitorpamplona.quartz.nip44Encryption.Nip44
+import com.vitorpamplona.quartz.utils.RandomInstance
+import fr.acinq.bitcoin.ByteVector
+import fr.acinq.bitcoin.ByteVector32
+import fr.acinq.bitcoin.Chain
+import fr.acinq.bitcoin.PublicKey
+import fr.acinq.bitcoin.crypto.iceberg.Iceberg
+import fr.acinq.bitcoin.crypto.iceberg.PublicShare
+import fr.acinq.bitcoin.crypto.iceberg.Share
+import fr.acinq.bitcoin.utils.Either
+import kotlinx.coroutines.CancellationException
+import kotlinx.serialization.Serializable
+import kotlin.time.Clock
+import kotlin.time.Instant
+
+/**
+ * Runs an Iceberg key ceremony ([IcebergDkg]) in a group's Marmot room: the key a group Lightning
+ * wallet signs its channels with (`docs/group-lightning-wallet.md`, Phase 5).
+ *
+ * Built like [ChillDkgRitualManager], and following its rules: every step is a pure function of what
+ * this device has stored, so a ceremony survives the app being killed; nothing of this device's own is
+ * published until its owner approves, at three gates; faults are values with one failure path; and each
+ * device writes the ceremony's transcript lines from what it has received.
+ *
+ * ### Two things it does not need, that ChillDKG does
+ *
+ * **No host keys.** ChillDKG's first round exists to fix the participant set and its order. Here the
+ * set is fixed before anyone speaks -- it is the people who hold the room's onchain wallet key
+ * (decision D1), which the proposal names and every device checks against its own record of that
+ * ceremony -- and the order is the bytewise order of their nostr keys.
+ *
+ * **No coordinator aggregation.** Every round is broadcast and every device assembles its own share, so
+ * the member who opens the ceremony does nothing the others do not.
+ *
+ * ### What travels in the clear, inside MLS
+ *
+ * Commitments, public shares and transcript hashes are public by construction. Contributions are not:
+ * each one goes only to the other holders of its seed, NIP-44 encrypted from the sender's nostr key to
+ * each recipient's, inside the MLS message the whole room can read. A member who is in the room but
+ * outside a seed's holders sees ciphertext.
+ *
+ * The room must be a Marmot room: that is where the onchain wallet's statement and every signing
+ * session already are.
+ */
+object IcebergRitualManager {
+ private val logger = Logger.withTag("IcebergRitualManager")
+
+ private const val SESSION_TAG = "iceberg_session"
+ private const val THRESHOLD_TAG = "threshold"
+ private const val ONCHAIN_TAG = "onchain_dkg"
+
+ @Serializable
+ private data class Round1(val commitments: Map)
+
+ @Serializable
+ private data class Round2(val to: Map)
+
+ @Serializable
+ private data class Round2Plain(val contributions: Map)
+
+ @Serializable
+ private data class Round3(val publicShare: String, val transcript: String)
+
+ /** The thresholds a group whose onchain key is [onchainKey] could choose, smallest first; empty if none. */
+ fun thresholdsFor(onchainKey: DkgSession): List =
+ onchainKey.participantPublicKeySet()?.let { IcebergDkg.deployableThresholds(it.size) }.orEmpty()
+
+ /** A participant's nostr key as the compressed point [IcebergDkg.Params] orders and binds. */
+ private fun asPoint(nostrKey: HexKey): PublicKey = PublicKey(ByteVector("02$nostrKey"))
+
+ fun paramsOf(session: IcebergKeySession): IcebergDkg.Params =
+ IcebergDkg.Params.of(session.threshold, session.participants().map(::asPoint), ByteVector32(session.id))
+
+ private fun indexOf(session: IcebergKeySession, nostrKey: HexKey): Int? =
+ session.participants().indexOf(nostrKey.lowercase()).takeIf { it >= 0 }?.plus(1)
+
+ /**
+ * Opens a ceremony over the people who hold [localChatRoom]'s onchain wallet key, at [threshold].
+ * A ceremony already running in the room is returned instead of a second.
+ *
+ * @param chain the network the Lightning wallet is for. The room must have opened an onchain
+ * wallet there first (decision D2), because that wallet is where the Lightning wallet closes to.
+ */
+ suspend fun proposeCeremony(
+ database: BennuDatabase,
+ localChatRoom: LocalChatRoom,
+ userPublicKey: HexKey,
+ nostrPrivateKey: ByteArray,
+ threshold: Int,
+ chain: Chain,
+ ): IcebergKeySession {
+ val roomId = localChatRoom.chatRoom.id
+ require(localChatRoom.chatRoom.mlsGroupState != null) { "An Iceberg ceremony runs in a Marmot room" }
+
+ database.icebergKeySessionDao().getSessionsForChatRoom(roomId)
+ .firstOrNull { it.stage != IcebergRitualStage.FAILED && it.stage != IcebergRitualStage.COMPLETE }
+ ?.let { return it }
+
+ val onchainKey = FrostSigningManager.completedKey(database, roomId)
+ ?: throw IllegalStateException("This group has no onchain key whose holders could sign a Lightning wallet")
+ requireNotNull(GroupWalletManager.walletFor(database, roomId, chain)) {
+ "Open a group onchain wallet on ${chain.name} before a Lightning wallet: it is where the Lightning wallet closes to"
+ }
+ val members = requireNotNull(onchainKey.participantPublicKeySet()) { "The onchain key does not record who holds it" }
+ require(userPublicKey in members) { "This device does not hold the onchain key" }
+ require(IcebergDkg.isDeployable(members.size, threshold)) { "$threshold-of-${members.size} is not a deployable Iceberg group" }
+
+ val session = IcebergKeySession(
+ id = RandomInstance.bytes(32).toHex(),
+ chatRoomId = roomId,
+ coordinatorPublicKey = userPublicKey,
+ userPublicKey = userPublicKey,
+ threshold = threshold,
+ participantCount = members.size,
+ participantPublicKeys = IcebergKeySession.formatParticipants(members),
+ onchainDkgSessionId = onchainKey.id,
+ root = RandomInstance.bytes(32).toHex(),
+ // Opening a ceremony is agreeing to be in it, as with ChillDKG's host key.
+ joinApprovedAt = Clock.System.now(),
+ )
+ database.icebergKeySessionDao().upsert(session)
+ announce(
+ database, session, ChatMessage.TYPE_ICEBERG_STARTED,
+ "started a key ceremony for a Lightning wallet. It will take ${session.threshold} of ${session.participantCount} " +
+ "of the people who hold the onchain wallet's key to sign for it, and ${2 * session.threshold - 1} of their devices " +
+ "to be online for every payment.",
+ session.coordinatorPublicKey,
+ )
+ broadcast(database, localChatRoom, session, GroupLightningEvents.CEREMONY_PROPOSAL, "", includeProposalTags = true)
+ advance(database, localChatRoom, session.id, nostrPrivateKey)
+ return database.icebergKeySessionDao().getSessionById(session.id) ?: session
+ }
+
+ /** Feeds one inbound ceremony message in and advances as far as it will go. Safe to call twice. */
+ suspend fun processCeremonyPayload(
+ database: BennuDatabase,
+ localChatRoom: LocalChatRoom,
+ innerEvent: Event,
+ userPublicKey: HexKey,
+ nostrPrivateKey: ByteArray,
+ ) {
+ val sessionId = innerEvent.tags.firstOrNull { it.size >= 2 && it[0] == SESSION_TAG }?.get(1)
+ if (sessionId == null) {
+ logger.w("Iceberg payload ${innerEvent.id} has no session tag; dropping")
+ return
+ }
+ val session = if (innerEvent.kind == GroupLightningEvents.CEREMONY_PROPOSAL) {
+ acceptProposal(database, localChatRoom, innerEvent, sessionId, userPublicKey)
+ } else {
+ database.icebergKeySessionDao().getSessionById(sessionId)
+ } ?: return
+ if (session.stage == IcebergRitualStage.FAILED || session.stage == IcebergRitualStage.COMPLETE) return
+ if (!record(database, session, innerEvent)) return
+ advance(database, localChatRoom, session.id, nostrPrivateKey)
+ }
+
+ private suspend fun acceptProposal(
+ database: BennuDatabase,
+ localChatRoom: LocalChatRoom,
+ innerEvent: Event,
+ sessionId: String,
+ userPublicKey: HexKey,
+ ): IcebergKeySession? {
+ database.icebergKeySessionDao().getSessionById(sessionId)?.let { return it }
+
+ val members = innerEvent.tags.taggedUsers().map { it.pubKey.lowercase() }.toSet() + innerEvent.pubKey.lowercase()
+ val threshold = innerEvent.tags.firstOrNull { it.size >= 2 && it[0] == THRESHOLD_TAG }?.get(1)?.toIntOrNull()
+ val onchainId = innerEvent.tags.firstOrNull { it.size >= 2 && it[0] == ONCHAIN_TAG }?.get(1)
+ if (userPublicKey.lowercase() !in members) return null
+ if (threshold == null || !IcebergDkg.isDeployable(members.size, threshold)) {
+ logger.w("Iceberg proposal $sessionId asks for $threshold-of-${members.size}, which is not deployable; dropping")
+ return null
+ }
+ // D1, checked rather than trusted: the people the proposal names must be exactly the people
+ // who hold the onchain key it names, as this device's own record of that ceremony says.
+ val onchainKey = onchainId?.let { database.dkgSessionDao().getSessionById(it) }
+ if (onchainKey?.participantPublicKeySet()?.map { it.lowercase() }?.toSet() != members) {
+ logger.w("Iceberg proposal $sessionId names people who are not the holders of onchain key $onchainId; dropping")
+ return null
+ }
+ // The id is the ceremony id the key is bound to (IcebergDkg.Params), so it has to be 32 bytes.
+ if (runCatching { ByteVector32(sessionId) }.isFailure) {
+ logger.w("Iceberg proposal $sessionId has an id that is not 32 bytes; dropping")
+ return null
+ }
+
+ val session = IcebergKeySession(
+ id = sessionId,
+ chatRoomId = localChatRoom.chatRoom.id,
+ coordinatorPublicKey = innerEvent.pubKey,
+ userPublicKey = userPublicKey,
+ threshold = threshold,
+ participantCount = members.size,
+ participantPublicKeys = IcebergKeySession.formatParticipants(members),
+ onchainDkgSessionId = onchainKey.id,
+ root = RandomInstance.bytes(32).toHex(),
+ )
+ database.icebergKeySessionDao().upsert(session)
+ announce(
+ database, session, ChatMessage.TYPE_ICEBERG_STARTED,
+ "started a key ceremony for a Lightning wallet. It will take ${session.threshold} of ${session.participantCount} " +
+ "of the people who hold the onchain wallet's key to sign for it, and ${2 * session.threshold - 1} of their devices " +
+ "to be online for every payment.",
+ session.coordinatorPublicKey,
+ )
+ announceApprovalNeeded(database, session, IcebergApprovalStep.JOIN)
+ replayStoredMessages(database, session)
+ return session
+ }
+
+ private suspend fun replayStoredMessages(database: BennuDatabase, session: IcebergKeySession) {
+ database.marmotInnerEventDao()
+ .getByChatRoomAndKinds(chatRoomId = session.chatRoomId, kinds = GroupLightningEvents.CEREMONY.toList())
+ .filter { it.kind != GroupLightningEvents.CEREMONY_PROPOSAL && it.tags.any { t -> t.size >= 2 && t[0] == SESSION_TAG && t[1] == session.id } }
+ .forEach { stored ->
+ val event = Event(stored.id, stored.publicKey, stored.createdAt.epochSeconds, stored.kind, stored.tags, stored.content, "")
+ if (!record(database, session, event)) return
+ }
+ }
+
+ /** Files one message, first copy wins. False when the message ends the ceremony. */
+ private suspend fun record(database: BennuDatabase, session: IcebergKeySession, innerEvent: Event): Boolean {
+ val sender = innerEvent.pubKey.lowercase()
+ when (innerEvent.kind) {
+ GroupLightningEvents.CEREMONY_PROPOSAL -> Unit
+ GroupLightningEvents.DKG_ROUND_1, GroupLightningEvents.DKG_ROUND_2, GroupLightningEvents.DKG_ROUND_3 -> {
+ if (indexOf(session, sender) == null) {
+ logger.w("Ceremony ${session.id}: kind ${innerEvent.kind} from ${sender.take(8)}, who is not in it; ignoring")
+ return true
+ }
+ val dao = database.icebergKeySessionDao()
+ if (dao.getMessage(session.id, innerEvent.kind, sender) == null) {
+ dao.upsert(IcebergParticipantMessage(session.id, sender, innerEvent.kind, innerEvent.content))
+ announceStep(database, session, innerEvent.kind, sender)
+ }
+ }
+ GroupLightningEvents.CEREMONY_FAILURE -> {
+ fail(database, session, "Abandoned by ${sender.take(8)}: ${innerEvent.content}", sender)
+ return false
+ }
+ }
+ return true
+ }
+
+ /**
+ * Takes every step the stored messages allow, stopping at the first that waits on somebody. Each step
+ * asks whether its output exists rather than what the stage says, as [ChillDkgRitualManager.advance] does.
+ */
+ private suspend fun advance(database: BennuDatabase, localChatRoom: LocalChatRoom, sessionId: String, nostrPrivateKey: ByteArray) {
+ var session = database.icebergKeySessionDao().getSessionById(sessionId) ?: return
+ if (session.stage == IcebergRitualStage.COMPLETE || session.stage == IcebergRitualStage.FAILED) return
+ val dao = database.icebergKeySessionDao()
+ try {
+ val params = paramsOf(session)
+ val me = indexOf(session, session.userPublicKey) ?: error("this device is not in ceremony ${session.id}")
+ val root = ByteVector32(session.root ?: error("ceremony ${session.id} has lost its random root"))
+
+ if (session.joinApprovedAt == null) return
+ if (own(database, session, GroupLightningEvents.DKG_ROUND_1) == null) {
+ val commitments = IcebergDkg.round1(params, me, root)
+ publishOwn(database, localChatRoom, session, GroupLightningEvents.DKG_ROUND_1, CommonJson.encodeToString(Round1.serializer(), Round1(commitments.byRank.entries.associate { (rank, c) -> rank.toString() to c.toHex() })))
+ }
+ val commitments = commitmentsOf(database, session, params) ?: return
+ session = moveTo(database, session, IcebergRitualStage.COLLECTING_REVEALS)
+
+ if (session.revealApprovedAt == null) {
+ announceApprovalNeeded(database, session, IcebergApprovalStep.REVEAL)
+ return
+ }
+ if (own(database, session, GroupLightningEvents.DKG_ROUND_2) == null) {
+ val to = (1..params.n).filter { it != me }.associate { k ->
+ val recipient = session.participants()[k - 1]
+ val plain = Round2Plain(IcebergDkg.round2(params, me, root, k).entries.associate { (rank, c) -> rank.toString() to c.toHex() })
+ recipient to Nip44.encrypt(CommonJson.encodeToString(Round2Plain.serializer(), plain), nostrPrivateKey, recipient.hexToByteArray()).encodePayload()
+ }
+ publishOwn(database, localChatRoom, session, GroupLightningEvents.DKG_ROUND_2, CommonJson.encodeToString(Round2.serializer(), Round2(to)))
+ }
+ val reveals = revealsTo(database, session, me, nostrPrivateKey) ?: return
+ val share = when (val assembled = IcebergDkg.assemble(params, me, root, commitments, reveals)) {
+ is Either.Left -> throw assembled.value
+ is Either.Right -> assembled.value
+ }
+ session = moveTo(database, session, IcebergRitualStage.COLLECTING_CONFIRMATIONS)
+
+ if (session.confirmApprovedAt == null) {
+ announceApprovalNeeded(database, session, IcebergApprovalStep.CONFIRM)
+ return
+ }
+ val transcript = IcebergDkg.transcriptHash(params, commitments)
+ val myPublicShare = Iceberg.publicShare(share, null)
+ if (own(database, session, GroupLightningEvents.DKG_ROUND_3) == null) {
+ publishOwn(database, localChatRoom, session, GroupLightningEvents.DKG_ROUND_3, CommonJson.encodeToString(Round3.serializer(), Round3(myPublicShare.toByteArray().toHex(), transcript.toHex())))
+ }
+ val confirmations = dao.getMessagesByKind(session.id, GroupLightningEvents.DKG_ROUND_3)
+ if (confirmations.size < params.n) return
+ val byIndex = confirmations.associate { m -> indexOf(session, m.participantPublicKey)!! to CommonJson.decodeFromString(Round3.serializer(), m.payload) }
+ val disagreeing = byIndex.filterValues { it.transcript != transcript.toHex() }.keys
+ check(disagreeing.isEmpty()) { "participants ${disagreeing.sorted()} saw a different set of commitments" }
+ val publicShares = (1..params.n).map { PublicShare(byIndex.getValue(it).publicShare) }
+ check(publicShares[me - 1] == myPublicShare) { "the public share published for this device is not the one its share gives" }
+ val groupKey = when (val key = IcebergDkg.groupPublicKey(params, publicShares)) {
+ is Either.Left -> throw key.value
+ is Either.Right -> key.value
+ }
+ update(database, session) {
+ it.copy(
+ stage = IcebergRitualStage.COMPLETE,
+ share = share.toByteArray().toHex(),
+ root = null,
+ groupPublicKey = groupKey.value.toHex(),
+ publicShares = publicShares.joinToString(",") { p -> p.toByteArray().toHex() },
+ )
+ }
+ announce(
+ database, session, ChatMessage.TYPE_ICEBERG_COMPLETE,
+ "The group has a key for a Lightning wallet. It takes ${session.threshold} of ${session.participantCount} to sign for it.",
+ session.coordinatorPublicKey,
+ )
+ logger.i("Iceberg ceremony ${session.id} complete")
+ } catch (e: CancellationException) {
+ throw e
+ } catch (e: Throwable) {
+ logger.e("Iceberg ceremony ${session.id} failed", e)
+ fail(database, session, e.message ?: e::class.simpleName ?: "Unknown error")
+ broadcast(database, localChatRoom, session, GroupLightningEvents.CEREMONY_FAILURE, e.message ?: "Ceremony failed")
+ }
+ }
+
+ /** Every participant's commitments, or null while any are missing. */
+ private suspend fun commitmentsOf(database: BennuDatabase, session: IcebergKeySession, params: IcebergDkg.Params): Map? {
+ val messages = database.icebergKeySessionDao().getMessagesByKind(session.id, GroupLightningEvents.DKG_ROUND_1)
+ if (messages.size < params.n) return null
+ return messages.associate { m ->
+ val j = indexOf(session, m.participantPublicKey)!!
+ val body = CommonJson.decodeFromString(Round1.serializer(), m.payload)
+ j to IcebergDkg.Commitments(j, body.commitments.entries.associate { (rank, c) -> rank.toInt() to ByteVector32(c) })
+ }
+ }
+
+ /** What every other participant revealed to this device, decrypted, or null while any are missing. */
+ private suspend fun revealsTo(database: BennuDatabase, session: IcebergKeySession, me: Int, nostrPrivateKey: ByteArray): Map>? {
+ val messages = database.icebergKeySessionDao().getMessagesByKind(session.id, GroupLightningEvents.DKG_ROUND_2)
+ .filter { it.participantPublicKey != session.userPublicKey.lowercase() }
+ if (messages.size < session.participantCount - 1) return null
+ val myKey = session.userPublicKey.lowercase()
+ return messages.associate { m ->
+ val j = indexOf(session, m.participantPublicKey)!!
+ val ciphertext = CommonJson.decodeFromString(Round2.serializer(), m.payload).to[myKey]
+ ?: throw IcebergDkg.Fault.MissingReveal(j)
+ val plain = try {
+ Nip44.decrypt(ciphertext, nostrPrivateKey, m.participantPublicKey.hexToByteArray())
+ } catch (e: Throwable) {
+ throw IcebergDkg.Fault.MalformedMessage(j, "its contributions could not be decrypted")
+ }
+ j to CommonJson.decodeFromString(Round2Plain.serializer(), plain).contributions.entries.associate { (rank, c) -> rank.toInt() to ByteVector32(c) }
+ }
+ }
+
+ /** What this ceremony is waiting on its owner for, or null. Mirrors the gates in [advance]. */
+ suspend fun pendingApproval(database: BennuDatabase, session: IcebergKeySession): IcebergApprovalStep? {
+ if (session.stage == IcebergRitualStage.COMPLETE || session.stage == IcebergRitualStage.FAILED) return null
+ if (session.joinApprovedAt == null) return IcebergApprovalStep.JOIN
+ val dao = database.icebergKeySessionDao()
+ if (session.revealApprovedAt == null) {
+ return if (dao.countMessagesByKind(session.id, GroupLightningEvents.DKG_ROUND_1) >= session.participantCount) IcebergApprovalStep.REVEAL else null
+ }
+ if (session.confirmApprovedAt == null) {
+ val reveals = dao.getMessagesByKind(session.id, GroupLightningEvents.DKG_ROUND_2).count { it.participantPublicKey != session.userPublicKey.lowercase() }
+ return if (reveals >= session.participantCount - 1) IcebergApprovalStep.CONFIRM else null
+ }
+ return null
+ }
+
+ /** Records that this device's owner agreed to [step] and runs on. A step it is not waiting on is a no-op. */
+ suspend fun approve(database: BennuDatabase, localChatRoom: LocalChatRoom, sessionId: String, step: IcebergApprovalStep, nostrPrivateKey: ByteArray) {
+ val session = database.icebergKeySessionDao().getSessionById(sessionId) ?: return
+ if (pendingApproval(database, session) != step) {
+ logger.i("Ceremony $sessionId is not waiting on $step; ignoring the approval")
+ return
+ }
+ val now = Clock.System.now()
+ update(database, session) {
+ when (step) {
+ IcebergApprovalStep.JOIN -> it.copy(joinApprovedAt = now)
+ IcebergApprovalStep.REVEAL -> it.copy(revealApprovedAt = now)
+ IcebergApprovalStep.CONFIRM -> it.copy(confirmApprovedAt = now)
+ }
+ }
+ advance(database, localChatRoom, sessionId, nostrPrivateKey)
+ }
+
+ /** The share this device holds for the room's newest completed ceremony, with what it is a share of. */
+ suspend fun completedKey(database: BennuDatabase, chatRoomId: String): IcebergKeySession? =
+ database.icebergKeySessionDao().getSessionsForChatRoom(chatRoomId).firstOrNull { it.stage == IcebergRitualStage.COMPLETE && it.share != null }
+
+ fun shareOf(session: IcebergKeySession): Share? = session.share?.let { Share(it.hexToByteArray()) }
+
+ private suspend fun own(database: BennuDatabase, session: IcebergKeySession, kind: Kind): IcebergParticipantMessage? =
+ database.icebergKeySessionDao().getMessage(session.id, kind, session.userPublicKey.lowercase())
+
+ private suspend fun update(database: BennuDatabase, session: IcebergKeySession, transform: (IcebergKeySession) -> IcebergKeySession): IcebergKeySession {
+ val current = database.icebergKeySessionDao().getSessionById(session.id) ?: session
+ val updated = transform(current)
+ if (updated == current) return current
+ val stamped = updated.copy(updatedAt = Clock.System.now())
+ database.icebergKeySessionDao().upsert(stamped)
+ return stamped
+ }
+
+ private suspend fun moveTo(database: BennuDatabase, session: IcebergKeySession, stage: IcebergRitualStage): IcebergKeySession = update(database, session) { current ->
+ val settled = current.stage == IcebergRitualStage.COMPLETE || current.stage == IcebergRitualStage.FAILED
+ if (settled || current.stage.ordinal >= stage.ordinal) current else current.copy(stage = stage)
+ }
+
+ private suspend fun fail(database: BennuDatabase, session: IcebergKeySession, reason: String, culprit: HexKey = session.userPublicKey) {
+ val current = database.icebergKeySessionDao().getSessionById(session.id) ?: session
+ if (current.stage == IcebergRitualStage.FAILED) return
+ update(database, current) { it.copy(stage = IcebergRitualStage.FAILED, failureReason = reason, root = null) }
+ announce(database, current, ChatMessage.TYPE_ICEBERG_FAILED, "abandoned the Lightning wallet's key ceremony. No key was created, and it is safe to run it again.", culprit)
+ }
+
+ private suspend fun announceApprovalNeeded(database: BennuDatabase, session: IcebergKeySession, step: IcebergApprovalStep) {
+ val asked = (database.icebergKeySessionDao().getSessionById(session.id) ?: session).approvalRequestedThrough
+ if (asked != null && asked.ordinal >= step.ordinal) return
+ update(database, session) { it.copy(approvalRequestedThrough = step) }
+ val (type, content) = when (step) {
+ IcebergApprovalStep.JOIN -> ChatMessage.TYPE_ICEBERG_APPROVAL_NEEDED_JOIN to
+ "Your approval is needed to join the Lightning wallet's key ceremony. Nothing has been published from this device yet."
+ IcebergApprovalStep.REVEAL -> ChatMessage.TYPE_ICEBERG_APPROVAL_NEEDED_REVEAL to
+ "Everyone has joined the Lightning wallet's key ceremony. Your approval is needed to send your contributions to the key."
+ IcebergApprovalStep.CONFIRM -> ChatMessage.TYPE_ICEBERG_APPROVAL_NEEDED_CONFIRM to
+ "Your share of the Lightning wallet's key is assembled. Your approval is needed to publish what you saw, so the group can check it agrees."
+ }
+ announce(database, session, type, content, session.userPublicKey)
+ }
+
+ private suspend fun announceStep(database: BennuDatabase, session: IcebergKeySession, kind: Kind, actor: HexKey) {
+ val (type, content) = when (kind) {
+ GroupLightningEvents.DKG_ROUND_1 -> ChatMessage.TYPE_ICEBERG_COMMITTED to
+ "joined the Lightning wallet's key ceremony, committing to their contributions before anyone reveals one."
+ GroupLightningEvents.DKG_ROUND_2 -> ChatMessage.TYPE_ICEBERG_REVEALED to
+ "sent their contributions to the key, each one only to the members who will hold it."
+ GroupLightningEvents.DKG_ROUND_3 -> ChatMessage.TYPE_ICEBERG_CONFIRMED to
+ "assembled their share and published what they saw, for the group to check it agrees."
+ else -> return
+ }
+ announce(database, session, type, content, actor)
+ }
+
+ private suspend fun announce(database: BennuDatabase, session: IcebergKeySession, messageType: String, content: String, actor: HexKey) {
+ database.chatMessageDao().upsert(
+ ChatMessage(
+ senderPublicKey = actor,
+ isUserMessage = actor.lowercase() == session.userPublicKey.lowercase(),
+ giftWrapPayloadId = null,
+ marmotGroupEventId = null,
+ marmotInnerEventId = null,
+ chatRoomId = session.chatRoomId,
+ content = content,
+ messageType = messageType,
+ dkgSessionId = session.id,
+ )
+ )
+ }
+
+ private suspend fun publishOwn(database: BennuDatabase, localChatRoom: LocalChatRoom, session: IcebergKeySession, kind: Kind, content: String) {
+ broadcast(database, localChatRoom, session, kind, content)
+ val dao = database.icebergKeySessionDao()
+ val me = session.userPublicKey.lowercase()
+ val known = dao.getMessage(session.id, kind, me) != null
+ dao.upsert(IcebergParticipantMessage(session.id, me, kind, content))
+ if (!known) announceStep(database, session, kind, me)
+ }
+
+ /**
+ * Queues one of this device's messages as a Marmot inner event for the room. The p-tags name the
+ * participants on every message, as the ChillDKG ritual's do: they are the set the proposal is
+ * checked against, and inside MLS naming them leaks nothing.
+ */
+ private suspend fun broadcast(
+ database: BennuDatabase,
+ localChatRoom: LocalChatRoom,
+ session: IcebergKeySession,
+ kind: Kind,
+ content: String,
+ includeProposalTags: Boolean = false,
+ ) {
+ val pTags = session.participants().filterNot { it == session.userPublicKey.lowercase() }.map { PTag.assemble(it, null) }
+ val ownTags = buildList {
+ add(arrayOf(SESSION_TAG, session.id))
+ if (includeProposalTags) {
+ add(arrayOf(THRESHOLD_TAG, session.threshold.toString()))
+ add(arrayOf(ONCHAIN_TAG, session.onchainDkgSessionId))
+ }
+ }
+ val tags = pTags.toTypedArray() + ownTags.toTypedArray()
+ val createdAt = Clock.System.now().epochSeconds
+ val id = EventHasher.hashId(pubKey = session.userPublicKey, createdAt = createdAt, tags = tags, content = content, kind = kind)
+ database.marmotInnerEventDao().upsert(
+ MarmotInnerEvent(
+ id = id,
+ publicKey = session.userPublicKey,
+ kind = kind,
+ createdAt = Instant.fromEpochSeconds(createdAt),
+ tags = tags,
+ content = content,
+ chatRoomId = localChatRoom.chatRoom.id,
+ )
+ )
+ }
+}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/repository/GroupLightningRepository.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/repository/GroupLightningRepository.kt
new file mode 100644
index 00000000..51a51ff5
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/repository/GroupLightningRepository.kt
@@ -0,0 +1,37 @@
+package com.machankura.bennu.compose.repository
+
+import com.machankura.bennu.compose.database.model.IcebergKeySession
+import com.machankura.bennu.compose.database.model.IcebergParticipantMessage
+import com.machankura.bennu.compose.database.model.intermdiate.LocalChatRoom
+import com.machankura.bennu.compose.database.model.types.IcebergApprovalStep
+import com.vitorpamplona.quartz.nip01Core.core.HexKey
+import fr.acinq.bitcoin.Chain
+import kotlinx.coroutines.flow.Flow
+
+/**
+ * Reads, opens and approves a group's Lightning wallet: for now, the Iceberg ceremony its key comes
+ * from (`docs/group-lightning-wallet.md`, Phase 5). Advancing a ceremony is the inbound path's job,
+ * except that a step waiting on this device's owner waits until [approveCeremony].
+ */
+interface GroupLightningRepository {
+ fun observeCeremony(sessionId: String): Flow
+
+ fun observeCeremonies(chatRoomId: String): Flow>
+
+ suspend fun ceremonyMessages(sessionId: String): List
+
+ suspend fun pendingApproval(session: IcebergKeySession): IcebergApprovalStep?
+
+ /** The thresholds a ceremony in [chatRoomId] could use, smallest first; empty when the room cannot have one. */
+ suspend fun ceremonyThresholds(chatRoomId: String): List
+
+ /** How many people hold the onchain wallet's key, and so would be in a ceremony; 0 for a room without one. */
+ suspend fun keyHolderCount(chatRoomId: String): Int
+
+ /** Whether [chatRoomId] has opened the onchain wallet a Lightning wallet on [chain] would close to. */
+ suspend fun hasOnchainWallet(chatRoomId: String, chain: Chain): Boolean
+
+ suspend fun proposeCeremony(localChatRoom: LocalChatRoom, userPublicKey: HexKey, nostrPrivateKey: ByteArray, threshold: Int, chain: Chain): IcebergKeySession
+
+ suspend fun approveCeremony(localChatRoom: LocalChatRoom, sessionId: String, step: IcebergApprovalStep, nostrPrivateKey: ByteArray)
+}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/composable/ChatRoomMessagingScreen.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/composable/ChatRoomMessagingScreen.kt
index 46e20351..16df3349 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/composable/ChatRoomMessagingScreen.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/composable/ChatRoomMessagingScreen.kt
@@ -1,5 +1,6 @@
package com.machankura.bennu.compose.ui.composable
+import com.machankura.bennu.compose.ui.composable.navigation.routes.IcebergCeremonyRoute
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
@@ -186,6 +187,15 @@ fun ChatRoomMessagingScreen(
)
)
},
+ onOpenIcebergCeremony = { sessionId ->
+ onNavigateToRoute.invoke(
+ IcebergCeremonyRoute(
+ activeUserPublicKey = activeUserPublicKey,
+ chatRoomId = chatRoomId,
+ sessionId = sessionId
+ )
+ )
+ },
onOpenSigning = { sessionId ->
onNavigateToRoute.invoke(
proposalDestination(
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/composable/IcebergCeremonyScreen.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/composable/IcebergCeremonyScreen.kt
new file mode 100644
index 00000000..2cd3cdd0
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/composable/IcebergCeremonyScreen.kt
@@ -0,0 +1,241 @@
+package com.machankura.bennu.compose.ui.composable
+
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.items
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.Bolt
+import androidx.compose.material.icons.filled.Key
+import androidx.compose.material3.Button
+import androidx.compose.material3.Card
+import androidx.compose.material3.ExperimentalMaterial3Api
+import androidx.compose.material3.FilterChip
+import androidx.compose.material3.Icon
+import androidx.compose.material3.ListItem
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Scaffold
+import androidx.compose.material3.SnackbarHost
+import androidx.compose.material3.Text
+import androidx.compose.material3.TopAppBar
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.rememberCoroutineScope
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.text.style.TextOverflow
+import androidx.lifecycle.viewmodel.compose.viewModel
+import bennu.composeapp.generated.resources.Res
+import bennu.composeapp.generated.resources.a_lightning_wallet_needs_four_signers
+import bennu.composeapp.generated.resources.abandoned_s
+import bennu.composeapp.generated.resources.confirm_what_you_saw
+import bennu.composeapp.generated.resources.confirming_publishes_your_public_share
+import bennu.composeapp.generated.resources.couldn_t_approve_this_step
+import bennu.composeapp.generated.resources.couldn_t_start_the_key_ceremony
+import bennu.composeapp.generated.resources.join_the_ceremony
+import bennu.composeapp.generated.resources.joining_publishes_commitments
+import bennu.composeapp.generated.resources.lightning_wallet_key
+import bennu.composeapp.generated.resources.open_an_onchain_wallet_on_s_first
+import bennu.composeapp.generated.resources.s_of_3_steps
+import bennu.composeapp.generated.resources.send_your_contributions
+import bennu.composeapp.generated.resources.sending_contributions_encrypts_each
+import bennu.composeapp.generated.resources.signers_needed_s_of_s
+import bennu.composeapp.generated.resources.start_a_key_ceremony
+import bennu.composeapp.generated.resources.the_group_has_a_lightning_wallet_key
+import bennu.composeapp.generated.resources.the_lightning_wallet_key_is_made_by_everyone
+import bennu.composeapp.generated.resources.this_group_has_no_lightning_wallet_key_yet
+import bennu.composeapp.generated.resources.waiting_for_contributions
+import bennu.composeapp.generated.resources.waiting_for_everyone_to_confirm
+import bennu.composeapp.generated.resources.waiting_for_everyone_to_join
+import bennu.composeapp.generated.resources.your_share_of_this_key_is_stored_unencrypted
+import com.machankura.bennu.compose.database.model.types.IcebergApprovalStep
+import com.machankura.bennu.compose.database.model.types.IcebergRitualStage
+import com.machankura.bennu.compose.identity.Identity
+import com.machankura.bennu.compose.nostr.wallet.GroupWalletStatementEvent
+import com.machankura.bennu.compose.repository.ChatRepository
+import com.machankura.bennu.compose.repository.GroupLightningRepository
+import com.machankura.bennu.compose.ui.composable.widgets.Decorative
+import com.machankura.bennu.compose.ui.composable.widgets.EmptyState
+import com.machankura.bennu.compose.ui.composable.widgets.ErrorState
+import com.machankura.bennu.compose.ui.composable.widgets.LoadingDataIndicator
+import com.machankura.bennu.compose.ui.composable.widgets.LocalSnackbarHostState
+import com.machankura.bennu.compose.ui.composable.widgets.NavigateBackButton
+import com.machankura.bennu.compose.ui.composable.widgets.ScreenStateTransition
+import com.machankura.bennu.compose.ui.composable.widgets.rememberNotifier
+import com.machankura.bennu.compose.ui.theme.readableContent
+import com.machankura.bennu.compose.ui.theme.spacing
+import com.machankura.bennu.compose.ui.view.model.IcebergCeremonyViewModel
+import com.machankura.bennu.compose.ui.view.state.IcebergCeremonyUIState
+import com.machankura.bennu.compose.wallet.GroupLightningRollout
+import com.vitorpamplona.quartz.nip01Core.core.HexKey
+import kotlinx.coroutines.flow.StateFlow
+import org.jetbrains.compose.resources.stringResource
+
+/**
+ * A group's Lightning wallet key ceremony: who has done which of its three rounds, what this device is
+ * being asked, and -- for a group without one -- the way to start it.
+ */
+@OptIn(ExperimentalMaterial3Api::class)
+@Composable
+fun IcebergCeremonyScreen(
+ activeUserPublicKey: HexKey,
+ chatRoomId: String,
+ sessionId: String?,
+ activeIdentityStateFlow: StateFlow,
+ chatRepository: ChatRepository,
+ lightningRepository: GroupLightningRepository,
+ onNavigateBack: () -> Unit,
+) {
+ val viewModel: IcebergCeremonyViewModel = viewModel(
+ factory = IcebergCeremonyViewModel.factory(
+ activeUserPublicKey = activeUserPublicKey,
+ chatRoomId = chatRoomId,
+ sessionId = sessionId,
+ chain = GroupLightningRollout.NETWORK,
+ activeIdentityStateFlow = activeIdentityStateFlow,
+ chatRepository = chatRepository,
+ lightningRepository = lightningRepository,
+ )
+ )
+ LaunchedEffect(true) { viewModel.initiate() }
+
+ val notify = rememberNotifier(rememberCoroutineScope())
+ val couldNotStart = stringResource(Res.string.couldn_t_start_the_key_ceremony)
+ val couldNotApprove = stringResource(Res.string.couldn_t_approve_this_step)
+
+ Scaffold(
+ snackbarHost = { SnackbarHost(LocalSnackbarHostState.current) },
+ topBar = {
+ TopAppBar(
+ title = { Text(stringResource(Res.string.lightning_wallet_key), maxLines = 1, overflow = TextOverflow.Ellipsis) },
+ navigationIcon = { NavigateBackButton(onNavigateBack) }
+ )
+ }
+ ) { padding ->
+ ScreenStateTransition(viewModel.uiState) { uiState ->
+ when (val state = uiState) {
+ is IcebergCeremonyUIState.Error -> ErrorState(modifier = Modifier.padding(padding), message = state.message, onRetry = null)
+
+ IcebergCeremonyUIState.Loading -> LoadingDataIndicator(modifier = Modifier.fillMaxWidth().padding(padding))
+
+ is IcebergCeremonyUIState.Loaded -> if (state.session == null) {
+ EmptyState(
+ modifier = Modifier.padding(padding).readableContent(),
+ message = when {
+ !state.hasOnchainWallet -> stringResource(Res.string.open_an_onchain_wallet_on_s_first, GroupWalletStatementEvent.chainName(GroupLightningRollout.NETWORK))
+ state.thresholds.isEmpty() -> stringResource(Res.string.a_lightning_wallet_needs_four_signers)
+ else -> stringResource(Res.string.this_group_has_no_lightning_wallet_key_yet)
+ },
+ icon = Icons.Default.Bolt,
+ action = if (viewModel.canPropose()) {
+ {
+ StartCeremony(
+ thresholds = state.thresholds,
+ participants = state.holderCount,
+ chosen = viewModel.threshold.value,
+ onChoose = { viewModel.threshold.value = it },
+ isPending = viewModel.isActionPending.value,
+ onStart = { viewModel.propose(onFailure = { notify(couldNotStart) }) },
+ )
+ }
+ } else null
+ )
+ } else {
+ Ceremony(
+ modifier = Modifier.padding(padding),
+ state = state,
+ isPending = viewModel.isActionPending.value,
+ onApprove = { viewModel.approve(onFailure = { notify(couldNotApprove) }) },
+ )
+ }
+ }
+ }
+ }
+}
+
+@Composable
+private fun StartCeremony(thresholds: List, participants: Int, chosen: Int?, onChoose: (Int) -> Unit, isPending: Boolean, onStart: () -> Unit) {
+ Column(horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(MaterialTheme.spacing.itemGap)) {
+ Text(stringResource(Res.string.the_lightning_wallet_key_is_made_by_everyone, (2 * (chosen ?: 2) - 1).toString()), style = MaterialTheme.typography.bodyMedium)
+ Row(horizontalArrangement = Arrangement.spacedBy(MaterialTheme.spacing.relatedGap)) {
+ thresholds.forEach { t ->
+ FilterChip(
+ selected = t == chosen,
+ onClick = { onChoose(t) },
+ label = { Text(stringResource(Res.string.signers_needed_s_of_s, t.toString(), participants.toString())) },
+ )
+ }
+ }
+ Text(stringResource(Res.string.your_share_of_this_key_is_stored_unencrypted), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant)
+ Button(onClick = onStart, enabled = !isPending && chosen != null) {
+ Icon(Icons.Default.Key, contentDescription = Decorative)
+ Spacer(modifier = Modifier.width(MaterialTheme.spacing.relatedGap))
+ Text(stringResource(Res.string.start_a_key_ceremony))
+ }
+ }
+}
+
+@Composable
+private fun Ceremony(modifier: Modifier, state: IcebergCeremonyUIState.Loaded, isPending: Boolean, onApprove: () -> Unit) {
+ val session = state.session ?: return
+ val members = state.localChatRoom.localParticipants.associate { it.participant.participantPublicKey.lowercase() to it }
+ LazyColumn(
+ modifier = modifier.readableContent().fillMaxSize().padding(MaterialTheme.spacing.screenMargin),
+ verticalArrangement = Arrangement.spacedBy(MaterialTheme.spacing.itemGap),
+ ) {
+ item {
+ Text(
+ text = when (session.stage) {
+ IcebergRitualStage.COLLECTING_COMMITMENTS -> stringResource(Res.string.waiting_for_everyone_to_join)
+ IcebergRitualStage.COLLECTING_REVEALS -> stringResource(Res.string.waiting_for_contributions)
+ IcebergRitualStage.COLLECTING_CONFIRMATIONS -> stringResource(Res.string.waiting_for_everyone_to_confirm)
+ IcebergRitualStage.COMPLETE -> stringResource(Res.string.the_group_has_a_lightning_wallet_key)
+ IcebergRitualStage.FAILED -> stringResource(Res.string.abandoned_s, session.failureReason.orEmpty())
+ },
+ style = MaterialTheme.typography.titleMedium,
+ )
+ Text(
+ text = stringResource(Res.string.signers_needed_s_of_s, session.threshold.toString(), session.participantCount.toString()),
+ style = MaterialTheme.typography.bodyMedium,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ )
+ }
+ state.pending?.let { step ->
+ item {
+ Card(modifier = Modifier.fillMaxWidth()) {
+ Column(modifier = Modifier.padding(MaterialTheme.spacing.containerPadding), verticalArrangement = Arrangement.spacedBy(MaterialTheme.spacing.relatedGap)) {
+ Text(
+ text = when (step) {
+ IcebergApprovalStep.JOIN -> stringResource(Res.string.joining_publishes_commitments)
+ IcebergApprovalStep.REVEAL -> stringResource(Res.string.sending_contributions_encrypts_each)
+ IcebergApprovalStep.CONFIRM -> stringResource(Res.string.confirming_publishes_your_public_share)
+ },
+ style = MaterialTheme.typography.bodyMedium,
+ )
+ Button(onClick = onApprove, enabled = !isPending) {
+ Text(
+ when (step) {
+ IcebergApprovalStep.JOIN -> stringResource(Res.string.join_the_ceremony)
+ IcebergApprovalStep.REVEAL -> stringResource(Res.string.send_your_contributions)
+ IcebergApprovalStep.CONFIRM -> stringResource(Res.string.confirm_what_you_saw)
+ }
+ )
+ }
+ }
+ }
+ }
+ }
+ items(session.participants()) { participant ->
+ ListItem(
+ headlineContent = { Text(members[participant]?.profile?.humanReadableNameOrPubkey() ?: participant.take(16)) },
+ supportingContent = { Text(stringResource(Res.string.s_of_3_steps, (state.progress[participant] ?: 0).toString())) },
+ )
+ }
+ }
+}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/composable/navigation/BennuNavHost.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/composable/navigation/BennuNavHost.kt
index 87577df5..653ba78b 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/composable/navigation/BennuNavHost.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/composable/navigation/BennuNavHost.kt
@@ -1,5 +1,8 @@
package com.machankura.bennu.compose.ui.composable.navigation
+import com.machankura.bennu.compose.ui.composable.navigation.routes.IcebergCeremonyRoute
+import com.machankura.bennu.compose.ui.composable.IcebergCeremonyScreen
+import com.machankura.bennu.compose.database.repository.DatabaseGroupLightningRepository
import com.machankura.bennu.compose.nostr.wallet.GroupWalletStatementEvent
import com.machankura.bennu.compose.wallet.GroupChainClients
import com.machankura.bennu.compose.ui.composable.GroupSendScreen
@@ -236,6 +239,10 @@ fun BennuNavHost(
)
}
+ val databaseGroupLightningRepository = remember {
+ DatabaseGroupLightningRepository(database = auxDatabaseManager.auxDatabase)
+ }
+
val databaseFrostSigningRepository = remember {
DatabaseFrostSigningRepository(
database = auxDatabaseManager.auxDatabase,
@@ -659,6 +666,21 @@ fun BennuNavHost(
}
)
}
+ composable { backStackEntry ->
+ val route = backStackEntry.toRoute()
+
+ IcebergCeremonyScreen(
+ activeUserPublicKey = route.activeUserPublicKey,
+ chatRoomId = route.chatRoomId,
+ sessionId = route.sessionId,
+ activeIdentityStateFlow = sovereignWalletViewModel.activeIdentity,
+ chatRepository = databaseChatRepository,
+ lightningRepository = databaseGroupLightningRepository,
+ onNavigateBack = {
+ navController.popBackStack()
+ }
+ )
+ }
composable { backStackEntry ->
val route = backStackEntry.toRoute()
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/composable/navigation/routes/IcebergCeremonyRoute.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/composable/navigation/routes/IcebergCeremonyRoute.kt
new file mode 100644
index 00000000..59bef09d
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/composable/navigation/routes/IcebergCeremonyRoute.kt
@@ -0,0 +1,15 @@
+package com.machankura.bennu.compose.ui.composable.navigation.routes
+
+import kotlinx.serialization.Serializable
+
+/**
+ * The Iceberg key ceremony a group's Lightning wallet signs with: watch it, approve this device's
+ * steps, or start one. Pushed from a transcript line, which names its ceremony, or from the Lightning
+ * wallet screen, which passes null and gets the room's newest.
+ */
+@Serializable
+data class IcebergCeremonyRoute(
+ val activeUserPublicKey: String,
+ val chatRoomId: String,
+ val sessionId: String? = null,
+) : Route()
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/composable/widgets/chat/ChatTranscript.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/composable/widgets/chat/ChatTranscript.kt
index b3cf1793..dbe89ca0 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/composable/widgets/chat/ChatTranscript.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/composable/widgets/chat/ChatTranscript.kt
@@ -111,6 +111,8 @@ import com.machankura.bennu.compose.ui.composable.widgets.ErrorState
fun ChatTranscript(
viewModel: ChatMessageListViewModel,
onOpenSharedKey: (dkgSessionId: String?) -> Unit,
+ /** Opens the Lightning wallet key ceremony an [ChatMessage.ICEBERG_TYPES] line is about. */
+ onOpenIcebergCeremony: (sessionId: String?) -> Unit = {},
/**
* Opens the signing this line is about, by session id -- or the room's
* whole list of proposals when the line predates [ChatMessage.frostSigningSessionId]
@@ -273,6 +275,18 @@ fun ChatTranscript(
return@items
}
+ // The Lightning wallet's key ceremony, the same kind of
+ // notice as the onchain key's, opening its own screen.
+ if (localChatMessage.chatMessage.messageType in ChatMessage.ICEBERG_TYPES) {
+ RitualNotice(
+ localChatMessage = localChatMessage,
+ isAnswered = localChatMessage.chatMessage.id in answeredRequests,
+ isSettled = localChatMessage.chatMessage.id in settledRequests,
+ onClick = { onOpenIcebergCeremony(localChatMessage.chatMessage.dkgSessionId) }
+ )
+ return@items
+ }
+
// A private message this device cannot open. Everything
// about it is known except the one thing that matters,
// so it is a notice rather than an empty bubble --
@@ -816,6 +830,13 @@ private fun RitualNotice(
ChatMessage.TYPE_DKG_APPROVAL_NEEDED_ROUND_1 -> Icons.Default.Upload
ChatMessage.TYPE_DKG_APPROVAL_NEEDED_ROUND_2 -> Icons.Default.FactCheck
+ ChatMessage.TYPE_ICEBERG_STARTED -> Icons.Default.Key
+ ChatMessage.TYPE_ICEBERG_COMMITTED, ChatMessage.TYPE_ICEBERG_APPROVAL_NEEDED_JOIN -> Icons.Default.PersonAdd
+ ChatMessage.TYPE_ICEBERG_REVEALED, ChatMessage.TYPE_ICEBERG_APPROVAL_NEEDED_REVEAL -> Icons.Default.Upload
+ ChatMessage.TYPE_ICEBERG_CONFIRMED, ChatMessage.TYPE_ICEBERG_APPROVAL_NEEDED_CONFIRM -> Icons.Default.FactCheck
+ ChatMessage.TYPE_ICEBERG_COMPLETE -> Icons.Default.CheckCircle
+ ChatMessage.TYPE_ICEBERG_FAILED -> Icons.Default.ErrorOutline
+
ChatMessage.TYPE_FROST_STARTED -> Icons.Default.Draw
ChatMessage.TYPE_FROST_NONCE -> Icons.Default.Upload
ChatMessage.TYPE_FROST_SIGNER_SET -> Icons.Default.Groups
@@ -858,11 +879,13 @@ private fun RitualNotice(
// offering to review it would be offering a decision that has already gone by.
val isRequest = (
chatMessage.messageType in ChatMessage.DKG_REQUEST_TYPES ||
+ chatMessage.messageType in ChatMessage.ICEBERG_REQUEST_TYPES ||
chatMessage.messageType in ChatMessage.FROST_REQUEST_TYPES
) && !isAnswered && !isSettled
val tint = when {
chatMessage.messageType == ChatMessage.TYPE_DKG_FAILED ||
+ chatMessage.messageType == ChatMessage.TYPE_ICEBERG_FAILED ||
chatMessage.messageType == ChatMessage.TYPE_FROST_FAILED ||
chatMessage.messageType == ChatMessage.TYPE_MEMBER_INVITE_FAILED ||
chatMessage.messageType == ChatMessage.TYPE_CHANGE_REJECTED ->
@@ -898,6 +921,7 @@ private fun RitualNotice(
// so it follows a rename and is not stuck on the "LOADING..."
// placeholder a member is given the moment they are first seen.
if (chatMessage.messageType in ChatMessage.DKG_AUTHORED_TYPES ||
+ chatMessage.messageType in ChatMessage.ICEBERG_AUTHORED_TYPES ||
chatMessage.messageType in ChatMessage.FROST_AUTHORED_TYPES
) {
withStyle(
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/view/model/IcebergCeremonyViewModel.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/view/model/IcebergCeremonyViewModel.kt
new file mode 100644
index 00000000..d5788862
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/view/model/IcebergCeremonyViewModel.kt
@@ -0,0 +1,157 @@
+package com.machankura.bennu.compose.ui.view.model
+
+import androidx.compose.runtime.MutableState
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.setValue
+import androidx.lifecycle.ViewModel
+import androidx.lifecycle.ViewModelProvider
+import androidx.lifecycle.viewModelScope
+import androidx.lifecycle.viewmodel.initializer
+import androidx.lifecycle.viewmodel.viewModelFactory
+import co.touchlab.kermit.Logger
+import com.machankura.bennu.compose.database.model.types.IcebergRitualStage
+import com.machankura.bennu.compose.identity.Identity
+import com.machankura.bennu.compose.repository.ChatRepository
+import com.machankura.bennu.compose.repository.GroupLightningRepository
+import com.machankura.bennu.compose.ui.view.state.IcebergCeremonyUIState
+import com.machankura.bennu.compose.wallet.GroupLightningRollout
+import com.vitorpamplona.quartz.nip01Core.core.HexKey
+import fr.acinq.bitcoin.Chain
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.Job
+import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.flow.map
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
+
+/**
+ * Watches a group's Lightning wallet key ceremony, opens one, and approves its steps.
+ *
+ * Nothing here drives the protocol: [com.machankura.bennu.compose.managers.IcebergRitualManager]
+ * advances as messages arrive, and this only reads the session and asks its owner what it is waiting on.
+ */
+class IcebergCeremonyViewModel(
+ val activeUserPublicKey: HexKey,
+ val chatRoomId: String,
+ /** The ceremony to show, when the caller knew which; null shows the room's newest. */
+ val sessionId: String?,
+ val chain: Chain,
+ initialUIState: IcebergCeremonyUIState,
+ private val activeIdentityStateFlow: StateFlow,
+ private val chatRepository: ChatRepository,
+ private val lightningRepository: GroupLightningRepository,
+) : ViewModel() {
+ private val logger = Logger.withTag(TAG)
+
+ var uiState: IcebergCeremonyUIState by mutableStateOf(initialUIState)
+ private set
+
+ val isActionPending: MutableState = mutableStateOf(false)
+
+ /** The threshold a new ceremony would be opened at; starts at the smallest the group allows. */
+ val threshold: MutableState = mutableStateOf(null)
+
+ private var watching: Job? = null
+
+ fun initiate() {
+ watching?.cancel()
+ watching = viewModelScope.launch(Dispatchers.IO) {
+ val localChatRoom = chatRepository.getChatRoomByIdentifier(chatRoomId)
+ if (localChatRoom == null) {
+ uiState = IcebergCeremonyUIState.Error("Couldn't find the group")
+ return@launch
+ }
+ val thresholds = lightningRepository.ceremonyThresholds(chatRoomId)
+ if (threshold.value == null) threshold.value = thresholds.firstOrNull()
+ val hasOnchainWallet = lightningRepository.hasOnchainWallet(chatRoomId, chain)
+ val holderCount = lightningRepository.keyHolderCount(chatRoomId)
+
+ val sessions = if (sessionId != null) {
+ lightningRepository.observeCeremony(sessionId)
+ } else {
+ lightningRepository.observeCeremonies(chatRoomId).map { it.firstOrNull() }
+ }
+ sessions.collect { session ->
+ val messages = session?.let { lightningRepository.ceremonyMessages(it.id) }.orEmpty()
+ uiState = IcebergCeremonyUIState.Loaded(
+ localChatRoom = localChatRoom,
+ session = session,
+ progress = session?.participants().orEmpty().associateWith { p -> messages.count { it.participantPublicKey == p } },
+ pending = session?.let { lightningRepository.pendingApproval(it) },
+ thresholds = thresholds,
+ holderCount = holderCount,
+ hasOnchainWallet = hasOnchainWallet,
+ )
+ }
+ }
+ }
+
+ /** Whether this device can open a ceremony: none running, a deployable size, an onchain wallet, a key to sign with. */
+ fun canPropose(): Boolean {
+ val loaded = uiState as? IcebergCeremonyUIState.Loaded ?: return false
+ val running = loaded.session?.stage?.let { it != IcebergRitualStage.FAILED && it != IcebergRitualStage.COMPLETE } == true
+ return !running && loaded.thresholds.isNotEmpty() && loaded.hasOnchainWallet && GroupLightningRollout.allows(chain) &&
+ activeIdentityStateFlow.value?.nostrPrivateKey != null
+ }
+
+ fun propose(onFailure: () -> Unit) {
+ val loaded = uiState as? IcebergCeremonyUIState.Loaded ?: return
+ val t = threshold.value ?: return
+ val privateKey = activeIdentityStateFlow.value?.nostrPrivateKey?.value?.toByteArray() ?: return onFailure()
+ if (isActionPending.value) return
+ isActionPending.value = true
+ viewModelScope.launch(Dispatchers.IO) {
+ val proposed = runCatching { lightningRepository.proposeCeremony(loaded.localChatRoom, activeUserPublicKey, privateKey, t, chain) }
+ .onFailure { logger.e("Could not open a Lightning wallet key ceremony in $chatRoomId", it) }
+ .getOrNull()
+ isActionPending.value = false
+ if (proposed == null) withContext(Dispatchers.Main) { onFailure() }
+ }
+ }
+
+ fun approve(onFailure: () -> Unit) {
+ val loaded = uiState as? IcebergCeremonyUIState.Loaded ?: return
+ val session = loaded.session ?: return
+ val step = loaded.pending ?: return
+ val privateKey = activeIdentityStateFlow.value?.nostrPrivateKey?.value?.toByteArray() ?: return onFailure()
+ if (isActionPending.value) return
+ isActionPending.value = true
+ viewModelScope.launch(Dispatchers.IO) {
+ val done = runCatching { lightningRepository.approveCeremony(loaded.localChatRoom, session.id, step, privateKey) }
+ .onFailure { logger.e("Could not approve $step of ${session.id}", it) }
+ .isSuccess
+ isActionPending.value = false
+ if (!done) withContext(Dispatchers.Main) { onFailure() }
+ // The ceremony may have moved without a new row being written; read it again.
+ initiate()
+ }
+ }
+
+ companion object {
+ private const val TAG = "IcebergCeremonyViewModel"
+
+ fun factory(
+ activeUserPublicKey: HexKey,
+ chatRoomId: String,
+ sessionId: String?,
+ chain: Chain,
+ activeIdentityStateFlow: StateFlow,
+ chatRepository: ChatRepository,
+ lightningRepository: GroupLightningRepository,
+ ): ViewModelProvider.Factory = viewModelFactory {
+ initializer {
+ IcebergCeremonyViewModel(
+ activeUserPublicKey = activeUserPublicKey,
+ chatRoomId = chatRoomId,
+ sessionId = sessionId,
+ chain = chain,
+ initialUIState = IcebergCeremonyUIState.Loading,
+ activeIdentityStateFlow = activeIdentityStateFlow,
+ chatRepository = chatRepository,
+ lightningRepository = lightningRepository,
+ )
+ }
+ }
+ }
+}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/view/state/IcebergCeremonyUIState.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/view/state/IcebergCeremonyUIState.kt
new file mode 100644
index 00000000..5456706a
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/view/state/IcebergCeremonyUIState.kt
@@ -0,0 +1,27 @@
+package com.machankura.bennu.compose.ui.view.state
+
+import com.machankura.bennu.compose.database.model.IcebergKeySession
+import com.machankura.bennu.compose.database.model.intermdiate.LocalChatRoom
+import com.machankura.bennu.compose.database.model.types.IcebergApprovalStep
+import com.vitorpamplona.quartz.nip01Core.core.HexKey
+
+sealed class IcebergCeremonyUIState {
+ data object Loading : IcebergCeremonyUIState()
+
+ data class Error(val message: String) : IcebergCeremonyUIState()
+
+ /**
+ * @param session null when the room has no ceremony yet, which is the screen's empty state.
+ * @param progress for each participant, how many of the three rounds this device has from them.
+ * @param thresholds what a new ceremony could be opened at; empty when the room cannot have one.
+ */
+ data class Loaded(
+ val localChatRoom: LocalChatRoom,
+ val session: IcebergKeySession?,
+ val progress: Map,
+ val pending: IcebergApprovalStep?,
+ val thresholds: List,
+ val holderCount: Int,
+ val hasOnchainWallet: Boolean,
+ ) : IcebergCeremonyUIState()
+}
diff --git a/composeApp/src/commonTest/kotlin/com/machankura/bennu/compose/managers/IcebergDkgTest.kt b/composeApp/src/commonTest/kotlin/com/machankura/bennu/compose/managers/IcebergDkgTest.kt
index a8879ff6..13540cf2 100644
--- a/composeApp/src/commonTest/kotlin/com/machankura/bennu/compose/managers/IcebergDkgTest.kt
+++ b/composeApp/src/commonTest/kotlin/com/machankura/bennu/compose/managers/IcebergDkgTest.kt
@@ -198,13 +198,13 @@ class IcebergDkgTest {
}
@Test
- fun `members shown different commitments sign different transcripts`() {
+ fun `members shown different commitments publish different transcripts`() {
val params = IcebergDkg.Params.of(2, hostKeys(4), bytes32())
val roots = (1..4).associateWith { bytes32() }
val commitments = (1..4).associateWith { IcebergDkg.round1(params, it, roots.getValue(it)) }
- val run = run(4, 2)
- val honest = IcebergDkg.transcriptHash(params, commitments, run.publicShares, run.groupKey)
+ val honest = IcebergDkg.transcriptHash(params, commitments)
+ assertEquals(honest, IcebergDkg.transcriptHash(params, commitments.toList().reversed().toMap()))
val other = commitments + (2 to IcebergDkg.round1(params, 2, bytes32()))
- assertNotEquals(honest, IcebergDkg.transcriptHash(params, other, run.publicShares, run.groupKey))
+ assertNotEquals(honest, IcebergDkg.transcriptHash(params, other))
}
}
diff --git a/composeApp/src/jvmTest/kotlin/com/machankura/bennu/compose/managers/IcebergCeremonyJvmTest.kt b/composeApp/src/jvmTest/kotlin/com/machankura/bennu/compose/managers/IcebergCeremonyJvmTest.kt
new file mode 100644
index 00000000..0bd0f8b9
--- /dev/null
+++ b/composeApp/src/jvmTest/kotlin/com/machankura/bennu/compose/managers/IcebergCeremonyJvmTest.kt
@@ -0,0 +1,293 @@
+package com.machankura.bennu.compose.managers
+
+import androidx.room3.Room
+import com.machankura.bennu.compose.database.BennuDatabase
+import com.machankura.bennu.compose.database.builder.getRoomDatabase
+import com.machankura.bennu.compose.database.model.ChatMessage
+import com.machankura.bennu.compose.database.model.ChatRoom
+import com.machankura.bennu.compose.database.model.DkgParticipantMessage
+import com.machankura.bennu.compose.database.model.DkgSession
+import com.machankura.bennu.compose.database.model.IcebergKeySession
+import com.machankura.bennu.compose.database.model.MarmotInnerEvent
+import com.machankura.bennu.compose.database.model.NostrEvent
+import com.machankura.bennu.compose.database.model.Profile
+import com.machankura.bennu.compose.database.model.intermdiate.LocalChatRoom
+import com.machankura.bennu.compose.database.model.types.DkgRitualStage
+import com.machankura.bennu.compose.database.model.types.IcebergApprovalStep
+import com.machankura.bennu.compose.database.model.types.IcebergRitualStage
+import com.machankura.bennu.compose.extensions.toHex
+import com.machankura.bennu.compose.nostr.dkg.DkgRitualEvents
+import com.machankura.bennu.compose.nostr.frost.FrostSigningEvents
+import com.machankura.bennu.compose.nostr.lightning.GroupLightningEvents
+import com.machankura.bennu.compose.nostr.wallet.GroupWalletStatementEvent
+import com.vitorpamplona.quartz.nip01Core.core.Event
+import com.vitorpamplona.quartz.nip01Core.core.HexKey
+import com.vitorpamplona.quartz.nip01Core.core.toHexKey
+import com.vitorpamplona.quartz.nip01Core.crypto.EventHasher
+import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair
+import fr.acinq.bitcoin.ByteVector32
+import fr.acinq.bitcoin.Chain
+import fr.acinq.bitcoin.Crypto
+import fr.acinq.bitcoin.PrivateKey
+import fr.acinq.bitcoin.PublicKey
+import fr.acinq.bitcoin.byteVector32
+import fr.acinq.bitcoin.crypto.frost.Frost
+import fr.acinq.bitcoin.crypto.frost.KeyMaterial
+import fr.acinq.bitcoin.crypto.iceberg.Iceberg
+import fr.acinq.bitcoin.crypto.musig2.IndividualNonce
+import fr.acinq.bitcoin.crypto.musig2.KeyAggCache
+import fr.acinq.bitcoin.crypto.musig2.SecretNonce
+import fr.acinq.bitcoin.crypto.musig2.Session
+import fr.acinq.bitcoin.utils.Either
+import kotlinx.coroutines.runBlocking
+import kotlin.random.Random
+import kotlin.test.AfterTest
+import kotlin.test.Test
+import kotlin.test.assertEquals
+import kotlin.test.assertNotNull
+import kotlin.test.assertNull
+import kotlin.test.assertTrue
+import kotlin.time.Instant
+
+/**
+ * An Iceberg key ceremony between four devices, each with its own database, over the messages the
+ * manager queues for the room -- the seam `SubgroupCeremonyInParentRoomTest` uses: what is under test is
+ * what each device stores, publishes and refuses, not whether MLS encrypts it.
+ *
+ * The four hold a 3-of-4 FROST key for the room and have opened an onchain wallet under it, which is
+ * what a Lightning wallet needs before it can have a key of its own (decisions D1 and D2).
+ */
+class IcebergCeremonyJvmTest {
+ private val n = 4
+ private val keyMaterial: KeyMaterial = Frost.trustedDealerKeygen(
+ thresholdSecretKey = PrivateKey(ByteVector32("1ceb".padEnd(62, '0') + "a1")),
+ nParticipants = n,
+ threshold = 3,
+ )
+ private val thresholdPublicKey = keyMaterial.thresholdPublicKey.value.toHex()
+ private val onchainCeremonyId = "onchain".padEnd(64, '0')
+ private val roomId = SharedKeyDerivation.marmotGroupId(thresholdPublicKey)
+ private val chain = Chain.Regtest
+ private val account = GroupWalletDerivation.account(thresholdPublicKey, chain)
+
+ private val keys = (1..n).map { KeyPair() }
+ private val members = keys.map { it.pubKey.toHexKey() }
+ private val hostKeys = (1..n).map { "02" + "2${it}".padEnd(64, '0') }
+
+ private val devices = mutableListOf()
+
+ @AfterTest
+ fun close() = devices.forEach { it.db.close() }
+
+ private inner class Device(val index: Int, val db: BennuDatabase, val room: LocalChatRoom) {
+ val publicKey: HexKey = members[index]
+ val privateKey: ByteArray = keys[index].privKey!!
+ val received = mutableSetOf()
+ suspend fun ceremony(id: String) = db.icebergKeySessionDao().getSessionById(id)
+ }
+
+ private suspend fun device(index: Int, holders: List = members): Device {
+ val db = getRoomDatabase(Room.inMemoryDatabaseBuilder())
+ members.forEach { member ->
+ val eventId = "e$member".take(64)
+ db.nostrEventDao().upsert(NostrEvent(id = eventId, pubKey = member, kind = 0, tags = emptyArray(), content = "{}", sig = "0".repeat(128)))
+ db.profileDao().upsert(Profile(publicKey = member, nostrEventId = eventId))
+ }
+ val chatRoom = ChatRoom(id = roomId, userPublicKey = members[index], subject = "Treasury", description = SharedKeyDerivation.describe("Treasury."), mlsGroupState = "00")
+ db.chatRoomDao().upsert(chatRoom)
+ db.dkgSessionDao().upsert(
+ DkgSession(
+ id = onchainCeremonyId, chatRoomId = roomId, coordinatorPublicKey = members.first(), userPublicKey = members[index],
+ threshold = 3, participantCount = n, stage = DkgRitualStage.COMPLETE,
+ hostPublicKey = hostKeys[index], round1Random = "1".repeat(64), round2AuxRandom = "2".repeat(64),
+ thresholdPublicKey = thresholdPublicKey,
+ secretShare = keyMaterial.secretShares[index].value.toHex(),
+ publicShares = keyMaterial.publicShares.joinToString(",") { it.value.toHex() },
+ participantPublicKeys = DkgSession.formatParticipants(holders.toSet()),
+ )
+ )
+ members.forEachIndexed { i, member ->
+ db.dkgSessionDao().upsert(DkgParticipantMessage(sessionId = onchainCeremonyId, participantPublicKey = member, kind = DkgRitualEvents.HOST_KEY, payload = hostKeys[i]))
+ }
+ val room = db.chatRoomDao().findChatRoomById(roomId) ?: LocalChatRoom(chatRoom = chatRoom)
+ return Device(index, db, room).also { devices += it }
+ }
+
+ private suspend fun outbox(from: Device, kinds: Set) = from.db.marmotInnerEventDao()
+ .getByChatRoomAndKinds(chatRoomId = roomId, kinds = kinds.toList())
+ .filter { it.publicKey == from.publicKey }
+ .sortedWith(compareBy({ it.createdAt }, { it.kind }))
+
+ private fun MarmotInnerEvent.asEvent() = Event(id, publicKey, createdAt.epochSeconds, kind, tags, content, "")
+
+ /** Moves every queued message of [kinds] to every other device until nothing new moves. */
+ private suspend fun pump(between: List, kinds: Set) {
+ var moved = true
+ while (moved) {
+ moved = false
+ for (from in between) for (to in between) {
+ if (from === to) continue
+ outbox(from, kinds).forEach { queued ->
+ if (to.received.add(queued.id)) {
+ moved = true
+ to.db.marmotInnerEventDao().upsert(queued.copy(chatRoomId = roomId))
+ when (queued.kind) {
+ in FrostSigningEvents.ALL -> FrostSigningManager.processSigningPayload(to.db, to.room, queued.asEvent(), to.publicKey)
+ in GroupLightningEvents.CEREMONY -> IcebergRitualManager.processCeremonyPayload(to.db, to.room, queued.asEvent(), to.publicKey, to.privateKey)
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private suspend fun openOnchainWallet(all: List) {
+ val template = GroupWalletStatementEvent.template(account)
+ val session = FrostSigningManager.proposeSigning(all[0].db, all[0].room, all[0].publicKey, template.kind, template.tags, template.content)
+ pump(all, FrostSigningEvents.ALL)
+ all.drop(1).forEach { FrostSigningManager.approve(it.db, it.room, session.id) }
+ pump(all, FrostSigningEvents.ALL)
+ all.forEach { assertNotNull(GroupWalletManager.walletFor(it.db, roomId, chain), "device ${it.index} has the onchain wallet") }
+ }
+
+ private suspend fun group(): List = (0 until n).map { device(it) }.also { openOnchainWallet(it) }
+
+ /** Runs the ceremony from [proposer], each other device approving every step when it is asked. */
+ private suspend fun runCeremony(all: List, proposer: Device = all[0], threshold: Int = 2): IcebergKeySession {
+ val proposed = IcebergRitualManager.proposeCeremony(proposer.db, proposer.room, proposer.publicKey, proposer.privateKey, threshold, chain)
+ repeat(6) {
+ pump(all, GroupLightningEvents.CEREMONY)
+ all.forEach { d ->
+ val session = d.ceremony(proposed.id) ?: return@forEach
+ IcebergRitualManager.pendingApproval(d.db, session)?.let { step -> IcebergRitualManager.approve(d.db, d.room, session.id, step, d.privateKey) }
+ }
+ }
+ pump(all, GroupLightningEvents.CEREMONY)
+ return proposed
+ }
+
+ private fun signsWithStockCosigner(sessions: List, signers: List): Boolean {
+ val s0 = sessions.first()
+ val groupKey = PublicKey.fromHex(s0.groupPublicKey!!)
+ val shares = sessions.map { IcebergRitualManager.shareOf(it)!! }
+ val byIndex = shares.associateBy { it.toByteArray()[3].toInt() }
+ val cosigner = PrivateKey(Random.nextBytes(32).byteVector32())
+ val msg = Random.nextBytes(32).byteVector32()
+ val sid = Random.nextBytes(32).byteVector32()
+ val (aggregateKey, cache) = KeyAggCache.create(listOf(groupKey, cosigner.publicKey()))
+ val contributions = signers.map { Iceberg.generateNonce(byIndex.getValue(it), null, sid) }
+ val groupNonce = (Iceberg.aggregateNonces(contributions, s0.participantCount, s0.threshold, groupKey) as Either.Right).value
+ val (secret, public) = SecretNonce.generate(Random.nextBytes(32).byteVector32(), Either.Left(cosigner), msg, cache, null)
+ val session = Session.create((IndividualNonce.aggregate(listOf(groupNonce, public)) as Either.Right).value, msg, cache)
+ val cosignerAgg = (IndividualNonce.aggregate(listOf(public)) as Either.Right).value
+ val signatureShares = signers.map { (Iceberg.partialSign(byIndex.getValue(it), null, sid, contributions, groupKey, cache, msg, cosignerAgg) as Either.Right).value }
+ val groupPartial = (Iceberg.aggregatePartialSignatures(signatureShares, s0.participantCount, s0.threshold) as Either.Right).value
+ val sig = (session.aggregateSigs(listOf(groupPartial, (session.sign(secret, cosigner) as Either.Right).value)) as Either.Right).value
+ return Crypto.verifySignatureSchnorr(msg, sig, aggregateKey)
+ }
+
+ @Test
+ fun `four devices make one 2-of-4 key, and it signs`() = runBlocking {
+ val all = group()
+ val proposed = runCeremony(all)
+ val sessions = all.map { assertNotNull(it.ceremony(proposed.id), "device ${it.index} has the ceremony") }
+ sessions.forEach { assertEquals(IcebergRitualStage.COMPLETE, it.stage, "device ${it.userPublicKey.take(8)}: ${it.failureReason}") }
+ assertEquals(1, sessions.map { it.groupPublicKey }.toSet().size, "every device has the same key")
+ assertEquals(1, sessions.map { it.publicShares }.toSet().size)
+ sessions.forEach { assertNull(it.root, "the random root is dropped once the share exists") }
+ assertTrue(signsWithStockCosigner(sessions, listOf(1, 2, 3)))
+ assertTrue(signsWithStockCosigner(sessions, listOf(2, 3, 4)))
+ // Each device wrote the ceremony's lines from what it received, ending with the key.
+ all.forEach { d ->
+ val lines = d.db.chatMessageDao().getChatMessagesByChatRoomId(roomId).map { it.chatMessage }.filter { it.messageType in ChatMessage.ICEBERG_TYPES }
+ assertEquals(1, lines.count { it.messageType == ChatMessage.TYPE_ICEBERG_COMPLETE })
+ assertEquals(n, lines.count { it.messageType == ChatMessage.TYPE_ICEBERG_COMMITTED })
+ assertTrue(ChatMessage.answeredRequests(lines).size == lines.count { it.messageType in ChatMessage.ICEBERG_REQUEST_TYPES }, "every request this device was asked is answered")
+ }
+ }
+
+ @Test
+ fun `nothing of a member's goes out before they approve it`() = runBlocking {
+ val all = group()
+ val proposed = IcebergRitualManager.proposeCeremony(all[0].db, all[0].room, all[0].publicKey, all[0].privateKey, 2, chain)
+ pump(all, GroupLightningEvents.CEREMONY)
+ val other = all[1]
+ assertEquals(IcebergApprovalStep.JOIN, IcebergRitualManager.pendingApproval(other.db, other.ceremony(proposed.id)!!))
+ assertTrue(outbox(other, GroupLightningEvents.CEREMONY).isEmpty(), "a member who has not joined has published nothing")
+
+ all.drop(1).forEach { IcebergRitualManager.approve(it.db, it.room, proposed.id, IcebergApprovalStep.JOIN, it.privateKey) }
+ pump(all, GroupLightningEvents.CEREMONY)
+ assertEquals(setOf(GroupLightningEvents.DKG_ROUND_1), outbox(other, GroupLightningEvents.CEREMONY).map { it.kind }.toSet(), "joining publishes commitments and nothing more")
+ assertEquals(IcebergApprovalStep.REVEAL, IcebergRitualManager.pendingApproval(other.db, other.ceremony(proposed.id)!!))
+ }
+
+ @Test
+ fun `a contribution travels only as ciphertext`() = runBlocking {
+ val all = group()
+ val proposed = runCeremony(all)
+ val reveal = outbox(all[1], setOf(GroupLightningEvents.DKG_ROUND_2)).single()
+ val shareHex = all[1].ceremony(proposed.id)!!.share!!
+ // No seed a member holds appears in what it sent: only ciphertext addressed to each other member.
+ (0 until (shareHex.length - 8) / 64).map { shareHex.substring(8 + 64 * it, 72 + 64 * it) }.forEach { seed ->
+ assertTrue(seed !in reveal.content)
+ }
+ members.filter { it != all[1].publicKey }.forEach { assertTrue(it in reveal.content, "a ciphertext for each other member") }
+ }
+
+ @Test
+ fun `messages delivered twice, or before the proposal, change nothing`() = runBlocking {
+ val all = group()
+ val proposed = runCeremony(all)
+ val before = all.map { it.ceremony(proposed.id) }
+ // Deliver everything to everyone again.
+ all.forEach { it.received.clear() }
+ pump(all, GroupLightningEvents.CEREMONY)
+ assertEquals(before, all.map { it.ceremony(proposed.id) })
+
+ // A fifth reading of the room by a device that hears round one before the proposal: it files
+ // the early messages and replays them once the proposal arrives.
+ val late = device(3)
+ val proposal = outbox(all[0], setOf(GroupLightningEvents.CEREMONY_PROPOSAL)).single()
+ val early = all.flatMap { outbox(it, setOf(GroupLightningEvents.DKG_ROUND_1)) }
+ early.forEach { late.db.marmotInnerEventDao().upsert(it) }
+ early.forEach { IcebergRitualManager.processCeremonyPayload(late.db, late.room, it.asEvent(), late.publicKey, late.privateKey) }
+ assertNull(late.ceremony(proposed.id), "nothing is filed before the proposal")
+ late.db.marmotInnerEventDao().upsert(proposal)
+ IcebergRitualManager.processCeremonyPayload(late.db, late.room, proposal.asEvent(), late.publicKey, late.privateKey)
+ assertEquals(n, late.db.icebergKeySessionDao().countMessagesByKind(proposed.id, GroupLightningEvents.DKG_ROUND_1), "the early commitments were replayed")
+ }
+
+ @Test
+ fun `a proposal naming people who do not hold the onchain key is dropped`() = runBlocking {
+ val all = group()
+ val outsider = KeyPair().pubKey.toHexKey()
+ val tags = (members.drop(1).dropLast(1) + outsider).map { arrayOf("p", it) } + listOf(
+ arrayOf("iceberg_session", Random.nextBytes(32).toHex()), arrayOf("threshold", "2"), arrayOf("onchain_dkg", onchainCeremonyId),
+ )
+ val createdAt = 1_700_000_000L
+ val event = Event(EventHasher.hashId(pubKey = members[0], createdAt = createdAt, kind = GroupLightningEvents.CEREMONY_PROPOSAL, tags = tags.toTypedArray(), content = ""), members[0], createdAt, GroupLightningEvents.CEREMONY_PROPOSAL, tags.toTypedArray(), "", "")
+ IcebergRitualManager.processCeremonyPayload(all[1].db, all[1].room, event, all[1].publicKey, all[1].privateKey)
+ assertTrue(all[1].db.icebergKeySessionDao().getSessionsForChatRoom(roomId).isEmpty())
+ }
+
+ @Test
+ fun `an undeployable threshold is refused at both ends`() = runBlocking {
+ val all = group()
+ val refused = runCatching { IcebergRitualManager.proposeCeremony(all[0].db, all[0].room, all[0].publicKey, all[0].privateKey, 3, chain) }
+ assertTrue(refused.isFailure, "3-of-4 cannot be expressed")
+ val tags = members.drop(1).map { arrayOf("p", it) } + listOf(
+ arrayOf("iceberg_session", Random.nextBytes(32).toHex()), arrayOf("threshold", "3"), arrayOf("onchain_dkg", onchainCeremonyId),
+ )
+ val event = Event(EventHasher.hashId(pubKey = members[0], createdAt = 1L, kind = GroupLightningEvents.CEREMONY_PROPOSAL, tags = tags.toTypedArray(), content = ""), members[0], 1L, GroupLightningEvents.CEREMONY_PROPOSAL, tags.toTypedArray(), "", "")
+ IcebergRitualManager.processCeremonyPayload(all[1].db, all[1].room, event, all[1].publicKey, all[1].privateKey)
+ assertTrue(all[1].db.icebergKeySessionDao().getSessionsForChatRoom(roomId).isEmpty())
+ }
+
+ @Test
+ fun `there is no ceremony without an onchain wallet`() = runBlocking {
+ val lone = (0 until n).map { device(it) }
+ val refused = runCatching { IcebergRitualManager.proposeCeremony(lone[0].db, lone[0].room, lone[0].publicKey, lone[0].privateKey, 2, chain) }
+ assertTrue(refused.isFailure)
+ assertTrue(refused.exceptionOrNull()!!.message!!.contains("onchain wallet"))
+ }
+}
diff --git a/docs/group-lightning-wallet.md b/docs/group-lightning-wallet.md
index 664eba71..2f57a8e6 100644
--- a/docs/group-lightning-wallet.md
+++ b/docs/group-lightning-wallet.md
@@ -34,6 +34,7 @@ build chose differently, this table says so.
| 2 | done, in the fork (`4bc973df`): the three signing methods suspend, `RemoteIcebergFundingSigner`, pings answered outside the channel loop. lightning-kmp's JVM suite, 985 tests, passes |
| 3 | done: in the fork (`e15e31ba`), `withGroupBasepoints`, `GroupHeldOutputs` and `KeyManager.defaultFinalScriptPubKey`, 991 tests passing. In the app, `GroupLightningDerivation`, pinned, with a FROST quorum spending `to_remote` and `to_local` |
| 4 | done: `GroupChainClients`, one Electrum connection per network for the wallets and the watcher; the wallet routes carry a chain; a second wallet row for testnet3 behind `GroupLightningRollout`, which is off |
+| 5 | done: `IcebergRitualManager`, schema 27 (`IcebergKeySession`, `IcebergParticipantMessage`), the ceremony screen and its transcript lines. Seven four-device tests, and the app's 1,391 JVM tests pass |
| what the plan said | what it turned out to be |
|---|---|
@@ -53,6 +54,12 @@ build chose differently, this table says so.
| a testnet3 Electrum client per identity, from `AppConfigurationManager.randomElectrumServer` | from lightning-kmp's `ElectrumServers.pickElectrumServer`, which lists the same servers and needs no Phoenix business to call. The node's own client still serves the node's network |
| `GroupOnchainWallets` is keyed by `(chain, account)` | it stays keyed by xpub, which already names one account on one network. What changed is the client: each wallet is made on its own network's |
| a regtest test opens, receives and spends with mainnet unaffected | the existing wallet suites run on regtest unchanged through the new registry, and two new tests check that each spend goes out on its own network's connection, and that a spend naming no known network is left alone |
+| the ceremony's participants are sorted by host key | by nostr key. Their set is fixed before anyone speaks, as the holders of the onchain wallet's key that every device already has on record, so ChillDKG's host-key round has nothing to settle. Each key is read as the even point over its x coordinate for `IcebergDkg.Params` |
+| a transcript *signature* in round 3 | a transcript *hash*, beside the public share. The MLS frame already says who sent it. The hash covers the parameters and every commitment but not the public shares, which are published in the same message. `groupPublicKey`'s consistency check holds those together, and Phase 6's statement is where a member whose device computed a different key refuses to sign |
+| round-2 values are NIP-44 encrypted to each recipient's ceremony host key | to each recipient's nostr key, from the sender's, for the same reason as the row above |
+| an `IcebergKeySession` holds the share, and the protocol state | it holds the share and the *inputs*, as `DkgSession` does: a random root that every contribution is derived from, and every message in `IcebergParticipantMessage`. The root is dropped once the share exists, or when the ceremony fails |
+| the ceremony's transcript lines get their own session column | they reuse `ChatMessage.dkgSessionId` for the Iceberg session's id. The line's type says which ceremony screen it opens |
+| entry from the Lightning wallet screen | the Lightning wallet screen arrives in Phase 6. Until then the ceremony screen is reached from its own transcript lines, and `IcebergCeremonyRoute` with no session shows the room's newest, with the way to start one |
| the kinds are reserved | in code: `GroupLightningEvents`, 30333-30349, with a test asserting the run is unbroken and touches no kind the app already dispatches on |
| library phases land in the forks' `threshold` branches | on a new branch, `claude/group-lightning-wallet`, in `lightning-kmp-app` and in `experimental/lightning-kmp`. It is local and not pushed. The app's submodule pointer follows it, so a checkout of this branch needs those commits from the same machine until they are pushed |