2025-08-05 14:06:07 -07:00
|
|
|
import waku/waku_core
|
2025-07-05 14:54:19 -07:00
|
|
|
import std/[random, times]
|
|
|
|
|
import crypto
|
|
|
|
|
import blake2
|
2025-08-05 14:06:07 -07:00
|
|
|
|
|
|
|
|
proc getTimestamp*(): Timestamp =
|
|
|
|
|
result = waku_core.getNanosecondTime(getTime().toUnix())
|
2025-07-05 14:54:19 -07:00
|
|
|
|
|
|
|
|
proc generateSalt*(): uint64 =
|
|
|
|
|
randomize()
|
|
|
|
|
result = 0
|
|
|
|
|
for i in 0 ..< 8:
|
|
|
|
|
result = result or (uint64(rand(255)) shl (i * 8))
|
|
|
|
|
|
2025-07-11 15:43:19 -07:00
|
|
|
proc hash_func*(s: string): string =
|
|
|
|
|
# This should be Blake2s but it does not exist so substituting with Blake2b
|
|
|
|
|
result = getBlake2b(s, 4, "")
|
|
|
|
|
|
2025-07-05 14:54:19 -07:00
|
|
|
proc get_addr*(pubkey: SkPublicKey): string =
|
|
|
|
|
# TODO: Needs Spec
|
2025-07-11 15:43:19 -07:00
|
|
|
result = hash_func(pubkey.toHexCompressed())
|
|
|
|
|
|
|
|
|
|
|
2025-07-05 14:54:19 -07:00
|
|
|
|