-
Notifications
You must be signed in to change notification settings - Fork 56
Build WASM prover / module #7
Comments
@Schaeff can you link to some of your work on this? |
This will just be cross-compiling using Emscriptem, it looks very straightforward. That will enable it to run in Chrome 57+ on Android and Desktop, iOS, Edge Mobile etc. See:
However, Chrome seems to have a memory limit of about 2gb for webassembly modules, I fear that without #3 this limit will be hit very quickly, and even then it may be highly problematic. |
So, I have a work-in-progress repo which uses Emscripten to build the There are a few broken things though:
Executable sizes are very reasonable:
I'm going to add some more test executables to the repo which do end-to-end tests to see if I can get the SHA256-full circuit proving and then verifying under webassembly without reaching the memory limit. This will let me compare the performance versus native x86_64 code to see if that's a significant issue. The biggest problem is probably going to be speed of the Staying under the 2gb limit is gonna be ... challenging, especially with larger circuits, but it's doable. verify.wasm.gz |
So cool! These tools are gonna be really useful. |
Only two modifications need making to
However, the wasm build is dog slow. Also in I made a test which, in one go creates a mod_hashpreimage, creates keypair, proves something, then verifies the proof. Time for test_hashpreimage native build:
Times for test_hashpreimage WASM build:
That'a significant decrease in speed... like very significant. test_hashpreimage.wasm.gz run with: Now I have a baseline I can start experimenting with optimisations.
I will push up my |
After building GMP with 64bit limbs, cleaning up the
It doesn't seem, for WASM, that there's much difference between 32bit limbs and 64bit limbs. Everything is just slow.... Anyway, all the stuff needed to build is at: https://github.com/HarryR/ethsnarks-emscripten |
For any of the SNARK circuits, we should be able to build a WebAssembly module which:
This seems fairly straightforward, using the current cmake project, to build target webassembly using Emscriptem, without modifying any of the C++ code heavily.
References:
This will need to be a separate repo which uses the
ethsnarks
repo as a sub-module.The text was updated successfully, but these errors were encountered: