Skip to content

Commit

Permalink
Merge pull request privacy-scaling-explorations#1423 from privacy-sca…
Browse files Browse the repository at this point in the history
…ling-explorations/refactor/simplify-circuit

refactor(circuits): simplify generatePathIndices templates
  • Loading branch information
0xmad authored May 3, 2024
2 parents 8e9f7d2 + 2ee32f4 commit 28e41e2
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 12 deletions.
6 changes: 0 additions & 6 deletions circuits/circom/trees/incrementalMerkleTree.circom
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,16 @@ template MerkleGeneratePathIndices(levels) {

signal input in;
signal output out[levels];
signal n[levels + 1];

var m = in;
var computedResults[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;
Expand Down
6 changes: 0 additions & 6 deletions circuits/circom/trees/incrementalQuinaryTree.circom
Original file line number Diff line number Diff line change
Expand Up @@ -199,22 +199,16 @@ template QuinGeneratePathIndices(levels) {

signal input in;
signal output out[levels];
signal n[levels + 1];

var m = in;
var computedResults[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;
Expand Down

0 comments on commit 28e41e2

Please sign in to comment.