|
| 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 |
0 commit comments