diff --git a/src/conversations/private_v1.nim b/src/conversations/private_v1.nim index 7095f8e..de831a7 100644 --- a/src/conversations/private_v1.nim +++ b/src/conversations/private_v1.nim @@ -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) diff --git a/src/utils.nim b/src/utils.nim index 1456452..4ac5555 100644 --- a/src/utils.nim +++ b/src/utils.nim @@ -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()) + +