configurable CHUNK_TREE_HEIGHT

This commit is contained in:
Alexey 2021-02-24 22:07:08 +03:00
parent 4f732d05bc
commit 7abc834475
2 changed files with 26 additions and 16 deletions

View File

@ -23,3 +23,15 @@ $ yarn circuit
$ npx hardhat node --fork <https://eth-mainnet.alchemyapi.io/v2/API_KEY> --fork-block-number 11827889
$ npx hardhat test
```
## Checklist for batch size changing
find and replace the `CHUNK_TREE_HEIGHT = ` in following files
1. `circuits/BatchTreeUpdate.circom`
2. `contracts/TornadoTrees.sol`
3. `tornadoTrees.test.js`
## build large circuits
1. docker build . -t tornadocash/tornado-trees

View File

@ -74,20 +74,18 @@ template BatchTreeUpdate(levels, batchLevels, zeroBatchLeaf) {
// zeroLeaf = keccak256("tornado") % FIELD_SIZE
// zeroBatchLeaf is poseidon(zeroLeaf, zeroLeaf) (batchLevels - 1) times
component main = BatchTreeUpdate(20, 2, 21572503925325825116380792768937986743990254033176521064707045559165336555197)
function nthZero(n) {
if (n == 0) return 21663839004416932945382355908790599225266501822907911457504978515578255421292;
if (n == 1) return 11850551329423159860688778991827824730037759162201783566284850822760196767874;
if (n == 2) return 21572503925325825116380792768937986743990254033176521064707045559165336555197;
if (n == 3) return 11224495635916644180335675565949106569141882748352237685396337327907709534945;
if (n == 4) return 2399242030534463392142674970266584742013168677609861039634639961298697064915;
if (n == 5) return 13182067204896548373877843501261957052850428877096289097123906067079378150834;
if (n == 6) return 7106632500398372645836762576259242192202230138343760620842346283595225511823;
if (n == 7) return 17857585024203959071818533000506593455576509792639288560876436361491747801924;
if (n == 8) return 17278668323652664881420209773995988768195998574629614593395162463145689805534;
if (n == 9) return 209436188287252095316293336871467217491997565239632454977424802439169726471;
}
// for mainnet use 20, 7, 17278668323652664881420209773995988768195998574629614593395162463145689805534
/*
zeros of n-th order:
21663839004416932945382355908790599225266501822907911457504978515578255421292
11850551329423159860688778991827824730037759162201783566284850822760196767874
21572503925325825116380792768937986743990254033176521064707045559165336555197
11224495635916644180335675565949106569141882748352237685396337327907709534945
2399242030534463392142674970266584742013168677609861039634639961298697064915
13182067204896548373877843501261957052850428877096289097123906067079378150834
7106632500398372645836762576259242192202230138343760620842346283595225511823
17278668323652664881420209773995988768195998574629614593395162463145689805534
209436188287252095316293336871467217491997565239632454977424802439169726471
6509061943359659796226067852175931816441223836265895622135845733346450111408
*/
var CHUNK_TREE_HEIGHT = 2
component main = BatchTreeUpdate(20, CHUNK_TREE_HEIGHT, nthZero(CHUNK_TREE_HEIGHT))