Add nullifier=H(key, secret)

This commit is contained in:
arnaucube
2020-05-24 00:32:53 +02:00
parent 9776f46e4b
commit a756810fc9
11 changed files with 103 additions and 77 deletions

View File

@@ -22,9 +22,10 @@ describe("deposit test", function () {
const coinCode = "0";
const amount = '1000000000000000000';
const nullifier = "567891234";
// const nullifier = "567891234";
const poseidon = circomlib.poseidon.createHash(6, 8, 57);
const nullifier = poseidon([2, secret]);
const commitment = poseidon([coinCode, amount, secret, nullifier]).toString();
// add commitment into SMT
@@ -33,7 +34,7 @@ describe("deposit test", function () {
// await tree.insert(2, 0);
let rootOld = tree.root;
let res = await tree.find(commitment);
let res = await tree.find(2);
// console.log(res);
assert(!res.found);
let siblingsOld = res.siblings;
@@ -60,7 +61,6 @@ describe("deposit test", function () {
"coinCode": coinCode,
"amount": amount,
"secret": secret,
"nullifier": nullifier,
"oldKey": "1",
"oldValue": "0",
"siblingsOld": siblingsOld,

View File

@@ -22,9 +22,10 @@ describe("withdraw test", function () {
const coinCode = "0";
const amount = '1000000000000000000';
const nullifier = "567891234";
// const nullifier = "567891234";
const poseidon = circomlib.poseidon.createHash(6, 8, 57);
const nullifier = poseidon([2, secret]);
const commitment = poseidon([coinCode, amount, secret, nullifier]).toString();
// add commitment into SMT

View File

@@ -22,7 +22,7 @@ const secret = ["1234567890", "987654321", "123"];
const coinCode = "0"; // refearing to ETH
const ethAmount = '1';
const amount = web3.utils.toWei(ethAmount, 'ether');
const nullifier = ["567891234", "432198765", "321"];
const nullifier = ["0", "0", "0"];
let commitment = [];
let tree;
let oldKey = [];
@@ -88,9 +88,7 @@ contract("miksi", (accounts) => {
it("Get the commitments data", async () => {
// getCommitments data
let res = await insMiksi.getCommitments();
expect(res[0][0].toString()).to.be.equal('189025084074544266465422070282645213792582195466360448472858620722286781863');
// expect(res[1].toString()).to.be.equal('9328869343897770565751281504295758914771207504252217956739346620422361279598');
console.log(res[0]);
expect(res[1].toString()).to.be.equal(tree.root.toString());
commitmentsArray[0] = res[0];
currKey = res[2];
});
@@ -155,6 +153,7 @@ contract("miksi", (accounts) => {
async function computeTree(u) {
const poseidon = circomlib.poseidon.createHash(6, 8, 57);
nullifier[u] = poseidon([currKey+1, secret[u]]).toString();
commitment[u] = poseidon([coinCode, amount, secret[u], nullifier[u]]).toString();
// deposit
@@ -197,7 +196,6 @@ async function makeDeposit(u, addr) {
"coinCode": coinCode,
"amount": amount,
"secret": secret[u],
"nullifier": nullifier[u],
"oldKey": oldKey[u],
"oldValue": oldValue[u],
"siblingsOld": siblingsOld[u],

View File

@@ -9,13 +9,13 @@ describe("deposit test", function () {
it("Test Deposit", async () => {
const secret = "1234567890";
const nullifier = "567891234";
const key = 1;
const commitments = [];
const wasm = await fs.promises.readFile("./build/deposit.wasm");
console.log("w", wasm.length);
const witness = await miksi.calcDepositWitness(wasm, secret, nullifier, commitments, 1);
const witness = await miksi.calcDepositWitness(wasm, key, secret, commitments);
// console.log("w", witness);