mirror of
https://github.com/tornadocash/tornado-relayer.git
synced 2024-10-01 08:25:37 -04:00
single array proof
This commit is contained in:
parent
45414ae010
commit
9449e2a8b6
6
index.js
6
index.js
@ -52,7 +52,7 @@ app.post('/relay', async (req, resp) => {
|
||||
return resp.status(400).json({ error: 'This relayer does not support the token' })
|
||||
}
|
||||
|
||||
let { pi_a, pi_b, pi_c, publicSignals } = req.body.proof
|
||||
let { proof, publicSignals } = req.body.proof
|
||||
|
||||
const relayer = toChecksumAddress(`0x${publicSignals[3].slice(26)}`)
|
||||
if (relayer !== web3.eth.defaultAccount) {
|
||||
@ -95,8 +95,8 @@ app.post('/relay', async (req, resp) => {
|
||||
if (!isKnownRoot) {
|
||||
return resp.status(400).json({ error: 'The merkle root is too old or invalid.' })
|
||||
}
|
||||
const gas = await mixer.methods.withdraw(pi_a, pi_b, pi_c, publicSignals).estimateGas({ value: refund })
|
||||
const result = mixer.methods.withdraw(pi_a, pi_b, pi_c, publicSignals).send({
|
||||
const gas = await mixer.methods.withdraw(proof, publicSignals).estimateGas({ value: refund })
|
||||
const result = mixer.methods.withdraw(proof, publicSignals).send({
|
||||
value: refund,
|
||||
gas: numberToHex(gas + 50000),
|
||||
gasPrice: toHex(toWei(gasPrices.fast.toString(), 'gwei')),
|
||||
|
27
utils.js
27
utils.js
@ -45,42 +45,25 @@ async function fetchDAIprice({ ethPriceInDai, web3 }) {
|
||||
function isValidProof(proof) {
|
||||
// validator expects `websnarkUtils.toSolidityInput(proof)` output
|
||||
|
||||
if (!(proof.pi_a && proof.pi_b && proof.pi_c && proof.publicSignals)) {
|
||||
return { valid: false, reason: 'One of inputs is empty. There must be pi_a, pi_b, pi_c and publicSignals' }
|
||||
if (!(proof.proof && proof.publicSignals)) {
|
||||
return { valid: false, reason: 'One of inputs is empty. There must be proof and publicSignals' }
|
||||
}
|
||||
|
||||
Object.keys(proof).forEach(key => {
|
||||
if (!Array.isArray(proof[key])) {
|
||||
return { valid: false, reason: `Corrupted ${key}` }
|
||||
}
|
||||
if (key === 'pi_b') {
|
||||
if (!Array.isArray(proof[key][0]) || !Array.isArray(proof[key][1])) {
|
||||
return { valid: false, reason: `Corrupted ${key}` }
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if (proof.pi_a.length !== 2) {
|
||||
return { valid: false, reason: 'Corrupted pi_a' }
|
||||
if (proof.proof.length !== 8) {
|
||||
return { valid: false, reason: 'Corrupted proof' }
|
||||
}
|
||||
|
||||
if (proof.pi_b.length !== 2 || proof.pi_b[0].length !== 2 || proof.pi_b[1].length !== 2) {
|
||||
return { valid: false, reason: 'Corrupted pi_b' }
|
||||
}
|
||||
|
||||
if (proof.pi_c.length !== 2) {
|
||||
return { valid: false, reason: 'Corrupted pi_c' }
|
||||
}
|
||||
|
||||
if (proof.publicSignals.length !== 5) {
|
||||
if (proof.publicSignals.length !== 6) {
|
||||
return { valid: false, reason: 'Corrupted publicSignals' }
|
||||
}
|
||||
|
||||
for (let [key, input] of Object.entries(proof)) {
|
||||
if (key === 'pi_b') {
|
||||
input = input[0].concat(input[1])
|
||||
}
|
||||
|
||||
for (let i = 0; i < input.length; i++ ) {
|
||||
if (!isHexStrict(input[i]) || input[i].length !== 66) {
|
||||
return { valid: false, reason: `Corrupted ${key}` }
|
||||
|
Loading…
Reference in New Issue
Block a user