Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/spaceandtimelabs/blitzar-rs

High-Level Rust wrapper for the blitzar-sys crate
https://github.com/spaceandtimelabs/blitzar-rs

elliptic-curve-cryptography rust zk-proofs

Last synced: about 1 month ago
JSON representation

High-Level Rust wrapper for the blitzar-sys crate

Awesome Lists containing this project

README

        




Blitzar Crate



Blitzar



Twitter


Discord Server



License


OS


CPU


Rust


CUDA


Build State



High-Level Rust wrapper for the blitzar-sys crate.


Report Bug
|
Request a Feature


#### Background
Blitzar was created by the core cryptography team at [Space and Time](https://www.spaceandtime.io/) to accelerate Proof of SQL, a novel zero-knowledge proof for SQL operations. After surveying our options for a GPU acceleration framework, we realized that Proof of SQL needed something better… so we built Blitzar. Now, Proof of SQL runs with a 3.2 second proving time against a million-row table on a single GPU, and it’s only getting faster.

We’ve open-sourced Blitzar to provide the Web3 community with a faster and more
robust framework for building GPU-accelerated ZK proofs. We’re excited to open
the project to community contributions to expand the scope of Blitzar and lay
the foundation for the next wave of lightning fast ZK proofs.

#### Overview
Blitzar-rs is a High-Level rust wrapper for the [blitzar-sys crate](https://github.com/spaceandtimelabs/blitzar/tree/main/rust/blitzar-sys) for accelerating cryptographic zero-knowledge proof algorithms on the CPU and GPU.
> **Note**
> This repo contains the high-Level rust wrapper for the blitzar-sys crate. If you are using C++, use the code from the companion repo here: https://github.com/spaceandtimelabs/blitzar.

The crate provides

* Functions for doing group operations on [Curve-25519](https://en.wikipedia.org/wiki/Curve25519), [Ristretto25519](https://ristretto.group/), [bls12-381 G1](https://electriccoin.co/blog/new-snark-curve/), [bn254 G1](https://hackmd.io/@jpw/bn254) and [Grumpkin](https://hackmd.io/@aztec-network/B19AA8812#Curve-cycles) elements.
* An implementation of [Inner Product Argument Protocol](https://eprint.iacr.org/2017/1066.pdf) for producing and verifying a compact proof of the inner product of two vectors.

**WARNING**: This project has not undergone a security audit and is NOT ready
for production use.

#### Computational Backends
Although the primary goal of this library is to provide GPU acceleration for cryptographic ZK proof algorithms, the library also provides CPU support for the sake of testing. The following backends are supported:

| Backend | Implementation | Target Hardware |
| :--- | :--- | :--- |
| `cpu` | Serial | x86 capable CPUs |
| `gpu` | Parallel | Nvidia CUDA capable GPUs

## Cryptographic Primitives

#### Multi-Scalar Multiplication (MSM) / Generalized Pedersen Commitment / Multiexponentiation

Blitzar provides an implementation of Multi-Scalar Multiplication (i.e. generalized Pedersen commitments). Mathematical details behind MSM are outlined in the [Blitzar Github repository](https://github.com/spaceandtimelabs/blitzar#multi-scalar-multiplication-msm--generalized-pedersen-commitment--multiexponentiation).

Note: we interchangeably use the terms "multi-scalar multiplication" and "multiexponentiation" to refer to the this operation because when the group is written additively, the operation is a multi-scalar multiplication, and when the group is written multiplicatively, the operation is a multiexponentiation.

The Blitzar implementation allows for computation of multiple, potentially different length, MSMs simultaneously. Additionally, either built-in, precomputed, generators can be used, or they can be provided as needed.

Currently, Blitzar supports Curve25519 and bls12-381 G1 as groups. We're always working to expand the curves that we support, so check back for updates.

#### Inner Product Argument

Blitzar provides a modified implementation of an inner product argument (e.g. [Bulletproofs](https://eprint.iacr.org/2017/1066.pdf) and [Halo2](https://zcash.github.io/halo2/background/pc-ipa.html)). Mathematical details of the modified inner product argument are outlined in the [Blitzar Github repository](https://github.com/spaceandtimelabs/blitzar#inner-product-argument).

#### Other Features to Come

If there is a particular feature that you would like to see, please [reach out](https://github.com/spaceandtimelabs/blitzar/issues). Blitzar is a community-first project, and we want to hear from you.

## Getting Started

To get a local copy up and running, consider the following steps.

### Prerequisites to build from source

GPU backend prerequisites:

* [Rust 1.81](https://www.rust-lang.org/tools/install)
* `x86_64` Linux instance.
* NVIDIA driver version >= 560.35.03 (check the [compatibility list here](https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html)).

CPU backend prerequisites:

You'll need the following requirements to run the environment:

* [Rust 1.81](https://www.rust-lang.org/tools/install)
* `x86_64` Linux instance.

## Usage

### Add to your project

To add this library to your project, update your `Cargo.toml` file with the following line:

```
[dependencies]
blitzar =
```

### Feature Flags

| Feature | Default? | Description |
| :--- | :---: | :--- |
| `cpu` | x | Enables the CPU backend. |
| `gpu` | ✓ | Enables the GPU Backend. |

### Tests

```bash
cargo test
```

### Documentation

```bash
cargo doc --no-deps --open
```

### Examples

Check [EXAMPLES](docs/EXAMPLES.md) file.

### Running benchmarks:

Benchmarks are run using [criterion.rs](https://github.com/bheisler/criterion.rs):

```
cargo bench --features
```
To run individual tests:
```
cargo bench --features --bench
```

## Development Process

The main branch is regularly built and tested, being the only source of truth. [Tags](https://github.com/spaceandtimelabs/blitzar-rs/tags) are created regularly from automated semantic release executions.

## Contributing

We're excited to open Blitzar-rs to the community, but are not accepting community Pull Requests yet due to logistic reasons. However, feel free to contribute with any suggestion, idea, or bugfix on our [Issues](https://github.com/spaceandtimelabs/blitzar-rs/issues) panel. Also, see [contribution guide](CONTRIBUTING.md).

## Community & support

Join our [Discord server](https://discord.com/invite/SpaceandTimeDB) to ask questions, discuss features, and for general chat.

## License

This project is released under the [Apache 2 License](LICENSE).

## C++ code

This repo contains the high-Level rust wrapper for the blitzar-sys crate. If you are using C++, use the code from the companion repo here: https://github.com/spaceandtimelabs/blitzar.