-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mopro wasm halo2 #254
Mopro wasm halo2 #254
Conversation
I followed the but the commit is built for Nov 27th update: |
Deploying mopro with Cloudflare Pages
|
test-e2e/web/README.md
Outdated
mopro-wasm $ wasm-pack build --target web --out-dir ../test-e2e/web/halo2-plonk-fibonacci -- --features plonk | ||
mopro-wasm $ wasm-pack build --target web --out-dir ../test-e2e/web/halo2-hyperplonk-fibonacci -- --features hyperplonk | ||
mopro-wasm $ wasm-pack build --target web --out-dir ../test-e2e/web/halo2-gemini-fibonacci -- --features gemini |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am thinking can this be
wasm-pack build --target web --out-dir ../test-e2e/web/mopro -- --features plonk --features hyperplonk --features gemini
so the users can simply use
import * as mopro_wasm from './mopro/mopro_wasm.js';
and call each function with
mopro_wasm.generate_plonk_proof(...)
mopro_wasm.generate_hyperplonk_proof(...)
mopro_wasm.generate_gemini_proof(...)
// and could be others in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assumed that the user would eventually use only one type of backend—Plonk, HyperPlonk, or Gemini in Halo2—even for testing purposes. However, if you think it's better to have a single Wasm package in test-e2e/web
, such as test-e2e/web/halo2-wasm-circuit
, I can modify it to follow your suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or maybe even not specify halo2
?
I hope it can be more general for applications
so like test-e2e/web/mopro
or test-e2e/web/mopro-pkg
to let users know the package is generated by mopro and in the documentation we can guide them to use
import * as mopro_wasm from './mopro/mopro_wasm.js';
to import and use functions
```bash | ||
wasm-pack test --chrome --headless -- --features plonk | ||
``` | ||
|
||
```bash | ||
wasm-pack test --chrome --headless -- --features hyperplonk | ||
``` | ||
|
||
```bash | ||
wasm-pack test --chrome --headless -- --features gemini | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
if you rename the function like
generate_plonk_proof(...)
generate_hyperplonk_proof(...)
generate_gemini_proof(...)
you can test the functions with
wasm-pack test --chrome --headless -- --all-features
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, this doc is simply copied from mopro-wasm
during the compilation of the wasm code with wasm-pack
. It will be updated
test-e2e/web/test_halo2.js
Outdated
const PROVING_KEY = await fetchBinaryFile('./halo2-hyperplonk-fibonacci/parameters/hyperplonk_fibonacci_pk.bin'); | ||
const VERIFYING_KEY = await fetchBinaryFile('./halo2-hyperplonk-fibonacci/parameters/hyperplonk_fibonacci_vk.bin'); | ||
|
||
const result = await halo2_hyperplonk_wasm.generate_proof(SRS_KEY, PROVING_KEY, input); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am also thinking to print out (or show on screen) the execution time of generate_proof
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I had added a feature that displayed the proof generation time alongside the test results. However, I eventually removed it because showing the generation time without any additional metadata—such as device information or circuit configuration—could lead to unmanaged benchmarking results.
If you think it's not a significant issue, I would be happy to add the feature back, either by logging the proof generation time to the console or showing it alongside the test results
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is interesting to benchmark different backends or different circuits
and we can update the result here https://zkmopro.org/docs/performance#halo2
(but update here is optional)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will update halo2 wasm benchmark result in another PR. I want to add managing number thread feature in test-e2e/web
mopro-wasm/src/wasm.rs
Outdated
|
||
#[cfg(feature = "plonk")] | ||
#[wasm_bindgen] | ||
pub fn prove_and_verify_plonk_proof() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure what is the function for?
there is generate_proof
and verify_proof
in each file (plonk
, hyperplonk
, and gemini
)
and there is also tests in tests/wasm.rs
maybe this file can be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad. This file is left-over, I will remove this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works well for me
just need to change halo2
to more general term like mopro supported proving systems
(But when mentioning rayon
, we can still mention halo2
)
...e/web/mopro-pkg/snippets/wasm-bindgen-rayon-9d40dbf53d170728/src/workerHelpers.no-bundler.js
Show resolved
Hide resolved
You can see how many web-worker spawned in browser from dev tool like one below. It's updated at 63e90b9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thank you!
It is such a big progress of mopro :)
To enable multithreading in WASM,
wasm-bindgen-rayon
must be used.from: Rayon - github
Currently,
wasm-bindgen-rayon
version 1.2.1 can only be compiled with the nightly rust, specifically nightly-2024-07-18test-e2e
based onjs
test-e2e/web
in headless wayRelated issue: #202