Skip to content

feat: add WebGPU+WASM backend - #1789

Draft
ivokub wants to merge 8 commits into
masterfrom
feat/webgpu-backends
Draft

feat: add WebGPU+WASM backend#1789
ivokub wants to merge 8 commits into
masterfrom
feat/webgpu-backends

Conversation

@ivokub

@ivokub ivokub commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Description

Still WIP. Adds dedicated shaders+backend which allows to use WebGPU acceleration for proof generation for PLONK/Groth16 over BN254/BLS12-377/BLS12-381.

Still incoming

Type of change

  • New feature (non-breaking change which adds functionality)

How has this been tested?

Dedicated pages for running in browser

How has this been benchmarked?

  • Benchmark A, on Macbook pro M1, 32GB RAM
  • Benchmark B, on x86 Intel xxx, 16GB RAM

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I did not modify files generated from templates
  • golangci-lint does not output errors locally
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Note

High Risk
New unaudited cryptographic proving path with GPU/WASM bridging; correctness bugs could yield invalid proofs, and BLS G2 coverage is known incomplete.

Overview
Adds an experimental backend/accelerated/webgpu stack for in-browser Groth16 (and PLONK per layout/README) on BN254, BLS12-377, and BLS12-381.

A Go coordinator built for js/wasm keeps compilation, witness solving, and final proof assembly in Go, but offloads quotient-H, batched G1/G2 MSMs, and BSB22 commitment/PoK MSMs to a TypeScript WebGPU runtime via syscall/js (gnarkGroth16WebGPU and shared bridge helpers). Proving keys are uploaded once (Prepare / prepareKey) with scratch buffers and quotient-domain prewarm.

Also includes WGSL shaders, web/ npm build (build:all, shader bundle generation), wasm entrypoints (native vs WebGPU runtimes), and testdata generators/fixtures for GPU kernel and prover regression. .gitignore now excludes WebGPU web build outputs.

Marked WIP / not audited; README notes G2 API test failures on BLS12-377/381 while Groth16/PLONK prover tests pass.

Reviewed by Cursor Bugbot for commit 1bea45a. Bugbot is set up for automated code reviews on this repo. Configure here.

@socket-security

socket-security Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​typescript-eslint@​8.59.31001007498100
Addednpm/​typescript@​5.9.31001009010090
Addednpm/​@​eslint/​js@​9.39.410010010091100
Addednpm/​@​webgpu/​types@​0.1.7010010010092100
Addednpm/​eslint@​9.39.49710010095100

View full report

@socket-security

socket-security Bot commented Jun 30, 2026

Copy link
Copy Markdown

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report

@ivokub

ivokub commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1bea45a. Configure here.

func (r *Runtime[PK, VK, Proof]) ensurePrepared(handle string, pk pkEntry[PK], ccs *ccsEntry) error {
if pk.prepared {
return nil
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prepared flag ignores constraint system

Medium Severity

The wasm runtime marks a proving key as prepared after the first successful PrepareWithCS and then skips all later preparation for that key handle. PLONK quotient setup and WebGPU preloads are tied to a specific constraint system, but the flag is not associated with which CCS handle was used. Reusing the same proving-key handle with a different constraint-system handle can skip required setup while still proving, yielding incorrect proofs or subtle verification failures.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1bea45a. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant