mirror of
https://github.com/logos-messaging/nim-chat-poc.git
synced 2026-01-02 14:13:10 +00:00
isolate hash func
This commit is contained in:
parent
e834704a89
commit
7ea9dd084d
@ -4,7 +4,6 @@ import ../utils
|
||||
|
||||
import std/[sequtils, strutils]
|
||||
import std/algorithm
|
||||
import blake2
|
||||
import sugar
|
||||
|
||||
type
|
||||
@ -27,7 +26,7 @@ proc derive_topic(participants: seq[PublicKey], discriminator: string): string =
|
||||
addrs.add(discriminator)
|
||||
let raw = addrs.join("|")
|
||||
|
||||
return "/convo/private/" & getBlake2b(raw, 18, "")
|
||||
return "/convo/private/" & utils.hash_func(raw)
|
||||
|
||||
|
||||
|
||||
|
||||
@ -12,7 +12,13 @@ proc generateSalt*(): uint64 =
|
||||
for i in 0 ..< 8:
|
||||
result = result or (uint64(rand(255)) shl (i * 8))
|
||||
|
||||
proc hash_func*(s: string): string =
|
||||
# This should be Blake2s but it does not exist so substituting with Blake2b
|
||||
result = getBlake2b(s, 4, "")
|
||||
|
||||
proc get_addr*(pubkey: SkPublicKey): string =
|
||||
# TODO: Needs Spec
|
||||
result = getBlake2b(pubkey.toHexCompressed(), 4, "")
|
||||
result = hash_func(pubkey.toHexCompressed())
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user