mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-07 00:13:06 +00:00
chore(rln-relay): bump zerokit and update ffi (#1571)
fix(chat2): compilation
This commit is contained in:
parent
111b2a0d6d
commit
577cdf030b
@ -117,7 +117,7 @@ proc toString*(message: Chat2Message): string =
|
|||||||
|
|
||||||
# Similarly as Status public chats now.
|
# Similarly as Status public chats now.
|
||||||
proc generateSymKey(contentTopic: ContentTopic): SymKey =
|
proc generateSymKey(contentTopic: ContentTopic): SymKey =
|
||||||
var ctx: HMAC[sha256]
|
var ctx: HMAC[pbkdf2.sha256]
|
||||||
var symKey: SymKey
|
var symKey: SymKey
|
||||||
if pbkdf2(ctx, contentTopic.toBytes(), "", 65356, symKey) != sizeof(SymKey):
|
if pbkdf2(ctx, contentTopic.toBytes(), "", 65356, symKey) != sizeof(SymKey):
|
||||||
raise (ref Defect)(msg: "Should not occur as array is properly sized")
|
raise (ref Defect)(msg: "Should not occur as array is properly sized")
|
||||||
|
|||||||
@ -403,8 +403,8 @@ suite "Waku rln relay":
|
|||||||
# prepare other inputs to the hash function
|
# prepare other inputs to the hash function
|
||||||
let outputBuffer = default(Buffer)
|
let outputBuffer = default(Buffer)
|
||||||
|
|
||||||
let hashSuccess = hash(rlnInstance.get(), unsafeAddr hashInputBuffer,
|
let hashSuccess = sha256(unsafeAddr hashInputBuffer,
|
||||||
unsafeAddr outputBuffer)
|
unsafeAddr outputBuffer)
|
||||||
require:
|
require:
|
||||||
hashSuccess
|
hashSuccess
|
||||||
let outputArr = cast[ptr array[32, byte]](outputBuffer.`ptr`)[]
|
let outputArr = cast[ptr array[32, byte]](outputBuffer.`ptr`)[]
|
||||||
@ -429,7 +429,7 @@ suite "Waku rln relay":
|
|||||||
# prepare the input
|
# prepare the input
|
||||||
let msg = "Hello".toBytes()
|
let msg = "Hello".toBytes()
|
||||||
|
|
||||||
let hash = rln.hash(msg)
|
let hash = sha256(msg)
|
||||||
|
|
||||||
check:
|
check:
|
||||||
"1e32b3ab545c07c8b4a7ab1ca4f46bc31e4fdc29ac3b240ef1d54b4017a26e4c" ==
|
"1e32b3ab545c07c8b4a7ab1ca4f46bc31e4fdc29ac3b240ef1d54b4017a26e4c" ==
|
||||||
|
|||||||
2
vendor/zerokit
vendored
2
vendor/zerokit
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 005393d69606d2893c9b2b7aed506d1920472688
|
Subproject commit a6145ab2012a1e9b6bdd08963d6e1db09f06c88d
|
||||||
@ -151,11 +151,20 @@ proc new_circuit_from_data*(tree_height: uint, circom_buffer: ptr Buffer, zkey_b
|
|||||||
## ctx holds the final created rln object
|
## ctx holds the final created rln object
|
||||||
## the return bool value indicates the success or failure of the operation
|
## the return bool value indicates the success or failure of the operation
|
||||||
|
|
||||||
proc hash*(ctx: ptr RLN,
|
#-------------------------------- Hashing utils -------------------------------------------
|
||||||
input_buffer: ptr Buffer,
|
|
||||||
output_buffer: ptr Buffer): bool {.importc: "hash".}
|
proc sha256*(input_buffer: ptr Buffer,
|
||||||
|
output_buffer: ptr Buffer): bool {.importc: "hash".}
|
||||||
## it hashes (sha256) the plain text supplied in inputs_buffer and then maps it to a field element
|
## it hashes (sha256) the plain text supplied in inputs_buffer and then maps it to a field element
|
||||||
## this proc is used to map arbitrary signals to field element for the sake of proof generation
|
## this proc is used to map arbitrary signals to field element for the sake of proof generation
|
||||||
## inputs_buffer holds the hash input as a byte seq
|
## inputs_buffer holds the hash input as a byte seq
|
||||||
## the hash output is generated and populated inside output_buffer
|
## the hash output is generated and populated inside output_buffer
|
||||||
## the output_buffer contains 32 bytes hash output
|
## the output_buffer contains 32 bytes hash output
|
||||||
|
|
||||||
|
proc poseidon*(input_buffer: ptr Buffer,
|
||||||
|
output_buffer: ptr Buffer): bool {.importc: "poseidon_hash".}
|
||||||
|
## it hashes (poseidon) the plain text supplied in inputs_buffer
|
||||||
|
## this proc is used to compute the identity secret hash, and external nullifier
|
||||||
|
## inputs_buffer holds the hash input as a byte seq
|
||||||
|
## the hash output is generated and populated inside output_buffer
|
||||||
|
## the output_buffer contains 32 bytes hash output
|
||||||
|
|||||||
@ -78,21 +78,21 @@ proc createRLNInstance*(d: int = MerkleTreeDepth): RLNResult =
|
|||||||
res = createRLNInstanceLocal(d)
|
res = createRLNInstanceLocal(d)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
proc hash*(rlnInstance: ptr RLN, data: openArray[byte]): MerkleNode =
|
proc sha256*(data: openArray[byte]): MerkleNode =
|
||||||
## a thin layer on top of the Nim wrapper of the Poseidon hasher
|
## a thin layer on top of the Nim wrapper of the sha256 hasher
|
||||||
debug "hash input", hashhex = data.toHex()
|
debug "sha256 hash input", hashhex = data.toHex()
|
||||||
var lenPrefData = appendLength(data)
|
var lenPrefData = appendLength(data)
|
||||||
var
|
var
|
||||||
hashInputBuffer = lenPrefData.toBuffer()
|
hashInputBuffer = lenPrefData.toBuffer()
|
||||||
outputBuffer: Buffer # will holds the hash output
|
outputBuffer: Buffer # will holds the hash output
|
||||||
|
|
||||||
debug "hash input buffer length", bufflen = hashInputBuffer.len
|
debug "sha256 hash input buffer length", bufflen = hashInputBuffer.len
|
||||||
let
|
let
|
||||||
hashSuccess = hash(rlnInstance, addr hashInputBuffer, addr outputBuffer)
|
hashSuccess = sha256(addr hashInputBuffer, addr outputBuffer)
|
||||||
|
|
||||||
# check whether the hash call is done successfully
|
# check whether the hash call is done successfully
|
||||||
if not hashSuccess:
|
if not hashSuccess:
|
||||||
debug "error in hash"
|
debug "error in sha256 hash"
|
||||||
return default(MerkleNode)
|
return default(MerkleNode)
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user