mirror of
https://github.com/logos-messaging/nim-chat-poc.git
synced 2026-07-08 01:19:32 +00:00
Global, restart-based Required/None anonymity mode: route chat messages through the
libp2p mixnet for sender anonymity, on the logos-delivery (efafdfdc2) nwaku stack.
Static RLN spam protection; no on-chain LEZ gifter / dynamic membership.
Delivery (src/chat/delivery/waku_client.nim):
- WakuConfig.mixEnabled/mixNodes/minMixPoolSize; parseMixNodes, waitForMixPool,
getMixPoolSize, mixReady.
- Required mode: sendBytes -> lightpushPublish(mixify=true) over the mix pool,
fail-fast below minMixPoolSize (no relay fallback). None mode: relay publish.
Errors propagate up to chat_send_message.
- Receive via WakuFilter (subscribe to static peers; no relay mounted), refreshed
by a 60s keep-alive.
- Static RLN: pre-populated rln_tree.db + per-peer keystore; nodekey config to adopt
a provisioned identity. No per-send root-convergence wait (static membership).
API / build:
- chat_get_mix_status FFI -> {mixEnabled,mixReady,mixPoolSize,minPoolSize}.
- Reproducible nix build: librln consumed as a cdylib (avoids the two-Rust-staticlib
symbol collision); -d:libp2p_mix_experimental_exit_is_dest.
- vendor/nwaku -> efafdfdc2; vendor/nim-protobuf-serialization -> 38d24eb (0.4.0).
19 lines
613 B
Nim
19 lines
613 B
Nim
import logos_delivery/waku/waku_core
|
|
import std/[macros, times]
|
|
import blake2
|
|
import strutils
|
|
|
|
proc getCurrentTimestamp*(): Timestamp =
|
|
result = waku_core.getNanosecondTime(getTime().toUnix())
|
|
|
|
proc hash_func*(s: string | seq[byte]): string =
|
|
# This should be Blake2s but it does not exist so substituting with Blake2b
|
|
result = getBlake2b(s, 4, "")
|
|
|
|
proc bytesToHex*[T](bytes: openarray[T], lowercase: bool = false): string =
|
|
## Convert bytes to hex string with case option
|
|
result = ""
|
|
for b in bytes:
|
|
let hex = b.toHex(2)
|
|
result.add(if lowercase: hex.toLower() else: hex)
|