Skip to content

spaceandtimelabs/blitzar-rs

Repository files navigation


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

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.

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 and Halo2). Mathematical details of the modified inner product argument are outlined in the Blitzar Github repository.

Other Features to Come

If there is a particular feature that you would like to see, please reach out. 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:
CPU backend prerequisites:

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

Usage

Add to your project

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

[dependencies]
blitzar = <version_number>

Feature Flags

Feature Default? Description
cpu x Enables the CPU backend.
gpu Enables the GPU Backend.

Tests

cargo test

Documentation

cargo doc --no-deps --open

Examples

Check EXAMPLES file.

Running benchmarks:

Benchmarks are run using criterion.rs:

cargo bench --features <cpu | gpu>

To run individual tests:

cargo bench --features <cpu | gpu> --bench <blitzar_benchmarks | packed_msm_benchmarks>

Development Process

The main branch is regularly built and tested, being the only source of truth. 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 panel. Also, see contribution guide.

Community & support

Join our Discord server to ask questions, discuss features, and for general chat.

License

This project is released under the Apache 2 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.