Skip to content

Commit

Permalink
Update readme with new benchmark results
Browse files Browse the repository at this point in the history
  • Loading branch information
belijzajac committed Jun 3, 2023
1 parent 866784b commit ce157af
Show file tree
Hide file tree
Showing 22 changed files with 53 additions and 30 deletions.
Binary file added images/blob_to_kzg_commitment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/commit_to_poly.png
Binary file not shown.
Binary file added images/compute_blob_kzg_proof.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/compute_kzg_proof.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/das_extension.png
Binary file not shown.
Binary file added images/fft.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/fft_fr.png
Binary file not shown.
Binary file removed images/fft_g1.png
Binary file not shown.
Binary file added images/multi_scalar_multiplication.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/new_poly_div.png
Binary file not shown.
Binary file removed images/recovery.png
Binary file not shown.
Binary file added images/verify_blob_kzg_proof.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/verify_blob_kzg_proof_batch_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/verify_blob_kzg_proof_batch_16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/verify_blob_kzg_proof_batch_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/verify_blob_kzg_proof_batch_32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/verify_blob_kzg_proof_batch_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/verify_blob_kzg_proof_batch_64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/verify_blob_kzg_proof_batch_8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/verify_kzg_proof.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/zero_poly.png
Binary file not shown.
83 changes: 53 additions & 30 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ Support for multiple backend ECC libraries is implemented via [Traits](https://g
| Backend ECC | FFT/DAS | EIP-4844 (non-parallel) | EIP-4844 (parallel) | [c-kzg-4844](https://github.com/ethereum/c-kzg-4844) drop-in replacement |
| :---: | :---: | :---: | :---: | :---: |
| [blst](https://github.com/supranational/blst) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| [mcl](https://github.com/herumi/mcl) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :white_check_mark: |
| [arkworks](https://github.com/arkworks-rs/algebra) | :heavy_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| [zkcrypto](https://github.com/zkcrypto/bls12_381) | :heavy_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| [mcl](https://github.com/herumi/mcl) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: |
| [arkworks](https://github.com/arkworks-rs/algebra) (1) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: |
| [zkcrypto](https://github.com/zkcrypto/bls12_381) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: |

(1) There are several known issues with the Arkworks implementation.

# Drop-in replacement for c-kzg-4844

We aim to expose [an identical C interface](https://github.com/sifraitech/rust-kzg/blob/b4de1923a6218ea37021d0f9e3bd375dbf529d34/blst-from-scratch/src/eip_4844.rs#L604:L835) compared to [c-kzg-4844](https://github.com/ethereum/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](https://github.com/ethereum/c-kzg-4844/tree/main/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](https://github.com/sifraitech/rust-kzg/blob/main/blst/run-c-kzg-4844-tests.sh)
We aim to expose [an identical C interface](https://github.com/sifraitech/rust-kzg/blob/b4de1923a6218ea37021d0f9e3bd375dbf529d34/blst-from-scratch/src/eip_4844.rs#L604:L835) compared to [c-kzg-4844](https://github.com/ethereum/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](https://github.com/ethereum/c-kzg-4844/tree/main/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](https://github.com/sifraitech/rust-kzg/blob/main/blst/run-c-kzg-4844-tests.sh).

# Example

Expand All @@ -25,36 +27,57 @@ Currently, the ECC backend is set by pointing Cargo to the corresponding crate:

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

# Benchmarks

The latest benchmarks on AMD 3900X:

| Bench | Rust BLST | Rust BLST parallel | C-KZG (Rust bindings) | Rust MCL |
| :---: | :---: | :---: | :---: | :---: |
| Compute (2 Blobs) | 140.13 ms | 98.537 ms | 144.48 ms | 143.65 ms |
| Compute (4 Blobs) | 233.99 ms | 99.359 ms | 246.13 ms | 237.93 ms |
| Compute (8 Blobs) | 420.68 ms | 105.93 ms | 435.51 ms | 429.48 ms |
| Compute (16 Blobs) | 794.75 ms | 142.87 ms | 827.55 ms | 813.36 ms |
| Verify (2 Blobs) | 2.4682 ms | 2.4682 ms | 3.1103 ms | 6.8721 ms |
| Verify (4 Blobs) | 3.1072 ms | 3.1072 ms | 4.7926 ms | 11.403 ms |
| Verify (8 Blobs) | 4.2477 ms | 4.2477 ms | 7.9565 ms | 20.866 ms |
| Verify (16 Blobs) | 6.6977 ms | 6.6977 ms | 15.074 ms | 39.335 ms |

Benchmarks [run](https://github.com/sifraitech/kzg/blob/main/.github/workflows/benchmarks.yml) on every Github build. However, it's best to run it on a dedicated machine. [Tautvydas](https://github.com/belijzajac) rendered nice charts for results he got on cloud servers:

![fft fr](images/fft_fr.png)
![fft g1](images/fft_g1.png)
![commit to poly](images/commit_to_poly.png)
![new poly div](images/new_poly_div.png)
![zero poly](images/zero_poly.png)
![das extension](images/das_extension.png)
![recovery](images/recovery.png)

Some results are weird and needs to be double-checked.
Benchmarks [run](https://github.com/sifraitech/kzg/blob/main/.github/workflows/benchmarks.yml) on every Github build. However, it's best to run them on a dedicated machine. [Tautvydas](https://github.com/belijzajac) rendered nice charts for results he got on cloud servers:

## Blob to KZG commitment

![blob to kzg commitment](images/blob_to_kzg_commitment.png)

## Compute KZG proof

![compute kzg proof](images/compute_kzg_proof.png)

## Verify KZG proof

![verify kzg proof](images/verify_kzg_proof.png)

## Compute blob KZG proof

![compute blob kzg proof](images/compute_blob_kzg_proof.png)

## Verify blob KZG proof

![verify blob kzg proof](images/verify_blob_kzg_proof.png)

## Verify blob KZG proof batch

![verify blob kzg proof batch count 64](images/verify_blob_kzg_proof_batch_64.png)

<details>
<summary>Click to expand (blobs count 32 to 1)</summary>

![verify blob kzg proof batch count 64](images/verify_blob_kzg_proof_batch_32.png)
![verify blob kzg proof batch count 64](images/verify_blob_kzg_proof_batch_16.png)
![verify blob kzg proof batch count 64](images/verify_blob_kzg_proof_batch_8.png)
![verify blob kzg proof batch count 64](images/verify_blob_kzg_proof_batch_4.png)
![verify blob kzg proof batch count 64](images/verify_blob_kzg_proof_batch_2.png)
![verify blob kzg proof batch count 64](images/verify_blob_kzg_proof_batch_1.png)

</details>

## Fast Fourier transform (FFT)

![fft fr g1](images/fft.png)

## Multi-scalar multiplication (MSM)

![commit to polynomial](images/multi_scalar_multiplication.png)

# Authors

Expand Down

0 comments on commit ce157af

Please sign in to comment.