mirror of
https://github.com/tornadocash/tornado-relayer.git
synced 2025-08-15 01:25:33 -04:00
single array proof
This commit is contained in:
parent
45414ae010
commit
9449e2a8b6
2 changed files with 8 additions and 25 deletions
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…
Add table
Add a link
Reference in a new issue