|
@ -61,7 +61,7 @@ module.exports={ |
|
|
"_args": [ |
|
|
"_args": [ |
|
|
[ |
|
|
[ |
|
|
"@web3-js/websocket@1.0.30", |
|
|
"@web3-js/websocket@1.0.30", |
|
|
"/home/user/git/miksi/miksi-core" |
|
|
|
|
|
|
|
|
"/home/nicebox/miksi/miksi-core" |
|
|
] |
|
|
] |
|
|
], |
|
|
], |
|
|
"_from": "@web3-js/websocket@1.0.30", |
|
|
"_from": "@web3-js/websocket@1.0.30", |
|
@ -86,7 +86,7 @@ module.exports={ |
|
|
], |
|
|
], |
|
|
"_resolved": "https://registry.npmjs.org/@web3-js/websocket/-/websocket-1.0.30.tgz", |
|
|
"_resolved": "https://registry.npmjs.org/@web3-js/websocket/-/websocket-1.0.30.tgz", |
|
|
"_spec": "1.0.30", |
|
|
"_spec": "1.0.30", |
|
|
"_where": "/home/user/git/miksi/miksi-core", |
|
|
|
|
|
|
|
|
"_where": "/home/nicebox/miksi/miksi-core", |
|
|
"author": { |
|
|
"author": { |
|
|
"name": "Brian McKelvey", |
|
|
"name": "Brian McKelvey", |
|
|
"email": "theturtle32@gmail.com", |
|
|
"email": "theturtle32@gmail.com", |
|
@ -27405,7 +27405,7 @@ module.exports={ |
|
|
"_args": [ |
|
|
"_args": [ |
|
|
[ |
|
|
[ |
|
|
"elliptic@6.5.2", |
|
|
"elliptic@6.5.2", |
|
|
"/home/user/git/miksi/miksi-core" |
|
|
|
|
|
|
|
|
"/home/nicebox/miksi/miksi-core" |
|
|
] |
|
|
] |
|
|
], |
|
|
], |
|
|
"_from": "elliptic@6.5.2", |
|
|
"_from": "elliptic@6.5.2", |
|
@ -27434,7 +27434,7 @@ module.exports={ |
|
|
], |
|
|
], |
|
|
"_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.2.tgz", |
|
|
"_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.2.tgz", |
|
|
"_spec": "6.5.2", |
|
|
"_spec": "6.5.2", |
|
|
"_where": "/home/user/git/miksi/miksi-core", |
|
|
|
|
|
|
|
|
"_where": "/home/nicebox/miksi/miksi-core", |
|
|
"author": { |
|
|
"author": { |
|
|
"name": "Fedor Indutny", |
|
|
"name": "Fedor Indutny", |
|
|
"email": "fedor@indutny.com" |
|
|
"email": "fedor@indutny.com" |
|
@ -75059,7 +75059,7 @@ module.exports={ |
|
|
"_args": [ |
|
|
"_args": [ |
|
|
[ |
|
|
[ |
|
|
"web3@1.2.7", |
|
|
"web3@1.2.7", |
|
|
"/home/user/git/miksi/miksi-core" |
|
|
|
|
|
|
|
|
"/home/nicebox/miksi/miksi-core" |
|
|
] |
|
|
] |
|
|
], |
|
|
], |
|
|
"_from": "web3@1.2.7", |
|
|
"_from": "web3@1.2.7", |
|
@ -75084,7 +75084,7 @@ module.exports={ |
|
|
], |
|
|
], |
|
|
"_resolved": "https://registry.npmjs.org/web3/-/web3-1.2.7.tgz", |
|
|
"_resolved": "https://registry.npmjs.org/web3/-/web3-1.2.7.tgz", |
|
|
"_spec": "1.2.7", |
|
|
"_spec": "1.2.7", |
|
|
"_where": "/home/user/git/miksi/miksi-core", |
|
|
|
|
|
|
|
|
"_where": "/home/nicebox/miksi/miksi-core", |
|
|
"author": { |
|
|
"author": { |
|
|
"name": "ethereum.org" |
|
|
"name": "ethereum.org" |
|
|
}, |
|
|
}, |
|
@ -76310,25 +76310,28 @@ exports.calcCommitment = (secret, nullifier) => { |
|
|
return commitment; |
|
|
return commitment; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
exports.calcDepositWitness = async (wasm, secret, nullifier, commitments) => { |
|
|
|
|
|
|
|
|
exports.calcDepositWitness = async (wasm, secret, nullifier, commitments, key) => { |
|
|
const poseidon = circomlib.poseidon.createHash(6, 8, 57); |
|
|
const poseidon = circomlib.poseidon.createHash(6, 8, 57); |
|
|
const commitment = poseidon([coinCode, amount, secret, nullifier]).toString(); |
|
|
const commitment = poseidon([coinCode, amount, secret, nullifier]).toString(); |
|
|
|
|
|
|
|
|
// rebuild the tree
|
|
|
// rebuild the tree
|
|
|
let tree = await smt.newMemEmptyTrie(); |
|
|
let tree = await smt.newMemEmptyTrie(); |
|
|
await tree.insert(1, 0); |
|
|
|
|
|
|
|
|
await tree.insert(0, 0); |
|
|
for (let i=0; i<commitments.length; i++) { |
|
|
for (let i=0; i<commitments.length; i++) { |
|
|
await tree.insert(commitments[i], 0); |
|
|
|
|
|
|
|
|
await tree.insert(i+1, commitments[i]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// old root
|
|
|
// old root
|
|
|
const rootOld = tree.root; |
|
|
const rootOld = tree.root; |
|
|
const resOld = await tree.find(commitment); |
|
|
const resOld = await tree.find(commitment); |
|
|
let oldKey = "0"; |
|
|
let oldKey = "0"; |
|
|
|
|
|
let oldValue = "0"; |
|
|
if (!resOld.found) { |
|
|
if (!resOld.found) { |
|
|
oldKey = resOld.notFoundKey.toString(); |
|
|
oldKey = resOld.notFoundKey.toString(); |
|
|
|
|
|
oldValue = resOld.notFoundValue.toString(); |
|
|
} |
|
|
} |
|
|
console.log("oldKey", oldKey); |
|
|
console.log("oldKey", oldKey); |
|
|
|
|
|
console.log("oldValue", oldValue); |
|
|
// if (resOld.found) {
|
|
|
// if (resOld.found) {
|
|
|
// console.error("leaf expect to not exist but exists");
|
|
|
// console.error("leaf expect to not exist but exists");
|
|
|
// }
|
|
|
// }
|
|
@ -76337,13 +76340,13 @@ exports.calcDepositWitness = async (wasm, secret, nullifier, commitments) => { |
|
|
siblingsOld.push("0"); |
|
|
siblingsOld.push("0"); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
await tree.insert(commitment, 0); |
|
|
|
|
|
|
|
|
await tree.insert(key, commitment); |
|
|
|
|
|
|
|
|
// new root
|
|
|
// new root
|
|
|
const rootNew = tree.root; |
|
|
const rootNew = tree.root; |
|
|
const resNew = await tree.find(commitment); |
|
|
|
|
|
|
|
|
const resNew = await tree.find(key); |
|
|
if (!resNew.found) { |
|
|
if (!resNew.found) { |
|
|
console.error("leaf expect to exist but not exists"); |
|
|
|
|
|
|
|
|
console.error("leaf with the new commitment expect to exist but not exists"); |
|
|
} |
|
|
} |
|
|
let siblingsNew = resNew.siblings; |
|
|
let siblingsNew = resNew.siblings; |
|
|
while (siblingsNew.length < nLevels) { |
|
|
while (siblingsNew.length < nLevels) { |
|
@ -76357,11 +76360,13 @@ exports.calcDepositWitness = async (wasm, secret, nullifier, commitments) => { |
|
|
"secret": secret, |
|
|
"secret": secret, |
|
|
"nullifier": nullifier, |
|
|
"nullifier": nullifier, |
|
|
"oldKey": oldKey, |
|
|
"oldKey": oldKey, |
|
|
|
|
|
"oldValue": oldValue, |
|
|
"siblingsOld": siblingsOld, |
|
|
"siblingsOld": siblingsOld, |
|
|
"siblingsNew": siblingsNew, |
|
|
"siblingsNew": siblingsNew, |
|
|
"rootOld": rootOld, |
|
|
"rootOld": rootOld, |
|
|
"rootNew": rootNew, |
|
|
"rootNew": rootNew, |
|
|
"commitment": commitment |
|
|
|
|
|
|
|
|
"commitment": commitment, |
|
|
|
|
|
"key": key |
|
|
}); |
|
|
}); |
|
|
console.log("input", input); |
|
|
console.log("input", input); |
|
|
// const options = {};
|
|
|
// const options = {};
|
|
@ -76394,23 +76399,23 @@ exports.calcDepositWitness = async (wasm, secret, nullifier, commitments) => { |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
exports.calcWithdrawWitness = async (wasm, secret, nullifier, commitments, addr) => { |
|
|
|
|
|
|
|
|
exports.calcWithdrawWitness = async (wasm, secret, nullifier, commitments, addr, key) => { |
|
|
const poseidon = circomlib.poseidon.createHash(6, 8, 57); |
|
|
const poseidon = circomlib.poseidon.createHash(6, 8, 57); |
|
|
const commitment = poseidon([coinCode, amount, secret, nullifier]).toString(); |
|
|
const commitment = poseidon([coinCode, amount, secret, nullifier]).toString(); |
|
|
|
|
|
|
|
|
// rebuild the tree
|
|
|
// rebuild the tree
|
|
|
let tree = await smt.newMemEmptyTrie(); |
|
|
let tree = await smt.newMemEmptyTrie(); |
|
|
await tree.insert(1, 0); |
|
|
|
|
|
|
|
|
await tree.insert(0, 0); |
|
|
for (let i=0; i<commitments.length; i++) { |
|
|
for (let i=0; i<commitments.length; i++) { |
|
|
await tree.insert(commitments[i], 0); |
|
|
|
|
|
|
|
|
await tree.insert(i+1, commitments[i]); |
|
|
} |
|
|
} |
|
|
// await tree.insert(commitment, 0);
|
|
|
// await tree.insert(commitment, 0);
|
|
|
|
|
|
|
|
|
// root
|
|
|
// root
|
|
|
const root = tree.root; |
|
|
const root = tree.root; |
|
|
const res = await tree.find(commitment); |
|
|
|
|
|
|
|
|
const res = await tree.find(key); |
|
|
if (!res.found) { |
|
|
if (!res.found) { |
|
|
console.error("leaf expect to exist but not exists"); |
|
|
|
|
|
|
|
|
console.error("leaf expect to exist but not exists, key:", key); |
|
|
} |
|
|
} |
|
|
let siblings = res.siblings; |
|
|
let siblings = res.siblings; |
|
|
while (siblings.length < nLevels) { |
|
|
while (siblings.length < nLevels) { |
|
@ -76425,7 +76430,8 @@ exports.calcWithdrawWitness = async (wasm, secret, nullifier, commitments, addr) |
|
|
"nullifier": nullifier, |
|
|
"nullifier": nullifier, |
|
|
"siblings": siblings, |
|
|
"siblings": siblings, |
|
|
"root": root, |
|
|
"root": root, |
|
|
"address": addr |
|
|
|
|
|
|
|
|
"address": addr, |
|
|
|
|
|
"key": key |
|
|
}); |
|
|
}); |
|
|
console.log("input", input); |
|
|
console.log("input", input); |
|
|
// const options = {};
|
|
|
// const options = {};
|
|
|