chore: log the encrypt key

This commit is contained in:
kaichaosun 2025-11-27 15:44:14 +08:00
parent 60f81d1e3e
commit f1ad7e64e3
No known key found for this signature in database
GPG Key ID: 223E0F992F4F03BF
4 changed files with 18 additions and 9 deletions

View File

@ -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()

View File

@ -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

View File

@ -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[

View File

@ -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