From 62d7a25ccbd4be65e567304b13cf25d1536fd937 Mon Sep 17 00:00:00 2001 From: Jordi Baylina Date: Wed, 7 Sep 2022 18:17:42 +0200 Subject: [PATCH] Fix circuit Zero linearhashes --- circuits.bn128/linearhash.circom | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/circuits.bn128/linearhash.circom b/circuits.bn128/linearhash.circom index d2c0cbfd..a15e9ed3 100644 --- a/circuits.bn128/linearhash.circom +++ b/circuits.bn128/linearhash.circom @@ -26,15 +26,20 @@ template LinearHash(nInputs, eSize) { nHashes = (nElements256 - 1)\16 +1; } - component hash[nHashes-1]; - var nLastHash = nElements256 - (nHashes - 1)*16; - component lastHash = PoseidonEx(nLastHash, 1); + component hash[nHashes>0 ? nHashes-1 : 0]; + var nLastHash; + component lastHash; for (var i=0; i0) { + nLastHash = nElements256 - (nHashes - 1)*16; + lastHash = PoseidonEx(nLastHash, 1); + } + var curHash =0; var curHashIdx = 0;