isolate hash func

This commit is contained in:
Jazz Turner-Baggs 2025-07-11 15:43:19 -07:00
parent e834704a89
commit 7ea9dd084d
2 changed files with 8 additions and 3 deletions

View File

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

View File

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