https://github.com/timjp87/kzg-elixir
Elixir bindings to implementation of the Polynomial Commitments API for EIP-4844 and EIP-7594, written in C
https://github.com/timjp87/kzg-elixir
Last synced: 4 months ago
JSON representation
Elixir bindings to implementation of the Polynomial Commitments API for EIP-4844 and EIP-7594, written in C
- Host: GitHub
- URL: https://github.com/timjp87/kzg-elixir
- Owner: timjp87
- License: mit
- Created: 2025-12-20T13:44:10.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-12-24T09:55:15.000Z (7 months ago)
- Last Synced: 2026-03-05T12:54:02.578Z (5 months ago)
- Language: Elixir
- Size: 8.79 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# KzgElixir
Elixir NIF bindings for the [c-kzg-4844](https://github.com/ethereum/c-kzg-4844) library, providing KZG trusted setup verification for Ethereum EIP-4844 (Proto-Danksharding).
## Prerequisites
You need a C compiler (`gcc` or `clang`) and `make` installed on your system to build the NIF.
- **macOS**: `xcode-select --install`
- **Linux**: `apt-get install build-essential` or equivalent
### Submodules
This library relies on `c-kzg-4844` and `blst` as git submodules. You must initialize them:
```bash
git submodule update --init --recursive
```
## Installation
Add `kzg_elixir` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:kzg_elixir, "~> 2.1.5"}
]
end
```
## Usage
### 1. Load Trusted Setup
Before performing any KZG operations, you must load the trusted setup configuration. This is usually provided as a file (e.g., `trusted_setup_4096.txt`).
```elixir
path = "path/to/trusted_setup.txt"
:ok = KzgElixir.load_trusted_setup(path)
```
### 2. Verify Blob KZG Proof
Verify that a blob matches a given KZG commitment and proof.
```elixir
blob = <<...>> # 131072 bytes
commitment = <<...>> # 48 bytes
proof = <<...>> # 48 bytes
case KzgElixir.verify_blob_kzg_proof(blob, commitment, proof) do
{:ok, true} -> IO.puts("Valid!")
{:ok, false} -> IO.puts("Invalid!")
{:error, reason} -> IO.puts("Error: #{inspect(reason)}")
end
```
## Development
The C sources for `c-kzg-4844` and `blst` are bundled in `c_src`. The `Makefile` handles the compilation of the static libraries and links them into the NIF.
```bash
mix deps.get
mix compile
mix test
```