├── LICENSE ├── README.md ├── build_image.sh ├── evaluate.sh └── harness ├── Cargo.lock ├── Cargo.toml ├── README.md ├── benches └── msm.rs ├── src ├── api.rs ├── gen.rs └── lib.rs └── tests └── msm.rs /LICENSE: -------------------------------------------------------------------------------- 1 | Dual-licensed under both the MIT and Apache-2.0 licenses 2 | --- 3 | MIT License 4 | 5 | Copyright (c) 2022 ZPrize 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | --- 25 | Apache License 26 | Version 2.0, January 2004 27 | http://www.apache.org/licenses/ 28 | 29 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 30 | 31 | 1. Definitions. 32 | 33 | "License" shall mean the terms and conditions for use, reproduction, 34 | and distribution as defined by Sections 1 through 9 of this document. 35 | 36 | "Licensor" shall mean the copyright owner or entity authorized by 37 | the copyright owner that is granting the License. 38 | 39 | "Legal Entity" shall mean the union of the acting entity and all 40 | other entities that control, are controlled by, or are under common 41 | control with that entity. For the purposes of this definition, 42 | "control" means (i) the power, direct or indirect, to cause the 43 | direction or management of such entity, whether by contract or 44 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 45 | outstanding shares, or (iii) beneficial ownership of such entity. 46 | 47 | "You" (or "Your") shall mean an individual or Legal Entity 48 | exercising permissions granted by this License. 49 | 50 | "Source" form shall mean the preferred form for making modifications, 51 | including but not limited to software source code, documentation 52 | source, and configuration files. 53 | 54 | "Object" form shall mean any form resulting from mechanical 55 | transformation or translation of a Source form, including but 56 | not limited to compiled object code, generated documentation, 57 | and conversions to other media types. 58 | 59 | "Work" shall mean the work of authorship, whether in Source or 60 | Object form, made available under the License, as indicated by a 61 | copyright notice that is included in or attached to the work 62 | (an example is provided in the Appendix below). 63 | 64 | "Derivative Works" shall mean any work, whether in Source or Object 65 | form, that is based on (or derived from) the Work and for which the 66 | editorial revisions, annotations, elaborations, or other modifications 67 | represent, as a whole, an original work of authorship. For the purposes 68 | of this License, Derivative Works shall not include works that remain 69 | separable from, or merely link (or bind by name) to the interfaces of, 70 | the Work and Derivative Works thereof. 71 | 72 | "Contribution" shall mean any work of authorship, including 73 | the original version of the Work and any modifications or additions 74 | to that Work or Derivative Works thereof, that is intentionally 75 | submitted to Licensor for inclusion in the Work by the copyright owner 76 | or by an individual or Legal Entity authorized to submit on behalf of 77 | the copyright owner. For the purposes of this definition, "submitted" 78 | means any form of electronic, verbal, or written communication sent 79 | to the Licensor or its representatives, including but not limited to 80 | communication on electronic mailing lists, source code control systems, 81 | and issue tracking systems that are managed by, or on behalf of, the 82 | Licensor for the purpose of discussing and improving the Work, but 83 | excluding communication that is conspicuously marked or otherwise 84 | designated in writing by the copyright owner as "Not a Contribution." 85 | 86 | "Contributor" shall mean Licensor and any individual or Legal Entity 87 | on behalf of whom a Contribution has been received by Licensor and 88 | subsequently incorporated within the Work. 89 | 90 | 2. Grant of Copyright License. Subject to the terms and conditions of 91 | this License, each Contributor hereby grants to You a perpetual, 92 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 93 | copyright license to reproduce, prepare Derivative Works of, 94 | publicly display, publicly perform, sublicense, and distribute the 95 | Work and such Derivative Works in Source or Object form. 96 | 97 | 3. Grant of Patent License. Subject to the terms and conditions of 98 | this License, each Contributor hereby grants to You a perpetual, 99 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 100 | (except as stated in this section) patent license to make, have made, 101 | use, offer to sell, sell, import, and otherwise transfer the Work, 102 | where such license applies only to those patent claims licensable 103 | by such Contributor that are necessarily infringed by their 104 | Contribution(s) alone or by combination of their Contribution(s) 105 | with the Work to which such Contribution(s) was submitted. If You 106 | institute patent litigation against any entity (including a 107 | cross-claim or counterclaim in a lawsuit) alleging that the Work 108 | or a Contribution incorporated within the Work constitutes direct 109 | or contributory patent infringement, then any patent licenses 110 | granted to You under this License for that Work shall terminate 111 | as of the date such litigation is filed. 112 | 113 | 4. Redistribution. You may reproduce and distribute copies of the 114 | Work or Derivative Works thereof in any medium, with or without 115 | modifications, and in Source or Object form, provided that You 116 | meet the following conditions: 117 | 118 | (a) You must give any other recipients of the Work or 119 | Derivative Works a copy of this License; and 120 | 121 | (b) You must cause any modified files to carry prominent notices 122 | stating that You changed the files; and 123 | 124 | (c) You must retain, in the Source form of any Derivative Works 125 | that You distribute, all copyright, patent, trademark, and 126 | attribution notices from the Source form of the Work, 127 | excluding those notices that do not pertain to any part of 128 | the Derivative Works; and 129 | 130 | (d) If the Work includes a "NOTICE" text file as part of its 131 | distribution, then any Derivative Works that You distribute must 132 | include a readable copy of the attribution notices contained 133 | within such NOTICE file, excluding those notices that do not 134 | pertain to any part of the Derivative Works, in at least one 135 | of the following places: within a NOTICE text file distributed 136 | as part of the Derivative Works; within the Source form or 137 | documentation, if provided along with the Derivative Works; or, 138 | within a display generated by the Derivative Works, if and 139 | wherever such third-party notices normally appear. The contents 140 | of the NOTICE file are for informational purposes only and 141 | do not modify the License. You may add Your own attribution 142 | notices within Derivative Works that You distribute, alongside 143 | or as an addendum to the NOTICE text from the Work, provided 144 | that such additional attribution notices cannot be construed 145 | as modifying the License. 146 | 147 | You may add Your own copyright statement to Your modifications and 148 | may provide additional or different license terms and conditions 149 | for use, reproduction, or distribution of Your modifications, or 150 | for any such Derivative Works as a whole, provided Your use, 151 | reproduction, and distribution of the Work otherwise complies with 152 | the conditions stated in this License. 153 | 154 | 5. Submission of Contributions. Unless You explicitly state otherwise, 155 | any Contribution intentionally submitted for inclusion in the Work 156 | by You to the Licensor shall be under the terms and conditions of 157 | this License, without any additional terms or conditions. 158 | Notwithstanding the above, nothing herein shall supersede or modify 159 | the terms of any separate license agreement you may have executed 160 | with Licensor regarding such Contributions. 161 | 162 | 6. Trademarks. This License does not grant permission to use the trade 163 | names, trademarks, service marks, or product names of the Licensor, 164 | except as required for reasonable and customary use in describing the 165 | origin of the Work and reproducing the content of the NOTICE file. 166 | 167 | 7. Disclaimer of Warranty. Unless required by applicable law or 168 | agreed to in writing, Licensor provides the Work (and each 169 | Contributor provides its Contributions) on an "AS IS" BASIS, 170 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 171 | implied, including, without limitation, any warranties or conditions 172 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 173 | PARTICULAR PURPOSE. You are solely responsible for determining the 174 | appropriateness of using or redistributing the Work and assume any 175 | risks associated with Your exercise of permissions under this License. 176 | 177 | 8. Limitation of Liability. In no event and under no legal theory, 178 | whether in tort (including negligence), contract, or otherwise, 179 | unless required by applicable law (such as deliberate and grossly 180 | negligent acts) or agreed to in writing, shall any Contributor be 181 | liable to You for damages, including any direct, indirect, special, 182 | incidental, or consequential damages of any character arising as a 183 | result of this License or out of the use or inability to use the 184 | Work (including but not limited to damages for loss of goodwill, 185 | work stoppage, computer failure or malfunction, or any and all 186 | other commercial damages or losses), even if such Contributor 187 | has been advised of the possibility of such damages. 188 | 189 | 9. Accepting Warranty or Additional Liability. While redistributing 190 | the Work or Derivative Works thereof, You may choose to offer, 191 | and charge a fee for, acceptance of support, warranty, indemnity, 192 | or other liability obligations and/or rights consistent with this 193 | License. However, in accepting such obligations, You may act only 194 | on Your own behalf and on Your sole responsibility, not on behalf 195 | of any other Contributor, and only if You agree to indemnify, 196 | defend, and hold each Contributor harmless for any liability 197 | incurred by, or claims asserted against, such Contributor by reason 198 | of your accepting any such warranty or additional liability. 199 | 200 | END OF TERMS AND CONDITIONS 201 | 202 | APPENDIX: How to apply the Apache License to your work. 203 | 204 | To apply the Apache License to your work, attach the following 205 | boilerplate notice, with the fields enclosed by brackets "[]" 206 | replaced with your own identifying information. (Don't include 207 | the brackets!) The text should be enclosed in the appropriate 208 | comment syntax for the file format. We also recommend that a 209 | file or class name and description of purpose be included on the 210 | same "printed page" as the copyright notice for easier 211 | identification within third-party archives. 212 | 213 | Copyright [yyyy] [name of copyright owner] 214 | 215 | Licensed under the Apache License, Version 2.0 (the "License"); 216 | you may not use this file except in compliance with the License. 217 | You may obtain a copy of the License at 218 | 219 | http://www.apache.org/licenses/LICENSE-2.0 220 | 221 | Unless required by applicable law or agreed to in writing, software 222 | distributed under the License is distributed on an "AS IS" BASIS, 223 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 224 | See the License for the specific language governing permissions and 225 | limitations under the License. 226 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Accelerating MSM Operations on GPU/FPGA 2 | 3 | 4 | 5 | Prize Sponsor: Aleo 6 | 7 | Prize Architect: Aleo 8 | 9 | ## Prize Description 10 | 11 | ### Summary 12 | 13 | 14 | 15 | Multiscalar multiplication (MSM) operations are an essential building block for zk computations. This prize will focus on computing the fastest MSM using either GPUs or FPGAs. 16 | 17 | ### Optimization Objective 18 | 19 | 20 | 21 | Compute the fixed-base point MSM for 2^26 randomly sampled scalars from the BLS 12-377 base field with lowest latency . 22 | 23 | 24 | 25 | More specifically, given a fixed set of elliptic curve points from the BLS 12-377 G1 curve: 26 | 27 | ![](https://lh4.googleusercontent.com/gK2osGICS_AGf2o7BjYn0EYxRsL__bFNOijYfjCJJd4qSMbkAhJMfUmcFHZsJmcdy6kMCKdefofjb0K2QLRgLcx6e8R7D3AA5rv-lT60c190MID4ncsi9RkPa-75twKBHKjG_hGXjL9Wa-Q6ig) 28 | 29 | 30 | 31 | and a randomly sampled input vector of finite field elements from the scalar field: 32 | 33 | 34 | 35 | ![](https://lh4.googleusercontent.com/Udo-s0GY7GaAKc1pBc3sEmTvn7EdF8tOXKs4AOGXo6sVJEnOEmIMzLTOfr_Pv6Mu1UxMeZ07hRqGkGoJcBPGsZ3JkMxZChvtWcuvmWCGMyvTlXHGHv1ISd5dNdz1GxLq_S-M3srkVHXsSca6BQ) 36 | 37 | 38 | 39 | Calculate elliptic curve point Q when n = 2^26 40 | 41 | 42 | 43 | ![](https://lh4.googleusercontent.com/FJZlZkLVwVFdhOYjHM-aeRDR9yhEQM1bcsOF9ml7P_unOHId3255O9_dFTQ7X-uYddkV6FJO31XneTSTI_u0BzZXjBbcIyAoB20xyZ3BE4m5nd7V8sUTi81C2I2XcI5wt1pa1aMHviSUdDC9ew) 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | ### Constraints 52 | 53 | 54 | 55 | - Sufficient documentation must be provided along with the implementation 56 | 57 | - Only a single GPU/FPGA may be used; the problem may not be parallelized across multiple hardware instances. 58 | 59 | - Submissions may be written in any language. The provided test harness, however, will be in Rust. So competitors submitting solutions using other languages will be required to create their own Rust bindings 60 | 61 | 62 | ## Timeline 63 | 64 | 65 | 66 | June 1 - Final competitor selection 67 | 68 | June 10 - Competition begins 69 | 70 | July 25 - Mid-competition IPR 71 | 72 | September 10 - Deadline for submissions 73 | 74 | October 1 - Winners announced 75 | 76 | 77 | 78 | --- 79 | 80 | ## Judging 81 | 82 | 83 | 84 | Competitors for the prize will be selected based on their prior documented experience and academic achievement. 85 | 86 | 87 | 88 | Submissions will be analyzed for both correctness and performance. 89 | 90 | ### Correctness 91 | 92 | 93 | 94 | We will provide a set of test input/output vectors so that the competitors can sanity check the correctness of their code. 95 | 96 | 97 | 98 | The final correctness of the submission will be tested using randomly sampled test inputs/outputs that are not disclosed to the competitors during the competition. Submissions that fail any test cases will be judged as incorrect and lose the opportunity to win the prize. 99 | 100 | ### Performance 101 | 102 | 103 | 104 | Given input vectors consisting of 2^26 fixed elliptic curve points (bases), participants will compute a scalar multiplication of those bases with a set of four vectors of scalar elements from the associated BLS 12-377 G1 field in succession. Competitors will be provided with a set of test vectors to use while building the solution (of course, competitors can, and are encouraged to, use other vectors during the design and build process). 105 | 106 | 107 | 108 | For scoring, solutions will be run using four randomly selected test vectors as input across ten trials in total. The winning submission will be the one with the lowest average latency across all ten trials. 109 | 110 | 111 | 112 | In addition, all submissions will be manually reviewed by the prize committee appointed by the prize sponsor, Aleo. 113 | 114 | ### Hardware & Benchmarks 115 | 116 | 117 | 118 | Competitors will be given access to one of the following: 119 | 120 | 121 | 122 | 1. A dedicated instance of baseline image consisting of an AMD Epyc Milan CPU (8 cores), an A40 NVIDIA GPU (w/ 80 GB PCIe connection), and 48 GB of RAM provided by Coreweave 123 | 124 | 2. AWS credits to use an Amazon F1 instance FPGA f1.2xlarge consisting of a single FPGA and 8 CPU cores. 125 | 126 | 127 | 128 | 129 | In addition, the prize sponsor (Aleo) will provide a test harness consisting of test vectors as well as a reference implementation that consists of: 130 | 131 | - A starting GPU library for MSM (on NVidia cards) provided by Aleo 132 | 133 | - A modified version of the ZCash FPGA MSM library for F1 134 | 135 | 136 | 137 | 138 | ## Prize Allocation 139 | 140 | All submissions that receive a prize must beat the benchmark solution. 141 | 142 | 143 | 144 | | | | 145 | |--|--| 146 | | Top GPU solution | 25% of total prize | 147 | | Top FPGA solution | 25% of total prize | 148 | | Most creative solution | 10% of total prize | 149 | 150 | 151 | 152 | 153 | 154 | 155 | In addition the winning submission has the opportunity to earn up to 40% of the total prize amount based on how much their solution improved on the starting benchmark. See the table below: 156 | 157 | 158 | 159 | 160 | | | | 161 | |--|--| 162 | | 2x better than baseline | +10% | 163 | | 3x better than baseline | +10% | 164 | | 5x better than baseline | +20% | 165 | 166 | 167 | 168 | Example: a competitor submits a solution using a GPU that is the fastest overall solution and beats the provided benchmark implementation by 5x. That competitor would earn 20% (for being the top GPU submission) plus 10% (for beating the baseline by 2x) plus 10% (for beating the baseline by 3x) and another 10% for beating it by 5x. So the total share of the prize money would be 25% + 5% + 15% + 20% = 65% 169 | 170 | 171 | 172 | Prizes will be given out in good faith and in the sole discretion of the prize committee. 173 | 174 | ## Notes 175 | 176 | 177 | 178 | All submission code must be open-sourced at the time of submission. Code and documentation must be dual-licensed under both the MIT and Apache-2.0 licenses. 179 | 180 | ## Questions 181 | 182 | 183 | 184 | If there are any questions about this prize, please contact Alex at Aleo: [zprize@aleo.org](mailto:zprize@aleo.org) 185 | 186 | 187 | 188 | ## References 189 | 190 | [1] Scalar-multiplication algorithms. [https://cryptojedi.org/peter/data/eccss-20130911b.pdf](https://cryptojedi.org/peter/data/eccss-20130911b.pdf) 191 | -------------------------------------------------------------------------------- /build_image.sh: -------------------------------------------------------------------------------- 1 | script=${BASH_SOURCE[0]} 2 | if [ $script == $0 ]; then 3 | echo "ERROR: You must source this script" 4 | exit 2 5 | fi 6 | if [ "$BUCKET_ID" -eq "" ]; then 7 | echo "ERROR: BUCKET_ID must be set." 8 | fi 9 | 10 | full_script=$(readlink -f $script) 11 | script_name=$(basename $full_script) 12 | 13 | 14 | function usage { 15 | echo -e "USAGE: source $script_name [-d|-dcp DCP_FILE.tar] [-h|-help]" 16 | } 17 | 18 | function help { 19 | info_msg "$script_name" 20 | info_msg " " 21 | info_msg "build an FPGA image for POC" 22 | info_msg " " 23 | info_msg "build_agfi.sh script will:" 24 | info_msg " (1) configure aws key and region (us-east-1)" 25 | info_msg " (2) copy the tar file into an existing s3 bucket (in that region)" 26 | info_msg " (3) create an FGPA image and return the corresponding AFI/AGFI identifier for loading it" 27 | echo " " 28 | usage 29 | } 30 | # Process command line args 31 | args=( "$@" ) 32 | for (( i = 0; i < ${#args[@]}; i++ )); do 33 | arg=${args[$i]} 34 | case $arg in 35 | -d|-dcp) 36 | tar_file=${args[$i+1]} 37 | i=$i+1 38 | ;; 39 | -h|-help) 40 | help 41 | return 0 42 | ;; 43 | *) 44 | err_msg "Invalid option: $arg\n" 45 | usage 46 | return 1 47 | esac 48 | done 49 | 50 | info_msg " " 51 | info_msg "copying tar file $tar_file to bucket s3://$BUCKET_ID/$tar_file" 52 | aws s3 cp $tar_file s3://$BUCKET_ID/$tar_file 53 | 54 | info_msg " " 55 | info_msg "creating afi, logs will be saved in s3://$BUCKET_ID/logs.txt" 56 | 57 | aws ec2 create-fpga-image \ 58 | --name zprize_msm_submission \ 59 | --description "Submission for ZPRIZE" \ 60 | --input-storage-location Bucket=$BUCKET_ID,Key=$tar_file \ 61 | --logs-storage-location Bucket=$BUCKET_ID,Key=logs.txt > image-id.json 62 | -------------------------------------------------------------------------------- /evaluate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export SUBMISSION_URL=$1 4 | shift 5 | 6 | exec 2>evaluate.log 7 | set -ex 8 | 9 | function info { 10 | echo -e " 11 | \033[32m===============================\033[0m 12 | [\033[96m INFO \033[0m] $@ 13 | \033[32m===============================\033[0m 14 | " 15 | } 16 | 17 | # Clone into submission directory 18 | info Cloning the repository 19 | 20 | git clone \ 21 | --branch master \ 22 | --depth 1 \ 23 | --single-branch \ 24 | --recurse-submodules \ 25 | --shallow-submodules \ 26 | $SUBMISSION_URL submission 27 | 28 | info Setting up HDK 29 | set +e 30 | source aws-fpga/hdk_setup.sh 31 | set -e 32 | 33 | # Compile logic 34 | info Compiling CL 35 | export CL_DIR=$(pwd)/submission/cl 36 | vivado -mode batch 37 | pushd $CL_DIR/build/scripts 38 | ./aws_build_dcp_from_cl.sh -foreground 39 | popd 40 | 41 | # Create AFI 42 | info Creating AFI 43 | source ./build_image.sh -dcp $CL_DIR/build/checkpoints/to_aws/*Developer_CL.tar 44 | AGFI_ID=$(grep agfi image-id.json | cut -d'"' -f 4) 45 | 46 | # Load the image (twice, due to weird bugs in aws) 47 | info Loading AFI 48 | sudo fpga-load-local-image -S 0 -I $AGFI_ID 49 | sudo fpga-load-local-image -S 0 -I $AGFI_ID 50 | 51 | # Run correctness tests 52 | info Testing correctness 53 | pushd harness 54 | cargo test --release 55 | 56 | # Run benchmark 57 | info Benchmarking 58 | cargo bench 59 | popd 60 | 61 | # The output should now be in `harness/target/criterion/**` 62 | -------------------------------------------------------------------------------- /harness/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 = "ark-bls12-377" 7 | version = "0.3.0" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "dc41c02c0d18a226947ee9ee023b1d957bdb6a68fc22ac296722935a9fef423c" 10 | dependencies = [ 11 | "ark-ec", 12 | "ark-ff", 13 | "ark-std", 14 | ] 15 | 16 | [[package]] 17 | name = "ark-ec" 18 | version = "0.3.0" 19 | source = "registry+https://github.com/rust-lang/crates.io-index" 20 | checksum = "dea978406c4b1ca13c2db2373b05cc55429c3575b8b21f1b9ee859aa5b03dd42" 21 | dependencies = [ 22 | "ark-ff", 23 | "ark-serialize", 24 | "ark-std", 25 | "derivative", 26 | "num-traits", 27 | "rayon", 28 | "zeroize", 29 | ] 30 | 31 | [[package]] 32 | name = "ark-ff" 33 | version = "0.3.0" 34 | source = "registry+https://github.com/rust-lang/crates.io-index" 35 | checksum = "6b3235cc41ee7a12aaaf2c575a2ad7b46713a8a50bda2fc3b003a04845c05dd6" 36 | dependencies = [ 37 | "ark-ff-asm", 38 | "ark-ff-macros", 39 | "ark-serialize", 40 | "ark-std", 41 | "derivative", 42 | "num-bigint", 43 | "num-traits", 44 | "paste", 45 | "rustc_version 0.3.3", 46 | "zeroize", 47 | ] 48 | 49 | [[package]] 50 | name = "ark-ff-asm" 51 | version = "0.3.0" 52 | source = "registry+https://github.com/rust-lang/crates.io-index" 53 | checksum = "db02d390bf6643fb404d3d22d31aee1c4bc4459600aef9113833d17e786c6e44" 54 | dependencies = [ 55 | "quote", 56 | "syn", 57 | ] 58 | 59 | [[package]] 60 | name = "ark-ff-macros" 61 | version = "0.3.0" 62 | source = "registry+https://github.com/rust-lang/crates.io-index" 63 | checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" 64 | dependencies = [ 65 | "num-bigint", 66 | "num-traits", 67 | "quote", 68 | "syn", 69 | ] 70 | 71 | [[package]] 72 | name = "ark-serialize" 73 | version = "0.3.0" 74 | source = "registry+https://github.com/rust-lang/crates.io-index" 75 | checksum = "1d6c2b318ee6e10f8c2853e73a83adc0ccb88995aa978d8a3408d492ab2ee671" 76 | dependencies = [ 77 | "ark-std", 78 | "digest", 79 | ] 80 | 81 | [[package]] 82 | name = "ark-std" 83 | version = "0.3.0" 84 | source = "registry+https://github.com/rust-lang/crates.io-index" 85 | checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" 86 | dependencies = [ 87 | "num-traits", 88 | "rand", 89 | "rayon", 90 | ] 91 | 92 | [[package]] 93 | name = "atty" 94 | version = "0.2.14" 95 | source = "registry+https://github.com/rust-lang/crates.io-index" 96 | checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 97 | dependencies = [ 98 | "hermit-abi", 99 | "libc", 100 | "winapi", 101 | ] 102 | 103 | [[package]] 104 | name = "autocfg" 105 | version = "1.1.0" 106 | source = "registry+https://github.com/rust-lang/crates.io-index" 107 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 108 | 109 | [[package]] 110 | name = "bitflags" 111 | version = "1.3.2" 112 | source = "registry+https://github.com/rust-lang/crates.io-index" 113 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 114 | 115 | [[package]] 116 | name = "bstr" 117 | version = "0.2.17" 118 | source = "registry+https://github.com/rust-lang/crates.io-index" 119 | checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" 120 | dependencies = [ 121 | "lazy_static", 122 | "memchr", 123 | "regex-automata", 124 | "serde", 125 | ] 126 | 127 | [[package]] 128 | name = "bumpalo" 129 | version = "3.10.0" 130 | source = "registry+https://github.com/rust-lang/crates.io-index" 131 | checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3" 132 | 133 | [[package]] 134 | name = "cast" 135 | version = "0.2.7" 136 | source = "registry+https://github.com/rust-lang/crates.io-index" 137 | checksum = "4c24dab4283a142afa2fdca129b80ad2c6284e073930f964c3a1293c225ee39a" 138 | dependencies = [ 139 | "rustc_version 0.4.0", 140 | ] 141 | 142 | [[package]] 143 | name = "cfg-if" 144 | version = "1.0.0" 145 | source = "registry+https://github.com/rust-lang/crates.io-index" 146 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 147 | 148 | [[package]] 149 | name = "clap" 150 | version = "2.34.0" 151 | source = "registry+https://github.com/rust-lang/crates.io-index" 152 | checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" 153 | dependencies = [ 154 | "bitflags", 155 | "textwrap 0.11.0", 156 | "unicode-width", 157 | ] 158 | 159 | [[package]] 160 | name = "clap" 161 | version = "3.2.7" 162 | source = "registry+https://github.com/rust-lang/crates.io-index" 163 | checksum = "5b7b16274bb247b45177db843202209b12191b631a14a9d06e41b3777d6ecf14" 164 | dependencies = [ 165 | "atty", 166 | "bitflags", 167 | "clap_lex", 168 | "indexmap", 169 | "strsim", 170 | "termcolor", 171 | "textwrap 0.15.0", 172 | ] 173 | 174 | [[package]] 175 | name = "clap_lex" 176 | version = "0.2.4" 177 | source = "registry+https://github.com/rust-lang/crates.io-index" 178 | checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" 179 | dependencies = [ 180 | "os_str_bytes", 181 | ] 182 | 183 | [[package]] 184 | name = "criterion" 185 | version = "0.3.5" 186 | source = "registry+https://github.com/rust-lang/crates.io-index" 187 | checksum = "1604dafd25fba2fe2d5895a9da139f8dc9b319a5fe5354ca137cbbce4e178d10" 188 | dependencies = [ 189 | "atty", 190 | "cast", 191 | "clap 2.34.0", 192 | "criterion-plot", 193 | "csv", 194 | "itertools", 195 | "lazy_static", 196 | "num-traits", 197 | "oorandom", 198 | "plotters", 199 | "rayon", 200 | "regex", 201 | "serde", 202 | "serde_cbor", 203 | "serde_derive", 204 | "serde_json", 205 | "tinytemplate", 206 | "walkdir", 207 | ] 208 | 209 | [[package]] 210 | name = "criterion-plot" 211 | version = "0.4.4" 212 | source = "registry+https://github.com/rust-lang/crates.io-index" 213 | checksum = "d00996de9f2f7559f7f4dc286073197f83e92256a59ed395f9aac01fe717da57" 214 | dependencies = [ 215 | "cast", 216 | "itertools", 217 | ] 218 | 219 | [[package]] 220 | name = "crossbeam-channel" 221 | version = "0.5.5" 222 | source = "registry+https://github.com/rust-lang/crates.io-index" 223 | checksum = "4c02a4d71819009c192cf4872265391563fd6a84c81ff2c0f2a7026ca4c1d85c" 224 | dependencies = [ 225 | "cfg-if", 226 | "crossbeam-utils", 227 | ] 228 | 229 | [[package]] 230 | name = "crossbeam-deque" 231 | version = "0.8.1" 232 | source = "registry+https://github.com/rust-lang/crates.io-index" 233 | checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" 234 | dependencies = [ 235 | "cfg-if", 236 | "crossbeam-epoch", 237 | "crossbeam-utils", 238 | ] 239 | 240 | [[package]] 241 | name = "crossbeam-epoch" 242 | version = "0.9.9" 243 | source = "registry+https://github.com/rust-lang/crates.io-index" 244 | checksum = "07db9d94cbd326813772c968ccd25999e5f8ae22f4f8d1b11effa37ef6ce281d" 245 | dependencies = [ 246 | "autocfg", 247 | "cfg-if", 248 | "crossbeam-utils", 249 | "memoffset", 250 | "once_cell", 251 | "scopeguard", 252 | ] 253 | 254 | [[package]] 255 | name = "crossbeam-utils" 256 | version = "0.8.10" 257 | source = "registry+https://github.com/rust-lang/crates.io-index" 258 | checksum = "7d82ee10ce34d7bc12c2122495e7593a9c41347ecdd64185af4ecf72cb1a7f83" 259 | dependencies = [ 260 | "cfg-if", 261 | "once_cell", 262 | ] 263 | 264 | [[package]] 265 | name = "csv" 266 | version = "1.1.6" 267 | source = "registry+https://github.com/rust-lang/crates.io-index" 268 | checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" 269 | dependencies = [ 270 | "bstr", 271 | "csv-core", 272 | "itoa 0.4.8", 273 | "ryu", 274 | "serde", 275 | ] 276 | 277 | [[package]] 278 | name = "csv-core" 279 | version = "0.1.10" 280 | source = "registry+https://github.com/rust-lang/crates.io-index" 281 | checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" 282 | dependencies = [ 283 | "memchr", 284 | ] 285 | 286 | [[package]] 287 | name = "derivative" 288 | version = "2.2.0" 289 | source = "registry+https://github.com/rust-lang/crates.io-index" 290 | checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" 291 | dependencies = [ 292 | "proc-macro2", 293 | "quote", 294 | "syn", 295 | ] 296 | 297 | [[package]] 298 | name = "digest" 299 | version = "0.9.0" 300 | source = "registry+https://github.com/rust-lang/crates.io-index" 301 | checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" 302 | dependencies = [ 303 | "generic-array", 304 | ] 305 | 306 | [[package]] 307 | name = "either" 308 | version = "1.6.1" 309 | source = "registry+https://github.com/rust-lang/crates.io-index" 310 | checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" 311 | 312 | [[package]] 313 | name = "fpga-msm" 314 | version = "0.1.0" 315 | dependencies = [ 316 | "ark-bls12-377", 317 | "ark-ec", 318 | "ark-ff", 319 | "ark-std", 320 | "clap 3.2.7", 321 | "criterion", 322 | "rand", 323 | ] 324 | 325 | [[package]] 326 | name = "generic-array" 327 | version = "0.14.5" 328 | source = "registry+https://github.com/rust-lang/crates.io-index" 329 | checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" 330 | dependencies = [ 331 | "typenum", 332 | "version_check", 333 | ] 334 | 335 | [[package]] 336 | name = "getrandom" 337 | version = "0.2.7" 338 | source = "registry+https://github.com/rust-lang/crates.io-index" 339 | checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" 340 | dependencies = [ 341 | "cfg-if", 342 | "libc", 343 | "wasi", 344 | ] 345 | 346 | [[package]] 347 | name = "half" 348 | version = "1.8.2" 349 | source = "registry+https://github.com/rust-lang/crates.io-index" 350 | checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" 351 | 352 | [[package]] 353 | name = "hashbrown" 354 | version = "0.12.1" 355 | source = "registry+https://github.com/rust-lang/crates.io-index" 356 | checksum = "db0d4cf898abf0081f964436dc980e96670a0f36863e4b83aaacdb65c9d7ccc3" 357 | 358 | [[package]] 359 | name = "hermit-abi" 360 | version = "0.1.19" 361 | source = "registry+https://github.com/rust-lang/crates.io-index" 362 | checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" 363 | dependencies = [ 364 | "libc", 365 | ] 366 | 367 | [[package]] 368 | name = "indexmap" 369 | version = "1.9.1" 370 | source = "registry+https://github.com/rust-lang/crates.io-index" 371 | checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" 372 | dependencies = [ 373 | "autocfg", 374 | "hashbrown", 375 | ] 376 | 377 | [[package]] 378 | name = "itertools" 379 | version = "0.10.3" 380 | source = "registry+https://github.com/rust-lang/crates.io-index" 381 | checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" 382 | dependencies = [ 383 | "either", 384 | ] 385 | 386 | [[package]] 387 | name = "itoa" 388 | version = "0.4.8" 389 | source = "registry+https://github.com/rust-lang/crates.io-index" 390 | checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" 391 | 392 | [[package]] 393 | name = "itoa" 394 | version = "1.0.2" 395 | source = "registry+https://github.com/rust-lang/crates.io-index" 396 | checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" 397 | 398 | [[package]] 399 | name = "js-sys" 400 | version = "0.3.58" 401 | source = "registry+https://github.com/rust-lang/crates.io-index" 402 | checksum = "c3fac17f7123a73ca62df411b1bf727ccc805daa070338fda671c86dac1bdc27" 403 | dependencies = [ 404 | "wasm-bindgen", 405 | ] 406 | 407 | [[package]] 408 | name = "lazy_static" 409 | version = "1.4.0" 410 | source = "registry+https://github.com/rust-lang/crates.io-index" 411 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 412 | 413 | [[package]] 414 | name = "libc" 415 | version = "0.2.126" 416 | source = "registry+https://github.com/rust-lang/crates.io-index" 417 | checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" 418 | 419 | [[package]] 420 | name = "log" 421 | version = "0.4.17" 422 | source = "registry+https://github.com/rust-lang/crates.io-index" 423 | checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" 424 | dependencies = [ 425 | "cfg-if", 426 | ] 427 | 428 | [[package]] 429 | name = "memchr" 430 | version = "2.5.0" 431 | source = "registry+https://github.com/rust-lang/crates.io-index" 432 | checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" 433 | 434 | [[package]] 435 | name = "memoffset" 436 | version = "0.6.5" 437 | source = "registry+https://github.com/rust-lang/crates.io-index" 438 | checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" 439 | dependencies = [ 440 | "autocfg", 441 | ] 442 | 443 | [[package]] 444 | name = "num-bigint" 445 | version = "0.4.3" 446 | source = "registry+https://github.com/rust-lang/crates.io-index" 447 | checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" 448 | dependencies = [ 449 | "autocfg", 450 | "num-integer", 451 | "num-traits", 452 | ] 453 | 454 | [[package]] 455 | name = "num-integer" 456 | version = "0.1.45" 457 | source = "registry+https://github.com/rust-lang/crates.io-index" 458 | checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" 459 | dependencies = [ 460 | "autocfg", 461 | "num-traits", 462 | ] 463 | 464 | [[package]] 465 | name = "num-traits" 466 | version = "0.2.15" 467 | source = "registry+https://github.com/rust-lang/crates.io-index" 468 | checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" 469 | dependencies = [ 470 | "autocfg", 471 | ] 472 | 473 | [[package]] 474 | name = "num_cpus" 475 | version = "1.13.1" 476 | source = "registry+https://github.com/rust-lang/crates.io-index" 477 | checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" 478 | dependencies = [ 479 | "hermit-abi", 480 | "libc", 481 | ] 482 | 483 | [[package]] 484 | name = "once_cell" 485 | version = "1.12.0" 486 | source = "registry+https://github.com/rust-lang/crates.io-index" 487 | checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" 488 | 489 | [[package]] 490 | name = "oorandom" 491 | version = "11.1.3" 492 | source = "registry+https://github.com/rust-lang/crates.io-index" 493 | checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" 494 | 495 | [[package]] 496 | name = "os_str_bytes" 497 | version = "6.1.0" 498 | source = "registry+https://github.com/rust-lang/crates.io-index" 499 | checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa" 500 | 501 | [[package]] 502 | name = "paste" 503 | version = "1.0.7" 504 | source = "registry+https://github.com/rust-lang/crates.io-index" 505 | checksum = "0c520e05135d6e763148b6426a837e239041653ba7becd2e538c076c738025fc" 506 | 507 | [[package]] 508 | name = "pest" 509 | version = "2.1.3" 510 | source = "registry+https://github.com/rust-lang/crates.io-index" 511 | checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" 512 | dependencies = [ 513 | "ucd-trie", 514 | ] 515 | 516 | [[package]] 517 | name = "plotters" 518 | version = "0.3.1" 519 | source = "registry+https://github.com/rust-lang/crates.io-index" 520 | checksum = "32a3fd9ec30b9749ce28cd91f255d569591cdf937fe280c312143e3c4bad6f2a" 521 | dependencies = [ 522 | "num-traits", 523 | "plotters-backend", 524 | "plotters-svg", 525 | "wasm-bindgen", 526 | "web-sys", 527 | ] 528 | 529 | [[package]] 530 | name = "plotters-backend" 531 | version = "0.3.2" 532 | source = "registry+https://github.com/rust-lang/crates.io-index" 533 | checksum = "d88417318da0eaf0fdcdb51a0ee6c3bed624333bff8f946733049380be67ac1c" 534 | 535 | [[package]] 536 | name = "plotters-svg" 537 | version = "0.3.1" 538 | source = "registry+https://github.com/rust-lang/crates.io-index" 539 | checksum = "521fa9638fa597e1dc53e9412a4f9cefb01187ee1f7413076f9e6749e2885ba9" 540 | dependencies = [ 541 | "plotters-backend", 542 | ] 543 | 544 | [[package]] 545 | name = "ppv-lite86" 546 | version = "0.2.16" 547 | source = "registry+https://github.com/rust-lang/crates.io-index" 548 | checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" 549 | 550 | [[package]] 551 | name = "proc-macro2" 552 | version = "1.0.40" 553 | source = "registry+https://github.com/rust-lang/crates.io-index" 554 | checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" 555 | dependencies = [ 556 | "unicode-ident", 557 | ] 558 | 559 | [[package]] 560 | name = "quote" 561 | version = "1.0.20" 562 | source = "registry+https://github.com/rust-lang/crates.io-index" 563 | checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" 564 | dependencies = [ 565 | "proc-macro2", 566 | ] 567 | 568 | [[package]] 569 | name = "rand" 570 | version = "0.8.5" 571 | source = "registry+https://github.com/rust-lang/crates.io-index" 572 | checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" 573 | dependencies = [ 574 | "libc", 575 | "rand_chacha", 576 | "rand_core", 577 | ] 578 | 579 | [[package]] 580 | name = "rand_chacha" 581 | version = "0.3.1" 582 | source = "registry+https://github.com/rust-lang/crates.io-index" 583 | checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" 584 | dependencies = [ 585 | "ppv-lite86", 586 | "rand_core", 587 | ] 588 | 589 | [[package]] 590 | name = "rand_core" 591 | version = "0.6.3" 592 | source = "registry+https://github.com/rust-lang/crates.io-index" 593 | checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" 594 | dependencies = [ 595 | "getrandom", 596 | ] 597 | 598 | [[package]] 599 | name = "rayon" 600 | version = "1.5.3" 601 | source = "registry+https://github.com/rust-lang/crates.io-index" 602 | checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" 603 | dependencies = [ 604 | "autocfg", 605 | "crossbeam-deque", 606 | "either", 607 | "rayon-core", 608 | ] 609 | 610 | [[package]] 611 | name = "rayon-core" 612 | version = "1.9.3" 613 | source = "registry+https://github.com/rust-lang/crates.io-index" 614 | checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" 615 | dependencies = [ 616 | "crossbeam-channel", 617 | "crossbeam-deque", 618 | "crossbeam-utils", 619 | "num_cpus", 620 | ] 621 | 622 | [[package]] 623 | name = "regex" 624 | version = "1.5.6" 625 | source = "registry+https://github.com/rust-lang/crates.io-index" 626 | checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" 627 | dependencies = [ 628 | "regex-syntax", 629 | ] 630 | 631 | [[package]] 632 | name = "regex-automata" 633 | version = "0.1.10" 634 | source = "registry+https://github.com/rust-lang/crates.io-index" 635 | checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" 636 | 637 | [[package]] 638 | name = "regex-syntax" 639 | version = "0.6.26" 640 | source = "registry+https://github.com/rust-lang/crates.io-index" 641 | checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" 642 | 643 | [[package]] 644 | name = "rustc_version" 645 | version = "0.3.3" 646 | source = "registry+https://github.com/rust-lang/crates.io-index" 647 | checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" 648 | dependencies = [ 649 | "semver 0.11.0", 650 | ] 651 | 652 | [[package]] 653 | name = "rustc_version" 654 | version = "0.4.0" 655 | source = "registry+https://github.com/rust-lang/crates.io-index" 656 | checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" 657 | dependencies = [ 658 | "semver 1.0.11", 659 | ] 660 | 661 | [[package]] 662 | name = "ryu" 663 | version = "1.0.10" 664 | source = "registry+https://github.com/rust-lang/crates.io-index" 665 | checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" 666 | 667 | [[package]] 668 | name = "same-file" 669 | version = "1.0.6" 670 | source = "registry+https://github.com/rust-lang/crates.io-index" 671 | checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" 672 | dependencies = [ 673 | "winapi-util", 674 | ] 675 | 676 | [[package]] 677 | name = "scopeguard" 678 | version = "1.1.0" 679 | source = "registry+https://github.com/rust-lang/crates.io-index" 680 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 681 | 682 | [[package]] 683 | name = "semver" 684 | version = "0.11.0" 685 | source = "registry+https://github.com/rust-lang/crates.io-index" 686 | checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" 687 | dependencies = [ 688 | "semver-parser", 689 | ] 690 | 691 | [[package]] 692 | name = "semver" 693 | version = "1.0.11" 694 | source = "registry+https://github.com/rust-lang/crates.io-index" 695 | checksum = "3d92beeab217753479be2f74e54187a6aed4c125ff0703a866c3147a02f0c6dd" 696 | 697 | [[package]] 698 | name = "semver-parser" 699 | version = "0.10.2" 700 | source = "registry+https://github.com/rust-lang/crates.io-index" 701 | checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" 702 | dependencies = [ 703 | "pest", 704 | ] 705 | 706 | [[package]] 707 | name = "serde" 708 | version = "1.0.137" 709 | source = "registry+https://github.com/rust-lang/crates.io-index" 710 | checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" 711 | 712 | [[package]] 713 | name = "serde_cbor" 714 | version = "0.11.2" 715 | source = "registry+https://github.com/rust-lang/crates.io-index" 716 | checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" 717 | dependencies = [ 718 | "half", 719 | "serde", 720 | ] 721 | 722 | [[package]] 723 | name = "serde_derive" 724 | version = "1.0.137" 725 | source = "registry+https://github.com/rust-lang/crates.io-index" 726 | checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" 727 | dependencies = [ 728 | "proc-macro2", 729 | "quote", 730 | "syn", 731 | ] 732 | 733 | [[package]] 734 | name = "serde_json" 735 | version = "1.0.81" 736 | source = "registry+https://github.com/rust-lang/crates.io-index" 737 | checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" 738 | dependencies = [ 739 | "itoa 1.0.2", 740 | "ryu", 741 | "serde", 742 | ] 743 | 744 | [[package]] 745 | name = "strsim" 746 | version = "0.10.0" 747 | source = "registry+https://github.com/rust-lang/crates.io-index" 748 | checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" 749 | 750 | [[package]] 751 | name = "syn" 752 | version = "1.0.98" 753 | source = "registry+https://github.com/rust-lang/crates.io-index" 754 | checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" 755 | dependencies = [ 756 | "proc-macro2", 757 | "quote", 758 | "unicode-ident", 759 | ] 760 | 761 | [[package]] 762 | name = "synstructure" 763 | version = "0.12.6" 764 | source = "registry+https://github.com/rust-lang/crates.io-index" 765 | checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" 766 | dependencies = [ 767 | "proc-macro2", 768 | "quote", 769 | "syn", 770 | "unicode-xid", 771 | ] 772 | 773 | [[package]] 774 | name = "termcolor" 775 | version = "1.1.3" 776 | source = "registry+https://github.com/rust-lang/crates.io-index" 777 | checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" 778 | dependencies = [ 779 | "winapi-util", 780 | ] 781 | 782 | [[package]] 783 | name = "textwrap" 784 | version = "0.11.0" 785 | source = "registry+https://github.com/rust-lang/crates.io-index" 786 | checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" 787 | dependencies = [ 788 | "unicode-width", 789 | ] 790 | 791 | [[package]] 792 | name = "textwrap" 793 | version = "0.15.0" 794 | source = "registry+https://github.com/rust-lang/crates.io-index" 795 | checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" 796 | 797 | [[package]] 798 | name = "tinytemplate" 799 | version = "1.2.1" 800 | source = "registry+https://github.com/rust-lang/crates.io-index" 801 | checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" 802 | dependencies = [ 803 | "serde", 804 | "serde_json", 805 | ] 806 | 807 | [[package]] 808 | name = "typenum" 809 | version = "1.15.0" 810 | source = "registry+https://github.com/rust-lang/crates.io-index" 811 | checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" 812 | 813 | [[package]] 814 | name = "ucd-trie" 815 | version = "0.1.3" 816 | source = "registry+https://github.com/rust-lang/crates.io-index" 817 | checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" 818 | 819 | [[package]] 820 | name = "unicode-ident" 821 | version = "1.0.1" 822 | source = "registry+https://github.com/rust-lang/crates.io-index" 823 | checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" 824 | 825 | [[package]] 826 | name = "unicode-width" 827 | version = "0.1.9" 828 | source = "registry+https://github.com/rust-lang/crates.io-index" 829 | checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" 830 | 831 | [[package]] 832 | name = "unicode-xid" 833 | version = "0.2.3" 834 | source = "registry+https://github.com/rust-lang/crates.io-index" 835 | checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" 836 | 837 | [[package]] 838 | name = "version_check" 839 | version = "0.9.4" 840 | source = "registry+https://github.com/rust-lang/crates.io-index" 841 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 842 | 843 | [[package]] 844 | name = "walkdir" 845 | version = "2.3.2" 846 | source = "registry+https://github.com/rust-lang/crates.io-index" 847 | checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" 848 | dependencies = [ 849 | "same-file", 850 | "winapi", 851 | "winapi-util", 852 | ] 853 | 854 | [[package]] 855 | name = "wasi" 856 | version = "0.11.0+wasi-snapshot-preview1" 857 | source = "registry+https://github.com/rust-lang/crates.io-index" 858 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 859 | 860 | [[package]] 861 | name = "wasm-bindgen" 862 | version = "0.2.81" 863 | source = "registry+https://github.com/rust-lang/crates.io-index" 864 | checksum = "7c53b543413a17a202f4be280a7e5c62a1c69345f5de525ee64f8cfdbc954994" 865 | dependencies = [ 866 | "cfg-if", 867 | "wasm-bindgen-macro", 868 | ] 869 | 870 | [[package]] 871 | name = "wasm-bindgen-backend" 872 | version = "0.2.81" 873 | source = "registry+https://github.com/rust-lang/crates.io-index" 874 | checksum = "5491a68ab4500fa6b4d726bd67408630c3dbe9c4fe7bda16d5c82a1fd8c7340a" 875 | dependencies = [ 876 | "bumpalo", 877 | "lazy_static", 878 | "log", 879 | "proc-macro2", 880 | "quote", 881 | "syn", 882 | "wasm-bindgen-shared", 883 | ] 884 | 885 | [[package]] 886 | name = "wasm-bindgen-macro" 887 | version = "0.2.81" 888 | source = "registry+https://github.com/rust-lang/crates.io-index" 889 | checksum = "c441e177922bc58f1e12c022624b6216378e5febc2f0533e41ba443d505b80aa" 890 | dependencies = [ 891 | "quote", 892 | "wasm-bindgen-macro-support", 893 | ] 894 | 895 | [[package]] 896 | name = "wasm-bindgen-macro-support" 897 | version = "0.2.81" 898 | source = "registry+https://github.com/rust-lang/crates.io-index" 899 | checksum = "7d94ac45fcf608c1f45ef53e748d35660f168490c10b23704c7779ab8f5c3048" 900 | dependencies = [ 901 | "proc-macro2", 902 | "quote", 903 | "syn", 904 | "wasm-bindgen-backend", 905 | "wasm-bindgen-shared", 906 | ] 907 | 908 | [[package]] 909 | name = "wasm-bindgen-shared" 910 | version = "0.2.81" 911 | source = "registry+https://github.com/rust-lang/crates.io-index" 912 | checksum = "6a89911bd99e5f3659ec4acf9c4d93b0a90fe4a2a11f15328472058edc5261be" 913 | 914 | [[package]] 915 | name = "web-sys" 916 | version = "0.3.58" 917 | source = "registry+https://github.com/rust-lang/crates.io-index" 918 | checksum = "2fed94beee57daf8dd7d51f2b15dc2bcde92d7a72304cdf662a4371008b71b90" 919 | dependencies = [ 920 | "js-sys", 921 | "wasm-bindgen", 922 | ] 923 | 924 | [[package]] 925 | name = "winapi" 926 | version = "0.3.9" 927 | source = "registry+https://github.com/rust-lang/crates.io-index" 928 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 929 | dependencies = [ 930 | "winapi-i686-pc-windows-gnu", 931 | "winapi-x86_64-pc-windows-gnu", 932 | ] 933 | 934 | [[package]] 935 | name = "winapi-i686-pc-windows-gnu" 936 | version = "0.4.0" 937 | source = "registry+https://github.com/rust-lang/crates.io-index" 938 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 939 | 940 | [[package]] 941 | name = "winapi-util" 942 | version = "0.1.5" 943 | source = "registry+https://github.com/rust-lang/crates.io-index" 944 | checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" 945 | dependencies = [ 946 | "winapi", 947 | ] 948 | 949 | [[package]] 950 | name = "winapi-x86_64-pc-windows-gnu" 951 | version = "0.4.0" 952 | source = "registry+https://github.com/rust-lang/crates.io-index" 953 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 954 | 955 | [[package]] 956 | name = "zeroize" 957 | version = "1.5.5" 958 | source = "registry+https://github.com/rust-lang/crates.io-index" 959 | checksum = "94693807d016b2f2d2e14420eb3bfcca689311ff775dcf113d74ea624b7cdf07" 960 | dependencies = [ 961 | "zeroize_derive", 962 | ] 963 | 964 | [[package]] 965 | name = "zeroize_derive" 966 | version = "1.3.2" 967 | source = "registry+https://github.com/rust-lang/crates.io-index" 968 | checksum = "3f8f187641dad4f680d25c4bfc4225b418165984179f26ca76ec4fb6441d3a17" 969 | dependencies = [ 970 | "proc-macro2", 971 | "quote", 972 | "syn", 973 | "synstructure", 974 | ] 975 | -------------------------------------------------------------------------------- /harness/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fpga-msm" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | ark-ff = "0.3" 8 | ark-ec = { version = "0.3", features = ["parallel"] } 9 | ark-std = "0.3" 10 | clap = "3.2" 11 | rand = "0.8" 12 | ark-bls12-377 = "0.3" 13 | 14 | [dev-dependencies] 15 | criterion = { version = "0.3", features = [ "html_reports" ] } 16 | 17 | [[bench]] 18 | name = "msm" 19 | harness = false 20 | 21 | [profile.release] 22 | debug = true 23 | -------------------------------------------------------------------------------- /harness/README.md: -------------------------------------------------------------------------------- 1 | # Benchmark harness for FPGA MSM implementations in the ZPRIZE competition 2 | 3 | This repository contains the code to benchmark FPGA implementations. 4 | 5 | ## Submission 6 | 7 | A submission is recieved in the form of a URL pointing to a git repository with the following structure: 8 | 9 | root 10 | ├── cl/ (custom logic) 11 | └── driver 12 | ├── Cargo.toml 13 | └── src/ 14 | 15 | We use the master branch, and perform a shallow clone. 16 | 17 | ### Custom Logic 18 | 19 | The custom logic will be compiled with the AWS HDK environment. 20 | We will use HDK version `1.4.24`. 21 | This means that the `cl` directory must contain a `build/scripts` subdirectory with a script named `aws_build_dcp_from_cl.sh`. 22 | The output will be taken from `build/checkpoints/to_aws/.Developer_CL.tar`. 23 | 24 | ### Driver 25 | 26 | The driver package must be named `zprize_fpga_msm`, and export (at least) functions with the following signatures: 27 | ```rust 28 | pub fn multi_scalar_mult_init(points: &[G]) -> MultiScalarMultContext; 29 | 30 | pub fn multi_scalar_mult( 31 | context: &mut MultiScalarMultContext, 32 | points: &[G], 33 | scalars: &[::BigInt], 34 | ) -> G::Projective 35 | ``` 36 | 37 | The driver will be compiled with the latest rust compiler (version 1.61.0). 38 | 39 | ## This repository 40 | 41 | In this repository you will find: 42 | * A script to compile FPGA images 43 | * The benchmark harness 44 | * Test vector generation utilities 45 | * A script that evaluates a submission 46 | -------------------------------------------------------------------------------- /harness/benches/msm.rs: -------------------------------------------------------------------------------- 1 | // Copyright Supranational LLC 2 | // Licensed under the Apache License, Version 2.0, see LICENSE for details. 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | use criterion::{criterion_group, criterion_main, Criterion}; 6 | 7 | use ark_bls12_377::G1Affine; 8 | use fpga_msm::{multi_scalar_mult, multi_scalar_mult_init}; 9 | use rand::{prelude::StdRng, RngCore, SeedableRng}; 10 | 11 | use std::str::FromStr; 12 | 13 | fn criterion_benchmark(c: &mut Criterion) { 14 | let bench_npow = std::env::var("BENCH_NPOW").unwrap_or("26".to_string()); 15 | let npoints_npow = i32::from_str(&bench_npow).unwrap(); 16 | let rng = match std::env::var("MSM_SEED") { 17 | Ok(seed) => rand::rngs::StdRng::seed_from_u64(seed.parse().unwrap()), 18 | Err(_) => { 19 | let seed = StdRng::from_entropy().next_u64(); 20 | eprintln!("using seed: {}", seed); 21 | StdRng::seed_from_u64(seed) 22 | } 23 | }; 24 | 25 | let batches = 4; 26 | let (points, scalars, _results) = 27 | fpga_msm::gen::generate::(rng, 1 << npoints_npow, batches); 28 | 29 | let mut context = multi_scalar_mult_init(points.as_slice()); 30 | 31 | let mut group = c.benchmark_group("FPGA-MSM"); 32 | group.sample_size(10); 33 | 34 | let name = format!("2**{}x{}", npoints_npow, batches); 35 | group.bench_function(name, |b| { 36 | b.iter(|| { 37 | let _ = multi_scalar_mult(&mut context, &points.as_slice(), 38 | &scalars); 39 | }) 40 | }); 41 | 42 | group.finish(); 43 | } 44 | 45 | criterion_group!(benches, criterion_benchmark); 46 | criterion_main!(benches); 47 | -------------------------------------------------------------------------------- /harness/src/api.rs: -------------------------------------------------------------------------------- 1 | use ark_ec::AffineCurve; 2 | use ark_ff::PrimeField; 3 | use std::os::raw::c_void; 4 | 5 | #[repr(C)] 6 | pub struct MultiScalarMultContext { 7 | context: *mut c_void, 8 | } 9 | 10 | pub fn multi_scalar_mult_init(_points: &[G]) -> MultiScalarMultContext { 11 | MultiScalarMultContext { 12 | context: std::ptr::null_mut(), 13 | } 14 | } 15 | 16 | pub fn multi_scalar_mult( 17 | _context: &mut MultiScalarMultContext, 18 | points: &[G], 19 | scalars: &[::BigInt], 20 | ) -> Vec { 21 | let npoints = points.len(); 22 | if scalars.len() % npoints != 0 { 23 | panic!("length mismatch") 24 | } 25 | 26 | scalars 27 | .chunks_exact(npoints) 28 | .map(|batch| ark_ec::msm::VariableBaseMSM::multi_scalar_mul(points, batch)) 29 | .collect() 30 | } 31 | -------------------------------------------------------------------------------- /harness/src/gen.rs: -------------------------------------------------------------------------------- 1 | use ark_ec::msm::FixedBaseMSM; 2 | use ark_ec::{AffineCurve, ProjectiveCurve}; 3 | use ark_ff::fields::PrimeField; 4 | use ark_std::{One, UniformRand, Zero}; 5 | use rand::rngs::StdRng; 6 | 7 | pub fn generate_srs(beta: &P::ScalarField, length: usize) -> Vec

{ 8 | let scalar_bits = P::ScalarField::size_in_bits(); 9 | let mut scalars = Vec::with_capacity(length as _); 10 | scalars.push(P::ScalarField::one()); 11 | scalars.push(*beta); 12 | let mut last = *beta; 13 | for _ in 2..length { 14 | last = last * beta; 15 | scalars.push(last); 16 | } 17 | let g = P::prime_subgroup_generator(); 18 | let g_window = FixedBaseMSM::get_mul_window_size(length); 19 | let g_table = 20 | FixedBaseMSM::get_window_table::(scalar_bits, g_window, g.into_projective()); 21 | let res_jacobian = 22 | FixedBaseMSM::multi_scalar_mul::(scalar_bits, g_window, &g_table, &scalars); 23 | P::Projective::batch_normalization_into_affine(&res_jacobian) 24 | } 25 | 26 | pub fn generate( 27 | mut rng: StdRng, 28 | length: usize, 29 | batches: usize, 30 | ) -> ( 31 | Vec

, 32 | Vec<::BigInt>, 33 | Vec, 34 | ) { 35 | let g = P::prime_subgroup_generator(); 36 | let beta = P::ScalarField::rand(&mut rng); 37 | eprintln!("using beta: {}", beta); 38 | 39 | let srs = generate_srs::

(&beta, length); 40 | 41 | let mut scalars = Vec::with_capacity(length * batches); 42 | let mut results = vec![P::Projective::zero(); batches]; 43 | 44 | for i in 0..batches { 45 | let coeff: Vec<_> = (0..length) 46 | .map(|_| P::ScalarField::rand(&mut rng)) 47 | .collect(); 48 | 49 | let mut b = P::ScalarField::one(); 50 | let mut prod = P::ScalarField::zero(); 51 | for &c in &coeff { 52 | prod += c * b; 53 | b *= beta; 54 | } 55 | let res = g.mul(prod); 56 | 57 | let coeff_non_montgomery: Vec<_> = coeff.iter().map(P::ScalarField::into_repr).collect(); 58 | 59 | // if validate_result? 60 | if cfg!(debug_assertions) { 61 | assert_eq!( 62 | res, 63 | ark_ec::msm::VariableBaseMSM::multi_scalar_mul(&srs, &coeff_non_montgomery) 64 | ); 65 | } 66 | scalars.extend(coeff_non_montgomery); 67 | results[i] = res; 68 | } 69 | 70 | (srs, scalars, results) 71 | } 72 | -------------------------------------------------------------------------------- /harness/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub use api::*; 2 | 3 | mod api; 4 | pub mod gen; 5 | -------------------------------------------------------------------------------- /harness/tests/msm.rs: -------------------------------------------------------------------------------- 1 | // Copyright Supranational LLC 2 | // Licensed under the Apache License, Version 2.0, see LICENSE for details. 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | use ark_bls12_377::G1Affine; 6 | use fpga_msm::{multi_scalar_mult, multi_scalar_mult_init}; 7 | use rand::{prelude::StdRng, RngCore, SeedableRng}; 8 | 9 | use std::str::FromStr; 10 | 11 | #[test] 12 | fn msm_correctness() { 13 | let test_npow = std::env::var("TEST_NPOW").unwrap_or("15".to_string()); 14 | let npoints_npow = i32::from_str(&test_npow).unwrap(); 15 | let rng = match std::env::var("MSM_SEED") { 16 | Ok(seed) => rand::rngs::StdRng::seed_from_u64(seed.parse().unwrap()), 17 | Err(_) => { 18 | let seed = StdRng::from_entropy().next_u64(); 19 | eprintln!("using seed: {}", seed); 20 | StdRng::seed_from_u64(seed) 21 | } 22 | }; 23 | 24 | let batches = 4; 25 | eprintln!("Generating test data"); 26 | let (points, scalars, results) = 27 | fpga_msm::gen::generate::(rng, 1 << npoints_npow, batches); 28 | 29 | eprintln!("Initializing context"); 30 | let mut context = multi_scalar_mult_init(points.as_slice()); 31 | eprintln!("Running test"); 32 | let msm_results = multi_scalar_mult(&mut context, points.as_slice(), scalars.as_slice()); 33 | 34 | for i in 0..batches { 35 | assert_eq!(&msm_results[i], &results[i]); 36 | } 37 | } 38 | --------------------------------------------------------------------------------