Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/chat/conversations/private_v1.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/chat/errors.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ type
errTypeError
errWrapped


proc `$`*(x: ChatError): string =
fmt"ChatError(code={$x.code}, context: {x.context})"
3 changes: 3 additions & 0 deletions src/naxolotl/naxolotl.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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