mirror of
https://github.com/tornadocash/tornado-nova
synced 2024-02-02 14:53:56 +01:00
remove zkutil
This commit is contained in:
parent
bd2252afa3
commit
01c4930dcd
10
package.json
10
package.json
@ -21,17 +21,17 @@
|
||||
"@nomiclabs/hardhat-waffle": "^2.0.1",
|
||||
"@openzeppelin/contracts": "^3.4.0",
|
||||
"bignumber.js": "^9.0.0",
|
||||
"circom": "0.5.42",
|
||||
"circom_runtime": "^0.1.12",
|
||||
"circom": "^0.5.45",
|
||||
"circom_runtime": "^0.1.13",
|
||||
"circomlib": "git+https://github.com/tornadocash/circomlib.git#d20d53411d1bef61f38c99a8b36d5d0cc4836aa1",
|
||||
"dotenv": "^10.0.0",
|
||||
"ethereum-waffle": "^3.2.0",
|
||||
"ethers": "^5.0.0",
|
||||
"ffiasm": "^0.1.1",
|
||||
"ffjavascript": "^0.2.35",
|
||||
"ffiasm": "^0.1.3",
|
||||
"ffjavascript": "^0.2.36",
|
||||
"fixed-merkle-tree": "^0.5.0",
|
||||
"hardhat": "^2.3.0",
|
||||
"snarkjs": "^0.3.57",
|
||||
"snarkjs": "^0.4.5",
|
||||
"tmp-promise": "^3.0.2"
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,17 @@
|
||||
#!/bin/bash -e
|
||||
POWERS_OF_TAU=14 # circuit will support max 2^POWERS_OF_TAU constraints
|
||||
mkdir -p artifacts/circuits
|
||||
if [ ! -f artifacts/circuits/ptau$POWERS_OF_TAU ]; then
|
||||
echo "Generating powers of tau file"
|
||||
npx snarkjs powersoftau new bn128 $POWERS_OF_TAU artifacts/circuits/tmp_ptau$POWERS_OF_TAU
|
||||
npx snarkjs powersoftau contribute artifacts/circuits/tmp_ptau$POWERS_OF_TAU artifacts/circuits/tmp2_ptau$POWERS_OF_TAU
|
||||
npx snarkjs powersoftau prepare phase2 artifacts/circuits/tmp2_ptau$POWERS_OF_TAU artifacts/circuits/ptau$POWERS_OF_TAU
|
||||
rm artifacts/circuits/tmp_ptau$POWERS_OF_TAU artifacts/circuits/tmp2_ptau$POWERS_OF_TAU
|
||||
fi
|
||||
npx circom -v -r artifacts/circuits/$1.r1cs -w artifacts/circuits/$1.wasm -s artifacts/circuits/$1.sym circuits/$1.circom
|
||||
zkutil setup -c artifacts/circuits/$1.r1cs -p artifacts/circuits/$1.params
|
||||
zkutil generate-verifier -p artifacts/circuits/$1.params -v artifacts/circuits/Verifier.sol
|
||||
npx snarkjs groth16 setup artifacts/circuits/$1.r1cs artifacts/circuits/ptau$POWERS_OF_TAU artifacts/circuits/tmp_$1.zkey
|
||||
npx snarkjs zkey contribute artifacts/circuits/tmp_$1.zkey artifacts/circuits/$1.zkey
|
||||
npx snarkjs zkey export solidityverifier artifacts/circuits/$1.zkey artifacts/circuits/Verifier.sol
|
||||
#zkutil setup -c artifacts/circuits/$1.r1cs -p artifacts/circuits/$1.params
|
||||
#zkutil generate-verifier -p artifacts/circuits/$1.params -v artifacts/circuits/Verifier.sol
|
||||
npx snarkjs info -r artifacts/circuits/$1.r1cs
|
||||
|
@ -1,4 +1,4 @@
|
||||
const { wtns } = require('snarkjs')
|
||||
const { wtns, groth16 } = require('snarkjs')
|
||||
const { utils } = require('ffjavascript')
|
||||
|
||||
const fs = require('fs')
|
||||
@ -6,7 +6,22 @@ const tmp = require('tmp-promise')
|
||||
const util = require('util')
|
||||
const exec = util.promisify(require('child_process').exec)
|
||||
|
||||
function prove(input, keyBasePath) {
|
||||
const { toFixedHex } = require('./utils')
|
||||
|
||||
async function prove(input, keyBasePath) {
|
||||
const {proof} = await groth16.fullProve(utils.stringifyBigInts(input), `${keyBasePath}.wasm`, `${keyBasePath}.zkey`);
|
||||
return '0x' +
|
||||
toFixedHex(proof.pi_a[0]).slice(2) +
|
||||
toFixedHex(proof.pi_a[1]).slice(2) +
|
||||
toFixedHex(proof.pi_b[0][1]).slice(2) +
|
||||
toFixedHex(proof.pi_b[0][0]).slice(2) +
|
||||
toFixedHex(proof.pi_b[1][1]).slice(2) +
|
||||
toFixedHex(proof.pi_b[1][0]).slice(2) +
|
||||
toFixedHex(proof.pi_c[0]).slice(2) +
|
||||
toFixedHex(proof.pi_c[1]).slice(2)
|
||||
}
|
||||
|
||||
function proveZkutil(input, keyBasePath) {
|
||||
input = utils.stringifyBigInts(input)
|
||||
// console.log('input', input)
|
||||
return tmp.dir().then(async (dir) => {
|
||||
@ -34,7 +49,7 @@ function prove(input, keyBasePath) {
|
||||
console.log(out, e)
|
||||
throw e
|
||||
}
|
||||
return '0x' + JSON.parse(fs.readFileSync(`${dir}/proof.json`)).proof
|
||||
return '0x' + JSON.parse(fs.readFileSync(`${dir}/proof.json`).toString()).proof
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ class Utxo {
|
||||
|
||||
getNullifier() {
|
||||
if (!this._nullifier) {
|
||||
if (this.amount > 0 && (!this.index || !this.privkey)) {
|
||||
if (this.amount > 0 && (this.index === undefined || !this.privkey === undefined)) {
|
||||
throw new Error('Can not compute nullifier without utxo index or private key')
|
||||
}
|
||||
this._nullifier = poseidonHash([this.getCommitment(), this.index || 0, this.privkey || 0])
|
||||
|
32
yarn.lock
32
yarn.lock
@ -1773,9 +1773,9 @@ blake2b-wasm@^1.1.0:
|
||||
dependencies:
|
||||
nanoassert "^1.0.0"
|
||||
|
||||
"blake2b-wasm@https://github.com/jbaylina/blake2b-wasm.git":
|
||||
"blake2b-wasm@git+https://github.com/jbaylina/blake2b-wasm.git":
|
||||
version "2.1.0"
|
||||
resolved "https://github.com/jbaylina/blake2b-wasm.git#0d5f024b212429c7f50a7f533aa3a2406b5b42b3"
|
||||
resolved "git+https://github.com/jbaylina/blake2b-wasm.git#0d5f024b212429c7f50a7f533aa3a2406b5b42b3"
|
||||
dependencies:
|
||||
nanoassert "^1.0.0"
|
||||
|
||||
@ -2210,10 +2210,10 @@ circom@0.5.33:
|
||||
tmp-promise "^2.0.2"
|
||||
wasmbuilder "0.0.10"
|
||||
|
||||
circom@0.5.42:
|
||||
version "0.5.42"
|
||||
resolved "https://registry.yarnpkg.com/circom/-/circom-0.5.42.tgz#96a456f9538f4425654df091d15e3158e9da2acc"
|
||||
integrity sha512-v6+f9g3z2ia17NQvQmyZjvh8cE8O3GtxRE36KfJfx/a+s58Y7aEDWsUG+GFRJhp1ajiQELdj3NehY9vHSf5Rkg==
|
||||
circom@^0.5.45:
|
||||
version "0.5.45"
|
||||
resolved "https://registry.yarnpkg.com/circom/-/circom-0.5.45.tgz#82931882c5d38022ccb8be9c4a6314ea94bc511e"
|
||||
integrity sha512-5Ixp6UjwrhBWnnFBO/mTns+eeEDOpi5UoN4znAUWy5rklCUWYt2Ezl9QVUswBXjMP5kpfEtGUY2XSsYRAp6uMg==
|
||||
dependencies:
|
||||
chai "^4.2.0"
|
||||
circom_runtime "0.1.12"
|
||||
@ -2234,7 +2234,7 @@ circom_runtime@0.1.12:
|
||||
ffjavascript "0.2.34"
|
||||
fnv-plus "^1.3.1"
|
||||
|
||||
circom_runtime@0.1.13, circom_runtime@^0.1.12:
|
||||
circom_runtime@0.1.13, circom_runtime@^0.1.13:
|
||||
version "0.1.13"
|
||||
resolved "https://registry.yarnpkg.com/circom_runtime/-/circom_runtime-0.1.13.tgz#90f86f35d989c48d4c27595b94664ea6918fbede"
|
||||
integrity sha512-vmv19/0p5OTe5uCI7PWqPtB5vPoYWjczqKYnabaC5HOxX99R4K1MuNqEXsNEAoEfZrmfAQd7vXLcATN9NVnsPA==
|
||||
@ -2829,7 +2829,7 @@ ee-first@1.1.1:
|
||||
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
|
||||
integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=
|
||||
|
||||
ejs@^3.0.1:
|
||||
ejs@^3.0.1, ejs@^3.1.6:
|
||||
version "3.1.6"
|
||||
resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.6.tgz#5bfd0a0689743bb5268b3550cceeebbc1702822a"
|
||||
integrity sha512-9lt9Zse4hPucPkoP7FHDF0LQAlGyF9JVpnClFLFH3aSSbxmyoqINRpp/9wePWJTUl4KOQwRL72Iw3InHPDkoGw==
|
||||
@ -3758,7 +3758,7 @@ ffiasm@0.1.1:
|
||||
ejs "^3.0.1"
|
||||
yargs "^15.3.1"
|
||||
|
||||
ffiasm@^0.1.1:
|
||||
ffiasm@^0.1.3:
|
||||
version "0.1.3"
|
||||
resolved "https://registry.yarnpkg.com/ffiasm/-/ffiasm-0.1.3.tgz#9d636448e31ce676c0e6684102d4d44bcf58c71f"
|
||||
integrity sha512-/+rZrpKO98W5BSqy2E6vxVaNh63MnRPA+1H7ufmpOrbZjG2pIEPCYbn5g7q2AXaX+75IMKasi4IOFrwPkxJXVg==
|
||||
@ -3811,7 +3811,7 @@ ffjavascript@0.2.35:
|
||||
wasmcurves "0.0.14"
|
||||
web-worker "^1.0.0"
|
||||
|
||||
ffjavascript@^0.2.30, ffjavascript@^0.2.35:
|
||||
ffjavascript@0.2.36, ffjavascript@^0.2.30, ffjavascript@^0.2.36:
|
||||
version "0.2.36"
|
||||
resolved "https://registry.yarnpkg.com/ffjavascript/-/ffjavascript-0.2.36.tgz#1ec3386ae260def96dde898999b4eee8b0f71902"
|
||||
integrity sha512-OPgov0qQiV7wffycylpmEq6rm4Pu68LIMFbB1jrM5bCr1yXqgIMQ6IparbgRuFG5aj3NPmsorrGh7pQJnQlIIw==
|
||||
@ -7423,16 +7423,18 @@ snapdragon@^0.8.1:
|
||||
source-map-resolve "^0.5.0"
|
||||
use "^3.1.0"
|
||||
|
||||
snarkjs@^0.3.57:
|
||||
version "0.3.60"
|
||||
resolved "https://registry.yarnpkg.com/snarkjs/-/snarkjs-0.3.60.tgz#fe573e347a924af8ed162154e866e02ef8d8230c"
|
||||
integrity sha512-l3QMKvr+KUetxlJq9TCS0KNxiUquUDYFqHIzn3TxNSPPlcQfIq6V0isZKCjuML+XNGaoJ7s+kfdAZ8qp/2yOYQ==
|
||||
snarkjs@^0.4.5:
|
||||
version "0.4.5"
|
||||
resolved "https://registry.yarnpkg.com/snarkjs/-/snarkjs-0.4.5.tgz#c7246b0bdcdafd25c67c0ecc395556715b059a14"
|
||||
integrity sha512-rgxbp3JMhGdPgkhCrssq+a4Bv2vm2QucWwK9QG5cdyRRpx8f5EOpyMPy7pi/U8VUyyyulAaDowKBf7x7chB7zg==
|
||||
dependencies:
|
||||
"@iden3/binfileutils" "0.0.8"
|
||||
blake2b-wasm "https://github.com/jbaylina/blake2b-wasm.git"
|
||||
circom_runtime "0.1.13"
|
||||
ejs "^3.1.6"
|
||||
fastfile "0.0.19"
|
||||
ffjavascript "0.2.35"
|
||||
ffjavascript "0.2.36"
|
||||
js-sha3 "^0.8.0"
|
||||
logplease "^1.2.15"
|
||||
r1csfile "0.0.32"
|
||||
readline "^1.3.0"
|
||||
|
Loading…
Reference in New Issue
Block a user