mirror of
https://github.com/codex-storage/nim-poseidon2.git
synced 2025-02-23 16:28:07 +00:00
19 lines
480 B
Nim
19 lines
480 B
Nim
import ./types
|
|
import constantine/math/arithmetic
|
|
import constantine/math/io/io_bigints
|
|
|
|
func 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..<min(i + chunkLen, bytes.len)]
|
|
let bigint = B.unmarshal(chunk, endian)
|
|
let element = F.fromBig(bigint)
|
|
elements.add(element)
|
|
i += chunkLen
|
|
return elements
|