mirror of
https://github.com/logos-messaging/nim-chat-poc.git
synced 2026-01-02 06:03:09 +00:00
fix: outgoing messages should not be decrypted
This commit is contained in:
parent
c6e03686fe
commit
523dca43e1
@ -94,6 +94,10 @@ proc decrypt*(convo: PrivateV1, enc: EncryptedPayload): Result[seq[byte], ChatEr
|
||||
)
|
||||
copyMem(addr header.dhPublic[0], unsafeAddr dr.dh[0], dr.dh.len) # TODO: Avoid this copy
|
||||
|
||||
if convo.doubleratchet.dhSelf.public == header.dhPublic:
|
||||
info "outgoing message, no need to decrypt"
|
||||
return err(ChatError(code: errDecryptOutgoing, context: "Attempted to decrypt outgoing message"))
|
||||
|
||||
convo.doubleratchet.decrypt(header, dr.ciphertext, @[]).mapErr(proc(e: NaxolotlError): ChatError = ChatError(code: errWrapped, context: repr(e) ))
|
||||
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ type
|
||||
ErrorCode* = enum
|
||||
errTypeError
|
||||
errWrapped
|
||||
errDecryptOutgoing
|
||||
|
||||
|
||||
proc `$`*(x: ChatError): string =
|
||||
|
||||
@ -16,7 +16,7 @@ const maxSkip = 10
|
||||
|
||||
|
||||
type Doubleratchet* = object
|
||||
dhSelf: PrivateKey
|
||||
dhSelf*: PrivateKey
|
||||
dhRemote: PublicKey
|
||||
|
||||
rootKey: RootKey
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user