Skip to content

Commit b062963

Browse files
ivokubCopilot
andauthored
feat: add BLS12-377, BLS12-381 and BW6-761 GPU acceleration support for Groth16 (#1625)
Co-authored-by: Copilot <[email protected]>
1 parent 191e8b5 commit b062963

31 files changed

+3942
-238
lines changed

README.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -171,20 +171,11 @@ The following schemes and curves support experimental use of Ingonyama's ICICLE
171171
instantiated with the following curve(s)
172172

173173
- [x] BN254
174+
- [x] BLS12-377
175+
- [x] BLS12-381
176+
- [x] BW6-761
174177

175-
To use GPUs, add the `icicle` buildtag to your build/run commands, e.g. `go run -tags=icicle main.go`.
176-
177-
You can then toggle on or off icicle acceleration by providing the `WithIcicleAcceleration` backend ProverOption:
178-
179-
```go
180-
// toggle on
181-
proofIci, err := groth16.Prove(ccs, pk, secretWitness, backend.WithIcicleAcceleration())
182-
183-
// toggle off
184-
proof, err := groth16.Prove(ccs, pk, secretWitness)
185-
```
186-
187-
For more information about prerequisites see the [ICICLE repo](https://github.com/ingonyama-zk/icicle-gnark).
178+
For usage instructions see [accelerated backend documentation](backend/accelerated/icicle/doc.go) and [ICICLE repo](https://github.com/ingonyama-zk/icicle-gnark).
188179

189180
## Citing
190181

backend/accelerated/icicle/doc.go

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// Package icicle implements backends using ICICLE library.
2+
//
3+
// This backend depends on the MIT-licensed [ICICLE] library. We currently
4+
// support Groth16 proving system on the following curves:
5+
// - BLS12-377
6+
// - BLS12-381
7+
// - BN254
8+
// - BW6-761
9+
//
10+
// # Setup
11+
//
12+
// Before using the GPU-acceleration for ICICLE backend, you must install the
13+
// CUDA toolkit and have a compatible NVIDIA GPU. See [CUDA instructions] for
14+
// more details. We have tested with CUDA 13 on Linux (Ubuntu 24.04), but other
15+
// versions should work as well.
16+
//
17+
// Additionally, for building ICICLE backend, you need to have a working clang
18+
// toolchain.
19+
//
20+
// To initialize the ICICLE backend, follow the instructions in the [ICICLE]
21+
// repository. Namely, first you should install the ICICLE library:
22+
//
23+
// git clone https://github.com/ingonyama-zk/icicle-gnark
24+
// cd icicle-gnark/wrappers/golang
25+
// sudo ./build.sh -curve=all
26+
//
27+
// After that, the libraries are installed in `/usr/local/lib` and backend in
28+
// `/usr/local/lib/backend`.
29+
//
30+
// Now set the environment variables:
31+
//
32+
// export CGO_LDFLAGS="-L/usr/local/lib -licicle_device -lstdc++ -lm -Wl,-rpath=/usr/local/lib"
33+
// export ICICLE_BACKEND_INSTALL_DIR="/usr/local/lib/backend/"
34+
//
35+
// # Usage
36+
//
37+
// To use the ICICLE backend in your code, you should use the `icicle_groth16`
38+
// package and use it for proving:
39+
//
40+
// import icicle_groth "github.com/consensys/gnark/backend/accelerated/icicle/groth16"
41+
// ...
42+
// pk := icicle_groth.NewProvingKey(curve)
43+
// n, err = pk.ReadFrom(r)
44+
// ...
45+
// proof, err := icicle_groth.Prove(ccs, pk, witness)
46+
//
47+
// Finally, to build the application, use the `icicle` build tag to ensure the ICICLE integration is built:
48+
//
49+
// go build -tags=icicle main.go
50+
//
51+
// # Proving key
52+
//
53+
// Keep in mind that the definitions of ICICLE and native gnark proving keys are
54+
// different, so you cannot directly use the native gnark proving key with the
55+
// ICICLE backend. However, the serialization is compatible, so you can use the
56+
// `ReadFrom` and `WriteTo` methods to read/write the proving keys in binary
57+
// format and use the same proving key for both backends.
58+
//
59+
// # Non-free backends
60+
//
61+
// gnark by default depends on the MIT-licensed ICICLE backend library. However, ICICLE
62+
// can be used with non-free backends (newer CUDA and Metal), but this is not tested
63+
// and we do not provide support for this.
64+
//
65+
// # Future compatibility
66+
//
67+
// Keep in mind that the accelerated backends are not automatically tested in
68+
// the CI, so we cannot guarantee that future changes in gnark will not break
69+
// the ICICLE integration. We also may change interfaces in the sub-packages to
70+
// align with the external dependency changes.
71+
//
72+
// [ICICLE]: https://github.com/ingonyama-zk/icicle-gnark
73+
// [CUDA instructions]: https://developer.nvidia.com/cuda-downloads?target_os=Linux
74+
package icicle

backend/accelerated/icicle/groth16/bls12-377/doc.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)