From 25878c88cf7d1fd61f51aed761fc99e1d696a225 Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Thu, 26 Oct 2023 14:39:27 +0200 Subject: [PATCH] Determine merkle root of byte arrays --- poseidon2.nim | 21 +++++++++++++++++---- poseidon2/types.nim | 16 ++++++++-------- tests/test.nim | 34 +++++++++++++++++++++++++++++++++- 3 files changed, 58 insertions(+), 13 deletions(-) diff --git a/poseidon2.nim b/poseidon2.nim index 3bef275..f750564 100644 --- a/poseidon2.nim +++ b/poseidon2.nim @@ -3,7 +3,7 @@ import constantine/math/arithmetic, - constantine/math/io/io_fields, + constantine/math/io/io_bigints, constantine/math/config/curves import poseidon2/types @@ -100,7 +100,20 @@ proc merkleRoot*(xs: openArray[F]) : F = return merkleRoot(ys) -#------------------------------------------------------------------------------- - - +proc unmarshal( + _: type F, + bytes: openArray[byte], + endian: static Endianness): seq[F] = + const chunkLen = 31 + var elements: seq[F] + var i = 0 + while i < bytes.len: + let chunk = bytes[i..