mirror of
https://github.com/logos-storage/nim-poseidon2.git
synced 2026-01-03 06:03:10 +00:00
convert visual inspection tests to unit tests
This commit is contained in:
parent
b72c92639b
commit
f73bce6aa1
@ -1,4 +1,4 @@
|
||||
|
||||
import std/unittest
|
||||
import std/math
|
||||
|
||||
import constantine/math/io/io_fields
|
||||
@ -7,28 +7,26 @@ import constantine/math/config/curves
|
||||
import poseidon2/types
|
||||
import poseidon2
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
suite "poseidon2":
|
||||
|
||||
var x: F = toF(0)
|
||||
var y: F = toF(1)
|
||||
var z: F = toF(2)
|
||||
test "permutation in place":
|
||||
var x: F = toF(0)
|
||||
var y: F = toF(1)
|
||||
var z: F = toF(2)
|
||||
|
||||
perm_inplace(x, y, z)
|
||||
perm_inplace(x, y, z)
|
||||
|
||||
echo "\npermutation of (0,1,2):"
|
||||
echo( toDecimal(x) )
|
||||
echo( toDecimal(y) )
|
||||
echo( toDecimal(z) )
|
||||
check toDecimal(x) == "21882471761025344482456282050943515707267606647948403374880378562101343146243"
|
||||
check toDecimal(y) == "09030699330013392132529464674294378792132780497765201297316864012141442630280"
|
||||
check toDecimal(z) == "09137931384593657624554037900714196568304064431583163402259937475584578975855"
|
||||
|
||||
#---------------------------------------
|
||||
test "merkle root":
|
||||
let m = 17
|
||||
let n = 2^m
|
||||
var xs: seq[F]
|
||||
for i in 1..n:
|
||||
xs.add( toF(i) )
|
||||
|
||||
let m = 17
|
||||
let n = 2^m
|
||||
var xs: seq[F]
|
||||
for i in 1..n:
|
||||
xs.add( toF(i) )
|
||||
|
||||
echo("\nmerkle root of ",1,"..",n,":")
|
||||
let root = merkle_root(xs)
|
||||
echo( toHex(root) )
|
||||
let root = merkle_root(xs)
|
||||
check toHex(root) == "0x1eabbb64b76d5aecd393601c4a01878450e23f45fe8b2748bb63a615351b11d1"
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user