Resolve dependencies via self-hosted registry & move package to tornado scope

This commit is contained in:
Theo 2023-09-18 06:45:35 -07:00
parent 2a26a90940
commit 427ebea84b
15 changed files with 854 additions and 291 deletions

1
.npmrc Normal file

@ -0,0 +1 @@
@tornado:registry=https://git.tornado.ws/api/packages/tornado-packages/npm/

@ -2,7 +2,7 @@
## v2 changes
`TornadoTrees.sol` is no longer part of this project. It migrated to [tornado-trees](https://github.com/tornadocash/tornado-trees)
`TornadoTrees.sol` is no longer part of this project. It migrated to [@tornado/trees](https://git.tornado.ws/tornado-packages/tornado-trees)
## Dependencies

@ -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() {

@ -1,6 +1,6 @@
include "../node_modules/circomlib/circuits/poseidon.circom";
include "../node_modules/circomlib/circuits/bitify.circom";
include "../node_modules/circomlib/circuits/comparators.circom";
include "../node_modules/@tornado/circomlib/circuits/poseidon.circom";
include "../node_modules/@tornado/circomlib/circuits/bitify.circom";
include "../node_modules/@tornado/circomlib/circuits/comparators.circom";
include "./Utils.circom";
include "./MerkleTree.circom";
include "./MerkleTreeUpdater.circom";

@ -1,5 +1,5 @@
include "../node_modules/circomlib/circuits/bitify.circom";
include "../node_modules/circomlib/circuits/pedersen.circom";
include "../node_modules/@tornado/circomlib/circuits/bitify.circom";
include "../node_modules/@tornado/circomlib/circuits/pedersen.circom";
// computes Pedersen(nullifier + secret)
template TornadoCommitmentHasher() {

@ -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 "./Utils.circom";
include "./MerkleTree.circom";
include "./MerkleTreeUpdater.circom";

@ -5,7 +5,7 @@ pragma experimental ABIEncoderV2;
import "./interfaces/IVerifier.sol";
import "./interfaces/IRewardSwap.sol";
import "tornado-trees/contracts/TornadoTrees.sol";
import "@tornado/trees/contracts/TornadoTrees.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "torn-token/contracts/ENS.sol";
@ -105,11 +105,9 @@ contract Miner is EnsResolve {
_setRates(_rates);
// prettier-ignore
_setVerifiers([
IVerifier(resolve(_verifiers[0])),
IVerifier(resolve(_verifiers[1])),
IVerifier(resolve(_verifiers[2]))
]);
_setVerifiers(
[IVerifier(resolve(_verifiers[0])), IVerifier(resolve(_verifiers[1])), IVerifier(resolve(_verifiers[2]))]
);
}
function reward(bytes memory _proof, RewardArgs memory _args) public {
@ -239,14 +237,14 @@ contract Miner is EnsResolve {
// ------VIEW-------
/**
@dev Whether the root is present in the root history
* @dev Whether the root is present in the root history
*/
function isKnownAccountRoot(bytes32 _root, uint256 _index) public view returns (bool) {
return _root != 0 && accountRoots[_index % ACCOUNT_ROOT_HISTORY_SIZE] == _root;
}
/**
@dev Returns the last root
* @dev Returns the last root
*/
function getLastAccountRoot() public view returns (bytes32) {
return accountRoots[accountCount % ACCOUNT_ROOT_HISTORY_SIZE];

@ -3,4 +3,4 @@
pragma solidity ^0.6.0;
pragma experimental ABIEncoderV2;
import "tornado-trees/contracts/mocks/TornadoTreesMock.sol";
import "@tornado/trees/contracts/mocks/TornadoTreesMock.sol";

@ -2,4 +2,4 @@
pragma solidity ^0.6.0;
import "tornado-trees/contracts/mocks/TornadoTreesV1Mock.sol";
import "@tornado/trees/contracts/mocks/TornadoTreesV1Mock.sol";

@ -1,8 +1,8 @@
{
"name": "tornado-anonymity-mining",
"name": "@tornado/anonymity-mining",
"version": "2.1.5",
"main": "index.js",
"repository": "https://github.com/tornadocash/tornado-anonymity-mining.git",
"repository": "https://git.tornado.ws/tornado-packages/anonymity-mining.git",
"author": "Tornadocash team <hello@tornado.cash>",
"license": "MIT",
"files": [
@ -47,13 +47,13 @@
"truffle-plugin-verify": "^0.3.11"
},
"dependencies": {
"circomlib": "git+https://github.com/tornadocash/circomlib.git#3b492f9801573eebcfe1b6c584afe8a3beecf2b4",
"@tornado/circomlib": "^0.0.21",
"@tornado/fixed-merkle-tree": "0.3.4",
"@tornado/snarkjs": "0.1.20",
"@tornado/trees": "^0.0.11",
"@tornado/websnark": "^0.0.4",
"decimal.js": "^10.2.0",
"eth-sig-util": "^2.5.3",
"fixed-merkle-tree": "^0.3.4",
"snarkjs": "git+https://github.com/tornadocash/snarkjs.git#869181cfaf7526fe8972073d31655493a04326d5",
"tornado-trees": "^0.0.11",
"web3": "^1.2.11",
"websnark": "git+https://github.com/tornadocash/websnark.git#86a526718cd6f6f5d31bdb1fe26a9ec8819f633e"
"web3": "^1.2.11"
}
}

@ -3,6 +3,6 @@ npx circom circuits/$1.circom -o build/circuits/$1.json
npx snarkjs info -c build/circuits/$1.json
zkutil setup -c build/circuits/$1.json -p build/circuits/$1.params
zkutil export-keys -c build/circuits/$1.json -p build/circuits/$1.params --pk build/circuits/$1_proving_key.json --vk build/circuits/$1_verification_key.json
node node_modules/websnark/tools/buildpkey.js -i build/circuits/$1_proving_key.json -o build/circuits/$1_proving_key.bin
node node_modules/@tornado/websnark/tools/buildpkey.js -i build/circuits/$1_proving_key.json -o build/circuits/$1_proving_key.bin
zkutil generate-verifier -p build/circuits/$1.params -v build/circuits/${1}Verifier.sol
sed -i.bak "s/contract Verifier/contract ${1}Verifier/g" build/circuits/${1}Verifier.sol

@ -11,9 +11,9 @@ const {
RewardArgs,
} = require('./utils')
const Account = require('./account')
const MerkleTree = require('fixed-merkle-tree')
const websnarkUtils = require('websnark/src/utils')
const buildGroth16 = require('websnark/src/groth16')
const MerkleTree = require('@tornado/fixed-merkle-tree')
const websnarkUtils = require('@tornado/websnark/src/utils')
const buildGroth16 = require('@tornado/websnark/src/groth16')
const web3 = new Web3()

@ -1,10 +1,10 @@
const crypto = require('crypto')
const Decimal = require('decimal.js')
const { bigInt } = require('snarkjs')
const { bigInt } = require('@tornado/snarkjs')
const { toBN, soliditySha3 } = require('web3-utils')
const Web3 = require('web3')
const web3 = new Web3()
const { babyJub, pedersenHash, mimcsponge, poseidon } = require('circomlib')
const { babyJub, pedersenHash, mimcsponge, poseidon } = require('@tornado/circomlib')
const RewardExtData = {
RewardExtData: {

@ -34,7 +34,7 @@ const provingKeys = {
withdrawProvingKey: fs.readFileSync('./build/circuits/Withdraw_proving_key.bin').buffer,
treeUpdateProvingKey: fs.readFileSync('./build/circuits/TreeUpdate_proving_key.bin').buffer,
}
const MerkleTree = require('fixed-merkle-tree')
const MerkleTree = require('@tornado/fixed-merkle-tree')
// Set time to beginning of a second
async function timeReset() {

1072
yarn.lock

File diff suppressed because it is too large Load Diff