From 2ee32f470fb8d2dbb02bdea2769166754c480706 Mon Sep 17 00:00:00 2001 From: ctrlc03 <93448202+ctrlc03@users.noreply.github.com> Date: Fri, 3 May 2024 08:02:31 +0100 Subject: [PATCH] refactor(circuits): simplify generatePathIndices templates --- circuits/circom/trees/incrementalMerkleTree.circom | 6 ------ circuits/circom/trees/incrementalQuinaryTree.circom | 6 ------ 2 files changed, 12 deletions(-) diff --git a/circuits/circom/trees/incrementalMerkleTree.circom b/circuits/circom/trees/incrementalMerkleTree.circom index 2583211e16..36fcd05012 100644 --- a/circuits/circom/trees/incrementalMerkleTree.circom +++ b/circuits/circom/trees/incrementalMerkleTree.circom @@ -124,7 +124,6 @@ template MerkleGeneratePathIndices(levels) { signal input in; signal output out[levels]; - signal n[levels + 1]; var m = in; var computedResults[levels]; @@ -132,14 +131,9 @@ template MerkleGeneratePathIndices(levels) { for (var i = 0; i < levels; i++) { // circom's best practices suggests to avoid using <-- unless you // are aware of what's going on. This is the only way to do modulo operation. - n[i] <-- m; out[i] <-- m % BASE; m = m \ BASE; - } - - n[levels] <-- m; - for (var i = 0; i < levels; i++) { // Check that each output element is less than the base. var computedIsOutputElementLessThanBase = SafeLessThan(3)([out[i], BASE]); computedIsOutputElementLessThanBase === 1; diff --git a/circuits/circom/trees/incrementalQuinaryTree.circom b/circuits/circom/trees/incrementalQuinaryTree.circom index a4de305301..853ef5f245 100644 --- a/circuits/circom/trees/incrementalQuinaryTree.circom +++ b/circuits/circom/trees/incrementalQuinaryTree.circom @@ -199,7 +199,6 @@ template QuinGeneratePathIndices(levels) { signal input in; signal output out[levels]; - signal n[levels + 1]; var m = in; var computedResults[levels]; @@ -207,14 +206,9 @@ template QuinGeneratePathIndices(levels) { for (var i = 0; i < levels; i++) { // circom's best practices suggests to avoid using <-- unless you // are aware of what's going on. This is the only way to do modulo operation. - n[i] <-- m; out[i] <-- m % BASE; m = m \ BASE; - } - - n[levels] <-- m; - for (var i = 0; i < levels; i++) { // Check that each output element is less than the base. var computedIsOutputElementLessThanBase = SafeLessThan(3)([out[i], BASE]); computedIsOutputElementLessThanBase === 1;