diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..05ba80e --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +@tornado:registry=https://git.tornado.ws/api/packages/tornado-packages/npm/ \ No newline at end of file diff --git a/circuits/BatchTreeUpdate.circom b/circuits/BatchTreeUpdate.circom index aaec2a0..ff3a396 100644 --- a/circuits/BatchTreeUpdate.circom +++ b/circuits/BatchTreeUpdate.circom @@ -1,5 +1,5 @@ -include "../node_modules/circomlib/circuits/poseidon.circom"; -include "../node_modules/circomlib/circuits/bitify.circom"; +include "../node_modules/@tornado/circomlib/circuits/poseidon.circom"; +include "../node_modules/@tornado/circomlib/circuits/bitify.circom"; include "./MerkleTreeUpdater.circom"; include "./TreeUpdateArgsHasher.circom"; diff --git a/circuits/MerkleTree.circom b/circuits/MerkleTree.circom index c508e18..5d4f150 100644 --- a/circuits/MerkleTree.circom +++ b/circuits/MerkleTree.circom @@ -1,5 +1,5 @@ -include "../node_modules/circomlib/circuits/poseidon.circom"; -include "../node_modules/circomlib/circuits/bitify.circom"; +include "../node_modules/@tornado/circomlib/circuits/poseidon.circom"; +include "../node_modules/@tornado/circomlib/circuits/bitify.circom"; // Computes Poseidon([left, right]) template HashLeftRight() { diff --git a/circuits/TreeUpdateArgsHasher.circom b/circuits/TreeUpdateArgsHasher.circom index a8306d8..320b94f 100644 --- a/circuits/TreeUpdateArgsHasher.circom +++ b/circuits/TreeUpdateArgsHasher.circom @@ -1,5 +1,5 @@ -include "../node_modules/circomlib/circuits/bitify.circom"; -include "../node_modules/circomlib/circuits/sha256/sha256.circom"; +include "../node_modules/@tornado/circomlib/circuits/bitify.circom"; +include "../node_modules/@tornado/circomlib/circuits/sha256/sha256.circom"; // Computes a SHA256 hash of all inputs packed into a byte array // Field elements are padded to 256 bits with zeroes diff --git a/optimize/Dockerfile b/optimize/Dockerfile index 753daec..e351eb7 100644 --- a/optimize/Dockerfile +++ b/optimize/Dockerfile @@ -41,7 +41,7 @@ RUN source $HOME/.cargo/env && cargo install zkutil RUN npm install -g circom snarkjs WORKDIR /root/test -RUN npm init -y && npm install circomlib +RUN npm init -y && npm install @tornado/circomlib RUN apt-get update && apt-get install -y ne RUN mkdir circuits COPY sha/circuit.circom sha/input.js test.sh ./circuits/ diff --git a/package.json b/package.json index 246b6f9..18fc197 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "name": "tornado-trees", + "name": "@tornado/trees", "version": "0.0.11", "main": "src/index.js", - "repository": "https://github.com/tornadocash/tornado-trees.git", + "repository": "https://git.tornado.ws/tornado-packages/tornado-trees.git", "author": "Tornadocash team ", "license": "MIT", "files": [ @@ -42,13 +42,13 @@ "dependencies": { "@openzeppelin/contracts": "^3.4.0", "@openzeppelin/upgrades-core": "^1.5.1", + "@tornado/circomlib": "^0.0.21", + "@tornado/fixed-merkle-tree": "^0.5.0", "circom": "0.5.42", "circom_runtime": "^0.1.12", - "circomlib": "git+https://github.com/tornadocash/circomlib.git#d20d53411d1bef61f38c99a8b36d5d0cc4836aa1", "dotenv": "^8.2.0", "ffiasm": "^0.1.1", "ffjavascript": "^0.2.35", - "fixed-merkle-tree": "^0.5.0", "jssha": "^3.2.0", "snarkjs": "^0.3.57", "tmp-promise": "^3.0.2" diff --git a/scripts/deploy.js b/scripts/deploy.js index b4f057b..814423d 100644 --- a/scripts/deploy.js +++ b/scripts/deploy.js @@ -5,7 +5,7 @@ // Runtime Environment's members available in the global scope. const hre = require('hardhat') const { toFixedHex, poseidonHash2 } = require('../src/utils') -const MerkleTree = require('fixed-merkle-tree') +const MerkleTree = require('@tornado/fixed-merkle-tree') const abi = new hre.ethers.utils.AbiCoder() const instances = [ '0x1111000000000000000000000000000000001111', diff --git a/scripts/deployEmptyV1.js b/scripts/deployEmptyV1.js index 3848893..10f56f8 100644 --- a/scripts/deployEmptyV1.js +++ b/scripts/deployEmptyV1.js @@ -5,7 +5,7 @@ // Runtime Environment's members available in the global scope. const hre = require('hardhat') const { toFixedHex, poseidonHash2 } = require('../src/utils') -const MerkleTree = require('fixed-merkle-tree') +const MerkleTree = require('@tornado/fixed-merkle-tree') const abi = new hre.ethers.utils.AbiCoder() const instances = [ '0x1111000000000000000000000000000000001111', diff --git a/src/utils.js b/src/utils.js index f1cc15f..a962f5d 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,7 +1,7 @@ const crypto = require('crypto') const ethers = require('ethers') const BigNumber = ethers.BigNumber -const { poseidon } = require('circomlib') +const { poseidon } = require('@tornado/circomlib') const poseidonHash = (items) => BigNumber.from(poseidon(items).toString()) diff --git a/test/snark.test.js b/test/snark.test.js index ca0d929..dd1f922 100644 --- a/test/snark.test.js +++ b/test/snark.test.js @@ -1,5 +1,5 @@ const { expect } = require('chai') -const MerkleTree = require('fixed-merkle-tree') +const MerkleTree = require('@tornado/fixed-merkle-tree') const { poseidonHash2, randomBN } = require('../src/utils') const { batchTreeUpdate, prove } = require('../src/index') diff --git a/test/tornadoTrees.test.js b/test/tornadoTrees.test.js index bc11ead..0bf04a5 100644 --- a/test/tornadoTrees.test.js +++ b/test/tornadoTrees.test.js @@ -1,7 +1,7 @@ /* global ethers */ const { expect } = require('chai') const { toFixedHex, poseidonHash2, randomBN } = require('../src/utils') -const MerkleTree = require('fixed-merkle-tree') +const MerkleTree = require('@tornado/fixed-merkle-tree') const controller = require('../src/index') async function register(note, tornadoTrees, from) { diff --git a/yarn.lock b/yarn.lock index ee1dee7..3520c7e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -736,6 +736,37 @@ dependencies: defer-to-connect "^1.0.1" +"@tornado/circomlib@0.0.21", "@tornado/circomlib@^0.0.21": + version "0.0.21" + resolved "https://git.tornado.ws/api/packages/tornado-packages/npm/%40tornado%2Fcircomlib/-/0.0.21/circomlib-0.0.21.tgz#fb7a502aa32bcb2b23205a05877d1cd030c41b19" + integrity sha512-CFaqfgoWZBdD9xZurVOEalWKEVn/NzsT63W/VLGFRbmAUTYJ1vING9LjC0ZXBvec8vzyYquIkvNRdx6axFdJ5g== + dependencies: + "@tornado/snarkjs" "0.1.20" + blake-hash "^1.1.0" + blake2b "^2.1.3" + typedarray-to-buffer "^3.1.5" + web3 "^1.2.11" + +"@tornado/fixed-merkle-tree@^0.5.0": + version "0.5.1" + resolved "https://git.tornado.ws/api/packages/tornado-packages/npm/%40tornado%2Ffixed-merkle-tree/-/0.5.1/fixed-merkle-tree-0.5.1.tgz#bda51bc964a8ed86ce9735f49d1efe1f32595140" + integrity sha512-aMbCrnHLnvGWSr54/oT4IUg7106+F/55APn2uMhEeg0rQk5PXXRgzzqvHgBqyjRpMibKzOT7m7G8SMMVMpXFFg== + dependencies: + "@tornado/circomlib" "0.0.21" + "@tornado/snarkjs" "0.1.20" + +"@tornado/snarkjs@0.1.20": + version "0.1.20" + resolved "https://git.tornado.ws/api/packages/tornado-packages/npm/%40tornado%2Fsnarkjs/-/0.1.20/snarkjs-0.1.20.tgz#d7610cd3c8dc10598da7dc3e40e5d7470c3aa8c7" + integrity sha512-mn+ePoQjqOHyDyK8AMy8SXYqNSxJWVswWVmMYvuc75/9bBtJ7SNtwrTByxmfWjrf4S3BM3IrGfHqBHEXY6gR4Q== + dependencies: + big-integer "^1.6.43" + chai "^4.2.0" + escape-string-regexp "^1.0.5" + eslint "^5.16.0" + keccak "^2.0.0" + yargs "^12.0.5" + "@types/bn.js@*": version "5.1.0" resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-5.1.0.tgz#32c5d271503a12653c62cf4d2b45e6eab8cebc68" @@ -2225,22 +2256,6 @@ cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: inherits "^2.0.1" safe-buffer "^5.0.1" -circom@0.5.33: - version "0.5.33" - resolved "https://registry.yarnpkg.com/circom/-/circom-0.5.33.tgz#6943d5799adf5388989bfbb3ef8f502fb1b4f662" - integrity sha512-UdL8fr6GckhQ4VoWjIvuYwCHneJe8z/AyJpDxgKLyuaX51ijd4gBP6jlwHDbQJsha2aU2GR9qgDsxd0jfari1Q== - dependencies: - chai "^4.2.0" - circom_runtime "0.1.8" - fastfile "0.0.18" - ffiasm "0.1.1" - ffjavascript "0.2.22" - ffwasm "0.0.7" - fnv-plus "^1.3.1" - r1csfile "0.0.16" - 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" @@ -2273,33 +2288,6 @@ circom_runtime@0.1.12, circom_runtime@^0.1.12: ffjavascript "0.2.34" fnv-plus "^1.3.1" -circom_runtime@0.1.8: - version "0.1.8" - resolved "https://registry.yarnpkg.com/circom_runtime/-/circom_runtime-0.1.8.tgz#d967a1618fe5290849f9c0bbffb6b97b95c0f1c8" - integrity sha512-5ZmzCyidkNPb1zZsJGRXTuWcJ6kW6+gRBtHgf2tFqTh5dUyWVVPH0Zg7AsU2ijPr1AmYZUlme0yORUZK5HrjOA== - dependencies: - ffjavascript "0.2.10" - fnv-plus "^1.3.1" - -"circomlib@git+https://github.com/tornadocash/circomlib.git#5beb6aee94923052faeecea40135d45b6ce6172c": - version "0.0.20" - resolved "git+https://github.com/tornadocash/circomlib.git#5beb6aee94923052faeecea40135d45b6ce6172c" - dependencies: - blake-hash "^1.1.0" - blake2b "^2.1.3" - snarkjs "git+https://github.com/tornadocash/snarkjs.git#869181cfaf7526fe8972073d31655493a04326d5" - typedarray-to-buffer "^3.1.5" - web3 "^1.2.11" - -"circomlib@git+https://github.com/tornadocash/circomlib.git#d20d53411d1bef61f38c99a8b36d5d0cc4836aa1": - version "0.4.1" - resolved "git+https://github.com/tornadocash/circomlib.git#d20d53411d1bef61f38c99a8b36d5d0cc4836aa1" - dependencies: - blake-hash "^1.1.0" - blake2b "^2.1.3" - circom "0.5.33" - ffjavascript "0.1.0" - class-is@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/class-is/-/class-is-1.1.0.tgz#9d3c0fba0440d211d843cec3dedfa48055005825" @@ -3855,22 +3843,6 @@ ffiasm@0.1.1, ffiasm@^0.1.1: ejs "^3.0.1" yargs "^15.3.1" -ffjavascript@0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/ffjavascript/-/ffjavascript-0.1.0.tgz#456256c259654cc1ce864c6762b0e76ee1714100" - integrity sha512-dmKlUasSfvUcxBm8nCSKl2x7EFJsXA7OVP8XLFA03T2+6mAc3IiVLC2ambEVOcMOhyhl0vJfVZjM9f9d38D1rw== - dependencies: - big-integer "^1.6.48" - -ffjavascript@0.2.10: - version "0.2.10" - resolved "https://registry.yarnpkg.com/ffjavascript/-/ffjavascript-0.2.10.tgz#b0bf88d69be0b51e0bd28e1966c4a6fb29a86682" - integrity sha512-GQI6gHYYG5/iD4Kt3VzezzK7fARJzP0zkc82V/+JAdjfeKBXhDSo5rpKFuK3cDcrdW0Fu2emuYNMEAuFqhEQvQ== - dependencies: - big-integer "^1.6.48" - wasmcurves "0.0.5" - worker-threads "^1.0.0" - ffjavascript@0.2.22: version "0.2.22" resolved "https://registry.yarnpkg.com/ffjavascript/-/ffjavascript-0.2.22.tgz#101f33db330b0f6a0c10dec22ebf5725618a8a7d" @@ -4016,14 +3988,6 @@ find-yarn-workspace-root@^1.2.1: fs-extra "^4.0.3" micromatch "^3.1.4" -fixed-merkle-tree@^0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/fixed-merkle-tree/-/fixed-merkle-tree-0.5.0.tgz#401cdcf3d670c1e18bc7d3a8e81322eb1b27c1d1" - integrity sha512-egOy12EzVATX3Ru2/SLtnWprVpy/sbPCt/MbeG3ANB28jykWLEYj7EjinFnOxtsgR3gTHU6xYXX53yMn/bZqyw== - dependencies: - circomlib "git+https://github.com/tornadocash/circomlib.git#5beb6aee94923052faeecea40135d45b6ce6172c" - snarkjs "git+https://github.com/tornadocash/snarkjs.git#869181cfaf7526fe8972073d31655493a04326d5" - flat-cache@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-2.0.1.tgz#5d296d6f04bda44a4630a301413bdbc2ec085ec0" @@ -7458,17 +7422,6 @@ snarkjs@^0.3.57: logplease "^1.2.15" r1csfile "0.0.31" -"snarkjs@git+https://github.com/tornadocash/snarkjs.git#869181cfaf7526fe8972073d31655493a04326d5": - version "0.1.20" - resolved "git+https://github.com/tornadocash/snarkjs.git#869181cfaf7526fe8972073d31655493a04326d5" - dependencies: - big-integer "^1.6.43" - chai "^4.2.0" - escape-string-regexp "^1.0.5" - eslint "^5.16.0" - keccak "^2.0.0" - yargs "^12.0.5" - solc@0.7.3: version "0.7.3" resolved "https://registry.yarnpkg.com/solc/-/solc-0.7.3.tgz#04646961bd867a744f63d2b4e3c0701ffdc7d78a" @@ -8353,14 +8306,6 @@ wasmcurves@0.0.14: big-integer "^1.6.42" blakejs "^1.1.0" -wasmcurves@0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/wasmcurves/-/wasmcurves-0.0.5.tgz#d0b58e803c0b1c09c966b7dc0fad6dd405d18547" - integrity sha512-BmI4GXLjLawGg2YkvHa8zRsnWec+d1uwoxE+Iov8cqOpDL7GA5XO2pk2yuDbXHMzwIug2exnKot3baRZ86R0pA== - dependencies: - big-integer "^1.6.42" - blakejs "^1.1.0" - web-worker@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/web-worker/-/web-worker-1.0.0.tgz#c7ced4e1eb6227636ada35056a9e5a477414e4d0"