diff --git a/src/chat/conversations/private_v1.nim b/src/chat/conversations/private_v1.nim index 7554bc9..5b31f4a 100644 --- a/src/chat/conversations/private_v1.nim +++ b/src/chat/conversations/private_v1.nim @@ -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 diff --git a/src/chat/errors.nim b/src/chat/errors.nim index e7b8008..f4751b0 100644 --- a/src/chat/errors.nim +++ b/src/chat/errors.nim @@ -9,6 +9,5 @@ type errTypeError errWrapped - proc `$`*(x: ChatError): string = fmt"ChatError(code={$x.code}, context: {x.context})" diff --git a/src/naxolotl/naxolotl.nim b/src/naxolotl/naxolotl.nim index f2b0fb8..ad2efa6 100644 --- a/src/naxolotl/naxolotl.nim +++ b/src/naxolotl/naxolotl.nim @@ -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 \ No newline at end of file