-
Notifications
You must be signed in to change notification settings - Fork 36
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
Benchmark ark-works for circom with wasm-bindgen
#290
Comments
Successfully compiled Could you provide guidance on obtaining the wtns file mentioned in this issue? Should I explore |
I think you can save the witness output to a file use num_bigint::BigUint;
use std::fs::File;
use std::io::{self, Read, Write};
fn save_biguint_vec_to_file(vec: &[BigUint], file_path: &str) -> io::Result<()> {
let mut file = File::create(file_path)?;
for biguint in vec {
let bytes = biguint.to_bytes_be();
let length = bytes.len() as u64;
// Write the length of the bytes
file.write_all(&length.to_be_bytes())?;
// Write the actual bytes
file.write_all(&bytes)?;
}
Ok(())
}
fn load_biguint_vec_from_file(file_path: &str) -> io::Result<Vec<BigUint>> {
let mut file = File::open(file_path)?;
let mut buf = Vec::new();
file.read_to_end(&mut buf)?;
let mut biguint_vec = Vec::new();
let mut cursor = 0;
while cursor < buf.len() {
// Read the length of the bytes (u64 is 8 bytes)
let mut length_bytes = [0u8; 8];
length_bytes.copy_from_slice(&buf[cursor..cursor + 8]);
cursor += 8;
let length = u64::from_be_bytes(length_bytes) as usize;
// Read the actual bytes
let bytes = &buf[cursor..cursor + length];
cursor += length;
// Convert bytes back to BigUint
biguint_vec.push(BigUint::from_bytes_be(bytes));
}
Ok(biguint_vec)
} and snarkjs wtns calculate circuit_js/circuit.wasm input.json witness.wtns The disadvantage of the |
You can refer to how vacp2p does |
Problem
We have explored this before: #202 (comment)
But looking carefully into the waku implementation, it doesn't enable
rayon
in theirwasm-bindgen
(and the
ark-groth16
has the featureparallel
to enablerayon
)with current mopro implementation, we support
wasm-bindgen-rayon
so we can try to benchmark circom groth16 prover for circuits
The result with
parallel
and withoutparallel
parallel
Details
Try to use
mopro build
forweb
(by default it supports rayon)and record the time it executes when generating a groth16 proof
(NOTE: without witness generation time, I think it is not possible to generate wasm bindings with current rust witness generator)
You can also refer to waku implementation: https://github.com/vacp2p/zerokit/blob/master/rln-wasm/src/lib.rs
Or you can load the wtns, zkey as bytes before generate the function
e.g.
Acceptance criteria
Benchmark the execution time for the following circuits in the browser
ark-works
with rayonsnarkjs
Please check the circuit input, wasm, zkey here
https://github.com/zkmopro/android-benchmark-app/tree/main/ios/MoproApp
Next steps (optional)
Update documentation for https://zkmopro.org/docs/performance/
The text was updated successfully, but these errors were encountered: