diff --git a/README.md b/README.md index 612fc42..9378ffc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # ZK Proof of Assets -Circom & Groth16 SNARK implementation of Proof of Assets. This repo allows digital asset custodians (such as cryptocurrency exchanges) to prove that they own a certain amount of digital assets, without revealing the addresses that hold the assets. Proof of Assets is the first out of 2 protocols that make up a Proof of Reserves protocol; the other protocol is Proof of Liabilities (repo [here](https://github.com/silversixpence-crypto/dapol). +Circom & Groth16 SNARK implementation of Proof of Assets. This repo allows digital asset custodians (such as cryptocurrency exchanges) to prove that they own a certain amount of digital assets, without revealing the addresses that hold the assets. Proof of Assets is the first out of 2 protocols that make up a Proof of Reserves protocol; the other protocol is Proof of Liabilities (repo [here](https://github.com/silversixpence-crypto/dapol). 1. For details on the whole PoR project see [this project doc](https://hackmd.io/@JI2FtqawSzO-olUw-r48DQ/S1Ozo-iO2). 2. For the original Proof of Assets design doc see [this](https://hackmd.io/@JI2FtqawSzO-olUw-r48DQ/rJXtAeyLT). Note, however, that the final design is slightly different to the original (some optimizations were done). See below for final design. 3. For an in-depth explanation of Proof of Assets see [this article](https://hackmd.io/@JI2FtqawSzO-olUw-r48DQ/r1FR-0uBR). @@ -11,7 +11,7 @@ The above-linked docs offer an in-depth explanation, but here is a brief one: Problem statement: a crypto-asset custodian wants to prove they own $X$ digital assets, but do not want to reveal the addresses that hold the assets. -Solution: the custodian produces signatures for the addresses (which forms the ownership proof), and feeds them as private inputs to a ZK-SNARK, which verifies them and checks that they are contained within a larger set of addresses (the anonymity set). This set is a public input to the snark and must be checked to mirror the blockchain by the verifier. Finally, the snark adds up the balances of the addresses, and outputs a Pedersen commitment of the sum. The commitment is public and can be used in conjunction with +Solution: the custodian produces signatures for the addresses (which forms the ownership proof), and feeds them as private inputs to a ZK-SNARK, which verifies them and checks that they are contained within a larger set of addresses (the anonymity set). This set is a public input to the snark and must be checked to mirror the blockchain by the verifier. Finally, the snark adds up the balances of the addresses, and outputs a Pedersen commitment of the sum. The commitment is public and can be used in conjunction with the output of Proof of Liabilities to show solvency. ## Current state @@ -126,14 +126,14 @@ Most of the time taken up by the workflow is in generating the proving keys (zke ### Constraints -For layer 1, the number of non-linear constraints can be estimated with the following equation: +For layer 1, the number of non-linear constraints can be estimated with the following equation: $$C_{\text{layer 1}}(s) = 447044s + 888502$$ where $s$ is the number of signatures. This equation was calculated using a line of best fit from the test data (`(num_sigs, constraints)`): ``` [(1, 1509221), (2, 1932908), (2, 1932908), (4, 1932908), (7, 4161827), (16, 8173925), (128, 58102853)] ``` -For layer 2, the number of non-linear constraints can be estimated with the following equation: +For layer 2, the number of non-linear constraints can be estimated with the following equation: $$C_{\text{layer 2}}(s,h) = 159591s + 6054h + 19490640$$ where $h$ is the height of the Merkle tree. Note that the main source of constraints in the layer 2 circuit comes from Groth16 verification. This equation was calculated using a line of best fit from the test data (`(num_sigs, height, constraints)`): ``` @@ -146,6 +146,4 @@ Related issue: https://github.com/silversixpence-crypto/zk-proof-of-assets/issue There are scripts in the *tests* directory for running the tests. The have the format `N_sigs_K_batches_H_height.sh`. The tests can take many hours to run, depending on the test & the size of the machine running them. The results from running the tests can be found in the directory under *tests* with the same name as the shell script. The *tests/old* directory contains tests that were run using a slightly older version of the workflow (same circuits, different scripts). -There are only integration tests, no unit tests. The reason for this is that the whole system might change in the next version, so writing lots of unit tests is a bit of a waste of time. The unit tests would be there to catch any bugs introduced with future changes, but if there are to be no future changes to the current system then the unit tests are a waste. We already have integration tests to make sure that no bugs are present with the current workflow. - - +There are only integration tests, no unit tests. The reason for this is that the whole system might change in the next version, so writing lots of unit tests is a bit of a waste of time. The unit tests would be there to catch any bugs introduced with future changes, but if there are to be no future changes to the current system then the unit tests are a waste. We already have integration tests to make sure that no bugs are present with the current workflow. diff --git a/package.json b/package.json index 31d9430..d25a16b 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "bigint-mod-arith": "^3.1.0", "chai": "^4.3.4", "circom_tester": "^0.0.9", + "eslint": "^9.6.0", "lodash": "^4.17.21", "mocha": "^9.1.3", "ts-node": "^10.4.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6f2c04f..6213b2d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -58,6 +58,9 @@ devDependencies: circom_tester: specifier: ^0.0.9 version: 0.0.9 + eslint: + specifier: ^9.6.0 + version: 9.6.0 lodash: specifier: ^4.17.21 version: 4.17.21 @@ -106,6 +109,59 @@ packages: '@jridgewell/trace-mapping': 0.3.9 dev: true + /@eslint-community/eslint-utils@4.4.0(eslint@9.6.0): + resolution: {integrity: sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 + dependencies: + eslint: 9.6.0 + eslint-visitor-keys: 3.4.3 + dev: true + + /@eslint-community/regexpp@4.11.0: + resolution: {integrity: sha512-G/M/tIiMrTAxEWRfLfQJMmGNX28IxBg4PBz8XqQhqUHLFI6TL2htpIB1iQCj144V5ee/JaKyT9/WZ0MGZWfA7A==} + engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} + dev: true + + /@eslint/config-array@0.17.0: + resolution: {integrity: sha512-A68TBu6/1mHHuc5YJL0U0VVeGNiklLAL6rRmhTCP2B5XjWLMnrX+HkO+IAXyHvks5cyyY1jjK5ITPQ1HGS2EVA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + dependencies: + '@eslint/object-schema': 2.1.4 + debug: 4.3.3(supports-color@8.1.1) + minimatch: 3.1.2 + transitivePeerDependencies: + - supports-color + dev: true + + /@eslint/eslintrc@3.1.0: + resolution: {integrity: sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + dependencies: + ajv: 6.12.6 + debug: 4.3.3(supports-color@8.1.1) + espree: 10.1.0 + globals: 14.0.0 + ignore: 5.3.1 + import-fresh: 3.3.0 + js-yaml: 4.1.0 + minimatch: 3.1.2 + strip-json-comments: 3.1.1 + transitivePeerDependencies: + - supports-color + dev: true + + /@eslint/js@9.6.0: + resolution: {integrity: sha512-D9B0/3vNg44ZeWbYMpBoXqNP4j6eQD5vNwIlGAuFRRzK/WtT/jvDQW3Bi9kkf3PMDMlM7Yi+73VLUsn5bJcl8A==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + dev: true + + /@eslint/object-schema@2.1.4: + resolution: {integrity: sha512-BsWiH1yFGjXXS2yvrf5LyuoSIIbPrGUWob917o+BTKuZ7qJdxX8aJLRxs1fS9n6r7vESrq1OUqb68dANcFXuQQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + dev: true + /@ethersproject/abi@5.7.0: resolution: {integrity: sha512-351ktp42TiRcYB3H1OP8yajPeAQstMW/yCFokj/AthP9bLHzQFPlOrxOcwYEDkUAICmOHljvN4K39OMTMUa9RA==} dependencies: @@ -421,6 +477,16 @@ packages: '@ethersproject/strings': 5.7.0 dev: false + /@humanwhocodes/module-importer@1.0.1: + resolution: {integrity: sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==} + engines: {node: '>=12.22'} + dev: true + + /@humanwhocodes/retry@0.3.0: + resolution: {integrity: sha512-d2CGZR2o7fS6sWB7DG/3a95bGKQyHMACZ5aW8qGkkqQpUoZV6C0X7Pc7l4ZNMZkfNBf4VWNe9E1jRsf0G146Ew==} + engines: {node: '>=18.18'} + dev: true + /@iden3/bigarray@0.0.2: resolution: {integrity: sha512-Xzdyxqm1bOFF6pdIsiHLLl3HkSLjbhqJHVyqaTxXt3RqXBEnmsUmEW47H7VOi/ak7TdkRpNkxjyK5Zbkm+y52g==} @@ -500,6 +566,27 @@ packages: resolution: {integrity: sha512-ZVRouDO5mbdCiDg4zCd3ZZABduRtpy4tCnB33Gh9upHe9tRzpiqbRSN1VTjrj/2g8u2c6MBi0YLNnNQpBYOiWg==} dev: false + /@nodelib/fs.scandir@2.1.5: + resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} + engines: {node: '>= 8'} + dependencies: + '@nodelib/fs.stat': 2.0.5 + run-parallel: 1.2.0 + dev: true + + /@nodelib/fs.stat@2.0.5: + resolution: {integrity: sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==} + engines: {node: '>= 8'} + dev: true + + /@nodelib/fs.walk@1.2.8: + resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} + engines: {node: '>= 8'} + dependencies: + '@nodelib/fs.scandir': 2.1.5 + fastq: 1.17.1 + dev: true + /@sinclair/typebox@0.27.8: resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==} dev: true @@ -591,6 +678,14 @@ packages: through: 2.3.8 dev: false + /acorn-jsx@5.3.2(acorn@8.12.0): + resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} + peerDependencies: + acorn: ^6.0.0 || ^7.0.0 || ^8.0.0 + dependencies: + acorn: 8.12.0 + dev: true + /acorn-walk@8.3.1: resolution: {integrity: sha512-TgUZgYvqZprrl7YldZNoa9OciCAyZR+Ejm9eXzKCmjsF5IKp/wgQ7Z/ZpjpGTIUPwrHQIcYeI8qDh4PsEwxMbw==} engines: {node: '>=0.4.0'} @@ -602,6 +697,12 @@ packages: hasBin: true dev: true + /acorn@8.12.0: + resolution: {integrity: sha512-RTvkC4w+KNXrM39/lWCUaG0IbRkWdCv7W/IOW9oU6SawyxulvkQy5HQPVTKxEjczcUvapcrw3cFx/60VN/NRNw==} + engines: {node: '>=0.4.0'} + hasBin: true + dev: true + /aes-js@3.0.0: resolution: {integrity: sha512-H7wUZRn8WpTq9jocdxQ2c8x2sKo9ZVmzfRE13GiNJXfp7NcKYEdvl3vspKjXox6RIG2VtaRe4JFvxG4rqp2Zuw==} dev: false @@ -610,6 +711,15 @@ packages: resolution: {integrity: sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q==} dev: false + /ajv@6.12.6: + resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==} + dependencies: + fast-deep-equal: 3.1.3 + fast-json-stable-stringify: 2.1.0 + json-schema-traverse: 0.4.1 + uri-js: 4.4.1 + dev: true + /ansi-colors@4.1.1: resolution: {integrity: sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==} engines: {node: '>=6'} @@ -775,6 +885,11 @@ packages: set-function-length: 1.1.1 dev: true + /callsites@3.1.0: + resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} + engines: {node: '>=6'} + dev: true + /camelcase@6.3.0: resolution: {integrity: sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==} engines: {node: '>=10'} @@ -921,6 +1036,15 @@ packages: resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==} dev: true + /cross-spawn@7.0.3: + resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} + engines: {node: '>= 8'} + dependencies: + path-key: 3.1.1 + shebang-command: 2.0.0 + which: 2.0.2 + dev: true + /csv-generate@4.4.1: resolution: {integrity: sha512-O/einO0v4zPmXaOV+sYqGa02VkST4GP5GLpWBNHEouIU7pF3kpGf3D0kCCvX82ydIY4EKkOK+R8b1BYsRXravg==} dev: false @@ -970,7 +1094,6 @@ packages: /deep-is@0.1.4: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} - dev: false /define-data-property@1.1.1: resolution: {integrity: sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ==} @@ -1052,6 +1175,76 @@ packages: source-map: 0.6.1 dev: false + /eslint-scope@8.0.1: + resolution: {integrity: sha512-pL8XjgP4ZOmmwfFE8mEhSxA7ZY4C+LWyqjQ3o4yWkkmD0qcMT9kkW3zWHOczhWcjTSgqycYAgwSlXvZltv65og==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + dependencies: + esrecurse: 4.3.0 + estraverse: 5.3.0 + dev: true + + /eslint-visitor-keys@3.4.3: + resolution: {integrity: sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + dev: true + + /eslint-visitor-keys@4.0.0: + resolution: {integrity: sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + dev: true + + /eslint@9.6.0: + resolution: {integrity: sha512-ElQkdLMEEqQNM9Njff+2Y4q2afHk7JpkPvrd7Xh7xefwgQynqPxwf55J7di9+MEibWUGdNjFF9ITG9Pck5M84w==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + hasBin: true + dependencies: + '@eslint-community/eslint-utils': 4.4.0(eslint@9.6.0) + '@eslint-community/regexpp': 4.11.0 + '@eslint/config-array': 0.17.0 + '@eslint/eslintrc': 3.1.0 + '@eslint/js': 9.6.0 + '@humanwhocodes/module-importer': 1.0.1 + '@humanwhocodes/retry': 0.3.0 + '@nodelib/fs.walk': 1.2.8 + ajv: 6.12.6 + chalk: 4.1.2 + cross-spawn: 7.0.3 + debug: 4.3.3(supports-color@8.1.1) + escape-string-regexp: 4.0.0 + eslint-scope: 8.0.1 + eslint-visitor-keys: 4.0.0 + espree: 10.1.0 + esquery: 1.5.0 + esutils: 2.0.3 + fast-deep-equal: 3.1.3 + file-entry-cache: 8.0.0 + find-up: 5.0.0 + glob-parent: 6.0.2 + ignore: 5.3.1 + imurmurhash: 0.1.4 + is-glob: 4.0.3 + is-path-inside: 3.0.3 + json-stable-stringify-without-jsonify: 1.0.1 + levn: 0.4.1 + lodash.merge: 4.6.2 + minimatch: 3.1.2 + natural-compare: 1.4.0 + optionator: 0.9.4 + strip-ansi: 6.0.1 + text-table: 0.2.0 + transitivePeerDependencies: + - supports-color + dev: true + + /espree@10.1.0: + resolution: {integrity: sha512-M1M6CpiE6ffoigIOWYO9UDP8TMUw9kqb21tf+08IgDYjCsOvCuDt4jQcZmoYxx+w7zlKw9/N0KXfto+I8/FrXA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + dependencies: + acorn: 8.12.0 + acorn-jsx: 5.3.2(acorn@8.12.0) + eslint-visitor-keys: 4.0.0 + dev: true + /esprima@1.2.2: resolution: {integrity: sha512-+JpPZam9w5DuJ3Q67SqsMGtiHKENSMRVoxvArfJZK01/BfLEObtZ6orJa/MtoGNR/rfMgp5837T41PAmTwAv/A==} engines: {node: '>=0.4.0'} @@ -1064,15 +1257,33 @@ packages: hasBin: true dev: false + /esquery@1.5.0: + resolution: {integrity: sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==} + engines: {node: '>=0.10'} + dependencies: + estraverse: 5.3.0 + dev: true + + /esrecurse@4.3.0: + resolution: {integrity: sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==} + engines: {node: '>=4.0'} + dependencies: + estraverse: 5.3.0 + dev: true + /estraverse@4.3.0: resolution: {integrity: sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==} engines: {node: '>=4.0'} dev: false + /estraverse@5.3.0: + resolution: {integrity: sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==} + engines: {node: '>=4.0'} + dev: true + /esutils@2.0.3: resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} engines: {node: '>=0.10.0'} - dev: false /ethers@5.7.2: resolution: {integrity: sha512-wswUsmWo1aOK8rR7DIKiWSw9DbLWe6x98Jrn8wcTflTVvaXhAMaB5zGAXy0GYQEQp9iO1iSHWVyARQm11zUtyg==} @@ -1139,9 +1350,16 @@ packages: jest-util: 29.7.0 dev: true + /fast-deep-equal@3.1.3: + resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} + dev: true + + /fast-json-stable-stringify@2.1.0: + resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==} + dev: true + /fast-levenshtein@2.0.6: resolution: {integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==} - dev: false /fastfile@0.0.18: resolution: {integrity: sha512-q03PTKc+wptis4WmuFOwPNQx2p5myFUrl/dMgRlW9mymc1Egyc14JPHgiGnWK+sJ0+dBl2Vwtfh5GfSQltYOpw==} @@ -1155,6 +1373,12 @@ packages: resolution: {integrity: sha512-r5ZDbgImvVWCP0lA/cGNgQcZqR+aYdFx3u+CtJqUE510pBUVGMn4ulL/iRTI4tACTYsNJ736uzFxEBXesPAktA==} dev: false + /fastq@1.17.1: + resolution: {integrity: sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==} + dependencies: + reusify: 1.0.4 + dev: true + /ffjavascript@0.2.22: resolution: {integrity: sha512-EsVqap2Txm17bKW0z/jXCX3M7rQ++nQUAJY8alWDpyhjRj90xjl6GLeVSKZQ8rOFDQ/SFFXcEB8w9X8Boxid+w==} dependencies: @@ -1186,6 +1410,13 @@ packages: wasmcurves: 0.2.2 web-worker: 1.2.0 + /file-entry-cache@8.0.0: + resolution: {integrity: sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==} + engines: {node: '>=16.0.0'} + dependencies: + flat-cache: 4.0.1 + dev: true + /filelist@1.0.4: resolution: {integrity: sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==} dependencies: @@ -1206,11 +1437,23 @@ packages: path-exists: 4.0.0 dev: true + /flat-cache@4.0.1: + resolution: {integrity: sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==} + engines: {node: '>=16'} + dependencies: + flatted: 3.3.1 + keyv: 4.5.4 + dev: true + /flat@5.0.2: resolution: {integrity: sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==} hasBin: true dev: true + /flatted@3.3.1: + resolution: {integrity: sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==} + dev: true + /fnv-plus@1.3.1: resolution: {integrity: sha512-Gz1EvfOneuFfk4yG458dJ3TLJ7gV19q3OM/vVvvHf7eT02Hm1DleB4edsia6ahbKgAYxO9gvyQ1ioWZR+a00Yw==} dev: true @@ -1262,6 +1505,13 @@ packages: is-glob: 4.0.3 dev: true + /glob-parent@6.0.2: + resolution: {integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==} + engines: {node: '>=10.13.0'} + dependencies: + is-glob: 4.0.3 + dev: true + /glob@7.2.0: resolution: {integrity: sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==} dependencies: @@ -1284,6 +1534,11 @@ packages: path-is-absolute: 1.0.1 dev: true + /globals@14.0.0: + resolution: {integrity: sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==} + engines: {node: '>=18'} + dev: true + /gopd@1.0.1: resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==} dependencies: @@ -1363,6 +1618,24 @@ packages: engines: {node: '>= 6.0.0'} dev: false + /ignore@5.3.1: + resolution: {integrity: sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==} + engines: {node: '>= 4'} + dev: true + + /import-fresh@3.3.0: + resolution: {integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==} + engines: {node: '>=6'} + dependencies: + parent-module: 1.0.1 + resolve-from: 4.0.0 + dev: true + + /imurmurhash@0.1.4: + resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==} + engines: {node: '>=0.8.19'} + dev: true + /inflight@1.0.6: resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} dependencies: @@ -1422,6 +1695,11 @@ packages: engines: {node: '>=0.12.0'} dev: true + /is-path-inside@3.0.3: + resolution: {integrity: sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==} + engines: {node: '>=8'} + dev: true + /is-plain-obj@2.1.0: resolution: {integrity: sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==} engines: {node: '>=8'} @@ -1519,6 +1797,18 @@ packages: argparse: 2.0.1 dev: true + /json-buffer@3.0.1: + resolution: {integrity: sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==} + dev: true + + /json-schema-traverse@0.4.1: + resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==} + dev: true + + /json-stable-stringify-without-jsonify@1.0.1: + resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==} + dev: true + /jsonparse@1.3.1: resolution: {integrity: sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==} engines: {'0': node >= 0.2.0} @@ -1532,6 +1822,12 @@ packages: underscore: 1.12.1 dev: false + /keyv@4.5.4: + resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==} + dependencies: + json-buffer: 3.0.1 + dev: true + /levn@0.3.0: resolution: {integrity: sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA==} engines: {node: '>= 0.8.0'} @@ -1540,6 +1836,14 @@ packages: type-check: 0.3.2 dev: false + /levn@0.4.1: + resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} + engines: {node: '>= 0.8.0'} + dependencies: + prelude-ls: 1.2.1 + type-check: 0.4.0 + dev: true + /locate-path@6.0.0: resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} engines: {node: '>=10'} @@ -1547,6 +1851,10 @@ packages: p-locate: 5.0.0 dev: true + /lodash.merge@4.6.2: + resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} + dev: true + /lodash@4.17.21: resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} dev: true @@ -1658,6 +1966,10 @@ packages: hasBin: true dev: true + /natural-compare@1.4.0: + resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} + dev: true + /node-addon-api@3.2.1: resolution: {integrity: sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==} dev: false @@ -1690,6 +2002,18 @@ packages: word-wrap: 1.2.5 dev: false + /optionator@0.9.4: + resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==} + engines: {node: '>= 0.8.0'} + dependencies: + deep-is: 0.1.4 + fast-levenshtein: 2.0.6 + levn: 0.4.1 + prelude-ls: 1.2.1 + type-check: 0.4.0 + word-wrap: 1.2.5 + dev: true + /p-limit@3.1.0: resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} engines: {node: '>=10'} @@ -1704,6 +2028,13 @@ packages: p-limit: 3.1.0 dev: true + /parent-module@1.0.1: + resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==} + engines: {node: '>=6'} + dependencies: + callsites: 3.1.0 + dev: true + /path-exists@4.0.0: resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} engines: {node: '>=8'} @@ -1714,6 +2045,11 @@ packages: engines: {node: '>=0.10.0'} dev: true + /path-key@3.1.1: + resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} + engines: {node: '>=8'} + dev: true + /pathval@1.1.1: resolution: {integrity: sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==} dev: true @@ -1728,6 +2064,11 @@ packages: engines: {node: '>= 0.8.0'} dev: false + /prelude-ls@1.2.1: + resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} + engines: {node: '>= 0.8.0'} + dev: true + /pretty-format@29.7.0: resolution: {integrity: sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} @@ -1737,6 +2078,15 @@ packages: react-is: 18.2.0 dev: true + /punycode@2.3.1: + resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} + engines: {node: '>=6'} + dev: true + + /queue-microtask@1.2.3: + resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} + dev: true + /r1csfile@0.0.16: resolution: {integrity: sha512-A2jRVWzGgmXeG2lVAc0H4suJmzt50it5UvBnycJgBCpMXM3tH/M6RguP7nvs6suY/yYnkN6jX6iTScSiDUF3FA==} dependencies: @@ -1798,6 +2148,16 @@ packages: engines: {node: '>=0.10.0'} dev: true + /resolve-from@4.0.0: + resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==} + engines: {node: '>=4'} + dev: true + + /reusify@1.0.4: + resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} + engines: {iojs: '>=1.0.0', node: '>=0.10.0'} + dev: true + /rimraf@3.0.2: resolution: {integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==} hasBin: true @@ -1805,6 +2165,12 @@ packages: glob: 7.2.3 dev: true + /run-parallel@1.2.0: + resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} + dependencies: + queue-microtask: 1.2.3 + dev: true + /safe-buffer@5.2.1: resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} @@ -1828,6 +2194,18 @@ packages: has-property-descriptors: 1.0.1 dev: true + /shebang-command@2.0.0: + resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} + engines: {node: '>=8'} + dependencies: + shebang-regex: 3.0.0 + dev: true + + /shebang-regex@3.0.0: + resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} + engines: {node: '>=8'} + dev: true + /slash@3.0.0: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} engines: {node: '>=8'} @@ -1937,6 +2315,10 @@ packages: has-flag: 4.0.0 dev: true + /text-table@0.2.0: + resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} + dev: true + /through@2.3.8: resolution: {integrity: sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==} dev: false @@ -2007,6 +2389,13 @@ packages: prelude-ls: 1.1.2 dev: false + /type-check@0.4.0: + resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} + engines: {node: '>= 0.8.0'} + dependencies: + prelude-ls: 1.2.1 + dev: true + /type-detect@4.0.8: resolution: {integrity: sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==} engines: {node: '>=4'} @@ -2026,6 +2415,12 @@ packages: resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} dev: true + /uri-js@4.4.1: + resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} + dependencies: + punycode: 2.3.1 + dev: true + /util-deprecate@1.0.2: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} dev: false @@ -2091,7 +2486,6 @@ packages: /word-wrap@1.2.5: resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==} engines: {node: '>=0.10.0'} - dev: false /worker-threads@1.0.0: resolution: {integrity: sha512-vK6Hhvph8oLxocEJIlc3YfGAZhm210uGzjZsXSu+JYLAQ/s/w4Tqgl60JrdH58hW8NSGP4m3bp8a92qPXgX05w==} diff --git a/scripts/README.md b/scripts/README.md index 9018ea6..b60cfb7 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -701,7 +701,7 @@ npx ts-node ./scripts/input_prep_for_layer_three.ts \ --merkle-root-path \ --layer-two-sanitized-proof-paths \ --write-layer-three-data-to \ - --blinding-factor + --blindingFactor ``` Note: the layer two proof paths must be separated by a comma (e.g. "path1,path2,path3") @@ -712,7 +712,7 @@ npx ts-node ./scripts/input_prep_for_layer_three.ts \ --merkle-root-path ./build/merkle_root.json \ --layer-two-sanitized-proof-paths "./build/layer_two/batch_0/sanitized_proof.json,./build/layer_two/batch_1/sanitized_proof.json" \ --write-layer-three-data-to ./build/layer_three \ - --blinding-factor 78534060564309 + --blindingFactor 78534060564309 ```
@@ -969,8 +969,17 @@ matches the one that was outputted by the layer 3 circuit. ```bash npx ts-node ./scripts/pedersen_commitment_checker.ts \ + --poa-input-data \ --layer-three-public-inputs \ - --blinding-factor + --blindingFactor +``` + +Example: +```bash +npx ts-node ./scripts/pedersen_commitment_checker.ts \ + --poa-input-data tests/4_sigs_2_batches_12_height/input_data_for_4_accounts.json + --layer-three-public-inputs tests/4_sigs_2_batches_12_height/layer_three/public.json \ + --blindingFactor 57896044618658097711785492504343953926634992332820282019728792003956564819948 \ ``` ## [Sanitize G16 proof](./sanitize_groth16_proof.py) diff --git a/scripts/ecdsa_sigs_parser.ts b/scripts/ecdsa_sigs_parser.ts index 564d7ff..4ec2766 100644 --- a/scripts/ecdsa_sigs_parser.ts +++ b/scripts/ecdsa_sigs_parser.ts @@ -44,6 +44,8 @@ fs.readFile(signaturesPath, function read(err: any, jsonIn: any) { let sigsInputData: SignatureData[] = JSON.parse(jsonIn); + console.log(`Parsing ${sigsInputData.length} ECDSA signatures..`); + let accountAttestations: AccountAttestation[] = sigsInputData.map(sigInputData => { let ethers_ecdsaSig = ethers.Signature.from(sigInputData.signature); let pubkey = ethers.SigningKey.recoverPublicKey(sigInputData.signature.msghash, ethers_ecdsaSig) @@ -81,6 +83,8 @@ fs.readFile(signaturesPath, function read(err: any, jsonIn: any) { }; }); + console.log(`Successfully parsed ECDSA signatures and converted them to ECDSA* signatures`); + let outputData: ProofOfAssetsInputFileShape = { accountAttestations } diff --git a/scripts/full_workflow.sh b/scripts/full_workflow.sh index 69c4987..fc0edc5 100755 --- a/scripts/full_workflow.sh +++ b/scripts/full_workflow.sh @@ -281,8 +281,23 @@ set_ptau_path() { set_signals_path() { declare -n ret=$2 local name + parse_layer_name $1 name - ret="$build_dir"/layer_"$name"_input.json + + if [[ $name == one || $name == two ]]; then + batch_num=$3 + if [[ -z $batch_num ]]; then + ERR_MSG="$ERR_PREFIX: [likely a bug] No batch number set for signals path. Layer: $name" + exit 1 + else + ret="$build_dir"/layer_"$name"/"$batch_num"/layer_"$name"_"$batch_num"_input.json + fi + elif [[ $name == three ]]; then + ret="$build_dir"/layer_"$name"/layer_"$name"_input.json + else + ERR_MSG="$ERR_PREFIX: [likely a bug] Invalid layer selection for signals path: $name" + exit 1 + fi } set_existing_zkey_path() { @@ -357,7 +372,7 @@ generate_merkle_tree() { MSG="GENERATING MERKLE TREE FOR ANONYMITY SET, AND MERKLE PROOFS FOR OWNED ADDRESSES" printf "\n================ $MSG ================\nSEE $logs_dir/merkle_tree.log\n" - RUSTFLAGS=-Awarnings execute cargo run --bin merkle-tree -- \ + RUSTFLAGS=-Awarnings execute ./target/release/merkle-tree \ --anon-set "$anon_set_path" \ --poa-input-data "$parsed_sigs_path" \ --output-dir "$build_dir" \ @@ -388,7 +403,7 @@ fi # these need to be exported for the parallel command export -f setup_layer set_layer_build_dir set_ptau_path set_zkey_arg parse_layer_name set_existing_zkey_path export SCRIPTS_DIR FULL_WORKFLOW_DIR ZKEY_DIR -export threshold parallelism num_sigs num_sigs_per_batch build_dir logs_dir remainder merkle_tree_height +export parallelism num_sigs num_sigs_per_batch build_dir logs_dir remainder merkle_tree_height layers="one two three $setup_remainder_inputs" @@ -460,16 +475,16 @@ prove_layers_one_two() { local start_index end_index build signals circuit zkey proof # Index range of the signature set to be done in this batch. - start_index=$((i * threshold)) + start_index=$((i * num_sigs_per_batch)) if [[ $i -eq $((parallelism - 1)) ]]; then end_index=$num_sigs else - end_index=$((start_index + threshold)) # not inclusive + end_index=$((start_index + num_sigs_per_batch)) # not inclusive fi # Setup layer 1 path variables. set_layer_build_dir 1 build - set_signals_path 1 signals + set_signals_path 1 signals batch_"$i" set_circuit_path 1 circuit set_zkey_arg 1 zkey @@ -490,7 +505,7 @@ prove_layers_one_two() { # Setup layer 2 path variables. set_layer_build_dir 2 build - set_signals_path 2 signals + set_signals_path 2 signals batch_"$i" set_circuit_path 2 circuit set_zkey_arg 2 zkey @@ -561,17 +576,18 @@ execute npx ts-node "$SCRIPTS_DIR"/input_prep_for_layer_three.ts \ --merkle-root-path "$merkle_root_path" \ --layer-two-sanitized-proof-paths "$layer_two_proofs" \ --write-layer-three-data-to "$signals" \ - --blinding-factor $blinding_factor + --blindingFactor $blinding_factor MSG="RUNNING PROVING SYSTEM FOR LAYER THREE CIRCUIT" printf "\n================ $MSG ================\n" "$SCRIPTS_DIR"/g16_prove.sh -b -B "$build" $zkey "$circuit" "$signals" +"$SCRIPTS_DIR"/g16_verify.sh -b -B "$build" "$circuit" MSG="VERIFYING FINAL PEDERSEN COMMITMENT" execute npx ts-node "$SCRIPTS_DIR"/pedersen_commitment_checker.ts \ --poa-input-data "$parsed_sigs_path" \ --layer-three-public-inputs "$build"/public.json \ - --blinding-factor $blinding_factor + --blindingFactor $blinding_factor echo "SUCCESS" diff --git a/scripts/generate_circuits.ts b/scripts/generate_circuits.ts index c06db8b..9eda708 100644 --- a/scripts/generate_circuits.ts +++ b/scripts/generate_circuits.ts @@ -59,7 +59,17 @@ assert.ok(typeof parallelism === 'number'); assert.ok(typeof circuitsDir === 'string'); assert.ok(typeof circuitsLib === 'string'); +console.log(`Generating circuits for input values: +Number of signatures in batch: ${numSigs} +Number of signatures in last batch: ${numSigsRemainder} +Merkle tree height: ${merkleTreeHeight} +Number of batches: ${parallelism} +Directory to write circom files to: ${circuitsDir} +Circuits library: ${circuitsLib} +`); + if (!fs.existsSync(circuitsDir)) { + console.log(`Creating directory ${circuitsDir} to write circuits to`); fs.mkdirSync(circuitsDir); } @@ -86,6 +96,8 @@ component main = LayerThree(${parallelism}); `}; if (numSigsRemainder > 0) { + console.log(`Different circuits required for the final batch (named with suffix 'remainder')`); + let remainderCircuits = { one_remainder: `pragma circom 2.1.7; @@ -112,3 +124,5 @@ for (const [name, code] of Object.entries(circuits)) { let filepath = path.join(circuitsDir, "layer_" + name + ".circom"); fs.writeFileSync(filepath, code); } + +console.log("Successfully wrote circuits."); diff --git a/scripts/input_prep_for_layer_one.ts b/scripts/input_prep_for_layer_one.ts index 2f0b39f..c0e4d88 100644 --- a/scripts/input_prep_for_layer_one.ts +++ b/scripts/input_prep_for_layer_one.ts @@ -13,14 +13,11 @@ Some of this code was taken from https://github.com/puma314/batch-ecdsa/blob/b512c651f497985a74858154e4a69bcdaf02443e/test/utils.ts **/ -import { Point, CURVE } from '@noble/secp256k1'; - import { jsonReviver } from "./lib/json_serde"; import { EcdsaStarSignature, ProofOfAssetsInputFileShape } from "./lib/interfaces"; import { bigint_to_array, Uint8Array_to_bigint } from "./lib/utils"; const fs = require('fs'); -const circomlibjs = require("circomlibjs"); const path = require('path'); interface LayerOneInputFileShape { @@ -71,6 +68,13 @@ var layerOneInputPath = argv.layerOneInputPath; var startIndex = argv.accountStartIndex; var endIndex = argv.accountEndIndex; +console.log(`Preparing input for layer 1 using the following data: +- System input: ${inputDataPath} +- Start index for batch: ${startIndex} +- End index for batch: ${endIndex} +Path to write processed data to: ${layerOneInputPath} +`); + fs.readFile(inputDataPath, function read(err: any, json_in: any) { if (err) { throw err; @@ -79,6 +83,7 @@ fs.readFile(inputDataPath, function read(err: any, json_in: any) { var inputData: ProofOfAssetsInputFileShape = JSON.parse(json_in, jsonReviver); if (endIndex === -1) { + console.log("Batch contains all input data i.e. there is only 1 batch"); endIndex = inputData.accountAttestations.length; } @@ -92,7 +97,7 @@ fs.readFile(inputDataPath, function read(err: any, json_in: any) { const jsonOut = JSON.stringify( layerOneInput, - (key, value) => typeof value === "bigint" ? value.toString() : value, + (_, value) => typeof value === "bigint" ? value.toString() : value, 2 ); diff --git a/scripts/input_prep_for_layer_three.ts b/scripts/input_prep_for_layer_three.ts index 783ec5d..83e6b70 100644 --- a/scripts/input_prep_for_layer_three.ts +++ b/scripts/input_prep_for_layer_three.ts @@ -13,7 +13,7 @@ npx ts-node ./scripts/input_prep_for_layer_three.ts \ --merkle-root-path \ --layer-two-sanitized-proof-paths \ --write-layer-three-data-to \ - --blinding-factor + --blindingFactor ``` Note: the layer two proof paths must be separated by a comma (e.g. "path1,path2,path3") @@ -24,7 +24,7 @@ npx ts-node ./scripts/input_prep_for_layer_three.ts \ --merkle-root-path ./build/merkle_root.json \ --layer-two-sanitized-proof-paths "./build/layer_two/batch_0/sanitized_proof.json,./build/layer_two/batch_1/sanitized_proof.json" \ --write-layer-three-data-to ./build/layer_three \ - --blinding-factor 78534060564309 + --blindingFactor 78534060564309 ``` **/ @@ -91,8 +91,9 @@ var argv = require('minimist')(process.argv.slice(2), { merkleRootPath: ['merkle-root-path', 'm'], layerTwoSanitizedProofPaths: ['layer-two-sanitized-proof-paths', 'p'], layerThreeInputPath: ['write-layer-three-data-to', 'o'], - blindingFactor: ['blinding-factor', 'b'], }, + // if we don't treat this as a string then there are problems converting to bigint + string: ['blindingFactor'] }); let merkleRootPath = argv.merkleRootPath; @@ -106,7 +107,6 @@ let merkleRoot: bigint = JSON.parse(merkleRootRaw, jsonReviver); let proofDataArray: Groth16ProofAsInput[] = []; let balances: bigint[] = []; - for (const layerTwoProofPath of layerTwoSanitizedProofPaths.split(',')) { if (!fs.lstatSync(layerTwoProofPath).isFile()) { throw new Error(`Expected ${layerTwoProofPath} to be a path to a file`); @@ -123,6 +123,13 @@ for (const layerTwoProofPath of layerTwoSanitizedProofPaths.split(',')) { proofDataArray.push(proofData); } +console.log(`Preparing input for layer 3 using the following data: +- Merkle root: ${merkleRoot} +- Blinding factor: ${blindingFactor} +- Balances (layer 2 output): ${balances} +Path to write processed data to: ${layerThreeInputPath} +`); + let layerThreeInput: LayerThreeInputFileShape = constructInput(proofDataArray, balances, merkleRoot, blindingFactor); const jsonOut = JSON.stringify( diff --git a/scripts/input_prep_for_layer_two.ts b/scripts/input_prep_for_layer_two.ts index 068217c..1abf19e 100644 --- a/scripts/input_prep_for_layer_two.ts +++ b/scripts/input_prep_for_layer_two.ts @@ -87,6 +87,8 @@ async function writePubkeyXCoordsHash(pubkeys: Point[], outputPath: String): Pro let xCoords = pubkeys.map(pubkey => bigint_to_array(64, 4, pubkey.x)).flat(); let hash = await hashXCoords(xCoords); + console.log(`Hash of public keys x-coords: ${hash}`); + fs.writeFileSync(outputPath, hash); return hash; @@ -123,6 +125,8 @@ function constructInput(proofData: Groth16ProofAsInput, xCoordsHash: string, acc // that the addresses are in ascending order, which is required by the circuit so that // the prover cannot do a double-spend attack. function checkAddressOrdering(accountAttestations: AccountAttestation[], merkleLeaves: Leaf[]) { + console.log("Checking that the order of addresses in input data & Merkle proofs is the same..") + if (accountAttestations.length != merkleLeaves.length) { throw new Error(`Length of input data array ${accountAttestations.length} should equal length of merkle proofs array ${merkleLeaves.length}`); } @@ -186,7 +190,18 @@ let endIndex = argv.accountEndIndex; let inputDataRaw = fs.readFileSync(inputDataPath); let inputData: ProofOfAssetsInputFileShape = JSON.parse(inputDataRaw, jsonReviver); +console.log(`Preparing input for layer 2 using the following data: +- System input: ${inputDataPath} +- Start index for batch: ${startIndex} +- End index for batch: ${endIndex} +- Merkle proofs path: ${merkleProofsPath} +- Merkle root path: ${merkleRootPath} +Path to write processed data to: ${layerTwoInputPath} +Path to write public keys hash to: ${xCoordsHashPath} +`); + if (endIndex === -1) { + console.log("Batch contains all input data i.e. there is only 1 batch"); endIndex = inputData.accountAttestations.length; } @@ -219,7 +234,7 @@ writePubkeyXCoordsHash(accountAttestations.map(w => w.signature.pubkey), xCoords const jsonOut = JSON.stringify( layerTwoInput, - (key, value) => typeof value === "bigint" ? value.toString() : value, + (_, value) => typeof value === "bigint" ? value.toString() : value, 2 ); diff --git a/scripts/machine_initialization.sh b/scripts/machine_initialization.sh index e99131c..f943186 100755 --- a/scripts/machine_initialization.sh +++ b/scripts/machine_initialization.sh @@ -364,6 +364,8 @@ if $REPO; then cd - pip install -r requirements.txt + + cargo build --release fi # TODO instead of checking if the file exists rather check its checksum, diff --git a/scripts/merkle_tree.rs b/scripts/merkle_tree.rs index 982f76d..ec672e2 100644 --- a/scripts/merkle_tree.rs +++ b/scripts/merkle_tree.rs @@ -265,7 +265,6 @@ fn build_leaves(anon_set_file_path: PathBuf) -> Vec<[u8; 32]> { leaves.len() ); - leaves.sort(); leaves } @@ -329,8 +328,6 @@ fn generate_proofs( }) .collect(); - owned_leaves.sort_by(|a, b| a.hash.cmp(&b.hash)); - let mut owned_leaf_indices = Vec::::new(); let mut anon_i = 0; @@ -361,17 +358,17 @@ fn generate_proofs( let anon_set_index = *owned_leaf_indices.get(i).unwrap(); let proof: MerkleProof = merkle_tree.proof(&[anon_set_index]); + let owned_leaf = owned_leaves.get(i).unwrap(); output_leaves.push(Leaf { address: BigIntJson { - __bigint__: owned_leaves.get(i).unwrap().address.clone(), + __bigint__: owned_leaf.address.clone(), }, balance: BigIntJson { - __bigint__: owned_leaves.get(i).unwrap().balance.clone(), + __bigint__: owned_leaf.balance.clone(), }, hash: BigIntJson { - __bigint__: BigUint::from_bytes_be(&owned_leaves.get(i).unwrap().hash[..]) - .to_string(), + __bigint__: BigUint::from_bytes_be(&owned_leaf.hash[..]).to_string(), }, }); diff --git a/scripts/pedersen_commitment_checker.ts b/scripts/pedersen_commitment_checker.ts index 79eaae5..6524d51 100644 --- a/scripts/pedersen_commitment_checker.ts +++ b/scripts/pedersen_commitment_checker.ts @@ -4,26 +4,34 @@ matches the one that was outputted by the layer 3 circuit. ```bash npx ts-node ./scripts/pedersen_commitment_checker.ts \ + --poa-input-data \ --layer-three-public-inputs \ - --blinding-factor + --blindingFactor +``` + +Example: +```bash +npx ts-node ./scripts/pedersen_commitment_checker.ts \ + --poa-input-data tests/4_sigs_2_batches_12_height/input_data_for_4_accounts.json + --layer-three-public-inputs tests/4_sigs_2_batches_12_height/layer_three/public.json \ + --blindingFactor 57896044618658097711785492504343953926634992332820282019728792003956564819948 \ ``` */ -import { generator_g_formatted, generator_h_formatted, formatScalarPower, pedersenCommitment, dechunkToPoint, pointEqual } from "./lib/pedersen_commitment"; +import { pedersenCommitment, dechunkToPoint, pointEqual } from "./lib/pedersen_commitment"; import { jsonReviver } from "./lib/json_serde"; import { ProofOfAssetsInputFileShape } from "./lib/interfaces"; const assert = require('assert'); const fs = require('fs'); -const circomlibjs = require("circomlibjs"); -const path = require('path'); var argv = require('minimist')(process.argv.slice(2), { alias: { poaInputDataPath: ['poa-input-data', 'i'], layerThreePublicInputsPath: ['layer-three-public-inputs', 'p'], - blindingFactor: ['blinding-factor', 'b'], }, + // if we don't treat this as a string then there are problems converting to bigint + string: ['blindingFactor'] }); let inputDataPath = argv.poaInputDataPath; @@ -41,6 +49,9 @@ let balanceSum = inputData.accountAttestations.reduce( 0n ); +console.log(`Balance sum calculated from input data: ${balanceSum}`); +console.log(`Blinding factor given: ${blindingFactor}`); + let comCalc = pedersenCommitment(balanceSum, blindingFactor); let comCircuit = dechunkToPoint(publicInputs.map(i => BigInt(i))); diff --git a/tests/4_sigs_2_batches_12_height/benchmarks.txt b/tests/4_sigs_2_batches_12_height/benchmarks.txt index c67dd37..f02328c 100644 --- a/tests/4_sigs_2_batches_12_height/benchmarks.txt +++ b/tests/4_sigs_2_batches_12_height/benchmarks.txt @@ -4,7 +4,7 @@ machine specs: - ssd: PCIe v4 docker container -- max mem: 90 GB +- max mem: 110GB (layer 3 zkey gen won't work with <=90GB) - unlimited swap layer 3 zkey gen max memory usage: 290 GB @@ -26,8 +26,8 @@ Layer 1 timings: # Compile: 1.5m # zkey gen: 2.5m # vkey gen: 1s -# witness gen: ? -# proof gen: ? +# witness gen: 20s +# proof gen: 20s Compilation data for layer 2: # non-linear constraints: 19981480 @@ -43,7 +43,7 @@ Layer 2 timings: # zkey gen: 3h 15m # vkey gen: 1s # witness gen: 1m -# proof gen: 27s +# proof gen: 1m Compilation data for layer 3: # non-linear constraints: 48187301 @@ -55,8 +55,8 @@ Compilation data for layer 3: # labels: 64544124 Layer 3 timings: -# Compile: 17m -# zkey gen: ? -# vkey gen: ? -# witness gen: ? -# proof gen: ? +# Compile: 18m +# zkey gen: 34h +# vkey gen: 1s +# witness gen: 2m +# proof gen: 1m diff --git a/tests/4_sigs_2_batches_12_height/layer_one.circom b/tests/4_sigs_2_batches_12_height/layer_one.circom new file mode 100644 index 0000000..373d955 --- /dev/null +++ b/tests/4_sigs_2_batches_12_height/layer_one.circom @@ -0,0 +1,5 @@ +pragma circom 2.1.7; + +include "../../circuits/layer_one.circom"; + +component main = LayerOne(2); diff --git a/tests/4_sigs_2_batches_12_height/layer_one/batch_0/layer_one_batch_0_input.json b/tests/4_sigs_2_batches_12_height/layer_one/batch_0/layer_one_batch_0_input.json new file mode 100644 index 0000000..9bac599 --- /dev/null +++ b/tests/4_sigs_2_batches_12_height/layer_one/batch_0/layer_one_batch_0_input.json @@ -0,0 +1,88 @@ +{ + "r": [ + [ + "8283825256485755217", + "12586025252080832011", + "10034357323917035883", + "16656807064911499678" + ], + [ + "6592705692109320610", + "5755984142664230719", + "7449152340560853872", + "13826303034843243587" + ] + ], + "s": [ + [ + "7057909857611246358", + "13683450941706838642", + "6702724470140675030", + "2025531239386524080" + ], + [ + "15533340121565926900", + "16688202106738241591", + "17495235553685193193", + "4722186637344480522" + ] + ], + "rprime": [ + [ + "17472741145835596079", + "10961668878470433421", + "3936809230092778112", + "1446895159079357967" + ], + [ + "6889075888112430858", + "8505806102411190414", + "15853632118289402100", + "14578682502140089875" + ] + ], + "pubkey": [ + [ + [ + "17105043016749647727", + "5701361998605325075", + "1392987705434378706", + "5556261108040736076" + ], + [ + "3076834974760725370", + "18120500676670971410", + "12043021184502540410", + "2920022113385597452" + ] + ], + [ + [ + "9624140601341552853", + "577372893988295340", + "4582757630355041526", + "12259545538130189379" + ], + [ + "9015510754502857787", + "11374584350181849293", + "14408252452037248603", + "8757260512348593260" + ] + ] + ], + "msghash": [ + [ + "4259029091327649082", + "18075889304104109728", + "193165059624015318", + "4042542633332367681" + ], + [ + "4259029091327649082", + "18075889304104109728", + "193165059624015318", + "4042542633332367681" + ] + ] +} \ No newline at end of file diff --git a/tests/4_sigs_2_batches_12_height/layer_one/batch_0/proof.json b/tests/4_sigs_2_batches_12_height/layer_one/batch_0/proof.json new file mode 100644 index 0000000..a0ce33f --- /dev/null +++ b/tests/4_sigs_2_batches_12_height/layer_one/batch_0/proof.json @@ -0,0 +1 @@ +{"pi_a":["3588956336903508278458088639082250795769881026046423946819712278486965170810","19728840202204753727041489142308069371214116874311577106102600289957235899312","1"],"pi_b":[["13693853089362639305086702553999964814238004852615792031433334061846580376444","8244467083706542322038869099942398078514467392861897017105989146533694143543"],["18601704269088652824418326399207485347619500362582006819488144622840608650810","6903680150249631143332655204961189761788701690502819724147122450255265421808"],["1","0"]],"pi_c":["20073450560917882169471472610112151339187242766522336618782585564565436095712","14429680230385598165372089972102093457539661286840933336480493532380559247769","1"],"protocol":"groth16"} \ No newline at end of file diff --git a/tests/4_sigs_2_batches_12_height/layer_one/batch_0/public.json b/tests/4_sigs_2_batches_12_height/layer_one/batch_0/public.json new file mode 100644 index 0000000..c671b47 --- /dev/null +++ b/tests/4_sigs_2_batches_12_height/layer_one/batch_0/public.json @@ -0,0 +1 @@ +["9000893389993958142909825092262956977854017969992936210397545518212252085408"] \ No newline at end of file diff --git a/tests/4_sigs_2_batches_12_height/layer_one/batch_0/sanitized_proof.json b/tests/4_sigs_2_batches_12_height/layer_one/batch_0/sanitized_proof.json new file mode 100644 index 0000000..9039b85 --- /dev/null +++ b/tests/4_sigs_2_batches_12_height/layer_one/batch_0/sanitized_proof.json @@ -0,0 +1 @@ +{"gamma2": [[[5896345417453, 4240670514135, 6172078461917, 219834884668, 2138480846496, 206187650596], [6286472319682, 5759053266064, 8549822680278, 8639745994386, 912741836299, 219532437284]], [[4404069170602, 525855202521, 8311963231281, 825823174727, 854139906743, 161342114743], [3147424765787, 7086132606363, 7632907980226, 5320198199754, 6592898451945, 77528801456]]], "delta2": [[[5896345417453, 4240670514135, 6172078461917, 219834884668, 2138480846496, 206187650596], [6286472319682, 5759053266064, 8549822680278, 8639745994386, 912741836299, 219532437284]], [[4404069170602, 525855202521, 8311963231281, 825823174727, 854139906743, 161342114743], [3147424765787, 7086132606363, 7632907980226, 5320198199754, 6592898451945, 77528801456]]], "negalfa1xbeta2": [[[4063420080633, 6555003798509, 3528875089017, 5800537096256, 8041381108016, 203518374640], [7676269984398, 1145806392863, 6738515895690, 5144301275423, 8547057760405, 353834589854]], [[5712635615088, 8763475698695, 7480760495871, 1630925336586, 5902994417779, 229051200835], [1066113280330, 5452941452156, 130670027992, 6364438679415, 8227984268724, 117895881848]], [[2720638156466, 8183746692879, 2805734624200, 4541538633192, 1476702149455, 162434980571], [4093955238700, 4839352246179, 5773319594517, 5269728708172, 8404179905859, 4522318692]], [[7907150524416, 8555524456643, 2425990496019, 5117607179458, 886559720121, 343845114320], [3348806304058, 5295378168489, 5426585403009, 4313512356362, 2882006508456, 312905790371]], [[6984987484510, 4411212100320, 517962775393, 5578757090043, 1344911245314, 115782940661], [4257694794763, 5641455412912, 2987387394488, 6147130513016, 8766894161060, 7451503335]], [[3338043330865, 3023333978926, 4787719622265, 3729967781503, 2489094582823, 396043239802], [3390886416082, 169102433935, 2279828268438, 1618451670976, 7055320302964, 48334526481]]], "IC": [[[3438634672293, 428623504470, 1239661638946, 4592575630099, 4718074060279, 391703255017], [736095545553, 7908275742977, 5996144448348, 2612960446962, 6981527486830, 114278943485]], [[7300870722407, 4564868088854, 6027530968738, 7579380702266, 8238732274174, 157946431856], [3402449260953, 923821035216, 1160303724672, 6614167134533, 5612517460683, 19608956603]]], "negpa": [[888989168250, 4089786513428, 5580038308846, 196999003954, 2483856858228, 68158356067], [5835251859863, 5770799346549, 4213988250654, 786345942186, 6846257664561, 41009508679]], "pb": [[[5975506629500, 451240011649, 7687170193318, 38739019584, 440733849809, 260061819421], [6480925948983, 1092475010697, 6635458197966, 3078595733081, 390442426917, 156571791442]], [[219435693626, 1137363613209, 8129453469908, 2779815241811, 3880201331857, 353267486147], [8564125751792, 8273357745654, 2127540493851, 7281845197450, 4443059881936, 131108725123]]], "pc": [[7659228486880, 5712562545745, 4903271222192, 5315576310522, 6258985172348, 381217619384], [5765572266393, 4721646019661, 3893633605316, 8482752124659, 4878450710429, 274036012354]], "pubInput": [9000893389993958142909825092262956977854017969992936210397545518212252085408]} \ No newline at end of file diff --git a/tests/4_sigs_2_batches_12_height/layer_one/batch_1/layer_one_batch_1_input.json b/tests/4_sigs_2_batches_12_height/layer_one/batch_1/layer_one_batch_1_input.json new file mode 100644 index 0000000..474a081 --- /dev/null +++ b/tests/4_sigs_2_batches_12_height/layer_one/batch_1/layer_one_batch_1_input.json @@ -0,0 +1,88 @@ +{ + "r": [ + [ + "18062270279216764066", + "14998891048746818057", + "9451190442309743375", + "4938341300787962776" + ], + [ + "18341532888376914698", + "18426805991054984806", + "17800060033105046952", + "7290173074861377975" + ] + ], + "s": [ + [ + "6158751559077032761", + "2387290828335961488", + "13067131861978709615", + "7545927745435623868" + ], + [ + "11271411995767839205", + "6097696515014378693", + "1910051574845390041", + "6175484978579305312" + ] + ], + "rprime": [ + [ + "14229908297153343703", + "1301934868758488793", + "8054862539108869156", + "548779589522051992" + ], + [ + "13948188981754735383", + "16160597067603772723", + "9660066520840298073", + "13656698123665946097" + ] + ], + "pubkey": [ + [ + [ + "14228908065897860265", + "674372215316085523", + "5502143411088503636", + "5352130313043736271" + ], + [ + "15780325351295040937", + "18053032955918543435", + "14332870360095815283", + "5037907681404033639" + ] + ], + [ + [ + "17816677882583810512", + "7159181518165646761", + "17607006858653642357", + "8906821236153911103" + ], + [ + "16595138451532418448", + "6890360790353706397", + "12220664162022676023", + "15928648658598746638" + ] + ] + ], + "msghash": [ + [ + "4259029091327649082", + "18075889304104109728", + "193165059624015318", + "4042542633332367681" + ], + [ + "4259029091327649082", + "18075889304104109728", + "193165059624015318", + "4042542633332367681" + ] + ] +} \ No newline at end of file diff --git a/tests/4_sigs_2_batches_12_height/layer_one/batch_1/proof.json b/tests/4_sigs_2_batches_12_height/layer_one/batch_1/proof.json new file mode 100644 index 0000000..8452233 --- /dev/null +++ b/tests/4_sigs_2_batches_12_height/layer_one/batch_1/proof.json @@ -0,0 +1 @@ +{"pi_a":["13954819912053585557263975895196150225210866753851599768786634689681804336072","10723942013612784876197019068477602148359023745727733740067134266685214737723","1"],"pi_b":[["12844031903784303211480177128083351359758129495818182154517043584694149581076","7881114331811498328996313854991949102446544602748734627595146947504825151683"],["498360565595666460766264608934714675757535127885061866397244828492931124405","751566881496774803228491055918265358067839711065042325324407118105647635780"],["1","0"]],"pi_c":["17978418762850094514373194856296395224553191737599274063765022692228386239738","8587177082107321305844110287160538567672077298130269888195542700435549563766","1"],"protocol":"groth16"} \ No newline at end of file diff --git a/tests/4_sigs_2_batches_12_height/layer_one/batch_1/public.json b/tests/4_sigs_2_batches_12_height/layer_one/batch_1/public.json new file mode 100644 index 0000000..dc15f9b --- /dev/null +++ b/tests/4_sigs_2_batches_12_height/layer_one/batch_1/public.json @@ -0,0 +1 @@ +["19492645588548049736720929089533886782184841935829231059201178683912765812771"] \ No newline at end of file diff --git a/tests/4_sigs_2_batches_12_height/layer_one/batch_1/sanitized_proof.json b/tests/4_sigs_2_batches_12_height/layer_one/batch_1/sanitized_proof.json new file mode 100644 index 0000000..f1fd4bd --- /dev/null +++ b/tests/4_sigs_2_batches_12_height/layer_one/batch_1/sanitized_proof.json @@ -0,0 +1 @@ +{"gamma2": [[[5896345417453, 4240670514135, 6172078461917, 219834884668, 2138480846496, 206187650596], [6286472319682, 5759053266064, 8549822680278, 8639745994386, 912741836299, 219532437284]], [[4404069170602, 525855202521, 8311963231281, 825823174727, 854139906743, 161342114743], [3147424765787, 7086132606363, 7632907980226, 5320198199754, 6592898451945, 77528801456]]], "delta2": [[[5896345417453, 4240670514135, 6172078461917, 219834884668, 2138480846496, 206187650596], [6286472319682, 5759053266064, 8549822680278, 8639745994386, 912741836299, 219532437284]], [[4404069170602, 525855202521, 8311963231281, 825823174727, 854139906743, 161342114743], [3147424765787, 7086132606363, 7632907980226, 5320198199754, 6592898451945, 77528801456]]], "negalfa1xbeta2": [[[4063420080633, 6555003798509, 3528875089017, 5800537096256, 8041381108016, 203518374640], [7676269984398, 1145806392863, 6738515895690, 5144301275423, 8547057760405, 353834589854]], [[5712635615088, 8763475698695, 7480760495871, 1630925336586, 5902994417779, 229051200835], [1066113280330, 5452941452156, 130670027992, 6364438679415, 8227984268724, 117895881848]], [[2720638156466, 8183746692879, 2805734624200, 4541538633192, 1476702149455, 162434980571], [4093955238700, 4839352246179, 5773319594517, 5269728708172, 8404179905859, 4522318692]], [[7907150524416, 8555524456643, 2425990496019, 5117607179458, 886559720121, 343845114320], [3348806304058, 5295378168489, 5426585403009, 4313512356362, 2882006508456, 312905790371]], [[6984987484510, 4411212100320, 517962775393, 5578757090043, 1344911245314, 115782940661], [4257694794763, 5641455412912, 2987387394488, 6147130513016, 8766894161060, 7451503335]], [[3338043330865, 3023333978926, 4787719622265, 3729967781503, 2489094582823, 396043239802], [3390886416082, 169102433935, 2279828268438, 1618451670976, 7055320302964, 48334526481]]], "IC": [[[3438634672293, 428623504470, 1239661638946, 4592575630099, 4718074060279, 391703255017], [736095545553, 7908275742977, 5996144448348, 2612960446962, 6981527486830, 114278943485]], [[7300870722407, 4564868088854, 6027530968738, 7579380702266, 8238732274174, 157946431856], [3402449260953, 923821035216, 1160303724672, 6614167134533, 5612517460683, 19608956603]]], "negpa": [[6666369473480, 963416241449, 6865529509905, 1937457309095, 4971875816243, 265017875709], [947852687372, 6616656488978, 7107363246341, 5343318142587, 5874056305673, 212022750266]], "pb": [[[338826496276, 2629408116079, 2847411429040, 8158085671120, 1478664846647, 243922750142], [1565230870723, 6032911963381, 5249017874917, 4835534477071, 5181809202290, 149671310099]], [[302466059445, 2915838224464, 7773337681826, 4003701148897, 7543896879428, 9464433024], [5871798181188, 6266063000028, 1154891481013, 63256422964, 3906375139267, 14273108477]]], "pc": [[7991010243834, 1376398010037, 7393816202935, 6434714278384, 4963491009176, 341430586648], [1309722651510, 4102964328770, 544329317532, 987315288907, 8550210757569, 163080243455]], "pubInput": [19492645588548049736720929089533886782184841935829231059201178683912765812771]} \ No newline at end of file diff --git a/tests/4_sigs_2_batches_12_height/layer_one/layer_one_vkey.json b/tests/4_sigs_2_batches_12_height/layer_one/layer_one_vkey.json new file mode 100644 index 0000000..52d9e58 --- /dev/null +++ b/tests/4_sigs_2_batches_12_height/layer_one/layer_one_vkey.json @@ -0,0 +1,94 @@ +{ + "protocol": "groth16", + "curve": "bn128", + "nPublic": 1, + "vk_alpha_1": [ + "20491192805390485299153009773594534940189261866228447918068658471970481763042", + "9383485363053290200918347156157836566562967994039712273449902621266178545958", + "1" + ], + "vk_beta_2": [ + [ + "6375614351688725206403948262868962793625744043794305715222011528459656738731", + "4252822878758300859123897981450591353533073413197771768651442665752259397132" + ], + [ + "10505242626370262277552901082094356697409835680220590971873171140371331206856", + "21847035105528745403288232691147584728191162732299865338377159692350059136679" + ], + [ + "1", + "0" + ] + ], + "vk_gamma_2": [ + [ + "10857046999023057135944570762232829481370756359578518086990519993285655852781", + "11559732032986387107991004021392285783925812861821192530917403151452391805634" + ], + [ + "8495653923123431417604973247489272438418190587263600148770280649306958101930", + "4082367875863433681332203403145435568316851327593401208105741076214120093531" + ], + [ + "1", + "0" + ] + ], + "vk_delta_2": [ + [ + "10857046999023057135944570762232829481370756359578518086990519993285655852781", + "11559732032986387107991004021392285783925812861821192530917403151452391805634" + ], + [ + "8495653923123431417604973247489272438418190587263600148770280649306958101930", + "4082367875863433681332203403145435568316851327593401208105741076214120093531" + ], + [ + "1", + "0" + ] + ], + "vk_alphabeta_12": [ + [ + [ + "2029413683389138792403550203267699914886160938906632433982220835551125967885", + "21072700047562757817161031222997517981543347628379360635925549008442030252106" + ], + [ + "5940354580057074848093997050200682056184807770593307860589430076672439820312", + "12156638873931618554171829126792193045421052652279363021382169897324752428276" + ], + [ + "7898200236362823042373859371574133993780991612861777490112507062703164551277", + "7074218545237549455313236346927434013100842096812539264420499035217050630853" + ] + ], + [ + [ + "7077479683546002997211712695946002074877511277312570035766170199895071832130", + "10093483419865920389913245021038182291233451549023025229112148274109565435465" + ], + [ + "4595479056700221319381530156280926371456704509942304414423590385166031118820", + "19831328484489333784475432780421641293929726139240675179672856274388269393268" + ], + [ + "11934129596455521040620786944827826205713621633706285934057045369193958244500", + "8037395052364110730298837004334506829870972346962140206007064471173334027475" + ] + ] + ], + "IC": [ + [ + "20625583719965013928052478711607056403382308811402008297891595719487226716325", + "6017488713975235137813171783620559305333800188891427992772189439505137576145", + "1" + ], + [ + "8316850349862801724531830564484208746787953817783164008107815266813603631975", + "1032532078579206440156972485856490010797489952623902864786100010662947688857", + "1" + ] + ] +} \ No newline at end of file diff --git a/tests/4_sigs_2_batches_12_height/layer_three.circom b/tests/4_sigs_2_batches_12_height/layer_three.circom new file mode 100644 index 0000000..82737c4 --- /dev/null +++ b/tests/4_sigs_2_batches_12_height/layer_three.circom @@ -0,0 +1,5 @@ +pragma circom 2.1.7; + +include "../../circuits/layer_three.circom"; + +component main = LayerThree(2); diff --git a/tests/4_sigs_2_batches_12_height/layer_three/layer_three_input.json b/tests/4_sigs_2_batches_12_height/layer_three/layer_three_input.json new file mode 100644 index 0000000..2e51ff3 --- /dev/null +++ b/tests/4_sigs_2_batches_12_height/layer_three/layer_three_input.json @@ -0,0 +1,954 @@ +{ + "gamma2": [ + [ + [ + [ + 5896345417453, + 4240670514135, + 6172078461917, + 219834884668, + 2138480846496, + 206187650596 + ], + [ + 6286472319682, + 5759053266064, + 8549822680278, + 8639745994386, + 912741836299, + 219532437284 + ] + ], + [ + [ + 4404069170602, + 525855202521, + 8311963231281, + 825823174727, + 854139906743, + 161342114743 + ], + [ + 3147424765787, + 7086132606363, + 7632907980226, + 5320198199754, + 6592898451945, + 77528801456 + ] + ] + ], + [ + [ + [ + 5896345417453, + 4240670514135, + 6172078461917, + 219834884668, + 2138480846496, + 206187650596 + ], + [ + 6286472319682, + 5759053266064, + 8549822680278, + 8639745994386, + 912741836299, + 219532437284 + ] + ], + [ + [ + 4404069170602, + 525855202521, + 8311963231281, + 825823174727, + 854139906743, + 161342114743 + ], + [ + 3147424765787, + 7086132606363, + 7632907980226, + 5320198199754, + 6592898451945, + 77528801456 + ] + ] + ] + ], + "delta2": [ + [ + [ + [ + 7300997600937, + 3671456639412, + 2717627081993, + 6985411679643, + 1907644562408, + 21301064739 + ], + [ + 1872180458763, + 2832557307082, + 5519107048858, + 283194671451, + 7082056950819, + 335024307424 + ] + ], + [ + [ + 5381216886041, + 4559876870073, + 7161995890056, + 8570550695984, + 5414652438075, + 221552075284 + ], + [ + 7523888268402, + 7759490010103, + 1269368874867, + 6474541189950, + 5220500539024, + 207406487578 + ] + ] + ], + [ + [ + [ + 7300997600937, + 3671456639412, + 2717627081993, + 6985411679643, + 1907644562408, + 21301064739 + ], + [ + 1872180458763, + 2832557307082, + 5519107048858, + 283194671451, + 7082056950819, + 335024307424 + ] + ], + [ + [ + 5381216886041, + 4559876870073, + 7161995890056, + 8570550695984, + 5414652438075, + 221552075284 + ], + [ + 7523888268402, + 7759490010103, + 1269368874867, + 6474541189950, + 5220500539024, + 207406487578 + ] + ] + ] + ], + "negalfa1xbeta2": [ + [ + [ + [ + 4063420080633, + 6555003798509, + 3528875089017, + 5800537096256, + 8041381108016, + 203518374640 + ], + [ + 7676269984398, + 1145806392863, + 6738515895690, + 5144301275423, + 8547057760405, + 353834589854 + ] + ], + [ + [ + 5712635615088, + 8763475698695, + 7480760495871, + 1630925336586, + 5902994417779, + 229051200835 + ], + [ + 1066113280330, + 5452941452156, + 130670027992, + 6364438679415, + 8227984268724, + 117895881848 + ] + ], + [ + [ + 2720638156466, + 8183746692879, + 2805734624200, + 4541538633192, + 1476702149455, + 162434980571 + ], + [ + 4093955238700, + 4839352246179, + 5773319594517, + 5269728708172, + 8404179905859, + 4522318692 + ] + ], + [ + [ + 7907150524416, + 8555524456643, + 2425990496019, + 5117607179458, + 886559720121, + 343845114320 + ], + [ + 3348806304058, + 5295378168489, + 5426585403009, + 4313512356362, + 2882006508456, + 312905790371 + ] + ], + [ + [ + 6984987484510, + 4411212100320, + 517962775393, + 5578757090043, + 1344911245314, + 115782940661 + ], + [ + 4257694794763, + 5641455412912, + 2987387394488, + 6147130513016, + 8766894161060, + 7451503335 + ] + ], + [ + [ + 3338043330865, + 3023333978926, + 4787719622265, + 3729967781503, + 2489094582823, + 396043239802 + ], + [ + 3390886416082, + 169102433935, + 2279828268438, + 1618451670976, + 7055320302964, + 48334526481 + ] + ] + ], + [ + [ + [ + 4063420080633, + 6555003798509, + 3528875089017, + 5800537096256, + 8041381108016, + 203518374640 + ], + [ + 7676269984398, + 1145806392863, + 6738515895690, + 5144301275423, + 8547057760405, + 353834589854 + ] + ], + [ + [ + 5712635615088, + 8763475698695, + 7480760495871, + 1630925336586, + 5902994417779, + 229051200835 + ], + [ + 1066113280330, + 5452941452156, + 130670027992, + 6364438679415, + 8227984268724, + 117895881848 + ] + ], + [ + [ + 2720638156466, + 8183746692879, + 2805734624200, + 4541538633192, + 1476702149455, + 162434980571 + ], + [ + 4093955238700, + 4839352246179, + 5773319594517, + 5269728708172, + 8404179905859, + 4522318692 + ] + ], + [ + [ + 7907150524416, + 8555524456643, + 2425990496019, + 5117607179458, + 886559720121, + 343845114320 + ], + [ + 3348806304058, + 5295378168489, + 5426585403009, + 4313512356362, + 2882006508456, + 312905790371 + ] + ], + [ + [ + 6984987484510, + 4411212100320, + 517962775393, + 5578757090043, + 1344911245314, + 115782940661 + ], + [ + 4257694794763, + 5641455412912, + 2987387394488, + 6147130513016, + 8766894161060, + 7451503335 + ] + ], + [ + [ + 3338043330865, + 3023333978926, + 4787719622265, + 3729967781503, + 2489094582823, + 396043239802 + ], + [ + 3390886416082, + 169102433935, + 2279828268438, + 1618451670976, + 7055320302964, + 48334526481 + ] + ] + ] + ], + "IC": [ + [ + [ + [ + 1993850387479, + 601431161060, + 1264413738710, + 6024355881581, + 3655307968236, + 313892020972 + ], + [ + 248631750559, + 6785810023803, + 586465185482, + 8253502562712, + 6140122289189, + 368515743347 + ] + ], + [ + [ + 7078574820332, + 7507013140647, + 3381129117031, + 1438519995117, + 7726812166613, + 175391830205 + ], + [ + 419709697496, + 2704656433194, + 3096425096437, + 7678054651869, + 4915955857917, + 212377660173 + ] + ], + [ + [ + 2187758863416, + 5026353877863, + 7502804309061, + 5479535447000, + 4777301685959, + 356733234343 + ], + [ + 2725984561233, + 6506864462978, + 4379544096917, + 8696971335248, + 434216993311, + 90117895219 + ] + ] + ], + [ + [ + [ + 1993850387479, + 601431161060, + 1264413738710, + 6024355881581, + 3655307968236, + 313892020972 + ], + [ + 248631750559, + 6785810023803, + 586465185482, + 8253502562712, + 6140122289189, + 368515743347 + ] + ], + [ + [ + 7078574820332, + 7507013140647, + 3381129117031, + 1438519995117, + 7726812166613, + 175391830205 + ], + [ + 419709697496, + 2704656433194, + 3096425096437, + 7678054651869, + 4915955857917, + 212377660173 + ] + ], + [ + [ + 2187758863416, + 5026353877863, + 7502804309061, + 5479535447000, + 4777301685959, + 356733234343 + ], + [ + 2725984561233, + 6506864462978, + 4379544096917, + 8696971335248, + 434216993311, + 90117895219 + ] + ] + ] + ], + "negpa": [ + [ + [ + 6210693699744, + 8410044883335, + 4227607149969, + 2032562056085, + 3686068998772, + 184907718443 + ], + [ + 6084848791208, + 2792611087575, + 5994208362537, + 4668107736667, + 4303465769615, + 52446902846 + ] + ], + [ + [ + 983112648864, + 710950435136, + 3983351386226, + 2019238412404, + 3383486070161, + 99055007920 + ], + [ + 6664379415590, + 3405286667456, + 6722992742146, + 8506800145174, + 5445916891752, + 221676553438 + ] + ] + ], + "pb": [ + [ + [ + [ + 5249110902096, + 7682907370163, + 8085479362734, + 2271526125859, + 1742363940723, + 212555177186 + ], + [ + 7909973451309, + 8079275493041, + 1238328959323, + 242685084731, + 1657600152744, + 337432180143 + ] + ], + [ + [ + 4599920871647, + 855539416662, + 2269986142411, + 2593477331115, + 3001950636726, + 245935791148 + ], + [ + 7268225133093, + 4015830295646, + 4747280990832, + 7509715299076, + 2976568805235, + 265285784173 + ] + ] + ], + [ + [ + [ + 738023511647, + 8570599187683, + 5468685438518, + 8418139980240, + 8280548089242, + 128230885354 + ], + [ + 6511825510623, + 5439362433411, + 5140365578388, + 3570342053789, + 2595721636263, + 310116844528 + ] + ], + [ + [ + 8211375647764, + 5185498657296, + 4584768856453, + 5534322675959, + 7688249336571, + 368533380167 + ], + [ + 1204217846478, + 2429854030881, + 1791776469363, + 251129208664, + 931284974209, + 138601402787 + ] + ] + ] + ], + "pc": [ + [ + [ + 1199689074682, + 5009969793574, + 2452136378762, + 8195015893028, + 8085404497251, + 150191018660 + ], + [ + 3984505858779, + 6507674781789, + 2870227971981, + 7965658142325, + 3631028450622, + 111480746130 + ] + ], + [ + [ + 6753997579501, + 6688098888302, + 4261766387823, + 4068093607760, + 56340378639, + 296501205713 + ], + [ + 5587648706799, + 1880672857317, + 221699952420, + 1260217266870, + 5154945170018, + 411259496656 + ] + ] + ], + "balances": [ + 1582, + 632 + ], + "merkle_root": "4318193320874967181734161223197902340245632311881706422143392565195194701670", + "ped_com_generator_g": [ + [ + "6836562328990639286768922", + "21231440843933962135602345", + "10097852978535018773096760" + ], + [ + "7737125245533626718119512", + "23211375736600880154358579", + "30948500982134506872478105" + ], + [ + "1", + "0", + "0" + ], + [ + "20943500354259764865654179", + "24722277920680796426601402", + "31289658119428895172835987" + ] + ], + "ped_com_generator_h": [ + [ + "25216993871230434893611732", + "9916620965782940099910782", + "22458531548786918476949667" + ], + [ + "21884858353640497412030729", + "35476303531314904878318154", + "26084798248790655303674485" + ], + [ + "10233610430992458328537838", + "30672415684739511832637253", + "30050209230045197847977122" + ], + [ + "2484788782710010642915997", + "32760755509781578113777050", + "16895836248737265303642429" + ] + ], + "ped_com_blinding_factor": [ + "0", + "0", + "1", + "1", + "0", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1" + ] +} \ No newline at end of file diff --git a/tests/4_sigs_2_batches_12_height/layer_three/layer_three_vkey.json b/tests/4_sigs_2_batches_12_height/layer_three/layer_three_vkey.json new file mode 100644 index 0000000..fb59ebf --- /dev/null +++ b/tests/4_sigs_2_batches_12_height/layer_three/layer_three_vkey.json @@ -0,0 +1,149 @@ +{ + "protocol": "groth16", + "curve": "bn128", + "nPublic": 12, + "vk_alpha_1": [ + "20491192805390485299153009773594534940189261866228447918068658471970481763042", + "9383485363053290200918347156157836566562967994039712273449902621266178545958", + "1" + ], + "vk_beta_2": [ + [ + "6375614351688725206403948262868962793625744043794305715222011528459656738731", + "4252822878758300859123897981450591353533073413197771768651442665752259397132" + ], + [ + "10505242626370262277552901082094356697409835680220590971873171140371331206856", + "21847035105528745403288232691147584728191162732299865338377159692350059136679" + ], + [ + "1", + "0" + ] + ], + "vk_gamma_2": [ + [ + "10857046999023057135944570762232829481370756359578518086990519993285655852781", + "11559732032986387107991004021392285783925812861821192530917403151452391805634" + ], + [ + "8495653923123431417604973247489272438418190587263600148770280649306958101930", + "4082367875863433681332203403145435568316851327593401208105741076214120093531" + ], + [ + "1", + "0" + ] + ], + "vk_delta_2": [ + [ + "20752135957831649308428715235845523694123089981475547301774965853299163575165", + "11166464509660687568497308646019664427802067439861635656589088889386485999585" + ], + [ + "14368558932740149474915532255240484582159740027608659190016816966689744628973", + "17284592389429020600372978980409278887220491656935703517793444037774040726138" + ], + [ + "1", + "0" + ] + ], + "vk_alphabeta_12": [ + [ + [ + "2029413683389138792403550203267699914886160938906632433982220835551125967885", + "21072700047562757817161031222997517981543347628379360635925549008442030252106" + ], + [ + "5940354580057074848093997050200682056184807770593307860589430076672439820312", + "12156638873931618554171829126792193045421052652279363021382169897324752428276" + ], + [ + "7898200236362823042373859371574133993780991612861777490112507062703164551277", + "7074218545237549455313236346927434013100842096812539264420499035217050630853" + ] + ], + [ + [ + "7077479683546002997211712695946002074877511277312570035766170199895071832130", + "10093483419865920389913245021038182291233451549023025229112148274109565435465" + ], + [ + "4595479056700221319381530156280926371456704509942304414423590385166031118820", + "19831328484489333784475432780421641293929726139240675179672856274388269393268" + ], + [ + "11934129596455521040620786944827826205713621633706285934057045369193958244500", + "8037395052364110730298837004334506829870972346962140206007064471173334027475" + ] + ] + ], + "IC": [ + [ + "17446980736771223908976028111819298521680164320753476177202783224256048854809", + "7772384605112316739609738704792214020192877382838170057509683858340380908894", + "1" + ], + [ + "3153277083746784414878893079649184664936604725740574548763982751664351655240", + "4272380543430364064107167393903190138956192570688257593841005598347003056015", + "1" + ], + [ + "8063755876413640702423296153423867877399416691933555622141412687809941789480", + "10160774936827936335537831175040673272847039911345771974627743585702071396794", + "1" + ], + [ + "12905292194691113368849909064261333647761383748000658848084489615845708596519", + "5054460807571324428396341345247000243460276213798976318762990142654332083198", + "1" + ], + [ + "14163026474907867849692884981525542546289853379143266601342528670877020747399", + "19287531459192702422644045903484665328149494829439815355202649574856308260571", + "1" + ], + [ + "9980926785255639516271961308665090604878316468065341062836121589691177697795", + "5516148493581594227099280197166537946041546622468491815917135523808634817189", + "1" + ], + [ + "15511848529860314095454437102889226782776368395100287439045947460081908797345", + "17834966801773328467396402087512664691621026564679676611918357916617837483794", + "1" + ], + [ + "16400843628372014093894610237195488326590465676055505718283311051601778750356", + "4646823193245075404815533182233413603038592807965501288361186647864320930862", + "1" + ], + [ + "16050767027136652049571787501648080490646167359934650355840975405735699514109", + "9471251571924637827982168885633911007419596417997438902830987764249232216630", + "1" + ], + [ + "7277872540720893070694307942368613567715628622732683707611908910364214407583", + "9229648254317466296439702289346600544663103875015953280069341699418102093760", + "1" + ], + [ + "4221867288648367631897389630268112041590156389289422517964691415615140813936", + "5809605932904760458408813812533284346794339172187285131573514466630059638028", + "1" + ], + [ + "13797644080144070854665215043164482587233486474965446139110020613166048688294", + "5927857353036029104190805079335343524863517047004665762045949574503317838551", + "1" + ], + [ + "10261988117989168954881241001152521477583284005093968843314390709159760457872", + "6007321311776612851389281701809283125963560798899819595307683630039001022418", + "1" + ] + ] +} \ No newline at end of file diff --git a/tests/4_sigs_2_batches_12_height/layer_three/proof.json b/tests/4_sigs_2_batches_12_height/layer_three/proof.json new file mode 100644 index 0000000..5ef69da --- /dev/null +++ b/tests/4_sigs_2_batches_12_height/layer_three/proof.json @@ -0,0 +1 @@ +{"pi_a":["6121789724380223281956184720223036011810181021796470611328454672536192905481","13664264677229714309246238210316569350420318853583703917099356992735230408926","1"],"pi_b":[["15179239835126767913768419882053184100353324275534327399951477556526114390368","18328428788309396707356928919866729474925224371380892843362139429775983229287"],["11301066205375648802688086780093052234305282205411437776544818999328802106301","8118764259476165796541644345787277597055011084318766274005551891317192830153"],["1","0"]],"pi_c":["13990055210685102352411457924183460906934203772293433362549747728007708974980","12735872834712575929849229435484752807609206067438710207573683251745020412982","1"],"protocol":"groth16"} \ No newline at end of file diff --git a/tests/4_sigs_2_batches_12_height/layer_three/public.json b/tests/4_sigs_2_batches_12_height/layer_three/public.json new file mode 100644 index 0000000..e58be5a --- /dev/null +++ b/tests/4_sigs_2_batches_12_height/layer_three/public.json @@ -0,0 +1 @@ +["37323006132942127659789430","18502626366508469053576455","2226261317640915504556883","29844592400044339381070020","38506669655093591207287407","33245312749822307553279203","33456438196012142413237030","2694187650061437742650984","24373104647763967944760889","36035509487839878566276731","32918383546904653921107155","10427377489130586025251934"] \ No newline at end of file diff --git a/tests/4_sigs_2_batches_12_height/layer_two.circom b/tests/4_sigs_2_batches_12_height/layer_two.circom new file mode 100644 index 0000000..87cabdf --- /dev/null +++ b/tests/4_sigs_2_batches_12_height/layer_two.circom @@ -0,0 +1,5 @@ +pragma circom 2.1.7; + +include "../../circuits/layer_two.circom"; + +component main {public [merkle_root]} = LayerTwo(2, 12); diff --git a/tests/4_sigs_2_batches_12_height/layer_two/batch_0/layer_two_batch_0_input.json b/tests/4_sigs_2_batches_12_height/layer_two/batch_0/layer_two_batch_0_input.json new file mode 100644 index 0000000..026784e --- /dev/null +++ b/tests/4_sigs_2_batches_12_height/layer_two/batch_0/layer_two_batch_0_input.json @@ -0,0 +1,396 @@ +{ + "gamma2": [ + [ + [ + 5896345417453, + 4240670514135, + 6172078461917, + 219834884668, + 2138480846496, + 206187650596 + ], + [ + 6286472319682, + 5759053266064, + 8549822680278, + 8639745994386, + 912741836299, + 219532437284 + ] + ], + [ + [ + 4404069170602, + 525855202521, + 8311963231281, + 825823174727, + 854139906743, + 161342114743 + ], + [ + 3147424765787, + 7086132606363, + 7632907980226, + 5320198199754, + 6592898451945, + 77528801456 + ] + ] + ], + "delta2": [ + [ + [ + 5896345417453, + 4240670514135, + 6172078461917, + 219834884668, + 2138480846496, + 206187650596 + ], + [ + 6286472319682, + 5759053266064, + 8549822680278, + 8639745994386, + 912741836299, + 219532437284 + ] + ], + [ + [ + 4404069170602, + 525855202521, + 8311963231281, + 825823174727, + 854139906743, + 161342114743 + ], + [ + 3147424765787, + 7086132606363, + 7632907980226, + 5320198199754, + 6592898451945, + 77528801456 + ] + ] + ], + "negalfa1xbeta2": [ + [ + [ + 4063420080633, + 6555003798509, + 3528875089017, + 5800537096256, + 8041381108016, + 203518374640 + ], + [ + 7676269984398, + 1145806392863, + 6738515895690, + 5144301275423, + 8547057760405, + 353834589854 + ] + ], + [ + [ + 5712635615088, + 8763475698695, + 7480760495871, + 1630925336586, + 5902994417779, + 229051200835 + ], + [ + 1066113280330, + 5452941452156, + 130670027992, + 6364438679415, + 8227984268724, + 117895881848 + ] + ], + [ + [ + 2720638156466, + 8183746692879, + 2805734624200, + 4541538633192, + 1476702149455, + 162434980571 + ], + [ + 4093955238700, + 4839352246179, + 5773319594517, + 5269728708172, + 8404179905859, + 4522318692 + ] + ], + [ + [ + 7907150524416, + 8555524456643, + 2425990496019, + 5117607179458, + 886559720121, + 343845114320 + ], + [ + 3348806304058, + 5295378168489, + 5426585403009, + 4313512356362, + 2882006508456, + 312905790371 + ] + ], + [ + [ + 6984987484510, + 4411212100320, + 517962775393, + 5578757090043, + 1344911245314, + 115782940661 + ], + [ + 4257694794763, + 5641455412912, + 2987387394488, + 6147130513016, + 8766894161060, + 7451503335 + ] + ], + [ + [ + 3338043330865, + 3023333978926, + 4787719622265, + 3729967781503, + 2489094582823, + 396043239802 + ], + [ + 3390886416082, + 169102433935, + 2279828268438, + 1618451670976, + 7055320302964, + 48334526481 + ] + ] + ], + "IC": [ + [ + [ + 3438634672293, + 428623504470, + 1239661638946, + 4592575630099, + 4718074060279, + 391703255017 + ], + [ + 736095545553, + 7908275742977, + 5996144448348, + 2612960446962, + 6981527486830, + 114278943485 + ] + ], + [ + [ + 7300870722407, + 4564868088854, + 6027530968738, + 7579380702266, + 8238732274174, + 157946431856 + ], + [ + 3402449260953, + 923821035216, + 1160303724672, + 6614167134533, + 5612517460683, + 19608956603 + ] + ] + ], + "negpa": [ + [ + 888989168250, + 4089786513428, + 5580038308846, + 196999003954, + 2483856858228, + 68158356067 + ], + [ + 5835251859863, + 5770799346549, + 4213988250654, + 786345942186, + 6846257664561, + 41009508679 + ] + ], + "pb": [ + [ + [ + 5975506629500, + 451240011649, + 7687170193318, + 38739019584, + 440733849809, + 260061819421 + ], + [ + 6480925948983, + 1092475010697, + 6635458197966, + 3078595733081, + 390442426917, + 156571791442 + ] + ], + [ + [ + 219435693626, + 1137363613209, + 8129453469908, + 2779815241811, + 3880201331857, + 353267486147 + ], + [ + 8564125751792, + 8273357745654, + 2127540493851, + 7281845197450, + 4443059881936, + 131108725123 + ] + ] + ], + "pc": [ + [ + 7659228486880, + 5712562545745, + 4903271222192, + 5315576310522, + 6258985172348, + 381217619384 + ], + [ + 5765572266393, + 4721646019661, + 3893633605316, + 8482752124659, + 4878450710429, + 274036012354 + ] + ], + "pubkey_x_coord_hash": "9000893389993958142909825092262956977854017969992936210397545518212252085408", + "pubkey": [ + [ + [ + "17105043016749647727", + "5701361998605325075", + "1392987705434378706", + "5556261108040736076" + ], + [ + "3076834974760725370", + "18120500676670971410", + "12043021184502540410", + "2920022113385597452" + ] + ], + [ + [ + "9624140601341552853", + "577372893988295340", + "4582757630355041526", + "12259545538130189379" + ], + [ + "9015510754502857787", + "11374584350181849293", + "14408252452037248603", + "8757260512348593260" + ] + ] + ], + "leaf_addresses": [ + "585496983680464354843203206628328260164972202022", + "686020384476461118200129503363572918284147523277" + ], + "leaf_balances": [ + "354", + "278" + ], + "merkle_root": "4318193320874967181734161223197902340245632311881706422143392565195194701670", + "path_elements": [ + [ + "4349721275274738381241569003471081141175587583089487364046676011890610649424", + "10908753786939934283468828605067964211716652841329025740461433382234919489197", + "16352379447560688481481462569228974495382288933654162054648474819334811484041", + "9702153268425194574340318095368306544190936491080468055257364635524808708903", + "17452920407975580192135841508381296905635342117804438506287926028596277420533", + "11982841249028225953064054009031805209069239195940883456151924955407332506690", + "21113074710410554347131009801334441295736984910585571552916658943815010850923", + "4371359742011662026091144991263538807288018595647904280345120195692289292209", + "11138215023390412549764280226461600215418876386837682264043531382845084155545", + "18058162515625986979521314894856053934664827061464386252755122399764572069395", + "1589217760340766630245572284989506044204426535540286344066932667138019105592" + ], + [ + "3848958046091856970940589385460166459056304523201121813167001872014444181853", + "2056558934883355252380410983852491148950282217542215281008528735247677375017", + "15092538165399723178537097617967210674988953803936575594758722094510498620981", + "19278154460008411270109712600548500126746291816569972112816508111158017746771", + "5814415459593048667354029779079975339623334592467480460629331600804878195607", + "15573633139204179332553336935745601940063968797638772468289649255981617936214", + "7728671856352963983406440759840857064012649717847081435752300158500514116859", + "9410817704118227936309163916981605594292390336864083679390135499544732980260", + "11138215023390412549764280226461600215418876386837682264043531382845084155545", + "18058162515625986979521314894856053934664827061464386252755122399764572069395", + "1589217760340766630245572284989506044204426535540286344066932667138019105592" + ] + ], + "path_indices": [ + [ + 1, + 0, + 1, + 1, + 0, + 1, + 0, + 0, + 1, + 1, + 0 + ], + [ + 1, + 1, + 0, + 0, + 1, + 1, + 0, + 1, + 1, + 1, + 0 + ] + ] +} \ No newline at end of file diff --git a/tests/4_sigs_2_batches_12_height/layer_two/batch_0/proof.json b/tests/4_sigs_2_batches_12_height/layer_two/batch_0/proof.json new file mode 100644 index 0000000..a423ce5 --- /dev/null +++ b/tests/4_sigs_2_batches_12_height/layer_two/batch_0/proof.json @@ -0,0 +1 @@ +{"pi_a":["5215854942671395670554719183114044815108253348836947984938961651083127326880","10215609945935094580950571361207913806569171215268149805111000936651669455137","1"],"pi_b":[["6752144199708452920709134547162462457394797403319477803115894642510223447647","16329557791148208182859933823781734983016680301512385259315428500574516797663"],["19405547410919210472179726934253990721718910390168362306072893639780380765204","7298215677993434429542764479974100854676686034818660635123037203688964365006"],["1","0"]],"pi_c":["15612610728063502484523828251422294409074314635241297983525485395305771853037","21655340031681204595031331503029399264054093131453291437860700267979199281391","1"],"protocol":"groth16"} \ No newline at end of file diff --git a/tests/4_sigs_2_batches_12_height/layer_two/batch_0/public.json b/tests/4_sigs_2_batches_12_height/layer_two/batch_0/public.json new file mode 100644 index 0000000..0bc1df7 --- /dev/null +++ b/tests/4_sigs_2_batches_12_height/layer_two/batch_0/public.json @@ -0,0 +1 @@ +["632","4318193320874967181734161223197902340245632311881706422143392565195194701670"] \ No newline at end of file diff --git a/tests/4_sigs_2_batches_12_height/layer_two/batch_0/sanitized_proof.json b/tests/4_sigs_2_batches_12_height/layer_two/batch_0/sanitized_proof.json new file mode 100644 index 0000000..688dcbb --- /dev/null +++ b/tests/4_sigs_2_batches_12_height/layer_two/batch_0/sanitized_proof.json @@ -0,0 +1 @@ +{"gamma2": [[[5896345417453, 4240670514135, 6172078461917, 219834884668, 2138480846496, 206187650596], [6286472319682, 5759053266064, 8549822680278, 8639745994386, 912741836299, 219532437284]], [[4404069170602, 525855202521, 8311963231281, 825823174727, 854139906743, 161342114743], [3147424765787, 7086132606363, 7632907980226, 5320198199754, 6592898451945, 77528801456]]], "delta2": [[[7300997600937, 3671456639412, 2717627081993, 6985411679643, 1907644562408, 21301064739], [1872180458763, 2832557307082, 5519107048858, 283194671451, 7082056950819, 335024307424]], [[5381216886041, 4559876870073, 7161995890056, 8570550695984, 5414652438075, 221552075284], [7523888268402, 7759490010103, 1269368874867, 6474541189950, 5220500539024, 207406487578]]], "negalfa1xbeta2": [[[4063420080633, 6555003798509, 3528875089017, 5800537096256, 8041381108016, 203518374640], [7676269984398, 1145806392863, 6738515895690, 5144301275423, 8547057760405, 353834589854]], [[5712635615088, 8763475698695, 7480760495871, 1630925336586, 5902994417779, 229051200835], [1066113280330, 5452941452156, 130670027992, 6364438679415, 8227984268724, 117895881848]], [[2720638156466, 8183746692879, 2805734624200, 4541538633192, 1476702149455, 162434980571], [4093955238700, 4839352246179, 5773319594517, 5269728708172, 8404179905859, 4522318692]], [[7907150524416, 8555524456643, 2425990496019, 5117607179458, 886559720121, 343845114320], [3348806304058, 5295378168489, 5426585403009, 4313512356362, 2882006508456, 312905790371]], [[6984987484510, 4411212100320, 517962775393, 5578757090043, 1344911245314, 115782940661], [4257694794763, 5641455412912, 2987387394488, 6147130513016, 8766894161060, 7451503335]], [[3338043330865, 3023333978926, 4787719622265, 3729967781503, 2489094582823, 396043239802], [3390886416082, 169102433935, 2279828268438, 1618451670976, 7055320302964, 48334526481]]], "IC": [[[1993850387479, 601431161060, 1264413738710, 6024355881581, 3655307968236, 313892020972], [248631750559, 6785810023803, 586465185482, 8253502562712, 6140122289189, 368515743347]], [[7078574820332, 7507013140647, 3381129117031, 1438519995117, 7726812166613, 175391830205], [419709697496, 2704656433194, 3096425096437, 7678054651869, 4915955857917, 212377660173]], [[2187758863416, 5026353877863, 7502804309061, 5479535447000, 4777301685959, 356733234343], [2725984561233, 6506864462978, 4379544096917, 8696971335248, 434216993311, 90117895219]]], "negpa": [[983112648864, 710950435136, 3983351386226, 2019238412404, 3383486070161, 99055007920], [6664379415590, 3405286667456, 6722992742146, 8506800145174, 5445916891752, 221676553438]], "pb": [[[738023511647, 8570599187683, 5468685438518, 8418139980240, 8280548089242, 128230885354], [6511825510623, 5439362433411, 5140365578388, 3570342053789, 2595721636263, 310116844528]], [[8211375647764, 5185498657296, 4584768856453, 5534322675959, 7688249336571, 368533380167], [1204217846478, 2429854030881, 1791776469363, 251129208664, 931284974209, 138601402787]]], "pc": [[6753997579501, 6688098888302, 4261766387823, 4068093607760, 56340378639, 296501205713], [5587648706799, 1880672857317, 221699952420, 1260217266870, 5154945170018, 411259496656]], "pubInput": [632, 4318193320874967181734161223197902340245632311881706422143392565195194701670]} \ No newline at end of file diff --git a/tests/4_sigs_2_batches_12_height/layer_two/batch_1/layer_two_batch_1_input.json b/tests/4_sigs_2_batches_12_height/layer_two/batch_1/layer_two_batch_1_input.json new file mode 100644 index 0000000..b2efa66 --- /dev/null +++ b/tests/4_sigs_2_batches_12_height/layer_two/batch_1/layer_two_batch_1_input.json @@ -0,0 +1,396 @@ +{ + "gamma2": [ + [ + [ + 5896345417453, + 4240670514135, + 6172078461917, + 219834884668, + 2138480846496, + 206187650596 + ], + [ + 6286472319682, + 5759053266064, + 8549822680278, + 8639745994386, + 912741836299, + 219532437284 + ] + ], + [ + [ + 4404069170602, + 525855202521, + 8311963231281, + 825823174727, + 854139906743, + 161342114743 + ], + [ + 3147424765787, + 7086132606363, + 7632907980226, + 5320198199754, + 6592898451945, + 77528801456 + ] + ] + ], + "delta2": [ + [ + [ + 5896345417453, + 4240670514135, + 6172078461917, + 219834884668, + 2138480846496, + 206187650596 + ], + [ + 6286472319682, + 5759053266064, + 8549822680278, + 8639745994386, + 912741836299, + 219532437284 + ] + ], + [ + [ + 4404069170602, + 525855202521, + 8311963231281, + 825823174727, + 854139906743, + 161342114743 + ], + [ + 3147424765787, + 7086132606363, + 7632907980226, + 5320198199754, + 6592898451945, + 77528801456 + ] + ] + ], + "negalfa1xbeta2": [ + [ + [ + 4063420080633, + 6555003798509, + 3528875089017, + 5800537096256, + 8041381108016, + 203518374640 + ], + [ + 7676269984398, + 1145806392863, + 6738515895690, + 5144301275423, + 8547057760405, + 353834589854 + ] + ], + [ + [ + 5712635615088, + 8763475698695, + 7480760495871, + 1630925336586, + 5902994417779, + 229051200835 + ], + [ + 1066113280330, + 5452941452156, + 130670027992, + 6364438679415, + 8227984268724, + 117895881848 + ] + ], + [ + [ + 2720638156466, + 8183746692879, + 2805734624200, + 4541538633192, + 1476702149455, + 162434980571 + ], + [ + 4093955238700, + 4839352246179, + 5773319594517, + 5269728708172, + 8404179905859, + 4522318692 + ] + ], + [ + [ + 7907150524416, + 8555524456643, + 2425990496019, + 5117607179458, + 886559720121, + 343845114320 + ], + [ + 3348806304058, + 5295378168489, + 5426585403009, + 4313512356362, + 2882006508456, + 312905790371 + ] + ], + [ + [ + 6984987484510, + 4411212100320, + 517962775393, + 5578757090043, + 1344911245314, + 115782940661 + ], + [ + 4257694794763, + 5641455412912, + 2987387394488, + 6147130513016, + 8766894161060, + 7451503335 + ] + ], + [ + [ + 3338043330865, + 3023333978926, + 4787719622265, + 3729967781503, + 2489094582823, + 396043239802 + ], + [ + 3390886416082, + 169102433935, + 2279828268438, + 1618451670976, + 7055320302964, + 48334526481 + ] + ] + ], + "IC": [ + [ + [ + 3438634672293, + 428623504470, + 1239661638946, + 4592575630099, + 4718074060279, + 391703255017 + ], + [ + 736095545553, + 7908275742977, + 5996144448348, + 2612960446962, + 6981527486830, + 114278943485 + ] + ], + [ + [ + 7300870722407, + 4564868088854, + 6027530968738, + 7579380702266, + 8238732274174, + 157946431856 + ], + [ + 3402449260953, + 923821035216, + 1160303724672, + 6614167134533, + 5612517460683, + 19608956603 + ] + ] + ], + "negpa": [ + [ + 6666369473480, + 963416241449, + 6865529509905, + 1937457309095, + 4971875816243, + 265017875709 + ], + [ + 947852687372, + 6616656488978, + 7107363246341, + 5343318142587, + 5874056305673, + 212022750266 + ] + ], + "pb": [ + [ + [ + 338826496276, + 2629408116079, + 2847411429040, + 8158085671120, + 1478664846647, + 243922750142 + ], + [ + 1565230870723, + 6032911963381, + 5249017874917, + 4835534477071, + 5181809202290, + 149671310099 + ] + ], + [ + [ + 302466059445, + 2915838224464, + 7773337681826, + 4003701148897, + 7543896879428, + 9464433024 + ], + [ + 5871798181188, + 6266063000028, + 1154891481013, + 63256422964, + 3906375139267, + 14273108477 + ] + ] + ], + "pc": [ + [ + 7991010243834, + 1376398010037, + 7393816202935, + 6434714278384, + 4963491009176, + 341430586648 + ], + [ + 1309722651510, + 4102964328770, + 544329317532, + 987315288907, + 8550210757569, + 163080243455 + ] + ], + "pubkey_x_coord_hash": "19492645588548049736720929089533886782184841935829231059201178683912765812771", + "pubkey": [ + [ + [ + "14228908065897860265", + "674372215316085523", + "5502143411088503636", + "5352130313043736271" + ], + [ + "15780325351295040937", + "18053032955918543435", + "14332870360095815283", + "5037907681404033639" + ] + ], + [ + [ + "17816677882583810512", + "7159181518165646761", + "17607006858653642357", + "8906821236153911103" + ], + [ + "16595138451532418448", + "6890360790353706397", + "12220664162022676023", + "15928648658598746638" + ] + ] + ], + "leaf_addresses": [ + "1042835897233575902921944741192356113755614147158", + "1081948206509724247469855359253310974508642486386" + ], + "leaf_balances": [ + "957", + "625" + ], + "merkle_root": "4318193320874967181734161223197902340245632311881706422143392565195194701670", + "path_elements": [ + [ + "9420544448928115759552449206917324253815013819695948518778323292407633156997", + "11269255297473612321670759621757763186716604497669944723873540427323164404466", + "14160194761677438946780797257104824355055855850316454315768272198470064041030", + "18992352838716072518958410512596045546946840217715312233036643710257271591607", + "16529697526387351258612596534052591335472060701146382780614788300261330225994", + "12152328126685856836964958548832863303872048508624084045033796801610286409305", + "18045471049093775887537648687769693388497255246303563801921406869839624093734", + "21402652562692118383819069505387119978392089076009318078768023675333255037942", + "1983202401115818410209050326710873535454542764533783601957587552407062588687", + "3489722332385963895163296136203623919605617685962612285826551659940522426495", + "9075707798414418422272392943672608885494235264532541279941321974636973442827" + ], + [ + "12398277554550371959442395694679718294665038191814185513758373950944383495795", + "11738827141020318149401075442988705657393044724592178930475312848133383559019", + "4365803328522958927719169650663035897068917106697497427661410516850504432229", + "1223557066936463719275135375440824852412302848597211754190599788765561848646", + "5404305249136924348177689411345012525831174774214417100763115309011824848909", + "6902192929221647916468686361438670129443848724033742876601780380493893807026", + "5397851610671505906280084192291809806437605592122972581500309936061956004895", + "11537487077288702203918970422562269638543791019789979252167552594744185264907", + "1983202401115818410209050326710873535454542764533783601957587552407062588687", + "3489722332385963895163296136203623919605617685962612285826551659940522426495", + "9075707798414418422272392943672608885494235264532541279941321974636973442827" + ] + ], + "path_indices": [ + [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 1, + 0, + 1 + ], + [ + 0, + 0, + 1, + 1, + 1, + 1, + 0, + 1, + 1, + 0, + 1 + ] + ] +} \ No newline at end of file diff --git a/tests/4_sigs_2_batches_12_height/layer_two/batch_1/proof.json b/tests/4_sigs_2_batches_12_height/layer_two/batch_1/proof.json new file mode 100644 index 0000000..ccf6025 --- /dev/null +++ b/tests/4_sigs_2_batches_12_height/layer_two/batch_1/proof.json @@ -0,0 +1 @@ +{"pi_a":["9736527788240399431303680917973594906980933070023095106345246981322053851296","19126591106998296337164273104736668080310971413581814038798764805047854091935","1"],"pi_b":[["11192336407747372533687808343750627137094177765574206446069320717153113212240","17767878086798296244916059458277314562423896502167345598476621615691630928429"],["12950030884575740962353847171805128546682433875043652745755230575146163390687","13968926939192262606033413487039199531423112857142946848033522203823567415845"],["1","0"]],"pi_c":["7908480181608219224820397284819136437255683775447540924314424593655146383354","5870146425957205381318403119216769030247941564026453748815188471217461816027","1"],"protocol":"groth16"} \ No newline at end of file diff --git a/tests/4_sigs_2_batches_12_height/layer_two/batch_1/public.json b/tests/4_sigs_2_batches_12_height/layer_two/batch_1/public.json new file mode 100644 index 0000000..27f1a56 --- /dev/null +++ b/tests/4_sigs_2_batches_12_height/layer_two/batch_1/public.json @@ -0,0 +1 @@ +["1582","4318193320874967181734161223197902340245632311881706422143392565195194701670"] \ No newline at end of file diff --git a/tests/4_sigs_2_batches_12_height/layer_two/batch_1/sanitized_proof.json b/tests/4_sigs_2_batches_12_height/layer_two/batch_1/sanitized_proof.json new file mode 100644 index 0000000..2a543f5 --- /dev/null +++ b/tests/4_sigs_2_batches_12_height/layer_two/batch_1/sanitized_proof.json @@ -0,0 +1 @@ +{"gamma2": [[[5896345417453, 4240670514135, 6172078461917, 219834884668, 2138480846496, 206187650596], [6286472319682, 5759053266064, 8549822680278, 8639745994386, 912741836299, 219532437284]], [[4404069170602, 525855202521, 8311963231281, 825823174727, 854139906743, 161342114743], [3147424765787, 7086132606363, 7632907980226, 5320198199754, 6592898451945, 77528801456]]], "delta2": [[[7300997600937, 3671456639412, 2717627081993, 6985411679643, 1907644562408, 21301064739], [1872180458763, 2832557307082, 5519107048858, 283194671451, 7082056950819, 335024307424]], [[5381216886041, 4559876870073, 7161995890056, 8570550695984, 5414652438075, 221552075284], [7523888268402, 7759490010103, 1269368874867, 6474541189950, 5220500539024, 207406487578]]], "negalfa1xbeta2": [[[4063420080633, 6555003798509, 3528875089017, 5800537096256, 8041381108016, 203518374640], [7676269984398, 1145806392863, 6738515895690, 5144301275423, 8547057760405, 353834589854]], [[5712635615088, 8763475698695, 7480760495871, 1630925336586, 5902994417779, 229051200835], [1066113280330, 5452941452156, 130670027992, 6364438679415, 8227984268724, 117895881848]], [[2720638156466, 8183746692879, 2805734624200, 4541538633192, 1476702149455, 162434980571], [4093955238700, 4839352246179, 5773319594517, 5269728708172, 8404179905859, 4522318692]], [[7907150524416, 8555524456643, 2425990496019, 5117607179458, 886559720121, 343845114320], [3348806304058, 5295378168489, 5426585403009, 4313512356362, 2882006508456, 312905790371]], [[6984987484510, 4411212100320, 517962775393, 5578757090043, 1344911245314, 115782940661], [4257694794763, 5641455412912, 2987387394488, 6147130513016, 8766894161060, 7451503335]], [[3338043330865, 3023333978926, 4787719622265, 3729967781503, 2489094582823, 396043239802], [3390886416082, 169102433935, 2279828268438, 1618451670976, 7055320302964, 48334526481]]], "IC": [[[1993850387479, 601431161060, 1264413738710, 6024355881581, 3655307968236, 313892020972], [248631750559, 6785810023803, 586465185482, 8253502562712, 6140122289189, 368515743347]], [[7078574820332, 7507013140647, 3381129117031, 1438519995117, 7726812166613, 175391830205], [419709697496, 2704656433194, 3096425096437, 7678054651869, 4915955857917, 212377660173]], [[2187758863416, 5026353877863, 7502804309061, 5479535447000, 4777301685959, 356733234343], [2725984561233, 6506864462978, 4379544096917, 8696971335248, 434216993311, 90117895219]]], "negpa": [[6210693699744, 8410044883335, 4227607149969, 2032562056085, 3686068998772, 184907718443], [6084848791208, 2792611087575, 5994208362537, 4668107736667, 4303465769615, 52446902846]], "pb": [[[5249110902096, 7682907370163, 8085479362734, 2271526125859, 1742363940723, 212555177186], [7909973451309, 8079275493041, 1238328959323, 242685084731, 1657600152744, 337432180143]], [[4599920871647, 855539416662, 2269986142411, 2593477331115, 3001950636726, 245935791148], [7268225133093, 4015830295646, 4747280990832, 7509715299076, 2976568805235, 265285784173]]], "pc": [[1199689074682, 5009969793574, 2452136378762, 8195015893028, 8085404497251, 150191018660], [3984505858779, 6507674781789, 2870227971981, 7965658142325, 3631028450622, 111480746130]], "pubInput": [1582, 4318193320874967181734161223197902340245632311881706422143392565195194701670]} \ No newline at end of file diff --git a/tests/4_sigs_2_batches_12_height/layer_two/layer_two_vkey.json b/tests/4_sigs_2_batches_12_height/layer_two/layer_two_vkey.json new file mode 100644 index 0000000..cc2fc7a --- /dev/null +++ b/tests/4_sigs_2_batches_12_height/layer_two/layer_two_vkey.json @@ -0,0 +1,99 @@ +{ + "protocol": "groth16", + "curve": "bn128", + "nPublic": 2, + "vk_alpha_1": [ + "20491192805390485299153009773594534940189261866228447918068658471970481763042", + "9383485363053290200918347156157836566562967994039712273449902621266178545958", + "1" + ], + "vk_beta_2": [ + [ + "6375614351688725206403948262868962793625744043794305715222011528459656738731", + "4252822878758300859123897981450591353533073413197771768651442665752259397132" + ], + [ + "10505242626370262277552901082094356697409835680220590971873171140371331206856", + "21847035105528745403288232691147584728191162732299865338377159692350059136679" + ], + [ + "1", + "0" + ] + ], + "vk_gamma_2": [ + [ + "10857046999023057135944570762232829481370756359578518086990519993285655852781", + "11559732032986387107991004021392285783925812861821192530917403151452391805634" + ], + [ + "8495653923123431417604973247489272438418190587263600148770280649306958101930", + "4082367875863433681332203403145435568316851327593401208105741076214120093531" + ], + [ + "1", + "0" + ] + ], + "vk_delta_2": [ + [ + "1121631971333613235356189119223529623712678207000001314166643264462790743721", + "17641088789788723808752709334014684676496307432117162333982681159192843564299" + ], + [ + "11666078386073787693340259602498070928594523734020378222564957188290265832729", + "10921226256913911056292272440918200264110660173378987226696655064471866180722" + ], + [ + "1", + "0" + ] + ], + "vk_alphabeta_12": [ + [ + [ + "2029413683389138792403550203267699914886160938906632433982220835551125967885", + "21072700047562757817161031222997517981543347628379360635925549008442030252106" + ], + [ + "5940354580057074848093997050200682056184807770593307860589430076672439820312", + "12156638873931618554171829126792193045421052652279363021382169897324752428276" + ], + [ + "7898200236362823042373859371574133993780991612861777490112507062703164551277", + "7074218545237549455313236346927434013100842096812539264420499035217050630853" + ] + ], + [ + [ + "7077479683546002997211712695946002074877511277312570035766170199895071832130", + "10093483419865920389913245021038182291233451549023025229112148274109565435465" + ], + [ + "4595479056700221319381530156280926371456704509942304414423590385166031118820", + "19831328484489333784475432780421641293929726139240675179672856274388269393268" + ], + [ + "11934129596455521040620786944827826205713621633706285934057045369193958244500", + "8037395052364110730298837004334506829870972346962140206007064471173334027475" + ] + ] + ], + "IC": [ + [ + "16528344032539948469207939486045044606277579694874575483928697724353095040023", + "19404618723943969981280203475494251604461900732728092578392942166017645965215", + "1" + ], + [ + "9235457789461764211727029523146907672708133885279969292402123819890567547884", + "11182989046041777112058646871965530544916623827492243741893968494943074106840", + "1" + ], + [ + "18784197211527487095733472900158245831952102833526579249218133690431523193912", + "4745261032932500971712209712966519026557368798194537164593144998711354943569", + "1" + ] + ] +} \ No newline at end of file diff --git a/tests/line_of_best_fit.py b/tests/line_of_best_fit.py new file mode 100644 index 0000000..545f751 --- /dev/null +++ b/tests/line_of_best_fit.py @@ -0,0 +1,36 @@ +""" +Used to get the line of best fit for the benchmark data. + +Example: +- number of signatures VS non-linear constraints for layer 1 circuit +""" + +import numpy as np + +def find_best_fit_line(data): + """ + This function takes a list of (x, y) coordinates and returns the slope and intercept + of the line of best fit. + + Args: + data: A list of tuples containing (x, y) coordinates. + + Returns: + A tuple containing the slope and intercept of the best fit line. + """ + # Extract x and y coordinates from data list + x, y = zip(*data) + x = np.array(x) + y = np.array(y) + + # Use polyfit to find coefficients + slope, intercept = np.polyfit(x, y, 1) + + return slope, intercept + +# layer 1 non-linear constraints (number of signatures, constraints) +data = [(1, 1509221), (2, 1932908), (2, 1932908), (4, 1932908), (7, 4161827), (16, 8173925), (128, 58102853)] +slope, intercept = find_best_fit_line(data) + +# Print the equation of the best fit line (y = mx + b) +print(f"Equation of best fit line: y = {slope:.2f}x + {intercept:.2f}") diff --git a/tests/plane_of_best_fit.py b/tests/plane_of_best_fit.py new file mode 100644 index 0000000..7d44cfa --- /dev/null +++ b/tests/plane_of_best_fit.py @@ -0,0 +1,44 @@ +""" +Used to get the plane of best fit for the benchmark data. + +Example: +- (number of signatures, merkle tree height) VS non-linear constraints for layer 2 circuit +""" + +import numpy as np +from sklearn.linear_model import LinearRegression + +def find_best_fit_plane(data): + """ + This function takes a list of (x, y, z) coordinates and finds the equation + of the plane of best fit. + + Args: + data: A list of tuples containing (x, y, z) coordinates. + + Returns: + A tuple containing a, b, c, and d representing the plane equation: + ax + by + cz + d = 0 + """ + # Convert data to numpy arrays + X = np.array([[point[0], point[1]] for point in data]) + y = np.array([point[2] for point in data]) + + # Use linear regression to find plane coefficients + model = LinearRegression() + model.fit(X, y) + + # Extract coefficients (a, b, and c) and offset (d) + a = model.coef_[0] + b = model.coef_[1] + c = -1 # Plane equation has z coefficient as -1 for linear regression + d = model.intercept_ + + return a, b, c, d + +# layer 2 non-linear constraints (number of signatures, merkle tree height, constraints) +data = [(4, 12, 19981480), (1, 5, 19823616), (2, 25, 19987876), (7, 25, 20784765), (16, 25, 22219209), (128, 25, 40070665)] +a, b, c, d = find_best_fit_plane(data) + +# Print the equation of the plane of best fit +print(f"Plane equation: {a:.2f}x + {b:.2f}y + {c:.2f}z + {d:.2f} = 0")