Bug fix on marmot keypackage bundle (Buggy nsec)

This commit is contained in:
Kgothatso Ngako
2026-06-22 22:30:39 +02:00
parent 9def2cbe33
commit 0f8ee65033
4 changed files with 25 additions and 22 deletions

View File

@@ -2,7 +2,7 @@
"formatVersion": 1,
"database": {
"version": 1,
"identityHash": "f7045a56c021b062dd142cc9cd8513a3",
"identityHash": "6b621966e86b542862bb89991b2b3acb",
"entities": [
{
"tableName": "BroadcastNostrEventReceipt",
@@ -1188,7 +1188,7 @@
},
{
"tableName": "MarmotKeyPackageBundle",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `publicKey` TEXT NOT NULL, `tlsEncodedMarmotKeyPackage` TEXT NOT NULL, `ncryptsecInitPrivateKey` TEXT NOT NULL, `ncryptsecEncryptionPrivateKey` TEXT NOT NULL, `ncryptsecSignaturePrivateKey` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, FOREIGN KEY(`publicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `publicKey` TEXT NOT NULL, `tlsEncodedMarmotKeyPackage` TEXT NOT NULL, `ncryptsecInitPrivateKey` TEXT NOT NULL, `ncryptsecEncryptionPrivateKey` TEXT NOT NULL, `ncryptsecSignaturePrivateKey` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER)",
"fields": [
{
"fieldPath": "id",
@@ -1261,17 +1261,15 @@
"id"
]
},
"foreignKeys": [
"indices": [
{
"table": "Profile",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"name": "index_MarmotKeyPackageBundle_publicKey",
"unique": false,
"columnNames": [
"publicKey"
],
"referencedColumns": [
"publicKey"
]
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_MarmotKeyPackageBundle_publicKey` ON `${TABLE_NAME}` (`publicKey`)"
}
]
},
@@ -3034,7 +3032,7 @@
],
"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, 'f7045a56c021b062dd142cc9cd8513a3')"
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '6b621966e86b542862bb89991b2b3acb')"
]
}
}

View File

@@ -2,6 +2,7 @@ package at.torch.compose.database.model
import androidx.room3.Entity
import androidx.room3.ForeignKey
import androidx.room3.Index
import androidx.room3.PrimaryKey
import at.torch.compose.database.model.traits.BroadcastableEntity
import at.torch.compose.database.model.traits.LocalStoreEntity
@@ -12,14 +13,17 @@ import kotlin.time.Clock
import kotlin.time.Instant
@Entity(
foreignKeys = [
ForeignKey(
entity = Profile::class,
parentColumns = ["publicKey"],
childColumns = ["publicKey"],
onDelete = ForeignKey.CASCADE,
),
]
// foreignKeys = [
// ForeignKey(
// entity = Profile::class,
// parentColumns = ["publicKey"],
// childColumns = ["publicKey"],
// onDelete = ForeignKey.CASCADE,
// ),
// ],
indices = [
Index("publicKey"),
],
)
data class MarmotKeyPackageBundle(
@PrimaryKey(autoGenerate = true)

View File

@@ -29,9 +29,9 @@ class DatabaseMarmotRepository(
MarmotKeyPackageBundle(
publicKey = publicKey,
tlsEncodedMarmotKeyPackage = tlsWriter.toByteArray().toHex(),
ncryptsecInitPrivateKey = nip49.encrypt(keyPackageBundle.initPrivateKey.toHex(), nsecPassword), // TODO: ncryptSec this using the private key
ncryptsecEncryptionPrivateKey = nip49.encrypt(keyPackageBundle.encryptionPrivateKey.toHex(), nsecPassword), // TODO: ncryptSec this using the private key
ncryptsecSignaturePrivateKey = nip49.encrypt(keyPackageBundle.signaturePrivateKey.toHex(), nsecPassword) // TODO: ncryptSec this using the private key
ncryptsecInitPrivateKey = keyPackageBundle.initPrivateKey.toHex(), // TODO: ncryptSec this using the private key
ncryptsecEncryptionPrivateKey = keyPackageBundle.encryptionPrivateKey.toHex(), // TODO: ncryptSec this using the private key
ncryptsecSignaturePrivateKey = keyPackageBundle.signaturePrivateKey.toHex() // TODO: ncryptSec this using the private key
)
)

View File

@@ -1,5 +1,6 @@
package at.torch.compose.database.repository
import at.torch.compose.database.model.Profile
import at.torch.compose.database.model.UnsignedNostrEvent
import at.torch.compose.nostr.Relays
import co.touchlab.kermit.Logger