reduce nullifier bits to 31

This commit is contained in:
poma 2019-08-01 17:49:34 +03:00
parent e387025992
commit c7953ae2c6
No known key found for this signature in database
GPG key ID: 530BBEE4AE8C3604
3 changed files with 16 additions and 16 deletions

4
cli.js
View file

@ -21,7 +21,7 @@ const pedersenHash = (data) => circomlib.babyJub.unpackPoint(circomlib.pedersenH
function createDeposit(nullifier, secret) {
let deposit = { nullifier, secret }
deposit.preimage = Buffer.concat([deposit.nullifier.leInt2Buff(32), deposit.secret.leInt2Buff(32)])
deposit.preimage = Buffer.concat([deposit.nullifier.leInt2Buff(31), deposit.secret.leInt2Buff(31)])
deposit.commitment = pedersenHash(deposit.preimage)
return deposit
}
@ -61,7 +61,7 @@ async function withdraw(note, receiver) {
})
const tree = new merkleTree(MERKLE_TREE_HEIGHT, EMPTY_ELEMENT, leaves)
const validRoot = await mixer.methods.isKnownRoot(await tree.root()).call()
const nullifierHash = pedersenHash(deposit.nullifier.leInt2Buff(32))
const nullifierHash = pedersenHash(deposit.nullifier.leInt2Buff(31))
const nullifierHashToCheck = nullifierHash.toString(16).padStart('66', '0x000000')
const isSpent = await mixer.methods.isSpent(nullifierHashToCheck).call()
assert(validRoot === true)