Home

Awesome

ICICLE

<div align="center"> ICICLE is a high-performance cryptographic acceleration library designed to optimize cryptographic computations across various hardware platforms, including CPUs, GPUs, and other accelerators. </div> <p align="center"> <br> <img alt="ICICLE" width="300" height="300" src="McPaw.gif"/> </p> <p align="center"> <br> <br> <a href="https://discord.gg/EVVXTdt6DF"> <img src="https://img.shields.io/discord/1063033227788423299?logo=discord&style=flat&labelColor=black&color=5765f2" alt="Chat with us on Discord"> </a> <a href="https://www.linkedin.com/company/ingonyama"> <img src="https://img.shields.io/badge/follow-blue?style=flat&logo=linkedin&labelColor=black" alt="Follow us on LinkedIn"> </a> <a href="https://x.com/Ingo_zk"> <img src="https://img.shields.io/badge/follow-darkgray?style=flat&logo=x&labelColor=black" alt="Follow us on Twitter"> </a> <a href="https://github.com/ingonyama-zk/icicle/releases"> <img src="https://img.shields.io/github/v/release/ingonyama-zk/icicle?style=flat&labelColor=black&color=lightblue" alt="GitHub Release"> </a> </p>

Background

Zero Knowledge Proofs (ZKPs) are considered one of the greatest achievements of modern cryptography. Accordingly, ZKPs are expected to disrupt a number of industries and will usher in an era of trustless and privacy preserving services and infrastructure.

We believe that ICICLE will be a cornerstone in the acceleration of ZKPs:

Getting Started

This guide will help you get started with ICICLE in C++, Rust, and Go.

[!NOTE] Developers: We highly recommend reading our documentation for a comprehensive explanation of ICICLE’s capabilities.

[!TIP] Try out ICICLE by running some examples available in C++, Rust, and Go bindings. Check out our install-and-use examples in C++, Rust and Go

Prerequisites

[!NOTE] For older GPUs that only support CUDA 11, ICICLE may still function, but official support is for CUDA 12 onwards.

Accessing Hardware

If you don't have access to an Nvidia GPU we have some options for you.

Google Colab offers a free T4 GPU instance and ICICLE can be used with it, reference this guide for setting up your Google Colab workplace.

If you require more compute and have an interesting research project, we have bounty and grant programs.

Building ICICLE from source

ICICLE provides build systems for C++, Rust, and Go. Each build system incorporates the core ICICLE library, which contains the essential cryptographic primitives. Refer to the Getting started page for full details about building and using ICICLE.

[!WARNING] Ensure ICICLE libraries are installed correctly when building or installing a library/application that depends on ICICLE so that they can be located at runtime.

Rust

In cargo.toml, specify the ICICLE libs to use:

[dependencies]
icicle-runtime = { git = "https://github.com/ingonyama-zk/icicle.git", branch="main" }
icicle-core = { git = "https://github.com/ingonyama-zk/icicle.git", branch="main" }
icicle-babybear = { git = "https://github.com/ingonyama-zk/icicle.git", branch="main" }
# add other ICICLE crates here if need additional fields/curves

You can specify branch=branch-name, tag=tag-name, or rev=commit-id.

Build the Rust project:

cargo build --release

Go

There are two ways to build from source in Go:

  1. Clone the repo, update your go.mod to point to the local clone, and build ICICLE within the clone
git clone https://github.com/ingonyama-zk/icicle.git

Add ICICLE v3 to your go.mod file:

require github.com/ingonyama-zk/icicle/v3 v3.0.0

replace github.com/ingonyama-zk/icicle/v3 => ../path/to/cloned/icicle

Navigate to the cloned repo's golang bindings and build the library using the supplied build script

cd icicle/wrappers/golang
chmod +x build.sh
./build.sh -curve=bn254
  1. Update your go.mod to include ICICLE as a dependency, navigate to the dependency in your GOMODCACHE and build ICICLE there
go get github.com/ingonyama-zk/icicle/v3
cd $(go env GOMODCACHE)/github.com/ingonyama-zk/icicle/v3@<version>/wrappers/golang
chmod +x build.sh
./build.sh -curve=bn254

[!NOTE] To specify the field, use the flag -field=<field>, where <field> can be one of the following: babybear, stark252, m31. To specify a curve, use the flag -curve=<curve>, where <curve> can be one of the following: bn254, bls12_377, bls12_381, bw6_761, grumpkin.

Once ICICLE has been built, you can add specific packages when you need them in your application:

import (
  runtime "github.com/ingonyama-zk/icicle/v3/wrappers/golang/runtime"
  core "github.com/ingonyama-zk/icicle/v3/wrappers/golang/core"
  bn254 "github.com/ingonyama-zk/icicle/v3/wrappers/golang/curves/bn254"
  bn254MSM "github.com/ingonyama-zk/icicle/v3/wrappers/golang/curves/bn254/msm"
)

C++

ICICLE can be built and tested in C++ using CMake. The build process is straightforward, but there are several flags you can use to customize the build for your needs.

Clone the ICICLE repository:

git clone https://github.com/ingonyama-zk/icicle.git
cd icicle

Configure the build:

mkdir -p build && rm -rf build/*
cmake -S icicle -B build -DFIELD=babybear

[!NOTE] To specify the field, use the flag -DFIELD=field, where field can be one of the following: babybear, stark252, m31. To specify a curve, use the flag -DCURVE=curve, where curve can be one of the following: bn254, bls12_377, bls12_381, bw6_761, grumpkin.

Build the project:

cmake --build build -j # -j is for multi-core compilation

Link your application (or library) to ICICLE:

target_link_libraries(yourApp PRIVATE icicle_field_babybear icicle_device)

Install (optional):

To install the libs, specify the install prefix -DCMAKE_INSTALL_PREFIX=/install/dir/. Then after building, use cmake to install the libraries:

cmake -S icicle -B build -DFIELD=babybear -DCMAKE_INSTALL_PREFIX=/path/to/install/dir/
cmake --build build -j # build
cmake --install build # install icicle to /path/to/install/dir/

Run tests (optional):

[!CAUTION] Most tests assume a CUDA backend exists and will fail otherwise, if a CUDA device is not found.

Add -DBUILD_TESTS=ON to the cmake command, build and execute tests:

cmake -S icicle -B build -DFIELD=babybear -DBUILD_TESTS=ON
cmake --build build -j
cd build/tests
ctest

or choose the test-suite

./build/tests/test_field_api # or another test suite
# can specify tests using regex. For example for tests with ntt in the name:
./build/tests/test_field_api --gtest_filter="*ntt*"

Build Flags:

You can customize your ICICLE build with the following flags:

Install CUDA backend

To install the CUDA backend

  1. Download the release binaries.
  2. Install it, by extracting the binaries to /opt/ or any other custom install path.
  3. In your application, load the cuda backend and select a CUDA device.
  4. All subsequent API will now use the selected device.

Rust:

use icicle_runtime::{runtime, Device};

runtime::load_backend_from_env_or_default().unwrap();
// or load programmatically
runtime::load_backend("/path/to/backend/installdir").unwrap();
// Select CUDA device
let device = Device::new("CUDA", 1 /*gpu-id*/);
icicle_runtime::set_device(&device).unwrap();

// Any call will now execute on GPU-1

Go:

import(
  "github.com/ingonyama-zk/icicle/v3/wrappers/golang/runtime"
)

result := runtime.LoadBackendFromEnvOrDefault()
// or load from custom install dir
result := runtime.LoadBackend("/path/to/backend/installdir", true)
// Select CUDA device
device := runtime.CreateDevice("CUDA", 0) // or other
result := runtime.SetDevice(device)

// Any call will now execute on GPU-0

C++:

#include "icicle/runtime.h"

// Load the installed backend
eIcicleError result = icicle_load_backend_from_env_or_default();
// or load it programmatically
eIcicleError result = icicle_load_backend("/path/to/backend/installdir", true);

// Select CUDA device
icicle::Device device = {"CUDA", 0 /*gpu-id*/};
eIcicleError result = icicle_set_device(device);

// Any call will now execute on GPU-0

Full details can be found in our getting started docs

Contributions

Join our Discord Server and find us on the ICICLE channel. We will be happy to work together to support your use case, and talk features, bugs and design.

Development Contributions

If you are changing code, please make sure to change your git hooks path to the repo's hooks directory by running the following command:

git config core.hooksPath ./scripts/hooks

In case clang-format is missing on your system, you can install it using the following command:

sudo apt install clang-format

You will also need to install codespell to check for typos.

This will ensure our custom hooks are run and will make it easier to follow our coding guidelines.

Hall of Fame

Help & Support

For help and support talk to our devs in our discord channel #ICICLE or contact us at support@ingonyama.com.

License

ICICLE frontend is distributed under the terms of the MIT License.

[!NOTE] ICICLE backends, excluding the CPU backend, are distributed under a special license and are not covered by the MIT license.

See LICENSE-MIT for details.

<!-- Begin Links --> <!-- End Links -->