diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index b25adc83d..2960b949c 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -32,9 +32,7 @@ - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented my code, particularly in hard-to-understand areas -- [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have run `yarn style` without getting any errors - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes -- [ ] Any dependent changes have been merged and published in downstream modules diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 36dd67edf..e0a995a8b 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -4,7 +4,11 @@ on: push: branches: - main + paths: + - packages/**/src/*.{ts,js} pull_request: + paths: + - packages/**/src/*.{ts,js} jobs: gh-pages: @@ -24,13 +28,13 @@ jobs: run: yarn - name: Build libraries - run: yarn build:libraries + run: yarn build - name: Generate doc website run: yarn docs - - name: Publish on Github Pages - if: github.event_name == 'push' && github.ref == 'refs/heads/main' + - if: github.event_name == 'push' && github.ref == 'refs/heads/main' + name: Publish on Github Pages uses: crazy-max/ghaction-github-pages@v2.5.0 with: build_dir: docs diff --git a/.github/workflows/production.yml b/.github/workflows/main.yml similarity index 55% rename from .github/workflows/production.yml rename to .github/workflows/main.yml index 1eb971c98..26cdec973 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/main.yml @@ -1,9 +1,14 @@ -name: production +name: main on: push: branches: - main + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true jobs: style: @@ -24,14 +29,8 @@ jobs: - name: Build | Lint | Format run: yarn style - test: + tests: runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - type: - - contracts - - libraries steps: - name: Checkout @@ -46,27 +45,24 @@ jobs: - name: Install dependencies run: yarn - - name: Build libraries and contracts - run: yarn build - - - name: Test ${{ matrix.type }} - run: yarn test:${{ matrix.type }} - - - name: Coveralls - uses: coverallsapp/github-action@master + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v44 with: - github-token: ${{ secrets.GITHUB_TOKEN }} - flag-name: run-${{ matrix.type }} - path-to-lcov: ./coverage/${{ matrix.type }}/lcov.info - parallel: true + files: | + packages/**/src/*.{ts,js} + packages/**/tests/*.{ts,js} - coverage: - runs-on: ubuntu-latest - needs: test + - if: steps.changed-files.outputs.any_changed == 'true' + name: Build libraries + run: yarn build - steps: - - name: Coveralls Finished + - if: steps.changed-files.outputs.any_changed == 'true' + name: Test libraries + run: yarn test + + - if: steps.changed-files.outputs.any_changed == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main' + name: Coveralls uses: coverallsapp/github-action@master with: github-token: ${{ secrets.GITHUB_TOKEN }} - parallel-finished: true diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml deleted file mode 100644 index aaf1055b0..000000000 --- a/.github/workflows/pull-requests.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: pull-requests - -on: - pull_request: - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - style: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: "20" - cache: yarn - - - name: Install dependencies - run: yarn - - - name: Build | Lint | Format - run: yarn style - - test: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - type: - - contracts - - libraries - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: "20" - cache: yarn - - - name: Install dependencies - run: yarn - - - name: Build libraries and contracts - run: yarn build - - - name: Test ${{ matrix.type }} - run: yarn test:${{ matrix.type }} diff --git a/.lintstagedrc.json b/.lintstagedrc.json index c40921207..4e92cb102 100644 --- a/.lintstagedrc.json +++ b/.lintstagedrc.json @@ -1,4 +1,4 @@ { - "**/*.{js,ts,jsx,tsx,md,json,sol}": "prettier --write", + "**/*.{js,ts,jsx,tsx,md,json,yml,yaml}": "prettier --write", "**/*.{js,ts,jsx,tsx}": "eslint" } diff --git a/README.md b/README.md index 13c03979e..d65ef158a 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ZK-Kit logo - JS & Solidity + JS

@@ -16,8 +16,8 @@ Github license - - GitHub Workflow test + + GitHub Workflow Tests Coveralls @@ -59,7 +59,6 @@ ♚ [Yarn workspaces](https://yarnpkg.com/features/workspaces): minimal monorepo package management (`yarn`, `yarn build`, `yarn docs`)\ ♛ [Conventional Commits](https://www.conventionalcommits.org): human and machine readable meaning to commit messages (`yarn commit`)\ ♜ [Jest](https://jestjs.io/): tests and test coverage for all libraries (`yarn test:libraries`)\ -♜ [Mocha](https://mochajs.org/): tests for contracts (`yarn test:contracts`)\ ♞ [ESLint](https://eslint.org/), [Prettier](https://prettier.io/): code quality and formatting (`yarn prettier` & `yarn lint`)\ ♝ [Typedocs](https://typedoc.org/): documentation generator for TypeScript (`yarn docs`)\ ♟ [Benny](https://github.com/caderek/benny): simple benchmarking framework for JavaScript/TypeScript (`yarn benchmarks`)\ @@ -247,26 +246,6 @@ - - - - @zk-kit/imt.sol - - - - - - NPM version - - - - - - Downloads - - - - @@ -360,13 +339,13 @@ yarn lint Run [Prettier](https://prettier.io/) to check formatting rules: ```bash -yarn prettier +yarn format ``` or to automatically format the code: ```bash -yarn prettier:write +yarn format:write ``` ### Conventional commits @@ -389,7 +368,7 @@ yarn test ### Build -Build all the packages and compile contracts: +Build all the packages: ```bash yarn build diff --git a/package.json b/package.json index 8224aca1e..a4dab89c0 100644 --- a/package.json +++ b/package.json @@ -1,25 +1,22 @@ { "name": "zk-kit", - "description": "A monorepo of reusable libraries for zero-knowledge technologies.", + "description": "A monorepo of reusable JS libraries for zero-knowledge technologies.", "license": "MIT", "repository": "git@github.com:privacy-scaling-explorations/zk-kit.git", "homepage": "https://github.com/privacy-scaling-explorations/zk-kit", "bugs": "https://github.com/privacy-scaling-explorations/zk-kit/issues", "private": true, "scripts": { - "build": "turbo build", - "_build:libraries": "yarn workspaces foreach -A -t --no-private run build", - "build:libraries": "turbo _build:libraries", - "test": "turbo _test:libraries test:coverage", - "_test:libraries": "jest --coverage", - "test:libraries": "turbo _test:libraries", + "_build": "yarn workspaces foreach -A -t --no-private run build", + "build": "turbo _build", + "_test": "jest --coverage", + "test": "turbo _test", "test:library": "jest packages/${0}", - "test:contracts": "turbo test:coverage", "version:bump": "yarn workspace @zk-kit/${0} version ${1} && yarn remove:stable-version-field ${0} && NO_HOOK=1 git commit -am \"chore(${0}): v${1}\" && git tag ${0}-v${1}", "version:publish": "yarn workspaces foreach -A --no-private npm publish --tolerate-republish --access public", "version:release": "changelogithub", "lint:eslint": "eslint . --ext .js,.ts", - "lint": "turbo lint:eslint lint", + "lint": "turbo lint:eslint", "format:prettier": "prettier -c .", "format:prettier:write": "prettier -w .", "format": "turbo format:prettier", @@ -29,7 +26,7 @@ "remove:stable-version-field": "ts-node scripts/remove-stable-version-field.ts ${0} && yarn format:prettier:write", "precommit": "lint-staged", "postinstall": "husky && git config --local core.editor cat", - "style": "turbo lint:eslint lint format:prettier" + "style": "turbo lint:eslint format:prettier" }, "keywords": [ "javascript", @@ -39,12 +36,10 @@ "zk-snarks" ], "workspaces": [ - "packages/*", - "packages/*/contracts" + "packages/*" ], "packageManager": "yarn@4.1.0", "devDependencies": { - "@aztec/bb.js": "^0.33.0", "@commitlint/cli": "^18.6.1", "@commitlint/config-conventional": "^18.6.2", "@types/glob": "^7.2.0", diff --git a/packages/groth16/LICENSE b/packages/groth16/LICENSE deleted file mode 100644 index ef7e7efc0..000000000 --- a/packages/groth16/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ -GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - {one line to give the program's name and a brief idea of what it does.} - Copyright (C) {year} {name of author} - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - {project} Copyright (C) {year} {fullname} - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/packages/groth16/README.md b/packages/groth16/README.md deleted file mode 100644 index 1c0be41b0..000000000 --- a/packages/groth16/README.md +++ /dev/null @@ -1,132 +0,0 @@ -

-

- SnarkJS Groth16 -

-

A snippet of SnarkJS code for verifying and generating Groth16 proofs only.

-

- -

- - - - - NPM license - - - NPM version - - - Downloads - - - npm bundle size (scoped) - - - Linter eslint - - - Code style prettier - -

- -
-

- - 🗣️ Chat & Support - -   |   - - 📘 Docs - -

-
- -> [!WARNING] -> This package is no longer maintained as [SnarkJS](https://github.com/iden3/snarkjs) has integrated most of the above optimizations. Please, consider installing it instead. - -| This package contains [SnarkJS](https://github.com/iden3/snarkjs) functions for generating and verifying zero knowledge proofs with Groth16 specifically. In addition to the original code it also uses the cached `bn128` curve if it already exists, making verification and generation of consecutive proofs faster. | -| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - -Some advantages of using this package instead of `snarkjs` directly are: - -- It only includes code to verify and generate Groth16 proofs, making your final bundle lighter. -- It doesn't call the [ffjavascript](https://github.com/iden3/ffjavascript) `buildBn128` function if a `bn128` cached curve already exists, making verification and generation of consecutive proofs much faster (e.g. verification seems to be ~9 times faster after the first one). -- It includes TS types. -- It provides an ESM bundle that is compatible with browsers. So there is no need to add any polyfill or additional configuration. - -## References - -1. Jens Groth. _On the Size of Pairing-Based Non-interactive Arguments_. 2016-04-28. https://link.springer.com/chapter/10.1007/978-3-662-49896-5_11. - ---- - -## 🛠 Install - -### npm or yarn - -Install the `@zk-kit/groth16` package and its peer dependencies with npm: - -```bash -npm i @zk-kit/groth16 -``` - -or yarn: - -```bash -yarn add @zk-kit/groth16 -``` - -## 📜 Usage - -> [!WARNING] -> You will need to provide your own circuits here in your specified path. Remember to define your circuit input and rename the files accordingly. - -```typescript -import { prove, verify, buildBn128 } from "@zk-kit/groth16" - -// Build the BN128 curve for Groth16. -// https://github.com/iden3/ffjavascript/blob/master/src/wasm_field1.js -await buildBn128() // WasmField1 - -// Define your circuit input. -// const input = { -// input1: 1, -// input2: 2, -// inputN: "N" -// } - -// Compute the proof. -const proof = await prove(input, "/circuit.zkey", "/circuit.wasm") - -/* -{ - proof: { - pi_a: [ - '8259885706934172848141475422209230656096448508815982888010519325096632035723', - '3142099172052192611205205328157407975469005554072266974009053708782134081166', - '1' - ], - pi_b: [ [Array], [Array], [Array] ], - pi_c: [ - '13863804425308906943736719856399634046638544298517159271373916818387594277305', - '21340646707244019956779928177502771923632450548108204371058275686712196195969', - '1' - ], - protocol: 'groth16', - curve: 'bn128' - }, - publicSignals: [ - '527758365153958423212195330785598453331596731388181860789801455413116800554', - '19104626566001952573667666924569656871967113105870778077087237826253896482830', - '122' - ] -} -*/ -console.log(proof) - -// Verify the proof. -const response = await verify("/circuit_verification_key.json", proof) - -// true or false. -console.log(response) -``` diff --git a/packages/groth16/build.tsconfig.json b/packages/groth16/build.tsconfig.json deleted file mode 100644 index 2d4a1d6da..000000000 --- a/packages/groth16/build.tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "baseUrl": ".", - "declarationDir": "dist/types" - }, - "include": ["src"] -} diff --git a/packages/groth16/package.json b/packages/groth16/package.json deleted file mode 100644 index 134c4dafd..000000000 --- a/packages/groth16/package.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "name": "@zk-kit/groth16", - "version": "0.5.0", - "description": "A snippet of SnarkJS code for verifying and generating Groth16 proofs only.", - "type": "module", - "license": "GPL-3.0", - "main": "dist/index.browser.js", - "types": "dist/types/index.d.ts", - "exports": { - ".": { - "types": "./dist/types/index.d.ts", - "node": { - "require": "./dist/index.node.cjs", - "default": "./dist/index.node.js" - }, - "browser": "./dist/index.browser.js", - "default": "./dist/index.browser.js" - } - }, - "files": [ - "dist/", - "src/", - "LICENSE", - "README.md" - ], - "repository": "https://github.com/privacy-scaling-explorations/zk-kit", - "homepage": "https://github.com/privacy-scaling-explorations/zk-kit/tree/main/packages/groth16", - "bugs": { - "url": "https://github.com/privacy-scaling-explorations/zk-kit.git/issues" - }, - "scripts": { - "build": "rimraf dist && yarn build:browser && yarn build:node", - "build:browser": "rollup -c rollup.browser.config.ts --configPlugin typescript", - "build:node": "rollup -c rollup.node.config.ts --configPlugin typescript", - "prepublishOnly": "yarn build" - }, - "publishConfig": { - "access": "public" - }, - "devDependencies": { - "@iden3/binfileutils": "0.0.11", - "@rollup/plugin-commonjs": "^25.0.7", - "@rollup/plugin-node-resolve": "^15.2.3", - "@rollup/plugin-typescript": "^11.1.6", - "@rollup/plugin-virtual": "^3.0.2", - "fastfile": "0.0.20", - "rimraf": "^5.0.5", - "rollup": "^4.12.0", - "rollup-plugin-cleanup": "^3.2.1" - }, - "dependencies": { - "circom_runtime": "0.1.24", - "ffjavascript": "0.2.62" - } -} diff --git a/packages/groth16/rollup.browser.config.ts b/packages/groth16/rollup.browser.config.ts deleted file mode 100644 index 50c6c88b6..000000000 --- a/packages/groth16/rollup.browser.config.ts +++ /dev/null @@ -1,55 +0,0 @@ -import commonjs from "@rollup/plugin-commonjs" -import { nodeResolve } from "@rollup/plugin-node-resolve" -import typescript from "@rollup/plugin-typescript" -import virtual from "@rollup/plugin-virtual" -import * as fs from "fs" -import cleanup from "rollup-plugin-cleanup" - -// Needed by fastfile. -import { O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC } from "constants" - -const constants = ` -export const O_TRUNC = ${O_TRUNC}; -export const O_CREAT = ${O_CREAT}; -export const O_RDWR = ${O_RDWR}; -export const O_EXCL = ${O_EXCL}; -export const O_RDONLY = ${O_RDONLY} -` - -const empty = "export default {}" - -const pkg = JSON.parse(fs.readFileSync("./package.json", "utf-8")) -const banner = `/** - * @module ${pkg.name} - * @version ${pkg.version} - * @file ${pkg.description} - * @copyright Ethereum Foundation ${new Date().getFullYear()} - * @license ${pkg.license} - * @see [Github]{@link ${pkg.homepage}} -*/` - -export default { - input: "src/index.ts", - output: [ - { - file: pkg.exports["."].browser, - format: "es", - banner - } - ], - external: Object.keys(pkg.dependencies), - plugins: [ - typescript({ - tsconfig: "./build.tsconfig.json" - }), - virtual({ - fs: empty, - constants - }), - nodeResolve(), - commonjs({ - esmExternals: true - }), - cleanup({ comments: "jsdoc" }) - ] -} diff --git a/packages/groth16/rollup.node.config.ts b/packages/groth16/rollup.node.config.ts deleted file mode 100644 index a5b1f8c22..000000000 --- a/packages/groth16/rollup.node.config.ts +++ /dev/null @@ -1,43 +0,0 @@ -import commonjs from "@rollup/plugin-commonjs" -import { nodeResolve } from "@rollup/plugin-node-resolve" -import * as fs from "fs" -import cleanup from "rollup-plugin-cleanup" -import typescript from "@rollup/plugin-typescript" - -const pkg = JSON.parse(fs.readFileSync("./package.json", "utf-8")) -const banner = `/** - * @module ${pkg.name} - * @version ${pkg.version} - * @file ${pkg.description} - * @copyright Ethereum Foundation ${new Date().getFullYear()} - * @license ${pkg.license} - * @see [Github]{@link ${pkg.homepage}} -*/` - -export default { - input: "src/index.ts", - output: [ - { - file: pkg.exports["."].node.require, - format: "cjs", - banner, - exports: "auto" - }, - { - file: pkg.exports["."].node.default, - format: "es", - banner - } - ], - external: Object.keys(pkg.dependencies), - plugins: [ - typescript({ - tsconfig: "./build.tsconfig.json" - }), - nodeResolve(), - commonjs({ - esmExternals: true - }), - cleanup({ comments: "jsdoc" }) - ] -} diff --git a/packages/groth16/snark-artifacts/index.json b/packages/groth16/snark-artifacts/index.json deleted file mode 100644 index 874031cd3..000000000 --- a/packages/groth16/snark-artifacts/index.json +++ /dev/null @@ -1,95 +0,0 @@ -{ - "protocol": "groth16", - "curve": "bn128", - "nPublic": 3, - "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": [ - [ - "17546152771742044890128665170773308307706885904145171368861289731338407120726", - "21635289475723704811498602453116541869848271742675656134593605133653559871988" - ], - [ - "12208424286857750236404959484429248934995357114248145547240410687755355066198", - "19321625097082563598592975631421044551870980615218660051914871088320678365555" - ], - ["1", "0"] - ], - "vk_alphabeta_12": [ - [ - [ - "2029413683389138792403550203267699914886160938906632433982220835551125967885", - "21072700047562757817161031222997517981543347628379360635925549008442030252106" - ], - [ - "5940354580057074848093997050200682056184807770593307860589430076672439820312", - "12156638873931618554171829126792193045421052652279363021382169897324752428276" - ], - [ - "7898200236362823042373859371574133993780991612861777490112507062703164551277", - "7074218545237549455313236346927434013100842096812539264420499035217050630853" - ] - ], - [ - [ - "7077479683546002997211712695946002074877511277312570035766170199895071832130", - "10093483419865920389913245021038182291233451549023025229112148274109565435465" - ], - [ - "4595479056700221319381530156280926371456704509942304414423590385166031118820", - "19831328484489333784475432780421641293929726139240675179672856274388269393268" - ], - [ - "11934129596455521040620786944827826205713621633706285934057045369193958244500", - "8037395052364110730298837004334506829870972346962140206007064471173334027475" - ] - ] - ], - "IC": [ - [ - "10540353245037691655240058832465935071147222378795512774896416883563614389198", - "20042286059857913285646233979306226083538103143380748863555356103197961213823", - "1" - ], - [ - "12178048393484805922448151297512780036777540315506565788645040495931277621130", - "9697539656531822741576184528195082340044862873578980581504958946888585254425", - "1" - ], - [ - "20991907493060125430185038723439696392069163847357524165903787100018954817952", - "12348708907766483529401318577288191297476103087328423321867414316726183562292", - "1" - ], - [ - "6823739927950557742246913693052072220213742766782370219666937126411380340633", - "19878777316727584245579797737044924949420447706770682437221414501064053790692", - "1" - ] - ] -} diff --git a/packages/groth16/snark-artifacts/index.wasm b/packages/groth16/snark-artifacts/index.wasm deleted file mode 100644 index 7a67220dc..000000000 Binary files a/packages/groth16/snark-artifacts/index.wasm and /dev/null differ diff --git a/packages/groth16/snark-artifacts/index.zkey b/packages/groth16/snark-artifacts/index.zkey deleted file mode 100644 index 3d37f26c1..000000000 Binary files a/packages/groth16/snark-artifacts/index.zkey and /dev/null differ diff --git a/packages/groth16/src/buildBn128.ts b/packages/groth16/src/buildBn128.ts deleted file mode 100644 index 06ee286fb..000000000 --- a/packages/groth16/src/buildBn128.ts +++ /dev/null @@ -1,13 +0,0 @@ -/* istanbul ignore file */ - -import { buildBn128 as _buildBn128 } from "ffjavascript" - -/** - * Builds and returns a BN 128 curve. If the curve has been cached, - * it returns the cached curve. - * @returns BN 128 ffjavascript curve. - */ -export default async function buildBn128(): Promise { - // @ts-ignore - return globalThis.curve_bn128 ?? (await _buildBn128()) -} diff --git a/packages/groth16/src/index.ts b/packages/groth16/src/index.ts deleted file mode 100644 index 7b93ac0b3..000000000 --- a/packages/groth16/src/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -import prove from "./prove" -import verify from "./verify" -import buildBn128 from "./buildBn128" - -export { prove, verify, buildBn128 } -export * from "./types" diff --git a/packages/groth16/src/prove.ts b/packages/groth16/src/prove.ts deleted file mode 100644 index 285c8ba7c..000000000 --- a/packages/groth16/src/prove.ts +++ /dev/null @@ -1,235 +0,0 @@ -/* eslint-disable no-plusplus */ -/* eslint-disable eqeqeq */ -/* eslint-disable @typescript-eslint/naming-convention */ -/* istanbul ignore file */ - -// @ts-ignore -import * as binFileUtils from "@iden3/binfileutils" -import { BigBuffer, Scalar, utils } from "ffjavascript" -import { log2 } from "./utils" -import * as zkeyUtils from "./zkey-utils" -import * as wtnsUtils from "./wtns-utils" -import wtnsCalculate from "./wtns-calculate" -import { CircuitSignals, Groth16Proof, PublicSignals, ZKArtifact } from "./types" - -const { stringifyBigInts, unstringifyBigInts } = utils - -async function buildABC1(curve: any, zkey: any, witness: any, coeffs: any) { - const { n8 } = curve.Fr - const sCoef = 4 * 3 + zkey.n8r - const nCoef = (coeffs.byteLength - 4) / sCoef - - const outBuffA = new BigBuffer(zkey.domainSize * n8) - const outBuffB = new BigBuffer(zkey.domainSize * n8) - const outBuffC = new BigBuffer(zkey.domainSize * n8) - - const outBuf = [outBuffA, outBuffB] - for (let i = 0; i < nCoef; i++) { - const buffCoef = coeffs.slice(4 + i * sCoef, 4 + i * sCoef + sCoef) - const buffCoefV = new DataView(buffCoef.buffer) - const m = buffCoefV.getUint32(0, true) - const c = buffCoefV.getUint32(4, true) - const s = buffCoefV.getUint32(8, true) - const coef = buffCoef.slice(12, 12 + n8) - outBuf[m].set( - curve.Fr.add(outBuf[m].slice(c * n8, c * n8 + n8), curve.Fr.mul(coef, witness.slice(s * n8, s * n8 + n8))), - c * n8 - ) - } - - for (let i = 0; i < zkey.domainSize; i++) { - outBuffC.set(curve.Fr.mul(outBuffA.slice(i * n8, i * n8 + n8), outBuffB.slice(i * n8, i * n8 + n8)), i * n8) - } - - return [outBuffA, outBuffB, outBuffC] -} - -async function joinABC(curve: any, _zkey: any, a: any, b: any, c: any) { - const MAX_CHUNK_SIZE = 1 << 22 - - const { n8 } = curve.Fr - const nElements = Math.floor(a.byteLength / curve.Fr.n8) - - const promises = [] - - for (let i = 0; i < nElements; i += MAX_CHUNK_SIZE) { - const n = Math.min(nElements - i, MAX_CHUNK_SIZE) - - const task = [] - - const aChunk = a.slice(i * n8, (i + n) * n8) - const bChunk = b.slice(i * n8, (i + n) * n8) - const cChunk = c.slice(i * n8, (i + n) * n8) - - task.push({ cmd: "ALLOCSET", var: 0, buff: aChunk }) - task.push({ cmd: "ALLOCSET", var: 1, buff: bChunk }) - task.push({ cmd: "ALLOCSET", var: 2, buff: cChunk }) - task.push({ cmd: "ALLOC", var: 3, len: n * n8 }) - task.push({ - cmd: "CALL", - fnName: "qap_joinABC", - params: [{ var: 0 }, { var: 1 }, { var: 2 }, { val: n }, { var: 3 }] - }) - task.push({ cmd: "CALL", fnName: "frm_batchFromMontgomery", params: [{ var: 3 }, { val: n }, { var: 3 }] }) - task.push({ cmd: "GET", out: 0, var: 3, len: n * n8 }) - promises.push(curve.tm.queueAction(task)) - } - - const result = await Promise.all(promises) - - let outBuff - if (a instanceof BigBuffer) { - // @ts-ignore - outBuff = new BigBuffer(a.byteLength) - } else { - outBuff = new Uint8Array(a.byteLength) - } - - let p = 0 - for (let i = 0; i < result.length; i++) { - outBuff.set(result[i][0], p) - p += result[i][0].byteLength - } - - return outBuff -} - -/** - * Creates a Groth16 proof composed of public signals and zero-knowledge parameters. - * @param input Input signals of the circuit. - * @param wasmFile WASM file of the circuit. - * @param zkeyFile ZKey file of the circuit. - * @returns A proof containing public signals and zero-knowledge parameters. - */ -export default async function prove( - input: CircuitSignals, - wasmFile: ZKArtifact, - zkeyFile: ZKArtifact -): Promise<{ - proof: Groth16Proof - publicSignals: PublicSignals -}> { - input = unstringifyBigInts(input) - - const witnessFileName = { - type: "mem" - } - - await wtnsCalculate(input, wasmFile, witnessFileName) - - const { fd: fdWtns, sections: sectionsWtns } = await binFileUtils.readBinFile( - witnessFileName, - "wtns", - 2, - 1 << 25, - 1 << 23 - ) - - const wtns = await wtnsUtils.readHeader(fdWtns, sectionsWtns) - - const { fd: fdZKey, sections: sectionsZKey } = await binFileUtils.readBinFile(zkeyFile, "zkey", 2, 1 << 25, 1 << 23) - - const zkey = await zkeyUtils.readHeader(fdZKey, sectionsZKey, undefined) - - if (zkey.protocol !== "groth16") { - throw new Error("zkey file is not groth16") - } - - if (!Scalar.eq(zkey.r, wtns.q)) { - throw new Error("Curve of the witness does not match the curve of the proving key") - } - - if (wtns.nWitness !== zkey.nVars) { - throw new Error(`Invalid witness length. Circuit: ${zkey.nVars}, witness: ${wtns.nWitness}`) - } - - const { curve } = zkey - const { Fr } = curve - const { G1 } = curve - const { G2 } = curve - - const power = log2(zkey.domainSize) - - const buffWitness = await binFileUtils.readSection(fdWtns, sectionsWtns, 2) - const buffCoeffs = await binFileUtils.readSection(fdZKey, sectionsZKey, 4) - - const [buffA_T, buffB_T, buffC_T] = await buildABC1(curve, zkey, buffWitness, buffCoeffs) - - const inc = power == Fr.s ? curve.Fr.shift : curve.Fr.w[power + 1] - - const buffA = await Fr.ifft(buffA_T, "", "", undefined, "IFFT_A") - const buffAodd = await Fr.batchApplyKey(buffA, Fr.e(1), inc) - const buffAodd_T = await Fr.fft(buffAodd, "", "", undefined, "FFT_A") - - const buffB = await Fr.ifft(buffB_T, "", "", undefined, "IFFT_B") - const buffBodd = await Fr.batchApplyKey(buffB, Fr.e(1), inc) - const buffBodd_T = await Fr.fft(buffBodd, "", "", undefined, "FFT_B") - - const buffC = await Fr.ifft(buffC_T, "", "", undefined, "IFFT_C") - const buffCodd = await Fr.batchApplyKey(buffC, Fr.e(1), inc) - const buffCodd_T = await Fr.fft(buffCodd, "", "", undefined, "FFT_C") - - const buffPodd_T = await joinABC(curve, zkey, buffAodd_T, buffBodd_T, buffCodd_T) - - let proof: any = {} - - const buffBasesA = await binFileUtils.readSection(fdZKey, sectionsZKey, 5) - proof.pi_a = await curve.G1.multiExpAffine(buffBasesA, buffWitness, undefined, "multiexp A") - - const buffBasesB1 = await binFileUtils.readSection(fdZKey, sectionsZKey, 6) - let pib1 = await curve.G1.multiExpAffine(buffBasesB1, buffWitness, undefined, "multiexp B1") - - const buffBasesB2 = await binFileUtils.readSection(fdZKey, sectionsZKey, 7) - proof.pi_b = await curve.G2.multiExpAffine(buffBasesB2, buffWitness, undefined, "multiexp B2") - - const buffBasesC = await binFileUtils.readSection(fdZKey, sectionsZKey, 8) - proof.pi_c = await curve.G1.multiExpAffine( - buffBasesC, - buffWitness.slice((zkey.nPublic + 1) * curve.Fr.n8), - undefined, - "multiexp C" - ) - - const buffBasesH = await binFileUtils.readSection(fdZKey, sectionsZKey, 9) - const resH = await curve.G1.multiExpAffine(buffBasesH, buffPodd_T, undefined, "multiexp H") - - const r = curve.Fr.random() - const s = curve.Fr.random() - - proof.pi_a = G1.add(proof.pi_a, zkey.vk_alpha_1) - proof.pi_a = G1.add(proof.pi_a, G1.timesFr(zkey.vk_delta_1, r)) - - proof.pi_b = G2.add(proof.pi_b, zkey.vk_beta_2) - proof.pi_b = G2.add(proof.pi_b, G2.timesFr(zkey.vk_delta_2, s)) - - pib1 = G1.add(pib1, zkey.vk_beta_1) - pib1 = G1.add(pib1, G1.timesFr(zkey.vk_delta_1, s)) - - proof.pi_c = G1.add(proof.pi_c, resH) - - proof.pi_c = G1.add(proof.pi_c, G1.timesFr(proof.pi_a, s)) - proof.pi_c = G1.add(proof.pi_c, G1.timesFr(pib1, r)) - proof.pi_c = G1.add(proof.pi_c, G1.timesFr(zkey.vk_delta_1, Fr.neg(Fr.mul(r, s)))) - - let publicSignals = [] - - for (let i = 1; i <= zkey.nPublic; i++) { - const b = buffWitness.slice(i * Fr.n8, i * Fr.n8 + Fr.n8) - publicSignals.push(Scalar.fromRprLE(b, undefined, undefined)) - } - - proof.pi_a = G1.toObject(G1.toAffine(proof.pi_a)) - proof.pi_b = G2.toObject(G2.toAffine(proof.pi_b)) - proof.pi_c = G1.toObject(G1.toAffine(proof.pi_c)) - - proof.protocol = "groth16" - proof.curve = curve.name - - await fdZKey.close() - await fdWtns.close() - - proof = stringifyBigInts(proof) - publicSignals = stringifyBigInts(publicSignals) - - return { proof, publicSignals } -} diff --git a/packages/groth16/src/types/index.ts b/packages/groth16/src/types/index.ts deleted file mode 100644 index 0583a0377..000000000 --- a/packages/groth16/src/types/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -export type ZKArtifact = string | Uint8Array - -export type NumericString = `${number}` | string - -export type SignalValueType = NumericString | number | bigint | SignalValueType[] - -export interface CircuitSignals { - [signal: string]: SignalValueType -} - -export interface Groth16Proof { - pi_a: NumericString[] - pi_b: NumericString[][] - pi_c: NumericString[] - protocol: string - curve: string -} - -export type PublicSignals = NumericString[] diff --git a/packages/groth16/src/utils.ts b/packages/groth16/src/utils.ts deleted file mode 100644 index 198edd1d3..000000000 --- a/packages/groth16/src/utils.ts +++ /dev/null @@ -1,14 +0,0 @@ -/* eslint-disable import/prefer-default-export */ -/* eslint-disable no-return-assign */ -/* istanbul ignore file */ - -export function log2(V: any) { - return ( - ((V & 0xffff0000) !== 0 ? ((V &= 0xffff0000), 16) : 0) | - ((V & 0xff00ff00) !== 0 ? ((V &= 0xff00ff00), 8) : 0) | - ((V & 0xf0f0f0f0) !== 0 ? ((V &= 0xf0f0f0f0), 4) : 0) | - ((V & 0xcccccccc) !== 0 ? ((V &= 0xcccccccc), 2) : 0) | - // @ts-ignore - ((V & 0xaaaaaaaa) !== 0) - ) -} diff --git a/packages/groth16/src/verify.ts b/packages/groth16/src/verify.ts deleted file mode 100644 index 851be5bd2..000000000 --- a/packages/groth16/src/verify.ts +++ /dev/null @@ -1,90 +0,0 @@ -/* eslint-disable no-plusplus */ -/* eslint-disable @typescript-eslint/naming-convention */ -/* istanbul ignore file */ - -import { Scalar, utils } from "ffjavascript" -import buildBn128 from "./buildBn128" -import { Groth16Proof, PublicSignals } from "./types" - -const { unstringifyBigInts } = utils - -function isWellConstructed(curve: any, proof: any) { - const { G1 } = curve - const { G2 } = curve - - return G1.isValid(proof.pi_a) && G2.isValid(proof.pi_b) && G1.isValid(proof.pi_c) -} - -function publicInputsAreValid(curve: any, publicInputs: any) { - for (let i = 0; i < publicInputs.length; i++) { - if (!Scalar.lt(publicInputs[i], curve.r)) { - return false - } - } - return true -} - -/** - * Verifies if a Groth16 proof is valid or not. - * @param verificationKey The verification key used to verify the proof. - * @param proof The proof containing public signals and zero-knowledge parameters. - * @returns True if the proof is valid, and false otherwise. - */ -export default async function verify( - verificationKey: any, - { - proof, - publicSignals - }: { - proof: Groth16Proof - publicSignals: PublicSignals - } -): Promise { - verificationKey = unstringifyBigInts(verificationKey) - proof = unstringifyBigInts(proof) - publicSignals = unstringifyBigInts(publicSignals) - - const curve = await buildBn128() - - const IC0 = curve.G1.fromObject(verificationKey.IC[0]) - const IC = new Uint8Array(curve.G1.F.n8 * 2 * publicSignals.length) - const w = new Uint8Array(curve.Fr.n8 * publicSignals.length) - - if (!publicInputsAreValid(curve, publicSignals)) { - return false - } - - for (let i = 0; i < publicSignals.length; i++) { - const buffP = curve.G1.fromObject(verificationKey.IC[i + 1]) - IC.set(buffP, i * curve.G1.F.n8 * 2) - Scalar.toRprLE(w, curve.Fr.n8 * i, publicSignals[i], curve.Fr.n8) - } - - let cpub = await curve.G1.multiExpAffine(IC, w) - cpub = curve.G1.add(cpub, IC0) - - const pi_a = curve.G1.fromObject(proof.pi_a) - const pi_b = curve.G2.fromObject(proof.pi_b) - const pi_c = curve.G1.fromObject(proof.pi_c) - - if (!isWellConstructed(curve, { pi_a, pi_b, pi_c })) { - return false - } - - const vk_gamma_2 = curve.G2.fromObject(verificationKey.vk_gamma_2) - const vk_delta_2 = curve.G2.fromObject(verificationKey.vk_delta_2) - const vk_alpha_1 = curve.G1.fromObject(verificationKey.vk_alpha_1) - const vk_beta_2 = curve.G2.fromObject(verificationKey.vk_beta_2) - - return curve.pairingEq( - curve.G1.neg(pi_a), - pi_b, - cpub, - vk_gamma_2, - pi_c, - vk_delta_2, - - vk_alpha_1, - vk_beta_2 - ) -} diff --git a/packages/groth16/src/wtns-calculate.ts b/packages/groth16/src/wtns-calculate.ts deleted file mode 100644 index 263f7e91e..000000000 --- a/packages/groth16/src/wtns-calculate.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* eslint-disable eqeqeq */ -/* istanbul ignore file */ - -// @ts-ignore -import * as binFileUtils from "@iden3/binfileutils" -// @ts-ignore -import { WitnessCalculatorBuilder } from "circom_runtime" -// @ts-ignore -import * as fastFile from "fastfile" -import { utils } from "ffjavascript" -import * as wtnsUtils from "./wtns-utils" - -const { unstringifyBigInts } = utils - -export default async function wtnsCalculate(_input: any, wasmFileName: any, wtnsFileName: any) { - const input = unstringifyBigInts(_input) - - const fdWasm = await fastFile.readExisting(wasmFileName) - const wasm = await fdWasm.read(fdWasm.totalSize) - await fdWasm.close() - - const wc = await WitnessCalculatorBuilder(wasm) - - if (wc.circom_version() == 1) { - const w = await wc.calculateBinWitness(input) - - const fdWtns = await binFileUtils.createBinFile(wtnsFileName, "wtns", 2, 2) - - await wtnsUtils.writeBin(fdWtns, w, wc.prime) - await fdWtns.close() - } else { - const fdWtns = await fastFile.createOverride(wtnsFileName) - - const w = await wc.calculateWTNSBin(input) - - await fdWtns.write(w) - await fdWtns.close() - } -} diff --git a/packages/groth16/src/wtns-utils.ts b/packages/groth16/src/wtns-utils.ts deleted file mode 100644 index cadca43b2..000000000 --- a/packages/groth16/src/wtns-utils.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* eslint-disable eqeqeq */ -/* istanbul ignore file */ - -// @ts-ignore -import * as binFileUtils from "@iden3/binfileutils" -import { Scalar } from "ffjavascript" - -export async function writeBin(fd: any, witnessBin: any, prime: any) { - await binFileUtils.startWriteSection(fd, 1) - const n8 = (Math.floor((Scalar.bitLength(prime) - 1) / 64) + 1) * 8 - await fd.writeULE32(n8) - await binFileUtils.writeBigInt(fd, prime, n8) - if (witnessBin.byteLength % n8 != 0) { - throw new Error("Invalid witness length") - } - await fd.writeULE32(witnessBin.byteLength / n8) - await binFileUtils.endWriteSection(fd) - - await binFileUtils.startWriteSection(fd, 2) - await fd.write(witnessBin) - await binFileUtils.endWriteSection(fd) -} - -export async function readHeader(fd: any, sections: any) { - await binFileUtils.startReadUniqueSection(fd, sections, 1) - const n8 = await fd.readULE32() - const q = await binFileUtils.readBigInt(fd, n8) - const nWitness = await fd.readULE32() - await binFileUtils.endReadSection(fd) - - return { n8, q, nWitness } -} diff --git a/packages/groth16/src/zkey-utils.ts b/packages/groth16/src/zkey-utils.ts deleted file mode 100644 index 90839da87..000000000 --- a/packages/groth16/src/zkey-utils.ts +++ /dev/null @@ -1,62 +0,0 @@ -/* eslint-disable import/prefer-default-export */ -/* istanbul ignore file */ - -// @ts-ignore -import * as binFileUtils from "@iden3/binfileutils" -import buildBn128 from "./buildBn128" -import { log2 } from "./utils" - -async function readG1(fd: any, curve: any, toObject: any) { - const buff = await fd.read(curve.G1.F.n8 * 2) - const res = curve.G1.fromRprLEM(buff, 0) - return toObject ? curve.G1.toObject(res) : res -} - -async function readG2(fd: any, curve: any, toObject: any) { - const buff = await fd.read(curve.G2.F.n8 * 2) - const res = curve.G2.fromRprLEM(buff, 0) - return toObject ? curve.G2.toObject(res) : res -} - -async function readHeaderGroth16(fd: any, sections: any, toObject: any) { - const zkey: any = {} - - zkey.protocol = "groth16" - - await binFileUtils.startReadUniqueSection(fd, sections, 2) - const n8q = await fd.readULE32() - zkey.n8q = n8q - zkey.q = await binFileUtils.readBigInt(fd, n8q) - - const n8r = await fd.readULE32() - zkey.n8r = n8r - zkey.r = await binFileUtils.readBigInt(fd, n8r) - - zkey.curve = await buildBn128() - - zkey.nVars = await fd.readULE32() - zkey.nPublic = await fd.readULE32() - zkey.domainSize = await fd.readULE32() - zkey.power = log2(zkey.domainSize) - zkey.vk_alpha_1 = await readG1(fd, zkey.curve, toObject) - zkey.vk_beta_1 = await readG1(fd, zkey.curve, toObject) - zkey.vk_beta_2 = await readG2(fd, zkey.curve, toObject) - zkey.vk_gamma_2 = await readG2(fd, zkey.curve, toObject) - zkey.vk_delta_1 = await readG1(fd, zkey.curve, toObject) - zkey.vk_delta_2 = await readG2(fd, zkey.curve, toObject) - await binFileUtils.endReadSection(fd) - - return zkey -} - -export async function readHeader(fd: any, sections: any, toObject: any) { - await binFileUtils.startReadUniqueSection(fd, sections, 1) - const protocolId = await fd.readULE32() - await binFileUtils.endReadSection(fd) - - if (protocolId === 1) { - return readHeaderGroth16(fd, sections, toObject) - } - - throw new Error("Protocol not supported: ") -} diff --git a/packages/groth16/tests/index.test.ts b/packages/groth16/tests/index.test.ts deleted file mode 100644 index a9c185083..000000000 --- a/packages/groth16/tests/index.test.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { verify, prove, buildBn128 } from "../src" -import verificationKey from "../snark-artifacts/index.json" - -describe("Groth16", () => { - const wasmFilePath = "./packages/groth16/snark-artifacts/index.wasm" - const zkeyFilePath = "./packages/groth16/snark-artifacts/index.zkey" - - let curve: any - let proof: any - - beforeAll(async () => { - curve = await buildBn128() - }) - - afterAll(async () => { - await curve.terminate() - }) - - it("Should generate a proof", async () => { - proof = await prove( - { - message: 12, - scope: 122 - }, - wasmFilePath, - zkeyFilePath - ) - - expect(typeof proof).toBe("object") - }, 20000) - - it("Should verify a valid proof", async () => { - const response = await verify(verificationKey, proof) - - expect(response).toBe(true) - }) - - it("Should verify an invalid proof", async () => { - proof.publicSignals[0] = 0 - - const response = await verify(verificationKey, proof) - - expect(response).toBe(false) - }) -}) diff --git a/packages/groth16/tsconfig.json b/packages/groth16/tsconfig.json deleted file mode 100644 index d90026c5a..000000000 --- a/packages/groth16/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "resolveJsonModule": true - }, - "include": ["src", "tests", "rollup.browser.config.ts", "rollup.node.config.ts"] -} diff --git a/packages/groth16/typedoc.json b/packages/groth16/typedoc.json deleted file mode 100644 index 77a471c91..000000000 --- a/packages/groth16/typedoc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "entryPoints": ["src/index.ts"] -} diff --git a/packages/imt.sol/.env.example b/packages/imt.sol/.env.example deleted file mode 100644 index 9b91f04b3..000000000 --- a/packages/imt.sol/.env.example +++ /dev/null @@ -1,2 +0,0 @@ -COINMARKETCAP_API_KEY= -REPORT_GAS=false diff --git a/packages/imt.sol/.prettierrc.json b/packages/imt.sol/.prettierrc.json deleted file mode 100644 index 717fb520a..000000000 --- a/packages/imt.sol/.prettierrc.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "semi": false, - "arrowParens": "always", - "trailingComma": "none", - "plugins": ["prettier-plugin-solidity"] -} diff --git a/packages/imt.sol/.solcover.js b/packages/imt.sol/.solcover.js deleted file mode 100644 index 24a7b4526..000000000 --- a/packages/imt.sol/.solcover.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - istanbulFolder: "../../coverage/contracts" -} diff --git a/packages/imt.sol/.solhint.json b/packages/imt.sol/.solhint.json deleted file mode 100644 index bfc727d53..000000000 --- a/packages/imt.sol/.solhint.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "extends": "solhint:recommended", - "plugins": ["prettier"], - "rules": { - "compiler-version": ["error", ">=0.8.0"], - "const-name-snakecase": "off", - "no-empty-blocks": "off", - "constructor-syntax": "error", - "func-visibility": ["error", { "ignoreConstructors": true }], - "max-line-length": ["error", 120], - "not-rely-on-time": "off", - "prettier/prettier": [ - "error", - { - "endOfLine": "auto" - } - ], - "reason-string": ["warn", { "maxLength": 80 }] - } -} diff --git a/packages/imt.sol/LICENSE b/packages/imt.sol/LICENSE deleted file mode 120000 index 89a15f798..000000000 --- a/packages/imt.sol/LICENSE +++ /dev/null @@ -1 +0,0 @@ -contracts/LICENSE \ No newline at end of file diff --git a/packages/imt.sol/README.md b/packages/imt.sol/README.md deleted file mode 120000 index 1ee044251..000000000 --- a/packages/imt.sol/README.md +++ /dev/null @@ -1 +0,0 @@ -contracts/README.md \ No newline at end of file diff --git a/packages/imt.sol/contracts/BinaryIMT.sol b/packages/imt.sol/contracts/BinaryIMT.sol deleted file mode 100644 index 23c4e2068..000000000 --- a/packages/imt.sol/contracts/BinaryIMT.sol +++ /dev/null @@ -1,52 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.4; - -import {InternalBinaryIMT, BinaryIMTData} from "./internal/InternalBinaryIMT.sol"; - -library BinaryIMT { - using InternalBinaryIMT for *; - - function defaultZero(uint256 index) public pure returns (uint256) { - return InternalBinaryIMT._defaultZero(index); - } - - function init(BinaryIMTData storage self, uint256 depth, uint256 zero) public { - InternalBinaryIMT._init(self, depth, zero); - } - - function initWithDefaultZeroes(BinaryIMTData storage self, uint256 depth) public { - InternalBinaryIMT._initWithDefaultZeroes(self, depth); - } - - function insert(BinaryIMTData storage self, uint256 leaf) public returns (uint256) { - return InternalBinaryIMT._insert(self, leaf); - } - - function update( - BinaryIMTData storage self, - uint256 leaf, - uint256 newLeaf, - uint256[] calldata proofSiblings, - uint8[] calldata proofPathIndices - ) public { - InternalBinaryIMT._update(self, leaf, newLeaf, proofSiblings, proofPathIndices); - } - - function remove( - BinaryIMTData storage self, - uint256 leaf, - uint256[] calldata proofSiblings, - uint8[] calldata proofPathIndices - ) public { - InternalBinaryIMT._remove(self, leaf, proofSiblings, proofPathIndices); - } - - function verify( - BinaryIMTData storage self, - uint256 leaf, - uint256[] calldata proofSiblings, - uint8[] calldata proofPathIndices - ) private view returns (bool) { - return InternalBinaryIMT._verify(self, leaf, proofSiblings, proofPathIndices); - } -} diff --git a/packages/imt.sol/contracts/Constants.sol b/packages/imt.sol/contracts/Constants.sol deleted file mode 100644 index 9f3c45578..000000000 --- a/packages/imt.sol/contracts/Constants.sol +++ /dev/null @@ -1,5 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.4; - -uint256 constant SNARK_SCALAR_FIELD = 21888242871839275222246405745257275088548364400416034343698204186575808495617; -uint8 constant MAX_DEPTH = 32; diff --git a/packages/imt.sol/contracts/LICENSE b/packages/imt.sol/contracts/LICENSE deleted file mode 100644 index 8ef16f7a5..000000000 --- a/packages/imt.sol/contracts/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2024 Ethereum Foundation - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/packages/imt.sol/contracts/LazyIMT.sol b/packages/imt.sol/contracts/LazyIMT.sol deleted file mode 100644 index ce9ed2324..000000000 --- a/packages/imt.sol/contracts/LazyIMT.sol +++ /dev/null @@ -1,52 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.4; - -import {InternalLazyIMT, LazyIMTData} from "./internal/InternalLazyIMT.sol"; - -library LazyIMT { - using InternalLazyIMT for *; - - function init(LazyIMTData storage self, uint8 depth) public { - InternalLazyIMT._init(self, depth); - } - - function defaultZero(uint8 index) public pure returns (uint256) { - return InternalLazyIMT._defaultZero(index); - } - - function reset(LazyIMTData storage self) public { - InternalLazyIMT._reset(self); - } - - function indexForElement(uint8 level, uint40 index) public pure returns (uint40) { - return InternalLazyIMT._indexForElement(level, index); - } - - function insert(LazyIMTData storage self, uint256 leaf) public { - InternalLazyIMT._insert(self, leaf); - } - - function update(LazyIMTData storage self, uint256 leaf, uint40 index) public { - InternalLazyIMT._update(self, leaf, index); - } - - function root(LazyIMTData storage self) public view returns (uint256) { - return InternalLazyIMT._root(self); - } - - function root(LazyIMTData storage self, uint8 depth) public view returns (uint256) { - return InternalLazyIMT._root(self, depth); - } - - function merkleProofElements( - LazyIMTData storage self, - uint40 index, - uint8 depth - ) public view returns (uint256[] memory) { - return InternalLazyIMT._merkleProofElements(self, index, depth); - } - - function _root(LazyIMTData storage self, uint40 numberOfLeaves, uint8 depth) internal view returns (uint256) { - return InternalLazyIMT._root(self, numberOfLeaves, depth); - } -} diff --git a/packages/imt.sol/contracts/LeanIMT.sol b/packages/imt.sol/contracts/LeanIMT.sol deleted file mode 100644 index b3753c69f..000000000 --- a/packages/imt.sol/contracts/LeanIMT.sol +++ /dev/null @@ -1,45 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.4; - -import {InternalLeanIMT, LeanIMTData} from "./internal/InternalLeanIMT.sol"; - -library LeanIMT { - using InternalLeanIMT for *; - - function insert(LeanIMTData storage self, uint256 leaf) public returns (uint256) { - return InternalLeanIMT._insert(self, leaf); - } - - function insertMany(LeanIMTData storage self, uint256[] calldata leaves) public returns (uint256) { - return InternalLeanIMT._insertMany(self, leaves); - } - - function update( - LeanIMTData storage self, - uint256 oldLeaf, - uint256 newLeaf, - uint256[] calldata siblingNodes - ) public returns (uint256) { - return InternalLeanIMT._update(self, oldLeaf, newLeaf, siblingNodes); - } - - function remove( - LeanIMTData storage self, - uint256 oldLeaf, - uint256[] calldata siblingNodes - ) public returns (uint256) { - return InternalLeanIMT._remove(self, oldLeaf, siblingNodes); - } - - function has(LeanIMTData storage self, uint256 leaf) public view returns (bool) { - return InternalLeanIMT._has(self, leaf); - } - - function indexOf(LeanIMTData storage self, uint256 leaf) public view returns (uint256) { - return InternalLeanIMT._indexOf(self, leaf); - } - - function root(LeanIMTData storage self) public view returns (uint256) { - return InternalLeanIMT._root(self); - } -} diff --git a/packages/imt.sol/contracts/QuinaryIMT.sol b/packages/imt.sol/contracts/QuinaryIMT.sol deleted file mode 100644 index e549108b5..000000000 --- a/packages/imt.sol/contracts/QuinaryIMT.sol +++ /dev/null @@ -1,44 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.4; - -import {InternalQuinaryIMT, QuinaryIMTData} from "./internal/InternalQuinaryIMT.sol"; - -library QuinaryIMT { - using InternalQuinaryIMT for *; - - function init(QuinaryIMTData storage self, uint256 depth, uint256 zero) public { - InternalQuinaryIMT._init(self, depth, zero); - } - - function insert(QuinaryIMTData storage self, uint256 leaf) public { - InternalQuinaryIMT._insert(self, leaf); - } - - function update( - QuinaryIMTData storage self, - uint256 leaf, - uint256 newLeaf, - uint256[4][] calldata proofSiblings, - uint8[] calldata proofPathIndices - ) public { - InternalQuinaryIMT._update(self, leaf, newLeaf, proofSiblings, proofPathIndices); - } - - function remove( - QuinaryIMTData storage self, - uint256 leaf, - uint256[4][] calldata proofSiblings, - uint8[] calldata proofPathIndices - ) public { - InternalQuinaryIMT._remove(self, leaf, proofSiblings, proofPathIndices); - } - - function verify( - QuinaryIMTData storage self, - uint256 leaf, - uint256[4][] calldata proofSiblings, - uint8[] calldata proofPathIndices - ) private view returns (bool) { - return InternalQuinaryIMT._verify(self, leaf, proofSiblings, proofPathIndices); - } -} diff --git a/packages/imt.sol/contracts/README.md b/packages/imt.sol/contracts/README.md deleted file mode 100644 index 190fc04c7..000000000 --- a/packages/imt.sol/contracts/README.md +++ /dev/null @@ -1,68 +0,0 @@ -

-

- Incremental Merkle Trees (Solidity) -

-

Incremental Merkle tree implementations in Solidity.

-

- -

- - - - - NPM license - - - NPM version - - - Downloads - - - Linter eslint - - - Code style prettier - -

- - - -> [!WARNING] -> If you are looking for the first version of this package, please visit this [link](https://github.com/privacy-scaling-explorations/zk-kit/tree/imt-v1/packages/incremental-merkle-tree.sol). - -> [!WARNING] -> These libraries have **not** been audited. - -## Libraries - -✔️ [BinaryIMT](https://github.com/privacy-scaling-explorations/zk-kit/blob/main/packages/imt.sol/contracts/internal/InternalBinaryIMT.sol) (Poseidon)\ -✔️ [QuinaryIMT](https://github.com/privacy-scaling-explorations/zk-kit/blob/main/packages/imt.sol/contracts/internal/InternalQuinaryIMT.sol) (Poseidon)\ -✔️ [LazyIMT](https://github.com/privacy-scaling-explorations/zk-kit/blob/main/packages/imt.sol/contracts/internal/InternalLazyIMT.sol) (Poseidon)\ -✔️ [LeanIMT](https://github.com/privacy-scaling-explorations/zk-kit/blob/main/packages/imt.sol/contracts/internal/InternalLeanIMT.sol) (Poseidon) ([Visual explanation](https://hackmd.io/@vplasencia/S1whLBN16)) - -## 🛠 Install - -### npm or yarn - -Install the `@zk-kit/imt.sol` package with npm: - -```bash -npm i @zk-kit/imt.sol --save -``` - -or yarn: - -```bash -yarn add @zk-kit/imt.sol -``` - -## 📜 Usage - -Please, see the [test contracts](./test) for guidance on utilizing the libraries. diff --git a/packages/imt.sol/contracts/internal/InternalBinaryIMT.sol b/packages/imt.sol/contracts/internal/InternalBinaryIMT.sol deleted file mode 100644 index 273f89554..000000000 --- a/packages/imt.sol/contracts/internal/InternalBinaryIMT.sol +++ /dev/null @@ -1,285 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.4; - -import {PoseidonT3} from "poseidon-solidity/PoseidonT3.sol"; -import {SNARK_SCALAR_FIELD, MAX_DEPTH} from "../Constants.sol"; - -// Each incremental tree has certain properties and data that will -// be used to add new leaves. -struct BinaryIMTData { - uint256 depth; // Depth of the tree (levels - 1). - uint256 root; // Root hash of the tree. - uint256 numberOfLeaves; // Number of leaves of the tree. - mapping(uint256 => uint256) zeroes; // Zero hashes used for empty nodes (level -> zero hash). - // The nodes of the subtrees used in the last addition of a leaf (level -> [left node, right node]). - mapping(uint256 => uint256[2]) lastSubtrees; // Caching these values is essential to efficient appends. - bool useDefaultZeroes; -} - -error ValueGreaterThanSnarkScalarField(); -error DepthNotSupported(); -error WrongDefaultZeroIndex(); -error TreeIsFull(); -error NewLeafCannotEqualOldLeaf(); -error LeafDoesNotExist(); -error LeafIndexOutOfRange(); -error WrongMerkleProofPath(); - -/// @title Incremental binary Merkle tree. -/// @dev The incremental tree allows to calculate the root hash each time a leaf is added, ensuring -/// the integrity of the tree. -library InternalBinaryIMT { - uint256 internal constant Z_0 = 0; - uint256 internal constant Z_1 = 14744269619966411208579211824598458697587494354926760081771325075741142829156; - uint256 internal constant Z_2 = 7423237065226347324353380772367382631490014989348495481811164164159255474657; - uint256 internal constant Z_3 = 11286972368698509976183087595462810875513684078608517520839298933882497716792; - uint256 internal constant Z_4 = 3607627140608796879659380071776844901612302623152076817094415224584923813162; - uint256 internal constant Z_5 = 19712377064642672829441595136074946683621277828620209496774504837737984048981; - uint256 internal constant Z_6 = 20775607673010627194014556968476266066927294572720319469184847051418138353016; - uint256 internal constant Z_7 = 3396914609616007258851405644437304192397291162432396347162513310381425243293; - uint256 internal constant Z_8 = 21551820661461729022865262380882070649935529853313286572328683688269863701601; - uint256 internal constant Z_9 = 6573136701248752079028194407151022595060682063033565181951145966236778420039; - uint256 internal constant Z_10 = 12413880268183407374852357075976609371175688755676981206018884971008854919922; - uint256 internal constant Z_11 = 14271763308400718165336499097156975241954733520325982997864342600795471836726; - uint256 internal constant Z_12 = 20066985985293572387227381049700832219069292839614107140851619262827735677018; - uint256 internal constant Z_13 = 9394776414966240069580838672673694685292165040808226440647796406499139370960; - uint256 internal constant Z_14 = 11331146992410411304059858900317123658895005918277453009197229807340014528524; - uint256 internal constant Z_15 = 15819538789928229930262697811477882737253464456578333862691129291651619515538; - uint256 internal constant Z_16 = 19217088683336594659449020493828377907203207941212636669271704950158751593251; - uint256 internal constant Z_17 = 21035245323335827719745544373081896983162834604456827698288649288827293579666; - uint256 internal constant Z_18 = 6939770416153240137322503476966641397417391950902474480970945462551409848591; - uint256 internal constant Z_19 = 10941962436777715901943463195175331263348098796018438960955633645115732864202; - uint256 internal constant Z_20 = 15019797232609675441998260052101280400536945603062888308240081994073687793470; - uint256 internal constant Z_21 = 11702828337982203149177882813338547876343922920234831094975924378932809409969; - uint256 internal constant Z_22 = 11217067736778784455593535811108456786943573747466706329920902520905755780395; - uint256 internal constant Z_23 = 16072238744996205792852194127671441602062027943016727953216607508365787157389; - uint256 internal constant Z_24 = 17681057402012993898104192736393849603097507831571622013521167331642182653248; - uint256 internal constant Z_25 = 21694045479371014653083846597424257852691458318143380497809004364947786214945; - uint256 internal constant Z_26 = 8163447297445169709687354538480474434591144168767135863541048304198280615192; - uint256 internal constant Z_27 = 14081762237856300239452543304351251708585712948734528663957353575674639038357; - uint256 internal constant Z_28 = 16619959921569409661790279042024627172199214148318086837362003702249041851090; - uint256 internal constant Z_29 = 7022159125197495734384997711896547675021391130223237843255817587255104160365; - uint256 internal constant Z_30 = 4114686047564160449611603615418567457008101555090703535405891656262658644463; - uint256 internal constant Z_31 = 12549363297364877722388257367377629555213421373705596078299904496781819142130; - uint256 internal constant Z_32 = 21443572485391568159800782191812935835534334817699172242223315142338162256601; - - function _defaultZero(uint256 index) internal pure returns (uint256) { - if (index == 0) return Z_0; - if (index == 1) return Z_1; - if (index == 2) return Z_2; - if (index == 3) return Z_3; - if (index == 4) return Z_4; - if (index == 5) return Z_5; - if (index == 6) return Z_6; - if (index == 7) return Z_7; - if (index == 8) return Z_8; - if (index == 9) return Z_9; - if (index == 10) return Z_10; - if (index == 11) return Z_11; - if (index == 12) return Z_12; - if (index == 13) return Z_13; - if (index == 14) return Z_14; - if (index == 15) return Z_15; - if (index == 16) return Z_16; - if (index == 17) return Z_17; - if (index == 18) return Z_18; - if (index == 19) return Z_19; - if (index == 20) return Z_20; - if (index == 21) return Z_21; - if (index == 22) return Z_22; - if (index == 23) return Z_23; - if (index == 24) return Z_24; - if (index == 25) return Z_25; - if (index == 26) return Z_26; - if (index == 27) return Z_27; - if (index == 28) return Z_28; - if (index == 29) return Z_29; - if (index == 30) return Z_30; - if (index == 31) return Z_31; - if (index == 32) return Z_32; - revert WrongDefaultZeroIndex(); - } - - /// @dev Initializes a tree. - /// @param self: Tree data. - /// @param depth: Depth of the tree. - /// @param zero: Zero value to be used. - function _init(BinaryIMTData storage self, uint256 depth, uint256 zero) internal { - if (zero >= SNARK_SCALAR_FIELD) { - revert ValueGreaterThanSnarkScalarField(); - } else if (depth <= 0 || depth > MAX_DEPTH) { - revert DepthNotSupported(); - } - - self.depth = depth; - - for (uint8 i = 0; i < depth; ) { - self.zeroes[i] = zero; - zero = PoseidonT3.hash([zero, zero]); - - unchecked { - ++i; - } - } - - self.root = zero; - } - - function _initWithDefaultZeroes(BinaryIMTData storage self, uint256 depth) internal { - if (depth <= 0 || depth > MAX_DEPTH) { - revert DepthNotSupported(); - } - - self.depth = depth; - self.useDefaultZeroes = true; - - self.root = _defaultZero(depth); - } - - /// @dev Inserts a leaf in the tree. - /// @param self: Tree data. - /// @param leaf: Leaf to be inserted. - function _insert(BinaryIMTData storage self, uint256 leaf) internal returns (uint256) { - uint256 depth = self.depth; - - if (leaf >= SNARK_SCALAR_FIELD) { - revert ValueGreaterThanSnarkScalarField(); - } else if (self.numberOfLeaves >= 2 ** depth) { - revert TreeIsFull(); - } - - uint256 index = self.numberOfLeaves; - uint256 hash = leaf; - bool useDefaultZeroes = self.useDefaultZeroes; - - for (uint8 i = 0; i < depth; ) { - if (index & 1 == 0) { - self.lastSubtrees[i] = [hash, useDefaultZeroes ? _defaultZero(i) : self.zeroes[i]]; - } else { - self.lastSubtrees[i][1] = hash; - } - - hash = PoseidonT3.hash(self.lastSubtrees[i]); - index >>= 1; - - unchecked { - ++i; - } - } - - self.root = hash; - self.numberOfLeaves += 1; - return hash; - } - - /// @dev Updates a leaf in the tree. - /// @param self: Tree data. - /// @param leaf: Leaf to be updated. - /// @param newLeaf: New leaf. - /// @param proofSiblings: Array of the sibling nodes of the proof of membership. - /// @param proofPathIndices: Path of the proof of membership. - function _update( - BinaryIMTData storage self, - uint256 leaf, - uint256 newLeaf, - uint256[] calldata proofSiblings, - uint8[] calldata proofPathIndices - ) internal { - if (newLeaf == leaf) { - revert NewLeafCannotEqualOldLeaf(); - } else if (newLeaf >= SNARK_SCALAR_FIELD) { - revert ValueGreaterThanSnarkScalarField(); - } else if (!_verify(self, leaf, proofSiblings, proofPathIndices)) { - revert LeafDoesNotExist(); - } - - uint256 depth = self.depth; - uint256 hash = newLeaf; - uint256 updateIndex; - - for (uint8 i = 0; i < depth; ) { - updateIndex |= uint256(proofPathIndices[i]) << uint256(i); - - if (proofPathIndices[i] == 0) { - if (proofSiblings[i] == self.lastSubtrees[i][1]) { - self.lastSubtrees[i][0] = hash; - } - - hash = PoseidonT3.hash([hash, proofSiblings[i]]); - } else { - if (proofSiblings[i] == self.lastSubtrees[i][0]) { - self.lastSubtrees[i][1] = hash; - } - - hash = PoseidonT3.hash([proofSiblings[i], hash]); - } - - unchecked { - ++i; - } - } - - if (updateIndex >= self.numberOfLeaves) { - revert LeafIndexOutOfRange(); - } - - self.root = hash; - } - - /// @dev Removes a leaf from the tree. - /// @param self: Tree data. - /// @param leaf: Leaf to be removed. - /// @param proofSiblings: Array of the sibling nodes of the proof of membership. - /// @param proofPathIndices: Path of the proof of membership. - function _remove( - BinaryIMTData storage self, - uint256 leaf, - uint256[] calldata proofSiblings, - uint8[] calldata proofPathIndices - ) internal { - _update(self, leaf, self.useDefaultZeroes ? Z_0 : self.zeroes[0], proofSiblings, proofPathIndices); - } - - /// @dev Verify if the path is correct and the leaf is part of the tree. - /// @param self: Tree data. - /// @param leaf: Leaf to be removed. - /// @param proofSiblings: Array of the sibling nodes of the proof of membership. - /// @param proofPathIndices: Path of the proof of membership. - /// @return True or false. - function _verify( - BinaryIMTData storage self, - uint256 leaf, - uint256[] calldata proofSiblings, - uint8[] calldata proofPathIndices - ) internal view returns (bool) { - uint256 depth = self.depth; - - if (leaf >= SNARK_SCALAR_FIELD) { - revert ValueGreaterThanSnarkScalarField(); - } else if (proofPathIndices.length != depth || proofSiblings.length != depth) { - revert WrongMerkleProofPath(); - } - - uint256 hash = leaf; - - for (uint8 i = 0; i < depth; ) { - if (proofSiblings[i] >= SNARK_SCALAR_FIELD) { - revert ValueGreaterThanSnarkScalarField(); - } else if (proofPathIndices[i] != 1 && proofPathIndices[i] != 0) { - revert WrongMerkleProofPath(); - } - - if (proofPathIndices[i] == 0) { - hash = PoseidonT3.hash([hash, proofSiblings[i]]); - } else { - hash = PoseidonT3.hash([proofSiblings[i], hash]); - } - - unchecked { - ++i; - } - } - - return hash == self.root; - } -} diff --git a/packages/imt.sol/contracts/internal/InternalLazyIMT.sol b/packages/imt.sol/contracts/internal/InternalLazyIMT.sol deleted file mode 100644 index 697417932..000000000 --- a/packages/imt.sol/contracts/internal/InternalLazyIMT.sol +++ /dev/null @@ -1,267 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.4; - -import {PoseidonT3} from "poseidon-solidity/PoseidonT3.sol"; -import {SNARK_SCALAR_FIELD, MAX_DEPTH} from "../Constants.sol"; - -struct LazyIMTData { - uint40 maxIndex; - uint40 numberOfLeaves; - mapping(uint256 => uint256) elements; -} - -library InternalLazyIMT { - uint40 internal constant MAX_INDEX = (1 << 32) - 1; - - uint256 internal constant Z_0 = 0; - uint256 internal constant Z_1 = 14744269619966411208579211824598458697587494354926760081771325075741142829156; - uint256 internal constant Z_2 = 7423237065226347324353380772367382631490014989348495481811164164159255474657; - uint256 internal constant Z_3 = 11286972368698509976183087595462810875513684078608517520839298933882497716792; - uint256 internal constant Z_4 = 3607627140608796879659380071776844901612302623152076817094415224584923813162; - uint256 internal constant Z_5 = 19712377064642672829441595136074946683621277828620209496774504837737984048981; - uint256 internal constant Z_6 = 20775607673010627194014556968476266066927294572720319469184847051418138353016; - uint256 internal constant Z_7 = 3396914609616007258851405644437304192397291162432396347162513310381425243293; - uint256 internal constant Z_8 = 21551820661461729022865262380882070649935529853313286572328683688269863701601; - uint256 internal constant Z_9 = 6573136701248752079028194407151022595060682063033565181951145966236778420039; - uint256 internal constant Z_10 = 12413880268183407374852357075976609371175688755676981206018884971008854919922; - uint256 internal constant Z_11 = 14271763308400718165336499097156975241954733520325982997864342600795471836726; - uint256 internal constant Z_12 = 20066985985293572387227381049700832219069292839614107140851619262827735677018; - uint256 internal constant Z_13 = 9394776414966240069580838672673694685292165040808226440647796406499139370960; - uint256 internal constant Z_14 = 11331146992410411304059858900317123658895005918277453009197229807340014528524; - uint256 internal constant Z_15 = 15819538789928229930262697811477882737253464456578333862691129291651619515538; - uint256 internal constant Z_16 = 19217088683336594659449020493828377907203207941212636669271704950158751593251; - uint256 internal constant Z_17 = 21035245323335827719745544373081896983162834604456827698288649288827293579666; - uint256 internal constant Z_18 = 6939770416153240137322503476966641397417391950902474480970945462551409848591; - uint256 internal constant Z_19 = 10941962436777715901943463195175331263348098796018438960955633645115732864202; - uint256 internal constant Z_20 = 15019797232609675441998260052101280400536945603062888308240081994073687793470; - uint256 internal constant Z_21 = 11702828337982203149177882813338547876343922920234831094975924378932809409969; - uint256 internal constant Z_22 = 11217067736778784455593535811108456786943573747466706329920902520905755780395; - uint256 internal constant Z_23 = 16072238744996205792852194127671441602062027943016727953216607508365787157389; - uint256 internal constant Z_24 = 17681057402012993898104192736393849603097507831571622013521167331642182653248; - uint256 internal constant Z_25 = 21694045479371014653083846597424257852691458318143380497809004364947786214945; - uint256 internal constant Z_26 = 8163447297445169709687354538480474434591144168767135863541048304198280615192; - uint256 internal constant Z_27 = 14081762237856300239452543304351251708585712948734528663957353575674639038357; - uint256 internal constant Z_28 = 16619959921569409661790279042024627172199214148318086837362003702249041851090; - uint256 internal constant Z_29 = 7022159125197495734384997711896547675021391130223237843255817587255104160365; - uint256 internal constant Z_30 = 4114686047564160449611603615418567457008101555090703535405891656262658644463; - uint256 internal constant Z_31 = 12549363297364877722388257367377629555213421373705596078299904496781819142130; - uint256 internal constant Z_32 = 21443572485391568159800782191812935835534334817699172242223315142338162256601; - - function _defaultZero(uint8 index) internal pure returns (uint256) { - if (index == 0) return Z_0; - if (index == 1) return Z_1; - if (index == 2) return Z_2; - if (index == 3) return Z_3; - if (index == 4) return Z_4; - if (index == 5) return Z_5; - if (index == 6) return Z_6; - if (index == 7) return Z_7; - if (index == 8) return Z_8; - if (index == 9) return Z_9; - if (index == 10) return Z_10; - if (index == 11) return Z_11; - if (index == 12) return Z_12; - if (index == 13) return Z_13; - if (index == 14) return Z_14; - if (index == 15) return Z_15; - if (index == 16) return Z_16; - if (index == 17) return Z_17; - if (index == 18) return Z_18; - if (index == 19) return Z_19; - if (index == 20) return Z_20; - if (index == 21) return Z_21; - if (index == 22) return Z_22; - if (index == 23) return Z_23; - if (index == 24) return Z_24; - if (index == 25) return Z_25; - if (index == 26) return Z_26; - if (index == 27) return Z_27; - if (index == 28) return Z_28; - if (index == 29) return Z_29; - if (index == 30) return Z_30; - if (index == 31) return Z_31; - if (index == 32) return Z_32; - revert("LazyIMT: defaultZero bad index"); - } - - function _init(LazyIMTData storage self, uint8 depth) internal { - require(depth <= MAX_DEPTH, "LazyIMT: Tree too large"); - self.maxIndex = uint40((1 << depth) - 1); - self.numberOfLeaves = 0; - } - - function _reset(LazyIMTData storage self) internal { - self.numberOfLeaves = 0; - } - - function _indexForElement(uint8 level, uint40 index) internal pure returns (uint40) { - // store the elements sparsely - return MAX_INDEX * level + index; - } - - function _insert(LazyIMTData storage self, uint256 leaf) internal { - uint40 index = self.numberOfLeaves; - require(leaf < SNARK_SCALAR_FIELD, "LazyIMT: leaf must be < SNARK_SCALAR_FIELD"); - require(index < self.maxIndex, "LazyIMT: tree is full"); - - self.numberOfLeaves = index + 1; - - uint256 hash = leaf; - - for (uint8 i = 0; ; ) { - self.elements[_indexForElement(i, index)] = hash; - // it's a left element so we don't hash until there's a right element - if (index & 1 == 0) break; - uint40 elementIndex = _indexForElement(i, index - 1); - hash = PoseidonT3.hash([self.elements[elementIndex], hash]); - unchecked { - index >>= 1; - i++; - } - } - } - - function _update(LazyIMTData storage self, uint256 leaf, uint40 index) internal { - require(leaf < SNARK_SCALAR_FIELD, "LazyIMT: leaf must be < SNARK_SCALAR_FIELD"); - uint40 numberOfLeaves = self.numberOfLeaves; - require(index < numberOfLeaves, "LazyIMT: leaf must exist"); - - uint256 hash = leaf; - - for (uint8 i = 0; true; ) { - self.elements[_indexForElement(i, index)] = hash; - uint256 levelCount = numberOfLeaves >> (i + 1); - if (levelCount <= index >> 1) break; - if (index & 1 == 0) { - uint40 elementIndex = _indexForElement(i, index + 1); - hash = PoseidonT3.hash([hash, self.elements[elementIndex]]); - } else { - uint40 elementIndex = _indexForElement(i, index - 1); - hash = PoseidonT3.hash([self.elements[elementIndex], hash]); - } - unchecked { - index >>= 1; - i++; - } - } - } - - function _root(LazyIMTData storage self) internal view returns (uint256) { - // this will always short circuit if self.numberOfLeaves == 0 - uint40 numberOfLeaves = self.numberOfLeaves; - // dynamically determine a depth - uint8 depth = 1; - while (uint40(2) ** uint40(depth) < numberOfLeaves) { - depth++; - } - return _root(self, numberOfLeaves, depth); - } - - function _root(LazyIMTData storage self, uint8 depth) internal view returns (uint256) { - require(depth > 0, "LazyIMT: depth must be > 0"); - require(depth <= MAX_DEPTH, "LazyIMT: depth must be <= MAX_DEPTH"); - uint40 numberOfLeaves = self.numberOfLeaves; - require(uint40(2) ** uint40(depth) >= numberOfLeaves, "LazyIMT: ambiguous depth"); - return _root(self, numberOfLeaves, depth); - } - - // Here it's assumed that the depth value is valid. If it is either 0 or > 2^8-1 - // this function will panic. - function _root(LazyIMTData storage self, uint40 numberOfLeaves, uint8 depth) internal view returns (uint256) { - require(depth <= MAX_DEPTH, "LazyIMT: depth must be <= MAX_DEPTH"); - // this should always short circuit if self.numberOfLeaves == 0 - if (numberOfLeaves == 0) return _defaultZero(depth); - uint256[] memory levels = new uint256[](depth + 1); - _levels(self, numberOfLeaves, depth, levels); - return levels[depth]; - } - - function _levels( - LazyIMTData storage self, - uint40 numberOfLeaves, - uint8 depth, - uint256[] memory levels - ) internal view { - require(depth <= MAX_DEPTH, "LazyIMT: depth must be <= MAX_DEPTH"); - require(numberOfLeaves > 0, "LazyIMT: number of leaves must be > 0"); - // this should always short circuit if self.numberOfLeaves == 0 - uint40 index = numberOfLeaves - 1; - - if (index & 1 == 0) { - levels[0] = self.elements[_indexForElement(0, index)]; - } else { - levels[0] = _defaultZero(0); - } - - for (uint8 i = 0; i < depth; ) { - if (index & 1 == 0) { - levels[i + 1] = PoseidonT3.hash([levels[i], _defaultZero(i)]); - } else { - uint256 levelCount = (numberOfLeaves) >> (i + 1); - if (levelCount > index >> 1) { - uint256 parent = self.elements[_indexForElement(i + 1, index >> 1)]; - levels[i + 1] = parent; - } else { - uint256 sibling = self.elements[_indexForElement(i, index - 1)]; - levels[i + 1] = PoseidonT3.hash([sibling, levels[i]]); - } - } - unchecked { - index >>= 1; - i++; - } - } - } - - function _merkleProofElements( - LazyIMTData storage self, - uint40 index, - uint8 depth - ) internal view returns (uint256[] memory) { - uint40 numberOfLeaves = self.numberOfLeaves; - require(index < numberOfLeaves, "LazyIMT: leaf must exist"); - - uint8 targetDepth = 1; - while (uint40(2) ** uint40(targetDepth) < numberOfLeaves) { - targetDepth++; - } - require(depth >= targetDepth, "LazyIMT: proof depth"); - // pass depth -1 because we don't need the root value - uint256[] memory _elements = new uint256[](depth); - _levels(self, numberOfLeaves, targetDepth - 1, _elements); - - // unroll the bottom entry of the tree because it will never need to - // be pulled from _levels - if (index & 1 == 0) { - if (index + 1 >= numberOfLeaves) { - _elements[0] = _defaultZero(0); - } else { - _elements[0] = self.elements[_indexForElement(0, index + 1)]; - } - } else { - _elements[0] = self.elements[_indexForElement(0, index - 1)]; - } - index >>= 1; - - for (uint8 i = 1; i < depth; ) { - uint256 currentLevelCount = numberOfLeaves >> i; - if (index & 1 == 0) { - // if the element is an uncomputed edge node we'll use the value set - // from _levels above - // otherwise set as usual below - if (index + 1 < currentLevelCount) { - _elements[i] = self.elements[_indexForElement(i, index + 1)]; - } else if (((numberOfLeaves - 1) >> i) <= index) { - _elements[i] = _defaultZero(i); - } - } else { - _elements[i] = self.elements[_indexForElement(i, index - 1)]; - } - unchecked { - index >>= 1; - i++; - } - } - return _elements; - } -} diff --git a/packages/imt.sol/contracts/internal/InternalLeanIMT.sol b/packages/imt.sol/contracts/internal/InternalLeanIMT.sol deleted file mode 100644 index a7375d60d..000000000 --- a/packages/imt.sol/contracts/internal/InternalLeanIMT.sol +++ /dev/null @@ -1,345 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.4; - -import {PoseidonT3} from "poseidon-solidity/PoseidonT3.sol"; -import {SNARK_SCALAR_FIELD} from "../Constants.sol"; - -struct LeanIMTData { - // Tracks the current number of leaves in the tree. - uint256 size; - // Represents the current depth of the tree, which can increase as new leaves are inserted. - uint256 depth; - // A mapping from each level of the tree to the node value of the last even position at that level. - // Used for efficient inserts, updates and root calculations. - mapping(uint256 => uint256) sideNodes; - // A mapping from leaf values to their respective indices in the tree. - // This facilitates checks for leaf existence and retrieval of leaf positions. - mapping(uint256 => uint256) leaves; -} - -error WrongSiblingNodes(); -error LeafGreaterThanSnarkScalarField(); -error LeafCannotBeZero(); -error LeafAlreadyExists(); -error LeafDoesNotExist(); - -/// @title Lean Incremental binary Merkle tree. -/// @dev The LeanIMT is an optimized version of the BinaryIMT. -/// This implementation eliminates the use of zeroes, and make the tree depth dynamic. -/// When a node doesn't have the right child, instead of using a zero hash as in the BinaryIMT, -/// the node's value becomes that of its left child. Furthermore, rather than utilizing a static tree depth, -/// it is updated based on the number of leaves in the tree. This approach -/// results in the calculation of significantly fewer hashes, making the tree more efficient. -library InternalLeanIMT { - /// @dev Inserts a new leaf into the incremental merkle tree. - /// The function ensures that the leaf is valid according to the - /// constraints of the tree and then updates the tree's structure accordingly. - /// @param self: A storage reference to the 'LeanIMTData' struct. - /// @param leaf: The value of the new leaf to be inserted into the tree. - /// @return The new hash of the node after the leaf has been inserted. - function _insert(LeanIMTData storage self, uint256 leaf) internal returns (uint256) { - if (leaf >= SNARK_SCALAR_FIELD) { - revert LeafGreaterThanSnarkScalarField(); - } else if (leaf == 0) { - revert LeafCannotBeZero(); - } else if (_has(self, leaf)) { - revert LeafAlreadyExists(); - } - - uint256 index = self.size; - - // Cache tree depth to optimize gas - uint256 treeDepth = self.depth; - - // A new insertion can increase a tree's depth by at most 1, - // and only if the number of leaves supported by the current - // depth is less than the number of leaves to be supported after insertion. - if (2 ** treeDepth < index + 1) { - ++treeDepth; - } - - self.depth = treeDepth; - - uint256 node = leaf; - - for (uint256 level = 0; level < treeDepth; ) { - if ((index >> level) & 1 == 1) { - node = PoseidonT3.hash([self.sideNodes[level], node]); - } else { - self.sideNodes[level] = node; - } - - unchecked { - ++level; - } - } - - self.size = ++index; - - self.sideNodes[treeDepth] = node; - self.leaves[leaf] = index; - - return node; - } - - /// @dev Inserts many leaves into the incremental merkle tree. - /// The function ensures that the leaves are valid according to the - /// constraints of the tree and then updates the tree's structure accordingly. - /// @param self: A storage reference to the 'LeanIMTData' struct. - /// @param leaves: The values of the new leaves to be inserted into the tree. - /// @return The root after the leaves have been inserted. - function _insertMany(LeanIMTData storage self, uint256[] calldata leaves) internal returns (uint256) { - // Cache tree size to optimize gas - uint256 treeSize = self.size; - - // Check that all the new values are correct to be added. - for (uint256 i = 0; i < leaves.length; ) { - if (leaves[i] >= SNARK_SCALAR_FIELD) { - revert LeafGreaterThanSnarkScalarField(); - } else if (leaves[i] == 0) { - revert LeafCannotBeZero(); - } else if (_has(self, leaves[i])) { - revert LeafAlreadyExists(); - } - - self.leaves[leaves[i]] = treeSize + 1 + i; - - unchecked { - ++i; - } - } - - // Array to save the nodes that will be used to create the next level of the tree. - uint256[] memory currentLevelNewNodes; - - currentLevelNewNodes = leaves; - - // Cache tree depth to optimize gas - uint256 treeDepth = self.depth; - - // Calculate the depth of the tree after adding the new values. - // Unlike the 'insert' function, we need a while here as - // N insertions can increase the tree's depth more than once. - while (2 ** treeDepth < treeSize + leaves.length) { - ++treeDepth; - } - - self.depth = treeDepth; - - // First index to change in every level. - uint256 currentLevelStartIndex = treeSize; - - // Size of the level used to create the next level. - uint256 currentLevelSize = treeSize + leaves.length; - - // The index where changes begin at the next level. - uint256 nextLevelStartIndex = currentLevelStartIndex >> 1; - - // The size of the next level. - uint256 nextLevelSize = ((currentLevelSize - 1) >> 1) + 1; - - for (uint256 level = 0; level < treeDepth; ) { - // The number of nodes for the new level that will be created, - // only the new values, not the entire level. - uint256 numberOfNewNodes = nextLevelSize - nextLevelStartIndex; - uint256[] memory nextLevelNewNodes = new uint256[](numberOfNewNodes); - for (uint256 i = 0; i < numberOfNewNodes; ) { - uint256 leftNode; - - // Assign the left node using the saved path or the position in the array. - if ((i + nextLevelStartIndex) * 2 < currentLevelStartIndex) { - leftNode = self.sideNodes[level]; - } else { - leftNode = currentLevelNewNodes[(i + nextLevelStartIndex) * 2 - currentLevelStartIndex]; - } - - uint256 rightNode; - - // Assign the right node if the value exists. - if ((i + nextLevelStartIndex) * 2 + 1 < currentLevelSize) { - rightNode = currentLevelNewNodes[(i + nextLevelStartIndex) * 2 + 1 - currentLevelStartIndex]; - } - - uint256 parentNode; - - // Assign the parent node. - // If it has a right child the result will be the hash(leftNode, rightNode) if not, - // it will be the leftNode. - if (rightNode != 0) { - parentNode = PoseidonT3.hash([leftNode, rightNode]); - } else { - parentNode = leftNode; - } - - nextLevelNewNodes[i] = parentNode; - - unchecked { - ++i; - } - } - - // Update the `sideNodes` variable. - // If `currentLevelSize` is odd, the saved value will be the last value of the array - // if it is even and there are more than 1 element in `currentLevelNewNodes`, the saved value - // will be the value before the last one. - // If it is even and there is only one element, there is no need to save anything because - // the correct value for this level was already saved before. - if (currentLevelSize & 1 == 1) { - self.sideNodes[level] = currentLevelNewNodes[currentLevelNewNodes.length - 1]; - } else if (currentLevelNewNodes.length > 1) { - self.sideNodes[level] = currentLevelNewNodes[currentLevelNewNodes.length - 2]; - } - - currentLevelStartIndex = nextLevelStartIndex; - - // Calculate the next level startIndex value. - // It is the position of the parent node which is pos/2. - nextLevelStartIndex >>= 1; - - // Update the next array that will be used to calculate the next level. - currentLevelNewNodes = nextLevelNewNodes; - - currentLevelSize = nextLevelSize; - - // Calculate the size of the next level. - // The size of the next level is (currentLevelSize - 1) / 2 + 1. - nextLevelSize = ((nextLevelSize - 1) >> 1) + 1; - - unchecked { - ++level; - } - } - - // Update tree size - self.size = treeSize + leaves.length; - - // Update tree root - self.sideNodes[treeDepth] = currentLevelNewNodes[0]; - - return currentLevelNewNodes[0]; - } - - /// @dev Updates the value of an existing leaf and recalculates hashes - /// to maintain tree integrity. - /// @param self: A storage reference to the 'LeanIMTData' struct. - /// @param oldLeaf: The value of the leaf that is to be updated. - /// @param newLeaf: The new value that will replace the oldLeaf in the tree. - /// @param siblingNodes: An array of sibling nodes that are necessary to recalculate the path to the root. - /// @return The new hash of the updated node after the leaf has been updated. - function _update( - LeanIMTData storage self, - uint256 oldLeaf, - uint256 newLeaf, - uint256[] calldata siblingNodes - ) internal returns (uint256) { - if (newLeaf >= SNARK_SCALAR_FIELD) { - revert LeafGreaterThanSnarkScalarField(); - } else if (!_has(self, oldLeaf)) { - revert LeafDoesNotExist(); - } else if (_has(self, newLeaf)) { - revert LeafAlreadyExists(); - } - - uint256 index = _indexOf(self, oldLeaf); - uint256 node = newLeaf; - uint256 oldRoot = oldLeaf; - - uint256 lastIndex = self.size - 1; - uint256 i = 0; - - // Cache tree depth to optimize gas - uint256 treeDepth = self.depth; - - for (uint256 level = 0; level < treeDepth; ) { - if ((index >> level) & 1 == 1) { - if (siblingNodes[i] >= SNARK_SCALAR_FIELD) { - revert LeafGreaterThanSnarkScalarField(); - } - - node = PoseidonT3.hash([siblingNodes[i], node]); - oldRoot = PoseidonT3.hash([siblingNodes[i], oldRoot]); - - unchecked { - ++i; - } - } else { - if (index >> level != lastIndex >> level) { - if (siblingNodes[i] >= SNARK_SCALAR_FIELD) { - revert LeafGreaterThanSnarkScalarField(); - } - - node = PoseidonT3.hash([node, siblingNodes[i]]); - oldRoot = PoseidonT3.hash([oldRoot, siblingNodes[i]]); - - unchecked { - ++i; - } - } else { - self.sideNodes[i] = node; - } - } - - unchecked { - ++level; - } - } - - if (oldRoot != _root(self)) { - revert WrongSiblingNodes(); - } - - self.sideNodes[treeDepth] = node; - - if (newLeaf != 0) { - self.leaves[newLeaf] = self.leaves[oldLeaf]; - } - - self.leaves[oldLeaf] = 0; - - return node; - } - - /// @dev Removes a leaf from the tree by setting its value to zero. - /// This function utilizes the update function to set the leaf's value - /// to zero and update the tree's state accordingly. - /// @param self: A storage reference to the 'LeanIMTData' struct. - /// @param oldLeaf: The value of the leaf to be removed. - /// @param siblingNodes: An array of sibling nodes required for updating the path to the root after removal. - /// @return The new root hash of the tree after the leaf has been removed. - function _remove( - LeanIMTData storage self, - uint256 oldLeaf, - uint256[] calldata siblingNodes - ) internal returns (uint256) { - return _update(self, oldLeaf, 0, siblingNodes); - } - - /// @dev Checks if a leaf exists in the tree. - /// @param self: A storage reference to the 'LeanIMTData' struct. - /// @param leaf: The value of the leaf to check for existence. - /// @return A boolean value indicating whether the leaf exists in the tree. - function _has(LeanIMTData storage self, uint256 leaf) internal view returns (bool) { - return self.leaves[leaf] != 0; - } - - /// @dev Retrieves the index of a given leaf in the tree. - /// @param self: A storage reference to the 'LeanIMTData' struct. - /// @param leaf: The value of the leaf whose index is to be found. - /// @return The index of the specified leaf within the tree. If the leaf is not present, the function - /// reverts with a custom error. - function _indexOf(LeanIMTData storage self, uint256 leaf) internal view returns (uint256) { - if (self.leaves[leaf] == 0) { - revert LeafDoesNotExist(); - } - - return self.leaves[leaf] - 1; - } - - /// @dev Retrieves the root of the tree from the 'sideNodes' mapping using the - /// current tree depth. - /// @param self: A storage reference to the 'LeanIMTData' struct. - /// @return The root hash of the tree. - function _root(LeanIMTData storage self) internal view returns (uint256) { - return self.sideNodes[self.depth]; - } -} diff --git a/packages/imt.sol/contracts/internal/InternalQuinaryIMT.sol b/packages/imt.sol/contracts/internal/InternalQuinaryIMT.sol deleted file mode 100644 index 93f60732c..000000000 --- a/packages/imt.sol/contracts/internal/InternalQuinaryIMT.sol +++ /dev/null @@ -1,241 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.4; - -import {PoseidonT6} from "poseidon-solidity/PoseidonT6.sol"; -import {SNARK_SCALAR_FIELD, MAX_DEPTH} from "../Constants.sol"; - -// Each incremental tree has certain properties and data that will -// be used to add new leaves. -struct QuinaryIMTData { - uint256 depth; // Depth of the tree (levels - 1). - uint256 root; // Root hash of the tree. - uint256 numberOfLeaves; // Number of leaves of the tree. - mapping(uint256 => uint256) zeroes; // Zero hashes used for empty nodes (level -> zero hash). - // The nodes of the subtrees used in the last addition of a leaf (level -> [nodes]). - mapping(uint256 => uint256[5]) lastSubtrees; // Caching these values is essential to efficient appends. -} - -error ValueGreaterThanSnarkScalarField(); -error DepthNotSupported(); -error TreeIsFull(); -error NewLeafCannotEqualOldLeaf(); -error LeafDoesNotExist(); -error LeafIndexOutOfRange(); -error WrongMerkleProofPath(); - -/// @title Incremental quinary Merkle tree. -/// @dev The incremental tree allows to calculate the root hash each time a leaf is added, ensuring -/// the integrity of the tree. -library InternalQuinaryIMT { - /// @dev Initializes a tree. - /// @param self: Tree data. - /// @param depth: Depth of the tree. - /// @param zero: Zero value to be used. - function _init(QuinaryIMTData storage self, uint256 depth, uint256 zero) internal { - if (zero >= SNARK_SCALAR_FIELD) { - revert ValueGreaterThanSnarkScalarField(); - } else if (depth <= 0 || depth > MAX_DEPTH) { - revert DepthNotSupported(); - } - - self.depth = depth; - - for (uint8 i = 0; i < depth; ) { - self.zeroes[i] = zero; - uint256[5] memory zeroChildren; - - for (uint8 j = 0; j < 5; ) { - zeroChildren[j] = zero; - unchecked { - ++j; - } - } - - zero = PoseidonT6.hash(zeroChildren); - - unchecked { - ++i; - } - } - - self.root = zero; - } - - /// @dev Inserts a leaf in the tree. - /// @param self: Tree data. - /// @param leaf: Leaf to be inserted. - function _insert(QuinaryIMTData storage self, uint256 leaf) internal { - uint256 depth = self.depth; - - if (leaf >= SNARK_SCALAR_FIELD) { - revert ValueGreaterThanSnarkScalarField(); - } else if (self.numberOfLeaves >= 5 ** depth) { - revert TreeIsFull(); - } - - uint256 index = self.numberOfLeaves; - uint256 hash = leaf; - - for (uint8 i = 0; i < depth; ) { - uint8 position = uint8(index % 5); - - self.lastSubtrees[i][position] = hash; - - if (position == 0) { - for (uint8 j = 1; j < 5; ) { - self.lastSubtrees[i][j] = self.zeroes[i]; - unchecked { - ++j; - } - } - } - - hash = PoseidonT6.hash(self.lastSubtrees[i]); - index /= 5; - - unchecked { - ++i; - } - } - - self.root = hash; - self.numberOfLeaves += 1; - } - - /// @dev Updates a leaf in the tree. - /// @param self: Tree data. - /// @param leaf: Leaf to be updated. - /// @param newLeaf: New leaf. - /// @param proofSiblings: Array of the sibling nodes of the proof of membership. - /// @param proofPathIndices: Path of the proof of membership. - function _update( - QuinaryIMTData storage self, - uint256 leaf, - uint256 newLeaf, - uint256[4][] calldata proofSiblings, - uint8[] calldata proofPathIndices - ) internal { - if (newLeaf == leaf) { - revert NewLeafCannotEqualOldLeaf(); - } else if (newLeaf >= SNARK_SCALAR_FIELD) { - revert ValueGreaterThanSnarkScalarField(); - } else if (!_verify(self, leaf, proofSiblings, proofPathIndices)) { - revert LeafDoesNotExist(); - } - - uint256 depth = self.depth; - uint256 hash = newLeaf; - uint256 updateIndex; - - for (uint8 i = 0; i < depth; ) { - uint256[5] memory nodes; - updateIndex += proofPathIndices[i] * 5 ** i; - - for (uint8 j = 0; j < 5; ) { - if (j < proofPathIndices[i]) { - nodes[j] = proofSiblings[i][j]; - } else if (j == proofPathIndices[i]) { - nodes[j] = hash; - } else { - nodes[j] = proofSiblings[i][j - 1]; - } - unchecked { - ++j; - } - } - - if (nodes[0] == self.lastSubtrees[i][0] || nodes[4] == self.lastSubtrees[i][4]) { - self.lastSubtrees[i][proofPathIndices[i]] = hash; - } - - hash = PoseidonT6.hash(nodes); - - unchecked { - ++i; - } - } - - if (updateIndex >= self.numberOfLeaves) { - revert LeafIndexOutOfRange(); - } - - self.root = hash; - } - - /// @dev Removes a leaf from the tree. - /// @param self: Tree data. - /// @param leaf: Leaf to be removed. - /// @param proofSiblings: Array of the sibling nodes of the proof of membership. - /// @param proofPathIndices: Path of the proof of membership. - function _remove( - QuinaryIMTData storage self, - uint256 leaf, - uint256[4][] calldata proofSiblings, - uint8[] calldata proofPathIndices - ) internal { - _update(self, leaf, self.zeroes[0], proofSiblings, proofPathIndices); - } - - /// @dev Verify if the path is correct and the leaf is part of the tree. - /// @param self: Tree data. - /// @param leaf: Leaf to be removed. - /// @param proofSiblings: Array of the sibling nodes of the proof of membership. - /// @param proofPathIndices: Path of the proof of membership. - /// @return True or false. - function _verify( - QuinaryIMTData storage self, - uint256 leaf, - uint256[4][] calldata proofSiblings, - uint8[] calldata proofPathIndices - ) internal view returns (bool) { - uint256 depth = self.depth; - - if (leaf >= SNARK_SCALAR_FIELD) { - revert ValueGreaterThanSnarkScalarField(); - } else if (proofPathIndices.length != depth || proofSiblings.length != depth) { - revert WrongMerkleProofPath(); - } - - uint256 hash = leaf; - - for (uint8 i = 0; i < depth; ) { - uint256[5] memory nodes; - - if (proofPathIndices[i] < 0 || proofPathIndices[i] >= 5) { - revert WrongMerkleProofPath(); - } - - for (uint8 j = 0; j < 5; ) { - if (j < proofPathIndices[i]) { - require( - proofSiblings[i][j] < SNARK_SCALAR_FIELD, - "QuinaryIMT: sibling node must be < SNARK_SCALAR_FIELD" - ); - - nodes[j] = proofSiblings[i][j]; - } else if (j == proofPathIndices[i]) { - nodes[j] = hash; - } else { - require( - proofSiblings[i][j - 1] < SNARK_SCALAR_FIELD, - "QuinaryIMT: sibling node must be < SNARK_SCALAR_FIELD" - ); - - nodes[j] = proofSiblings[i][j - 1]; - } - - unchecked { - ++j; - } - } - - hash = PoseidonT6.hash(nodes); - - unchecked { - ++i; - } - } - - return hash == self.root; - } -} diff --git a/packages/imt.sol/contracts/package.json b/packages/imt.sol/contracts/package.json deleted file mode 100644 index e16f1ea16..000000000 --- a/packages/imt.sol/contracts/package.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "@zk-kit/imt.sol", - "version": "2.0.0-beta.12", - "description": "Incremental Merkle tree implementations in Solidity.", - "license": "MIT", - "files": [ - "*.sol", - "internal/*", - "!test/*", - "README.md", - "LICENSE" - ], - "keywords": [ - "blockchain", - "ethereum", - "hardhat", - "smart-contracts", - "solidity", - "libraries", - "merkle-tree", - "incremental-merkle-tree" - ], - "repository": "git@github.com:privacy-scaling-explorations/zk-kit.git", - "homepage": "https://github.com/privacy-scaling-explorations/zk-kit/tree/main/packages/imt.sol", - "publishConfig": { - "access": "public" - }, - "dependencies": { - "poseidon-solidity": "0.0.5" - } -} diff --git a/packages/imt.sol/contracts/test/BinaryIMTTest.sol b/packages/imt.sol/contracts/test/BinaryIMTTest.sol deleted file mode 100644 index b7a8057c1..000000000 --- a/packages/imt.sol/contracts/test/BinaryIMTTest.sol +++ /dev/null @@ -1,34 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity ^0.8.4; - -import {BinaryIMT, BinaryIMTData} from "../BinaryIMT.sol"; - -contract BinaryIMTTest { - BinaryIMTData public data; - - function init(uint256 depth) external { - BinaryIMT.init(data, depth, 0); - } - - function initWithDefaultZeroes(uint256 depth) external { - BinaryIMT.initWithDefaultZeroes(data, depth); - } - - function insert(uint256 leaf) external { - BinaryIMT.insert(data, leaf); - } - - function update( - uint256 leaf, - uint256 newLeaf, - uint256[] calldata proofSiblings, - uint8[] calldata proofPathIndices - ) external { - BinaryIMT.update(data, leaf, newLeaf, proofSiblings, proofPathIndices); - } - - function remove(uint256 leaf, uint256[] calldata proofSiblings, uint8[] calldata proofPathIndices) external { - BinaryIMT.remove(data, leaf, proofSiblings, proofPathIndices); - } -} diff --git a/packages/imt.sol/contracts/test/LazyIMTTest.sol b/packages/imt.sol/contracts/test/LazyIMTTest.sol deleted file mode 100644 index 417c34134..000000000 --- a/packages/imt.sol/contracts/test/LazyIMTTest.sol +++ /dev/null @@ -1,47 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity ^0.8.4; - -import {LazyIMT, LazyIMTData} from "../LazyIMT.sol"; - -contract LazyIMTTest { - LazyIMTData public data; - uint256 _root; - - function init(uint8 depth) public { - LazyIMT.init(data, depth); - } - - function reset() public { - LazyIMT.reset(data); - } - - function insert(uint256 leaf) public { - LazyIMT.insert(data, leaf); - } - - function update(uint256 leaf, uint40 index) public { - LazyIMT.update(data, leaf, index); - } - - // for benchmarking the root cost - function benchmarkRoot() public { - _root = LazyIMT.root(data); - } - - function root() public view returns (uint256) { - return LazyIMT.root(data); - } - - function dynamicRoot(uint8 depth) public view returns (uint256) { - return LazyIMT.root(data, depth); - } - - function staticRoot(uint8 depth) public view returns (uint256) { - return LazyIMT.root(data, depth); - } - - function merkleProofElements(uint40 index, uint8 depth) public view returns (uint256[] memory) { - return LazyIMT.merkleProofElements(data, index, depth); - } -} diff --git a/packages/imt.sol/contracts/test/LeanIMTTest.sol b/packages/imt.sol/contracts/test/LeanIMTTest.sol deleted file mode 100644 index b39f8d1ca..000000000 --- a/packages/imt.sol/contracts/test/LeanIMTTest.sol +++ /dev/null @@ -1,37 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity ^0.8.4; - -import {LeanIMT, LeanIMTData} from "../LeanIMT.sol"; - -contract LeanIMTTest { - LeanIMTData public data; - - function insert(uint256 leaf) external { - LeanIMT.insert(data, leaf); - } - - function insertMany(uint256[] calldata leaves) external { - LeanIMT.insertMany(data, leaves); - } - - function update(uint256 oldLeaf, uint256 newLeaf, uint256[] calldata siblingNodes) external { - LeanIMT.update(data, oldLeaf, newLeaf, siblingNodes); - } - - function remove(uint256 leaf, uint256[] calldata siblingNodes) external { - LeanIMT.remove(data, leaf, siblingNodes); - } - - function has(uint256 leaf) external view returns (bool) { - return LeanIMT.has(data, leaf); - } - - function indexOf(uint256 leaf) external view returns (uint256) { - return LeanIMT.indexOf(data, leaf); - } - - function root() public view returns (uint256) { - return LeanIMT.root(data); - } -} diff --git a/packages/imt.sol/contracts/test/QuinaryIMTTest.sol b/packages/imt.sol/contracts/test/QuinaryIMTTest.sol deleted file mode 100644 index 6094c5e80..000000000 --- a/packages/imt.sol/contracts/test/QuinaryIMTTest.sol +++ /dev/null @@ -1,30 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity ^0.8.4; - -import {QuinaryIMT, QuinaryIMTData} from "../QuinaryIMT.sol"; - -contract QuinaryIMTTest { - QuinaryIMTData public data; - - function init(uint256 depth) external { - QuinaryIMT.init(data, depth, 0); - } - - function insert(uint256 leaf) external { - QuinaryIMT.insert(data, leaf); - } - - function update( - uint256 leaf, - uint256 newLeaf, - uint256[4][] calldata proofSiblings, - uint8[] calldata proofPathIndices - ) external { - QuinaryIMT.update(data, leaf, newLeaf, proofSiblings, proofPathIndices); - } - - function remove(uint256 leaf, uint256[4][] calldata proofSiblings, uint8[] calldata proofPathIndices) external { - QuinaryIMT.remove(data, leaf, proofSiblings, proofPathIndices); - } -} diff --git a/packages/imt.sol/hardhat.config.ts b/packages/imt.sol/hardhat.config.ts deleted file mode 100644 index d652e05b7..000000000 --- a/packages/imt.sol/hardhat.config.ts +++ /dev/null @@ -1,23 +0,0 @@ -import "@nomicfoundation/hardhat-toolbox" -import { HardhatUserConfig } from "hardhat/config" -import "./tasks/deploy-imt-test" - -const hardhatConfig: HardhatUserConfig = { - solidity: { - version: "0.8.23", - settings: { - optimizer: { - enabled: true - } - } - }, - gasReporter: { - currency: "USD", - enabled: process.env.REPORT_GAS === "true" - }, - typechain: { - target: "ethers-v6" - } -} - -export default hardhatConfig diff --git a/packages/imt.sol/package.json b/packages/imt.sol/package.json deleted file mode 100644 index 3571142d4..000000000 --- a/packages/imt.sol/package.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "name": "imt.sol", - "private": true, - "scripts": { - "start": "hardhat node", - "build": "hardhat compile", - "test": "hardhat test", - "test:report-gas": "REPORT_GAS=true hardhat test", - "test:coverage": "hardhat coverage", - "typechain": "hardhat typechain", - "lint": "solhint 'contracts/**/*.sol'" - }, - "devDependencies": { - "@nomicfoundation/hardhat-chai-matchers": "^2.0.3", - "@nomicfoundation/hardhat-ethers": "^3.0.0", - "@nomicfoundation/hardhat-network-helpers": "^1.0.0", - "@nomicfoundation/hardhat-toolbox": "^4.0.0", - "@nomicfoundation/hardhat-verify": "^2.0.0", - "@typechain/ethers-v6": "^0.5.0", - "@typechain/hardhat": "^9.0.0", - "@types/chai": "^4.2.0", - "@types/mocha": "^10.0.6", - "@types/node": "^20.10.7", - "@zk-kit/imt": "workspace:packages/imt", - "@zk-kit/lean-imt": "workspace:packages/lean-imt", - "chai": "^4.2.0", - "ethers": "^6.4.0", - "hardhat": "^2.19.4", - "hardhat-gas-reporter": "^1.0.8", - "poseidon-lite": "^0.2.0", - "prettier-plugin-solidity": "^1.3.1", - "solhint": "^3.3.6", - "solhint-plugin-prettier": "^0.1.0", - "solidity-coverage": "^0.8.0", - "ts-node": "^10.9.2", - "typechain": "^8.3.0", - "typescript": "^5.3.3" - }, - "dependencies": { - "poseidon-solidity": "0.0.5" - } -} diff --git a/packages/imt.sol/scripts/defaultZeroes.mjs b/packages/imt.sol/scripts/defaultZeroes.mjs deleted file mode 100644 index 5bb49dda1..000000000 --- a/packages/imt.sol/scripts/defaultZeroes.mjs +++ /dev/null @@ -1,31 +0,0 @@ -import { poseidon } from "circomlibjs" - -const zeroes = [0] - -for (let x = 1; x < 33; x += 1) { - zeroes[x] = poseidon([zeroes[x - 1], zeroes[x - 1]]) -} - -console.log(` - ${Array(33) - .fill(0) - .map((_, i) => `uint256 constant public Z_${i} = ${zeroes[i]};`) - .join("\n ")} - -/* - function defaultZeroes() public pure returns (uint256[32] memory) { - return [${Array(32) - .fill() - .map((_, i) => `Z_${i}`) - .join(",")}]; - } -*/ - - function defaultZero(uint256 index) public pure returns (uint256) { - ${Array(33) - .fill() - .map((_, i) => ` if (index == ${i}) return Z_${i};`) - .join("\n")} - revert('badindex'); - } -`) diff --git a/packages/imt.sol/tasks/deploy-imt-test.ts b/packages/imt.sol/tasks/deploy-imt-test.ts deleted file mode 100644 index d9dc6f7e9..000000000 --- a/packages/imt.sol/tasks/deploy-imt-test.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { task, types } from "hardhat/config" - -task("deploy:imt-test", "Deploy an IMT contract for testing a library") - .addParam("library", "The name of the library", undefined, types.string) - .addOptionalParam("logs", "Print the logs", true, types.boolean) - .addOptionalParam("arity", "The arity of the tree", 2, types.int) - .setAction(async ({ logs, library: libraryName, arity }, { ethers }): Promise => { - const PoseidonFactory = await ethers.getContractFactory(`PoseidonT${arity + 1}`) - - const poseidon = await PoseidonFactory.deploy() - const poseidonAddress = await poseidon.getAddress() - - if (logs) { - console.info(`PoseidonT${arity + 1} library has been deployed to: ${poseidonAddress}`) - } - - const LibraryFactory = await ethers.getContractFactory(libraryName, { - libraries: { - [`PoseidonT${arity + 1}`]: poseidonAddress - } - }) - - const library = await LibraryFactory.deploy() - const libraryAddress = await library.getAddress() - - if (logs) { - console.info(`${libraryName} library has been deployed to: ${libraryAddress}`) - } - - const ContractFactory = await ethers.getContractFactory(`${libraryName}Test`, { - libraries: { - [libraryName]: libraryAddress - } - }) - - const contract = await ContractFactory.deploy() - const contractAddress = await contract.getAddress() - - if (logs) { - console.info(`${libraryName}Test contract has been deployed to: ${contractAddress}`) - } - - return { library, contract } - }) diff --git a/packages/imt.sol/test/BinaryIMT.ts b/packages/imt.sol/test/BinaryIMT.ts deleted file mode 100644 index 2d8e6d449..000000000 --- a/packages/imt.sol/test/BinaryIMT.ts +++ /dev/null @@ -1,367 +0,0 @@ -import { IMT as JSBinaryIMT } from "@zk-kit/imt" -import { expect } from "chai" -import { run } from "hardhat" -import { poseidon2 } from "poseidon-lite" -import { BinaryIMT, BinaryIMTTest } from "../typechain-types" - -describe("BinaryIMT", () => { - const SNARK_SCALAR_FIELD = BigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617") - let binaryIMT: BinaryIMT - let binaryIMTTest: BinaryIMTTest - let jsBinaryIMT: JSBinaryIMT - - beforeEach(async () => { - const { library, contract } = await run("deploy:imt-test", { library: "BinaryIMT", logs: false }) - - binaryIMT = library - binaryIMTTest = contract - jsBinaryIMT = new JSBinaryIMT(poseidon2, 16, 0, 2) - }) - - describe("# init", () => { - it("Should not create a tree with a depth > 32", async () => { - const transaction = binaryIMTTest.init(33) - - await expect(transaction).to.be.revertedWithCustomError(binaryIMT, "DepthNotSupported") - }) - - it("Should create a tree", async () => { - await binaryIMTTest.init(jsBinaryIMT.depth) - - const { depth } = await binaryIMTTest.data() - - expect(depth).to.equal(jsBinaryIMT.depth) - }) - - it("Should create a tree with default zeroes", async () => { - await binaryIMTTest.initWithDefaultZeroes(jsBinaryIMT.depth) - - const { depth, useDefaultZeroes } = await binaryIMTTest.data() - - expect(depth).to.equal(jsBinaryIMT.depth) - expect(useDefaultZeroes).to.equal(true) - }) - }) - - describe("# insert", () => { - it("Should not insert a leaf if its value is > SNARK_SCALAR_FIELD", async () => { - const transaction = binaryIMTTest.insert(SNARK_SCALAR_FIELD) - - await expect(transaction).to.be.revertedWithCustomError(binaryIMT, "ValueGreaterThanSnarkScalarField") - }) - - it("Should insert a leaf in a tree", async () => { - await binaryIMTTest.init(jsBinaryIMT.depth) - - jsBinaryIMT.insert(1) - - await binaryIMTTest.insert(1) - - const { root } = await binaryIMTTest.data() - - expect(root).to.equal(jsBinaryIMT.root) - }) - - it("Should insert a leaf in a tree with default zeroes", async () => { - await binaryIMTTest.init(jsBinaryIMT.depth) - - jsBinaryIMT.insert(1) - - await binaryIMTTest.insert(1) - - const { root } = await binaryIMTTest.data() - - expect(root).to.equal(jsBinaryIMT.root) - }) - - it("Should insert 4 leaves in a tree", async () => { - await binaryIMTTest.init(jsBinaryIMT.depth) - - for (let i = 0; i < 4; i += 1) { - const leaf = i + 1 - - jsBinaryIMT.insert(leaf) - await binaryIMTTest.insert(leaf) - - const { root } = await binaryIMTTest.data() - - expect(root).to.equal(jsBinaryIMT.root) - } - }) - - it("Should insert 4 leaves in a default zeroes tree", async () => { - const jsBinaryIMT = new JSBinaryIMT(poseidon2, 32, 0) - - await binaryIMTTest.initWithDefaultZeroes(jsBinaryIMT.depth) - - for (let x = 0; x < 4; x += 1) { - const leaf = (x + 10) ** 2 - - jsBinaryIMT.insert(leaf) - await binaryIMTTest.insert(leaf) - - const { root } = await binaryIMTTest.data() - - expect(root).to.equal(jsBinaryIMT.root) - } - }) - - it("Should not insert a leaf if the tree is full", async () => { - await binaryIMTTest.init(1) - await binaryIMTTest.insert(1) - await binaryIMTTest.insert(2) - - const transaction = binaryIMTTest.insert(3) - - await expect(transaction).to.be.revertedWithCustomError(binaryIMT, "TreeIsFull") - }) - }) - - describe("# update", () => { - it("Should not update a leaf if the new value is the same as the old one", async () => { - await binaryIMTTest.init(jsBinaryIMT.depth) - await binaryIMTTest.insert(1) - - const transaction = binaryIMTTest.update(1, 1, [0, 1], [0, 1]) - - await expect(transaction).to.be.revertedWithCustomError(binaryIMT, "NewLeafCannotEqualOldLeaf") - }) - - it("Should not update a leaf if its new value is > SNARK_SCALAR_FIELD", async () => { - await binaryIMTTest.init(jsBinaryIMT.depth) - await binaryIMTTest.insert(1) - - const transaction = binaryIMTTest.update(1, SNARK_SCALAR_FIELD, [0, 1], [0, 1]) - - await expect(transaction).to.be.revertedWithCustomError(binaryIMT, "ValueGreaterThanSnarkScalarField") - }) - - it("Should not update a leaf if its original value is > SNARK_SCALAR_FIELD", async () => { - await binaryIMTTest.init(jsBinaryIMT.depth) - await binaryIMTTest.insert(1) - - const transaction = binaryIMTTest.update(SNARK_SCALAR_FIELD, 2, [0, 1], [0, 1]) - - await expect(transaction).to.be.revertedWithCustomError(binaryIMT, "ValueGreaterThanSnarkScalarField") - }) - - it("Should not update a leaf if the path indices are wrong", async () => { - await binaryIMTTest.init(jsBinaryIMT.depth) - await binaryIMTTest.insert(1) - - jsBinaryIMT.insert(1) - jsBinaryIMT.update(0, 2) - - const { pathIndices, siblings } = jsBinaryIMT.createProof(0) - - pathIndices[0] = 2 - - const transaction = binaryIMTTest.update( - 1, - 2, - siblings.map((s) => s[0]), - pathIndices - ) - - await expect(transaction).to.be.revertedWithCustomError(binaryIMT, "WrongMerkleProofPath") - }) - - it("Should not update a leaf if the old leaf is wrong", async () => { - await binaryIMTTest.init(jsBinaryIMT.depth) - await binaryIMTTest.insert(1) - - jsBinaryIMT.insert(1) - jsBinaryIMT.update(0, 2) - - const { pathIndices, siblings } = jsBinaryIMT.createProof(0) - - const transaction = binaryIMTTest.update( - 2, - 3, - siblings.map((s) => s[0]), - pathIndices - ) - - await expect(transaction).to.be.revertedWithCustomError(binaryIMT, "LeafDoesNotExist") - }) - - it("Should update a leaf", async () => { - await binaryIMTTest.init(jsBinaryIMT.depth) - await binaryIMTTest.insert(1) - - jsBinaryIMT.insert(1) - jsBinaryIMT.update(0, 2) - - const { pathIndices, siblings } = jsBinaryIMT.createProof(0) - - await binaryIMTTest.update( - 1, - 2, - siblings.map((s) => s[0]), - pathIndices - ) - - const { root } = await binaryIMTTest.data() - - expect(root).to.equal(jsBinaryIMT.root) - }) - - it("Should not update a leaf that hasn't been inserted yet", async () => { - binaryIMTTest.init(jsBinaryIMT.depth) - - for (let i = 0; i < 4; i += 1) { - const leaf = i + 1 - - jsBinaryIMT.insert(leaf) - await binaryIMTTest.insert(leaf) - } - - // We're going to try to update leaf 7, despite there only being 4 leaves in the tree. - const leaf = 42069 - - // Note that we can insert zeros into the js library tree and the root won't change! - // that's because we use the zeros optimization to calculate the roots efficiently. - // technically speaking, there isn't an "empty" tree, there is only a tree that is - // entirely full of the zero value at every index. Therefore inserting the zero value - // at any point into an incremental merkle tree doesn't change it's root, because - // that is already the data the root was calculated from previously. In principle, - // we can update any leaf that hasn't been inserted yet using this method. - const rootBeforeZeros = jsBinaryIMT.root - - jsBinaryIMT.insert(0) - jsBinaryIMT.insert(0) - jsBinaryIMT.insert(0) - - // The root doesn't change because the tree started full with 0s! - expect(jsBinaryIMT.root).to.be.equal(rootBeforeZeros) - - // Now we can make a merkle proof of zero being included at the uninitialized index. - const { pathIndices, siblings } = jsBinaryIMT.createProof(6) - - const transaction = binaryIMTTest.update( - 0, - leaf, - siblings.map((s) => s[0]), - pathIndices - ) - - await expect(transaction).to.be.revertedWithCustomError(binaryIMT, "LeafIndexOutOfRange") - }) - }) - - describe("# remove", () => { - it("Should not remove a leaf if its value is > SNARK_SCALAR_FIELD", async () => { - const transaction = binaryIMTTest.remove(SNARK_SCALAR_FIELD, [0, 1], [0, 1]) - - await expect(transaction).to.be.revertedWithCustomError(binaryIMT, "ValueGreaterThanSnarkScalarField") - }) - - it("Should not remove a leaf that does not exist", async () => { - await binaryIMTTest.init(jsBinaryIMT.depth) - await binaryIMTTest.insert(1) - - jsBinaryIMT.insert(1) - jsBinaryIMT.delete(0) - - const { siblings, pathIndices } = jsBinaryIMT.createProof(0) - - const transaction = binaryIMTTest.remove( - 2, - siblings.map((s) => s[0]), - pathIndices - ) - - await expect(transaction).to.be.revertedWithCustomError(binaryIMT, "LeafDoesNotExist") - }) - - it("Should remove a leaf", async () => { - await binaryIMTTest.init(jsBinaryIMT.depth) - await binaryIMTTest.insert(1) - - jsBinaryIMT.insert(1) - jsBinaryIMT.delete(0) - - const { pathIndices, siblings } = jsBinaryIMT.createProof(0) - - await binaryIMTTest.remove( - 1, - siblings.map((s) => s[0]), - pathIndices - ) - - const { root } = await binaryIMTTest.data() - - expect(root).to.equal(jsBinaryIMT.root) - }) - - it("Should remove a leaf in a tree with default zeroes", async () => { - await binaryIMTTest.initWithDefaultZeroes(jsBinaryIMT.depth) - await binaryIMTTest.insert(1) - - jsBinaryIMT.insert(1) - jsBinaryIMT.delete(0) - - const { siblings, pathIndices } = jsBinaryIMT.createProof(0) - - await binaryIMTTest.remove( - 1, - siblings.map((s) => s[0]), - pathIndices - ) - - const { root } = await binaryIMTTest.data() - - expect(root).to.equal(jsBinaryIMT.root) - }) - - it("Should insert a leaf in a tree after a removal", async () => { - await binaryIMTTest.init(jsBinaryIMT.depth) - await binaryIMTTest.insert(1) - - jsBinaryIMT.insert(1) - jsBinaryIMT.delete(0) - - const { pathIndices, siblings } = jsBinaryIMT.createProof(0) - - await binaryIMTTest.remove( - 1, - siblings.map((s) => s[0]), - pathIndices - ) - - jsBinaryIMT.insert(2) - await binaryIMTTest.insert(2) - - const { root } = await binaryIMTTest.data() - - expect(root).to.equal(jsBinaryIMT.root) - }) - - it("Should insert 4 leaves and remove them all", async () => { - await binaryIMTTest.init(jsBinaryIMT.depth) - - for (let i = 0; i < 4; i += 1) { - const leaf = i + 1 - - jsBinaryIMT.insert(leaf) - await binaryIMTTest.insert(leaf) - } - - for (let i = 0; i < 4; i += 1) { - jsBinaryIMT.delete(i) - - const { siblings, pathIndices } = jsBinaryIMT.createProof(i) - - await binaryIMTTest.remove( - i + 1, - siblings.map((s) => s[0]), - pathIndices - ) - } - - const { root } = await binaryIMTTest.data() - - expect(root).to.equal(jsBinaryIMT.root) - }) - }) -}) diff --git a/packages/imt.sol/test/LazyIMT.ts b/packages/imt.sol/test/LazyIMT.ts deleted file mode 100644 index d34653a8a..000000000 --- a/packages/imt.sol/test/LazyIMT.ts +++ /dev/null @@ -1,373 +0,0 @@ -import { expect } from "chai" -import { run, network } from "hardhat" -import { poseidon2 } from "poseidon-lite" -import { IMT } from "@zk-kit/imt" -import type { BigNumber } from "ethers" -import { LazyIMT, LazyIMTTest } from "../typechain-types" - -const random = () => poseidon2([Math.floor(Math.random() * 2 ** 40), 0]) - -describe("LazyIMT", () => { - const SNARK_SCALAR_FIELD = BigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617") - let lazyIMTTest: LazyIMTTest - let lazyIMT: LazyIMT - - beforeEach(async () => { - const { library, contract } = await run("deploy:imt-test", { library: "LazyIMT", logs: false }) - - lazyIMTTest = contract - lazyIMT = library - }) - - describe("# init", () => { - it("Should check zero values", async () => { - expect("0").to.equal((await lazyIMT.defaultZero(0)).toString()) - - let hash = poseidon2([BigInt(0), BigInt(0)]) - - for (let x = 1; x < 33; x += 1) { - const v = await lazyIMT.defaultZero(x) - expect(v.toString()).to.equal(hash.toString()) - hash = poseidon2([hash, hash]) - } - - await expect(lazyIMT.defaultZero(34)).to.be.revertedWith("LazyIMT: defaultZero bad index") - }) - - for (let x = 0; x < 32; x += 1) { - it(`Should initialize tree with depth ${x}`, async () => { - { - const treeData = await lazyIMTTest.data() - - expect(treeData.maxIndex).to.equal(0) - expect(treeData.numberOfLeaves).to.equal(0) - } - - await lazyIMTTest.init(x) - - { - const treeData = await lazyIMTTest.data() - - expect(treeData.maxIndex).to.equal(2 ** x - 1) - expect(treeData.numberOfLeaves).to.equal(0) - } - }) - } - - it("Should fail to init large tree", async () => { - const treeData = await lazyIMTTest.data() - - expect(treeData.maxIndex).to.equal(0) - expect(treeData.numberOfLeaves).to.equal(0) - - await expect(lazyIMTTest.init(33)).to.be.revertedWith("LazyIMT: Tree too large") - }) - }) - - describe("# insert", () => { - for (let depth = 1; depth < 3; depth += 1) { - it(`Should insert leaves in tree with depth ${depth}`, async () => { - await lazyIMTTest.init(10) - - // empty root should be H(0, 0) - expect(await lazyIMTTest.root()).to.equal(poseidon2([BigInt(0), BigInt(0)])) - - const elements = [] - - for (let x = 0; x < 2 ** depth - 1; x += 1) { - const e = random() - - elements.push(e) - - // construct the tree - { - const targetDepth = Math.max(1, Math.ceil(Math.log2(elements.length))) - const merkleTree = new IMT(poseidon2, targetDepth, BigInt(0)) - for (const _e of elements) { - merkleTree.insert(_e) - } - await lazyIMTTest.insert(e) - await lazyIMTTest.benchmarkRoot().then((t) => t.wait()) - { - const root = await lazyIMTTest.root() - expect(root.toString()).to.equal(merkleTree.root.toString()) - } - { - const root = await lazyIMTTest.dynamicRoot(targetDepth) - expect(root.toString()).to.equal(merkleTree.root.toString()) - } - } - - const treeData = await lazyIMTTest.data() - - expect(treeData.numberOfLeaves).to.equal(elements.length) - - for (let y = depth; y < 12; y += 1) { - const merkleTree = new IMT(poseidon2, y, BigInt(0)) - for (const _e of elements) { - merkleTree.insert(_e) - } - const root = await lazyIMTTest.staticRoot(y) - expect(root.toString()).to.equal(merkleTree.root.toString()) - } - } - }) - } - - it("Should insert multiple leaves", async () => { - const depth = 8 - - const merkleTree = new IMT(poseidon2, depth, BigInt(0)) - await lazyIMTTest.init(depth) - - for (let x = 0; x < 130; x += 1) { - const e = random() - await lazyIMTTest.insert(e) - merkleTree.insert(e) - } - - const root = await lazyIMTTest.root() - expect(root.toString()).to.equal(merkleTree.root.toString()) - }) - - it("Should fail to insert too many leaves", async () => { - const depth = 3 - - await lazyIMTTest.init(depth) - - for (let x = 0; x < 2 ** depth - 1; x += 1) { - await lazyIMTTest.insert(random()) - } - - await expect(lazyIMTTest.insert(random())).to.be.revertedWith("LazyIMT: tree is full") - }) - - it("Should fail to insert leaf outside of field", async () => { - const depth = 3 - - await lazyIMTTest.init(depth) - - await expect(lazyIMTTest.insert(SNARK_SCALAR_FIELD)).to.be.revertedWith( - "LazyIMT: leaf must be < SNARK_SCALAR_FIELD" - ) - }) - }) - - describe("# update", () => { - for (let depth = 1; depth < 3; depth += 1) { - it(`Should update leaves in tree with depth ${depth}`, async () => { - await lazyIMTTest.init(depth) - - const elements = [] - - // runs in ~N^N - for (let x = 0; x < 2 ** depth - 1; x += 1) { - const e = random() - - elements.push(e) - - // construct the tree - const targetDepth = Math.max(1, Math.ceil(Math.log2(elements.length))) - - { - const merkleTree = new IMT(poseidon2, targetDepth, BigInt(0)) - - for (const _e of elements) { - merkleTree.insert(_e) - } - - await lazyIMTTest.insert(e) - - await lazyIMTTest.benchmarkRoot().then((t) => t.wait()) - - const root = await lazyIMTTest.root() - - expect(root.toString()).to.equal(merkleTree.root.toString()) - - const treeData = await lazyIMTTest.data() - - expect(treeData.numberOfLeaves).to.equal(elements.length) - } - - for (let y = 0; y < x; y += 1) { - const newE = random() - - elements.splice(y, 1, newE) - - await lazyIMTTest.update(newE, y) - - const merkleTree = new IMT(poseidon2, targetDepth, BigInt(0)) - - for (const _e of elements) { - merkleTree.insert(_e) - } - - const root = await lazyIMTTest.root() - - expect(root.toString()).to.equal(merkleTree.root.toString()) - - const treeData = await lazyIMTTest.data() - - expect(treeData.numberOfLeaves).to.equal(elements.length) - } - } - }) - } - - it("Should fail to update invalid leaf index", async () => { - const depth = 4 - - await lazyIMTTest.init(depth) - - for (let x = 0; x < 10; x += 1) { - await lazyIMTTest.insert(random()) - } - - await expect(lazyIMTTest.update(random(), 10)).to.be.revertedWith("LazyIMT: leaf must exist") - }) - - it("Should fail to update with invalid leaf value", async () => { - const depth = 3 - - await lazyIMTTest.init(depth) - - for (let x = 0; x < 3; x += 1) { - await lazyIMTTest.insert(random()) - } - - await expect(lazyIMTTest.update(SNARK_SCALAR_FIELD, 0)).to.be.revertedWith( - "LazyIMT: leaf must be < SNARK_SCALAR_FIELD" - ) - }) - }) - - describe("# reset", () => { - it("Should reset and reuse tree", async () => { - const depth = 3 - - await lazyIMTTest.init(10) - - { - const data = await lazyIMTTest.data() - - expect(data.numberOfLeaves).to.equal(0) - } - - for (let i = 0; i < 3; i += 1) { - const elements = [] - - for (let x = 0; x < 2 ** depth - 1; x += 1) { - const e = random() - - elements.push(e) - - // construct the tree - const targetDepth = Math.max(1, Math.ceil(Math.log2(elements.length))) - const merkleTree = new IMT(poseidon2, targetDepth, BigInt(0)) - - for (const _e of elements) { - merkleTree.insert(_e) - } - - await lazyIMTTest.insert(e) - - const root = await lazyIMTTest.root() - - expect(root.toString()).to.equal(merkleTree.root.toString()) - - const treeData = await lazyIMTTest.data() - - expect(treeData.numberOfLeaves).to.equal(elements.length) - } - - await lazyIMTTest.reset() - - { - const data = await lazyIMTTest.data() - expect(data.numberOfLeaves).to.equal(0) - } - } - }) - }) - - describe("# merkleProof", () => { - // Given a merkle proof (elements and indices) and a leaf, calculates the root - function calculateRoot(leafIndex: number, leaf: BigNumber, proofElements: BigNumber[]) { - let hash = leaf - const proofIndices = [] - for (let x = 0; x < proofElements.length; x += 1) { - proofIndices.push((leafIndex >> x) & 1) - } - for (let i = 0; i < proofElements.length; i += 1) { - const proofElement = proofElements[i] - const proofIndex = proofIndices[i] - if (proofIndex) { - hash = poseidon2([proofElement.toString(), hash.toString()]) - } else { - hash = poseidon2([hash.toString(), proofElement.toString()]) - } - } - return hash - } - - it("Should produce valid Merke proofs for different trees", async () => { - // Test different depths (key) and leafs (values) - const tests: { [key: number]: number[] } = { - 1: [1], - 2: [1, 2], - 5: [6, 7, 8, 15, 16], - 7: [7, 127], - 20: [9, 14, 15, 16, 18, 26, 27, 28, 40, 128, 129] - } - - // For each depth - // eslint-disable-next-line guard-for-in - for (const depth in tests) { - // For each amount of leafs - for (const numLeaf of tests[depth]) { - // Freeze the state - const snapshoot = await network.provider.request({ method: "evm_snapshot", params: [] }) - - // Create the tree - await lazyIMTTest.init(depth) - const elements = [] - for (let x = 0; x < numLeaf; x += 1) { - const e = random() - elements.push(e) - await lazyIMTTest.insert(e) - } - - // Get proofs for every leafs and verify against the root - for (let leafIndex = 0; leafIndex < numLeaf; leafIndex += 1) { - const proofElements = await lazyIMTTest.merkleProofElements(leafIndex, depth) - - // Calculate the root we arrive at with the proof we got - const calculatedRoot = calculateRoot(leafIndex, elements[leafIndex], proofElements) - - // Get the root from the contract - const staticRoot = await lazyIMTTest.staticRoot(depth) - - // If they match, proof is valid - await expect(calculatedRoot).to.be.equal(staticRoot) - } - - // Done with test, revert the tree state - await network.provider.request({ method: "evm_revert", params: [snapshoot] }) - } - } - }).timeout(8 * 60 * 1000) - }) - - it("Should fail to generate out of range static root", async () => { - await lazyIMTTest.init(10) - - const elements = [] - for (let x = 0; x < 20; x += 1) { - const e = random() - elements.push(e) - await lazyIMTTest.insert(e) - } - await expect(lazyIMTTest.staticRoot(4)).to.be.revertedWith("LazyIMT: ambiguous depth") - await expect(lazyIMTTest.staticRoot(33)).to.be.revertedWith("LazyIMT: depth must be <= MAX_DEPTH") - }) -}) diff --git a/packages/imt.sol/test/LeanIMT.ts b/packages/imt.sol/test/LeanIMT.ts deleted file mode 100644 index 315bd5ccb..000000000 --- a/packages/imt.sol/test/LeanIMT.ts +++ /dev/null @@ -1,380 +0,0 @@ -import { LeanIMT as JSLeanIMT } from "@zk-kit/lean-imt" -import { expect } from "chai" -import { run } from "hardhat" -import { poseidon2 } from "poseidon-lite" -import { LeanIMT, LeanIMTTest } from "../typechain-types" - -describe("LeanIMT", () => { - const SNARK_SCALAR_FIELD = BigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617") - let leanIMTTest: LeanIMTTest - let leanIMT: LeanIMT - let jsLeanIMT: JSLeanIMT - - beforeEach(async () => { - const { library, contract } = await run("deploy:imt-test", { library: "LeanIMT", logs: false }) - - leanIMTTest = contract - leanIMT = library - jsLeanIMT = new JSLeanIMT((a, b) => poseidon2([a, b])) - }) - - describe("# insert", () => { - it("Should not insert a leaf if its value is >= SNARK_SCALAR_FIELD", async () => { - const transaction = leanIMTTest.insert(SNARK_SCALAR_FIELD) - - await expect(transaction).to.be.revertedWithCustomError(leanIMT, "LeafGreaterThanSnarkScalarField") - }) - - it("Should not insert a leaf if it is 0", async () => { - const leaf = 0 - - const transaction = leanIMTTest.insert(leaf) - - await expect(transaction).to.be.revertedWithCustomError(leanIMT, "LeafCannotBeZero") - }) - - it("Should insert a leaf", async () => { - jsLeanIMT.insert(BigInt(1)) - - await leanIMTTest.insert(1) - - const root = await leanIMTTest.root() - - expect(root).to.equal(jsLeanIMT.root) - }) - - it("Should not insert a leaf if it was already inserted before", async () => { - await leanIMTTest.insert(1) - - const transaction = leanIMTTest.insert(1) - - await expect(transaction).to.be.revertedWithCustomError(leanIMT, "LeafAlreadyExists") - }) - - it("Should insert 10 leaves", async () => { - for (let i = 0; i < 10; i += 1) { - jsLeanIMT.insert(BigInt(i + 1)) - - await leanIMTTest.insert(i + 1) - - const root = await leanIMTTest.root() - - expect(root).to.equal(jsLeanIMT.root) - } - }) - }) - - describe("# insertMany", () => { - it("Should not insert a leaf if its value is >= SNARK_SCALAR_FIELD", async () => { - const transaction = leanIMTTest.insertMany([SNARK_SCALAR_FIELD]) - - await expect(transaction).to.be.revertedWithCustomError(leanIMT, "LeafGreaterThanSnarkScalarField") - }) - - it("Should not insert a leaf if it is 0", async () => { - const leaf = 0 - - const transaction = leanIMTTest.insertMany([leaf]) - - await expect(transaction).to.be.revertedWithCustomError(leanIMT, "LeafCannotBeZero") - }) - it("Should not insert a leaf if it was already inserted before", async () => { - await leanIMTTest.insert(1) - - const transaction = leanIMTTest.insertMany([1]) - - await expect(transaction).to.be.revertedWithCustomError(leanIMT, "LeafAlreadyExists") - }) - it("Should insert a leaf", async () => { - jsLeanIMT.insert(BigInt(1)) - - await leanIMTTest.insertMany([1]) - - const root = await leanIMTTest.root() - - expect(root).to.equal(jsLeanIMT.root) - }) - it("Should insert 10 leaves", async () => { - const elems: bigint[] = [] - for (let i = 0; i < 10; i += 1) { - elems.push(BigInt(i + 1)) - } - - jsLeanIMT.insertMany(elems) - await leanIMTTest.insertMany(elems) - - const root = await leanIMTTest.root() - expect(root).to.equal(jsLeanIMT.root) - }) - it("Should insert many leaves when the tree is not empty", async () => { - jsLeanIMT.insert(BigInt(1)) - - await leanIMTTest.insert(BigInt(1)) - - const elems: bigint[] = [] - for (let i = 1; i < 10; i += 1) { - elems.push(BigInt(i + 1)) - } - - jsLeanIMT.insertMany(elems) - await leanIMTTest.insertMany(elems) - - const root = await leanIMTTest.root() - expect(root).to.equal(jsLeanIMT.root) - }) - }) - - describe("# update", () => { - it("Should not update a leaf if the leaf does not exist", async () => { - const transaction = leanIMTTest.update(2, 1, [1, 2, 3, 4]) - - await expect(transaction).to.be.revertedWithCustomError(leanIMT, "LeafDoesNotExist") - }) - - it("Should not update a leaf if its value is >= SNARK_SCALAR_FIELD", async () => { - const transaction = leanIMTTest.update(2, SNARK_SCALAR_FIELD, [1, 2, 3, 4]) - - await expect(transaction).to.be.revertedWithCustomError(leanIMT, "LeafGreaterThanSnarkScalarField") - }) - - it("Should update a leaf if that's the only leaf in the tree", async () => { - await leanIMTTest.insert(1) - - jsLeanIMT.insert(BigInt(1)) - jsLeanIMT.update(0, BigInt(2)) - - const { siblings } = jsLeanIMT.generateProof(0) - - await leanIMTTest.update(1, 2, siblings) - - const root = await leanIMTTest.root() - - expect(root).to.equal(jsLeanIMT.root) - }) - - it("Should update a leaf if there's more than 1 leaf in the tree", async () => { - await leanIMTTest.insert(1) - await leanIMTTest.insert(2) - - jsLeanIMT.insertMany([BigInt(1), BigInt(2)]) - jsLeanIMT.update(0, BigInt(3)) - - const { siblings } = jsLeanIMT.generateProof(0) - - await leanIMTTest.update(1, 3, siblings) - - const root = await leanIMTTest.root() - - expect(root).to.equal(jsLeanIMT.root) - }) - - it("Should not update a leaf if its index is even and the value of at least one sibling node is >= SNARK_SCALAR_FIELD", async () => { - await leanIMTTest.insert(1) - await leanIMTTest.insert(2) - - jsLeanIMT.insertMany([BigInt(1), BigInt(2)]) - jsLeanIMT.update(0, BigInt(3)) - - const { siblings } = jsLeanIMT.generateProof(0) - - siblings[0] = SNARK_SCALAR_FIELD - - const transaction = leanIMTTest.update(1, 3, siblings) - - await expect(transaction).to.be.revertedWithCustomError(leanIMT, "LeafGreaterThanSnarkScalarField") - }) - - it("Should not update a leaf if its index is odd and the value of at least one sibling node is >= SNARK_SCALAR_FIELD", async () => { - await leanIMTTest.insert(1) - await leanIMTTest.insert(2) - - jsLeanIMT.insertMany([BigInt(1), BigInt(2)]) - jsLeanIMT.update(1, BigInt(3)) - - const { siblings } = jsLeanIMT.generateProof(1) - - siblings[0] = SNARK_SCALAR_FIELD - - const transaction = leanIMTTest.update(2, 3, siblings) - - await expect(transaction).to.be.revertedWithCustomError(leanIMT, "LeafGreaterThanSnarkScalarField") - }) - - it("Should not update a leaf if the siblings are wrong", async () => { - await leanIMTTest.insert(1) - await leanIMTTest.insert(2) - - jsLeanIMT.insertMany([BigInt(1), BigInt(2)]) - jsLeanIMT.update(0, BigInt(3)) - - const { siblings } = jsLeanIMT.generateProof(0) - - siblings[0] = BigInt(3) - - const transaction = leanIMTTest.update(1, 3, siblings) - - await expect(transaction).to.be.revertedWithCustomError(leanIMT, "WrongSiblingNodes") - }) - - it("Should update 6 leaves", async () => { - for (let i = 0; i < 6; i += 1) { - jsLeanIMT.insert(BigInt(i + 1)) - - await leanIMTTest.insert(i + 1) - } - - for (let i = 0; i < 6; i += 1) { - jsLeanIMT.update(i, BigInt(i + 7)) - - const { siblings } = jsLeanIMT.generateProof(i) - - await leanIMTTest.update(i + 1, i + 7, siblings) - - const root = await leanIMTTest.root() - - expect(root).to.equal(jsLeanIMT.root) - } - }) - - it("Should not update a leaf that was removed", async () => { - await leanIMTTest.insertMany([1, 2]) - jsLeanIMT.insertMany([BigInt(1), BigInt(2)]) - - jsLeanIMT.update(1, BigInt(0)) - - const { siblings } = jsLeanIMT.generateProof(1) - - await leanIMTTest.remove(2, siblings) - - jsLeanIMT.update(1, BigInt(3)) - - const { siblings: newSiblings } = jsLeanIMT.generateProof(1) - - const transaction = leanIMTTest.update(0, 3, newSiblings) - - await expect(transaction).to.be.revertedWithCustomError(leanIMT, "LeafDoesNotExist") - }) - it("Should not update a leaf if the new value already exists", async () => { - await leanIMTTest.insert(1) - await leanIMTTest.insert(2) - - jsLeanIMT.insertMany([BigInt(1), BigInt(2)]) - jsLeanIMT.update(0, BigInt(2)) - - const { siblings } = jsLeanIMT.generateProof(0) - - const transaction = leanIMTTest.update(1, 2, siblings) - - await expect(transaction).to.be.revertedWithCustomError(leanIMT, "LeafAlreadyExists") - }) - }) - - describe("# remove", () => { - it("Should remove a leaf", async () => { - await leanIMTTest.insert(1) - await leanIMTTest.insert(2) - await leanIMTTest.insert(3) - - jsLeanIMT.insertMany([BigInt(1), BigInt(2), BigInt(3)]) - jsLeanIMT.update(2, BigInt(0)) - - const { siblings } = jsLeanIMT.generateProof(2) - - await leanIMTTest.remove(3, siblings) - - const root = await leanIMTTest.root() - - expect(root).to.equal(jsLeanIMT.root) - }) - - it("Should remove 10 leaf", async () => { - for (let i = 0; i < 10; i += 1) { - jsLeanIMT.insert(BigInt(i + 1)) - - await leanIMTTest.insert(i + 1) - } - - for (let i = 0; i < 10; i += 1) { - jsLeanIMT.update(i, BigInt(0)) - - const { siblings } = jsLeanIMT.generateProof(i) - - await leanIMTTest.remove(i + 1, siblings) - - const root = await leanIMTTest.root() - - expect(root).to.equal(jsLeanIMT.root) - } - }) - }) - - describe("# has", () => { - it("Should return true because the node is in the tree", async () => { - await leanIMTTest.insert(1) - - const hasLeaf = await leanIMTTest.has(1) - - expect(hasLeaf).to.equal(true) - }) - - it("Should return false because the node is not the tree", async () => { - const hasLeaf = await leanIMTTest.has(2) - - expect(hasLeaf).to.equal(false) - }) - - it("Should return false if the leaf is 0", async () => { - await leanIMTTest.insertMany([1, 2]) - jsLeanIMT.insertMany([BigInt(1), BigInt(2)]) - - jsLeanIMT.update(1, BigInt(0)) - - const { siblings } = jsLeanIMT.generateProof(1) - - await leanIMTTest.remove(2, siblings) - - const hasLeaf = await leanIMTTest.has(0) - - expect(hasLeaf).to.equal(false) - }) - }) - describe("# indexOf", () => { - it("Should return the index of a leaf", async () => { - await leanIMTTest.insert(1) - - const index = await leanIMTTest.indexOf(1) - - expect(index).to.equal(0) - }) - - it("Should return the indices of the leaves", async () => { - await leanIMTTest.insertMany([1, 2]) - - const index1 = await leanIMTTest.indexOf(1) - const index2 = await leanIMTTest.indexOf(2) - - expect(index1).to.equal(0) - expect(index2).to.equal(1) - }) - - it("Should throw a custom error if the leaf does not exist", async () => { - await leanIMTTest.insertMany([1, 2]) - - const transaction = leanIMTTest.indexOf(3) - - await expect(transaction).to.be.revertedWithCustomError(leanIMT, "LeafDoesNotExist") - }) - }) - - describe("# root", () => { - it("Should return the tree root", async () => { - jsLeanIMT.insert(BigInt(1)) - - await leanIMTTest.insert(1) - - const root = await leanIMTTest.root() - - expect(root).to.equal(jsLeanIMT.root) - }) - }) -}) diff --git a/packages/imt.sol/test/QuinaryIMT.ts b/packages/imt.sol/test/QuinaryIMT.ts deleted file mode 100644 index 674a6ba08..000000000 --- a/packages/imt.sol/test/QuinaryIMT.ts +++ /dev/null @@ -1,275 +0,0 @@ -import { IMT as JSQuinaryIMT } from "@zk-kit/imt" -import { expect } from "chai" -import { run } from "hardhat" -import { poseidon5 } from "poseidon-lite" -import { QuinaryIMT, QuinaryIMTTest } from "../typechain-types" - -describe("QuinaryIMT", () => { - const SNARK_SCALAR_FIELD = BigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617") - let quinaryIMT: QuinaryIMT - let quinaryIMTTest: QuinaryIMTTest - let jsQuinaryIMT: JSQuinaryIMT - - beforeEach(async () => { - const { library, contract } = await run("deploy:imt-test", { library: "QuinaryIMT", arity: 5, logs: false }) - - quinaryIMT = library - quinaryIMTTest = contract - jsQuinaryIMT = new JSQuinaryIMT(poseidon5, 16, 0, 5) - }) - - describe("# init", () => { - it("Should not create a tree with a depth > 32", async () => { - const transaction = quinaryIMTTest.init(33) - - await expect(transaction).to.be.revertedWithCustomError(quinaryIMT, "DepthNotSupported") - }) - - it("Should create a tree", async () => { - await quinaryIMTTest.init(jsQuinaryIMT.depth) - - const { depth } = await quinaryIMTTest.data() - - expect(depth).to.equal(jsQuinaryIMT.depth) - }) - }) - - describe("# insert", () => { - it("Should not insert a leaf if its value is > SNARK_SCALAR_FIELD", async () => { - const transaction = quinaryIMTTest.insert(SNARK_SCALAR_FIELD) - - await expect(transaction).to.be.revertedWithCustomError(quinaryIMT, "ValueGreaterThanSnarkScalarField") - }) - - it("Should insert a leaf in a tree", async () => { - await quinaryIMTTest.init(jsQuinaryIMT.depth) - - jsQuinaryIMT.insert(1) - - await quinaryIMTTest.insert(1) - - const { root } = await quinaryIMTTest.data() - - expect(root).to.equal(jsQuinaryIMT.root) - }) - - it("Should insert 6 leaves in a tree", async () => { - await quinaryIMTTest.init(jsQuinaryIMT.depth) - - for (let i = 0; i < 6; i += 1) { - const leaf = i + 1 - - jsQuinaryIMT.insert(leaf) - await quinaryIMTTest.insert(leaf) - - const { root } = await quinaryIMTTest.data() - - expect(root).to.equal(jsQuinaryIMT.root) - } - }) - - it("Should not insert a leaf if the tree is full", async () => { - await quinaryIMTTest.init(1) - - for (let i = 0; i < 5; i += 1) { - await quinaryIMTTest.insert(i + 1) - } - - const transaction = quinaryIMTTest.insert(3) - - await expect(transaction).to.be.revertedWithCustomError(quinaryIMT, "TreeIsFull") - }) - }) - - describe("# update", () => { - it("Should not update a leaf if the new value is the same as the old one", async () => { - await quinaryIMTTest.init(jsQuinaryIMT.depth) - await quinaryIMTTest.insert(1) - - const transaction = quinaryIMTTest.update(1, 1, [[0, 1, 2, 3]], [0]) - - await expect(transaction).to.be.revertedWithCustomError(quinaryIMT, "NewLeafCannotEqualOldLeaf") - }) - - it("Should not update a leaf if its new value is > SNARK_SCALAR_FIELD", async () => { - await quinaryIMTTest.init(jsQuinaryIMT.depth) - await quinaryIMTTest.insert(1) - - const transaction = quinaryIMTTest.update(1, SNARK_SCALAR_FIELD, [[0, 1, 2, 3]], [0]) - - await expect(transaction).to.be.revertedWithCustomError(quinaryIMT, "ValueGreaterThanSnarkScalarField") - }) - - it("Should not update a leaf if its original value is > SNARK_SCALAR_FIELD", async () => { - await quinaryIMTTest.init(jsQuinaryIMT.depth) - await quinaryIMTTest.insert(1) - - const transaction = quinaryIMTTest.update(SNARK_SCALAR_FIELD, 2, [[0, 1, 2, 3]], [0]) - - await expect(transaction).to.be.revertedWithCustomError(quinaryIMT, "ValueGreaterThanSnarkScalarField") - }) - - it("Should not update a leaf if the path indices are wrong", async () => { - await quinaryIMTTest.init(jsQuinaryIMT.depth) - await quinaryIMTTest.insert(1) - - jsQuinaryIMT.insert(1) - jsQuinaryIMT.update(0, 2) - - const { pathIndices, siblings } = jsQuinaryIMT.createProof(0) - - pathIndices[0] = 5 - - const transaction = quinaryIMTTest.update(1, 2, siblings, pathIndices) - - await expect(transaction).to.be.revertedWithCustomError(quinaryIMT, "WrongMerkleProofPath") - }) - - it("Should not update a leaf if the old leaf is wrong", async () => { - await quinaryIMTTest.init(jsQuinaryIMT.depth) - await quinaryIMTTest.insert(1) - - jsQuinaryIMT.insert(1) - jsQuinaryIMT.update(0, 2) - - const { pathIndices, siblings } = jsQuinaryIMT.createProof(0) - - const transaction = quinaryIMTTest.update(2, 3, siblings, pathIndices) - - await expect(transaction).to.be.revertedWithCustomError(quinaryIMT, "LeafDoesNotExist") - }) - - it("Should update a leaf", async () => { - await quinaryIMTTest.init(jsQuinaryIMT.depth) - await quinaryIMTTest.insert(1) - - jsQuinaryIMT.insert(1) - jsQuinaryIMT.update(0, 2) - - const { pathIndices, siblings } = jsQuinaryIMT.createProof(0) - - await quinaryIMTTest.update(1, 2, siblings, pathIndices) - - const { root } = await quinaryIMTTest.data() - - expect(root).to.equal(jsQuinaryIMT.root) - }) - - it("Should not update a leaf that hasn't been inserted yet", async () => { - quinaryIMTTest.init(jsQuinaryIMT.depth) - - for (let i = 0; i < 4; i += 1) { - const leaf = i + 1 - - jsQuinaryIMT.insert(leaf) - await quinaryIMTTest.insert(leaf) - } - - // We're going to try to update leaf 7, despite there only being 4 leaves in the tree. - const leaf = 42069 - - // Note that we can insert zeros into the js library tree and the root won't change! - // that's because we use the zeros optimization to calculate the roots efficiently. - // technically speaking, there isn't an "empty" tree, there is only a tree that is - // entirely full of the zero value at every index. Therefore inserting the zero value - // at any point into an incremental merkle tree doesn't change it's root, because - // that is already the data the root was calculated from previously. In principle, - // we can update any leaf that hasn't been inserted yet using this method. - const rootBeforeZeros = jsQuinaryIMT.root - - jsQuinaryIMT.insert(0) - jsQuinaryIMT.insert(0) - jsQuinaryIMT.insert(0) - - // The root doesn't change because the tree started full with 0s! - expect(jsQuinaryIMT.root).to.be.equal(rootBeforeZeros) - - // Now we can make a merkle proof of zero being included at the uninitialized index. - const { pathIndices, siblings } = jsQuinaryIMT.createProof(6) - - const transaction = quinaryIMTTest.update(0, leaf, siblings, pathIndices) - - await expect(transaction).to.be.revertedWithCustomError(quinaryIMT, "LeafIndexOutOfRange") - }) - }) - - describe("# remove", () => { - it("Should not remove a leaf if its value is > SNARK_SCALAR_FIELD", async () => { - const transaction = quinaryIMTTest.remove(SNARK_SCALAR_FIELD, [[0, 1, 2, 3]], [0]) - - await expect(transaction).to.be.revertedWithCustomError(quinaryIMT, "ValueGreaterThanSnarkScalarField") - }) - - it("Should not remove a leaf that does not exist", async () => { - await quinaryIMTTest.init(jsQuinaryIMT.depth) - await quinaryIMTTest.insert(1) - - jsQuinaryIMT.insert(1) - jsQuinaryIMT.delete(0) - - const { siblings, pathIndices } = jsQuinaryIMT.createProof(0) - - const transaction = quinaryIMTTest.remove(2, siblings, pathIndices) - - await expect(transaction).to.be.revertedWithCustomError(quinaryIMT, "LeafDoesNotExist") - }) - - it("Should remove a leaf", async () => { - await quinaryIMTTest.init(jsQuinaryIMT.depth) - await quinaryIMTTest.insert(1) - - jsQuinaryIMT.insert(1) - jsQuinaryIMT.delete(0) - - const { pathIndices, siblings } = jsQuinaryIMT.createProof(0) - - await quinaryIMTTest.remove(1, siblings, pathIndices) - - const { root } = await quinaryIMTTest.data() - - expect(root).to.equal(jsQuinaryIMT.root) - }) - - it("Should insert a leaf in a tree after a removal", async () => { - await quinaryIMTTest.init(jsQuinaryIMT.depth) - await quinaryIMTTest.insert(1) - - jsQuinaryIMT.insert(1) - jsQuinaryIMT.delete(0) - - const { pathIndices, siblings } = jsQuinaryIMT.createProof(0) - - await quinaryIMTTest.remove(1, siblings, pathIndices) - - jsQuinaryIMT.insert(2) - await quinaryIMTTest.insert(2) - - const { root } = await quinaryIMTTest.data() - - expect(root).to.equal(jsQuinaryIMT.root) - }) - - it("Should insert 4 leaves and remove them all", async () => { - await quinaryIMTTest.init(jsQuinaryIMT.depth) - - for (let i = 0; i < 4; i += 1) { - const leaf = i + 1 - - jsQuinaryIMT.insert(leaf) - await quinaryIMTTest.insert(leaf) - } - - for (let i = 0; i < 4; i += 1) { - jsQuinaryIMT.delete(i) - - const { siblings, pathIndices } = jsQuinaryIMT.createProof(i) - - await quinaryIMTTest.remove(i + 1, siblings, pathIndices) - } - - const { root } = await quinaryIMTTest.data() - - expect(root).to.equal(jsQuinaryIMT.root) - }) - }) -}) diff --git a/packages/imt.sol/tsconfig.json b/packages/imt.sol/tsconfig.json deleted file mode 100644 index 0a513fff3..000000000 --- a/packages/imt.sol/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compilerOptions": { - "target": "es2020", - "module": "commonjs", - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "strict": true, - "skipLibCheck": true, - "resolveJsonModule": true - }, - "include": ["scripts/**/*", "tasks/**/*", "test/**/*", "typechain-types/**/*"], - "files": ["hardhat.config.ts"] -} diff --git a/packages/lazytower.sol/.env.example b/packages/lazytower.sol/.env.example deleted file mode 100644 index 9b91f04b3..000000000 --- a/packages/lazytower.sol/.env.example +++ /dev/null @@ -1,2 +0,0 @@ -COINMARKETCAP_API_KEY= -REPORT_GAS=false diff --git a/packages/lazytower.sol/.prettierrc.json b/packages/lazytower.sol/.prettierrc.json deleted file mode 100644 index 717fb520a..000000000 --- a/packages/lazytower.sol/.prettierrc.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "semi": false, - "arrowParens": "always", - "trailingComma": "none", - "plugins": ["prettier-plugin-solidity"] -} diff --git a/packages/lazytower.sol/.solcover.js b/packages/lazytower.sol/.solcover.js deleted file mode 100644 index ed8ee9ca5..000000000 --- a/packages/lazytower.sol/.solcover.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - istanbulFolder: "../../coverage/sol" -} diff --git a/packages/lazytower.sol/.solhint.json b/packages/lazytower.sol/.solhint.json deleted file mode 100644 index bfc727d53..000000000 --- a/packages/lazytower.sol/.solhint.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "extends": "solhint:recommended", - "plugins": ["prettier"], - "rules": { - "compiler-version": ["error", ">=0.8.0"], - "const-name-snakecase": "off", - "no-empty-blocks": "off", - "constructor-syntax": "error", - "func-visibility": ["error", { "ignoreConstructors": true }], - "max-line-length": ["error", 120], - "not-rely-on-time": "off", - "prettier/prettier": [ - "error", - { - "endOfLine": "auto" - } - ], - "reason-string": ["warn", { "maxLength": 80 }] - } -} diff --git a/packages/lazytower.sol/.solhintignore b/packages/lazytower.sol/.solhintignore deleted file mode 100644 index d52f55e25..000000000 --- a/packages/lazytower.sol/.solhintignore +++ /dev/null @@ -1 +0,0 @@ -contracts/Verifier.sol diff --git a/packages/lazytower.sol/LICENSE b/packages/lazytower.sol/LICENSE deleted file mode 120000 index 89a15f798..000000000 --- a/packages/lazytower.sol/LICENSE +++ /dev/null @@ -1 +0,0 @@ -contracts/LICENSE \ No newline at end of file diff --git a/packages/lazytower.sol/README.md b/packages/lazytower.sol/README.md deleted file mode 120000 index 1ee044251..000000000 --- a/packages/lazytower.sol/README.md +++ /dev/null @@ -1 +0,0 @@ -contracts/README.md \ No newline at end of file diff --git a/packages/lazytower.sol/contracts/LICENSE b/packages/lazytower.sol/contracts/LICENSE deleted file mode 100644 index 8ef16f7a5..000000000 --- a/packages/lazytower.sol/contracts/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2024 Ethereum Foundation - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/packages/lazytower.sol/contracts/LazyTowerHashChain.sol b/packages/lazytower.sol/contracts/LazyTowerHashChain.sol deleted file mode 100644 index d7fce2894..000000000 --- a/packages/lazytower.sol/contracts/LazyTowerHashChain.sol +++ /dev/null @@ -1,95 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.4; - -import {PoseidonT3} from "poseidon-solidity/PoseidonT3.sol"; -// CAPACITY = W * (W**0 + W**1 + ... + W**(H - 1)) = W * (W**H - 1) / (W - 1) -// 4 * (4**24 - 1) / (4 - 1) = 375_299_968_947_540; -uint256 constant H = 24; -uint256 constant W = 4; - -uint256 constant bitsPerLevel = 4; -uint256 constant levelBitmask = 15; // (1 << bitsPerLevel) - 1 -uint256 constant ones = 0x111111111111111111111111; // H ones - -// Each LazyTower has certain properties and data that will -// be used to add new items. -struct LazyTowerHashChainData { - uint256 levelLengths; // length of each level - uint256[H] digests; // digest of each level - uint256[H] digestOfDigests; // digest of digests -} - -/// @title LazyTower. -/// @dev The LazyTower allows to calculate the digest of digests each time an item is added, ensuring -/// the integrity of the LazyTower. -library LazyTowerHashChain { - uint256 internal constant SNARK_SCALAR_FIELD = - 21888242871839275222246405745257275088548364400416034343698204186575808495617; - - function findLowestNonFullLevelThenInc( - uint256 levelLengths - ) internal pure returns (uint256 level, bool isHead, bool isTop, uint256 newLevelLengths) { - // find the lowest non-full level - uint256 levelLength; - while (true) { - levelLength = levelLengths & levelBitmask; - if (levelLength < W) break; - level++; - levelLengths >>= bitsPerLevel; - } - - isHead = (levelLength == 0); - isTop = ((levelLengths >> bitsPerLevel) == 0); - - // increment the non-full levelLength(s) by one - // all full levels below become ones - uint256 fullLevelBits = level * bitsPerLevel; - uint256 onesMask = (1 << fullLevelBits) - 1; - newLevelLengths = ((levelLengths + 1) << fullLevelBits) + (onesMask & ones); - } - - /// @dev Add an item. - /// @param self: LazyTower data - /// @param item: item to be added - function add(LazyTowerHashChainData storage self, uint256 item) public { - require(item < SNARK_SCALAR_FIELD, "LazyTower: item must be < SNARK_SCALAR_FIELD"); - - uint256 level; - bool isHead; - bool isTop; - (level, isHead, isTop, self.levelLengths) = findLowestNonFullLevelThenInc(self.levelLengths); - - uint256 digest; - uint256 digestOfDigests; - uint256 toAdd; - - // append at the first non-full level - toAdd = (level == 0) ? item : self.digests[level - 1]; - digest = isHead ? toAdd : PoseidonT3.hash([self.digests[level], toAdd]); - digestOfDigests = isTop ? digest : PoseidonT3.hash([self.digestOfDigests[level + 1], digest]); - self.digests[level] = digest; - self.digestOfDigests[level] = digestOfDigests; - - // the rest of levels are all full - while (level != 0) { - level--; - - toAdd = (level == 0) ? item : self.digests[level - 1]; - digest = toAdd; - digestOfDigests = PoseidonT3.hash([digestOfDigests, digest]); // top-down - self.digests[level] = digest; - self.digestOfDigests[level] = digestOfDigests; - } - } - - function getDataForProving( - LazyTowerHashChainData storage self - ) external view returns (uint256, uint256[] memory, uint256) { - uint256 len = self.digests.length; - uint256[] memory digests = new uint256[](len); // for returning a dynamic array - for (uint256 i = 0; i < len; i++) { - digests[i] = self.digests[i]; - } - return (self.levelLengths, digests, self.digestOfDigests[0]); - } -} diff --git a/packages/lazytower.sol/contracts/README.md b/packages/lazytower.sol/contracts/README.md deleted file mode 100644 index bac6ef2b4..000000000 --- a/packages/lazytower.sol/contracts/README.md +++ /dev/null @@ -1,146 +0,0 @@ -

-

- LazyTower (Solidity) -

-

LazyTower Solidity libraries.

-

- -

- - - - - NPM license - - - NPM version - - - Downloads - - - Linter eslint - - - Code style prettier - -

- - - -## ❗ WARNING - -This library has not been audited. - -## Libraries: - -✔️ [LazyTowerHashChain](https://github.com/privacy-scaling-explorations/zk-kit/blob/main/packages/lazytower.sol/contracts/LazyTowerHashChain.sol) (Poseidon) - ---- - -## 🛠 Install - -### npm or yarn - -Install the `@zk-kit/lazytower.sol` package with npm: - -```bash -npm i @zk-kit/lazytower.sol --save -``` - -or yarn: - -```bash -yarn add @zk-kit/lazytower.sol -``` - -## 📜 Usage - -### Importing and using the library - -```solidity -// SPDX-License-Identifier: MIT - -pragma solidity ^0.8.4; - -import "../LazyTowerHashChain.sol"; - -contract LazyTowerHashChainTest { - using LazyTowerHashChain for LazyTowerHashChainData; - - event Add(uint256 item); - - // map for multiple test cases - mapping(bytes32 => LazyTowerHashChainData) public towers; - - function add(bytes32 _towerId, uint256 _item) external { - towers[_towerId].add(_item); - emit Add(_item); - } - - function getDataForProving(bytes32 _towerId) external view returns (uint256, uint256[] memory, uint256) { - return towers[_towerId].getDataForProving(); - } -} -``` - -### Creating an Hardhat task to deploy the contract - -```typescript -import { Contract } from "ethers" -import { task, types } from "hardhat/config" - -task("deploy:lazytower-test", "Deploy a LazyTowerHashChainTest contract") - .addOptionalParam("logs", "Print the logs", true, types.boolean) - .setAction(async ({ logs }, { ethers }): Promise => { - const PoseidonT3Factory = await ethers.getContractFactory("PoseidonT3") - const PoseidonT3 = await PoseidonT3Factory.deploy() - - if (logs) { - console.info(`PoseidonT3 library has been deployed to: ${PoseidonT3.address}`) - } - - const LazyTowerLibFactory = await ethers.getContractFactory("LazyTowerHashChain", { - libraries: { - PoseidonT3: PoseidonT3.address - } - }) - const lazyTowerLib = await LazyTowerLibFactory.deploy() - - await lazyTowerLib.deployed() - - if (logs) { - console.info(`LazyTowerHashChain library has been deployed to: ${lazyTowerLib.address}`) - } - - const ContractFactory = await ethers.getContractFactory("LazyTowerHashChainTest", { - libraries: { - LazyTowerHashChain: lazyTowerLib.address - } - }) - - const contract = await ContractFactory.deploy() - - await contract.deployed() - - if (logs) { - console.info(`Test contract has been deployed to: ${contract.address}`) - } - - return contract - }) -``` - -## Contacts - -### Developers - -- e-mail : lcamel@gmail.com -- github : [@LCamel](https://github.com/LCamel) -- website : https://www.facebook.com/LCamel diff --git a/packages/lazytower.sol/contracts/package.json b/packages/lazytower.sol/contracts/package.json deleted file mode 100644 index 4736599f0..000000000 --- a/packages/lazytower.sol/contracts/package.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "@zk-kit/lazytower.sol", - "version": "0.0.1", - "description": "LazyTower Solidity libraries.", - "license": "MIT", - "files": [ - "**/*.sol", - "!test/", - "README.md" - ], - "keywords": [ - "blockchain", - "ethereum", - "hardhat", - "smart-contracts", - "solidity", - "libraries", - "merkle-tree", - "incremental-merkle-tree", - "lazytower" - ], - "repository": "git@github.com:privacy-scaling-explorations/zk-kit.git", - "homepage": "https://github.com/privacy-scaling-explorations/zk-kit/tree/main/packages/lazytower.sol", - "author": { - "name": "LCamel", - "email": "lcamel@gmail.com", - "url": "https://twitter.com/LCamel" - }, - "publishConfig": { - "access": "public" - }, - "dependencies": { - "poseidon-solidity": "0.0.5" - } -} diff --git a/packages/lazytower.sol/contracts/test/LazyTowerHashChainTest.sol b/packages/lazytower.sol/contracts/test/LazyTowerHashChainTest.sol deleted file mode 100644 index c1501d0a0..000000000 --- a/packages/lazytower.sol/contracts/test/LazyTowerHashChainTest.sol +++ /dev/null @@ -1,23 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity ^0.8.4; - -import "../LazyTowerHashChain.sol"; - -contract LazyTowerHashChainTest { - using LazyTowerHashChain for LazyTowerHashChainData; - - event Add(uint256 item); - - // map for multiple test cases - mapping(bytes32 => LazyTowerHashChainData) public towers; - - function add(bytes32 _towerId, uint256 _item) external { - towers[_towerId].add(_item); - emit Add(_item); - } - - function getDataForProving(bytes32 _towerId) external view returns (uint256, uint256[] memory, uint256) { - return towers[_towerId].getDataForProving(); - } -} diff --git a/packages/lazytower.sol/hardhat.config.ts b/packages/lazytower.sol/hardhat.config.ts deleted file mode 100644 index 10c3e1f3b..000000000 --- a/packages/lazytower.sol/hardhat.config.ts +++ /dev/null @@ -1,17 +0,0 @@ -import "@nomicfoundation/hardhat-toolbox" -import { HardhatUserConfig } from "hardhat/config" -import "./tasks/deploy-lazytower-test" - -const hardhatConfig: HardhatUserConfig = { - solidity: "0.8.23", - gasReporter: { - currency: "USD", - enabled: process.env.REPORT_GAS === "true", - coinmarketcap: process.env.COINMARKETCAP_API_KEY - }, - typechain: { - target: "ethers-v6" - } -} - -export default hardhatConfig diff --git a/packages/lazytower.sol/package.json b/packages/lazytower.sol/package.json deleted file mode 100644 index 8d7a56179..000000000 --- a/packages/lazytower.sol/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "lazytower.sol", - "private": true, - "scripts": { - "start": "hardhat node", - "build": "hardhat compile", - "deploy:test-contracts": "hardhat deploy:tree-contracts", - "test": "hardhat test", - "test:report-gas": "REPORT_GAS=true hardhat test", - "test:coverage": "hardhat coverage", - "typechain": "hardhat typechain", - "lint": "solhint 'contracts/**/*.sol'" - }, - "devDependencies": { - "@nomicfoundation/hardhat-chai-matchers": "^2.0.3", - "@nomicfoundation/hardhat-ethers": "^3.0.0", - "@nomicfoundation/hardhat-network-helpers": "^1.0.0", - "@nomicfoundation/hardhat-toolbox": "^4.0.0", - "@nomicfoundation/hardhat-verify": "^2.0.0", - "@typechain/ethers-v6": "^0.5.0", - "@typechain/hardhat": "^9.0.0", - "@types/chai": "^4.2.0", - "@types/mocha": "^10.0.6", - "@types/node": "^20.10.7", - "chai": "^4.2.0", - "ethers": "^6.4.0", - "hardhat": "^2.19.4", - "hardhat-gas-reporter": "^1.0.8", - "poseidon-lite": "^0.2.0", - "prettier-plugin-solidity": "^1.3.1", - "solhint": "^3.3.6", - "solhint-plugin-prettier": "^0.1.0", - "solidity-coverage": "^0.8.0", - "ts-node": "^10.9.2", - "typechain": "^8.3.0", - "typescript": "^5.3.3" - }, - "dependencies": { - "poseidon-solidity": "0.0.5" - } -} diff --git a/packages/lazytower.sol/tasks/deploy-lazytower-test.ts b/packages/lazytower.sol/tasks/deploy-lazytower-test.ts deleted file mode 100644 index 1ac175160..000000000 --- a/packages/lazytower.sol/tasks/deploy-lazytower-test.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { task, types } from "hardhat/config" - -task("deploy:lazytower-test", "Deploy a LazyTowerHashChainTest contract") - .addOptionalParam("logs", "Print the logs", true, types.boolean) - .setAction(async ({ logs }, { ethers }): Promise => { - const PoseidonT3Factory = await ethers.getContractFactory("PoseidonT3") - - const poseidonT3 = await PoseidonT3Factory.deploy() - const poseidonT3Address = await poseidonT3.getAddress() - - if (logs) { - console.info(`PoseidonT3 library has been deployed to: ${poseidonT3Address}`) - } - - const LazyTowerLibFactory = await ethers.getContractFactory("LazyTowerHashChain", { - libraries: { - PoseidonT3: poseidonT3Address - } - }) - - const lazyTowerLib = await LazyTowerLibFactory.deploy() - const lazyTowerLibAddress = await lazyTowerLib.getAddress() - - if (logs) { - console.info(`LazyTowerHashChain library has been deployed to: ${lazyTowerLibAddress}`) - } - - const ContractFactory = await ethers.getContractFactory("LazyTowerHashChainTest", { - libraries: { - LazyTowerHashChain: lazyTowerLibAddress - } - }) - - const contract = await ContractFactory.deploy() - const contractAddress = await lazyTowerLib.getAddress() - - if (logs) { - console.info(`Test contract has been deployed to: ${contractAddress}`) - } - - return contract - }) diff --git a/packages/lazytower.sol/test/LazyTowerHashChainTest.ts b/packages/lazytower.sol/test/LazyTowerHashChainTest.ts deleted file mode 100644 index 633d4ad11..000000000 --- a/packages/lazytower.sol/test/LazyTowerHashChainTest.ts +++ /dev/null @@ -1,88 +0,0 @@ -import { expect } from "chai" -import { Contract, encodeBytes32String } from "ethers" -import { run } from "hardhat" -import { poseidon2 } from "poseidon-lite" -import ShiftTower from "./utils" - -describe("LazyTowerHashChainTest", () => { - let contract: Contract - - before(async () => { - contract = await run("deploy:lazytower-test", { logs: false }) - }) - - it("Should produce correct levelLengths, digests and digest of digests", async () => { - const lazyTowerId = encodeBytes32String("test1") - - const N = 150 - for (let i = 0; i < N; i += 1) { - await contract.add(lazyTowerId, i) - } - - const [levelLengths, digests, digestOfDigests] = await contract.getDataForProving(lazyTowerId) - - expect(levelLengths).to.equal(0x2112) - - expect(digests[0]).to.equal( - BigInt("7484852499570635450337779587061833141700590058395918107227385307780465498841") - ) - expect(digests[1]).to.equal( - BigInt("18801712394745483811033456933953954791894699812924877968490149877093764724813") - ) - expect(digests[2]).to.equal( - BigInt("18495397265763935736123111771752209927150052777598404957994272011704245682779") - ) - expect(digests[3]).to.equal( - BigInt("11606235313340788975553986881206148975708550071371494991713397040288897077102") - ) - for (let i = 4; i < digests.length; i += 1) { - expect(digests[i]).to.equal(BigInt("0")) - } - - expect(digestOfDigests).to.equal( - BigInt("19260615748091768530426964318883829655407684674262674118201416393073357631548") - ) - }) - - // FIXME: this times out in CI - it.skip("Should have the same output as the Javascript fixture", async () => { - const lazyTowerId = encodeBytes32String("test2") - - const H2 = (a: bigint, b: bigint) => poseidon2([a, b]) - const W = 4 - const shiftTower = ShiftTower(W, (vs: any[]) => vs.reduce(H2)) - for (let i = 0; i < 150; i += 1) { - shiftTower.add(i) - - const tx = contract.add(lazyTowerId, i) - - // event - await expect(tx).to.emit(contract, "Add").withArgs(i) - - // levelLengths and digest - const [levelLengths, digests, digestOfDigests] = await contract.getDataForProving(lazyTowerId) - - expect(levelLengths).to.equal(shiftTower.L.map((l) => l.length).reduce((s, v, lv) => s + (v << (lv * 4)))) - - const D = shiftTower.L.map((l: any[]) => l.reduce(H2)) - for (let lv = 0; lv < digests.length; lv += 1) { - expect(digests[lv]).to.equal(D[lv] ?? 0) - } - - expect(digestOfDigests).to.equal(D.reverse().reduce(H2)) - } - }) - - it("Should reject values not in the field", async () => { - const lazyTowerId = encodeBytes32String("test3") - - let item = BigInt("21888242871839275222246405745257275088548364400416034343698204186575808495616") - - const tx = contract.add(lazyTowerId, item) - await expect(tx).to.emit(contract, "Add").withArgs(item) - - item += BigInt(1) - const tx2 = contract.add(lazyTowerId, item) - await expect(tx2).to.be.revertedWith("LazyTower: item must be < SNARK_SCALAR_FIELD") - }) -}) diff --git a/packages/lazytower.sol/test/utils.ts b/packages/lazytower.sol/test/utils.ts deleted file mode 100644 index e720fe5b5..000000000 --- a/packages/lazytower.sol/test/utils.ts +++ /dev/null @@ -1,21 +0,0 @@ -export default function ShiftTower(W: number, digest: (values: number[]) => number) { - const S: number[][] = [] - const L: number[][] = [] - - function _add(lv: number, v: number): number { - if (lv === L.length) { - S[lv] = [] - L[lv] = [v] - } else if (L[lv].length < W) { - L[lv].push(v) - } else { - const d = digest(L[lv]) - S[lv].push(...L[lv]) - L[lv] = [v] - return _add(lv + 1, d) - } - return lv - } - const add = (item: number) => _add(0, item) - return { W, digest, L, S, add } -} diff --git a/packages/lazytower.sol/tsconfig.json b/packages/lazytower.sol/tsconfig.json deleted file mode 100644 index 0a513fff3..000000000 --- a/packages/lazytower.sol/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compilerOptions": { - "target": "es2020", - "module": "commonjs", - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "strict": true, - "skipLibCheck": true, - "resolveJsonModule": true - }, - "include": ["scripts/**/*", "tasks/**/*", "test/**/*", "typechain-types/**/*"], - "files": ["hardhat.config.ts"] -} diff --git a/packages/poseidon-proof/package.json b/packages/poseidon-proof/package.json index c3bd14f80..08473835d 100644 --- a/packages/poseidon-proof/package.json +++ b/packages/poseidon-proof/package.json @@ -38,6 +38,7 @@ "@types/download": "^8.0.5", "@types/snarkjs": "^0", "@types/tmp": "^0.2.6", + "ffjavascript": "^0.3.0", "poseidon-lite": "^0.2.0", "rimraf": "^5.0.5", "rollup": "^4.12.0", diff --git a/packages/poseidon-proof/tests/index.test.ts b/packages/poseidon-proof/tests/index.test.ts index 5eb1e1bb5..b609b34b9 100644 --- a/packages/poseidon-proof/tests/index.test.ts +++ b/packages/poseidon-proof/tests/index.test.ts @@ -1,4 +1,4 @@ -import { buildBn128 } from "@zk-kit/groth16" +import { getCurveFromName } from "ffjavascript" import { decodeBytes32String, toBeHex } from "ethers" import { poseidon2 } from "poseidon-lite" import generate from "../src/generate" @@ -12,25 +12,25 @@ let digest: bigint let fullProof: PoseidonProof beforeAll(async () => { - curve = await buildBn128() + curve = await getCurveFromName("bn128") fullProof = await generate([1, 2], scope) digest = poseidon2([hash(1), hash(2)]) -}, 20_000) +}, 30_000) afterAll(async () => { await curve.terminate() }) describe("PoseidonProof", () => { - it("should generate a Poseidon proof from 1 to 16 preimages", async () => { + it("should generate a Poseidon proof", async () => { expect(fullProof.proof).toHaveLength(8) expect(decodeBytes32String(toBeHex(fullProof.scope, 32))).toBe(scope.toString()) expect(fullProof.digest).toBe(digest.toString()) }) - it("Should verify a Poseidon proof from 1 to 16 preimage(s)", async () => { + it("Should verify a Poseidon proof", async () => { await expect(verify(fullProof)).resolves.toBe(true) }) diff --git a/packages/rollup-plugin-rust/LICENSE b/packages/rollup-plugin-rust/LICENSE deleted file mode 100644 index 8ef16f7a5..000000000 --- a/packages/rollup-plugin-rust/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2024 Ethereum Foundation - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/packages/rollup-plugin-rust/README.md b/packages/rollup-plugin-rust/README.md deleted file mode 100644 index da23a060a..000000000 --- a/packages/rollup-plugin-rust/README.md +++ /dev/null @@ -1,74 +0,0 @@ -

-

- Rust Rollup Plugin -

-

Rollup plugin to create WASM/JS libraries from Rust crates.

-

- -

- - - - - NPM license - - - NPM version - - - Downloads - - - npm bundle size (scoped) - - - Linter eslint - - - Code style prettier - -

- - - ---- - -## 🛠 Install - -### npm or yarn - -Install the `@zk-kit/rollup-plugin-rust` package with npm: - -```bash -npm i @zk-kit/rollup-plugin-rust -``` - -or yarn: - -```bash -yarn add @zk-kit/rollup-plugin-rust -``` - -## 📜 Usage - -```typescript -import rust from "@zk-kit/rollup-plugin-rust" - -export default { - input: "Cargo.toml", - output: [ - { - file: "dist/index.js", - name: "myPackageName", - format: "iife" - } - ], - plugins: [rust()] -} -``` diff --git a/packages/rollup-plugin-rust/build.tsconfig.json b/packages/rollup-plugin-rust/build.tsconfig.json deleted file mode 100644 index 6e90fdda9..000000000 --- a/packages/rollup-plugin-rust/build.tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "declarationDir": "types", - "noImplicitAny": false - }, - "include": ["src"] -} diff --git a/packages/rollup-plugin-rust/demo/Cargo.lock b/packages/rollup-plugin-rust/demo/Cargo.lock deleted file mode 100644 index 9109e9f7c..000000000 --- a/packages/rollup-plugin-rust/demo/Cargo.lock +++ /dev/null @@ -1,157 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "bumpalo" -version = "3.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "console_error_panic_hook" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" -dependencies = [ - "cfg-if", - "wasm-bindgen", -] - -[[package]] -name = "hello-wasm" -version = "0.1.0" -dependencies = [ - "console_error_panic_hook", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "js-sys" -version = "0.3.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "log" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "proc-macro2" -version = "1.0.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "392a54546fda6b7cc663379d0e6ce8b324cf88aecc5a499838e1be9781bdce2e" -dependencies = [ - "unicode-xid", -] - -[[package]] -name = "quote" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "syn" -version = "1.0.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecb2e6da8ee5eb9a61068762a32fa9619cc591ceb055b3687f4cd4051ec2e06b" -dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", -] - -[[package]] -name = "unicode-xid" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" - -[[package]] -name = "wasm-bindgen" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" -dependencies = [ - "bumpalo", - "lazy_static", - "log", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" - -[[package]] -name = "web-sys" -version = "0.3.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb" -dependencies = [ - "js-sys", - "wasm-bindgen", -] diff --git a/packages/rollup-plugin-rust/demo/Cargo.toml b/packages/rollup-plugin-rust/demo/Cargo.toml deleted file mode 100644 index 9d8665199..000000000 --- a/packages/rollup-plugin-rust/demo/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -[package] -name = "hello-wasm" -version = "0.1.0" -authors = ["Cedoor "] -edition = "2024" -categories = ["wasm"] - -[lib] -crate-type = ["cdylib"] - -[dependencies] -wasm-bindgen = "0.2.58" -console_error_panic_hook = "0.1.6" - -[dependencies.web-sys] -version = "0.3.35" -features = [ - "console", -] diff --git a/packages/rollup-plugin-rust/demo/index.html b/packages/rollup-plugin-rust/demo/index.html deleted file mode 100644 index 459212044..000000000 --- a/packages/rollup-plugin-rust/demo/index.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - -

- -

- - diff --git a/packages/rollup-plugin-rust/demo/package.json b/packages/rollup-plugin-rust/demo/package.json deleted file mode 100644 index 13143c4b5..000000000 --- a/packages/rollup-plugin-rust/demo/package.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "name": "@zk-kit/hello-wasm", - "version": "0.1.0", - "description": "Boilerplate to compile a Rust packages to WASM.", - "license": "MIT", - "iife": "dist/index.js", - "unpkg": "dist/index.min.js", - "jsdelivr": "dist/index.min.js", - "main": "dist/index.node.js", - "exports": { - "import": "./dist/index.mjs", - "require": "./dist/index.node.js" - }, - "types": "dist/types/index.d.ts", - "files": [ - "dist/", - "src/", - "index.html", - "LICENSE", - "README.md" - ], - "repository": "git@github.com:privacy-scaling-explorations/zk-kit.git", - "homepage": "https://github.com/privacy-scaling-explorations/zk-kit/tree/main/packages/hello-wasm", - "author": { - "name": "Omar Desogus", - "email": "me@cedoor.dev", - "url": "https://cedoor.dev" - }, - "scripts": { - "start": "yarn build && serve", - "build": "rimraf dist && rollup -c", - "build:watch": "rollup -c -w", - "prepublishOnly": "yarn build" - }, - "publishConfig": { - "access": "public" - }, - "devDependencies": { - "rimraf": "^3.0.2", - "rollup": "^1.31.0" - } -} diff --git a/packages/rollup-plugin-rust/demo/rollup.config.js b/packages/rollup-plugin-rust/demo/rollup.config.js deleted file mode 100644 index 71212304b..000000000 --- a/packages/rollup-plugin-rust/demo/rollup.config.js +++ /dev/null @@ -1,28 +0,0 @@ -import fs from "fs" -import rust from ".." - -const pkg = JSON.parse(fs.readFileSync("./package.json", "utf8")) -const name = pkg.name.substr(1).replace(/[-/]./g, (x) => x.toUpperCase()[1]) -const banner = `/** - * @module ${pkg.name} - * @version ${pkg.version} - * @file ${pkg.description} - * @copyright ${pkg.author.name} ${new Date().getFullYear()} - * @license ${pkg.license} - * @see [Github]{@link ${pkg.homepage}} -*/` - -export default { - input: "Cargo.toml", - output: [ - { - file: pkg.iife, - name, - format: "iife", - banner - }, - { file: pkg.exports.require, format: "cjs", banner, exports: "auto" }, - { file: pkg.exports.import, format: "es", banner } - ], - plugins: [rust()] -} diff --git a/packages/rollup-plugin-rust/demo/src/lib.rs b/packages/rollup-plugin-rust/demo/src/lib.rs deleted file mode 100644 index 504203c25..000000000 --- a/packages/rollup-plugin-rust/demo/src/lib.rs +++ /dev/null @@ -1,9 +0,0 @@ -use wasm_bindgen::prelude::*; -use web_sys::console; - -#[wasm_bindgen] -pub fn greet(name: &str) { - console_error_panic_hook::set_once(); - - console::log_1(&JsValue::from(&format!("Hello, {}!", name))); -} diff --git a/packages/rollup-plugin-rust/package.json b/packages/rollup-plugin-rust/package.json deleted file mode 100644 index 462ac4e96..000000000 --- a/packages/rollup-plugin-rust/package.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "name": "@zk-kit/rollup-plugin-rust", - "version": "0.1.0", - "description": "Rollup plugin to create WASM/JS libraries from Rust crates.", - "type": "module", - "license": "MIT", - "main": "dist/index.js", - "types": "dist/types/index.d.ts", - "exports": { - ".": { - "require": "./dist/index.cjs", - "default": "./dist/index.js" - } - }, - "files": [ - "dist/", - "src/", - "README.md", - "LICENSE" - ], - "repository": "git@github.com:privacy-scaling-explorations/zk-kit.git", - "homepage": "https://github.com/privacy-scaling-explorations/zk-kit/tree/main/packages/rollup-plugin-rust", - "author": { - "name": "Cedoor", - "email": "me@cedoor.dev", - "url": "https://cedoor.dev" - }, - "scripts": { - "build": "rimraf dist && rollup -c rollup.config.ts --configPlugin typescript", - "prepublishOnly": "yarn build" - }, - "publishConfig": { - "access": "public" - }, - "devDependencies": { - "@rollup/plugin-typescript": "^11.1.6", - "rollup": "^4.12.0", - "rollup-plugin-cleanup": "^3.2.1" - }, - "dependencies": { - "glob": "^7.1.6", - "rimraf": "^5.0.5", - "rollup-pluginutils": "^2.8.2", - "toml": "^3.0.0", - "wasm-pack": "^0.10.2" - } -} diff --git a/packages/rollup-plugin-rust/rollup.config.ts b/packages/rollup-plugin-rust/rollup.config.ts deleted file mode 100644 index 64f1226c4..000000000 --- a/packages/rollup-plugin-rust/rollup.config.ts +++ /dev/null @@ -1,23 +0,0 @@ -import typescript from "@rollup/plugin-typescript" -import fs from "fs" -import cleanup from "rollup-plugin-cleanup" - -const pkg = JSON.parse(fs.readFileSync("./package.json", "utf8")) -const banner = `/** - * @module ${pkg.name} - * @version ${pkg.version} - * @file ${pkg.description} - * @copyright ${pkg.author.name} ${new Date().getFullYear()} - * @license ${pkg.license} - * @see [Github]{@link ${pkg.homepage}} -*/` - -export default { - input: "src/index.ts", - output: [ - { file: pkg.exports["."].require, format: "cjs", banner, exports: "auto" }, - { file: pkg.exports["."].default, format: "es", banner } - ], - external: ["fs", "glob", "path", "child_process", "toml", "rimraf", "os", "rollup-pluginutils"], - plugins: [typescript({ tsconfig: "./build.tsconfig.json" }), cleanup({ comments: "jsdoc" })] -} diff --git a/packages/rollup-plugin-rust/src/index.ts b/packages/rollup-plugin-rust/src/index.ts deleted file mode 100644 index d37acf439..000000000 --- a/packages/rollup-plugin-rust/src/index.ts +++ /dev/null @@ -1,125 +0,0 @@ -import path from "path" -import type { Plugin, PluginContext } from "rollup" -import { createFilter } from "rollup-pluginutils" -import toml from "toml" -import { InternalPluginOptions, PluginOptions } from "./types" -import { exec, glob, readFile, rm } from "./utils" - -async function wasmPack(options: InternalPluginOptions, source: string, dir: string) { - const { name } = toml.parse(source).package - const outDir = path.resolve(`target/wasm-pack/${name}`) - const args = [ - "--log-level", - options.verbose ? "info" : "error", - "build", - "--out-dir", - outDir, - "--out-name", - "index", - "--target", - "web", - options.debug ? "--dev" : "--release", - "--" - ].concat(options.cargoArgs) - - // Removes the old out directory. - await rm(outDir) - - // Runs the 'wasm-pack' command. - await exec("wasm-pack", args, dir) - - // Get the wasm code. - const wasm = await readFile(`${outDir}/index_bg.wasm`) - const base64Decode = ` - const base64codes = [62,0,0,0,63,52,53,54,55,56,57,58,59,60,61,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,0,0,0,0,0,0,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51]; - - function getBase64Code(charCode) { - return base64codes[charCode - 43]; - } - - function base64_decode(str) { - let missingOctets = str.endsWith("==") ? 2 : str.endsWith("=") ? 1 : 0; - let n = str.length; - let result = new Uint8Array(3 * (n / 4)); - let buffer; - - for (let i = 0, j = 0; i < n; i += 4, j += 3) { - buffer = - getBase64Code(str.charCodeAt(i)) << 18 | - getBase64Code(str.charCodeAt(i + 1)) << 12 | - getBase64Code(str.charCodeAt(i + 2)) << 6 | - getBase64Code(str.charCodeAt(i + 3)); - result[j] = buffer >> 16; - result[j + 1] = (buffer >> 8) & 0xFF; - result[j + 2] = buffer & 0xFF; - } - - return result.subarray(0, result.length - missingOctets); - }` - - return { - code: ` - import * as exports from "./${path.relative(dir, `${outDir}/index.js`)}"; - - ${base64Decode} - - const wasm_code = base64_decode("${wasm.toString("base64")}"); - - export default async () => { - await exports.default(wasm_code); - return exports; - };`, - map: { mappings: "" }, - moduleSideEffects: false - } -} - -async function watchFiles(plugin: PluginContext, options: InternalPluginOptions, dir: string) { - if (plugin.meta.watchMode) { - const matches = await Promise.all(options.watchPatterns.map((pattern) => glob(pattern, dir))) - - matches.forEach((files) => { - files.forEach((file) => { - plugin.addWatchFile(file) - }) - }) - } -} - -async function build(plugin: PluginContext, options: InternalPluginOptions, source: string, id: string): Promise { - const dir = path.dirname(id) - - const [output] = await Promise.all([wasmPack(options, source, dir), watchFiles(plugin, options, dir)]) - - return output -} - -/** - * Rollup plugin main function. - * @param externalOptions The plugin options. - * @returns The Rollup plugin object. - */ -export default function rust(externalOptions?: PluginOptions): Plugin { - const options: InternalPluginOptions = { - // Default options: - debug: true, - verbose: false, - cargoArgs: [], - watchPatterns: ["src/**"], - include: null, - exclude: null, - ...externalOptions - } - const filter = createFilter(options.include, options.exclude) - - return { - name: "rust", - transform(source, id) { - if (path.basename(id) === "Cargo.toml" && filter(id)) { - return build(this, options, source, id) - } - - return null - } - } -} diff --git a/packages/rollup-plugin-rust/src/types/index.ts b/packages/rollup-plugin-rust/src/types/index.ts deleted file mode 100644 index ef399059a..000000000 --- a/packages/rollup-plugin-rust/src/types/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -export type PluginOptions = { - debug?: boolean - verbose?: boolean - cargoArgs?: string[] - watchPatterns?: string[] - include?: (string | RegExp)[] | string | RegExp | null - exclude?: (string | RegExp)[] | string | RegExp | null -} - -export type InternalPluginOptions = Required diff --git a/packages/rollup-plugin-rust/src/utils.ts b/packages/rollup-plugin-rust/src/utils.ts deleted file mode 100644 index 30f213f6f..000000000 --- a/packages/rollup-plugin-rust/src/utils.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { spawn } from "child_process" -import _fs from "fs" -import _glob from "glob" -import { rimraf as _rimraf } from "rimraf" - -export function exec(command: string, args: ReadonlyArray, cwd: string): Promise { - return new Promise((resolve, reject) => { - const childProcess = spawn(command, args, { cwd, stdio: "inherit" }) - - childProcess - .on("close", (code) => { - if (code === 0) { - resolve() - } else { - reject(new Error(`Command '${childProcess.spawnargs.join(" ")}' failed with error code: ${code}`)) - } - }) - .on("error", reject) - }) -} - -export function glob(pattern: string, cwd?: string): Promise { - return new Promise((resolve, reject) => { - _glob( - pattern, - { - cwd, - strict: true, - absolute: true, - nodir: true - }, - (error, files) => { - if (error) { - reject(error) - } else { - resolve(files) - } - } - ) - }) -} - -export function readFile(path: string): Promise { - return new Promise((resolve, reject) => { - _fs.readFile(path, (error, file) => { - if (error) { - reject(error) - } else { - resolve(file) - } - }) - }) -} - -export function rm(path: string): Promise { - return _rimraf(path, { glob: false }) -} diff --git a/packages/rollup-plugin-rust/tsconfig.json b/packages/rollup-plugin-rust/tsconfig.json deleted file mode 100644 index 817845b38..000000000 --- a/packages/rollup-plugin-rust/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "noImplicitAny": false - }, - "include": ["src", "rollup.config.ts"] -} diff --git a/packages/smt/package.json b/packages/smt/package.json index f74ae52ca..1a5d5971c 100644 --- a/packages/smt/package.json +++ b/packages/smt/package.json @@ -42,6 +42,7 @@ "access": "public" }, "devDependencies": { + "@aztec/bb.js": "^0.40.1", "@rollup/plugin-terser": "^0.4.4", "@rollup/plugin-typescript": "^11.1.6", "@types/crypto-js": "^4.1.1", diff --git a/packages/smt/tests/index.test.ts b/packages/smt/tests/index.test.ts index 137ea48c6..ecc0935fd 100644 --- a/packages/smt/tests/index.test.ts +++ b/packages/smt/tests/index.test.ts @@ -18,7 +18,7 @@ describe("SMT", () => { hashes.sha256 = (childNodes: ChildNodes) => sha256(childNodes.join("")).toString() hashes.poseidon2 = (childNodes: ChildNodes) => bb - .poseidonHash([Fr.fromString(childNodes.join(""))]) + .poseidon2Hash([Fr.fromString(childNodes.join(""))]) .toString() .slice(2) hashes.pedersen = (childNodes: ChildNodes) => diff --git a/scripts/remove-stable-version-field.ts b/scripts/remove-stable-version-field.ts index c34fe73ed..861ede2db 100644 --- a/scripts/remove-stable-version-field.ts +++ b/scripts/remove-stable-version-field.ts @@ -1,13 +1,9 @@ -import { existsSync, readFileSync, writeFileSync } from "node:fs" +import { readFileSync, writeFileSync } from "node:fs" async function main() { const projectDirectory = `packages/${process.argv[2]}` - let filePath = `${projectDirectory}/package.json` - - if (existsSync(`${projectDirectory}/contracts/package.json`)) { - filePath = `${projectDirectory}/contracts/package.json` - } + const filePath = `${projectDirectory}/package.json` const content = JSON.parse(readFileSync(filePath, "utf8")) diff --git a/turbo.json b/turbo.json index 2a69a184c..3e5b57171 100644 --- a/turbo.json +++ b/turbo.json @@ -3,85 +3,35 @@ "pipeline": { "build": { "dependsOn": ["^build"], - "inputs": [ - "**/tsconfig.json", - "packages/**/*.{js,json,ts,sol}", - "!packages/**/{artifacts,cache,dist,typechain-types}/**" - ], - "outputs": ["packages/**/{artifacts,dist,typechain-types}/**"] + "inputs": ["tsconfig.json", "**/build.tsconfig.json", "**/rollup.config.ts", "packages/**/*.{js,json,ts}"], + "outputs": ["packages/**/dist/**"] }, - "//#_build:libraries": { - "inputs": [ - "tsconfig.json", - "packages/**/*.{js,json,ts}", - "!packages/**/{artifacts,cache,dist,typechain-types}/**" - ] + "//#_build": { + "inputs": ["tsconfig.json", "**/build.tsconfig.json", "**/rollup.config.ts", "packages/**/*.{js,json,ts}"] + }, + "//#_test": { + "dependsOn": ["_build"], + "inputs": ["jest.config.ts", "packages/**/*.{js,ts}"] }, "//#format:prettier": { "inputs": [ ".prettierrc.json", ".prettierignore", - "*.{js,ts,yml,json,md}", - "{.github,packages,scripts,types}/**/*.{js,ts,yml,json,md}", - "!packages/**/{artifacts,cache,dist,typechain-types}/**" + "*.{js,ts,yml,yaml,json,md}", + "{.github,packages,scripts,types}/**/*.{js,ts,yml,yaml,json,md}" ] }, "//#format:prettier:write": { "inputs": [ ".prettierrc.json", ".prettierignore", - "*.{js,ts,yml,json,md}", - "{.github,packages,scripts,types}/**/*.{js,ts,yml,json,md}", - "!packages/**/{artifacts,cache,dist,typechain-types}/**" + "*.{js,ts,yml,yaml,json,md}", + "{.github,packages,scripts,types}/**/*.{js,ts,yml,yaml,json,md}" ] }, "//#lint:eslint": { - "dependsOn": [ - "@zk-kit/baby-jubjub#build", - "@zk-kit/eddsa-poseidon#build", - "@zk-kit/imt#build", - "imt.sol#typechain", - "lazytower.sol#typechain", - "@zk-kit/poseidon-cipher#build", - "@zk-kit/rollup-plugin-rust#build", - "@zk-kit/smt#build", - "@zk-kit/utils#build" - ], - "inputs": [ - ".eslintrc.json", - ".eslintignore", - "{packages,scripts,types}/**/*.{js,ts}", - "!packages/**/{artifacts,cache,dist,typechain-types}/**" - ] - }, - "lint": { - "inputs": ["**/*.sol"] - }, - "//#_test:libraries": { - "dependsOn": [ - "@zk-kit/imt#build", - "@zk-kit/baby-jubjub#build", - "@zk-kit/eddsa-poseidon#build", - "@zk-kit/groth16#build", - "@zk-kit/lazytower#build", - "@zk-kit/poseidon-cipher#build", - "@zk-kit/poseidon-proof#build", - "@zk-kit/rollup-plugin-rust#build", - "@zk-kit/smt#build", - "@zk-kit/utils#build" - ], - "inputs": [ - "jest.config.ts", - "packages/**/*.{js,ts}", - "!packages/**/{artifacts,cache,dist,typechain-types}/**" - ] - }, - "test:coverage": { - "dependsOn": ["@zk-kit/imt#build", "^build"], - "inputs": ["**/*.sol"] - }, - "typechain": { - "inputs": ["packages/**/*.sol"] + "dependsOn": ["_build"], + "inputs": [".eslintrc.json", ".eslintignore", "{packages,scripts,types}/**/*.{js,ts}"] } } } diff --git a/yarn.lock b/yarn.lock index b17654be6..9cf49fe6b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -80,9 +80,9 @@ __metadata: languageName: node linkType: hard -"@aztec/bb.js@npm:^0.33.0": - version: 0.33.0 - resolution: "@aztec/bb.js@npm:0.33.0" +"@aztec/bb.js@npm:^0.40.1": + version: 0.40.1 + resolution: "@aztec/bb.js@npm:0.40.1" dependencies: comlink: "npm:^4.4.1" commander: "npm:^10.0.1" @@ -90,7 +90,7 @@ __metadata: tslib: "npm:^2.4.0" bin: bb.js: dest/node/main.js - checksum: 10/ecdf801a0d863da1f5ca8ab3fc2f5610866fe7f0c82c77f051046db98e5fc2dac31bb7bd559069782287e0ce32739a46229d4f6dab0dabf03e740e79789c12b5 + checksum: 10/01c26f3a514670601367dfdf5171bf9ac449ed4ca316068da330bc6933ee5fb7ea9dff886ddb79d8de227d80f61a1ea3346fc09b2c9be049fc2244e79d2d8880 languageName: node linkType: hard @@ -792,7 +792,7 @@ __metadata: languageName: node linkType: hard -"@ethersproject/abi@npm:5.7.0, @ethersproject/abi@npm:^5.0.9, @ethersproject/abi@npm:^5.1.2, @ethersproject/abi@npm:^5.6.3, @ethersproject/abi@npm:^5.7.0": +"@ethersproject/abi@npm:^5.1.2, @ethersproject/abi@npm:^5.6.3": version: 5.7.0 resolution: "@ethersproject/abi@npm:5.7.0" dependencies: @@ -809,7 +809,7 @@ __metadata: languageName: node linkType: hard -"@ethersproject/abstract-provider@npm:5.7.0, @ethersproject/abstract-provider@npm:^5.7.0": +"@ethersproject/abstract-provider@npm:^5.7.0": version: 5.7.0 resolution: "@ethersproject/abstract-provider@npm:5.7.0" dependencies: @@ -824,7 +824,7 @@ __metadata: languageName: node linkType: hard -"@ethersproject/abstract-signer@npm:5.7.0, @ethersproject/abstract-signer@npm:^5.7.0": +"@ethersproject/abstract-signer@npm:^5.7.0": version: 5.7.0 resolution: "@ethersproject/abstract-signer@npm:5.7.0" dependencies: @@ -837,7 +837,7 @@ __metadata: languageName: node linkType: hard -"@ethersproject/address@npm:5.7.0, @ethersproject/address@npm:^5.0.2, @ethersproject/address@npm:^5.7.0": +"@ethersproject/address@npm:^5.7.0": version: 5.7.0 resolution: "@ethersproject/address@npm:5.7.0" dependencies: @@ -850,7 +850,7 @@ __metadata: languageName: node linkType: hard -"@ethersproject/base64@npm:5.7.0, @ethersproject/base64@npm:^5.7.0": +"@ethersproject/base64@npm:^5.7.0": version: 5.7.0 resolution: "@ethersproject/base64@npm:5.7.0" dependencies: @@ -859,17 +859,7 @@ __metadata: languageName: node linkType: hard -"@ethersproject/basex@npm:5.7.0, @ethersproject/basex@npm:^5.7.0": - version: 5.7.0 - resolution: "@ethersproject/basex@npm:5.7.0" - dependencies: - "@ethersproject/bytes": "npm:^5.7.0" - "@ethersproject/properties": "npm:^5.7.0" - checksum: 10/840e333e109bff2fcf8d91dcfd45fa951835844ef0e1ba710037e87291c7b5f3c189ba86f6cee2ca7de2ede5b7d59fbb930346607695855bee20d2f9f63371ef - languageName: node - linkType: hard - -"@ethersproject/bignumber@npm:5.7.0, @ethersproject/bignumber@npm:^5.7.0": +"@ethersproject/bignumber@npm:^5.7.0": version: 5.7.0 resolution: "@ethersproject/bignumber@npm:5.7.0" dependencies: @@ -880,7 +870,7 @@ __metadata: languageName: node linkType: hard -"@ethersproject/bytes@npm:5.7.0, @ethersproject/bytes@npm:^5.7.0": +"@ethersproject/bytes@npm:^5.7.0": version: 5.7.0 resolution: "@ethersproject/bytes@npm:5.7.0" dependencies: @@ -889,7 +879,7 @@ __metadata: languageName: node linkType: hard -"@ethersproject/constants@npm:5.7.0, @ethersproject/constants@npm:^5.7.0": +"@ethersproject/constants@npm:^5.7.0": version: 5.7.0 resolution: "@ethersproject/constants@npm:5.7.0" dependencies: @@ -898,25 +888,7 @@ __metadata: languageName: node linkType: hard -"@ethersproject/contracts@npm:5.7.0": - version: 5.7.0 - resolution: "@ethersproject/contracts@npm:5.7.0" - dependencies: - "@ethersproject/abi": "npm:^5.7.0" - "@ethersproject/abstract-provider": "npm:^5.7.0" - "@ethersproject/abstract-signer": "npm:^5.7.0" - "@ethersproject/address": "npm:^5.7.0" - "@ethersproject/bignumber": "npm:^5.7.0" - "@ethersproject/bytes": "npm:^5.7.0" - "@ethersproject/constants": "npm:^5.7.0" - "@ethersproject/logger": "npm:^5.7.0" - "@ethersproject/properties": "npm:^5.7.0" - "@ethersproject/transactions": "npm:^5.7.0" - checksum: 10/5df66179af242faabea287a83fd2f8f303a4244dc87a6ff802e1e3b643f091451295c8e3d088c7739970b7915a16a581c192d4e007d848f1fdf3cc9e49010053 - languageName: node - linkType: hard - -"@ethersproject/hash@npm:5.7.0, @ethersproject/hash@npm:^5.7.0": +"@ethersproject/hash@npm:^5.7.0": version: 5.7.0 resolution: "@ethersproject/hash@npm:5.7.0" dependencies: @@ -933,48 +905,7 @@ __metadata: languageName: node linkType: hard -"@ethersproject/hdnode@npm:5.7.0, @ethersproject/hdnode@npm:^5.7.0": - version: 5.7.0 - resolution: "@ethersproject/hdnode@npm:5.7.0" - dependencies: - "@ethersproject/abstract-signer": "npm:^5.7.0" - "@ethersproject/basex": "npm:^5.7.0" - "@ethersproject/bignumber": "npm:^5.7.0" - "@ethersproject/bytes": "npm:^5.7.0" - "@ethersproject/logger": "npm:^5.7.0" - "@ethersproject/pbkdf2": "npm:^5.7.0" - "@ethersproject/properties": "npm:^5.7.0" - "@ethersproject/sha2": "npm:^5.7.0" - "@ethersproject/signing-key": "npm:^5.7.0" - "@ethersproject/strings": "npm:^5.7.0" - "@ethersproject/transactions": "npm:^5.7.0" - "@ethersproject/wordlists": "npm:^5.7.0" - checksum: 10/2fbe6278c324235afaa88baa5dea24d8674c72b14ad037fe2096134d41025977f410b04fd146e333a1b6cac9482e9de62d6375d1705fd42667543f2d0eb66655 - languageName: node - linkType: hard - -"@ethersproject/json-wallets@npm:5.7.0, @ethersproject/json-wallets@npm:^5.7.0": - version: 5.7.0 - resolution: "@ethersproject/json-wallets@npm:5.7.0" - dependencies: - "@ethersproject/abstract-signer": "npm:^5.7.0" - "@ethersproject/address": "npm:^5.7.0" - "@ethersproject/bytes": "npm:^5.7.0" - "@ethersproject/hdnode": "npm:^5.7.0" - "@ethersproject/keccak256": "npm:^5.7.0" - "@ethersproject/logger": "npm:^5.7.0" - "@ethersproject/pbkdf2": "npm:^5.7.0" - "@ethersproject/properties": "npm:^5.7.0" - "@ethersproject/random": "npm:^5.7.0" - "@ethersproject/strings": "npm:^5.7.0" - "@ethersproject/transactions": "npm:^5.7.0" - aes-js: "npm:3.0.0" - scrypt-js: "npm:3.0.1" - checksum: 10/4a1ef0912ffc8d18c392ae4e292948d86bffd715fe3dd3e66d1cd21f6c9267aeadad4da84261db853327f97cdfd765a377f9a87e39d4c6749223a69226faf0a1 - languageName: node - linkType: hard - -"@ethersproject/keccak256@npm:5.7.0, @ethersproject/keccak256@npm:^5.7.0": +"@ethersproject/keccak256@npm:^5.7.0": version: 5.7.0 resolution: "@ethersproject/keccak256@npm:5.7.0" dependencies: @@ -984,14 +915,14 @@ __metadata: languageName: node linkType: hard -"@ethersproject/logger@npm:5.7.0, @ethersproject/logger@npm:^5.7.0": +"@ethersproject/logger@npm:^5.7.0": version: 5.7.0 resolution: "@ethersproject/logger@npm:5.7.0" checksum: 10/683a939f467ae7510deedc23d7611d0932c3046137f5ffb92ba1e3c8cd9cf2fbbaa676b660c248441a0fa9143783137c46d6e6d17d676188dd5a6ef0b72dd091 languageName: node linkType: hard -"@ethersproject/networks@npm:5.7.1, @ethersproject/networks@npm:^5.7.0": +"@ethersproject/networks@npm:^5.7.0": version: 5.7.1 resolution: "@ethersproject/networks@npm:5.7.1" dependencies: @@ -1000,17 +931,7 @@ __metadata: languageName: node linkType: hard -"@ethersproject/pbkdf2@npm:5.7.0, @ethersproject/pbkdf2@npm:^5.7.0": - version: 5.7.0 - resolution: "@ethersproject/pbkdf2@npm:5.7.0" - dependencies: - "@ethersproject/bytes": "npm:^5.7.0" - "@ethersproject/sha2": "npm:^5.7.0" - checksum: 10/dea7ba747805e24b81dfb99e695eb329509bf5cad1a42e48475ade28e060e567458a3d5bf930f302691bded733fd3fa364f0c7adce920f9f05a5ef8c13267aaa - languageName: node - linkType: hard - -"@ethersproject/properties@npm:5.7.0, @ethersproject/properties@npm:^5.7.0": +"@ethersproject/properties@npm:^5.7.0": version: 5.7.0 resolution: "@ethersproject/properties@npm:5.7.0" dependencies: @@ -1019,45 +940,7 @@ __metadata: languageName: node linkType: hard -"@ethersproject/providers@npm:5.7.2": - version: 5.7.2 - resolution: "@ethersproject/providers@npm:5.7.2" - dependencies: - "@ethersproject/abstract-provider": "npm:^5.7.0" - "@ethersproject/abstract-signer": "npm:^5.7.0" - "@ethersproject/address": "npm:^5.7.0" - "@ethersproject/base64": "npm:^5.7.0" - "@ethersproject/basex": "npm:^5.7.0" - "@ethersproject/bignumber": "npm:^5.7.0" - "@ethersproject/bytes": "npm:^5.7.0" - "@ethersproject/constants": "npm:^5.7.0" - "@ethersproject/hash": "npm:^5.7.0" - "@ethersproject/logger": "npm:^5.7.0" - "@ethersproject/networks": "npm:^5.7.0" - "@ethersproject/properties": "npm:^5.7.0" - "@ethersproject/random": "npm:^5.7.0" - "@ethersproject/rlp": "npm:^5.7.0" - "@ethersproject/sha2": "npm:^5.7.0" - "@ethersproject/strings": "npm:^5.7.0" - "@ethersproject/transactions": "npm:^5.7.0" - "@ethersproject/web": "npm:^5.7.0" - bech32: "npm:1.1.4" - ws: "npm:7.4.6" - checksum: 10/8534a1896e61b9f0b66427a639df64a5fe76d0c08ec59b9f0cc64fdd1d0cc28d9fc3312838ae8d7817c8f5e2e76b7f228b689bc33d1cbb8e1b9517d4c4f678d8 - languageName: node - linkType: hard - -"@ethersproject/random@npm:5.7.0, @ethersproject/random@npm:^5.7.0": - version: 5.7.0 - resolution: "@ethersproject/random@npm:5.7.0" - dependencies: - "@ethersproject/bytes": "npm:^5.7.0" - "@ethersproject/logger": "npm:^5.7.0" - checksum: 10/c23ec447998ce1147651bd58816db4d12dbeb404f66a03d14a13e1edb439879bab18528e1fc46b931502903ac7b1c08ea61d6a86e621a6e060fa63d41aeed3ac - languageName: node - linkType: hard - -"@ethersproject/rlp@npm:5.7.0, @ethersproject/rlp@npm:^5.7.0": +"@ethersproject/rlp@npm:^5.7.0": version: 5.7.0 resolution: "@ethersproject/rlp@npm:5.7.0" dependencies: @@ -1067,18 +950,7 @@ __metadata: languageName: node linkType: hard -"@ethersproject/sha2@npm:5.7.0, @ethersproject/sha2@npm:^5.7.0": - version: 5.7.0 - resolution: "@ethersproject/sha2@npm:5.7.0" - dependencies: - "@ethersproject/bytes": "npm:^5.7.0" - "@ethersproject/logger": "npm:^5.7.0" - hash.js: "npm:1.1.7" - checksum: 10/09321057c022effbff4cc2d9b9558228690b5dd916329d75c4b1ffe32ba3d24b480a367a7cc92d0f0c0b1c896814d03351ae4630e2f1f7160be2bcfbde435dbc - languageName: node - linkType: hard - -"@ethersproject/signing-key@npm:5.7.0, @ethersproject/signing-key@npm:^5.7.0": +"@ethersproject/signing-key@npm:^5.7.0": version: 5.7.0 resolution: "@ethersproject/signing-key@npm:5.7.0" dependencies: @@ -1092,21 +964,7 @@ __metadata: languageName: node linkType: hard -"@ethersproject/solidity@npm:5.7.0": - version: 5.7.0 - resolution: "@ethersproject/solidity@npm:5.7.0" - dependencies: - "@ethersproject/bignumber": "npm:^5.7.0" - "@ethersproject/bytes": "npm:^5.7.0" - "@ethersproject/keccak256": "npm:^5.7.0" - "@ethersproject/logger": "npm:^5.7.0" - "@ethersproject/sha2": "npm:^5.7.0" - "@ethersproject/strings": "npm:^5.7.0" - checksum: 10/9a02f37f801c96068c3e7721f83719d060175bc4e80439fe060e92bd7acfcb6ac1330c7e71c49f4c2535ca1308f2acdcb01e00133129aac00581724c2d6293f3 - languageName: node - linkType: hard - -"@ethersproject/strings@npm:5.7.0, @ethersproject/strings@npm:^5.7.0": +"@ethersproject/strings@npm:^5.7.0": version: 5.7.0 resolution: "@ethersproject/strings@npm:5.7.0" dependencies: @@ -1117,7 +975,7 @@ __metadata: languageName: node linkType: hard -"@ethersproject/transactions@npm:5.7.0, @ethersproject/transactions@npm:^5.6.2, @ethersproject/transactions@npm:^5.7.0": +"@ethersproject/transactions@npm:^5.6.2, @ethersproject/transactions@npm:^5.7.0": version: 5.7.0 resolution: "@ethersproject/transactions@npm:5.7.0" dependencies: @@ -1134,41 +992,7 @@ __metadata: languageName: node linkType: hard -"@ethersproject/units@npm:5.7.0": - version: 5.7.0 - resolution: "@ethersproject/units@npm:5.7.0" - dependencies: - "@ethersproject/bignumber": "npm:^5.7.0" - "@ethersproject/constants": "npm:^5.7.0" - "@ethersproject/logger": "npm:^5.7.0" - checksum: 10/304714f848cd32e57df31bf545f7ad35c2a72adae957198b28cbc62166daa929322a07bff6e9c9ac4577ab6aa0de0546b065ed1b2d20b19e25748b7d475cb0fc - languageName: node - linkType: hard - -"@ethersproject/wallet@npm:5.7.0": - version: 5.7.0 - resolution: "@ethersproject/wallet@npm:5.7.0" - dependencies: - "@ethersproject/abstract-provider": "npm:^5.7.0" - "@ethersproject/abstract-signer": "npm:^5.7.0" - "@ethersproject/address": "npm:^5.7.0" - "@ethersproject/bignumber": "npm:^5.7.0" - "@ethersproject/bytes": "npm:^5.7.0" - "@ethersproject/hash": "npm:^5.7.0" - "@ethersproject/hdnode": "npm:^5.7.0" - "@ethersproject/json-wallets": "npm:^5.7.0" - "@ethersproject/keccak256": "npm:^5.7.0" - "@ethersproject/logger": "npm:^5.7.0" - "@ethersproject/properties": "npm:^5.7.0" - "@ethersproject/random": "npm:^5.7.0" - "@ethersproject/signing-key": "npm:^5.7.0" - "@ethersproject/transactions": "npm:^5.7.0" - "@ethersproject/wordlists": "npm:^5.7.0" - checksum: 10/340f8e5c77c6c47c4d1596c200d97c53c1d4b4eb54d9166d0f2a114cb81685e7689255b0627e917fbcdc29cb54c4bd1f1a9909f3096ef9dff9acc0b24972f1c1 - languageName: node - linkType: hard - -"@ethersproject/web@npm:5.7.1, @ethersproject/web@npm:^5.7.0": +"@ethersproject/web@npm:^5.7.0": version: 5.7.1 resolution: "@ethersproject/web@npm:5.7.1" dependencies: @@ -1181,19 +1005,6 @@ __metadata: languageName: node linkType: hard -"@ethersproject/wordlists@npm:5.7.0, @ethersproject/wordlists@npm:^5.7.0": - version: 5.7.0 - resolution: "@ethersproject/wordlists@npm:5.7.0" - dependencies: - "@ethersproject/bytes": "npm:^5.7.0" - "@ethersproject/hash": "npm:^5.7.0" - "@ethersproject/logger": "npm:^5.7.0" - "@ethersproject/properties": "npm:^5.7.0" - "@ethersproject/strings": "npm:^5.7.0" - checksum: 10/737fca67ad743a32020f50f5b9e147e5683cfba2692367c1124a5a5538be78515865257b426ec9141daac91a70295e5e21bef7a193b79fe745f1be378562ccaa - languageName: node - linkType: hard - "@fastify/busboy@npm:^2.0.0": version: 2.1.1 resolution: "@fastify/busboy@npm:2.1.1" @@ -2006,91 +1817,6 @@ __metadata: languageName: node linkType: hard -"@nomicfoundation/hardhat-chai-matchers@npm:^2.0.3": - version: 2.0.6 - resolution: "@nomicfoundation/hardhat-chai-matchers@npm:2.0.6" - dependencies: - "@types/chai-as-promised": "npm:^7.1.3" - chai-as-promised: "npm:^7.1.1" - deep-eql: "npm:^4.0.1" - ordinal: "npm:^1.0.3" - peerDependencies: - "@nomicfoundation/hardhat-ethers": ^3.0.0 - chai: ^4.2.0 - ethers: ^6.1.0 - hardhat: ^2.9.4 - checksum: 10/7ab908eddd51f63cda7709ec36beab9a7876d570f0708b68b8541160eeb1f54b8c9665e136661c5ee0d5d06060e909605341fff3f2c7b92ee671f951846bf203 - languageName: node - linkType: hard - -"@nomicfoundation/hardhat-ethers@npm:^3.0.0": - version: 3.0.5 - resolution: "@nomicfoundation/hardhat-ethers@npm:3.0.5" - dependencies: - debug: "npm:^4.1.1" - lodash.isequal: "npm:^4.5.0" - peerDependencies: - ethers: ^6.1.0 - hardhat: ^2.0.0 - checksum: 10/666101fe903923dda54e6f0c87946468e33d614b8b8ff6678b9507a753fcdb6b053d3b785ecb3964102f513d3fd9dcfaa22b39de6afe6f4df2400483e9c54850 - languageName: node - linkType: hard - -"@nomicfoundation/hardhat-network-helpers@npm:^1.0.0": - version: 1.0.10 - resolution: "@nomicfoundation/hardhat-network-helpers@npm:1.0.10" - dependencies: - ethereumjs-util: "npm:^7.1.4" - peerDependencies: - hardhat: ^2.9.5 - checksum: 10/38953777f69fea6c82a6df0f5de5c52afd797aae9d9d38d710dc19a4a0ef6bba2b4320db6050e04e94fb4bb0ce4cf81a2911a4da5097e0ca6fc1017ca77c3bb9 - languageName: node - linkType: hard - -"@nomicfoundation/hardhat-toolbox@npm:^4.0.0": - version: 4.0.0 - resolution: "@nomicfoundation/hardhat-toolbox@npm:4.0.0" - peerDependencies: - "@nomicfoundation/hardhat-chai-matchers": ^2.0.0 - "@nomicfoundation/hardhat-ethers": ^3.0.0 - "@nomicfoundation/hardhat-network-helpers": ^1.0.0 - "@nomicfoundation/hardhat-verify": ^2.0.0 - "@typechain/ethers-v6": ^0.5.0 - "@typechain/hardhat": ^9.0.0 - "@types/chai": ^4.2.0 - "@types/mocha": ">=9.1.0" - "@types/node": ">=16.0.0" - chai: ^4.2.0 - ethers: ^6.4.0 - hardhat: ^2.11.0 - hardhat-gas-reporter: ^1.0.8 - solidity-coverage: ^0.8.1 - ts-node: ">=8.0.0" - typechain: ^8.3.0 - typescript: ">=4.5.0" - checksum: 10/a563cb50bd86a740b47864398277f21d6ee89c16737c849265b868381025f412fddbab579ff592ac4e9feddd807b9f72435f72a93766a9a153d6c538844b43a7 - languageName: node - linkType: hard - -"@nomicfoundation/hardhat-verify@npm:^2.0.0": - version: 2.0.6 - resolution: "@nomicfoundation/hardhat-verify@npm:2.0.6" - dependencies: - "@ethersproject/abi": "npm:^5.1.2" - "@ethersproject/address": "npm:^5.0.2" - cbor: "npm:^8.1.0" - chalk: "npm:^2.4.2" - debug: "npm:^4.1.1" - lodash.clonedeep: "npm:^4.5.0" - semver: "npm:^6.3.0" - table: "npm:^6.8.0" - undici: "npm:^5.14.0" - peerDependencies: - hardhat: ^2.0.4 - checksum: 10/70f6cc1337a057d97b443d06475072cece2e28e1df41536041abfdaedf468cffb286fd8a3551ddb1e750d549f049aa96117c1a6af7d769d243ad9ba70973573d - languageName: node - linkType: hard - "@nomicfoundation/solidity-analyzer-darwin-arm64@npm:0.1.1": version: 0.1.1 resolution: "@nomicfoundation/solidity-analyzer-darwin-arm64@npm:0.1.1" @@ -2246,15 +1972,6 @@ __metadata: languageName: node linkType: hard -"@prettier/sync@npm:^0.3.0": - version: 0.3.0 - resolution: "@prettier/sync@npm:0.3.0" - peerDependencies: - prettier: ^3.0.0 - checksum: 10/10520d2479830c18256bf2b18349a15a8964f968059f7ccaa1f6d455c133a26e6c96bd7aea7c64ef6701700e8007ad68619b16ec83391b356b5d4a741cbae504 - languageName: node - linkType: hard - "@rollup/plugin-alias@npm:^5.1.0": version: 5.1.0 resolution: "@rollup/plugin-alias@npm:5.1.0" @@ -2372,18 +2089,6 @@ __metadata: languageName: node linkType: hard -"@rollup/plugin-virtual@npm:^3.0.2": - version: 3.0.2 - resolution: "@rollup/plugin-virtual@npm:3.0.2" - peerDependencies: - rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0 - peerDependenciesMeta: - rollup: - optional: true - checksum: 10/962bc9efece57a07c328a3d093bd1a62b9b4396a88640ac79cfc04181e06b31c4b37726ca27ded71178ace27db9b0085b43c4de823378773bb44cb233ea1340e - languageName: node - linkType: hard - "@rollup/pluginutils@npm:^5.0.1, @rollup/pluginutils@npm:^5.1.0": version: 5.1.0 resolution: "@rollup/pluginutils@npm:5.1.0" @@ -2693,38 +2398,6 @@ __metadata: languageName: node linkType: hard -"@solidity-parser/parser@npm:^0.14.0": - version: 0.14.5 - resolution: "@solidity-parser/parser@npm:0.14.5" - dependencies: - antlr4ts: "npm:^0.5.0-alpha.4" - checksum: 10/5ceb5601cf0b65cfcea86adf3efa3918cc377fff50cec361a3a0987de6c1ec79c5b5c4be8cc67df55d5a26f3243b35813a71f3d2e26f258fb38ce8158be97ea6 - languageName: node - linkType: hard - -"@solidity-parser/parser@npm:^0.16.0": - version: 0.16.2 - resolution: "@solidity-parser/parser@npm:0.16.2" - dependencies: - antlr4ts: "npm:^0.5.0-alpha.4" - checksum: 10/a95b0c45331623e587e938e69d49832814ab8867371bd58f9946346b99a18705ee47b98a1006c3da6dae33ec8c8c1bf7d203a4acfa1ced0bfd68632acf2cd19c - languageName: node - linkType: hard - -"@solidity-parser/parser@npm:^0.17.0": - version: 0.17.0 - resolution: "@solidity-parser/parser@npm:0.17.0" - checksum: 10/76de7d1268de676c101b9a41576c324c0d0b9699e3ba3d846b5e580d6cae454fd7ec088011c316ce18af1b23a1482da88768d30f0e41becfd9da90f692fb9a65 - languageName: node - linkType: hard - -"@solidity-parser/parser@npm:^0.18.0": - version: 0.18.0 - resolution: "@solidity-parser/parser@npm:0.18.0" - checksum: 10/3b600b584f49bd84d6d27aeeb453c49c279df49324e104bda00d12cd3b26f18cb6230ff63db6a0ba1f383868620d318b15b7417a92aa8c580099449adaa13d76 - languageName: node - linkType: hard - "@szmarczak/http-timer@npm:^4.0.5": version: 4.0.6 resolution: "@szmarczak/http-timer@npm:4.0.6" @@ -2778,34 +2451,6 @@ __metadata: languageName: node linkType: hard -"@typechain/ethers-v6@npm:^0.5.0": - version: 0.5.1 - resolution: "@typechain/ethers-v6@npm:0.5.1" - dependencies: - lodash: "npm:^4.17.15" - ts-essentials: "npm:^7.0.1" - peerDependencies: - ethers: 6.x - typechain: ^8.3.2 - typescript: ">=4.7.0" - checksum: 10/51dd8be3548fe3c061d2a5372beb9214e767e2b69f10c12424b699bba7ff409a13c4bdff2e513ef49046b51153db56489752205541be8fb1775f3b9ad884b85b - languageName: node - linkType: hard - -"@typechain/hardhat@npm:^9.0.0": - version: 9.1.0 - resolution: "@typechain/hardhat@npm:9.1.0" - dependencies: - fs-extra: "npm:^9.1.0" - peerDependencies: - "@typechain/ethers-v6": ^0.5.1 - ethers: ^6.1.0 - hardhat: ^2.9.9 - typechain: ^8.3.2 - checksum: 10/1f59d8243af020905f3cdb96125cf9fcad33bd16f919d5e07762c63e0220bccb658abf59b0ad74be784a3387c0a6b0262612fa1adeb9f6c99061a6abaa6afc53 - languageName: node - linkType: hard - "@types/babel__core@npm:^7.0.0, @types/babel__core@npm:^7.1.14, @types/babel__core@npm:^7.1.7": version: 7.20.5 resolution: "@types/babel__core@npm:7.20.5" @@ -2877,31 +2522,6 @@ __metadata: languageName: node linkType: hard -"@types/chai-as-promised@npm:^7.1.3": - version: 7.1.8 - resolution: "@types/chai-as-promised@npm:7.1.8" - dependencies: - "@types/chai": "npm:*" - checksum: 10/88e2d42f14d1de19ba1c7b5c35f263fef37d3ad241c71f5eb59b10763706f3902f4131b93854c9c6ed520081c7e36be555849f202418357f905bea71178b7d02 - languageName: node - linkType: hard - -"@types/chai@npm:*, @types/chai@npm:^4.2.0": - version: 4.3.14 - resolution: "@types/chai@npm:4.3.14" - checksum: 10/300be72bb22657c1e449b27a5f0ab24405edf3be5c42ea0095f8e1c6daabc29c3028eee2421cc443c01a098da47ba32baecc363be7324433132281b9d9a8216f - languageName: node - linkType: hard - -"@types/concat-stream@npm:^1.6.0": - version: 1.6.1 - resolution: "@types/concat-stream@npm:1.6.1" - dependencies: - "@types/node": "npm:*" - checksum: 10/7d211e74331affd3578b5469244f5cef84a93775f38332adb3ef12413559a23862bc682c6873d0a404b01c9d5d5f7d3ae091fe835b435b633eb420e3055b3e56 - languageName: node - linkType: hard - "@types/crypto-js@npm:^4.1.1": version: 4.2.2 resolution: "@types/crypto-js@npm:4.2.2" @@ -2936,16 +2556,7 @@ __metadata: languageName: node linkType: hard -"@types/form-data@npm:0.0.33": - version: 0.0.33 - resolution: "@types/form-data@npm:0.0.33" - dependencies: - "@types/node": "npm:*" - checksum: 10/f0c7437e9dd7b348cf7de772bf9c5ad810ecaec767b9199cfc600f4929d600212b52d1acd5a1c674e1ceec5e063cb4d9ce96c8e479aea8dacd56371e04aab836 - languageName: node - linkType: hard - -"@types/glob@npm:^7.1.1, @types/glob@npm:^7.2.0": +"@types/glob@npm:^7.2.0": version: 7.2.0 resolution: "@types/glob@npm:7.2.0" dependencies: @@ -3071,14 +2682,7 @@ __metadata: languageName: node linkType: hard -"@types/mocha@npm:^10.0.6": - version: 10.0.6 - resolution: "@types/mocha@npm:10.0.6" - checksum: 10/fc73626e81e89c32d06b7ff9b72c4177b46d579cdd932f796614adc026852d84cb849d743473ba572cb4d9ea6d8c04e3749552d326c26495ec1c4b46e6e0a0c0 - languageName: node - linkType: hard - -"@types/node@npm:*, @types/node@npm:^20, @types/node@npm:^20.10.7": +"@types/node@npm:*, @types/node@npm:^20": version: 20.12.7 resolution: "@types/node@npm:20.12.7" dependencies: @@ -3094,13 +2698,6 @@ __metadata: languageName: node linkType: hard -"@types/node@npm:^10.0.3": - version: 10.17.60 - resolution: "@types/node@npm:10.17.60" - checksum: 10/f9161493b3284b1d41d5d594c2768625acdd9e33f992f71ccde47861916e662e2ae438d2cc5f1b285053391a31b52a7564ecedc22d485610d236bfad9c7e6a1c - languageName: node - linkType: hard - "@types/node@npm:^12.12.6": version: 12.20.55 resolution: "@types/node@npm:12.20.55" @@ -3115,13 +2712,6 @@ __metadata: languageName: node linkType: hard -"@types/node@npm:^8.0.0": - version: 8.10.66 - resolution: "@types/node@npm:8.10.66" - checksum: 10/49a93cbeeca74e247970b5c2130abe8204587b6d3c5ec259543e7511234e5fa340341668155807ade7a86c22dab1ec8ee18c0ac745e4d54679de1b2dabd99363 - languageName: node - linkType: hard - "@types/normalize-package-data@npm:^2.4.0": version: 2.4.4 resolution: "@types/normalize-package-data@npm:2.4.4" @@ -3138,20 +2728,13 @@ __metadata: languageName: node linkType: hard -"@types/prettier@npm:^2.0.0, @types/prettier@npm:^2.1.1": +"@types/prettier@npm:^2.0.0": version: 2.7.3 resolution: "@types/prettier@npm:2.7.3" checksum: 10/cda84c19acc3bf327545b1ce71114a7d08efbd67b5030b9e8277b347fa57b05178045f70debe1d363ff7efdae62f237260713aafc2d7217e06fc99b048a88497 languageName: node linkType: hard -"@types/qs@npm:^6.2.31": - version: 6.9.15 - resolution: "@types/qs@npm:6.9.15" - checksum: 10/97d8208c2b82013b618e7a9fc14df6bd40a73e1385ac479b6896bafc7949a46201c15f42afd06e86a05e914f146f495f606b6fb65610cc60cf2e0ff743ec38a2 - languageName: node - linkType: hard - "@types/resolve@npm:1.20.2": version: 1.20.2 resolution: "@types/resolve@npm:1.20.2" @@ -3484,32 +3067,6 @@ __metadata: languageName: unknown linkType: soft -"@zk-kit/groth16@workspace:packages/groth16": - version: 0.0.0-use.local - resolution: "@zk-kit/groth16@workspace:packages/groth16" - dependencies: - "@iden3/binfileutils": "npm:0.0.11" - "@rollup/plugin-commonjs": "npm:^25.0.7" - "@rollup/plugin-node-resolve": "npm:^15.2.3" - "@rollup/plugin-typescript": "npm:^11.1.6" - "@rollup/plugin-virtual": "npm:^3.0.2" - circom_runtime: "npm:0.1.24" - fastfile: "npm:0.0.20" - ffjavascript: "npm:0.2.62" - rimraf: "npm:^5.0.5" - rollup: "npm:^4.12.0" - rollup-plugin-cleanup: "npm:^3.2.1" - languageName: unknown - linkType: soft - -"@zk-kit/imt.sol@workspace:packages/imt.sol/contracts": - version: 0.0.0-use.local - resolution: "@zk-kit/imt.sol@workspace:packages/imt.sol/contracts" - dependencies: - poseidon-solidity: "npm:0.0.5" - languageName: unknown - linkType: soft - "@zk-kit/imt@workspace:packages/imt": version: 0.0.0-use.local resolution: "@zk-kit/imt@workspace:packages/imt" @@ -3527,14 +3084,6 @@ __metadata: languageName: unknown linkType: soft -"@zk-kit/lazytower.sol@workspace:packages/lazytower.sol/contracts": - version: 0.0.0-use.local - resolution: "@zk-kit/lazytower.sol@workspace:packages/lazytower.sol/contracts" - dependencies: - poseidon-solidity: "npm:0.0.5" - languageName: unknown - linkType: soft - "@zk-kit/lazytower@workspace:packages/lazytower": version: 0.0.0-use.local resolution: "@zk-kit/lazytower@workspace:packages/lazytower" @@ -3592,6 +3141,7 @@ __metadata: "@types/tmp": "npm:^0.2.6" "@zk-kit/utils": "npm:1.0.0-beta.4" ethers: "npm:^6.12.0" + ffjavascript: "npm:^0.3.0" poseidon-lite: "npm:^0.2.0" rimraf: "npm:^5.0.5" rollup: "npm:^4.12.0" @@ -3600,25 +3150,11 @@ __metadata: languageName: unknown linkType: soft -"@zk-kit/rollup-plugin-rust@workspace:packages/rollup-plugin-rust": - version: 0.0.0-use.local - resolution: "@zk-kit/rollup-plugin-rust@workspace:packages/rollup-plugin-rust" - dependencies: - "@rollup/plugin-typescript": "npm:^11.1.6" - glob: "npm:^7.1.6" - rimraf: "npm:^5.0.5" - rollup: "npm:^4.12.0" - rollup-plugin-cleanup: "npm:^3.2.1" - rollup-pluginutils: "npm:^2.8.2" - toml: "npm:^3.0.0" - wasm-pack: "npm:^0.10.2" - languageName: unknown - linkType: soft - "@zk-kit/smt@workspace:packages/smt": version: 0.0.0-use.local resolution: "@zk-kit/smt@workspace:packages/smt" dependencies: + "@aztec/bb.js": "npm:^0.40.1" "@rollup/plugin-terser": "npm:^0.4.4" "@rollup/plugin-typescript": "npm:^11.1.6" "@types/crypto-js": "npm:^4.1.1" @@ -3665,20 +3201,6 @@ __metadata: languageName: node linkType: hard -"abbrev@npm:1": - version: 1.1.1 - resolution: "abbrev@npm:1.1.1" - checksum: 10/2d882941183c66aa665118bafdab82b7a177e9add5eb2776c33e960a4f3c89cff88a1b38aba13a456de01d0dd9d66a8bea7c903268b21ea91dd1097e1e2e8243 - languageName: node - linkType: hard - -"abbrev@npm:1.0.x": - version: 1.0.9 - resolution: "abbrev@npm:1.0.9" - checksum: 10/5ca5ac34c39d3ae15a90ce5570309e25c0e72d3947bdf95c10a1957f83609bf42831cb4b746d3d96b2a85a52b290832797b8a63b27449f47925b25ca86b78591 - languageName: node - linkType: hard - "abbrev@npm:^2.0.0": version: 2.0.0 resolution: "abbrev@npm:2.0.0" @@ -3761,13 +3283,6 @@ __metadata: languageName: node linkType: hard -"aes-js@npm:3.0.0": - version: 3.0.0 - resolution: "aes-js@npm:3.0.0" - checksum: 10/1b3772e5ba74abdccb6c6b99bf7f50b49057b38c0db1612b46c7024414f16e65ba7f1643b2d6e38490b1870bdf3ba1b87b35e2c831fd3fdaeff015f08aad19d1 - languageName: node - linkType: hard - "aes-js@npm:4.0.0-beta.5": version: 4.0.0-beta.5 resolution: "aes-js@npm:4.0.0-beta.5" @@ -3815,7 +3330,7 @@ __metadata: languageName: node linkType: hard -"ajv@npm:^6.12.3, ajv@npm:^6.12.4, ajv@npm:^6.12.6": +"ajv@npm:^6.12.3, ajv@npm:^6.12.4": version: 6.12.6 resolution: "ajv@npm:6.12.6" dependencies: @@ -3827,7 +3342,7 @@ __metadata: languageName: node linkType: hard -"ajv@npm:^8.0.1, ajv@npm:^8.11.0": +"ajv@npm:^8.11.0": version: 8.12.0 resolution: "ajv@npm:8.12.0" dependencies: @@ -3839,13 +3354,6 @@ __metadata: languageName: node linkType: hard -"amdefine@npm:>=0.0.4": - version: 1.0.1 - resolution: "amdefine@npm:1.0.1" - checksum: 10/517df65fc33d3ff14fe5c0057e041b03d603a2254dea7968b05dfbfa3041eb8430ea6729e305bc428c03fad03f162de91a4b256692d27d7b81d3ee691312cffe - languageName: node - linkType: hard - "ansi-align@npm:^3.0.0": version: 3.0.1 resolution: "ansi-align@npm:3.0.1" @@ -3945,22 +3453,6 @@ __metadata: languageName: node linkType: hard -"antlr4@npm:^4.11.0": - version: 4.13.1 - resolution: "antlr4@npm:4.13.1" - checksum: 10/b17ee045cf30c7cec563f3ce81dc8bffd2c17b546646cd76e7b5f4cc4b676a1960c1a8a9aea53769947b0c6de70ed2aea73431e76c3840ab3b69cf3de5f1fc89 - languageName: node - linkType: hard - -"antlr4ts@npm:^0.5.0-alpha.4": - version: 0.5.0-dev - resolution: "antlr4ts@npm:0.5.0-dev" - dependencies: - source-map-support: "npm:^0.5.16" - checksum: 10/a95a061fb2fc9e2a0cd065e112fbc3fb899f408feace51249367051711b2255488b4e89b5912a706080f807c72484499e0f61f6a782391ecaba39c556d479f55 - languageName: node - linkType: hard - "anymatch@npm:^2.0.0": version: 2.0.0 resolution: "anymatch@npm:2.0.0" @@ -4025,20 +3517,6 @@ __metadata: languageName: node linkType: hard -"array-back@npm:^3.0.1, array-back@npm:^3.1.0": - version: 3.1.0 - resolution: "array-back@npm:3.1.0" - checksum: 10/7205004fcd0f9edd926db921af901b083094608d5b265738d0290092f9822f73accb468e677db74c7c94ef432d39e5ed75a7b1786701e182efb25bbba9734209 - languageName: node - linkType: hard - -"array-back@npm:^4.0.1, array-back@npm:^4.0.2": - version: 4.0.2 - resolution: "array-back@npm:4.0.2" - checksum: 10/f30603270771eeb54e5aad5f54604c62b3577a18b6db212a7272b2b6c32049121b49431f656654790ed1469411e45f387e7627c0de8fd0515995cc40df9b9294 - languageName: node - linkType: hard - "array-buffer-byte-length@npm:^1.0.1": version: 1.0.1 resolution: "array-buffer-byte-length@npm:1.0.1" @@ -4084,13 +3562,6 @@ __metadata: languageName: node linkType: hard -"array-uniq@npm:1.0.3": - version: 1.0.3 - resolution: "array-uniq@npm:1.0.3" - checksum: 10/1625f06b093d8bf279b81adfec6e72951c0857d65b5e3f65f053fffe9f9dd61c2fc52cff57e38a4700817e7e3f01a4faa433d505ea9e33cdae4514c334e0bf9e - languageName: node - linkType: hard - "array-unique@npm:^0.3.2": version: 0.3.2 resolution: "array-unique@npm:0.3.2" @@ -4159,13 +3630,6 @@ __metadata: languageName: node linkType: hard -"asap@npm:~2.0.6": - version: 2.0.6 - resolution: "asap@npm:2.0.6" - checksum: 10/b244c0458c571945e4b3be0b14eb001bea5596f9868cc50cc711dc03d58a7e953517d3f0dad81ccde3ff37d1f074701fa76a6f07d41aaa992d7204a37b915dda - languageName: node - linkType: hard - "asn1@npm:~0.2.3": version: 0.2.6 resolution: "asn1@npm:0.2.6" @@ -4209,13 +3673,6 @@ __metadata: languageName: node linkType: hard -"ast-parents@npm:^0.0.1": - version: 0.0.1 - resolution: "ast-parents@npm:0.0.1" - checksum: 10/08eaa3b755529aad0708aad54ff09087b171334dcffa0774d3401e1dc54db1242bd5e76e599152705e813f768b9245a3c20777ed033c706d2093e358a91b12c2 - languageName: node - linkType: hard - "astral-regex@npm:^2.0.0": version: 2.0.0 resolution: "astral-regex@npm:2.0.0" @@ -4230,13 +3687,6 @@ __metadata: languageName: node linkType: hard -"async@npm:1.x": - version: 1.5.2 - resolution: "async@npm:1.5.2" - checksum: 10/8afcdcee05168250926a3e7bd4dfaa74b681a74f634bae2af424fb716042461cbd20a375d9bc2534daa50a2d45286c9b174952fb239cee4ab8d6351a40c65327 - languageName: node - linkType: hard - "async@npm:^3.2.3": version: 3.2.5 resolution: "async@npm:3.2.5" @@ -4251,13 +3701,6 @@ __metadata: languageName: node linkType: hard -"at-least-node@npm:^1.0.0": - version: 1.0.0 - resolution: "at-least-node@npm:1.0.0" - checksum: 10/463e2f8e43384f1afb54bc68485c436d7622acec08b6fad269b421cb1d29cebb5af751426793d0961ed243146fe4dc983402f6d5a51b720b277818dbf6f2e49e - languageName: node - linkType: hard - "atob@npm:^2.1.2": version: 2.1.2 resolution: "atob@npm:2.1.2" @@ -4299,17 +3742,6 @@ __metadata: languageName: node linkType: hard -"axios@npm:^1.5.1": - version: 1.6.8 - resolution: "axios@npm:1.6.8" - dependencies: - follow-redirects: "npm:^1.15.6" - form-data: "npm:^4.0.0" - proxy-from-env: "npm:^1.1.0" - checksum: 10/3f9a79eaf1d159544fca9576261ff867cbbff64ed30017848e4210e49f3b01e97cf416390150e6fdf6633f336cd43dc1151f890bbd09c3c01ad60bb0891eee63 - languageName: node - linkType: hard - "b4a@npm:^1.0.1": version: 1.6.6 resolution: "b4a@npm:1.6.6" @@ -4482,13 +3914,6 @@ __metadata: languageName: node linkType: hard -"bech32@npm:1.1.4": - version: 1.1.4 - resolution: "bech32@npm:1.1.4" - checksum: 10/63ff37c0ce43be914c685ce89700bba1589c319af0dac1ea04f51b33d0e5ecfd40d14c24f527350b94f0a4e236385373bb9122ec276410f354ddcdbf29ca13f4 - languageName: node - linkType: hard - "benchmark@npm:^2.1.4": version: 2.1.4 resolution: "benchmark@npm:2.1.4" @@ -4550,17 +3975,6 @@ __metadata: languageName: node linkType: hard -"binary-install@npm:^0.1.0": - version: 0.1.1 - resolution: "binary-install@npm:0.1.1" - dependencies: - axios: "npm:^0.21.1" - rimraf: "npm:^3.0.2" - tar: "npm:^6.1.0" - checksum: 10/a3df9c07a3ab81533cff610527263181c4c34a44efb115555be910b6011ac047bf875ad57469cc2259dfaba58e971c7ba2958038e9d222c546eef7b58b826ecc - languageName: node - linkType: hard - "bindings@npm:^1.2.1": version: 1.5.0 resolution: "bindings@npm:1.5.0" @@ -5088,33 +4502,13 @@ __metadata: languageName: node linkType: hard -"caseless@npm:^0.12.0, caseless@npm:~0.12.0": +"caseless@npm:~0.12.0": version: 0.12.0 resolution: "caseless@npm:0.12.0" checksum: 10/ea1efdf430975fdbac3505cdd21007f7ac5aa29b6d4d1c091f965853cd1bf87e4b08ea07b31a6d688b038872b7cdf0589d9262d59c699d199585daad052aeb20 languageName: node linkType: hard -"cbor@npm:^8.1.0": - version: 8.1.0 - resolution: "cbor@npm:8.1.0" - dependencies: - nofilter: "npm:^3.1.0" - checksum: 10/fc6c6d4f8d14def3a0f2ef111f4fc14b3b0bc91d22ed8fd0eb005095c4699c723a45721e515d713571148d0d965ceeb771f4ad422953cb4e9658b379991b52c9 - languageName: node - linkType: hard - -"chai-as-promised@npm:^7.1.1": - version: 7.1.1 - resolution: "chai-as-promised@npm:7.1.1" - dependencies: - check-error: "npm:^1.0.2" - peerDependencies: - chai: ">= 2.1.2 < 5" - checksum: 10/5d9ecab37b313047f5ea25d00b1cb6e7f2710c6e2f57d91aed7cfed5008d995cb65ea723af4e5d782bafd9a6eff5a4267af53dfe7212dc10dd1d92b9127bc531 - languageName: node - linkType: hard - "chai@npm:^4.2.0": version: 4.4.1 resolution: "chai@npm:4.4.1" @@ -5148,7 +4542,7 @@ __metadata: languageName: node linkType: hard -"chalk@npm:^4.0.0, chalk@npm:^4.0.2, chalk@npm:^4.1.0, chalk@npm:^4.1.2": +"chalk@npm:^4.0.0, chalk@npm:^4.0.2, chalk@npm:^4.1.0": version: 4.1.2 resolution: "chalk@npm:4.1.2" dependencies: @@ -5226,14 +4620,7 @@ __metadata: languageName: node linkType: hard -"charenc@npm:>= 0.0.1": - version: 0.0.2 - resolution: "charenc@npm:0.0.2" - checksum: 10/81dcadbe57e861d527faf6dd3855dc857395a1c4d6781f4847288ab23cffb7b3ee80d57c15bba7252ffe3e5e8019db767757ee7975663ad2ca0939bb8fcaf2e5 - languageName: node - linkType: hard - -"check-error@npm:^1.0.2, check-error@npm:^1.0.3": +"check-error@npm:^1.0.3": version: 1.0.3 resolution: "check-error@npm:1.0.3" dependencies: @@ -5603,20 +4990,6 @@ __metadata: languageName: node linkType: hard -"cli-table3@npm:^0.5.0": - version: 0.5.1 - resolution: "cli-table3@npm:0.5.1" - dependencies: - colors: "npm:^1.1.2" - object-assign: "npm:^4.1.0" - string-width: "npm:^2.1.1" - dependenciesMeta: - colors: - optional: true - checksum: 10/5b4aaa81943c9030e3366aaf20cc4be0792397d82dea3a1660e80ce49edded4dcc722f9bf272354061c5bfa3f4236ad2fdc86bc7bb0bbf7e4b8e8d3b418b955a - languageName: node - linkType: hard - "cli-table3@npm:^0.6.0": version: 0.6.4 resolution: "cli-table3@npm:0.6.4" @@ -5757,13 +5130,6 @@ __metadata: languageName: node linkType: hard -"colors@npm:1.4.0, colors@npm:^1.1.2": - version: 1.4.0 - resolution: "colors@npm:1.4.0" - checksum: 10/90b2d5465159813a3983ea72ca8cff75f784824ad70f2cc2b32c233e95bcfbcda101ebc6d6766bc50f57263792629bfb4f1f8a4dfbd1d240f229fc7f69b785fc - languageName: node - linkType: hard - "combined-stream@npm:^1.0.6, combined-stream@npm:^1.0.8, combined-stream@npm:~1.0.6": version: 1.0.8 resolution: "combined-stream@npm:1.0.8" @@ -5787,30 +5153,6 @@ __metadata: languageName: node linkType: hard -"command-line-args@npm:^5.1.1": - version: 5.2.1 - resolution: "command-line-args@npm:5.2.1" - dependencies: - array-back: "npm:^3.1.0" - find-replace: "npm:^3.0.0" - lodash.camelcase: "npm:^4.3.0" - typical: "npm:^4.0.0" - checksum: 10/e6a42652ae8843fbb56e2fba1e85da00a16a0482896bb1849092e1bc70b8bf353d945e69732bf4ae98370ff84e8910ff4933af8f2f747806a6b2cb5074799fdb - languageName: node - linkType: hard - -"command-line-usage@npm:^6.1.0": - version: 6.1.3 - resolution: "command-line-usage@npm:6.1.3" - dependencies: - array-back: "npm:^4.0.2" - chalk: "npm:^2.4.2" - table-layout: "npm:^1.0.2" - typical: "npm:^5.2.0" - checksum: 10/902901582a543b26f55f90fc0f266c08a603a92bfadd8d07c66679f3d9eea2c074a039404126b0c4b65ff8452153c5f2010ea2f4ec14b70be0c77241f6d5bd53 - languageName: node - linkType: hard - "commander@npm:11.1.0": version: 11.1.0 resolution: "commander@npm:11.1.0" @@ -5825,7 +5167,7 @@ __metadata: languageName: node linkType: hard -"commander@npm:^10.0.0, commander@npm:^10.0.1": +"commander@npm:^10.0.1": version: 10.0.1 resolution: "commander@npm:10.0.1" checksum: 10/8799faa84a30da985802e661cc9856adfaee324d4b138413013ef7f087e8d7924b144c30a1f1405475f0909f467665cd9e1ce13270a2f41b141dab0b7a58f3fb @@ -5884,18 +5226,6 @@ __metadata: languageName: node linkType: hard -"concat-stream@npm:^1.6.0, concat-stream@npm:^1.6.2": - version: 1.6.2 - resolution: "concat-stream@npm:1.6.2" - dependencies: - buffer-from: "npm:^1.0.0" - inherits: "npm:^2.0.3" - readable-stream: "npm:^2.2.2" - typedarray: "npm:^0.0.6" - checksum: 10/71db903c84fc073ca35a274074e8d26c4330713d299f8623e993c448c1f6bf8b967806dd1d1a7b0f8add6f15ab1af7435df21fe79b4fe7efd78420c89e054e28 - languageName: node - linkType: hard - "confbox@npm:^0.1.3, confbox@npm:^0.1.7": version: 0.1.7 resolution: "confbox@npm:0.1.7" @@ -6063,13 +5393,6 @@ __metadata: languageName: node linkType: hard -"core-util-is@npm:~1.0.0": - version: 1.0.3 - resolution: "core-util-is@npm:1.0.3" - checksum: 10/9de8597363a8e9b9952491ebe18167e3b36e7707569eed0ebf14f8bba773611376466ae34575bca8cfe3c767890c859c74056084738f09d4e4a6f902b2ad7d99 - languageName: node - linkType: hard - "cors@npm:^2.8.1": version: 2.8.5 resolution: "cors@npm:2.8.5" @@ -6093,7 +5416,7 @@ __metadata: languageName: node linkType: hard -"cosmiconfig@npm:^8.0.0, cosmiconfig@npm:^8.3.6": +"cosmiconfig@npm:^8.3.6": version: 8.3.6 resolution: "cosmiconfig@npm:8.3.6" dependencies: @@ -6203,13 +5526,6 @@ __metadata: languageName: node linkType: hard -"crypt@npm:>= 0.0.1": - version: 0.0.2 - resolution: "crypt@npm:0.0.2" - checksum: 10/2c72768de3d28278c7c9ffd81a298b26f87ecdfe94415084f339e6632f089b43fe039f2c93f612bcb5ffe447238373d93b2e8c90894cba6cfb0ac7a74616f8b9 - languageName: node - linkType: hard - "crypto-js@npm:^4.1.1": version: 4.2.0 resolution: "crypto-js@npm:4.2.0" @@ -6323,14 +5639,7 @@ __metadata: call-bind: "npm:^1.0.6" es-errors: "npm:^1.3.0" is-data-view: "npm:^1.0.1" - checksum: 10/96f34f151bf02affb7b9f98762fb7aca1dd5f4553cb57b80bce750ca609c15d33ca659568ef1d422f7e35680736cbccb893a3d4b012760c758c1446bbdc4c6db - languageName: node - linkType: hard - -"death@npm:^1.1.0": - version: 1.1.0 - resolution: "death@npm:1.1.0" - checksum: 10/b6fc4d1b8fbfc84486a025d36c540795c5ae9368f580a31fc2740935d0a9afbd31a214b00650335e97756f4c1a3fae895adc45795aeb9ef00694968311ab844d + checksum: 10/96f34f151bf02affb7b9f98762fb7aca1dd5f4553cb57b80bce750ca609c15d33ca659568ef1d422f7e35680736cbccb893a3d4b012760c758c1446bbdc4c6db languageName: node linkType: hard @@ -6444,7 +5753,7 @@ __metadata: languageName: node linkType: hard -"deep-eql@npm:^4.0.1, deep-eql@npm:^4.1.3": +"deep-eql@npm:^4.1.3": version: 4.1.3 resolution: "deep-eql@npm:4.1.3" dependencies: @@ -6460,13 +5769,6 @@ __metadata: languageName: node linkType: hard -"deep-extend@npm:~0.6.0": - version: 0.6.0 - resolution: "deep-extend@npm:0.6.0" - checksum: 10/7be7e5a8d468d6b10e6a67c3de828f55001b6eb515d014f7aeb9066ce36bd5717161eb47d6a0f7bed8a9083935b465bc163ee2581c8b128d29bf61092fdf57a7 - languageName: node - linkType: hard - "deep-is@npm:^0.1.3, deep-is@npm:~0.1.3": version: 0.1.4 resolution: "deep-is@npm:0.1.4" @@ -6651,15 +5953,6 @@ __metadata: languageName: node linkType: hard -"difflib@npm:^0.2.4": - version: 0.2.4 - resolution: "difflib@npm:0.2.4" - dependencies: - heap: "npm:>= 0.2.0" - checksum: 10/35c09c9469f762b72703a1eee4bd7bae6227fac96cef4605cd00f0ab3773b547584aefd2c5224f85c5b1701f0e8cedebd45afbb853b01d1d44863b4720cfcd35 - languageName: node - linkType: hard - "dir-glob@npm:^3.0.1": version: 3.0.1 resolution: "dir-glob@npm:3.0.1" @@ -7076,25 +6369,6 @@ __metadata: languageName: node linkType: hard -"escodegen@npm:1.8.x": - version: 1.8.1 - resolution: "escodegen@npm:1.8.1" - dependencies: - esprima: "npm:^2.7.1" - estraverse: "npm:^1.9.1" - esutils: "npm:^2.0.2" - optionator: "npm:^0.8.1" - source-map: "npm:~0.2.0" - dependenciesMeta: - source-map: - optional: true - bin: - escodegen: ./bin/escodegen.js - esgenerate: ./bin/esgenerate.js - checksum: 10/f7c4f9639f4198848784548f268bb4bbd55f1a12344af79ea4a8978168c2009b0bfc1047dece1e0fdca4ff539fe9dffb0b4183ecab22ab91dea88328487da86a - languageName: node - linkType: hard - "escodegen@npm:^1.8.1": version: 1.14.3 resolution: "escodegen@npm:1.14.3" @@ -7348,16 +6622,6 @@ __metadata: languageName: node linkType: hard -"esprima@npm:2.7.x, esprima@npm:^2.7.1": - version: 2.7.3 - resolution: "esprima@npm:2.7.3" - bin: - esparse: ./bin/esparse.js - esvalidate: ./bin/esvalidate.js - checksum: 10/7508285b882012deea8f68dff4b759f9a17e9317ad8c7449969feb1e2efc083fa4a0012139a4722f1e96da81ece0ac319756c8e79a01e5ddb4b36ae483464d3f - languageName: node - linkType: hard - "esprima@npm:^4.0.0, esprima@npm:^4.0.1": version: 4.0.1 resolution: "esprima@npm:4.0.1" @@ -7386,13 +6650,6 @@ __metadata: languageName: node linkType: hard -"estraverse@npm:^1.9.1": - version: 1.9.3 - resolution: "estraverse@npm:1.9.3" - checksum: 10/682a7e2fda17fd3e892b78a8347d055f923465598f5d713354aefd53a3348b2a1a6ee8df41031d8f5ad9802cfd27c29caac84c2f58ce3b2df659d43d668c870b - languageName: node - linkType: hard - "estraverse@npm:^4.1.1, estraverse@npm:^4.2.0": version: 4.3.0 resolution: "estraverse@npm:4.3.0" @@ -7445,32 +6702,6 @@ __metadata: languageName: node linkType: hard -"eth-gas-reporter@npm:^0.2.25": - version: 0.2.27 - resolution: "eth-gas-reporter@npm:0.2.27" - dependencies: - "@solidity-parser/parser": "npm:^0.14.0" - axios: "npm:^1.5.1" - cli-table3: "npm:^0.5.0" - colors: "npm:1.4.0" - ethereum-cryptography: "npm:^1.0.3" - ethers: "npm:^5.7.2" - fs-readdir-recursive: "npm:^1.1.0" - lodash: "npm:^4.17.14" - markdown-table: "npm:^1.1.3" - mocha: "npm:^10.2.0" - req-cwd: "npm:^2.0.0" - sha1: "npm:^1.1.1" - sync-request: "npm:^6.0.0" - peerDependencies: - "@codechecks/client": ^0.1.0 - peerDependenciesMeta: - "@codechecks/client": - optional: true - checksum: 10/d2ba21b6e7edfadc39a29368bf52d22ab5314ee6a132b88df2abfe746e4c8161a32fd998be4ee6a98309a4c04162d5150e46f1391f116bcb15a76d711538453d - languageName: node - linkType: hard - "eth-lib@npm:0.2.8": version: 0.2.8 resolution: "eth-lib@npm:0.2.8" @@ -7577,7 +6808,7 @@ __metadata: languageName: node linkType: hard -"ethereumjs-util@npm:^7.1.4, ethereumjs-util@npm:^7.1.5": +"ethereumjs-util@npm:^7.1.5": version: 7.1.5 resolution: "ethereumjs-util@npm:7.1.5" dependencies: @@ -7590,45 +6821,7 @@ __metadata: languageName: node linkType: hard -"ethers@npm:^5.7.2": - version: 5.7.2 - resolution: "ethers@npm:5.7.2" - dependencies: - "@ethersproject/abi": "npm:5.7.0" - "@ethersproject/abstract-provider": "npm:5.7.0" - "@ethersproject/abstract-signer": "npm:5.7.0" - "@ethersproject/address": "npm:5.7.0" - "@ethersproject/base64": "npm:5.7.0" - "@ethersproject/basex": "npm:5.7.0" - "@ethersproject/bignumber": "npm:5.7.0" - "@ethersproject/bytes": "npm:5.7.0" - "@ethersproject/constants": "npm:5.7.0" - "@ethersproject/contracts": "npm:5.7.0" - "@ethersproject/hash": "npm:5.7.0" - "@ethersproject/hdnode": "npm:5.7.0" - "@ethersproject/json-wallets": "npm:5.7.0" - "@ethersproject/keccak256": "npm:5.7.0" - "@ethersproject/logger": "npm:5.7.0" - "@ethersproject/networks": "npm:5.7.1" - "@ethersproject/pbkdf2": "npm:5.7.0" - "@ethersproject/properties": "npm:5.7.0" - "@ethersproject/providers": "npm:5.7.2" - "@ethersproject/random": "npm:5.7.0" - "@ethersproject/rlp": "npm:5.7.0" - "@ethersproject/sha2": "npm:5.7.0" - "@ethersproject/signing-key": "npm:5.7.0" - "@ethersproject/solidity": "npm:5.7.0" - "@ethersproject/strings": "npm:5.7.0" - "@ethersproject/transactions": "npm:5.7.0" - "@ethersproject/units": "npm:5.7.0" - "@ethersproject/wallet": "npm:5.7.0" - "@ethersproject/web": "npm:5.7.1" - "@ethersproject/wordlists": "npm:5.7.0" - checksum: 10/227dfa88a2547c799c0c3c9e92e5e246dd11342f4b495198b3ae7c942d5bf81d3970fcef3fbac974a9125d62939b2d94f3c0458464e702209b839a8e6e615028 - languageName: node - linkType: hard - -"ethers@npm:^6.12.0, ethers@npm:^6.4.0": +"ethers@npm:^6.12.0": version: 6.12.0 resolution: "ethers@npm:6.12.0" dependencies: @@ -7962,14 +7155,7 @@ __metadata: languageName: node linkType: hard -"fast-diff@npm:^1.1.2, fast-diff@npm:^1.2.0": - version: 1.3.0 - resolution: "fast-diff@npm:1.3.0" - checksum: 10/9e57415bc69cd6efcc720b3b8fe9fdaf42dcfc06f86f0f45378b1fa512598a8aac48aa3928c8751d58e2f01bb4ba4f07e4f3d9bc0d57586d45f1bd1e872c6cde - languageName: node - linkType: hard - -"fast-glob@npm:^3.0.3, fast-glob@npm:^3.2.9": +"fast-glob@npm:^3.2.9": version: 3.3.2 resolution: "fast-glob@npm:3.3.2" dependencies: @@ -8157,25 +7343,25 @@ __metadata: languageName: node linkType: hard -"ffjavascript@npm:0.2.62": - version: 0.2.62 - resolution: "ffjavascript@npm:0.2.62" +"ffjavascript@npm:0.2.63, ffjavascript@npm:^0.2.30, ffjavascript@npm:^0.2.35, ffjavascript@npm:^0.2.38, ffjavascript@npm:^0.2.48": + version: 0.2.63 + resolution: "ffjavascript@npm:0.2.63" dependencies: wasmbuilder: "npm:0.0.16" wasmcurves: "npm:0.2.2" - web-worker: "npm:^1.2.0" - checksum: 10/e99e1c26bd79a630536f6775dd062ed42f7f2d6fb4ed7a42af2641323d3b96cc950f072c180906a821422d9b14199c95190c3c9d623c2dccd3364d8e117bd663 + web-worker: "npm:1.2.0" + checksum: 10/2886a8737eb200dcb3f592a168d525bbde270e362589b5cb7dfa1cc86b78a3c455858664be994dae5c7acbf7eb831250afdf4270fc900d90b02ac6023a74c302 languageName: node linkType: hard -"ffjavascript@npm:0.2.63, ffjavascript@npm:^0.2.30, ffjavascript@npm:^0.2.35, ffjavascript@npm:^0.2.38, ffjavascript@npm:^0.2.48": - version: 0.2.63 - resolution: "ffjavascript@npm:0.2.63" +"ffjavascript@npm:^0.3.0": + version: 0.3.0 + resolution: "ffjavascript@npm:0.3.0" dependencies: wasmbuilder: "npm:0.0.16" wasmcurves: "npm:0.2.2" web-worker: "npm:1.2.0" - checksum: 10/2886a8737eb200dcb3f592a168d525bbde270e362589b5cb7dfa1cc86b78a3c455858664be994dae5c7acbf7eb831250afdf4270fc900d90b02ac6023a74c302 + checksum: 10/8478f3f3380b6195cf4994f9998e40a05780caa10b31bf67ba87ed294811ada6cb376deb58ce63d7fa124a828350a4c3530a6550545231872d7bd4e5e9f09f2f languageName: node linkType: hard @@ -8250,15 +7436,6 @@ __metadata: languageName: node linkType: hard -"find-replace@npm:^3.0.0": - version: 3.0.0 - resolution: "find-replace@npm:3.0.0" - dependencies: - array-back: "npm:^3.0.1" - checksum: 10/6b04bcfd79027f5b84aa1dfe100e3295da989bdac4b4de6b277f4d063e78f5c9e92ebc8a1fec6dd3b448c924ba404ee051cc759e14a3ee3e825fa1361025df08 - languageName: node - linkType: hard - "find-up@npm:5.0.0, find-up@npm:^5.0.0": version: 5.0.0 resolution: "find-up@npm:5.0.0" @@ -8322,7 +7499,7 @@ __metadata: languageName: node linkType: hard -"follow-redirects@npm:^1.12.1, follow-redirects@npm:^1.14.0, follow-redirects@npm:^1.15.6": +"follow-redirects@npm:^1.12.1, follow-redirects@npm:^1.14.0": version: 1.15.6 resolution: "follow-redirects@npm:1.15.6" peerDependenciesMeta: @@ -8372,7 +7549,7 @@ __metadata: languageName: node linkType: hard -"form-data@npm:^2.2.0, form-data@npm:^2.5.0": +"form-data@npm:^2.5.0": version: 2.5.1 resolution: "form-data@npm:2.5.1" dependencies: @@ -8394,17 +7571,6 @@ __metadata: languageName: node linkType: hard -"form-data@npm:^4.0.0": - version: 4.0.0 - resolution: "form-data@npm:4.0.0" - dependencies: - asynckit: "npm:^0.4.0" - combined-stream: "npm:^1.0.8" - mime-types: "npm:^2.1.12" - checksum: 10/7264aa760a8cf09482816d8300f1b6e2423de1b02bba612a136857413fdc96d7178298ced106817655facc6b89036c6e12ae31c9eb5bdc16aabf502ae8a5d805 - languageName: node - linkType: hard - "form-data@npm:~2.3.2": version: 2.3.3 resolution: "form-data@npm:2.3.3" @@ -8488,7 +7654,7 @@ __metadata: languageName: node linkType: hard -"fs-extra@npm:^7.0.0, fs-extra@npm:^7.0.1": +"fs-extra@npm:^7.0.1": version: 7.0.1 resolution: "fs-extra@npm:7.0.1" dependencies: @@ -8499,29 +7665,6 @@ __metadata: languageName: node linkType: hard -"fs-extra@npm:^8.1.0": - version: 8.1.0 - resolution: "fs-extra@npm:8.1.0" - dependencies: - graceful-fs: "npm:^4.2.0" - jsonfile: "npm:^4.0.0" - universalify: "npm:^0.1.0" - checksum: 10/6fb12449f5349be724a138b4a7b45fe6a317d2972054517f5971959c26fbd17c0e145731a11c7324460262baa33e0a799b183ceace98f7a372c95fbb6f20f5de - languageName: node - linkType: hard - -"fs-extra@npm:^9.1.0": - version: 9.1.0 - resolution: "fs-extra@npm:9.1.0" - dependencies: - at-least-node: "npm:^1.0.0" - graceful-fs: "npm:^4.2.0" - jsonfile: "npm:^6.0.1" - universalify: "npm:^2.0.0" - checksum: 10/08600da1b49552ed23dfac598c8fc909c66776dd130fea54fbcad22e330f7fcc13488bb995f6bc9ce5651aa35b65702faf616fe76370ee56f1aade55da982dca - languageName: node - linkType: hard - "fs-minipass@npm:^1.2.7": version: 1.2.7 resolution: "fs-minipass@npm:1.2.7" @@ -8549,13 +7692,6 @@ __metadata: languageName: node linkType: hard -"fs-readdir-recursive@npm:^1.1.0": - version: 1.1.0 - resolution: "fs-readdir-recursive@npm:1.1.0" - checksum: 10/d5e3fd8456b8e5d57a43f169a9eaf65c70fa82c4a22f1d4361cdba4ea5e61c60c5c2b4ac481ea137a4d43b2b99b3ea2fae95ac2730255c4206d61af645866c3a - languageName: node - linkType: hard - "fs.realpath@npm:^1.0.0": version: 1.0.0 resolution: "fs.realpath@npm:1.0.0" @@ -8656,13 +7792,6 @@ __metadata: languageName: node linkType: hard -"get-port@npm:^3.1.0": - version: 3.2.0 - resolution: "get-port@npm:3.2.0" - checksum: 10/577b6ae47dcac1cb64f9bad28c9aa9e4cd8e8f2166c4224485dcdd1dede64154517a57a0eb55bfb557ad3d48f9a1b400415ed047f04002e936f96ddb247f645d - languageName: node - linkType: hard - "get-stream@npm:^4.0.0": version: 4.1.0 resolution: "get-stream@npm:4.1.0" @@ -8722,18 +7851,6 @@ __metadata: languageName: node linkType: hard -"ghost-testrpc@npm:^0.0.2": - version: 0.0.2 - resolution: "ghost-testrpc@npm:0.0.2" - dependencies: - chalk: "npm:^2.4.2" - node-emoji: "npm:^1.10.0" - bin: - testrpc-sc: ./index.js - checksum: 10/e52f1d7ad5ac84c8528b3884496270c65056264b37373c00631ca874674b3cfd7c45ae2fc787ba3ff75e63273188f29d155d995ce3e361244bd55a9c365e444f - languageName: node - linkType: hard - "giget@npm:^1.2.1": version: 1.2.3 resolution: "giget@npm:1.2.3" @@ -8799,20 +7916,6 @@ __metadata: languageName: node linkType: hard -"glob@npm:7.1.7": - version: 7.1.7 - resolution: "glob@npm:7.1.7" - dependencies: - fs.realpath: "npm:^1.0.0" - inflight: "npm:^1.0.4" - inherits: "npm:2" - minimatch: "npm:^3.0.4" - once: "npm:^1.3.0" - path-is-absolute: "npm:^1.0.0" - checksum: 10/ff5aab0386e9cace92b0550d42085b71013c5ea382982dd7fdded998a559635f61413b8ba6fb7294eef289c83b52f4e64136f888300ac8afc4f3e5623182d6c8 - languageName: node - linkType: hard - "glob@npm:7.2.0": version: 7.2.0 resolution: "glob@npm:7.2.0" @@ -8855,20 +7958,7 @@ __metadata: languageName: node linkType: hard -"glob@npm:^5.0.15": - version: 5.0.15 - resolution: "glob@npm:5.0.15" - dependencies: - inflight: "npm:^1.0.4" - inherits: "npm:2" - minimatch: "npm:2 || 3" - once: "npm:^1.3.0" - path-is-absolute: "npm:^1.0.0" - checksum: 10/4a1f2401329d94b5c25c6ac16276aceccc52b865bd9b2b9198da21fc937d021bfd87463ae44de9a9e4794894a49bc619ebaf7e5b12182bcf97e2ceb68ae116d7 - languageName: node - linkType: hard - -"glob@npm:^7.0.0, glob@npm:^7.1.1, glob@npm:^7.1.2, glob@npm:^7.1.3, glob@npm:^7.1.4, glob@npm:^7.1.6": +"glob@npm:^7.0.0, glob@npm:^7.1.1, glob@npm:^7.1.2, glob@npm:^7.1.3, glob@npm:^7.1.4": version: 7.2.3 resolution: "glob@npm:7.2.3" dependencies: @@ -8891,26 +7981,6 @@ __metadata: languageName: node linkType: hard -"global-modules@npm:^2.0.0": - version: 2.0.0 - resolution: "global-modules@npm:2.0.0" - dependencies: - global-prefix: "npm:^3.0.0" - checksum: 10/4aee73adf533fe82ead2ad15c8bfb6ea4fb29e16d2d067521ab39d3b45b8f834d71c47a807e4f8f696e79497c3946d4ccdcd708da6f3a4522d65b087b8852f64 - languageName: node - linkType: hard - -"global-prefix@npm:^3.0.0": - version: 3.0.0 - resolution: "global-prefix@npm:3.0.0" - dependencies: - ini: "npm:^1.3.5" - kind-of: "npm:^6.0.2" - which: "npm:^1.3.1" - checksum: 10/a405b9f83c7d88a49dc1c1e458d6585e258356810d3d0f41094265152a06a0f393b14d911f45616e35a4ce3894176a73be2984883575e778f55e90bf812d7337 - languageName: node - linkType: hard - "global@npm:~4.4.0": version: 4.4.0 resolution: "global@npm:4.4.0" @@ -8946,22 +8016,6 @@ __metadata: languageName: node linkType: hard -"globby@npm:^10.0.1": - version: 10.0.2 - resolution: "globby@npm:10.0.2" - dependencies: - "@types/glob": "npm:^7.1.1" - array-union: "npm:^2.1.0" - dir-glob: "npm:^3.0.1" - fast-glob: "npm:^3.0.3" - glob: "npm:^7.1.3" - ignore: "npm:^5.1.1" - merge2: "npm:^1.2.3" - slash: "npm:^3.0.0" - checksum: 10/6974752014f0914b112957b4364b760af5f2fda4033ff29bedb830bbe278ff4c13ba64681741f3e62b1f12ea0f2d64bf02ac28534f9cbea4b90ed7e9cd6e954f - languageName: node - linkType: hard - "globby@npm:^11.1.0": version: 11.1.0 resolution: "globby@npm:11.1.0" @@ -9053,24 +8107,6 @@ __metadata: languageName: node linkType: hard -"handlebars@npm:^4.0.1": - version: 4.7.8 - resolution: "handlebars@npm:4.7.8" - dependencies: - minimist: "npm:^1.2.5" - neo-async: "npm:^2.6.2" - source-map: "npm:^0.6.1" - uglify-js: "npm:^3.1.4" - wordwrap: "npm:^1.0.0" - dependenciesMeta: - uglify-js: - optional: true - bin: - handlebars: bin/handlebars - checksum: 10/bd528f4dd150adf67f3f857118ef0fa43ff79a153b1d943fa0a770f2599e38b25a7a0dbac1a3611a4ec86970fd2325a81310fb788b5c892308c9f8743bd02e11 - languageName: node - linkType: hard - "har-schema@npm:^2.0.0": version: 2.0.0 resolution: "har-schema@npm:2.0.0" @@ -9117,20 +8153,7 @@ __metadata: languageName: node linkType: hard -"hardhat-gas-reporter@npm:^1.0.8": - version: 1.0.10 - resolution: "hardhat-gas-reporter@npm:1.0.10" - dependencies: - array-uniq: "npm:1.0.3" - eth-gas-reporter: "npm:^0.2.25" - sha1: "npm:^1.1.1" - peerDependencies: - hardhat: ^2.0.2 - checksum: 10/ad6df4f87ebddea967d02243a728f824cd02a486bc400a0b5fb0bfc55b24eb08d445d4c2650e8d53fa622050f6f4a971e954179bb2ac02f2bbaba97f4464d33f - languageName: node - linkType: hard - -"hardhat@npm:^2.1.2, hardhat@npm:^2.19.4": +"hardhat@npm:^2.1.2": version: 2.22.3 resolution: "hardhat@npm:2.22.3" dependencies: @@ -9198,13 +8221,6 @@ __metadata: languageName: node linkType: hard -"has-flag@npm:^1.0.0": - version: 1.0.0 - resolution: "has-flag@npm:1.0.0" - checksum: 10/ce3f8ae978e70f16e4bbe17d3f0f6d6c0a3dd3b62a23f97c91d0fda9ed8e305e13baf95cc5bee4463b9f25ac9f5255de113165c5fb285e01b8065b2ac079b301 - languageName: node - linkType: hard - "has-flag@npm:^3.0.0": version: 3.0.0 resolution: "has-flag@npm:3.0.0" @@ -9329,13 +8345,6 @@ __metadata: languageName: node linkType: hard -"heap@npm:>= 0.2.0": - version: 0.2.7 - resolution: "heap@npm:0.2.7" - checksum: 10/6374f6510af79bf47f2cfcee265bf608e6ed2b2694875974d1cb5654ddc98af05347dcf3a42ee9a7de318b576022d6f4d00fe06fa65a4a65c4c60638375eabfe - languageName: node - linkType: hard - "helmet-crossdomain@npm:0.4.0": version: 0.4.0 resolution: "helmet-crossdomain@npm:0.4.0" @@ -9457,18 +8466,6 @@ __metadata: languageName: node linkType: hard -"http-basic@npm:^8.1.1": - version: 8.1.3 - resolution: "http-basic@npm:8.1.3" - dependencies: - caseless: "npm:^0.12.0" - concat-stream: "npm:^1.6.2" - http-response-object: "npm:^3.0.1" - parse-cache-control: "npm:^1.0.1" - checksum: 10/f515c46159da289bc1573251a90f29b36ec7d781587481acc93656bc21d07f664c862662bd0e79144870c0254758e8b328e16ddc0a5c004827fb1503760e561e - languageName: node - linkType: hard - "http-cache-semantics@npm:^4.0.0, http-cache-semantics@npm:^4.1.1": version: 4.1.1 resolution: "http-cache-semantics@npm:4.1.1" @@ -9530,15 +8527,6 @@ __metadata: languageName: node linkType: hard -"http-response-object@npm:^3.0.1": - version: 3.0.2 - resolution: "http-response-object@npm:3.0.2" - dependencies: - "@types/node": "npm:^10.0.3" - checksum: 10/f530c1b28d35200ec125e3a1d3c2d6da1f9d78cc52537e9379219e8172bda24f831856eb050a635d9746f9545586532ade60ffe75253d5a1db14dfaf4759d691 - languageName: node - linkType: hard - "http-signature@npm:~1.2.0": version: 1.2.0 resolution: "http-signature@npm:1.2.0" @@ -9661,7 +8649,7 @@ __metadata: languageName: node linkType: hard -"ignore@npm:^5.1.1, ignore@npm:^5.2.0, ignore@npm:^5.2.4, ignore@npm:^5.3.1": +"ignore@npm:^5.2.0, ignore@npm:^5.3.1": version: 5.3.1 resolution: "ignore@npm:5.3.1" checksum: 10/0a884c2fbc8c316f0b9f92beaf84464253b73230a4d4d286697be45fca081199191ca33e1c2e82d9e5f851f5e9a48a78e25a35c951e7eb41e59f150db3530065 @@ -9697,38 +8685,6 @@ __metadata: languageName: node linkType: hard -"imt.sol@workspace:packages/imt.sol": - version: 0.0.0-use.local - resolution: "imt.sol@workspace:packages/imt.sol" - dependencies: - "@nomicfoundation/hardhat-chai-matchers": "npm:^2.0.3" - "@nomicfoundation/hardhat-ethers": "npm:^3.0.0" - "@nomicfoundation/hardhat-network-helpers": "npm:^1.0.0" - "@nomicfoundation/hardhat-toolbox": "npm:^4.0.0" - "@nomicfoundation/hardhat-verify": "npm:^2.0.0" - "@typechain/ethers-v6": "npm:^0.5.0" - "@typechain/hardhat": "npm:^9.0.0" - "@types/chai": "npm:^4.2.0" - "@types/mocha": "npm:^10.0.6" - "@types/node": "npm:^20.10.7" - "@zk-kit/imt": "workspace:packages/imt" - "@zk-kit/lean-imt": "workspace:packages/lean-imt" - chai: "npm:^4.2.0" - ethers: "npm:^6.4.0" - hardhat: "npm:^2.19.4" - hardhat-gas-reporter: "npm:^1.0.8" - poseidon-lite: "npm:^0.2.0" - poseidon-solidity: "npm:0.0.5" - prettier-plugin-solidity: "npm:^1.3.1" - solhint: "npm:^3.3.6" - solhint-plugin-prettier: "npm:^0.1.0" - solidity-coverage: "npm:^0.8.0" - ts-node: "npm:^10.9.2" - typechain: "npm:^8.3.0" - typescript: "npm:^5.3.3" - languageName: unknown - linkType: soft - "imurmurhash@npm:^0.1.4": version: 0.1.4 resolution: "imurmurhash@npm:0.1.4" @@ -9786,14 +8742,14 @@ __metadata: languageName: node linkType: hard -"inherits@npm:2, inherits@npm:2.0.4, inherits@npm:^2.0.1, inherits@npm:^2.0.3, inherits@npm:^2.0.4, inherits@npm:~2.0.3": +"inherits@npm:2, inherits@npm:2.0.4, inherits@npm:^2.0.1, inherits@npm:^2.0.3, inherits@npm:^2.0.4": version: 2.0.4 resolution: "inherits@npm:2.0.4" checksum: 10/cd45e923bee15186c07fa4c89db0aace24824c482fb887b528304694b2aa6ff8a898da8657046a5dcf3e46cd6db6c61629551f9215f208d7c3f157cf9b290521 languageName: node linkType: hard -"ini@npm:^1.3.4, ini@npm:^1.3.5": +"ini@npm:^1.3.4": version: 1.3.8 resolution: "ini@npm:1.3.8" checksum: 10/314ae176e8d4deb3def56106da8002b462221c174ddb7ce0c49ee72c8cd1f9044f7b10cc555a7d8850982c3b9ca96fc212122749f5234bc2b6fb05fb942ed566 @@ -10343,7 +9299,7 @@ __metadata: languageName: node linkType: hard -"isarray@npm:1.0.0, isarray@npm:~1.0.0": +"isarray@npm:1.0.0": version: 1.0.0 resolution: "isarray@npm:1.0.0" checksum: 10/f032df8e02dce8ec565cf2eb605ea939bdccea528dbcf565cdf92bfa2da9110461159d86a537388ef1acef8815a330642d7885b29010e8f7eac967c9993b65ab @@ -11413,18 +10369,6 @@ __metadata: languageName: node linkType: hard -"js-yaml@npm:3.x, js-yaml@npm:^3.13.1": - version: 3.14.1 - resolution: "js-yaml@npm:3.14.1" - dependencies: - argparse: "npm:^1.0.7" - esprima: "npm:^4.0.0" - bin: - js-yaml: bin/js-yaml.js - checksum: 10/9e22d80b4d0105b9899135365f746d47466ed53ef4223c529b3c0f7a39907743fdbd3c4379f94f1106f02755b5e90b2faaf84801a891135544e1ea475d1a1379 - languageName: node - linkType: hard - "js-yaml@npm:4.0.0": version: 4.0.0 resolution: "js-yaml@npm:4.0.0" @@ -11447,6 +10391,18 @@ __metadata: languageName: node linkType: hard +"js-yaml@npm:^3.13.1": + version: 3.14.1 + resolution: "js-yaml@npm:3.14.1" + dependencies: + argparse: "npm:^1.0.7" + esprima: "npm:^4.0.0" + bin: + js-yaml: bin/js-yaml.js + checksum: 10/9e22d80b4d0105b9899135365f746d47466ed53ef4223c529b3c0f7a39907743fdbd3c4379f94f1106f02755b5e90b2faaf84801a891135544e1ea475d1a1379 + languageName: node + linkType: hard + "jsbn@npm:1.1.0": version: 1.1.0 resolution: "jsbn@npm:1.1.0" @@ -11654,13 +10610,6 @@ __metadata: languageName: node linkType: hard -"jsonschema@npm:^1.2.4": - version: 1.4.1 - resolution: "jsonschema@npm:1.4.1" - checksum: 10/d7a188da7a3100a2caa362b80e98666d46607b7a7153aac405b8e758132961911c6df02d444d4700691330874e21a62639f550e856b21ddd28423690751ca9c6 - languageName: node - linkType: hard - "jsprim@npm:^1.2.2": version: 1.4.2 resolution: "jsprim@npm:1.4.2" @@ -11829,36 +10778,6 @@ __metadata: languageName: node linkType: hard -"lazytower.sol@workspace:packages/lazytower.sol": - version: 0.0.0-use.local - resolution: "lazytower.sol@workspace:packages/lazytower.sol" - dependencies: - "@nomicfoundation/hardhat-chai-matchers": "npm:^2.0.3" - "@nomicfoundation/hardhat-ethers": "npm:^3.0.0" - "@nomicfoundation/hardhat-network-helpers": "npm:^1.0.0" - "@nomicfoundation/hardhat-toolbox": "npm:^4.0.0" - "@nomicfoundation/hardhat-verify": "npm:^2.0.0" - "@typechain/ethers-v6": "npm:^0.5.0" - "@typechain/hardhat": "npm:^9.0.0" - "@types/chai": "npm:^4.2.0" - "@types/mocha": "npm:^10.0.6" - "@types/node": "npm:^20.10.7" - chai: "npm:^4.2.0" - ethers: "npm:^6.4.0" - hardhat: "npm:^2.19.4" - hardhat-gas-reporter: "npm:^1.0.8" - poseidon-lite: "npm:^0.2.0" - poseidon-solidity: "npm:0.0.5" - prettier-plugin-solidity: "npm:^1.3.1" - solhint: "npm:^3.3.6" - solhint-plugin-prettier: "npm:^0.1.0" - solidity-coverage: "npm:^0.8.0" - ts-node: "npm:^10.9.2" - typechain: "npm:^8.3.0" - typescript: "npm:^5.3.3" - languageName: unknown - linkType: soft - "leven@npm:^3.1.0": version: 3.1.0 resolution: "leven@npm:3.1.0" @@ -11969,13 +10888,6 @@ __metadata: languageName: node linkType: hard -"lodash.clonedeep@npm:^4.5.0": - version: 4.5.0 - resolution: "lodash.clonedeep@npm:4.5.0" - checksum: 10/957ed243f84ba6791d4992d5c222ffffca339a3b79dbe81d2eaf0c90504160b500641c5a0f56e27630030b18b8e971ea10b44f928a977d5ced3c8948841b555f - languageName: node - linkType: hard - "lodash.get@npm:^4.4.2": version: 4.4.2 resolution: "lodash.get@npm:4.4.2" @@ -11983,13 +10895,6 @@ __metadata: languageName: node linkType: hard -"lodash.isequal@npm:^4.5.0": - version: 4.5.0 - resolution: "lodash.isequal@npm:4.5.0" - checksum: 10/82fc58a83a1555f8df34ca9a2cd300995ff94018ac12cc47c349655f0ae1d4d92ba346db4c19bbfc90510764e0c00ddcc985a358bdcd4b3b965abf8f2a48a214 - languageName: node - linkType: hard - "lodash.isfunction@npm:^3.0.9": version: 3.0.9 resolution: "lodash.isfunction@npm:3.0.9" @@ -12046,13 +10951,6 @@ __metadata: languageName: node linkType: hard -"lodash.truncate@npm:^4.4.2": - version: 4.4.2 - resolution: "lodash.truncate@npm:4.4.2" - checksum: 10/7a495616121449e5d2288c606b1025d42ab9979e8c93ba885e5c5802ffd4f1ebad4428c793ccc12f73e73237e85a9f5b67dd6415757546fbd5a4653ba83e25ac - languageName: node - linkType: hard - "lodash.uniq@npm:^4.5.0": version: 4.5.0 resolution: "lodash.uniq@npm:4.5.0" @@ -12067,7 +10965,7 @@ __metadata: languageName: node linkType: hard -"lodash@npm:4.x, lodash@npm:^4.17.11, lodash@npm:^4.17.14, lodash@npm:^4.17.15, lodash@npm:^4.17.21, lodash@npm:^4.17.4, lodash@npm:^4.7.0": +"lodash@npm:4.x, lodash@npm:^4.17.11, lodash@npm:^4.17.15, lodash@npm:^4.17.4, lodash@npm:^4.7.0": version: 4.17.21 resolution: "lodash@npm:4.17.21" checksum: 10/c08619c038846ea6ac754abd6dd29d2568aa705feb69339e836dfa8d8b09abbb2f859371e86863eda41848221f9af43714491467b5b0299122431e202bb0c532 @@ -12279,13 +11177,6 @@ __metadata: languageName: node linkType: hard -"markdown-table@npm:^1.1.3": - version: 1.1.3 - resolution: "markdown-table@npm:1.1.3" - checksum: 10/ca94e8a84c467f9da963d1888aa298939f137d792b39259bf971d01d6fb534e02c0435e10dcccdc0b11d9e29bf6eb7dffacb007b07e3038b68b2e6eb02990fb1 - languageName: node - linkType: hard - "marked@npm:^4.3.0": version: 4.3.0 resolution: "marked@npm:4.3.0" @@ -12360,7 +11251,7 @@ __metadata: languageName: node linkType: hard -"merge2@npm:^1.2.3, merge2@npm:^1.3.0, merge2@npm:^1.4.1": +"merge2@npm:^1.3.0, merge2@npm:^1.4.1": version: 1.4.1 resolution: "merge2@npm:1.4.1" checksum: 10/7268db63ed5169466540b6fb947aec313200bcf6d40c5ab722c22e242f651994619bcd85601602972d3c85bd2cc45a358a4c61937e9f11a061919a1da569b0c2 @@ -12495,15 +11386,6 @@ __metadata: languageName: node linkType: hard -"minimatch@npm:2 || 3, minimatch@npm:^3.0.4, minimatch@npm:^3.0.5, minimatch@npm:^3.1.1, minimatch@npm:^3.1.2": - version: 3.1.2 - resolution: "minimatch@npm:3.1.2" - dependencies: - brace-expansion: "npm:^1.1.7" - checksum: 10/e0b25b04cd4ec6732830344e5739b13f8690f8a012d73445a4a19fbc623f5dd481ef7a5827fde25954cd6026fede7574cc54dc4643c99d6c6b653d6203f94634 - languageName: node - linkType: hard - "minimatch@npm:3.0.4": version: 3.0.4 resolution: "minimatch@npm:3.0.4" @@ -12522,6 +11404,15 @@ __metadata: languageName: node linkType: hard +"minimatch@npm:^3.0.4, minimatch@npm:^3.0.5, minimatch@npm:^3.1.1, minimatch@npm:^3.1.2": + version: 3.1.2 + resolution: "minimatch@npm:3.1.2" + dependencies: + brace-expansion: "npm:^1.1.7" + checksum: 10/e0b25b04cd4ec6732830344e5739b13f8690f8a012d73445a4a19fbc623f5dd481ef7a5827fde25954cd6026fede7574cc54dc4643c99d6c6b653d6203f94634 + languageName: node + linkType: hard + "minimatch@npm:^5.0.1": version: 5.1.6 resolution: "minimatch@npm:5.1.6" @@ -12551,7 +11442,7 @@ __metadata: languageName: node linkType: hard -"minimist@npm:^1.1.1, minimist@npm:^1.2.0, minimist@npm:^1.2.5, minimist@npm:^1.2.6": +"minimist@npm:^1.1.1, minimist@npm:^1.2.0, minimist@npm:^1.2.6": version: 1.2.8 resolution: "minimist@npm:1.2.8" checksum: 10/908491b6cc15a6c440ba5b22780a0ba89b9810e1aea684e253e43c4e3b8d56ec1dcdd7ea96dde119c29df59c936cde16062159eae4225c691e19c70b432b6e6f @@ -12689,23 +11580,23 @@ __metadata: languageName: node linkType: hard -"mkdirp@npm:0.5.x, mkdirp@npm:^0.5.5": - version: 0.5.6 - resolution: "mkdirp@npm:0.5.6" - dependencies: - minimist: "npm:^1.2.6" +"mkdirp@npm:1.x, mkdirp@npm:^1.0.3": + version: 1.0.4 + resolution: "mkdirp@npm:1.0.4" bin: mkdirp: bin/cmd.js - checksum: 10/0c91b721bb12c3f9af4b77ebf73604baf350e64d80df91754dc509491ae93bf238581e59c7188360cec7cb62fc4100959245a42cfe01834efedc5e9d068376c2 + checksum: 10/d71b8dcd4b5af2fe13ecf3bd24070263489404fe216488c5ba7e38ece1f54daf219e72a833a3a2dc404331e870e9f44963a33399589490956bff003a3404d3b2 languageName: node linkType: hard -"mkdirp@npm:1.x, mkdirp@npm:^1.0.3, mkdirp@npm:^1.0.4": - version: 1.0.4 - resolution: "mkdirp@npm:1.0.4" +"mkdirp@npm:^0.5.5": + version: 0.5.6 + resolution: "mkdirp@npm:0.5.6" + dependencies: + minimist: "npm:^1.2.6" bin: mkdirp: bin/cmd.js - checksum: 10/d71b8dcd4b5af2fe13ecf3bd24070263489404fe216488c5ba7e38ece1f54daf219e72a833a3a2dc404331e870e9f44963a33399589490956bff003a3404d3b2 + checksum: 10/0c91b721bb12c3f9af4b77ebf73604baf350e64d80df91754dc509491ae93bf238581e59c7188360cec7cb62fc4100959245a42cfe01834efedc5e9d068376c2 languageName: node linkType: hard @@ -12730,7 +11621,7 @@ __metadata: languageName: node linkType: hard -"mocha@npm:^10.0.0, mocha@npm:^10.2.0": +"mocha@npm:^10.0.0": version: 10.4.0 resolution: "mocha@npm:10.4.0" dependencies: @@ -12968,13 +11859,6 @@ __metadata: languageName: node linkType: hard -"neo-async@npm:^2.6.2": - version: 2.6.2 - resolution: "neo-async@npm:2.6.2" - checksum: 10/1a7948fea86f2b33ec766bc899c88796a51ba76a4afc9026764aedc6e7cde692a09067031e4a1bf6db4f978ccd99e7f5b6c03fe47ad9865c3d4f99050d67e002 - languageName: node - linkType: hard - "next-tick@npm:^1.1.0": version: 1.1.0 resolution: "next-tick@npm:1.1.0" @@ -13014,15 +11898,6 @@ __metadata: languageName: node linkType: hard -"node-emoji@npm:^1.10.0": - version: 1.11.0 - resolution: "node-emoji@npm:1.11.0" - dependencies: - lodash: "npm:^4.17.21" - checksum: 10/1d7ae9bcb0f23d7cdfcac5c3a90a6fd6ec584e6f7c70ff073f6122bfbed6c06284da7334092500d24e14162f5c4016e5dcd3355753cbd5b7e60de560a973248d - languageName: node - linkType: hard - "node-fetch-native@npm:^1.2.0, node-fetch-native@npm:^1.6.3": version: 1.6.4 resolution: "node-fetch-native@npm:1.6.4" @@ -13103,24 +11978,6 @@ __metadata: languageName: node linkType: hard -"nofilter@npm:^3.1.0": - version: 3.1.0 - resolution: "nofilter@npm:3.1.0" - checksum: 10/f63d87231dfda4b783db17d75b15aac948f78e65f4f1043096ef441147f6667ff74cd4b3f57ada5dbe240be282d3e9838558ac863a66cb04ef25fff7b2b4be4e - languageName: node - linkType: hard - -"nopt@npm:3.x": - version: 3.0.6 - resolution: "nopt@npm:3.0.6" - dependencies: - abbrev: "npm:1" - bin: - nopt: ./bin/nopt.js - checksum: 10/2f582a44f7a4e495f21b6668008eda47f6e9c50c27efc00494aa67360791c9240da537661371786afc5d5712f353d3debb863a7201b536fe35fb393ceadc8a23 - languageName: node - linkType: hard - "nopt@npm:^7.0.0": version: 7.2.0 resolution: "nopt@npm:7.2.0" @@ -13405,7 +12262,7 @@ __metadata: languageName: node linkType: hard -"once@npm:1.x, once@npm:^1.3.0, once@npm:^1.3.1, once@npm:^1.4.0": +"once@npm:^1.3.0, once@npm:^1.3.1, once@npm:^1.4.0": version: 1.4.0 resolution: "once@npm:1.4.0" dependencies: @@ -13479,13 +12336,6 @@ __metadata: languageName: node linkType: hard -"ordinal@npm:^1.0.3": - version: 1.0.3 - resolution: "ordinal@npm:1.0.3" - checksum: 10/6761c5b7606b6c4b0c22b4097dab4fe7ffcddacc49238eedf9c0ced877f5d4e4ad3f4fd43fefa1cc3f167cc54c7149267441b2ae85b81ccf13f45cf4b7947164 - languageName: node - linkType: hard - "os-tmpdir@npm:~1.0.2": version: 1.0.2 resolution: "os-tmpdir@npm:1.0.2" @@ -13607,13 +12457,6 @@ __metadata: languageName: node linkType: hard -"parse-cache-control@npm:^1.0.1": - version: 1.0.1 - resolution: "parse-cache-control@npm:1.0.1" - checksum: 10/13171cd97395bdcb9ad29e0b82a789f2313663f2392ab4f699c97ecd2059e18c00834b9c12c9b42f6b0f22bc3c9395d16db9d2e3db7e21538ad5cf2e5ec9fdbe - languageName: node - linkType: hard - "parse-headers@npm:^2.0.0": version: 2.0.5 resolution: "parse-headers@npm:2.0.5" @@ -13798,13 +12641,6 @@ __metadata: languageName: node linkType: hard -"pify@npm:^4.0.1": - version: 4.0.1 - resolution: "pify@npm:4.0.1" - checksum: 10/8b97cbf9dc6d4c1320cc238a2db0fc67547f9dc77011729ff353faf34f1936ea1a4d7f3c63b2f4980b253be77bcc72ea1e9e76ee3fd53cce2aafb6a8854d07ec - languageName: node - linkType: hard - "pirates@npm:^4.0.1, pirates@npm:^4.0.4": version: 4.0.6 resolution: "pirates@npm:4.0.6" @@ -13839,13 +12675,6 @@ __metadata: languageName: node linkType: hard -"pluralize@npm:^8.0.0": - version: 8.0.0 - resolution: "pluralize@npm:8.0.0" - checksum: 10/17877fdfdb7ddb3639ce257ad73a7c51a30a966091e40f56ea9f2f545b5727ce548d4928f8cb3ce38e7dc0c5150407d318af6a4ed0ea5265d378473b4c2c61ec - languageName: node - linkType: hard - "poseidon-lite@npm:0.2.0, poseidon-lite@npm:^0.2.0": version: 0.2.0 resolution: "poseidon-lite@npm:0.2.0" @@ -13853,13 +12682,6 @@ __metadata: languageName: node linkType: hard -"poseidon-solidity@npm:0.0.5": - version: 0.0.5 - resolution: "poseidon-solidity@npm:0.0.5" - checksum: 10/a680d0bf8c5eeb6ea8dd1b89a0a924fb2f9a7d33919ef26197aaf0e83ddca0e9c1125f3b3dffa40340a4ed6bef6d864203ff49da6fb91c4c4604149969cafc82 - languageName: node - linkType: hard - "posix-character-classes@npm:^0.1.0": version: 0.1.1 resolution: "posix-character-classes@npm:0.1.1" @@ -13888,37 +12710,6 @@ __metadata: languageName: node linkType: hard -"prettier-linter-helpers@npm:^1.0.0": - version: 1.0.0 - resolution: "prettier-linter-helpers@npm:1.0.0" - dependencies: - fast-diff: "npm:^1.1.2" - checksum: 10/00ce8011cf6430158d27f9c92cfea0a7699405633f7f1d4a45f07e21bf78e99895911cbcdc3853db3a824201a7c745bd49bfea8abd5fb9883e765a90f74f8392 - languageName: node - linkType: hard - -"prettier-plugin-solidity@npm:^1.3.1": - version: 1.3.1 - resolution: "prettier-plugin-solidity@npm:1.3.1" - dependencies: - "@solidity-parser/parser": "npm:^0.17.0" - semver: "npm:^7.5.4" - solidity-comments-extractor: "npm:^0.0.8" - peerDependencies: - prettier: ">=2.3.0" - checksum: 10/45c1bf16ca960e43e8dc518db95a9eecfce941480e2737272ab259ea9dcb9796a7830a8884de21637f286f80f06d4b4163418d4d55e41347aee96ee93bc4e8f0 - languageName: node - linkType: hard - -"prettier@npm:^2.3.1, prettier@npm:^2.8.3": - version: 2.8.8 - resolution: "prettier@npm:2.8.8" - bin: - prettier: bin-prettier.js - checksum: 10/00cdb6ab0281f98306cd1847425c24cbaaa48a5ff03633945ab4c701901b8e96ad558eb0777364ffc312f437af9b5a07d0f45346266e8245beaf6247b9c62b24 - languageName: node - linkType: hard - "prettier@npm:^3.2.5": version: 3.2.5 resolution: "prettier@npm:3.2.5" @@ -13958,13 +12749,6 @@ __metadata: languageName: node linkType: hard -"process-nextick-args@npm:~2.0.0": - version: 2.0.1 - resolution: "process-nextick-args@npm:2.0.1" - checksum: 10/1d38588e520dab7cea67cbbe2efdd86a10cc7a074c09657635e34f035277b59fbb57d09d8638346bf7090f8e8ebc070c96fa5fd183b777fff4f5edff5e9466cf - languageName: node - linkType: hard - "process@npm:^0.11.10": version: 0.11.10 resolution: "process@npm:0.11.10" @@ -13982,15 +12766,6 @@ __metadata: languageName: node linkType: hard -"promise@npm:^8.0.0": - version: 8.3.0 - resolution: "promise@npm:8.3.0" - dependencies: - asap: "npm:~2.0.6" - checksum: 10/55e9d0d723c66810966bc055c6c77a3658c0af7e4a8cc88ea47aeaf2949ca0bd1de327d9c631df61236f5406ad478384fa19a77afb3f88c0303eba9e5eb0a8d8 - languageName: node - linkType: hard - "prompts@npm:^2.0.1": version: 2.4.2 resolution: "prompts@npm:2.4.2" @@ -14011,13 +12786,6 @@ __metadata: languageName: node linkType: hard -"proxy-from-env@npm:^1.1.0": - version: 1.1.0 - resolution: "proxy-from-env@npm:1.1.0" - checksum: 10/f0bb4a87cfd18f77bc2fba23ae49c3b378fb35143af16cc478171c623eebe181678f09439707ad80081d340d1593cd54a33a0113f3ccb3f4bc9451488780ee23 - languageName: node - linkType: hard - "psl@npm:^1.1.28, psl@npm:^1.1.33": version: 1.9.0 resolution: "psl@npm:1.9.0" @@ -14065,7 +12833,7 @@ __metadata: languageName: node linkType: hard -"qs@npm:^6.4.0, qs@npm:^6.5.2": +"qs@npm:^6.5.2": version: 6.12.1 resolution: "qs@npm:6.12.1" dependencies: @@ -14241,21 +13009,6 @@ __metadata: languageName: node linkType: hard -"readable-stream@npm:^2.2.2": - version: 2.3.8 - resolution: "readable-stream@npm:2.3.8" - dependencies: - core-util-is: "npm:~1.0.0" - inherits: "npm:~2.0.3" - isarray: "npm:~1.0.0" - process-nextick-args: "npm:~2.0.0" - safe-buffer: "npm:~5.1.1" - string_decoder: "npm:~1.1.1" - util-deprecate: "npm:~1.0.1" - checksum: 10/8500dd3a90e391d6c5d889256d50ec6026c059fadee98ae9aa9b86757d60ac46fff24fafb7a39fa41d54cb39d8be56cc77be202ebd4cd8ffcf4cb226cbaa40d4 - languageName: node - linkType: hard - "readdirp@npm:~3.5.0": version: 3.5.0 resolution: "readdirp@npm:3.5.0" @@ -14290,15 +13043,6 @@ __metadata: languageName: node linkType: hard -"recursive-readdir@npm:^2.2.2": - version: 2.2.3 - resolution: "recursive-readdir@npm:2.2.3" - dependencies: - minimatch: "npm:^3.0.5" - checksum: 10/19298852b0b87810aed5f2c81a73bfaaeb9ade7c9bf363f350fc1443f2cc3df66ecade5e102dfbb153fcd9df20342c301848e11e149e5f78759c1d55aa2c9c39 - languageName: node - linkType: hard - "redent@npm:^3.0.0": version: 3.0.0 resolution: "redent@npm:3.0.0" @@ -14309,13 +13053,6 @@ __metadata: languageName: node linkType: hard -"reduce-flatten@npm:^2.0.0": - version: 2.0.0 - resolution: "reduce-flatten@npm:2.0.0" - checksum: 10/64393ef99a16b20692acfd60982d7fdbd7ff8d9f8f185c6023466444c6dd2abb929d67717a83cec7f7f8fb5f46a25d515b3b2bf2238fdbfcdbfd01d2a9e73cb8 - languageName: node - linkType: hard - "referrer-policy@npm:1.2.0": version: 1.2.0 resolution: "referrer-policy@npm:1.2.0" @@ -14366,24 +13103,6 @@ __metadata: languageName: node linkType: hard -"req-cwd@npm:^2.0.0": - version: 2.0.0 - resolution: "req-cwd@npm:2.0.0" - dependencies: - req-from: "npm:^2.0.0" - checksum: 10/c44f9dea0b0f7d3a72be18a04f7769e0eefbadca363e3a346c1c02b79745126c871e1f6970357b3e731c26740aad8344bf80fb3ce055a2bcf8ca85ad2b44f519 - languageName: node - linkType: hard - -"req-from@npm:^2.0.0": - version: 2.0.0 - resolution: "req-from@npm:2.0.0" - dependencies: - resolve-from: "npm:^3.0.0" - checksum: 10/4c369881a2296e23e71668ed089c5d93b37652fe900ec9f1e1f5c1da65f6bca4ee271e97ba2b806fdea50219e011995d1df3c80a7209015cc1e1fc622507f140 - languageName: node - linkType: hard - "request@npm:^2.79.0": version: 2.88.2 resolution: "request@npm:2.88.2" @@ -14463,13 +13182,6 @@ __metadata: languageName: node linkType: hard -"resolve-from@npm:^3.0.0": - version: 3.0.0 - resolution: "resolve-from@npm:3.0.0" - checksum: 10/c4189f1592a777f7d51c1ff6153df18b5d062c831fb0c623b4b87736c8a73c08e4eaab19e807399287040791f3e7aa0877f05f9d86739d3ef1ef0c727e9fe06c - languageName: node - linkType: hard - "resolve-from@npm:^4.0.0": version: 4.0.0 resolution: "resolve-from@npm:4.0.0" @@ -14500,13 +13212,6 @@ __metadata: languageName: node linkType: hard -"resolve@npm:1.1.x": - version: 1.1.7 - resolution: "resolve@npm:1.1.7" - checksum: 10/0a4ff8a102b1d059321caf77563cb2c495979c734f9dc400a70e3ceaaafe76a72bbcc625f9361756348d7b6af6d3cd2815cfbe3109be655a2b18e62d1cdadfc5 - languageName: node - linkType: hard - "resolve@npm:1.17.0": version: 1.17.0 resolution: "resolve@npm:1.17.0" @@ -14529,13 +13234,6 @@ __metadata: languageName: node linkType: hard -"resolve@patch:resolve@npm%3A1.1.x#optional!builtin": - version: 1.1.7 - resolution: "resolve@patch:resolve@npm%3A1.1.7#optional!builtin::version=1.1.7&hash=3bafbf" - checksum: 10/dc5c99fb47807d3771be3135ac6bdb892186973d0895ab17838f0b85bb575e03111214aa16cb68b6416df3c1dd658081a066dd7a9af6e668c28b0025080b615c - languageName: node - linkType: hard - "resolve@patch:resolve@npm%3A1.17.0#optional!builtin": version: 1.17.0 resolution: "resolve@patch:resolve@npm%3A1.17.0#optional!builtin::version=1.17.0&hash=c3c19d" @@ -14808,7 +13506,7 @@ __metadata: languageName: node linkType: hard -"safe-buffer@npm:~5.1.0, safe-buffer@npm:~5.1.1": +"safe-buffer@npm:~5.1.0": version: 5.1.2 resolution: "safe-buffer@npm:5.1.2" checksum: 10/7eb5b48f2ed9a594a4795677d5a150faa7eb54483b2318b568dc0c4fc94092a6cce5be02c7288a0500a156282f5276d5688bce7259299568d1053b2150ef374a @@ -14870,31 +13568,7 @@ __metadata: languageName: node linkType: hard -"sc-istanbul@npm:^0.4.5": - version: 0.4.6 - resolution: "sc-istanbul@npm:0.4.6" - dependencies: - abbrev: "npm:1.0.x" - async: "npm:1.x" - escodegen: "npm:1.8.x" - esprima: "npm:2.7.x" - glob: "npm:^5.0.15" - handlebars: "npm:^4.0.1" - js-yaml: "npm:3.x" - mkdirp: "npm:0.5.x" - nopt: "npm:3.x" - once: "npm:1.x" - resolve: "npm:1.1.x" - supports-color: "npm:^3.1.0" - which: "npm:^1.1.1" - wordwrap: "npm:^1.0.0" - bin: - istanbul: lib/cli.js - checksum: 10/69acccb8ef3af117a71a57a4a1767ce845e62d1d6ff3d6fd2b5e0dc02746772c352bebee67fd0d0bb805a864bd4753741b118690955955bf34c990c3db36c0f8 - languageName: node - linkType: hard - -"scrypt-js@npm:3.0.1, scrypt-js@npm:^3.0.0, scrypt-js@npm:^3.0.1": +"scrypt-js@npm:^3.0.0, scrypt-js@npm:^3.0.1": version: 3.0.1 resolution: "scrypt-js@npm:3.0.1" checksum: 10/2f8aa72b7f76a6f9c446bbec5670f80d47497bccce98474203d89b5667717223eeb04a50492ae685ed7adc5a060fc2d8f9fd988f8f7ebdaf3341967f3aeff116 @@ -14929,7 +13603,7 @@ __metadata: languageName: node linkType: hard -"semver@npm:7.6.0, semver@npm:7.x, semver@npm:^7.3.2, semver@npm:^7.3.4, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.5.2, semver@npm:^7.5.3, semver@npm:^7.5.4, semver@npm:^7.6.0": +"semver@npm:7.6.0, semver@npm:7.x, semver@npm:^7.3.2, semver@npm:^7.3.4, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.5.3, semver@npm:^7.5.4, semver@npm:^7.6.0": version: 7.6.0 resolution: "semver@npm:7.6.0" dependencies: @@ -15093,16 +13767,6 @@ __metadata: languageName: node linkType: hard -"sha1@npm:^1.1.1": - version: 1.1.1 - resolution: "sha1@npm:1.1.1" - dependencies: - charenc: "npm:>= 0.0.1" - crypt: "npm:>= 0.0.1" - checksum: 10/da9f47e949988e2f595ef19733fd1dc736866ef6de4e421a55c13b444c03ae532e528b7350ae6ea55d9fb053be61d4648ec2cd5250d46cfdbdf4f6b4e763713d - languageName: node - linkType: hard - "shebang-command@npm:^1.2.0": version: 1.2.0 resolution: "shebang-command@npm:1.2.0" @@ -15135,7 +13799,7 @@ __metadata: languageName: node linkType: hard -"shelljs@npm:^0.8.3, shelljs@npm:^0.8.4": +"shelljs@npm:^0.8.4": version: 0.8.5 resolution: "shelljs@npm:0.8.5" dependencies: @@ -15398,88 +14062,6 @@ __metadata: languageName: node linkType: hard -"solhint-plugin-prettier@npm:^0.1.0": - version: 0.1.0 - resolution: "solhint-plugin-prettier@npm:0.1.0" - dependencies: - "@prettier/sync": "npm:^0.3.0" - prettier-linter-helpers: "npm:^1.0.0" - peerDependencies: - prettier: ^3.0.0 - prettier-plugin-solidity: ^1.0.0 - checksum: 10/241caa07b9d1570117cf0cc56371cc81c69fb17706dbc68136dfb112279c8c1cf815dbaa70c146acd06876e16d9a7385312b63302f2381868c02c3bdfa23715b - languageName: node - linkType: hard - -"solhint@npm:^3.3.6": - version: 3.6.2 - resolution: "solhint@npm:3.6.2" - dependencies: - "@solidity-parser/parser": "npm:^0.16.0" - ajv: "npm:^6.12.6" - antlr4: "npm:^4.11.0" - ast-parents: "npm:^0.0.1" - chalk: "npm:^4.1.2" - commander: "npm:^10.0.0" - cosmiconfig: "npm:^8.0.0" - fast-diff: "npm:^1.2.0" - glob: "npm:^8.0.3" - ignore: "npm:^5.2.4" - js-yaml: "npm:^4.1.0" - lodash: "npm:^4.17.21" - pluralize: "npm:^8.0.0" - prettier: "npm:^2.8.3" - semver: "npm:^7.5.2" - strip-ansi: "npm:^6.0.1" - table: "npm:^6.8.1" - text-table: "npm:^0.2.0" - dependenciesMeta: - prettier: - optional: true - bin: - solhint: solhint.js - checksum: 10/3ee71c3e2363c046b2fe4379d8cd16283e2fd5c8e07d6200b324cd82c0f22c4765cecb9b0a3c9a8097158810b4f34c4a2320b0ad1f13343035f9cd8cc16e5a41 - languageName: node - linkType: hard - -"solidity-comments-extractor@npm:^0.0.8": - version: 0.0.8 - resolution: "solidity-comments-extractor@npm:0.0.8" - checksum: 10/615d53c2e8f5e7a1ad26e4e7e3bdc8b7c7885420611fcd690864bb54a9af2813a93cf30bdede16273791bda16eebc7a4ce1379d458ac2d7834074eb4936dea70 - languageName: node - linkType: hard - -"solidity-coverage@npm:^0.8.0": - version: 0.8.12 - resolution: "solidity-coverage@npm:0.8.12" - dependencies: - "@ethersproject/abi": "npm:^5.0.9" - "@solidity-parser/parser": "npm:^0.18.0" - chalk: "npm:^2.4.2" - death: "npm:^1.1.0" - difflib: "npm:^0.2.4" - fs-extra: "npm:^8.1.0" - ghost-testrpc: "npm:^0.0.2" - global-modules: "npm:^2.0.0" - globby: "npm:^10.0.1" - jsonschema: "npm:^1.2.4" - lodash: "npm:^4.17.21" - mocha: "npm:^10.2.0" - node-emoji: "npm:^1.10.0" - pify: "npm:^4.0.1" - recursive-readdir: "npm:^2.2.2" - sc-istanbul: "npm:^0.4.5" - semver: "npm:^7.3.4" - shelljs: "npm:^0.8.3" - web3-utils: "npm:^1.3.6" - peerDependencies: - hardhat: ^2.11.0 - bin: - solidity-coverage: plugins/bin.js - checksum: 10/69f73bba3f3b24bddac00f88a1e739b08b7b37edad46757f477c7ae0422e9f0f16c9da4e8521cb5d83054e2e990dc16d8ea931a334af245e48238577f64be00f - languageName: node - linkType: hard - "source-map-resolve@npm:^0.5.0": version: 0.5.3 resolution: "source-map-resolve@npm:0.5.3" @@ -15503,7 +14085,7 @@ __metadata: languageName: node linkType: hard -"source-map-support@npm:^0.5.13, source-map-support@npm:^0.5.16, source-map-support@npm:^0.5.6, source-map-support@npm:~0.5.20": +"source-map-support@npm:^0.5.13, source-map-support@npm:^0.5.6, source-map-support@npm:~0.5.20": version: 0.5.21 resolution: "source-map-support@npm:0.5.21" dependencies: @@ -15541,15 +14123,6 @@ __metadata: languageName: node linkType: hard -"source-map@npm:~0.2.0": - version: 0.2.0 - resolution: "source-map@npm:0.2.0" - dependencies: - amdefine: "npm:>=0.0.4" - checksum: 10/616b67d874a4bce443d285db07f8e4c6b1a1e60df17ea4e4d357c8173bd4b165c97386ee0675ef67afb9a9f1bdbd511368544febc4d92c8d8d1ebda57c4e7efb - languageName: node - linkType: hard - "sourcemap-codec@npm:^1.4.8": version: 1.4.8 resolution: "sourcemap-codec@npm:1.4.8" @@ -15732,13 +14305,6 @@ __metadata: languageName: node linkType: hard -"string-format@npm:^2.0.0": - version: 2.0.0 - resolution: "string-format@npm:2.0.0" - checksum: 10/8889014e926f69aaa8d117551a84a97cd7932484f5b0ab5b5b760eb0761e5722dee6112893ea742efac5adeb1b08dfedb77d9a91192dcd683a331e06c5148a87 - languageName: node - linkType: hard - "string-length@npm:^4.0.1": version: 4.0.2 resolution: "string-length@npm:4.0.2" @@ -15760,7 +14326,7 @@ __metadata: languageName: node linkType: hard -"string-width@npm:^1.0.2 || 2, string-width@npm:^2.1.1": +"string-width@npm:^1.0.2 || 2": version: 2.1.1 resolution: "string-width@npm:2.1.1" dependencies: @@ -15835,15 +14401,6 @@ __metadata: languageName: node linkType: hard -"string_decoder@npm:~1.1.1": - version: 1.1.1 - resolution: "string_decoder@npm:1.1.1" - dependencies: - safe-buffer: "npm:~5.1.0" - checksum: 10/7c41c17ed4dea105231f6df208002ebddd732e8e9e2d619d133cecd8e0087ddfd9587d2feb3c8caf3213cbd841ada6d057f5142cae68a4e62d3540778d9819b4 - languageName: node - linkType: hard - "strip-ansi-cjs@npm:strip-ansi@^6.0.1, strip-ansi@npm:^6.0.0, strip-ansi@npm:^6.0.1": version: 6.0.1 resolution: "strip-ansi@npm:6.0.1" @@ -15940,15 +14497,6 @@ __metadata: languageName: node linkType: hard -"supports-color@npm:^3.1.0": - version: 3.2.3 - resolution: "supports-color@npm:3.2.3" - dependencies: - has-flag: "npm:^1.0.0" - checksum: 10/476a70d263a1f7ac11c26c10dfc58f0d9439edf198005b95f0e358ea8182d06b492d96320f16a841e4e968c7189044dd8c3f3037bd533480d15c7cc00e17c5d8 - languageName: node - linkType: hard - "supports-color@npm:^5.3.0": version: 5.5.0 resolution: "supports-color@npm:5.5.0" @@ -16010,51 +14558,6 @@ __metadata: languageName: node linkType: hard -"sync-request@npm:^6.0.0": - version: 6.1.0 - resolution: "sync-request@npm:6.1.0" - dependencies: - http-response-object: "npm:^3.0.1" - sync-rpc: "npm:^1.2.1" - then-request: "npm:^6.0.0" - checksum: 10/7f2b63b77c8440d36212c61b4babdf740a4ac37492f62f1da5e59e4081c940275a9d929e359ba427d2796e1e401fe00f35f0354b356b3709524a9bcda093313c - languageName: node - linkType: hard - -"sync-rpc@npm:^1.2.1": - version: 1.3.6 - resolution: "sync-rpc@npm:1.3.6" - dependencies: - get-port: "npm:^3.1.0" - checksum: 10/13c05461a32f06f9f41993374b3b9e3145105baede4097bd385e57d841ac0b47dad51737a919c1592df5b04aabdfee03f1d28562c37d5a76ef704069db1b4522 - languageName: node - linkType: hard - -"table-layout@npm:^1.0.2": - version: 1.0.2 - resolution: "table-layout@npm:1.0.2" - dependencies: - array-back: "npm:^4.0.1" - deep-extend: "npm:~0.6.0" - typical: "npm:^5.2.0" - wordwrapjs: "npm:^4.0.0" - checksum: 10/5dd12bc64ddf246f774fc51b45398dd8da900b7bb246595c84007ea292c15936264701660b80704be17da5d4066a9a250549418c40a2b635a0916c9294b103af - languageName: node - linkType: hard - -"table@npm:^6.8.0, table@npm:^6.8.1": - version: 6.8.2 - resolution: "table@npm:6.8.2" - dependencies: - ajv: "npm:^8.0.1" - lodash.truncate: "npm:^4.4.2" - slice-ansi: "npm:^4.0.0" - string-width: "npm:^4.2.3" - strip-ansi: "npm:^6.0.1" - checksum: 10/2946162eb87a91b9bf4283214d26830db96f09cf517eff18e7501d47a4770c529b432bb54c9394337c3dfd6c8dbf66581f76edb37e9838beb6ec394080af4ac2 - languageName: node - linkType: hard - "tar@npm:^4.0.2": version: 4.4.19 resolution: "tar@npm:4.4.19" @@ -16070,7 +14573,7 @@ __metadata: languageName: node linkType: hard -"tar@npm:^6.1.0, tar@npm:^6.1.11, tar@npm:^6.1.2, tar@npm:^6.2.0": +"tar@npm:^6.1.11, tar@npm:^6.1.2, tar@npm:^6.2.0": version: 6.2.1 resolution: "tar@npm:6.2.1" dependencies: @@ -16133,25 +14636,6 @@ __metadata: languageName: node linkType: hard -"then-request@npm:^6.0.0": - version: 6.0.2 - resolution: "then-request@npm:6.0.2" - dependencies: - "@types/concat-stream": "npm:^1.6.0" - "@types/form-data": "npm:0.0.33" - "@types/node": "npm:^8.0.0" - "@types/qs": "npm:^6.2.31" - caseless: "npm:~0.12.0" - concat-stream: "npm:^1.6.0" - form-data: "npm:^2.2.0" - http-basic: "npm:^8.1.1" - http-response-object: "npm:^3.0.1" - promise: "npm:^8.0.0" - qs: "npm:^6.4.0" - checksum: 10/7a33192fa03493fa7d5a40dbe2039271723c1c226aaa6db91576b439bf56393c8fe5a206478f37855c98284adf31d18c5bb7bafc94ebedae7c5bdb26a580dacc - languageName: node - linkType: hard - "throat@npm:^5.0.0": version: 5.0.0 resolution: "throat@npm:5.0.0" @@ -16277,13 +14761,6 @@ __metadata: languageName: node linkType: hard -"toml@npm:^3.0.0": - version: 3.0.0 - resolution: "toml@npm:3.0.0" - checksum: 10/cfef0966868d552bd02e741f30945a611f70841b7cddb07ea2b17441fe32543985bc0a7c0dcf7971af26fcaf8a17712a485d911f46bfe28644536e9a71a2bd09 - languageName: node - linkType: hard - "tough-cookie@npm:^4.0.0": version: 4.1.3 resolution: "tough-cookie@npm:4.1.3" @@ -16345,29 +14822,6 @@ __metadata: languageName: node linkType: hard -"ts-command-line-args@npm:^2.2.0": - version: 2.5.1 - resolution: "ts-command-line-args@npm:2.5.1" - dependencies: - chalk: "npm:^4.1.0" - command-line-args: "npm:^5.1.1" - command-line-usage: "npm:^6.1.0" - string-format: "npm:^2.0.0" - bin: - write-markdown: dist/write-markdown.js - checksum: 10/dd1b1fcd7aea599a909f037903bd4903c25e44e034dac8e1a2c049f34992c6cb4c9c692023c92d0dbd0f6183c3bd1bfff2181fee57099b6c5f296d38038224bf - languageName: node - linkType: hard - -"ts-essentials@npm:^7.0.1": - version: 7.0.3 - resolution: "ts-essentials@npm:7.0.3" - peerDependencies: - typescript: ">=3.7.0" - checksum: 10/021b4263ddd58897171f3f5c467b5c872f76ba2ea07dfc11fa9667ba8d62ccb7f390db3e581139dcc6da94c3ff6306921f574acdb2b94cbc9d7da3e859e24665 - languageName: node - linkType: hard - "ts-jest@npm:^26.5.4": version: 26.5.6 resolution: "ts-jest@npm:26.5.6" @@ -16705,28 +15159,6 @@ __metadata: languageName: node linkType: hard -"typechain@npm:^8.3.0": - version: 8.3.2 - resolution: "typechain@npm:8.3.2" - dependencies: - "@types/prettier": "npm:^2.1.1" - debug: "npm:^4.3.1" - fs-extra: "npm:^7.0.0" - glob: "npm:7.1.7" - js-sha3: "npm:^0.8.0" - lodash: "npm:^4.17.15" - mkdirp: "npm:^1.0.4" - prettier: "npm:^2.3.1" - ts-command-line-args: "npm:^2.2.0" - ts-essentials: "npm:^7.0.1" - peerDependencies: - typescript: ">=4.3.0" - bin: - typechain: dist/cli/cli.js - checksum: 10/d6dad2f70bb3914c56bac6758ba2a761a1592a8258aa9f84360fda410c27bfade0b2f49faa366df94ac3c2f567d40b3db17f4a32903ef52bc7f9a020545eeb7f - languageName: node - linkType: hard - "typed-array-buffer@npm:^1.0.2": version: 1.0.2 resolution: "typed-array-buffer@npm:1.0.2" @@ -16788,13 +15220,6 @@ __metadata: languageName: node linkType: hard -"typedarray@npm:^0.0.6": - version: 0.0.6 - resolution: "typedarray@npm:0.0.6" - checksum: 10/2cc1bcf7d8c1237f6a16c04efc06637b2c5f2d74e58e84665445cf87668b85a21ab18dd751fa49eee6ae024b70326635d7b79ad37b1c370ed2fec6aeeeb52714 - languageName: node - linkType: hard - "typedoc@npm:^0.25.8": version: 0.25.13 resolution: "typedoc@npm:0.25.13" @@ -16851,20 +15276,6 @@ __metadata: languageName: node linkType: hard -"typical@npm:^4.0.0": - version: 4.0.0 - resolution: "typical@npm:4.0.0" - checksum: 10/aefe2c24b025cda22534ae2594df4a1df5db05b5fe3692890fd51db741ca4f18937a149f968b8d56d9a7b0756e7cd8843b1907bea21987ff4a06619c54d5a575 - languageName: node - linkType: hard - -"typical@npm:^5.2.0": - version: 5.2.0 - resolution: "typical@npm:5.2.0" - checksum: 10/fd8e4197cb2e021ca6d11fea0018ee219c29bf4160ab613492f74c0e21806003d1cd92a15088b111778a7b5c6432e4e28321899785a86980b390b87c4010efe5 - languageName: node - linkType: hard - "ufo@npm:^1.3.2, ufo@npm:^1.4.0, ufo@npm:^1.5.3": version: 1.5.3 resolution: "ufo@npm:1.5.3" @@ -16872,15 +15283,6 @@ __metadata: languageName: node linkType: hard -"uglify-js@npm:^3.1.4": - version: 3.17.4 - resolution: "uglify-js@npm:3.17.4" - bin: - uglifyjs: bin/uglifyjs - checksum: 10/4c0b800e0ff192079d2c3ce8414fd3b656a570028c7c79af5c29c53d5c532b68bbcae4ad47307f89c2ee124d11826fff7a136b59d5c5bb18422bcdf5568afe1e - languageName: node - linkType: hard - "ultron@npm:~1.1.0": version: 1.1.1 resolution: "ultron@npm:1.1.1" @@ -17069,7 +15471,7 @@ __metadata: languageName: node linkType: hard -"util-deprecate@npm:^1.0.1, util-deprecate@npm:~1.0.1": +"util-deprecate@npm:^1.0.1": version: 1.0.2 resolution: "util-deprecate@npm:1.0.2" checksum: 10/474acf1146cb2701fe3b074892217553dfcf9a031280919ba1b8d651a068c9b15d863b7303cb15bd00a862b498e6cf4ad7b4a08fb134edd5a6f7641681cb54a2 @@ -17239,17 +15641,6 @@ __metadata: languageName: node linkType: hard -"wasm-pack@npm:^0.10.2": - version: 0.10.3 - resolution: "wasm-pack@npm:0.10.3" - dependencies: - binary-install: "npm:^0.1.0" - bin: - wasm-pack: run.js - checksum: 10/5274e16344018252698a39c51db3f32f1f986737abe1ab5cc811192eaaab837267d38476cb81a214cfc00c599b679bdafcdcaceea5e61fef0f06a72cc53d0ea6 - languageName: node - linkType: hard - "wasmbuilder@npm:0.0.10": version: 0.0.10 resolution: "wasmbuilder@npm:0.0.10" @@ -17560,7 +15951,7 @@ __metadata: languageName: node linkType: hard -"web3-utils@npm:1.10.4, web3-utils@npm:^1.3.0, web3-utils@npm:^1.3.6, web3-utils@npm:^1.6.0": +"web3-utils@npm:1.10.4, web3-utils@npm:^1.3.0, web3-utils@npm:^1.6.0": version: 1.10.4 resolution: "web3-utils@npm:1.10.4" dependencies: @@ -17707,7 +16098,7 @@ __metadata: languageName: node linkType: hard -"which@npm:^1.1.1, which@npm:^1.2.9, which@npm:^1.3.1": +"which@npm:^1.2.9": version: 1.3.1 resolution: "which@npm:1.3.1" dependencies: @@ -17754,23 +16145,6 @@ __metadata: languageName: node linkType: hard -"wordwrap@npm:^1.0.0": - version: 1.0.0 - resolution: "wordwrap@npm:1.0.0" - checksum: 10/497d40beb2bdb08e6d38754faa17ce20b0bf1306327f80cb777927edb23f461ee1f6bc659b3c3c93f26b08e1cf4b46acc5bae8fda1f0be3b5ab9a1a0211034cd - languageName: node - linkType: hard - -"wordwrapjs@npm:^4.0.0": - version: 4.0.1 - resolution: "wordwrapjs@npm:4.0.1" - dependencies: - reduce-flatten: "npm:^2.0.0" - typical: "npm:^5.2.0" - checksum: 10/4182c48c9d3eab0932fb9f9f202e3f1d4d28ff6db3fd2e1654ec8606677d8e0ab80110f0f8e2e236ee2b52631cbc5fccf3097e9287e3ace20cbc1613a784befc - languageName: node - linkType: hard - "worker-threads@npm:^1.0.0": version: 1.0.0 resolution: "worker-threads@npm:1.0.0" @@ -17865,21 +16239,6 @@ __metadata: languageName: node linkType: hard -"ws@npm:7.4.6": - version: 7.4.6 - resolution: "ws@npm:7.4.6" - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: ^5.0.2 - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - checksum: 10/150e3f917b7cde568d833a5ea6ccc4132e59c38d04218afcf2b6c7b845752bd011a9e0dc1303c8694d3c402a0bdec5893661a390b71ff88f0fc81a4e4e66b09c - languageName: node - linkType: hard - "ws@npm:8.5.0": version: 8.5.0 resolution: "ws@npm:8.5.0" @@ -18160,7 +16519,6 @@ __metadata: version: 0.0.0-use.local resolution: "zk-kit@workspace:." dependencies: - "@aztec/bb.js": "npm:^0.33.0" "@commitlint/cli": "npm:^18.6.1" "@commitlint/config-conventional": "npm:^18.6.2" "@types/glob": "npm:^7.2.0"