https://github.com/ICME-Lab/msm-webgpu
WebGPU MSM implementation
https://github.com/ICME-Lab/msm-webgpu
Last synced: 28 days ago
JSON representation
WebGPU MSM implementation
- Host: GitHub
- URL: https://github.com/ICME-Lab/msm-webgpu
- Owner: ICME-Lab
- License: other
- Created: 2023-12-08T18:29:47.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2025-10-28T16:42:57.000Z (9 months ago)
- Last Synced: 2025-10-28T18:32:04.634Z (9 months ago)
- Language: Rust
- Homepage:
- Size: 320 KB
- Stars: 17
- Watchers: 1
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
Awesome Lists containing this project
- awesome-client-side-gpu - ICME-Lab/msm-webgpu - MSM over BN254 using the cuZK algorithm, compiled to WGSL shaders. `GPU: WebGPU` `Curve: BN254` `Op: MSM` `Lang: Rust`. (Projects by GPU Technology / WebGPU (Browser-Native))
README
# ICME WebGPU MSM
An implementation of the [cuZK paper](https://eprint.iacr.org/2022/1321.pdf) in Rust for Multi-Scalar Multiplication (MSM) over the BN254 curve for WebGPU.
For an introduction to ZK proving using WebGPU, see [this recent post](https://blog.zksecurity.xyz/posts/webgpu/) by zkSecurity.
This work is built upon the existing [ZPrize 2023 submission](https://github.com/td-kwj-zp2023/webgpu-msm-bls12-377) by Tal Derei and Koh Wei Jie. Their [documentation](https://hackmd.io/HNH0DcSqSka4hAaIfJNHEA) will largely serve as a documentation for this implementation, too.
Further reads on the optimisations applied:
- [Optimizing Montgomery Multiplication in WebAssembly](https://baincapitalcrypto.com/optimizing-montgomery-multiplication-in-webassembly/) by Koh Wei Jie.
- [Optimizing Barrett Reduction: Tighter Bounds Eliminate Redundant Subtractions](https://blog.zksecurity.xyz/posts/barrett-tighter-bound/) by Suneal Gong.
- [Signed Bucket Indexes for Multi-Scalar Multiplication (MSM)](https://hackmd.io/@drouyang/signed-bucket-index) by drouyang.eth.
Made with ❤️ by [ICME Labs](https://blog.icme.io/).

## Test
For $2^{16}$ MSMs:
```
wasm-pack test --chrome --test test_webgpu_msm_cuzk_16
```
For $2^{17}$ MSMs:
```
wasm-pack test --chrome --test test_webgpu_msm_cuzk_17
```
For $2^{18}$ MSMs:
```
wasm-pack test --chrome --test test_webgpu_msm_cuzk_18
```
For $2^{19}$ MSMs:
```
wasm-pack test --chrome --test test_webgpu_msm_cuzk_19
```
For $2^{20}$ MSMs:
```
wasm-pack test --chrome --test test_webgpu_msm_cuzk_20
```
## Web Browser UI test
```
RUSTFLAGS="-C target-feature=+simd128" wasm-pack build --target no-modules --release --out-dir www/pkg
```
```
cd www
```
```
npm install
```
```
npx serve
```
Open the browser and navigate to `http://localhost:3000`.
## Future work
- Implement cuzk on other curves.
- Implement cuzk on other libraries other than `halo2curves`, such as `arkworks`.
- Explore the trade-off between the running
time and the extra storage space needed by parallel Pippenger algorithm on webGPU as the paper [Elastic MSM](https://eprint.iacr.org/2024/057.pdf) suggests.