2023-04-10 08:03:36 -05:00
|
|
|
# Go bindings
|
2023-01-26 18:04:24 +01:00
|
|
|
|
|
|
|
This package implements Go bindings (using [Cgo](https://go.dev/blog/cgo)) for the
|
|
|
|
exported functions in [C-KZG-4844](https://github.com/ethereum/c-kzg-4844).
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
|
|
```
|
2023-03-22 05:28:42 -05:00
|
|
|
go get github.com/ethereum/c-kzg-4844
|
2023-01-26 18:04:24 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
## Go version
|
|
|
|
|
|
|
|
This package requires `1.19rc1` or later. Version `1.19beta1` and before will
|
|
|
|
not work. These versions have a linking issue and are unable to see `blst`
|
|
|
|
functions.
|
|
|
|
|
|
|
|
## Example
|
|
|
|
|
2023-03-22 05:28:42 -05:00
|
|
|
For reference, see the `example` module in this directory. You can test it out with `go run`:
|
2023-01-26 18:04:24 +01:00
|
|
|
|
|
|
|
```
|
2023-03-22 05:28:42 -05:00
|
|
|
user@system ~/c-kzg-4844/bindings/go/example $ go run .
|
2023-04-10 08:03:36 -05:00
|
|
|
go: downloading github.com/ethereum/c-kzg-4844 v0.0.0-20230407130613-fd0a51aa35bc
|
|
|
|
go: downloading github.com/supranational/blst v0.3.11-0.20230406105308-e9dfc5ee724b
|
2023-01-26 18:04:24 +01:00
|
|
|
88f1aea383b825371cb98acfbae6c81cce601a2e3129461c3c2b816409af8f3e5080db165fd327db687b3ed632153a62
|
|
|
|
```
|
|
|
|
|
|
|
|
## Tests
|
|
|
|
|
|
|
|
Run the tests with this command:
|
|
|
|
```
|
|
|
|
go test
|
|
|
|
```
|
|
|
|
|
|
|
|
## Benchmarks
|
|
|
|
|
|
|
|
Run the benchmarks with this command:
|
|
|
|
```
|
|
|
|
go test -bench=Benchmark
|
2023-01-26 23:42:56 +01:00
|
|
|
```
|
|
|
|
|
2023-04-07 07:57:48 -05:00
|
|
|
## Minimal
|
|
|
|
|
|
|
|
By default, `FIELD_ELEMENTS_PER_BLOB` will be 4096 (mainnet), but you can
|
|
|
|
manually set it to 4 (minimal), like so:
|
|
|
|
```
|
|
|
|
CGO_CFLAGS="-DFIELD_ELEMENTS_PER_BLOB=4" go build
|
|
|
|
```
|
|
|
|
|
2023-01-26 23:42:56 +01:00
|
|
|
## Note
|
|
|
|
|
|
|
|
The `go.mod` and `go.sum` files are in the project's root directory because the
|
|
|
|
bindings need access to the c-kzg-4844 source, but Go cannot reference files
|
|
|
|
outside its module/package. The best way to deal with this is to make the whole
|
|
|
|
project available, that way everything is accessible.
|