voting notes merkle tree

This commit is contained in:
Oskar Thoren 2019-11-02 16:22:26 +08:00
parent aaf9dd2b8b
commit 6f4721dab8
No known key found for this signature in database
GPG Key ID: B2ECCFD3BC2EF77E

View File

@ -420,9 +420,6 @@ function untrustedVerify(proof, publicSignals) {
// "With same external nullifier more than once" // "With same external nullifier more than once"
let vote_token = BigInt(12312); let vote_token = BigInt(12312);
// TODO: Ensure part of merkle tree
// TODO: Signal again
try { try {
assert(external_nullifier == vote_token, "Wrong token!"); assert(external_nullifier == vote_token, "Wrong token!");
assert(verifyProofWithKey(proof, publicSignals)); assert(verifyProofWithKey(proof, publicSignals));
@ -442,10 +439,24 @@ async function voteTesting() {
//assert(await votingExample(BigInt(12312), "I vote for B") == false); //assert(await votingExample(BigInt(12312), "I vote for B") == false);
// TODO: Bad identity, this requires constructing 'untrusted' tree and verifying // TODO: Bad identity, this requires constructing 'untrusted' tree and verifying
// root and nullifier hash (I believe) // TODO: To check for bad identity, we can simple reconstruct tree with:
// identity commitment and path
// Then merkle root has to match, and ZKP proves you are part of that
// tree with that root
// ...what does this mean if we add/leave network? need to update /
// allow slack
} catch(err) { } catch(err) {
console.log("Oops, no good", err); console.log("Oops, no good", err);
} }
}; };
voteTesting(); voteTesting();
// // test merkle tree, untrusted pov
// let identity = loadIdentity("17939861921584559533262186509737425990469800861754459917147159747570381958900");
// let commitment = identity.identity_commitment;
// let tree = MakeMerkleTree();
// let path = updateTreeAndGetPath(tree, 1, identity.identity_commitment);
// root = merkle_root
// is_valid(proof)
// enough to show that identity is part of merkle tree at some specific position