relayer init

This commit is contained in:
Alexey 2019-09-16 19:22:16 +03:00
parent b1244a87b4
commit 53828dca12
4 changed files with 123 additions and 8 deletions

@ -6,8 +6,8 @@ services:
restart: always restart: always
environment: environment:
NODE_ENV: production NODE_ENV: production
VIRTUAL_HOST: relayer.tornado.cash VIRTUAL_HOST: kovan.tornado.cash
LETSENCRYPT_HOST: relayer.tornado.cash LETSENCRYPT_HOST: kovan.tornado.cash
env_file: ./.env env_file: ./.env
monitor: monitor:

@ -38,6 +38,7 @@ app.get('/', function (req, res) {
}) })
app.post('/relay', async (req, resp) => { app.post('/relay', async (req, resp) => {
console.log(JSON.stringify(req.body, null, 2))
const { valid , reason } = isValidProof(req.body) const { valid , reason } = isValidProof(req.body)
if (!valid) { if (!valid) {
console.log('Proof is invalid:', reason) console.log('Proof is invalid:', reason)

@ -5,6 +5,7 @@
"name": "filled_subtrees", "name": "filled_subtrees",
"outputs": [ "outputs": [
{ {
"internalType": "uint256[]",
"name": "", "name": "",
"type": "uint256[]" "type": "uint256[]"
} }
@ -17,6 +18,7 @@
"constant": true, "constant": true,
"inputs": [ "inputs": [
{ {
"internalType": "uint256",
"name": "", "name": "",
"type": "uint256" "type": "uint256"
} }
@ -24,6 +26,7 @@
"name": "nullifierHashes", "name": "nullifierHashes",
"outputs": [ "outputs": [
{ {
"internalType": "bool",
"name": "", "name": "",
"type": "bool" "type": "bool"
} }
@ -35,11 +38,12 @@
{ {
"constant": true, "constant": true,
"inputs": [], "inputs": [],
"name": "transferValue", "name": "verifier",
"outputs": [ "outputs": [
{ {
"internalType": "contract IVerifier",
"name": "", "name": "",
"type": "uint256" "type": "address"
} }
], ],
"payable": false, "payable": false,
@ -52,6 +56,7 @@
"name": "roots", "name": "roots",
"outputs": [ "outputs": [
{ {
"internalType": "uint256[]",
"name": "", "name": "",
"type": "uint256[]" "type": "uint256[]"
} }
@ -64,6 +69,7 @@
"constant": true, "constant": true,
"inputs": [ "inputs": [
{ {
"internalType": "uint256",
"name": "", "name": "",
"type": "uint256" "type": "uint256"
} }
@ -71,6 +77,7 @@
"name": "commitments", "name": "commitments",
"outputs": [ "outputs": [
{ {
"internalType": "bool",
"name": "", "name": "",
"type": "bool" "type": "bool"
} }
@ -85,6 +92,7 @@
"name": "zeros", "name": "zeros",
"outputs": [ "outputs": [
{ {
"internalType": "uint256[]",
"name": "", "name": "",
"type": "uint256[]" "type": "uint256[]"
} }
@ -99,6 +107,7 @@
"name": "levels", "name": "levels",
"outputs": [ "outputs": [
{ {
"internalType": "uint256",
"name": "", "name": "",
"type": "uint256" "type": "uint256"
} }
@ -107,14 +116,46 @@
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{
"constant": true,
"inputs": [],
"name": "operator",
"outputs": [
{
"internalType": "address payable",
"name": "",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "isDepositsEnabled",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{ {
"constant": true, "constant": true,
"inputs": [ "inputs": [
{ {
"internalType": "uint256",
"name": "left", "name": "left",
"type": "uint256" "type": "uint256"
}, },
{ {
"internalType": "uint256",
"name": "right", "name": "right",
"type": "uint256" "type": "uint256"
} }
@ -122,6 +163,7 @@
"name": "hashLeftRight", "name": "hashLeftRight",
"outputs": [ "outputs": [
{ {
"internalType": "uint256",
"name": "mimc_hash", "name": "mimc_hash",
"type": "uint256" "type": "uint256"
} }
@ -136,6 +178,7 @@
"name": "next_index", "name": "next_index",
"outputs": [ "outputs": [
{ {
"internalType": "uint32",
"name": "", "name": "",
"type": "uint32" "type": "uint32"
} }
@ -150,6 +193,7 @@
"name": "current_root", "name": "current_root",
"outputs": [ "outputs": [
{ {
"internalType": "uint256",
"name": "", "name": "",
"type": "uint256" "type": "uint256"
} }
@ -162,6 +206,7 @@
"constant": true, "constant": true,
"inputs": [ "inputs": [
{ {
"internalType": "uint256",
"name": "root", "name": "root",
"type": "uint256" "type": "uint256"
} }
@ -169,6 +214,7 @@
"name": "isKnownRoot", "name": "isKnownRoot",
"outputs": [ "outputs": [
{ {
"internalType": "bool",
"name": "", "name": "",
"type": "bool" "type": "bool"
} }
@ -183,6 +229,22 @@
"name": "getLastRoot", "name": "getLastRoot",
"outputs": [ "outputs": [
{ {
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "mixDenomination",
"outputs": [
{
"internalType": "uint256",
"name": "", "name": "",
"type": "uint256" "type": "uint256"
} }
@ -194,20 +256,29 @@
{ {
"inputs": [ "inputs": [
{ {
"internalType": "address",
"name": "_verifier", "name": "_verifier",
"type": "address" "type": "address"
}, },
{ {
"name": "_transferValue", "internalType": "uint256",
"name": "_mixDenomination",
"type": "uint256" "type": "uint256"
}, },
{ {
"internalType": "uint8",
"name": "_merkleTreeHeight", "name": "_merkleTreeHeight",
"type": "uint8" "type": "uint8"
}, },
{ {
"internalType": "uint256",
"name": "_emptyElement", "name": "_emptyElement",
"type": "uint256" "type": "uint256"
},
{
"internalType": "address payable",
"name": "_operator",
"type": "address"
} }
], ],
"payable": false, "payable": false,
@ -219,16 +290,19 @@
"inputs": [ "inputs": [
{ {
"indexed": true, "indexed": true,
"internalType": "uint256",
"name": "commitment", "name": "commitment",
"type": "uint256" "type": "uint256"
}, },
{ {
"indexed": false, "indexed": false,
"internalType": "uint256",
"name": "leafIndex", "name": "leafIndex",
"type": "uint256" "type": "uint256"
}, },
{ {
"indexed": false, "indexed": false,
"internalType": "uint256",
"name": "timestamp", "name": "timestamp",
"type": "uint256" "type": "uint256"
} }
@ -241,16 +315,25 @@
"inputs": [ "inputs": [
{ {
"indexed": false, "indexed": false,
"internalType": "address",
"name": "to", "name": "to",
"type": "address" "type": "address"
}, },
{ {
"indexed": false, "indexed": false,
"internalType": "uint256",
"name": "nullifierHash", "name": "nullifierHash",
"type": "uint256" "type": "uint256"
}, },
{
"indexed": true,
"internalType": "address",
"name": "relayer",
"type": "address"
},
{ {
"indexed": false, "indexed": false,
"internalType": "uint256",
"name": "fee", "name": "fee",
"type": "uint256" "type": "uint256"
} }
@ -262,6 +345,7 @@
"constant": false, "constant": false,
"inputs": [ "inputs": [
{ {
"internalType": "uint256",
"name": "commitment", "name": "commitment",
"type": "uint256" "type": "uint256"
} }
@ -276,20 +360,24 @@
"constant": false, "constant": false,
"inputs": [ "inputs": [
{ {
"internalType": "uint256[2]",
"name": "a", "name": "a",
"type": "uint256[2]" "type": "uint256[2]"
}, },
{ {
"internalType": "uint256[2][2]",
"name": "b", "name": "b",
"type": "uint256[2][2]" "type": "uint256[2][2]"
}, },
{ {
"internalType": "uint256[2]",
"name": "c", "name": "c",
"type": "uint256[2]" "type": "uint256[2]"
}, },
{ {
"internalType": "uint256[5]",
"name": "input", "name": "input",
"type": "uint256[4]" "type": "uint256[5]"
} }
], ],
"name": "withdraw", "name": "withdraw",
@ -298,10 +386,35 @@
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
}, },
{
"constant": false,
"inputs": [],
"name": "toggleDeposits",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "address payable",
"name": "_newAccount",
"type": "address"
}
],
"name": "changeOperator",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{ {
"constant": true, "constant": true,
"inputs": [ "inputs": [
{ {
"internalType": "uint256",
"name": "nullifier", "name": "nullifier",
"type": "uint256" "type": "uint256"
} }
@ -309,6 +422,7 @@
"name": "isSpent", "name": "isSpent",
"outputs": [ "outputs": [
{ {
"internalType": "bool",
"name": "", "name": "",
"type": "bool" "type": "bool"
} }
@ -317,4 +431,4 @@
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
} }
] ]

@ -60,7 +60,7 @@ function isValidProof(proof) {
return { valid: false, reason: 'Corrupted pi_c' } return { valid: false, reason: 'Corrupted pi_c' }
} }
if (proof.publicSignals.length !== 4) { if (proof.publicSignals.length !== 5) {
return { valid: false, reason: 'Corrupted publicSignals' } return { valid: false, reason: 'Corrupted publicSignals' }
} }