make rounds number a constant

This commit is contained in:
poma 2019-11-02 04:33:19 +03:00
parent 9efab84e65
commit 7193655e49
2 changed files with 7 additions and 7 deletions

View File

@ -1,13 +1,13 @@
include "../node_modules/circomlib/circuits/mimcsponge.circom"; include "../node_modules/circomlib/circuits/mimcsponge.circom";
// Computes MiMC(left + right) // Computes MiMC(left + right)
template HashLeftRight(rounds) { template HashLeftRight() {
signal input left; signal input left;
signal input right; signal input right;
signal output hash; signal output hash;
component hasher = MiMCSponge(2, rounds, 1); component hasher = MiMCSponge(2, 220, 1);
hasher.ins[0] <== left; hasher.ins[0] <== left;
hasher.ins[1] <== right; hasher.ins[1] <== right;
hasher.k <== 0; hasher.k <== 0;
@ -43,7 +43,7 @@ template Selector() {
// Verifies that merkle proof is correct for given merkle root and a leaf // Verifies that merkle proof is correct for given merkle root and a leaf
// pathIndex input is an array of 0/1 selectors telling whether given pathElement is on the left or right side of merkle path // pathIndex input is an array of 0/1 selectors telling whether given pathElement is on the left or right side of merkle path
template MerkleTree(levels, rounds) { template MerkleTree(levels) {
signal input leaf; signal input leaf;
signal input root; signal input root;
signal private input pathElements[levels]; signal private input pathElements[levels];
@ -54,7 +54,7 @@ template MerkleTree(levels, rounds) {
for (var i = 0; i < levels; i++) { for (var i = 0; i < levels; i++) {
selectors[i] = Selector(); selectors[i] = Selector();
hashers[i] = HashLeftRight(rounds); hashers[i] = HashLeftRight();
selectors[i].pathElement <== pathElements[i]; selectors[i].pathElement <== pathElements[i];
selectors[i].pathIndex <== pathIndex[i]; selectors[i].pathIndex <== pathIndex[i];

View File

@ -27,7 +27,7 @@ template CommitmentHasher() {
} }
// Verifies that commitment that corresponds to given secret and nullifier is included in the merkle tree of deposits // Verifies that commitment that corresponds to given secret and nullifier is included in the merkle tree of deposits
template Withdraw(levels, rounds) { template Withdraw(levels) {
signal input root; signal input root;
signal input nullifierHash; signal input nullifierHash;
signal input receiver; // not taking part in any computations signal input receiver; // not taking part in any computations
@ -45,7 +45,7 @@ template Withdraw(levels, rounds) {
nullifierHash === hasher.nullifierHash; nullifierHash === hasher.nullifierHash;
component tree = MerkleTree(levels, rounds); component tree = MerkleTree(levels);
tree.leaf <== hasher.commitment; tree.leaf <== hasher.commitment;
tree.root <== root; tree.root <== root;
for (var i = 0; i < levels; i++) { for (var i = 0; i < levels; i++) {
@ -54,4 +54,4 @@ template Withdraw(levels, rounds) {
} }
} }
component main = Withdraw(16, 220); component main = Withdraw(16);