mirror of
https://github.com/tornadocash/tornado-core.git
synced 2025-08-11 16:19:59 -04:00
eslinter WIP
This commit is contained in:
parent
f3b1b7f96e
commit
2b2e174d06
6 changed files with 817 additions and 90 deletions
|
@ -1,38 +1,39 @@
|
|||
function send(method, params = []) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// eslint-disable-next-line no-undef
|
||||
web3.currentProvider.send({
|
||||
jsonrpc: '2.0',
|
||||
id: Date.now(),
|
||||
method,
|
||||
params
|
||||
}, (err, res) => {
|
||||
return err ? reject(err) : resolve(res);
|
||||
});
|
||||
});
|
||||
return err ? reject(err) : resolve(res)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const takeSnapshot = async seconds => {
|
||||
return await send('evm_snapshot');
|
||||
const takeSnapshot = async () => {
|
||||
return await send('evm_snapshot')
|
||||
}
|
||||
|
||||
const revertSnapshot = async (id) => {
|
||||
await send('evm_revert', [id]);
|
||||
await send('evm_revert', [id])
|
||||
}
|
||||
|
||||
const mineBlock = async (timestamp) => {
|
||||
await send('evm_mine', [timestamp]);
|
||||
await send('evm_mine', [timestamp])
|
||||
}
|
||||
|
||||
const increaseTime = async (seconds) => {
|
||||
await send('evm_increaseTime', [seconds]);
|
||||
await send('evm_increaseTime', [seconds])
|
||||
}
|
||||
|
||||
const minerStop = async () => {
|
||||
await send('miner_stop', []);
|
||||
await send('miner_stop', [])
|
||||
}
|
||||
|
||||
const minerStart = async () => {
|
||||
await send('miner_start', []);
|
||||
await send('miner_start', [])
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
@ -42,4 +43,4 @@ module.exports = {
|
|||
minerStop,
|
||||
minerStart,
|
||||
increaseTime,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
const snarkjs = require("snarkjs");
|
||||
const groth = snarkjs["groth"];
|
||||
const crypto = require("crypto");
|
||||
const circomlib = require('circomlib');
|
||||
const pedersen = circomlib.pedersenHash;
|
||||
const babyjub = circomlib.babyJub;
|
||||
const websnarkUtils = require('websnark/src/utils');
|
||||
const unstringifyBigInts2 = require("snarkjs/src/stringifybigint").unstringifyBigInts;
|
||||
const snarkjs = require('snarkjs')
|
||||
const groth = snarkjs['groth']
|
||||
const crypto = require('crypto')
|
||||
const circomlib = require('circomlib')
|
||||
const pedersen = circomlib.pedersenHash
|
||||
const babyjub = circomlib.babyJub
|
||||
const websnarkUtils = require('websnark/src/utils')
|
||||
const unstringifyBigInts2 = require('snarkjs/src/stringifybigint').unstringifyBigInts
|
||||
|
||||
const rbigint = (nbytes) => snarkjs.bigInt.leBuff2int(crypto.randomBytes(nbytes));
|
||||
const pedersenHash = (data) => babyjub.unpackPoint(pedersen.hash(data))[0];
|
||||
const rbigint = (nbytes) => snarkjs.bigInt.leBuff2int(crypto.randomBytes(nbytes))
|
||||
const pedersenHash = (data) => babyjub.unpackPoint(pedersen.hash(data))[0]
|
||||
|
||||
function snarkVerify(proof) {
|
||||
proof = unstringifyBigInts2(websnarkUtils.fromSolidityInput(proof));
|
||||
const verification_key = unstringifyBigInts2(require('../build/circuits/withdraw_verification_key.json'));
|
||||
return groth.isValid(verification_key, proof, proof.publicSignals);
|
||||
proof = unstringifyBigInts2(websnarkUtils.fromSolidityInput(proof))
|
||||
const verification_key = unstringifyBigInts2(require('../build/circuits/withdraw_verification_key.json'))
|
||||
return groth.isValid(verification_key, proof, proof.publicSignals)
|
||||
}
|
||||
|
||||
module.exports = {rbigint, pedersenHash, snarkVerify};
|
||||
module.exports = { rbigint, pedersenHash, snarkVerify }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue