-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
ZAL: ZK Accel Layer #308
ZAL: ZK Accel Layer #308
Conversation
CI error: https://github.com/mratsim/constantine/actions/runs/7069440808/job/19245124465?pr=308#step:24:98
LLVM 15+ supports opaque pointers by default. |
…l of rustBuild in .nimble)
Last remaining intermittent issue is because some of the MacOS runners do not support ADX instructions (error is SIGILL) and Rust Halo2curves does not support runtime CPU features detection.
|
This implements the tentative ZK Accel Layer for the Ethereum Foundation / Privacy Scaling Exploration prover, Halo2-KZG.
ZAL is described and discussed here: privacy-scaling-explorations/halo2#216
This uses candidate traits from https://github.com/taikoxyz/halo2curves/blob/pr-pse-exec-engine/src/zal.rs#L42-L49 (commit https://github.com/taikoxyz/halo2curves/blob/049469172c64698dcbcc0b0fc00bcedc7695a888/src/zal.rs#L42-L49)
Benchmarks
On a Ryzen Pro 7840U (2023, 8 cores, low-power mobile 15W to 30W TDP)
For hardware providers
The C header for the MSM is:
constantine/include/constantine/curves/bn254_snarks_parallel.h
Lines 21 to 24 in 3d4df3f
The C header for the threadpool is:
constantine/include/constantine/core/threadpool.h
Lines 22 to 39 in 3d4df3f
The Rust bindgen script is:
constantine/scripts/gen_rust_bindings.sh
Lines 3 to 15 in 3d4df3f
Wrapping to provide the Engine (i.e. just the threadpool, but it might be some Cuda or FPGA context manager for other backends) is done the following way:
constantine/constantine-rust/constantine-zal-halo2kzg/src/lib.rs
Lines 18 to 36 in 3d4df3f
Adding the MsmAccel trait is done the following way
constantine/constantine-rust/constantine-zal-halo2kzg/src/lib.rs
Lines 38 to 53 in 3d4df3f
Note on linking
For maximum performance, cross-language LTO between Nim and Rust is used.
Nim is compiled as a static library with clang and Thin-LTO
Rust is compiled with thin-lto as well, LLD is used as a linker through:
constantine/.cargo/config.toml
Line 3 in e280d80
On MacOS, Apple Clang does not support Intel assembly syntax as it is missing an upstream LLVM commit. Installing LLVM/Clang through Homebrew fixes that.