From 9a15a99b733b79a043d108656000512fde47254e Mon Sep 17 00:00:00 2001 From: davotoula Date: Sat, 9 May 2026 13:21:08 +0200 Subject: [PATCH] Quartz: - Drop full event JSON from signature-verify failure logs - Redact privKey in KeyPair.toString --- .../com/vitorpamplona/quartz/nip01Core/crypto/EventExt.kt | 4 ++-- .../com/vitorpamplona/quartz/nip01Core/crypto/KeyPair.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/crypto/EventExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/crypto/EventExt.kt index 644638d3c..84a91fd0d 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/crypto/EventExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/crypto/EventExt.kt @@ -39,7 +39,7 @@ fun Event.verifySignature(): Boolean { /** Checks if the ID is correct and then if the pubKey's secret key signed the event. */ fun Event.checkSignature() { if (!verifyId()) { - throw Exception("ID mismatch: our ID is ${generateId()} for event ${toJson()}") + throw Exception("ID mismatch: our ID is ${generateId()} for event id=$id, pubKey=$pubKey, kind=$kind, createdAt=$createdAt") } if (!verifySignature()) { throw Exception("Bad signature!") @@ -50,6 +50,6 @@ fun Event.verify(): Boolean = try { verifyId() && verifySignature() } catch (e: Exception) { - Log.w("Event", "Event $id does not have a valid signature: ${toJson()}", e) + Log.w("Event", "Event $id does not have a valid signature (pubKey=$pubKey, kind=$kind, createdAt=$createdAt)", e) false } diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/crypto/KeyPair.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/crypto/KeyPair.kt index e30ad7958..3ca7f18d9 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/crypto/KeyPair.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/crypto/KeyPair.kt @@ -53,5 +53,5 @@ class KeyPair( } } - override fun toString(): String = "KeyPair(privateKey=${privKey?.toHexKey()}, publicKey=${pubKey.toHexKey()}" + override fun toString(): String = "KeyPair(publicKey=${pubKey.toHexKey()}, privateKey=)" }