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

@@ -19,14 +19,16 @@ exports.randBigInt = () => {
return Fr.random();
};
exports.calcCommitment = (secret, nullifier) => {
exports.calcCommitment = (key, secret) => {
const poseidon = circomlib.poseidon.createHash(6, 8, 57);
const nullifier = poseidon([key, secret]).toString();
const commitment = poseidon([coinCode, amount, secret, nullifier]).toString();
return commitment;
};
exports.calcDepositWitness = async (wasm, secret, nullifier, commitments, key) => {
exports.calcDepositWitness = async (wasm, key, secret, commitments) => {
const poseidon = circomlib.poseidon.createHash(6, 8, 57);
const nullifier = poseidon([key, secret]).toString();
const commitment = poseidon([coinCode, amount, secret, nullifier]).toString();
console.log("PROVA", poseidon([key, commitment]).toString());
@@ -118,8 +120,9 @@ exports.calcDepositWitness = async (wasm, secret, nullifier, commitments, key) =
};
}
exports.calcWithdrawWitness = async (wasm, secret, nullifier, commitments, addr, key) => {
exports.calcWithdrawWitness = async (wasm, key, secret, commitments, addr) => {
const poseidon = circomlib.poseidon.createHash(6, 8, 57);
const nullifier = poseidon([key, secret]).toString();
const commitment = poseidon([coinCode, amount, secret, nullifier]).toString();
// rebuild the tree