Skip to content

Commit

Permalink
Merge pull request #1 from ingonyama-zk/fix/cleanup
Browse files Browse the repository at this point in the history
Flattening and condensing repo
  • Loading branch information
omershlo authored Mar 8, 2023
2 parents 7a88354 + 6d624c6 commit 4c94223
Show file tree
Hide file tree
Showing 63 changed files with 110 additions and 256 deletions.
29 changes: 27 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
[workspace]
[package]
name = "icicle-utils"
version = "0.1.0"
edition = "2021"
authors = [ "Ingonyama" ]
description = "An implementation of the Ingonyama Cuda Library"
homepage = "https://www.ingonyama.com"
repository = "https://github.com/ingonyama-zk/icicle"

members=["wrapper/icicle-utils"]
[dependencies]
hex="*"
ark-std = "0.3.0"
ark-ff = "0.3.0"
ark-poly = "0.3.0"
ark-ec = { version = "0.3.0", features = [ "parallel" ] }
ark-bls12-381 = { version = "0.3.0", optional = true }

rand="*" #TODO: sort dependencies that are not required by the release

[build-dependencies]
cc = { version = "1.0", features = ["parallel"] }

[dev-dependencies]
rand="*"

[features]
default = ["bls12_381"]
bls12_381 = ["ark-bls12-381/curve"]
81 changes: 76 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,86 @@
![image (4)](https://user-images.githubusercontent.com/2446179/223707486-ed8eb5ab-0616-4601-8557-12050df8ccf7.png)

## 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.

If we want ZK hardware today we have FPGAs or GPUs which are relatively inexpensive. However, the biggest selling point of GPUs is the software; we talk in particular about CUDA, which makes it easy to write code running on Nvidia GPUs, taking advantage of their highly parallel architecture. Together with the widespread availability of these devices, if we can get GPUs to work on ZK workloads, then we have made a giant step towards accessible and efficient ZK provers.

## Zero Knowledge on GPU

ICICLE is a CUDA implementation of general functions widely used in ZKP. ICICLE currently provides support for MSM, NTT, and ECNTT, with plans to support Hash functons soon.

### Supported primitives

- Fields
- Scalars
- Points
- Projective: {x, y, z}
- Affine: {x, y}
- Curves
- [BLS12-381]

> NOTE: _Support for BN254 and BLS12-377 are planned_
## Build and usage

> NOTE: [NVCC] is a prerequisite for building.
1. Define or select a curve for your application; we've provided a [template][CRV_TEMPLATE] for defining a curve
2. Include the curve in [`curve_config.cuh`][CRV_CONFIG]
3. Now you can build the ICICLE library using nvcc

```sh
mkdir -p build
nvcc -o build/<ENTER_DIR_NAME> icicle/lib.cu
```

### Rust Bindings

For convenience, we also provide rust bindings to the ICICLE library for the following primitives:

- MSM
- NTT
- Forward NTT
- Inverse NTT
- ECNTT
- Forward ECNTT
- Inverse NTT
- Scalar Vector Multiplication
- Point Vector Multiplication

A custom [build script][B_SCRIPT] is used to compile and link the ICICLE library. Make sure to change the `arch` flag depending on your GPU type or leave it as `native` for the compiler to detect the installed GPU type.

Once you have your parameters set, run:

```sh
cargo build --release
```

You'll find a release ready library at `target/release/libicicle_utils.rlib`.

### Example Usage

An example of using the Rust bindings library can be found in our [fast-danksharding implementation][FDI]

## Usage
We provide two ways to interact with the library. Check the links for more details:
1. [Rust API](/wrapper)
2. [CUDA interface](/cuda)

## Contributions

Join our [Discord Server](https://discord.gg/Y4SkbDf2Ff) 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.

## License
Icicle is distributed under the terms of the MIT License.

ICICLE is distributed under the terms of the MIT License.

See [LICENSE-MIT][LMIT] for details.

<!-- Begin Links -->
[BLS12-381]: ./icicle/curves/bls12_381.cuh
[NVCC]: https://docs.nvidia.com/cuda/#installation-guides
[CRV_TEMPLATE]: ./icicle/curves/curve_template.cuh
[CRV_CONFIG]: ./icicle/curves/curve_config.cuh
[B_SCRIPT]: ./build.rs
[FDI]: https://github.com/ingonyama-zk/fast-danksharding
[LMIT]: ./LICENSE
<!-- End Links -->
4 changes: 2 additions & 2 deletions wrapper/icicle-utils/build.rs → build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ fn main() {
//TODO: can conflict/duplicate with make ?

println!("cargo:rerun-if-env-changed=CXXFLAGS");
println!("cargo:rerun-if-changed=../../cuda");
println!("cargo:rerun-if-changed=./icicle");

let mut nvcc = cc::Build::new();

nvcc.cuda(true);
nvcc.debug(false);
nvcc.flag("-arch=native");
nvcc.file("../lib.cu").compile("ingo_icicle"); //TODO: extension??
nvcc.file("./icicle/lib.cu").compile("ingo_icicle"); //TODO: extension??

}
25 changes: 0 additions & 25 deletions cuda/README.md

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions icicle/lib.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "./appUtils/msm/msm.cuh"
#include "./appUtils/ntt/ntt.cuh"
#include "./appUtils/vector_manipulation/ve_mod_mult.cu"
#include "./appUtils/vector_manipulation/ve_mod_mult.cuh"

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions wrapper/CONTRIBUTING.md

This file was deleted.

53 changes: 0 additions & 53 deletions wrapper/README.md

This file was deleted.

46 changes: 0 additions & 46 deletions wrapper/icicle-utils/Cargo.lock

This file was deleted.

28 changes: 0 additions & 28 deletions wrapper/icicle-utils/Cargo.toml

This file was deleted.

49 changes: 0 additions & 49 deletions wrapper/icicle-utils/setup_files_format.txt

This file was deleted.

24 changes: 0 additions & 24 deletions wrapper/icicle-utils/src/main.rs

This file was deleted.

5 changes: 0 additions & 5 deletions wrapper/lib.cu

This file was deleted.

Loading

0 comments on commit 4c94223

Please sign in to comment.