Skip to content

Commit a6b24f7

Browse files
authored
Merge pull request #28 from waku-org/fix-decrypt-out-messages
fix: outgoing messages should not be decrypted
2 parents 4700223 + eca8b57 commit a6b24f7

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/chat/conversations/private_v1.nim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ proc handleFrame*[T: ConversationStore](convo: PrivateV1, client: T,
190190
let enc = decode(bytes, EncryptedPayload).valueOr:
191191
raise newException(ValueError, fmt"Failed to decode EncryptedPayload: {repr(error)}")
192192

193+
if convo.doubleratchet.dhSelfPublic() == enc.doubleratchet.dh:
194+
info "outgoing message, no need to handle", convo = convo.id()
195+
return
196+
193197
let plaintext = convo.decrypt(enc).valueOr:
194198
error "decryption failed", error = error
195199
return

src/chat/errors.nim

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@ type
99
errTypeError
1010
errWrapped
1111

12-
1312
proc `$`*(x: ChatError): string =
1413
fmt"ChatError(code={$x.code}, context: {x.context})"

src/naxolotl/naxolotl.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,6 @@ func initDoubleratchet*(sharedSecret: array[32, byte], dhSelf: PrivateKey, dhRem
187187

188188
if isSending:
189189
result.dhRatchetSend()
190+
191+
func dhSelfPublic*(self: Doubleratchet): PublicKey =
192+
self.dhSelf.public

0 commit comments

Comments
 (0)