Skip to content

Commit

Permalink
fix(incrementalquintree): remove unnecessary condition check in incre…
Browse files Browse the repository at this point in the history
…mentalQuinnTree.circom

fix(incrementalquintree): add range check for choices in incrementalQuinnTree.circom
  • Loading branch information
chaosma committed Feb 23, 2023
1 parent faa76ca commit 87b3397
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions circuits/circom/trees/incrementalQuinTree.circom
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 ++) {
Expand Down

0 comments on commit 87b3397

Please sign in to comment.