mirror of
https://github.com/logos-messaging/nim-chat-poc.git
synced 2026-01-10 10:03:10 +00:00
Merge pull request #28 from waku-org/fix-decrypt-out-messages
fix: outgoing messages should not be decrypted
This commit is contained in:
commit
a6b24f780b
@ -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
|
||||
|
||||
@ -9,6 +9,5 @@ type
|
||||
errTypeError
|
||||
errWrapped
|
||||
|
||||
|
||||
proc `$`*(x: ChatError): string =
|
||||
fmt"ChatError(code={$x.code}, context: {x.context})"
|
||||
|
||||
@ -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
|
||||
Loading…
x
Reference in New Issue
Block a user