From 87b339790a5d44adb8c5bf447346e16933c48d5c Mon Sep 17 00:00:00 2001 From: Chao Ma Date: Wed, 22 Feb 2023 12:03:16 +0800 Subject: [PATCH] fix(incrementalquintree): remove unnecessary condition check in incrementalQuinnTree.circom fix(incrementalquintree): add range check for choices in incrementalQuinnTree.circom --- circuits/circom/trees/incrementalQuinTree.circom | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/circuits/circom/trees/incrementalQuinTree.circom b/circuits/circom/trees/incrementalQuinTree.circom index d1fdbc5d22..b6f882d26f 100644 --- a/circuits/circom/trees/incrementalQuinTree.circom +++ b/circuits/circom/trees/incrementalQuinTree.circom @@ -1,4 +1,5 @@ pragma circom 2.0.0; +include "../../node_modules/circomlib/circuits/bitify.circom"; include "../../node_modules/circomlib/circuits/mux1.circom"; include "../../node_modules/circomlib/circuits/comparators.circom"; include "../hasherPoseidon.circom"; @@ -32,6 +33,9 @@ template QuinSelector(choices) { signal input index; signal output out; + // Ensure choices < 2^3 + component n2b = Num2Bits(3); + n2b.in <== choices; // Ensure that index < choices component lessThan = LessThan(3); lessThan.in[0] <== index; @@ -280,10 +284,6 @@ template QuinGeneratePathIndices(levels) { n[levels] <-- m; // Do a range check on each out[i] - for (var i = 1; i < levels + 1; i ++) { - n[i - 1] === n[i] * BASE + out[i-1]; - } - component leq[levels]; component sum = CalculateTotal(levels); for (var i = 0; i < levels; i ++) {