mirror of
https://github.com/logos-messaging/nim-chat-poc.git
synced 2026-01-02 14:13:10 +00:00
chore: log the encrypt key
This commit is contained in:
parent
60f81d1e3e
commit
f1ad7e64e3
@ -41,8 +41,8 @@ proc main() {.async.} =
|
||||
# Wire Callbacks
|
||||
saro.onNewMessage(proc(convo: Conversation, msg: ReceivedMessage) {.async.} =
|
||||
echo " Saro <------ :: " & getContent(msg.content)
|
||||
await sleepAsync(5000)
|
||||
discard await convo.sendMessage(saro.ds, initTextFrame("Ping").toContentFrame())
|
||||
# await sleepAsync(5000)
|
||||
# discard await convo.sendMessage(saro.ds, initTextFrame("Ping").toContentFrame())
|
||||
|
||||
)
|
||||
|
||||
@ -55,23 +55,28 @@ proc main() {.async.} =
|
||||
|
||||
raya.onNewMessage(proc(convo: Conversation,msg: ReceivedMessage) {.async.} =
|
||||
echo fmt" ------> Raya :: from:{msg.sender} " & getContent(msg.content)
|
||||
await sleepAsync(500)
|
||||
discard await convo.sendMessage(raya.ds, initTextFrame("Pong" & $ri).toContentFrame())
|
||||
# await sleepAsync(500)
|
||||
# discard await convo.sendMessage(raya.ds, initTextFrame("Pong" & $ri).toContentFrame())
|
||||
# await sleepAsync(800)
|
||||
# discard await convo.sendMessage(raya.ds, initTextFrame("Pong" & $ri).toContentFrame())
|
||||
# await sleepAsync(500)
|
||||
# discard await convo.sendMessage(raya.ds, initTextFrame("Pong" & $ri).toContentFrame())
|
||||
inc ri
|
||||
# inc ri
|
||||
)
|
||||
|
||||
raya.onNewConversation(proc(convo: Conversation) {.async.} =
|
||||
echo " ------> Raya :: New Conversation: " & convo.id()
|
||||
discard await convo.sendMessage(raya.ds, initTextFrame("Hello").toContentFrame())
|
||||
# discard await convo.sendMessage(raya.ds, initTextFrame("Hello from raya").toContentFrame())
|
||||
)
|
||||
raya.onDeliveryAck(proc(convo: Conversation, msgId: string) {.async.} =
|
||||
echo " raya -- Read Receipt for " & msgId
|
||||
)
|
||||
|
||||
saro.onNewConversation(proc(convo: Conversation) {.async.} =
|
||||
echo " Saro <------ :: New Conversation: " & convo.id()
|
||||
discard await convo.sendMessage(saro.ds, initTextFrame("Hello from saro").toContentFrame())
|
||||
)
|
||||
|
||||
|
||||
await saro.start()
|
||||
await raya.start()
|
||||
|
||||
@ -51,8 +51,8 @@ type KeyEntry* = object
|
||||
type Client* = ref object
|
||||
ident: Identity
|
||||
ds*: WakuClient
|
||||
keyStore: Table[string, KeyEntry] # Keyed by HexEncoded Public Key
|
||||
conversations: Table[string, Conversation] # Keyed by conversation ID
|
||||
keyStore*: Table[string, KeyEntry] # Keyed by HexEncoded Public Key
|
||||
conversations*: Table[string, Conversation] # Keyed by conversation ID
|
||||
inboundQueue: QueueRef
|
||||
isRunning: bool
|
||||
|
||||
|
||||
@ -90,7 +90,7 @@ proc createPrivateV1FromInvite*[T: ConversationStore](client: T,
|
||||
client.addConversation(convo)
|
||||
|
||||
# TODO send a control frame instead
|
||||
discard convo.sendMessage(client.ds, initTextFrame("Hello").toContentFrame())
|
||||
# discard convo.sendMessage(client.ds, initTextFrame("Hello").toContentFrame())
|
||||
|
||||
|
||||
proc handleFrame*[T: ConversationStore](convo: Inbox, client: T, bytes: seq[
|
||||
|
||||
@ -121,7 +121,11 @@ proc skipMessageKeys(self: var Doubleratchet, until: MsgCount): Result[(), strin
|
||||
|
||||
proc encrypt(self: var Doubleratchet, plaintext: var seq[byte], associatedData: openArray[byte]): (DrHeader, CipherText) =
|
||||
|
||||
info "encrypt message ", plaintext = hex(plaintext), chainKeySend = hex(self.chainKeySend)
|
||||
|
||||
let (msgKey, chainKey) = self.kdfChain(self.chainKeySend)
|
||||
info "derived msgKey ", msgKey = hex(msgKey)
|
||||
info "updating chainKeySend ", chainKey = hex(chainKey)
|
||||
# self.chainKeySend = chainKey
|
||||
let header = DrHeader(
|
||||
dhPublic: self.dhSelf.public, #TODO Serialize
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user