Merge pull request #28 from waku-org/fix-decrypt-out-messages

fix: outgoing messages should not be decrypted
This commit is contained in:
kaichao 2025-12-01 23:21:06 +08:00 committed by GitHub
commit a6b24f780b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 1 deletions

View File

@ -190,6 +190,10 @@ proc handleFrame*[T: ConversationStore](convo: PrivateV1, client: T,
let enc = decode(bytes, EncryptedPayload).valueOr:
raise newException(ValueError, fmt"Failed to decode EncryptedPayload: {repr(error)}")
if convo.doubleratchet.dhSelfPublic() == enc.doubleratchet.dh:
info "outgoing message, no need to handle", convo = convo.id()
return
let plaintext = convo.decrypt(enc).valueOr:
error "decryption failed", error = error
return

View File

@ -9,6 +9,5 @@ type
errTypeError
errWrapped
proc `$`*(x: ChatError): string =
fmt"ChatError(code={$x.code}, context: {x.context})"

View File

@ -187,3 +187,6 @@ func initDoubleratchet*(sharedSecret: array[32, byte], dhSelf: PrivateKey, dhRem
if isSending:
result.dhRatchetSend()
func dhSelfPublic*(self: Doubleratchet): PublicKey =
self.dhSelf.public