├── .github ├── NIGHTLY_CANARY_DIED.md └── workflows │ ├── benchmark.yml │ ├── nightly-canary.yml │ ├── pull-request-title.yml │ ├── release.yml │ └── test.yml ├── .gitignore ├── .release-please-manifest.json ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── Nargo.toml ├── README.md ├── info.sh ├── release-please-config.json ├── scripts └── build-gates-report.sh ├── signature_gen ├── .gitignore ├── Cargo.lock ├── Cargo.toml └── src │ └── main.rs └── src ├── bench.nr ├── lib.nr ├── rsa.nr └── types.nr /.github/NIGHTLY_CANARY_DIED.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Tests fail on latest Nargo nightly release" 3 | assignees: TomAFrench, kashbrti, jtriley-eth 4 | --- 5 | 6 | The tests on this Noir project have started failing when using the latest nightly release of the Noir compiler. This likely means that there have been breaking changes for which this project needs to be updated to take into account. 7 | 8 | Check the [{{env.WORKFLOW_NAME}}]({{env.WORKFLOW_URL}}) workflow for details. 9 | -------------------------------------------------------------------------------- /.github/workflows/benchmark.yml: -------------------------------------------------------------------------------- 1 | name: Benchmarks 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | 9 | jobs: 10 | test: 11 | name: Benchmark library 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Checkout sources 15 | uses: actions/checkout@v4 16 | 17 | - name: Install Nargo 18 | uses: noir-lang/noirup@v0.1.4 19 | with: 20 | toolchain: 1.0.0-beta.3 21 | 22 | - name: Install bb 23 | run: | 24 | npm install -g bbup 25 | bbup -nv 1.0.0-beta.3 26 | sudo apt install libc++-dev 27 | 28 | - name: Build Noir example 29 | run: nargo export 30 | 31 | - name: Generate gates report 32 | run: ./scripts/build-gates-report.sh ./export/ 33 | env: 34 | BACKEND: /home/runner/.bb/bb 35 | 36 | - name: Compare gates reports 37 | id: gates_diff 38 | uses: noir-lang/noir-gates-diff@dbe920a8dcc3370af4be4f702ca9cef29317bec1 39 | with: 40 | report: gates_report.json 41 | summaryQuantile: 0.9 # only display the 10% most significant circuit size diffs in the summary (defaults to 20%) 42 | 43 | - name: Add gates diff to sticky comment 44 | if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target' 45 | uses: marocchino/sticky-pull-request-comment@v2 46 | with: 47 | # delete the comment in case changes no longer impact circuit sizes 48 | delete: ${{ !steps.gates_diff.outputs.markdown }} 49 | message: ${{ steps.gates_diff.outputs.markdown }} 50 | -------------------------------------------------------------------------------- /.github/workflows/nightly-canary.yml: -------------------------------------------------------------------------------- 1 | name: Noir Nightly Canary 2 | 3 | on: 4 | schedule: 5 | # Run a check at 9 AM UTC 6 | - cron: "0 9 * * *" 7 | 8 | env: 9 | CARGO_TERM_COLOR: always 10 | 11 | permissions: 12 | issues: write 13 | 14 | jobs: 15 | test: 16 | name: Test on Nargo ${{matrix.toolchain}} 17 | runs-on: ubuntu-latest 18 | steps: 19 | - name: Checkout sources 20 | uses: actions/checkout@v4 21 | 22 | - name: Install Nargo 23 | uses: noir-lang/noirup@v0.1.4 24 | with: 25 | toolchain: nightly 26 | 27 | - name: Run Noir tests 28 | run: nargo test 29 | 30 | - name: Alert on dead canary 31 | uses: JasonEtco/create-an-issue@v2 32 | if: ${{ failure() }} 33 | env: 34 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 35 | WORKFLOW_NAME: ${{ github.workflow }} 36 | WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} 37 | with: 38 | update_existing: true 39 | filename: .github/NIGHTLY_CANARY_DIED.md 40 | -------------------------------------------------------------------------------- /.github/workflows/pull-request-title.yml: -------------------------------------------------------------------------------- 1 | name: Pull Request 2 | 3 | on: 4 | merge_group: 5 | pull_request_target: 6 | types: 7 | - opened 8 | - reopened 9 | - edited 10 | - synchronize 11 | 12 | permissions: 13 | pull-requests: read 14 | 15 | jobs: 16 | conventional-title: 17 | name: Validate PR title is Conventional Commit 18 | runs-on: ubuntu-latest 19 | steps: 20 | - name: Check title 21 | if: github.event_name == 'pull_request_target' 22 | uses: amannn/action-semantic-pull-request@v5 23 | env: 24 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 25 | with: 26 | types: | 27 | fix 28 | feat 29 | chore 30 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | release-please: 10 | name: Create Release 11 | outputs: 12 | release-pr: ${{ steps.release.outputs.pr }} 13 | tag-name: ${{ steps.release.outputs.tag_name }} 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Run release-please 17 | id: release 18 | uses: google-github-actions/release-please-action@v3 19 | with: 20 | token: ${{ secrets.GITHUB_TOKEN }} 21 | command: manifest 22 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Noir tests 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | 9 | env: 10 | CARGO_TERM_COLOR: always 11 | MINIMUM_NOIR_VERSION: v1.0.0-beta.3 12 | 13 | jobs: 14 | noir-version-list: 15 | name: Query supported Noir versions 16 | runs-on: ubuntu-latest 17 | outputs: 18 | noir_versions: ${{ steps.get_versions.outputs.versions }} 19 | 20 | steps: 21 | - name: Checkout sources 22 | id: get_versions 23 | run: | 24 | # gh returns the Noir releases in reverse chronological order so we keep all releases published after the minimum supported version. 25 | VERSIONS=$(gh release list -R noir-lang/noir --exclude-pre-releases --json tagName -q 'map(.tagName) | index(env.MINIMUM_NOIR_VERSION) as $index | if $index then .[0:$index+1] else [env.MINIMUM_NOIR_VERSION] end') 26 | echo "versions=$VERSIONS" 27 | echo "versions=$VERSIONS" >> $GITHUB_OUTPUT 28 | env: 29 | GH_TOKEN: ${{ github.token }} 30 | 31 | test: 32 | needs: [noir-version-list] 33 | name: Test on Nargo ${{matrix.toolchain}} 34 | runs-on: ubuntu-latest 35 | strategy: 36 | fail-fast: false 37 | matrix: 38 | toolchain: ${{ fromJson( needs.noir-version-list.outputs.noir_versions )}} 39 | include: 40 | - toolchain: nightly 41 | steps: 42 | - name: Checkout sources 43 | uses: actions/checkout@v4 44 | 45 | - name: Install Nargo 46 | uses: noir-lang/noirup@v0.1.4 47 | with: 48 | toolchain: ${{ matrix.toolchain }} 49 | 50 | - name: Run Noir tests 51 | run: nargo test 52 | 53 | format: 54 | needs: [noir-version-list] 55 | runs-on: ubuntu-latest 56 | steps: 57 | - name: Checkout sources 58 | uses: actions/checkout@v4 59 | 60 | - name: Install Nargo 61 | uses: noir-lang/noirup@v0.1.3 62 | with: 63 | toolchain: ${{env.MINIMUM_NOIR_VERSION}} 64 | 65 | - name: Run formatter 66 | run: nargo fmt --check 67 | 68 | # This is a job which depends on all test jobs and reports the overall status. 69 | # This allows us to add/remove test jobs without having to update the required workflows. 70 | tests-end: 71 | name: Noir End 72 | runs-on: ubuntu-latest 73 | # We want this job to always run (even if the dependant jobs fail) as we want this job to fail rather than skipping. 74 | if: ${{ always() }} 75 | needs: 76 | - test 77 | - format 78 | 79 | steps: 80 | - name: Report overall success 81 | run: | 82 | if [[ $FAIL == true ]]; then 83 | exit 1 84 | else 85 | exit 0 86 | fi 87 | env: 88 | # We treat any cancelled, skipped or failing jobs as a failure for the workflow as a whole. 89 | FAIL: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped') }} 90 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | export 3 | gates_report.json 4 | 5 | **/.DS_Store 6 | .vscode 7 | -------------------------------------------------------------------------------- /.release-please-manifest.json: -------------------------------------------------------------------------------- 1 | {".":"0.7.0"} 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [0.7.0](https://github.com/noir-lang/noir_rsa/compare/v0.6.0...v0.7.0) (2025-03-03) 4 | 5 | 6 | ### ⚠ BREAKING CHANGES 7 | 8 | * bump bignum to `v0.6.0` ([#47](https://github.com/noir-lang/noir_rsa/issues/47)) 9 | 10 | ### Miscellaneous Chores 11 | 12 | * Bump bignum to `v0.6.0` ([#47](https://github.com/noir-lang/noir_rsa/issues/47)) ([944c159](https://github.com/noir-lang/noir_rsa/commit/944c159ac8e0ed14a5d381421d0dd2248bc00940)) 13 | 14 | ## [0.6.0](https://github.com/noir-lang/noir_rsa/compare/v0.5.1...v0.6.0) (2025-02-18) 15 | 16 | 17 | ### ⚠ BREAKING CHANGES 18 | 19 | * bump bignum to `v0.5.4` ([#45](https://github.com/noir-lang/noir_rsa/issues/45)) 20 | 21 | ### Miscellaneous Chores 22 | 23 | * Bump bignum to `v0.5.4` ([#45](https://github.com/noir-lang/noir_rsa/issues/45)) ([be8889d](https://github.com/noir-lang/noir_rsa/commit/be8889d0abf2629407e06d4aa4213d272c619428)) 24 | 25 | ## [0.5.1](https://github.com/noir-lang/noir_rsa/compare/v0.5.0...v0.5.1) (2025-01-29) 26 | 27 | 28 | ### Features 29 | 30 | * Bump `bignum` to `v0.5.2` ([#43](https://github.com/noir-lang/noir_rsa/issues/43)) ([1000347](https://github.com/noir-lang/noir_rsa/commit/10003472e526e477aa433eff49410f4980e96db9)) 31 | 32 | ## [0.5.0](https://github.com/noir-lang/noir_rsa/compare/v0.4.1...v0.5.0) (2025-01-09) 33 | 34 | 35 | ### ⚠ BREAKING CHANGES 36 | 37 | * bump `noir-bignum` to `v0.5.0` ([#40](https://github.com/noir-lang/noir_rsa/issues/40)) 38 | 39 | ### Features 40 | 41 | * Bump `noir-bignum` to `v0.5.0` ([#40](https://github.com/noir-lang/noir_rsa/issues/40)) ([068cf97](https://github.com/noir-lang/noir_rsa/commit/068cf971a6670d9075eb2a4febfb300fb79d4186)) 42 | 43 | ## [0.4.1](https://github.com/noir-lang/noir_rsa/compare/v0.4.0...v0.4.1) (2024-12-04) 44 | 45 | 46 | ### Features 47 | 48 | * Update to bignum `v0.4.2` ([#32](https://github.com/noir-lang/noir_rsa/issues/32)) ([536c436](https://github.com/noir-lang/noir_rsa/commit/536c436412240b3b53682d0898a35690327dc2dc)) 49 | 50 | ## [0.4.0](https://github.com/noir-lang/noir_rsa/compare/v0.3.1...v0.4.0) (2024-11-08) 51 | 52 | 53 | ### ⚠ BREAKING CHANGES 54 | 55 | * update to noir-bignum v0.4.1 ([#30](https://github.com/noir-lang/noir_rsa/issues/30)) 56 | 57 | ### Features 58 | 59 | * Update to noir-bignum 0.3.6 and nargo 0.35.0 ([#23](https://github.com/noir-lang/noir_rsa/issues/23)) ([8784b19](https://github.com/noir-lang/noir_rsa/commit/8784b1910ccc4c0eda0a75f1a40d416162487335)) 60 | * Update to noir-bignum v0.4.1 ([#30](https://github.com/noir-lang/noir_rsa/issues/30)) ([e54d13d](https://github.com/noir-lang/noir_rsa/commit/e54d13dd71c83eb926cdfdb5a6ae37e242461a91)) 61 | 62 | ## [0.3.1](https://github.com/noir-lang/noir_rsa/compare/v0.3.0...v0.3.1) (2024-10-04) 63 | 64 | 65 | ### Bug Fixes 66 | 67 | * Update bignum dependency ([#18](https://github.com/noir-lang/noir_rsa/issues/18)) ([499a7f8](https://github.com/noir-lang/noir_rsa/commit/499a7f81348a7ba03120801cd2a1a4e091ab0ed5)) 68 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Thank you for your interest in contributing! We value your contributions. 🙏 4 | 5 | This guide will discuss how the team handles [Commits](#commits), [Pull Requests](#pull-requests), [Releases](#releases), the [Changelog](#changelog), and [Response time](#response-time). 6 | 7 | **Note:** We won't force external contributors to follow this verbatim, but following these guidelines definitely helps us in accepting your contributions. 8 | 9 | ## Commits 10 | 11 | We want to keep our commits small and focused. This allows for easily reviewing individual commits and/or splitting up pull requests when they grow too big. Additionally, this allows us to merge smaller changes quicker. 12 | 13 | When committing, it's often useful to use the `git add -p` workflow to decide on what parts of the changeset to stage for commit. 14 | 15 | ## Pull Requests 16 | 17 | Before you create a pull request, search for any issues related to the change you are making. If none exist already, create an issue that thoroughly describes the problem that you are trying to solve. These are used to inform reviewers of the original intent and should be referenced via the pull request template. 18 | 19 | Pull Requests should be focused on the specific change they are working towards. If prerequisite work is required to complete the original pull request, that work should be submitted as a separate pull request. 20 | 21 | This strategy avoids scenarios where pull requests grow too large/out-of-scope and don't get proper reviews—we want to avoid "LGTM, I trust you" reviews. 22 | 23 | ### Conventional Commits 24 | 25 | We use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) naming conventions for PRs, which help with releases and changelogs. Please use the following format for PR titles: 26 | 27 | ``` 28 | [optional scope]: 29 | ``` 30 | 31 | Generally, we want to only use the three primary types defined by the specification: 32 | 33 | - `feat:` - This should be the most used type, as most work we are doing in the project are new features. Commits using this type will always show up in the Changelog. 34 | - `fix:` - When fixing a bug, we should use this type. Commits using this type will always show up in the Changelog. 35 | - `chore:` - The least used type, these are not included in the Changelog unless they are breaking changes. But remain useful for an understandable commit history. 36 | 37 | #### Breaking Changes 38 | 39 | Annotating BREAKING CHANGES is extremely important to our release process and versioning. To mark a commit as breaking, we add the ! character after the type, but before the colon. For example: 40 | 41 | ``` 42 | feat!: Rename nargo build to nargo check (#693) 43 | ``` 44 | 45 | ``` 46 | feat(nargo)!: Enforce minimum rustc version 47 | ``` 48 | 49 | #### Scopes 50 | 51 | Scopes significantly improve the Changelog, so we want to use a scope whenever possible. If we are only changing one part of the project, we can use the name of the crate, like (nargo) or (noirc_driver). If a change touches multiple parts of the codebase, there might be a better scope, such as using (syntax) for new language features. 52 | 53 | ``` 54 | feat(nargo): Add support for wasm backend (#234) 55 | ``` 56 | 57 | ``` 58 | feat(syntax): Implement String data type (#123) 59 | ``` 60 | 61 | ### Typos and other small changes 62 | 63 | Significant changes, like new features or important bug fixes, typically have a more pronounced impact on the project’s overall development. For smaller fixes, such as typos, we encourage you to report them as Issues instead of opening PRs. This approach helps us manage our resources effectively and ensures that every change contributes meaningfully to the project. PRs involving such smaller fixes will likely be closed and incorporated in PRs authored by the core team. 64 | 65 | ### Reviews 66 | 67 | For any repository in the organization, we require code review & approval by **one** team member before the changes are merged, as enforced by GitHub branch protection. Non-breaking pull requests may be merged at any time. Breaking pull requests should only be merged when the team has general agreement of the changes and is preparing a breaking release. 68 | 69 | ### Documentation 70 | 71 | Breaking changes must be documented, either through adding/updating existing docs or README.md. 72 | 73 | ## Releases 74 | 75 | Releases are managed by [Release Please](https://github.com/googleapis/release-please) which runs in a GitHub Action whenever a commit is made on the master branch. 76 | 77 | Release Please parses Conventional Commit messages and opens (or updates) a pull request against the master branch that contains updates to the versions & Changelog within the project. If it doesn't detect any breaking change commits, it will only increment the "patch" version; however, if it detects a breaking change commit, it will increment the "minor" version number to indicate a breaking release. 78 | 79 | When we are ready to release the version, we approve and squash merge the release pull request into master. Release Please will detect this merge and generate the appropriate tags for the release. Additional release steps may be triggered inside the GitHub Action to automate other parts of the release process. 80 | 81 | There is no strict release cadence, but a new release is usually cut every 1 to 2 months. 82 | 83 | ## Changelog 84 | 85 | The Changelog is automatically managed by Release Please and informed by the Conventional Commits (as discussed above). 86 | 87 | ## Response time 88 | 89 | The team will respond to issues and PRs within 1 week from submission. 90 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Nargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "noir_rsa" 3 | type = "lib" 4 | authors = [""] 5 | compiler_version = ">=1.0.0" 6 | 7 | [dependencies] 8 | bignum = {tag = "v0.6.0", git = "https://github.com/noir-lang/noir-bignum"} 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # noir_rsa 2 | 3 | > [!IMPORTANT] 4 | > This library is no longer being actively developed by the noir-lang team. We recommend using the fork which is maintained by the [zkpassport](https://zkpassport.id) team which can be found at: https://github.com/zkpassport/noir_rsa 5 | 6 | Optimized Noir library that evaluates RSA signatures. 7 | 8 | This library uses as a dependency. 9 | 10 | ## Noir version compatibility 11 | 12 | This library is tested with all Noir stable releases from v1.0.0-beta.0. 13 | 14 | ## Benchmarks 15 | 16 | The benchmarking source code and its details can be found in [this repository](https://github.com/hashcloak/noir_rsa_bench). 17 | 18 | For the results, "UP" stands for UltraPlonk and "UH" stands for UltraHonk. 19 | 20 | The benchmark results for the verification of one signature are the following: 21 | 22 | | **Bit length** | **Circuit size** | **Avg. proving time (UP) [ms]** | **Avg. proving time (UH) [ms]** | 23 | |----------------|------------------|---------------------------------|--------------------------------------| 24 | | 1024 | 2204 | 234.8 | 181 | 25 | | 2048 | 7131 | 345.6 | 261.9 | 26 | 27 | Also, the results for the verification of 10 signatures are the following: 28 | 29 | | **Bit length** | **Circuit size** | **Avg. proving time (UP) [ms]** | **Avg. proving time (UH) [ms]** | 30 | |----------------|------------------|---------------------------------|--------------------------------------| 31 | | 1024 | 21516 | 970.9 | 514.4 | 32 | | 2048 | 63821 | 1801.7 | 964.2 | 33 | 34 | The benchmarks were executed using a laptop with Intel(R) Core(TM) i7-13700H CPU and 32 GB of RAM. 35 | 36 | ## Installation 37 | 38 | In your _Nargo.toml_ file, add the version of this library you would like to install under dependency: 39 | 40 | ``` 41 | [dependencies] 42 | noir_rsa = { tag = "v0.3.3", git = "https://github.com/noir-lang/noir_rsa" } 43 | ``` 44 | 45 | ## Usage 46 | 47 | See tests in `lib.nr` for examples. 48 | 49 | ## End-to-end example 50 | 51 | ### Generate RSA signature 52 | 53 | To verify an RSA signature, you first need a signature. 54 | 55 | Depending on the application you are building, you might be expecting user signatures from existing signing services (e.g. emails, passports, git commits), or you might be building the ability for users to sign directly in your application. 56 | 57 | Either way, you are free to choose how you collect / generate the signatures as long as they comply with the PKCS#1 v1.5 RSA cryptography specifications (ex. by following ). 58 | 59 | You need to install Rustup and run it in order to install Rust: 60 | 61 | ```bash 62 | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh 63 | rustup 64 | ``` 65 | 66 | Then clone this repo, move into the `signature_gen` folder, and run `cargo run`, optionally with the message to sign: 67 | 68 | ```bash 69 | cd signature_gen 70 | cargo run # or cargo run -- --msg "hello world!" 71 | ``` 72 | 73 | The program prints the hash of the message, the RSA signature, and the BigNumber instance you should use. These are parsed to a compatible format, ready to be used in the Noir RSA library. 74 | 75 | #### Use it in your Noir test 76 | 77 | Move into the `example` folder. Replace the hardcoded values with result of the previous step. Since you know the size of your key, you can import those types from the rsa lib: 78 | 79 | ```diff 80 | - let hash: [u8; 32] = etc... 81 | - let signature: BN2048 = etc... 82 | - let bn = etc... 83 | + let hash: [u8; 32] = paste from terminal... 84 | + let signature: BN2048 = paste from terminal... 85 | + let bn = paste from terminal... 86 | ``` 87 | 88 | Run the test: 89 | 90 | ```bash 91 | nargo test 92 | ``` 93 | 94 | #### Prove it 95 | 96 | Run `nargo check` to initialize `Prover.toml`: 97 | 98 | ```bash 99 | nargo check 100 | ``` 101 | 102 | Run the same `cargo` command, but with the `--toml` flag: 103 | 104 | ```bash 105 | cargo run -- --msg "hello world!" --toml 106 | ``` 107 | 108 | Copy and paste it to Prover.toml. Example: 109 | 110 | ```toml 111 | bn = [ 112 | [ 113 | "0xcba7415fa9d2192d5cdac144f95f75", 114 | "0x2b46305b91eeed9e9a992076172b46", 115 | "0x76c9e6e0a407e67bc0a3ee276927d7", 116 | "0x0d0eaa3b10ab266755ea20c44619f6", 117 | "0x4b040e9ab1acb761b1ab9a60309ee4", 118 | "...etc" 119 | ] 120 | ] 121 | ``` 122 | 123 | Then execute it, and prove it i.e. with barretenberg: 124 | 125 | ```bash 126 | nargo execute rsa 127 | bb prove -b ./target/example.json -w ./target/rsa.gz -o ./target/proof 128 | ``` 129 | 130 | ### Verify it 131 | 132 | To verify, we need to export the verification key: 133 | 134 | ```bash 135 | bb write_vk -b ./target/example.json -o ./target/vk 136 | ``` 137 | 138 | And verify: 139 | 140 | ```bash 141 | bb verify -k ./target/vk -p ./target/proof 142 | ``` 143 | -------------------------------------------------------------------------------- /info.sh: -------------------------------------------------------------------------------- 1 | (cd example && nargo compile --force --silence-warnings && bb gates -b ./target/example.json | grep "circuit") -------------------------------------------------------------------------------- /release-please-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "release-type": "simple", 3 | "bump-minor-pre-major": true, 4 | "bump-patch-for-minor-pre-major": true, 5 | "pull-request-title-pattern": "chore: Release ${version}", 6 | "group-pull-request-title-pattern": "chore: Release ${version}", 7 | "packages": { 8 | ".": { 9 | "release-type": "simple", 10 | "include-component-in-tag": false 11 | } 12 | }, 13 | "plugins": [ 14 | "sentence-case" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /scripts/build-gates-report.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | BACKEND=${BACKEND:-bb} 5 | 6 | cd $(dirname "$0")/../ 7 | 8 | artifacts_path=${1:-"./export"} 9 | artifacts=$(ls $artifacts_path) 10 | 11 | echo "{\"programs\": [" > gates_report.json 12 | 13 | # Bound for checking where to place last parentheses 14 | NUM_ARTIFACTS=$(ls -1q "$artifacts_path" | wc -l) 15 | 16 | ITER="1" 17 | for artifact in $artifacts; do 18 | ARTIFACT_NAME=$(basename "$artifact") 19 | 20 | GATES_INFO=$($BACKEND gates -b "$artifacts_path/$artifact") 21 | MAIN_FUNCTION_INFO=$(echo $GATES_INFO | jq -r ".functions[0] | {package_name: "\"$ARTIFACT_NAME\"", functions: [{name: \"main\", acir_opcodes, opcodes: .acir_opcodes, circuit_size}], unconstrained_functions: []}") 22 | echo -n $MAIN_FUNCTION_INFO >> gates_report.json 23 | 24 | if (($ITER == $NUM_ARTIFACTS)); then 25 | echo "" >> gates_report.json 26 | else 27 | echo "," >> gates_report.json 28 | fi 29 | 30 | ITER=$(( $ITER + 1 )) 31 | done 32 | 33 | echo "]}" >> gates_report.json 34 | 35 | 36 | -------------------------------------------------------------------------------- /signature_gen/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | ./.DS_Store -------------------------------------------------------------------------------- /signature_gen/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "aes" 7 | version = "0.8.4" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" 10 | dependencies = [ 11 | "cfg-if", 12 | "cipher", 13 | "cpufeatures", 14 | ] 15 | 16 | [[package]] 17 | name = "ansi_term" 18 | version = "0.12.1" 19 | source = "registry+https://github.com/rust-lang/crates.io-index" 20 | checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" 21 | dependencies = [ 22 | "winapi", 23 | ] 24 | 25 | [[package]] 26 | name = "atty" 27 | version = "0.2.14" 28 | source = "registry+https://github.com/rust-lang/crates.io-index" 29 | checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 30 | dependencies = [ 31 | "hermit-abi", 32 | "libc", 33 | "winapi", 34 | ] 35 | 36 | [[package]] 37 | name = "autocfg" 38 | version = "1.3.0" 39 | source = "registry+https://github.com/rust-lang/crates.io-index" 40 | checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" 41 | 42 | [[package]] 43 | name = "base16ct" 44 | version = "0.2.0" 45 | source = "registry+https://github.com/rust-lang/crates.io-index" 46 | checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" 47 | 48 | [[package]] 49 | name = "base64ct" 50 | version = "1.6.0" 51 | source = "registry+https://github.com/rust-lang/crates.io-index" 52 | checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" 53 | 54 | [[package]] 55 | name = "bit-set" 56 | version = "0.5.3" 57 | source = "registry+https://github.com/rust-lang/crates.io-index" 58 | checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" 59 | dependencies = [ 60 | "bit-vec", 61 | ] 62 | 63 | [[package]] 64 | name = "bit-vec" 65 | version = "0.6.3" 66 | source = "registry+https://github.com/rust-lang/crates.io-index" 67 | checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" 68 | 69 | [[package]] 70 | name = "bitflags" 71 | version = "1.3.2" 72 | source = "registry+https://github.com/rust-lang/crates.io-index" 73 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 74 | 75 | [[package]] 76 | name = "bitflags" 77 | version = "2.6.0" 78 | source = "registry+https://github.com/rust-lang/crates.io-index" 79 | checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" 80 | 81 | [[package]] 82 | name = "block-buffer" 83 | version = "0.10.4" 84 | source = "registry+https://github.com/rust-lang/crates.io-index" 85 | checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" 86 | dependencies = [ 87 | "generic-array 0.14.7", 88 | ] 89 | 90 | [[package]] 91 | name = "block-buffer" 92 | version = "0.11.0-pre.5" 93 | source = "registry+https://github.com/rust-lang/crates.io-index" 94 | checksum = "3ded684142010808eb980d9974ef794da2bcf97d13396143b1515e9f0fb4a10e" 95 | dependencies = [ 96 | "crypto-common 0.2.0-pre.5", 97 | ] 98 | 99 | [[package]] 100 | name = "block-padding" 101 | version = "0.3.3" 102 | source = "registry+https://github.com/rust-lang/crates.io-index" 103 | checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93" 104 | dependencies = [ 105 | "generic-array 0.14.7", 106 | ] 107 | 108 | [[package]] 109 | name = "byteorder" 110 | version = "1.5.0" 111 | source = "registry+https://github.com/rust-lang/crates.io-index" 112 | checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" 113 | 114 | [[package]] 115 | name = "cbc" 116 | version = "0.1.2" 117 | source = "registry+https://github.com/rust-lang/crates.io-index" 118 | checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6" 119 | dependencies = [ 120 | "cipher", 121 | ] 122 | 123 | [[package]] 124 | name = "cfg-if" 125 | version = "1.0.0" 126 | source = "registry+https://github.com/rust-lang/crates.io-index" 127 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 128 | 129 | [[package]] 130 | name = "cipher" 131 | version = "0.4.4" 132 | source = "registry+https://github.com/rust-lang/crates.io-index" 133 | checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" 134 | dependencies = [ 135 | "crypto-common 0.1.6", 136 | "inout", 137 | ] 138 | 139 | [[package]] 140 | name = "clap" 141 | version = "2.34.0" 142 | source = "registry+https://github.com/rust-lang/crates.io-index" 143 | checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" 144 | dependencies = [ 145 | "ansi_term", 146 | "atty", 147 | "bitflags 1.3.2", 148 | "strsim", 149 | "textwrap", 150 | "unicode-width", 151 | "vec_map", 152 | ] 153 | 154 | [[package]] 155 | name = "const-oid" 156 | version = "0.10.0-pre.2" 157 | source = "registry+https://github.com/rust-lang/crates.io-index" 158 | checksum = "f7e3352a27098ba6b09546e5f13b15165e6a88b5c2723afecb3ea9576b27e3ea" 159 | 160 | [[package]] 161 | name = "cpufeatures" 162 | version = "0.2.12" 163 | source = "registry+https://github.com/rust-lang/crates.io-index" 164 | checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" 165 | dependencies = [ 166 | "libc", 167 | ] 168 | 169 | [[package]] 170 | name = "crypto-common" 171 | version = "0.1.6" 172 | source = "registry+https://github.com/rust-lang/crates.io-index" 173 | checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" 174 | dependencies = [ 175 | "generic-array 0.14.7", 176 | "typenum", 177 | ] 178 | 179 | [[package]] 180 | name = "crypto-common" 181 | version = "0.2.0-pre.5" 182 | source = "registry+https://github.com/rust-lang/crates.io-index" 183 | checksum = "b7aa2ec04f5120b830272a481e8d9d8ba4dda140d2cda59b0f1110d5eb93c38e" 184 | dependencies = [ 185 | "getrandom", 186 | "hybrid-array", 187 | "rand_core", 188 | ] 189 | 190 | [[package]] 191 | name = "der" 192 | version = "0.8.0-pre.0" 193 | source = "registry+https://github.com/rust-lang/crates.io-index" 194 | checksum = "b489fd2221710c1dd46637d66b984161fb66134f81437a8489800306bcc2ecea" 195 | dependencies = [ 196 | "const-oid", 197 | "pem-rfc7468", 198 | "zeroize", 199 | ] 200 | 201 | [[package]] 202 | name = "digest" 203 | version = "0.10.7" 204 | source = "registry+https://github.com/rust-lang/crates.io-index" 205 | checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" 206 | dependencies = [ 207 | "block-buffer 0.10.4", 208 | "crypto-common 0.1.6", 209 | "subtle", 210 | ] 211 | 212 | [[package]] 213 | name = "digest" 214 | version = "0.11.0-pre.8" 215 | source = "registry+https://github.com/rust-lang/crates.io-index" 216 | checksum = "065d93ead7c220b85d5b4be4795d8398eac4ff68b5ee63895de0a3c1fb6edf25" 217 | dependencies = [ 218 | "block-buffer 0.11.0-pre.5", 219 | "const-oid", 220 | "crypto-common 0.2.0-pre.5", 221 | ] 222 | 223 | [[package]] 224 | name = "errno" 225 | version = "0.3.9" 226 | source = "registry+https://github.com/rust-lang/crates.io-index" 227 | checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" 228 | dependencies = [ 229 | "libc", 230 | "windows-sys", 231 | ] 232 | 233 | [[package]] 234 | name = "fastrand" 235 | version = "2.1.0" 236 | source = "registry+https://github.com/rust-lang/crates.io-index" 237 | checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" 238 | 239 | [[package]] 240 | name = "fnv" 241 | version = "1.0.7" 242 | source = "registry+https://github.com/rust-lang/crates.io-index" 243 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 244 | 245 | [[package]] 246 | name = "generic-array" 247 | version = "0.14.7" 248 | source = "registry+https://github.com/rust-lang/crates.io-index" 249 | checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" 250 | dependencies = [ 251 | "typenum", 252 | "version_check", 253 | ] 254 | 255 | [[package]] 256 | name = "generic-array" 257 | version = "1.1.0" 258 | source = "registry+https://github.com/rust-lang/crates.io-index" 259 | checksum = "96512db27971c2c3eece70a1e106fbe6c87760234e31e8f7e5634912fe52794a" 260 | dependencies = [ 261 | "typenum", 262 | ] 263 | 264 | [[package]] 265 | name = "getrandom" 266 | version = "0.2.15" 267 | source = "registry+https://github.com/rust-lang/crates.io-index" 268 | checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" 269 | dependencies = [ 270 | "cfg-if", 271 | "libc", 272 | "wasi", 273 | ] 274 | 275 | [[package]] 276 | name = "hermit-abi" 277 | version = "0.1.19" 278 | source = "registry+https://github.com/rust-lang/crates.io-index" 279 | checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" 280 | dependencies = [ 281 | "libc", 282 | ] 283 | 284 | [[package]] 285 | name = "hex" 286 | version = "0.4.3" 287 | source = "registry+https://github.com/rust-lang/crates.io-index" 288 | checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" 289 | 290 | [[package]] 291 | name = "hex-literal" 292 | version = "0.4.1" 293 | source = "registry+https://github.com/rust-lang/crates.io-index" 294 | checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" 295 | 296 | [[package]] 297 | name = "hmac" 298 | version = "0.12.1" 299 | source = "registry+https://github.com/rust-lang/crates.io-index" 300 | checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" 301 | dependencies = [ 302 | "digest 0.10.7", 303 | ] 304 | 305 | [[package]] 306 | name = "hybrid-array" 307 | version = "0.2.0-rc.9" 308 | source = "registry+https://github.com/rust-lang/crates.io-index" 309 | checksum = "4d306b679262030ad8813a82d4915fc04efff97776e4db7f8eb5137039d56400" 310 | dependencies = [ 311 | "typenum", 312 | ] 313 | 314 | [[package]] 315 | name = "inout" 316 | version = "0.1.3" 317 | source = "registry+https://github.com/rust-lang/crates.io-index" 318 | checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" 319 | dependencies = [ 320 | "block-padding", 321 | "generic-array 0.14.7", 322 | ] 323 | 324 | [[package]] 325 | name = "itoa" 326 | version = "1.0.11" 327 | source = "registry+https://github.com/rust-lang/crates.io-index" 328 | checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" 329 | 330 | [[package]] 331 | name = "keccak" 332 | version = "0.2.0-pre.0" 333 | source = "registry+https://github.com/rust-lang/crates.io-index" 334 | checksum = "a7cdd4f0dc5807b9a2b25dd48a3f58e862606fe7bd47f41ecde36e97422d7e90" 335 | dependencies = [ 336 | "cpufeatures", 337 | ] 338 | 339 | [[package]] 340 | name = "lazy_static" 341 | version = "1.5.0" 342 | source = "registry+https://github.com/rust-lang/crates.io-index" 343 | checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" 344 | dependencies = [ 345 | "spin", 346 | ] 347 | 348 | [[package]] 349 | name = "libc" 350 | version = "0.2.155" 351 | source = "registry+https://github.com/rust-lang/crates.io-index" 352 | checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" 353 | 354 | [[package]] 355 | name = "libm" 356 | version = "0.2.8" 357 | source = "registry+https://github.com/rust-lang/crates.io-index" 358 | checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" 359 | 360 | [[package]] 361 | name = "linux-raw-sys" 362 | version = "0.4.14" 363 | source = "registry+https://github.com/rust-lang/crates.io-index" 364 | checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" 365 | 366 | [[package]] 367 | name = "noir-bignum-paramgen" 368 | version = "0.1.5" 369 | source = "registry+https://github.com/rust-lang/crates.io-index" 370 | checksum = "4a2f214558ab24dd9af1d905187b42024370600b9458be46ab34c9af2f11e441" 371 | dependencies = [ 372 | "hex", 373 | "itoa", 374 | "num-bigint-dig", 375 | "num-integer", 376 | "num-traits", 377 | ] 378 | 379 | [[package]] 380 | name = "num-bigint-dig" 381 | version = "0.8.4" 382 | source = "registry+https://github.com/rust-lang/crates.io-index" 383 | checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" 384 | dependencies = [ 385 | "byteorder", 386 | "lazy_static", 387 | "libm", 388 | "num-integer", 389 | "num-iter", 390 | "num-traits", 391 | "rand", 392 | "smallvec", 393 | "zeroize", 394 | ] 395 | 396 | [[package]] 397 | name = "num-integer" 398 | version = "0.1.46" 399 | source = "registry+https://github.com/rust-lang/crates.io-index" 400 | checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" 401 | dependencies = [ 402 | "num-traits", 403 | ] 404 | 405 | [[package]] 406 | name = "num-iter" 407 | version = "0.1.45" 408 | source = "registry+https://github.com/rust-lang/crates.io-index" 409 | checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" 410 | dependencies = [ 411 | "autocfg", 412 | "num-integer", 413 | "num-traits", 414 | ] 415 | 416 | [[package]] 417 | name = "num-traits" 418 | version = "0.2.19" 419 | source = "registry+https://github.com/rust-lang/crates.io-index" 420 | checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" 421 | dependencies = [ 422 | "autocfg", 423 | "libm", 424 | ] 425 | 426 | [[package]] 427 | name = "pbkdf2" 428 | version = "0.12.2" 429 | source = "registry+https://github.com/rust-lang/crates.io-index" 430 | checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" 431 | dependencies = [ 432 | "digest 0.10.7", 433 | "hmac", 434 | ] 435 | 436 | [[package]] 437 | name = "pem-rfc7468" 438 | version = "1.0.0-pre.0" 439 | source = "registry+https://github.com/rust-lang/crates.io-index" 440 | checksum = "76a65e1c27d1680f8805b3f8c9949f08d6aa5d6cbd088c9896e64a53821dc27d" 441 | dependencies = [ 442 | "base64ct", 443 | ] 444 | 445 | [[package]] 446 | name = "pkcs1" 447 | version = "0.8.0-pre.0" 448 | source = "registry+https://github.com/rust-lang/crates.io-index" 449 | checksum = "4f6af6e88ac39402f67488e22faa9eb15cf065f520cf4a09419393691a6d0133" 450 | dependencies = [ 451 | "der", 452 | "pkcs8", 453 | "spki", 454 | ] 455 | 456 | [[package]] 457 | name = "pkcs5" 458 | version = "0.8.0-pre.0" 459 | source = "registry+https://github.com/rust-lang/crates.io-index" 460 | checksum = "2c6aebdab8ec0fe71f347de8d37212be79ccdedeb0f46133b0cf2bc5f6d2c65a" 461 | dependencies = [ 462 | "aes", 463 | "cbc", 464 | "der", 465 | "pbkdf2", 466 | "scrypt", 467 | "sha2 0.10.8", 468 | "spki", 469 | ] 470 | 471 | [[package]] 472 | name = "pkcs8" 473 | version = "0.11.0-pre.0" 474 | source = "registry+https://github.com/rust-lang/crates.io-index" 475 | checksum = "935c09e0aecb0cb8f8907b57438b19a068cb74a25189b06724f061170b2465ff" 476 | dependencies = [ 477 | "der", 478 | "pkcs5", 479 | "rand_core", 480 | "spki", 481 | ] 482 | 483 | [[package]] 484 | name = "ppv-lite86" 485 | version = "0.2.17" 486 | source = "registry+https://github.com/rust-lang/crates.io-index" 487 | checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" 488 | 489 | [[package]] 490 | name = "proc-macro2" 491 | version = "1.0.86" 492 | source = "registry+https://github.com/rust-lang/crates.io-index" 493 | checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" 494 | dependencies = [ 495 | "unicode-ident", 496 | ] 497 | 498 | [[package]] 499 | name = "proptest" 500 | version = "1.5.0" 501 | source = "registry+https://github.com/rust-lang/crates.io-index" 502 | checksum = "b4c2511913b88df1637da85cc8d96ec8e43a3f8bb8ccb71ee1ac240d6f3df58d" 503 | dependencies = [ 504 | "bit-set", 505 | "bit-vec", 506 | "bitflags 2.6.0", 507 | "lazy_static", 508 | "num-traits", 509 | "rand", 510 | "rand_chacha", 511 | "rand_xorshift", 512 | "regex-syntax", 513 | "rusty-fork", 514 | "tempfile", 515 | "unarray", 516 | ] 517 | 518 | [[package]] 519 | name = "quick-error" 520 | version = "1.2.3" 521 | source = "registry+https://github.com/rust-lang/crates.io-index" 522 | checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" 523 | 524 | [[package]] 525 | name = "quote" 526 | version = "1.0.36" 527 | source = "registry+https://github.com/rust-lang/crates.io-index" 528 | checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" 529 | dependencies = [ 530 | "proc-macro2", 531 | ] 532 | 533 | [[package]] 534 | name = "rand" 535 | version = "0.8.5" 536 | source = "registry+https://github.com/rust-lang/crates.io-index" 537 | checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" 538 | dependencies = [ 539 | "libc", 540 | "rand_chacha", 541 | "rand_core", 542 | ] 543 | 544 | [[package]] 545 | name = "rand_chacha" 546 | version = "0.3.1" 547 | source = "registry+https://github.com/rust-lang/crates.io-index" 548 | checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" 549 | dependencies = [ 550 | "ppv-lite86", 551 | "rand_core", 552 | ] 553 | 554 | [[package]] 555 | name = "rand_core" 556 | version = "0.6.4" 557 | source = "registry+https://github.com/rust-lang/crates.io-index" 558 | checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" 559 | dependencies = [ 560 | "getrandom", 561 | ] 562 | 563 | [[package]] 564 | name = "rand_xorshift" 565 | version = "0.3.0" 566 | source = "registry+https://github.com/rust-lang/crates.io-index" 567 | checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" 568 | dependencies = [ 569 | "rand_core", 570 | ] 571 | 572 | [[package]] 573 | name = "regex-syntax" 574 | version = "0.8.4" 575 | source = "registry+https://github.com/rust-lang/crates.io-index" 576 | checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" 577 | 578 | [[package]] 579 | name = "rsa" 580 | version = "0.10.0-pre.1" 581 | source = "git+https://github.com/RustCrypto/RSA#c66690221bbbef9a912adbbd6cfc518a827720f7" 582 | dependencies = [ 583 | "const-oid", 584 | "digest 0.11.0-pre.8", 585 | "num-bigint-dig", 586 | "num-integer", 587 | "num-traits", 588 | "pkcs1", 589 | "pkcs8", 590 | "rand_core", 591 | "signature", 592 | "spki", 593 | "subtle", 594 | "zeroize", 595 | ] 596 | 597 | [[package]] 598 | name = "rustix" 599 | version = "0.38.34" 600 | source = "registry+https://github.com/rust-lang/crates.io-index" 601 | checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" 602 | dependencies = [ 603 | "bitflags 2.6.0", 604 | "errno", 605 | "libc", 606 | "linux-raw-sys", 607 | "windows-sys", 608 | ] 609 | 610 | [[package]] 611 | name = "rusty-fork" 612 | version = "0.3.0" 613 | source = "registry+https://github.com/rust-lang/crates.io-index" 614 | checksum = "cb3dcc6e454c328bb824492db107ab7c0ae8fcffe4ad210136ef014458c1bc4f" 615 | dependencies = [ 616 | "fnv", 617 | "quick-error", 618 | "tempfile", 619 | "wait-timeout", 620 | ] 621 | 622 | [[package]] 623 | name = "salsa20" 624 | version = "0.10.2" 625 | source = "registry+https://github.com/rust-lang/crates.io-index" 626 | checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213" 627 | dependencies = [ 628 | "cipher", 629 | ] 630 | 631 | [[package]] 632 | name = "scrypt" 633 | version = "0.11.0" 634 | source = "registry+https://github.com/rust-lang/crates.io-index" 635 | checksum = "0516a385866c09368f0b5bcd1caff3366aace790fcd46e2bb032697bb172fd1f" 636 | dependencies = [ 637 | "pbkdf2", 638 | "salsa20", 639 | "sha2 0.10.8", 640 | ] 641 | 642 | [[package]] 643 | name = "serde" 644 | version = "1.0.204" 645 | source = "registry+https://github.com/rust-lang/crates.io-index" 646 | checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" 647 | dependencies = [ 648 | "serde_derive", 649 | ] 650 | 651 | [[package]] 652 | name = "serde_derive" 653 | version = "1.0.204" 654 | source = "registry+https://github.com/rust-lang/crates.io-index" 655 | checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" 656 | dependencies = [ 657 | "proc-macro2", 658 | "quote", 659 | "syn", 660 | ] 661 | 662 | [[package]] 663 | name = "serde_test" 664 | version = "1.0.176" 665 | source = "registry+https://github.com/rust-lang/crates.io-index" 666 | checksum = "5a2f49ace1498612d14f7e0b8245519584db8299541dfe31a06374a828d620ab" 667 | dependencies = [ 668 | "serde", 669 | ] 670 | 671 | [[package]] 672 | name = "serdect" 673 | version = "0.2.0" 674 | source = "registry+https://github.com/rust-lang/crates.io-index" 675 | checksum = "a84f14a19e9a014bb9f4512488d9829a68e04ecabffb0f9904cd1ace94598177" 676 | dependencies = [ 677 | "base16ct", 678 | "serde", 679 | ] 680 | 681 | [[package]] 682 | name = "sha1" 683 | version = "0.11.0-pre.3" 684 | source = "registry+https://github.com/rust-lang/crates.io-index" 685 | checksum = "3885de8cb916f223718c1ccd47a840b91f806333e76002dc5cb3862154b4fed3" 686 | dependencies = [ 687 | "cfg-if", 688 | "cpufeatures", 689 | "digest 0.11.0-pre.8", 690 | ] 691 | 692 | [[package]] 693 | name = "sha2" 694 | version = "0.10.8" 695 | source = "registry+https://github.com/rust-lang/crates.io-index" 696 | checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" 697 | dependencies = [ 698 | "cfg-if", 699 | "cpufeatures", 700 | "digest 0.10.7", 701 | ] 702 | 703 | [[package]] 704 | name = "sha2" 705 | version = "0.11.0-pre.3" 706 | source = "registry+https://github.com/rust-lang/crates.io-index" 707 | checksum = "8f33549bf3064b62478926aa89cbfc7c109aab66ae8f0d5d2ef839e482cc30d6" 708 | dependencies = [ 709 | "cfg-if", 710 | "cpufeatures", 711 | "digest 0.11.0-pre.8", 712 | ] 713 | 714 | [[package]] 715 | name = "sha3" 716 | version = "0.11.0-pre.3" 717 | source = "registry+https://github.com/rust-lang/crates.io-index" 718 | checksum = "f32c02b9987a647a3d6af14c3e88df86594e4283050d9d8ee3a035df247785b9" 719 | dependencies = [ 720 | "digest 0.11.0-pre.8", 721 | "keccak", 722 | ] 723 | 724 | [[package]] 725 | name = "signature" 726 | version = "2.3.0-pre.3" 727 | source = "registry+https://github.com/rust-lang/crates.io-index" 728 | checksum = "1700c22ba9ce32c7b0a1495068a906c3552e7db386af7cf865162e0dea498523" 729 | dependencies = [ 730 | "digest 0.11.0-pre.8", 731 | "rand_core", 732 | ] 733 | 734 | [[package]] 735 | name = "signature_gen" 736 | version = "0.1.0" 737 | dependencies = [ 738 | "base64ct", 739 | "clap", 740 | "const-oid", 741 | "digest 0.11.0-pre.8", 742 | "generic-array 1.1.0", 743 | "hex", 744 | "hex-literal", 745 | "itoa", 746 | "noir-bignum-paramgen", 747 | "num-bigint-dig", 748 | "num-integer", 749 | "num-traits", 750 | "pkcs1", 751 | "pkcs8", 752 | "proptest", 753 | "rand", 754 | "rand_chacha", 755 | "rand_core", 756 | "rand_xorshift", 757 | "rsa", 758 | "serde", 759 | "serde_test", 760 | "serdect", 761 | "sha1", 762 | "sha2 0.11.0-pre.3", 763 | "sha3", 764 | "signature", 765 | "spki", 766 | "subtle", 767 | "toml", 768 | "typenum", 769 | "zeroize", 770 | ] 771 | 772 | [[package]] 773 | name = "smallvec" 774 | version = "1.13.2" 775 | source = "registry+https://github.com/rust-lang/crates.io-index" 776 | checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" 777 | 778 | [[package]] 779 | name = "spin" 780 | version = "0.9.8" 781 | source = "registry+https://github.com/rust-lang/crates.io-index" 782 | checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" 783 | 784 | [[package]] 785 | name = "spki" 786 | version = "0.8.0-pre.0" 787 | source = "registry+https://github.com/rust-lang/crates.io-index" 788 | checksum = "cb2b56670f5ef52934c97efad30bf42585de0c33ec3e2a886e38b80d2db67243" 789 | dependencies = [ 790 | "base64ct", 791 | "der", 792 | ] 793 | 794 | [[package]] 795 | name = "strsim" 796 | version = "0.8.0" 797 | source = "registry+https://github.com/rust-lang/crates.io-index" 798 | checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" 799 | 800 | [[package]] 801 | name = "subtle" 802 | version = "2.6.1" 803 | source = "registry+https://github.com/rust-lang/crates.io-index" 804 | checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" 805 | 806 | [[package]] 807 | name = "syn" 808 | version = "2.0.71" 809 | source = "registry+https://github.com/rust-lang/crates.io-index" 810 | checksum = "b146dcf730474b4bcd16c311627b31ede9ab149045db4d6088b3becaea046462" 811 | dependencies = [ 812 | "proc-macro2", 813 | "quote", 814 | "unicode-ident", 815 | ] 816 | 817 | [[package]] 818 | name = "tempfile" 819 | version = "3.10.1" 820 | source = "registry+https://github.com/rust-lang/crates.io-index" 821 | checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" 822 | dependencies = [ 823 | "cfg-if", 824 | "fastrand", 825 | "rustix", 826 | "windows-sys", 827 | ] 828 | 829 | [[package]] 830 | name = "textwrap" 831 | version = "0.11.0" 832 | source = "registry+https://github.com/rust-lang/crates.io-index" 833 | checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" 834 | dependencies = [ 835 | "unicode-width", 836 | ] 837 | 838 | [[package]] 839 | name = "toml" 840 | version = "0.5.11" 841 | source = "registry+https://github.com/rust-lang/crates.io-index" 842 | checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" 843 | dependencies = [ 844 | "serde", 845 | ] 846 | 847 | [[package]] 848 | name = "typenum" 849 | version = "1.17.0" 850 | source = "registry+https://github.com/rust-lang/crates.io-index" 851 | checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" 852 | 853 | [[package]] 854 | name = "unarray" 855 | version = "0.1.4" 856 | source = "registry+https://github.com/rust-lang/crates.io-index" 857 | checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" 858 | 859 | [[package]] 860 | name = "unicode-ident" 861 | version = "1.0.12" 862 | source = "registry+https://github.com/rust-lang/crates.io-index" 863 | checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" 864 | 865 | [[package]] 866 | name = "unicode-width" 867 | version = "0.1.13" 868 | source = "registry+https://github.com/rust-lang/crates.io-index" 869 | checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" 870 | 871 | [[package]] 872 | name = "vec_map" 873 | version = "0.8.2" 874 | source = "registry+https://github.com/rust-lang/crates.io-index" 875 | checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" 876 | 877 | [[package]] 878 | name = "version_check" 879 | version = "0.9.4" 880 | source = "registry+https://github.com/rust-lang/crates.io-index" 881 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 882 | 883 | [[package]] 884 | name = "wait-timeout" 885 | version = "0.2.0" 886 | source = "registry+https://github.com/rust-lang/crates.io-index" 887 | checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" 888 | dependencies = [ 889 | "libc", 890 | ] 891 | 892 | [[package]] 893 | name = "wasi" 894 | version = "0.11.0+wasi-snapshot-preview1" 895 | source = "registry+https://github.com/rust-lang/crates.io-index" 896 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 897 | 898 | [[package]] 899 | name = "winapi" 900 | version = "0.3.9" 901 | source = "registry+https://github.com/rust-lang/crates.io-index" 902 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 903 | dependencies = [ 904 | "winapi-i686-pc-windows-gnu", 905 | "winapi-x86_64-pc-windows-gnu", 906 | ] 907 | 908 | [[package]] 909 | name = "winapi-i686-pc-windows-gnu" 910 | version = "0.4.0" 911 | source = "registry+https://github.com/rust-lang/crates.io-index" 912 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 913 | 914 | [[package]] 915 | name = "winapi-x86_64-pc-windows-gnu" 916 | version = "0.4.0" 917 | source = "registry+https://github.com/rust-lang/crates.io-index" 918 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 919 | 920 | [[package]] 921 | name = "windows-sys" 922 | version = "0.52.0" 923 | source = "registry+https://github.com/rust-lang/crates.io-index" 924 | checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" 925 | dependencies = [ 926 | "windows-targets", 927 | ] 928 | 929 | [[package]] 930 | name = "windows-targets" 931 | version = "0.52.6" 932 | source = "registry+https://github.com/rust-lang/crates.io-index" 933 | checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" 934 | dependencies = [ 935 | "windows_aarch64_gnullvm", 936 | "windows_aarch64_msvc", 937 | "windows_i686_gnu", 938 | "windows_i686_gnullvm", 939 | "windows_i686_msvc", 940 | "windows_x86_64_gnu", 941 | "windows_x86_64_gnullvm", 942 | "windows_x86_64_msvc", 943 | ] 944 | 945 | [[package]] 946 | name = "windows_aarch64_gnullvm" 947 | version = "0.52.6" 948 | source = "registry+https://github.com/rust-lang/crates.io-index" 949 | checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" 950 | 951 | [[package]] 952 | name = "windows_aarch64_msvc" 953 | version = "0.52.6" 954 | source = "registry+https://github.com/rust-lang/crates.io-index" 955 | checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" 956 | 957 | [[package]] 958 | name = "windows_i686_gnu" 959 | version = "0.52.6" 960 | source = "registry+https://github.com/rust-lang/crates.io-index" 961 | checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" 962 | 963 | [[package]] 964 | name = "windows_i686_gnullvm" 965 | version = "0.52.6" 966 | source = "registry+https://github.com/rust-lang/crates.io-index" 967 | checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" 968 | 969 | [[package]] 970 | name = "windows_i686_msvc" 971 | version = "0.52.6" 972 | source = "registry+https://github.com/rust-lang/crates.io-index" 973 | checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" 974 | 975 | [[package]] 976 | name = "windows_x86_64_gnu" 977 | version = "0.52.6" 978 | source = "registry+https://github.com/rust-lang/crates.io-index" 979 | checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" 980 | 981 | [[package]] 982 | name = "windows_x86_64_gnullvm" 983 | version = "0.52.6" 984 | source = "registry+https://github.com/rust-lang/crates.io-index" 985 | checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" 986 | 987 | [[package]] 988 | name = "windows_x86_64_msvc" 989 | version = "0.52.6" 990 | source = "registry+https://github.com/rust-lang/crates.io-index" 991 | checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" 992 | 993 | [[package]] 994 | name = "zeroize" 995 | version = "1.8.1" 996 | source = "registry+https://github.com/rust-lang/crates.io-index" 997 | checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" 998 | -------------------------------------------------------------------------------- /signature_gen/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "signature_gen" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | clap = "2.33" 8 | toml = "0.5" 9 | noir-bignum-paramgen = { version = "0.1.5" } 10 | hex = { version = "0.4" } 11 | rsa = { git = "https://github.com/RustCrypto/RSA" } # from online repo 12 | rand = { version = "0.8.5" } 13 | num-bigint = { version = "0.8.2", features = [ 14 | "i128", 15 | "prime", 16 | "zeroize", 17 | ], default-features = false, package = "num-bigint-dig" } 18 | num-traits = { version = "0.2.9", default-features = false, features = [ 19 | "libm", 20 | ] } 21 | num-integer = { version = "0.1.39", default-features = false } 22 | rand_core = { version = "0.6.4", default-features = false } 23 | const-oid = { version = "=0.10.0-pre.2", default-features = false } 24 | subtle = { version = "2.1.1", default-features = false } 25 | digest = { version = "=0.11.0-pre.8", default-features = false, features = [ 26 | "alloc", 27 | "oid", 28 | ] } 29 | pkcs1 = { version = "=0.8.0-pre.0", default-features = false, features = [ 30 | "alloc", 31 | "pkcs8", 32 | ] } 33 | pkcs8 = { version = "=0.11.0-pre.0", default-features = false, features = [ 34 | "alloc", 35 | ] } 36 | signature = { version = "=2.3.0-pre.3", default-features = false, features = [ 37 | "alloc", 38 | "digest", 39 | "rand_core", 40 | ] } 41 | spki = { version = "=0.8.0-pre.0", default-features = false, features = [ 42 | "alloc", 43 | ] } 44 | zeroize = { version = "1.5", features = ["alloc"] } 45 | sha1 = { version = "=0.11.0-pre.3", default-features = false, features = [ 46 | "oid", 47 | ] } 48 | serdect = { version = "0.2.0" } 49 | sha2 = { version = "=0.11.0-pre.3", default-features = false, features = [ 50 | "oid", 51 | ] } 52 | serde = { version = "1.0.184", default-features = false, features = ["derive"] } 53 | base64ct = { version = "1", features = ["alloc"] } 54 | hex-literal = "0.4.1" 55 | proptest = "1" 56 | serde_test = "1.0.89" 57 | rand_xorshift = "0.3" 58 | rand_chacha = "0.3" 59 | sha3 = { version = "=0.11.0-pre.3", default-features = false, features = [ 60 | "oid", 61 | ] } 62 | generic-array = { version = "1.1.0" } 63 | typenum = { version = "1.17.0" } 64 | itoa = { version = "1.0.11" } 65 | [features] 66 | default = ["std", "pem", "u64_digit"] 67 | hazmat = [] 68 | getrandom = ["rand_core/getrandom"] 69 | nightly = ["num-bigint/nightly"] 70 | # serde = ["dep:serde", "dep:serdect", "num-bigint/serde"] 71 | pem = ["pkcs1/pem", "pkcs8/pem"] 72 | pkcs5 = ["pkcs8/encryption"] 73 | u64_digit = ["num-bigint/u64_digit"] 74 | std = ["digest/std", "pkcs1/std", "pkcs8/std", "rand_core/std", "signature/std"] 75 | -------------------------------------------------------------------------------- /signature_gen/src/main.rs: -------------------------------------------------------------------------------- 1 | use num_bigint::BigUint; 2 | use rsa::pkcs1v15::Signature; 3 | use rsa::{RsaPrivateKey, RsaPublicKey}; 4 | use toml::Value; 5 | 6 | use rsa::signature::{SignatureEncoding, Signer}; 7 | use rsa::traits::PublicKeyParts; 8 | use sha2::{Digest, Sha256}; 9 | 10 | use clap::{App, Arg}; 11 | 12 | use noir_bignum_paramgen::{ 13 | bn_limbs, compute_barrett_reduction_parameter, split_into_120_bit_limbs, 14 | }; 15 | 16 | fn format_limbs_as_hex(limbs: &Vec) -> String { 17 | limbs 18 | .iter() 19 | .map(|a| format!("0x{:x}", a)) 20 | .collect::>() 21 | .join(", ") 22 | } 23 | 24 | fn format_limbs_as_toml_value(limbs: &Vec) -> Vec { 25 | limbs 26 | .iter() 27 | .map(|a| Value::String(format!("0x{:x}", a))) 28 | .collect() 29 | } 30 | 31 | fn generate_2048_bit_signature_parameters(msg: &str, as_toml: bool, exponent: u32) { 32 | let mut hasher = Sha256::new(); 33 | hasher.update(msg.as_bytes()); 34 | let hashed_message = hasher.finalize(); 35 | 36 | let hashed_as_bytes = hashed_message 37 | .iter() 38 | .map(|&b| b.to_string()) 39 | .collect::>() 40 | .join(", "); 41 | 42 | let mut rng: rand::prelude::ThreadRng = rand::thread_rng(); 43 | let bits: usize = 2048; 44 | let priv_key: RsaPrivateKey = 45 | RsaPrivateKey::new_with_exp(&mut rng, bits, &BigUint::from(exponent)) 46 | .expect("failed to generate a key"); 47 | let pub_key: RsaPublicKey = priv_key.clone().into(); 48 | 49 | let signing_key = rsa::pkcs1v15::SigningKey::::new(priv_key); 50 | let sig: Vec = signing_key.sign(msg.as_bytes()).to_vec(); 51 | 52 | let sig_bytes = &Signature::try_from(sig.as_slice()).unwrap().to_bytes(); 53 | 54 | let sig_uint: BigUint = BigUint::from_bytes_be(sig_bytes); 55 | 56 | let sig_str = bn_limbs(sig_uint.clone(), 2048); 57 | 58 | let modulus_limbs: Vec = split_into_120_bit_limbs(&pub_key.n().clone(), 2048); 59 | let redc_limbs = split_into_120_bit_limbs( 60 | &compute_barrett_reduction_parameter(&pub_key.n().clone()), 61 | 2048, 62 | ); 63 | 64 | if as_toml { 65 | let sig_limbs = split_into_120_bit_limbs(&sig_uint.clone(), 2048); 66 | 67 | println!("hash = [{}]", hashed_as_bytes); 68 | println!( 69 | "modulus_limbs = {}", 70 | Value::Array(format_limbs_as_toml_value(&modulus_limbs)) 71 | ); 72 | println!( 73 | "redc_limbs = {}", 74 | Value::Array(format_limbs_as_toml_value(&redc_limbs)) 75 | ); 76 | println!( 77 | "signature_limbs = {}", 78 | Value::Array(format_limbs_as_toml_value(&sig_limbs)) 79 | ); 80 | } else { 81 | println!("let hash: [u8; 32] = [{}];", hashed_as_bytes); 82 | println!( 83 | "let params: BigNumParams<18, 2048> = BigNumParams::new(\n\tfalse,\n\t[{}],\n\t[{}]\n);", 84 | format_limbs_as_hex(&modulus_limbs), 85 | format_limbs_as_hex(&redc_limbs) 86 | ); 87 | println!( 88 | "let signature: RuntimeBigNum<18, 2048> = RuntimeBigNum::from_array(\n\tparams,\n\tlimbs: {}\n);", 89 | sig_str.as_str() 90 | ); 91 | } 92 | } 93 | 94 | fn generate_1024_bit_signature_parameters(msg: &str, as_toml: bool, exponent: u32) { 95 | let mut hasher = Sha256::new(); 96 | hasher.update(msg.as_bytes()); 97 | let hashed_message = hasher.finalize(); 98 | 99 | let hashed_as_bytes = hashed_message 100 | .iter() 101 | .map(|&b| b.to_string()) 102 | .collect::>() 103 | .join(", "); 104 | 105 | let mut rng: rand::prelude::ThreadRng = rand::thread_rng(); 106 | let bits: usize = 1024; 107 | let priv_key: RsaPrivateKey = 108 | RsaPrivateKey::new_with_exp(&mut rng, bits, &BigUint::from(exponent)) 109 | .expect("failed to generate a key"); 110 | let pub_key: RsaPublicKey = priv_key.clone().into(); 111 | 112 | let signing_key = rsa::pkcs1v15::SigningKey::::new(priv_key); 113 | let sig: Vec = signing_key.sign(msg.as_bytes()).to_vec(); 114 | 115 | let sig_bytes = &Signature::try_from(sig.as_slice()).unwrap().to_bytes(); 116 | 117 | let sig_uint: BigUint = BigUint::from_bytes_be(sig_bytes); 118 | 119 | let sig_str = bn_limbs(sig_uint.clone(), 1024); 120 | 121 | let modulus_limbs: Vec = split_into_120_bit_limbs(&pub_key.n().clone(), 1024); 122 | let redc_limbs = split_into_120_bit_limbs( 123 | &compute_barrett_reduction_parameter(&pub_key.n().clone()), 124 | 1024, 125 | ); 126 | 127 | if as_toml { 128 | let sig_limbs = split_into_120_bit_limbs(&sig_uint.clone(), 1024); 129 | 130 | println!("hash = [{}]", hashed_as_bytes); 131 | println!( 132 | "modulus_limbs = {}", 133 | Value::Array(format_limbs_as_toml_value(&modulus_limbs)) 134 | ); 135 | println!( 136 | "redc_limbs = {}", 137 | Value::Array(format_limbs_as_toml_value(&redc_limbs)) 138 | ); 139 | println!( 140 | "signature_limbs = {}", 141 | Value::Array(format_limbs_as_toml_value(&sig_limbs)) 142 | ); 143 | } else { 144 | println!( 145 | "let params: BigNumParams<9, 1024> = BigNumParams::new(\n\tfalse,\n\t[{}],\n\t[{}]\n);", 146 | format_limbs_as_hex(&modulus_limbs), 147 | format_limbs_as_hex(&redc_limbs) 148 | ); 149 | println!( 150 | "let signature: RuntimeBigNum<9, 1024> = RuntimeBigNum::from_array(\n\tparams,\n\tlimbs: {}\n);", 151 | sig_str.as_str() 152 | ); 153 | } 154 | } 155 | 156 | fn main() { 157 | let matches = App::new("RSA Signature Generator") 158 | .arg( 159 | Arg::with_name("msg") 160 | .short("m") 161 | .long("msg") 162 | .takes_value(true) 163 | .help("Message to sign") 164 | .required(true), 165 | ) 166 | .arg( 167 | Arg::with_name("toml") 168 | .short("t") 169 | .long("toml") 170 | .help("Print output in TOML format"), 171 | ) 172 | .arg( 173 | Arg::with_name("exponent") 174 | .short("e") 175 | .long("exponent") 176 | .takes_value(true) 177 | .help("Exponent to use for the key") 178 | .default_value("65537"), 179 | ) 180 | .arg( 181 | Arg::with_name("bits") 182 | .short("b") 183 | .long("bits") 184 | .takes_value(true) 185 | .help("Number of bits of RSA signature (1024 or 2048") 186 | .default_value("2048"), 187 | ) 188 | .get_matches(); 189 | 190 | let msg = matches.value_of("msg").unwrap(); 191 | let as_toml = matches.is_present("toml"); 192 | let e: u32 = matches.value_of("exponent").unwrap().parse().unwrap(); 193 | let b: u32 = matches.value_of("bits").unwrap().parse().unwrap(); 194 | assert!( 195 | b == 1024 || b == 2048, 196 | "Number of bits of RSA signature can only be 1024 or 2048" 197 | ); 198 | if b == 1024 { 199 | generate_1024_bit_signature_parameters(msg, as_toml, e); 200 | } else { 201 | generate_2048_bit_signature_parameters(msg, as_toml, e); 202 | } 203 | } 204 | 205 | #[cfg(test)] 206 | mod tests { 207 | use super::*; 208 | use rand::thread_rng; 209 | use rsa::pkcs1v15::Signature; 210 | use rsa::signature::{Signer, Verifier}; 211 | use rsa::{pkcs1v15::VerifyingKey, RsaPrivateKey, RsaPublicKey}; 212 | use sha2::Sha256; 213 | 214 | #[test] 215 | fn test_signature_generation() { 216 | let mut rng = thread_rng(); 217 | let bits = 2048; 218 | let priv_key = RsaPrivateKey::new(&mut rng, bits).expect("failed to generate a key"); 219 | let pub_key: RsaPublicKey = priv_key.clone().into(); 220 | let text: &str = "hello world"; 221 | let signing_key = rsa::pkcs1v15::SigningKey::::new(priv_key); 222 | let sig: Vec = signing_key.sign(text.as_bytes()).to_vec(); 223 | let verifying_key = VerifyingKey::::new(pub_key); 224 | 225 | let result = verifying_key.verify( 226 | text.as_bytes(), 227 | &Signature::try_from(sig.as_slice()).unwrap(), 228 | ); 229 | result.expect("failed to verify"); 230 | } 231 | } 232 | -------------------------------------------------------------------------------- /src/bench.nr: -------------------------------------------------------------------------------- 1 | use super::rsa::verify_sha256_pkcs1v15; 2 | use bignum::{params::BigNumParams, RuntimeBigNum}; 3 | 4 | #[export] 5 | fn test_verify_sha256_pkcs1v15_2048(signature: [u128; 18]) { 6 | // Output of `cargo run -- --msg "Hello World! This is Noir-RSA"` in the `signature_gen` directory 7 | let sha256_hash: [u8; 32] = [ 8 | 91, 207, 46, 60, 22, 153, 217, 144, 2, 127, 224, 143, 181, 45, 32, 120, 122, 131, 166, 79, 9 | 166, 183, 43, 158, 116, 105, 73, 207, 196, 77, 33, 5, 10 | ]; 11 | 12 | let params: BigNumParams<18, 2048> = BigNumParams::new( 13 | false, 14 | [ 15 | 0x8d5e7d9daedd6cfd1c9bdf0227e05b, 16 | 0xbfb937fc4d3cf02cc0af780f3cab44, 17 | 0xd20637ef7adcf5d238ee87bccc9bca, 18 | 0xb9db4f2663108e2f8b673f7612ae8b, 19 | 0x85f894ef669b36bfd3d86b0a28873, 20 | 0xdcc70e1884e38b8229cce3b884121d, 21 | 0x35488d1138e0b03e1676f7f5d8a5b3, 22 | 0xe1a97820e7dcbb4eab35c9b71bb273, 23 | 0x97d19eb3c63249ddbfcff915863f54, 24 | 0x3a78c7af6da0f6af0d67b1ca4b6065, 25 | 0xd7a3c433c020f624821e5e678c7d69, 26 | 0x52d5b53240feae82ffea3d2a3d9b09, 27 | 0xb8aad5e19e2163f68997c6fdd71906, 28 | 0x5db432d06e8b0bf59511100c7894e2, 29 | 0xadc0bbc4c54da10d1cc88438ea3127, 30 | 0xece1cf6a1501109cd2734d5893c8d9, 31 | 0x7196b90acdf06c31b1288064fd0c27, 32 | 0xc8, 33 | ], 34 | [ 35 | 0x1b1deccf4dbde852c34a5d6908a0f, 36 | 0xbc9e5bdab22f023fbcca58692bccf5, 37 | 0x1f65439685623e45396ff55751c3bf, 38 | 0x2b6ad2c5f8e3aac15d0ccbab816bfa, 39 | 0x5ca2e8e3048243c16c708a8030ab0d, 40 | 0x30079bfeb1fa51e5501581173ca19c, 41 | 0xff8d5f6bea485fdcc2716327f69ab4, 42 | 0x36b599d81589416b5b5f037986b999, 43 | 0x75612e34a4ff29f0a19a7823512f58, 44 | 0x288b6897929b54c3b26a5faa07c00f, 45 | 0x4b5675fa13ab7444f1f047d3eb1bbe, 46 | 0x6ba0ac610ef9f267ab30fe25bb1c84, 47 | 0xa386b48ee03168d5cea3ecb9dc901f, 48 | 0xacf1a01f7dba44e050c976142fb1f6, 49 | 0x97a63b5cb7efc60d3502946aec63cf, 50 | 0x12cc1d5cab10a1e9e2398d29b9e3ef, 51 | 0x4635cf25c66e76bba8034df46204fb, 52 | 0x146f, 53 | ], 54 | ); 55 | 56 | let signature: RuntimeBigNum<18, 2048> = RuntimeBigNum { params, limbs: signature }; 57 | assert(verify_sha256_pkcs1v15(sha256_hash, signature, 65537)); 58 | } 59 | -------------------------------------------------------------------------------- /src/lib.nr: -------------------------------------------------------------------------------- 1 | pub mod rsa; 2 | pub mod types; 3 | mod bench; 4 | -------------------------------------------------------------------------------- /src/rsa.nr: -------------------------------------------------------------------------------- 1 | use dep::bignum::RuntimeBigNum; 2 | 3 | /** 4 | * @brief Compare a recovered byte hash from an RSA signature to the original message hash 5 | * @details Taken from https://github.com/richardliang/noir-rsa 6 | **/ 7 | fn compare_signature_sha256(padded_sha256_hash: [u8; N], msg_hash: [u8; 32]) -> bool { 8 | // Get length of sig (e.g. 1048 = 128 bytes, 2048 = 256 bytes) 9 | // NOTE: Assume MAX_BYTES < 2^32 bit number. MAX_BYTES of 259 > 2^8 bits so need to cast it to u32 10 | for i in 0..32 { 11 | // Padded hash is reversed 12 | assert(padded_sha256_hash[31 - i] == msg_hash[i]); 13 | } 14 | 15 | let hash_prefix: [u8; 19] = 16 | [32, 4, 0, 5, 1, 2, 4, 3, 101, 1, 72, 134, 96, 9, 6, 13, 48, 49, 48]; 17 | 18 | for i in 32..51 { 19 | assert(hash_prefix[i - 32] == padded_sha256_hash[i]); 20 | } 21 | 22 | assert(padded_sha256_hash[51] == 0); 23 | 24 | // Sub 32 bytes for hash, 19 bytes for prefix, 1 byte for 0, 1 byte for 1, 1 byte for 0 25 | let ps_len = N - 54; 26 | for i in 52..N { 27 | if i < 52 + ps_len { 28 | // PS padding which depends on RSA modulus / sig length. 1024 bits = 128 bytes = 128 - 54 = 74 bytes of 0xFF padding 29 | assert(padded_sha256_hash[i] == 255); 30 | } else if i == 52 + ps_len { 31 | // Pad 0x01 32 | assert(padded_sha256_hash[i] == 1); 33 | } else if i == 53 + ps_len { 34 | // 0x00 35 | assert(padded_sha256_hash[i] == 0); 36 | } else { 37 | // Padded with 0 until MAX_BYTES 38 | assert(padded_sha256_hash[i] == 0); 39 | } 40 | } 41 | 42 | true 43 | } 44 | 45 | /** 46 | * @brief Verify an RSA signature generated via the pkcs1v15 signature scheme. 47 | * @note The `exponent` can be either 65537 or 3 (i.e. the most common values in use for RSA) 48 | * Rough cost: 2,048 bit RSA: 26,888 gates per verification 49 | * 1,024 bit RSA: 11,983 gates per verification 50 | * A circuit that verifies 1 signature (and does nothing else) will cost ~32k due to initialization costs of lookup tables 51 | **/ 52 | pub fn verify_sha256_pkcs1v15( 53 | msg_hash: [u8; 32], 54 | sig: RuntimeBigNum, 55 | exponent: u32, 56 | ) -> bool { 57 | assert((exponent == 3) | (exponent == 65537), "Exponent must be 65537 or 3"); 58 | let mut exponentiated = sig * sig; // sig^2 59 | if exponent == 65537 { 60 | // e = 65537 = 1 0000 0000 0000 0001 61 | exponentiated = exponentiated * exponentiated; // sig^4 62 | exponentiated = exponentiated * exponentiated; // sig^8 63 | exponentiated = exponentiated * exponentiated; // sig^16 64 | exponentiated = exponentiated * exponentiated; // sig^32 65 | exponentiated = exponentiated * exponentiated; // sig^64 66 | exponentiated = exponentiated * exponentiated; // sig^128 67 | exponentiated = exponentiated * exponentiated; // sig^256 68 | exponentiated = exponentiated * exponentiated; // sig^512 69 | exponentiated = exponentiated * exponentiated; // sig^1024 70 | exponentiated = exponentiated * exponentiated; // sig^2048 71 | exponentiated = exponentiated * exponentiated; // sig^4096 72 | exponentiated = exponentiated * exponentiated; // sig^8192 73 | exponentiated = exponentiated * exponentiated; // sig^16384 74 | exponentiated = exponentiated * exponentiated; // sig^32768 75 | exponentiated = exponentiated * exponentiated; // sig^65536 76 | } 77 | // otherwise, e = 3 = 11 78 | exponentiated = exponentiated * sig; // either sig^2 * sig = sig^3 or sig^65536 * sig = sig^65537 79 | let mut padded_sha256_hash_bytes: [u8; (ModBits + 7) / 8] = exponentiated.to_le_bytes(); 80 | compare_signature_sha256(padded_sha256_hash_bytes, msg_hash) 81 | } 82 | 83 | mod tests { 84 | 85 | use crate::types::RBN2048; 86 | use super::verify_sha256_pkcs1v15; 87 | use bignum::params::BigNumParams; 88 | use bignum::RuntimeBigNum; 89 | 90 | #[test] 91 | fn test_verify_sha256_pkcs1v15_1024() { 92 | // Output of `cargo run -- --msg "hello world! test#123" --bits 1024` in the `signature_gen` directory 93 | let sha256_hash: [u8; 32] = [ 94 | 220, 155, 229, 143, 122, 133, 55, 215, 75, 44, 132, 111, 57, 33, 248, 84, 213, 170, 193, 95 | 96, 253, 57, 124, 13, 251, 42, 92, 147, 105, 172, 233, 85, 96 | ]; 97 | 98 | let params: BigNumParams<9, 1024> = BigNumParams::new( 99 | false, 100 | [ 101 | 0xab238ad9cb37979a43aefbf10be8fb, 102 | 0x31347febe45fe8c2dac1dd30900704, 103 | 0xa5a9a6b9cd0cc2b9d13bbd4e068263, 104 | 0x5eac6390f7873fe97ff9bb14a173ea, 105 | 0xbc41f700c91fd733a2c63177bbdbd4, 106 | 0x41442bd58769a3595b659a2ec9c6be, 107 | 0x4ddc91395f330382aa2e2d3fbe147, 108 | 0x3d008ff255a0bc71c7887f5728ba1, 109 | 0xb640c3a8f511c64e, 110 | ], 111 | [ 112 | 0x5d53d2634c6a0918266043968ce263, 113 | 0x5dd4be3dce0323a492ee9340aec4db, 114 | 0xf82d0e2e5c8319f01a460c72c01854, 115 | 0x236e6fc6e62e8a1d522acda5fb3892, 116 | 0xdaf755619d66e580901aa224d03174, 117 | 0x8366291616480e7e1f202dbcedda87, 118 | 0x40ba1202537d1e94561ccc05265586, 119 | 0x69b993d857ba89ea5de9822aeb4b93, 120 | 0x167968c0000761a273, 121 | ], 122 | ); 123 | 124 | let signature: RuntimeBigNum<9, 1024> = RuntimeBigNum { 125 | params, 126 | limbs: [ 127 | 0xc3850e84ea02da3f028ff422f4d6a9, 128 | 0x9761f0bd9021f76d45c60df0670a19, 129 | 0xc1ede421a43607ab623ed4d5a17fc8, 130 | 0x86197b4315206f4d53200b42555831, 131 | 0xe95783b69db28c26a83706f39d04cd, 132 | 0x18b178dc1a9ec76fb22b57e4dfa703, 133 | 0xdd0e19cd5a09ab48e7af4d0e3470e3, 134 | 0x10004dfab1cf91304e80e6baa4dfc7, 135 | 0x241c3fd77b90adef, 136 | ], 137 | }; 138 | 139 | assert(verify_sha256_pkcs1v15(sha256_hash, signature, 65537)); 140 | } 141 | 142 | #[test] 143 | fn test_verify_sha256_pkcs1v15_2048() { 144 | // Output of `cargo run -- --msg "Hello World! This is Noir-RSA"` in the `signature_gen` directory 145 | let sha256_hash: [u8; 32] = [ 146 | 91, 207, 46, 60, 22, 153, 217, 144, 2, 127, 224, 143, 181, 45, 32, 120, 122, 131, 166, 147 | 79, 166, 183, 43, 158, 116, 105, 73, 207, 196, 77, 33, 5, 148 | ]; 149 | 150 | let params: BigNumParams<18, 2048> = BigNumParams::new( 151 | false, 152 | [ 153 | 0x8d5e7d9daedd6cfd1c9bdf0227e05b, 154 | 0xbfb937fc4d3cf02cc0af780f3cab44, 155 | 0xd20637ef7adcf5d238ee87bccc9bca, 156 | 0xb9db4f2663108e2f8b673f7612ae8b, 157 | 0x85f894ef669b36bfd3d86b0a28873, 158 | 0xdcc70e1884e38b8229cce3b884121d, 159 | 0x35488d1138e0b03e1676f7f5d8a5b3, 160 | 0xe1a97820e7dcbb4eab35c9b71bb273, 161 | 0x97d19eb3c63249ddbfcff915863f54, 162 | 0x3a78c7af6da0f6af0d67b1ca4b6065, 163 | 0xd7a3c433c020f624821e5e678c7d69, 164 | 0x52d5b53240feae82ffea3d2a3d9b09, 165 | 0xb8aad5e19e2163f68997c6fdd71906, 166 | 0x5db432d06e8b0bf59511100c7894e2, 167 | 0xadc0bbc4c54da10d1cc88438ea3127, 168 | 0xece1cf6a1501109cd2734d5893c8d9, 169 | 0x7196b90acdf06c31b1288064fd0c27, 170 | 0xc8, 171 | ], 172 | [ 173 | 0x1b1deccf4dbde852c34a5d6908a0f, 174 | 0xbc9e5bdab22f023fbcca58692bccf5, 175 | 0x1f65439685623e45396ff55751c3bf, 176 | 0x2b6ad2c5f8e3aac15d0ccbab816bfa, 177 | 0x5ca2e8e3048243c16c708a8030ab0d, 178 | 0x30079bfeb1fa51e5501581173ca19c, 179 | 0xff8d5f6bea485fdcc2716327f69ab4, 180 | 0x36b599d81589416b5b5f037986b999, 181 | 0x75612e34a4ff29f0a19a7823512f58, 182 | 0x288b6897929b54c3b26a5faa07c00f, 183 | 0x4b5675fa13ab7444f1f047d3eb1bbe, 184 | 0x6ba0ac610ef9f267ab30fe25bb1c84, 185 | 0xa386b48ee03168d5cea3ecb9dc901f, 186 | 0xacf1a01f7dba44e050c976142fb1f6, 187 | 0x97a63b5cb7efc60d3502946aec63cf, 188 | 0x12cc1d5cab10a1e9e2398d29b9e3ef, 189 | 0x4635cf25c66e76bba8034df46204fb, 190 | 0x146f, 191 | ], 192 | ); 193 | 194 | let signature: RuntimeBigNum<18, 2048> = RuntimeBigNum { 195 | params, 196 | limbs: [ 197 | 0xad29e07d16a278de49a371b9760a27, 198 | 0x86311920cc0e17a3c20cdff4c56dbb, 199 | 0x863556c6c5247dd83668dd825716ae, 200 | 0xc247c960945f4485b46c33b87425ca, 201 | 0x7326463c5c4cd5b08e21b938d9ed9a, 202 | 0x4f89fe0c82da08a0259eddb34d0da1, 203 | 0x43a74e76d4e1bd2666f1591889af0d, 204 | 0x240f7b80f0ff29f4253ee3019f832d, 205 | 0xc6edd131fbaaf725fd423dac52b362, 206 | 0x85f9732679242163e8afff44f6104d, 207 | 0xd3c3bbcb1757013fd6fb80f31dd9a6, 208 | 0x9008633f15df440e6df6d21ee585a2, 209 | 0x324df3425ed256e283be5b6b761741, 210 | 0xc60c1302929bd0e07caa4aeff4e8fd, 211 | 0x600d804ff13ba8d0e1bc9508714212, 212 | 0x50f7e75e5751d7edd61167027926be, 213 | 0x0db41d39442023e1420a8a84fe81d9, 214 | 0xab, 215 | ], 216 | }; 217 | assert(verify_sha256_pkcs1v15(sha256_hash, signature, 65537)); 218 | } 219 | 220 | #[test] 221 | fn test_verify_sha256_pkcs1v15_2048_exponent_3() { 222 | // Output of `cargo run -- --msg "hello world" -e 3` in the `signature_gen` directory 223 | let sha256_hash: [u8; 32] = [ 224 | 185, 77, 39, 185, 147, 77, 62, 8, 165, 46, 82, 215, 218, 125, 171, 250, 196, 132, 239, 225 | 227, 122, 83, 128, 238, 144, 136, 247, 172, 226, 239, 205, 233, 226 | ]; 227 | 228 | let params: BigNumParams<18, 2048> = BigNumParams::new( 229 | false, 230 | [ 231 | 0xe40ee47801326543c8e84b85d567c1, 232 | 0x5b54ea87f0ce29de1995697b0696fd, 233 | 0x457078f8fdce68b437cac0970b2452, 234 | 0x473ec776fee3731b6ab06e35875ddc, 235 | 0x62dedd594e5f12c80c3ccb5791a6cd, 236 | 0xecb934b9d8272c5e3a418145345499, 237 | 0xd1af643b3d785470ed0c6cd633f706, 238 | 0xb58a57b9e96eccbdfc7c17f0333d4, 239 | 0x2ebd34b5039fc596504927c282c60d, 240 | 0x3a44928a74f25fc1043bb37ce4dfa8, 241 | 0x91448459f9617fac33a2816162ac9e, 242 | 0x70cb910d9f3e1a78864640ec6c8240, 243 | 0x9aed33f6b31f1c9de67248a98c180, 244 | 0x7f1416e032c79488c94b311e87bd9c, 245 | 0x7191b4ebb1b3fffa949fa48ed01e5, 246 | 0x350a75cbaeca6bfdd71ca83cdbcae9, 247 | 0xfb1d274fa207457c6814d42c09f9cf, 248 | 0xd4, 249 | ], 250 | [ 251 | 0x803bf4d38110a7d37fdd05f590dee9, 252 | 0xa68d317c933f37cab5ab4e7c00a3b9, 253 | 0x476a05a536bf5f2aa1b8850146cba7, 254 | 0xca297ea8b5528d91d4836ff27c30ab, 255 | 0x75cf2eaab76eefa12bbd570f1aea9f, 256 | 0x8f6a8ab877d9c5bcd98c37bdc5c2d3, 257 | 0xd497db1f6ebe83decacaa647fabea6, 258 | 0x686b27ca330e25e7a7cf197f6433ef, 259 | 0xfde04d2225c8308b07580af0058a0f, 260 | 0xa29fb69777c0e916976243b2b09855, 261 | 0xf983592285852e7e1c2cb3ae968323, 262 | 0x673608017f9f5acf67a01b73728d70, 263 | 0xeeff82521c0bc432a05f4b7444fac0, 264 | 0x85a89c4d229f60aaa3aa7ac7dac1e2, 265 | 0xcfecff93bc9fbfe0d6dff6091f2db8, 266 | 0xf20f047dcb224b4447bd098c07f8c2, 267 | 0x554bb53cadeb3eaab911a189f90227, 268 | 0x133b, 269 | ], 270 | ); 271 | 272 | let signature: RuntimeBigNum<18, 2048> = RuntimeBigNum { 273 | params, 274 | limbs: [ 275 | 0xa250eff812c63eaaeaa3f04641c05f, 276 | 0xecc09613cb8b289c1f37c8f92e6a05, 277 | 0x2c0a0510058360c07af65d46f594fd, 278 | 0x943d67513363d3de430c94a1dafe7c, 279 | 0x511ec8e9b10bc6c6ff0d6c232ccf92, 280 | 0x50ffd07b3c093b3f5fc027de847731, 281 | 0xc268e1489449943fdafdf89ff168c3, 282 | 0x0b8b7f9f49b492f78fda58d252f23a, 283 | 0x491c6c4ef836a6a8730b7bf81e865e, 284 | 0x8746c75fb079d014e419543f56d7f0, 285 | 0x65804c417d6168a8bc0025d255cebf, 286 | 0xf695e91b77890b8e3fd775fa56e627, 287 | 0x5e90001c0218550f4083ae28025a2f, 288 | 0x526bd4eff34f25f62a698f0470e0a6, 289 | 0x7f224306a7d9daf536b1559434c6c6, 290 | 0x88809f16fe1fcea3c87511d9319735, 291 | 0x7694685fee0bfab4a9196b92ec6f2e, 292 | 0xa7, 293 | ], 294 | }; 295 | 296 | assert(verify_sha256_pkcs1v15(sha256_hash, signature, 3)); 297 | } 298 | 299 | #[test] 300 | fn smoke_test() { 301 | // Output of `cargo run -- --msg "hello world"` in the `signature_gen` directory 302 | // Create runtime params: 303 | let modulus_limbs = [ 304 | 0x65af46d235241cf0e8fbe8cff4abb7, 305 | 0xeead39ba3f377ddd5ccb2ef2085190, 306 | 0xe483f94c0a98e8b618d92fb926f596, 307 | 0x1fa8c1b2c62cca6db090cd74a29db2, 308 | 0xc38e22042fcb74585a7e535301f50f, 309 | 0xcbc4378e5212752743ae78a75a44a9, 310 | 0xf5acc41788d9a346a0f75630a8b2b6, 311 | 0xf7a741bb3ecf1aadd5a327f362abd8, 312 | 0x4d5f24e815db43a1b2cc2ba40f8715, 313 | 0xe501f1a01305cb198475a4bff0da2e, 314 | 0xd541b78cfbc2b314083c340840c82c, 315 | 0xa0ab069c26b2a0458f4c642bf72526, 316 | 0x2ccb676d8f22517116fee0d2340533, 317 | 0x7cf2a7cf772025c0a83747bbc18228, 318 | 0xf9475f17988a56f17b3bdf88dc72dc, 319 | 0x4ff228bee24415fae7a7c05771e830, 320 | 0x55acd96b485515c38906106cf0d189, 321 | 0xb9, 322 | ]; 323 | let redc_limbs = [ 324 | 0x172c8f156f020ad88d30fa3ba47f03, 325 | 0x1740a43a67cb9a7be1ac1422d77246, 326 | 0x2d967be1edf369834317e04856e591, 327 | 0x65d9fa0de5fdab598c04d9a515156a, 328 | 0xc6791a661ea7621db7e6c4ec48f466, 329 | 0xa4a1a7c06d3e8a0bcbc540c6af6788, 330 | 0xdcaffeb149f5bf646caa00d7355715, 331 | 0xb75471630a9d0fefb5cb61e66991a1, 332 | 0x97c041a0fc30fdff3d5ed16997da02, 333 | 0xbfbe7d217694b269e1ed37819c2f17, 334 | 0x1b44ffc3180531e2ab8bdf7848a3a9, 335 | 0x9f004af11132cb68bb55998ed7616a, 336 | 0x1b15dbbb96ce80f479724bbd768a0c, 337 | 0x59ba1419093ae6ed2592ffb3065867, 338 | 0xa35b69affa3bb3f4713f315e50b584, 339 | 0xa873210f83a6de0d8cbb816af3e37, 340 | 0xbe4fe7cf98da87ec87638030797e92, 341 | 0x1619, 342 | ]; 343 | 344 | let signature_limbs = [ 345 | 0x2f397c4611d4a4271453e1e50e1578, 346 | 0xe506a7f47c721a4943783e8ad459e6, 347 | 0x6cc4ae1d91cb381cba9673470999fb, 348 | 0x1e127364d07f94e58227f50fbf5687, 349 | 0xf64a2579c7189f882d68832d16faa4, 350 | 0x3b014b74c6c6f76f2f8af170fa0fe4, 351 | 0x7df41e68c86815a6fdc33968c66b67, 352 | 0x6a57ac06282527242fddb6ed08dbdc, 353 | 0xac40d37b819c4b6193f90a634e4fc7, 354 | 0x96606ed166a7f032d858cd40ac73a5, 355 | 0x8eb7d4351159a46733f92610d5c597, 356 | 0xc8e8e9faa9738e82dbe774a3f5cf07, 357 | 0x89ca84fd54ee3d5cca87c9f178375e, 358 | 0xdb7a1465fc76507ea498a351af70dd, 359 | 0x6ac6fe14f51c711f983125c776f712, 360 | 0x3254c17fef51bf4194a8a1674634e3, 361 | 0xee38c83c77c6e1ff7b70a5d9d1dd0f, 362 | 0x26, 363 | ]; 364 | 365 | let hash: [u8; 32] = [ 366 | 0xb9, 0x4d, 0x27, 0xb9, 0x93, 0x4d, 0x3e, 0x08, 0xa5, 0x2e, 0x52, 0xd7, 0xda, 0x7d, 367 | 0xab, 0xfa, 0xc4, 0x84, 0xef, 0xe3, 0x7a, 0x53, 0x80, 0xee, 0x90, 0x88, 0xf7, 0xac, 368 | 0xe2, 0xef, 0xcd, 0xe9, 369 | ]; 370 | 371 | let has_multiplicative_inverse = false; 372 | let params: BigNumParams<18, 2048> = 373 | BigNumParams::new(has_multiplicative_inverse, modulus_limbs, redc_limbs); 374 | 375 | let signature: RBN2048 = RBN2048::from_array(params, signature_limbs); 376 | 377 | assert(verify_sha256_pkcs1v15(hash, signature, 65537)); 378 | } 379 | } 380 | -------------------------------------------------------------------------------- /src/types.nr: -------------------------------------------------------------------------------- 1 | use bignum::RuntimeBigNum; 2 | 3 | pub type RBN1024 = RuntimeBigNum<9, 1024>; 4 | pub type RBN1025 = RuntimeBigNum<9, 1025>; 5 | pub type RBN1964 = RuntimeBigNum<17, 1946>; 6 | pub type RBN2048 = RuntimeBigNum<18, 2048>; 7 | pub type RBN4096 = RuntimeBigNum<35, 4096>; 8 | --------------------------------------------------------------------------------