Skip to content

Parallelized multi-backend KZG library for Ethereum Data Sharding (aka Proto-Danksharding, EIP-4844)

License

Notifications You must be signed in to change notification settings

grandinetech/rust-kzg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Parallelized multi-backend KZG library for Ethereum Data Sharding (aka Proto-Danksharding, EIP-4844)

The goal is to create a parallelized KZG library for Ethereum Data Sharding (aka Proto-Danksharding, EIP-4844) that supports multiple ECC (Elliptic-curve cryptography) backend libraries.

Backend ECC libraries

Support for multiple backend ECC libraries is implemented via Traits. Such an approach allows to easy change backend ECC libraries as all the crates shared the same interface (see benchmarks and tests). The current state of supported backend ECC libraries:

Backend ECC FFT/DAS EIP-4844 (non-parallel) EIP-4844 (parallel) c-kzg-4844 drop-in replacement GPU acceleration
blst ✔️ ✔️ ✔️ ✔️ ✔️ via sppark
constantine ✔️ ✔️ ✔️ ✔️
mcl ✔️ ✔️ ✔️
arkworks ✔️ ✔️ ✔️ ✔️
arkworks3 ✔️ ✔️ ✔️ ✔️ ✔️ via sppark and wlc_msm
zkcrypto ✔️ ✔️ ✔️ ✔️

Drop-in replacement for c-kzg-4844

We aim to expose an identical C interface compared to c-kzg-4844 so that rust-kzg could work as a drop-in replacement for c-kzg-4844. If you already use c-kzg-4844 bindings you can try faster paralellized rust-kzg without any changes to your code-base by simply replacing the binary. Instructions for C#, Java, Nodejs, Python, Rust bindings are available here.

Example

The best place to look for examples is tests directory.

Currently, the ECC backend is set by pointing Cargo to the corresponding crate:

[dependencies]
kzg = { git = "https://github.com/sifraitech/rust-kzg.git", package = "rust-kzg-blst" }
kzg_traits = { git = "https://github.com/sifraitech/rust-kzg.git", package = "kzg" }

Benchmarks

Benchmarks run on every Github build. However, it's best to run them on a dedicated machine. Tautvydas rendered nice charts for results he got on cloud servers:

Blob to KZG commitment

blob to kzg commitment

Compute KZG proof

compute kzg proof

Verify KZG proof

verify kzg proof

Compute blob KZG proof

compute blob kzg proof

Verify blob KZG proof

verify blob kzg proof

Verify blob KZG proof batch

verify blob kzg proof batch count 64

Click to expand (blobs count 32 to 1)

Verify blob KZG proof batch (count 32)

verify blob kzg proof batch count 32

Verify blob KZG proof batch (count 16)

verify blob kzg proof batch count 16

Verify blob KZG proof batch (count 8)

verify blob kzg proof batch count 8

Verify blob KZG proof batch (count 4)

verify blob kzg proof batch count 4

Verify blob KZG proof batch (count 2)

verify blob kzg proof batch count 2

Verify blob KZG proof batch (count 1)

verify blob kzg proof batch count 1

Fast Fourier transform (FFT)

fft fr g1

Multi-scalar multiplication (MSM)

commit to polynomial

GPU acceleration

GPU-accelerated multi-scalar multiplication is available for arkworks3 and blst backends.

Multi-scalar multiplication

multi-scalar multiplication

Blob to KZG commitment

blob to KZG commitment

Compute KZG proof

compute blob KZG proof

Compute blob KZG proof

compute blob KZG proof

Authors

The project is mainly developed by a group of students at the Blockchain Technologies course led by Saulius Grigaitis. The project is heavily based on the go-kzg, c-kzg, and other libraries.

About

Parallelized multi-backend KZG library for Ethereum Data Sharding (aka Proto-Danksharding, EIP-4844)

Resources

License

Stars

Watchers

Forks

Packages

No packages published