Add circuit siblings check

This commit is contained in:
arnaucube
2020-05-18 21:58:22 +02:00
parent 6a513ded87
commit da7cac076e
5 changed files with 51 additions and 27 deletions

View File

@@ -29,6 +29,8 @@ exports.calcDepositWitness = async (wasm, secret, nullifier, commitments, key) =
const poseidon = circomlib.poseidon.createHash(6, 8, 57);
const commitment = poseidon([coinCode, amount, secret, nullifier]).toString();
console.log("PROVA", poseidon([key, commitment]).toString());
// rebuild the tree
let tree = await smt.newMemEmptyTrie();
await tree.insert(0, 0);
@@ -39,6 +41,7 @@ exports.calcDepositWitness = async (wasm, secret, nullifier, commitments, key) =
// old root
const rootOld = tree.root;
const resOld = await tree.find(commitment);
console.log("FIND old", resOld);
let oldKey = "0";
let oldValue = "0";
if (!resOld.found) {
@@ -60,6 +63,7 @@ exports.calcDepositWitness = async (wasm, secret, nullifier, commitments, key) =
// new root
const rootNew = tree.root;
const resNew = await tree.find(key);
console.log("FIND new", resNew);
if (!resNew.found) {
console.error("leaf with the new commitment expect to exist but not exists");
}