remove utils.js

This commit is contained in:
poma 2019-07-18 21:27:51 +03:00
parent 5cd7544a29
commit 6b3b7ca72b
No known key found for this signature in database
GPG key ID: 530BBEE4AE8C3604
3 changed files with 28 additions and 32 deletions

View file

@ -1,19 +0,0 @@
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]
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)
}
module.exports = { rbigint, pedersenHash, snarkVerify }