From 2040166c5856b3ea3b0690c2d0030fd7535a5f85 Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Thu, 9 Nov 2023 10:20:10 +0100 Subject: [PATCH] Fix merkle root of odd number of elements --- poseidon2.nim | 17 ++++++++--------- tests/poseidon2/testPoseidon2.nim | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/poseidon2.nim b/poseidon2.nim index 261879b..50ac201 100644 --- a/poseidon2.nim +++ b/poseidon2.nim @@ -85,17 +85,16 @@ func merkleRoot*(xs: openArray[F]) : F = let n : int = 2*halfn let isOdd : bool = (n != m) - var ys : seq[F] = newSeq[F](halfn) - + var ys : seq[F] if not isOdd: - for i in 0..