diff --git a/poseidon2/merkle.nim b/poseidon2/merkle.nim index fe18210..0c4465f 100644 --- a/poseidon2/merkle.nim +++ b/poseidon2/merkle.nim @@ -1,10 +1,16 @@ import std/sequtils import constantine/math/arithmetic +import constantine/math/io/io_fields import ./types import ./io import ./compress -func merkleRoot*(xs: openArray[F]) : F = +const KeyNone = F.fromHex("0x0") +const KeyBottomLayer = F.fromHex("0x1") +const KeyOdd = F.fromHex("0x2") +const KeyOddAndBottomLayer = F.fromhex("0x3") + +func merkleRoot*(xs: openArray[F], isBottomLayer: static bool = true) : F = let a = low(xs) let b = high(xs) let m = b-a+1 @@ -24,11 +30,13 @@ func merkleRoot*(xs: openArray[F]) : F = ys = newSeq[F](halfn+1) for i in 0..