On this page, you’ll learn how to get started on the SNARK prover contest. Here’s what you can expect:
In this challenge you’ll parallelizing the snark prover for GPU, vastly speeding up the time to create a snark proof.
We're offering $70k in cash + 3 Satoshi's Treasure Keys to speed up the zk-SNARK prover. That's broken down as follows:
And finally, we're giving $500 to the first ten teams that finish a tutorial that prepares you to make a GPU-enhanced submission.
At a high level, zk-SNARK systems look like this:
While the verifier can be performed extremely quickly and efficiently, modern provers can still be dramatically improved.
The majority of the computation time constructing a SNARK prover is spent on two steps: performing 7 FFTs and 4 multiexponentiations.
It's not important to worry about the details of these computations for now, but it's important to know that they're both perfectly parallelizeable, and therefore implementing them on GPUs (or other hardware that can exploit the parallelism) could yield a massive speedup.
We're here to help. If you run into issues, have clarifying questions on the documentations, get stuck, or want to discuss ideas, ask on our Discord chat or send an email to brad@o1labs.org.
To start, we'll show you how to go through the submission workflow for the problem of speeding up the SNARK prover. At a high level, it consists of these steps:
(Optional) Set up GPU machine.
Fork the git repo with reference code.
Compile and test.
Submit.
We expect many participants to use GPUs to try and speed up the SNARK prover, so we've set up a preconfigured AWS AMI that should help you get started.
Please note, this instance costs about $1/hour. If cost is an issue for you, please reach out to us on the Discord chat or send an email to brad@o1labs.org
Full instructions are here.
Go here to fork the reference repo. Once you've forked it, run:
git clone https://github.com/YOUR_USER_NAME/snark-challenge-prover-reference.git
to clone it.
If you're on the AMI, then you're already done, as we've preinstalled the dependencies.
If not, install the dependencies as follows (it may differ slightly for other distros).
We aren't supporting OSX for this challenge. Consider grabbing a cloud GPU machine, we've provided instructions above.
$ sudo apt-get install build-essential cmake git libgmp3-dev libprocps-dev python-markdown libboost-all-dev libssl-dev
$ sudo apt-get install build-essential cmake git libgmp3-dev libprocps4-dev python-markdown libboost-all-dev libssl-dev
$ sudo apt-get install build-essential cmake git libgmp3-dev libprocps3-dev python-markdown libboost-all-dev libssl-dev
$ sudo yum install gcc-c++ cmake make git gmp-devel procps-ng-devel python2-markdown
$ sudo yum install gcc-c++ cmake make git gmp-devel procps-ng-devel python-markdown
Once that's done, build with
$ ./build.sh
This will create three binaries. We won't go through them in detail right now but the problem page has more info.
To test the prover, run the following command:
$ ./generate_parameters fast; time ./main MNT4753 compute MNT4753-parameters MNT4753-input outputs
This will save your program's output to the file outputs
.
Now let's make a change to the implementation and re-compile. In libsnark/main.cpp
, find the line
const multi_exp_method method = multi_exp_method_BDLO12;
It should be line 24. Comment it out and uncomment the next line
const multi_exp_method method = multi_exp_method_bos_coster;
Recompile and run with
$ ./build.sh && time ./main MNT4753 compute MNT4753-parameters MNT4753-input outputs-new
The program should now be significantly faster! Check that the new outputs and the old outputs agree by checking shasum outputs outputs-new
.
Note that there is no need to rerun ./generate_parameters
every time you make a change.
Commit and push your change.
$ git commit -am 'try to speed things up' && git push
Go to this page to create a submission.
nvidia/cuda:10.1-devel
for the docker image.To help you get ready for your first submission, we've created a series of 3 tutorial sages that walk you through how to implement elliptic curves. Each stage should take a few hours, and by the end you’ll be setup to make your first big improvement.
The first 10 participants who complete the challenges in this stage will receive $500 and a SNARK Challenge swag-bag. You'll also be very well positioned to apply their solutions to create submissions for the $70,000 prizes for speeding up the prover.
Start with the tutorial here.
After you’ve finished the tutorial, you’ll have an on-GPU implementation of curve operations and you’ll be ready to start swapping components of the reference CPU prover for GPU components.
The first thing to do is to swap out is the prover’s multi-exponentiations (see prover reference here).
The multi-exponentiations can be seen as a giant map-reduce, as explained here. Move the “map” off CPU to take advantage of the parallelism offered by a GPU!
After that, some more hints on what to try:
For more information on the prover architecture, we suggest looking at the following
We've also provided some additional resources that should be helpful. Remember, if you run into any roadblocks, please feel free to ask questions in our Discord chat.