mirror of
https://github.com/logos-storage/nim-poseidon2.git
synced 2026-01-08 00:23:11 +00:00
Test merkleRoot() against reference
Co-Authored-By: Balazs Komuves <bkomuves@gmail.com>
This commit is contained in:
parent
4668f09496
commit
e19a08e6c3
@ -1,6 +1,7 @@
|
||||
import std/unittest
|
||||
import std/math
|
||||
import std/strutils
|
||||
import std/sequtils
|
||||
|
||||
import constantine/math/arithmetic
|
||||
import constantine/math/io/io_fields
|
||||
@ -31,9 +32,14 @@ suite "poseidon2":
|
||||
xs.add( toF(i) )
|
||||
|
||||
let root = merkleRoot(xs)
|
||||
check toHex(root) == "0x1eabbb64b76d5aecd393601c4a01878450e23f45fe8b2748bb63a615351b11d1"
|
||||
check root.toHex == "0x1eabbb64b76d5aecd393601c4a01878450e23f45fe8b2748bb63a615351b11d1"
|
||||
|
||||
test "merkle root of bytes":
|
||||
let bytes = toSeq 1'u8..80'u8
|
||||
let root = merkleRoot(bytes)
|
||||
check root.toHex == "0x2d2d6f27d20a9e5597e20a888a4deac0e0600f92f0b9691ace0fdfab2fc1f500"
|
||||
|
||||
test "merkle root converts every 31 bytes to a field element":
|
||||
let hex = [ # 31 bytes per field element
|
||||
"000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E",
|
||||
"1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user