c-kzg-4844/README.md

77 lines
2.0 KiB
Markdown
Raw Normal View History

# c-kzg - work in progress
2021-02-01 20:15:45 +00:00
The very beginnings of a simple implementation of [KZG commitments](https://dankradfeist.de/ethereum/2020/06/16/kate-polynomial-commitments.html) in C, using the [Blst library](https://github.com/supranational/blst) from Supranational for field and curve operations.
Initially, at least, this largely follows the [go-kzg](https://github.com/protolambda/go-kzg) implementation.
Done so far:
2021-02-03 17:00:23 +00:00
- FFT and inverse FFT over the finite field.
- FFTs over the G1 group
2021-02-05 20:48:56 +00:00
- Polynomial single commitment and verification
- Polynomial multi commitment and verification
2021-02-01 20:15:45 +00:00
## Installation
Build the [Blst library](https://github.com/supranational/blst) following the instructions there. Then,
1. Copy the resulting `libblst.a` file into the `lib/` directory here.
2. From Blst's `bindings/` directory copy `blst.h` and `blst_aux.h` to `inc/`
That is,
```
cp ../blst/libblast.a lib/
cp ../blst/bindings/*.h inc/
```
2021-02-03 17:00:23 +00:00
## Build
Build the `libckzg.a` library:
```
cd src
make lib
```
Build a debug version that aborts on error conditions and attempts to print some helpful info (file, line number, condition that failed):
```
cd src
make debuglib
```
2021-02-01 20:15:45 +00:00
## Run tests
```
cd src
2021-02-01 20:15:45 +00:00
make test
```
2021-02-03 17:00:23 +00:00
Unit tests for an individual file can be built and run with `make fft_fr_test` for example. Once a test runner such as *fft_fr_test* has been built, individual unit tests can be run with `./fft_fr_test <test-name>`.
2021-02-01 20:15:45 +00:00
Thanks to [Acutest](https://github.com/mity/acutest) for the unit test harness, which is used here under the MIT licence.
2021-02-08 08:39:24 +00:00
## Run benchmarks
This will run all available benchmarks, for the default one second per test size:
```
cd src
make bench
```
You can run individual benchmarks, and optionally specify how long to run each test size:
```
make fft_fr_bench
./fft_fr_bench 5
```
Doing `make clean` should resolve any weird build issues.
## Prerequisites
- Blst library (see above)
- `clang` compiler. I'm using Clang 10.0.0. I'll likely add `gcc` options in future.
- I'm developing on Ubuntu 20.04. Will check portability later.