- Drop full event JSON from signature-verify failure logs
- Redact privKey in KeyPair.toString
This commit is contained in:
davotoula
2026-05-09 13:21:08 +02:00
parent 2479fef181
commit 9a15a99b73
2 changed files with 3 additions and 3 deletions
@@ -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
}
@@ -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=<redacted>)"
}