* Convert argument types to bytes * Update java bindings * Update python bindings * Update node.js bindings * Update c# bindings * Fix java binding compile issues * Fix incorrect memcpy in nodejs bindings * Fix bug (called the wrong func) * Fix issues with java bindings * Fix issues with node.js bindings * Remove unnecessary wrapped funcs for c# * Rename struct member to bytes * Use goto out for callocs * Fix nit * Make un-exported funcs static * Fix python bindings * Check commitment length in python bindings * Update python error message * Steal good ideas from #37 * Fix tests.py which didn't get copied over * Convert remaining a[] to *a * Add missing Py_DECREF * Bytes only rust (#1) * Make interface bytes only * Fix benches * Avoid newtypes for kzg types * Fix benches again * Make fields private * tidy * Address review comments * Fix one small thing in rust bindings * Use ckzg types where possible * Remove null terminator from domain bytes in rust * Update rust binding docs * Use BYTES_PER_* where applicable * Add extra check for calloc Co-authored-by: Pawan Dhananjay <pawandhananjay@gmail.com>
This package wraps the c-kzg C code in C++ NAPI bindings which allow it to be imported into a NodeJS program.
Spec: https://github.com/ethereum/consensus-specs/blob/dev/specs/eip4844/polynomial-commitments.md
Usage
Install this library with
yarn add c-kzg
Import from it like any other library
import {
KZGCommitment,
blobToKzgCommitment,
verifyAggregateKzgProof,
loadTrustedSetup,
transformTrustedSetupJSON,
} from "c-kzg";
Requirements
The C and C++ code is compiled by node-gyp on installation. Your environment will need
- A compiler like g++ or clang
make
python3
Contributing
This directory contains the code necessary to generate NodeJS bindings for C-KZG.
The bindings file has the following interface:
loadTrustedSetup: (filePath: string) => SetupHandle;
freeTrustedSetup: (setupHandle: SetupHandle) => void;
blobToKzgCommitment: (blob: Blob, setupHandle: SetupHandle) => KZGCommitment;
computeAggregateKzgProof: (
blobs: Blob[],
setupHandle: SetupHandle
) => KZGProof;
verifyAggregateKzgProof: (
blobs: Blob[],
expectedKzgCommitments: KZGCommitment[],
kzgAggregatedProof: KZGProof,
setupHandle: SetupHandle
) => boolean;
But this library wraps it in module with manages the setupHandle internally.
First,
npm install -g yarn
if you don't have it.
Install the blst submodule
git submodule update --init
Build blst and c_kzg_4844.c
cd src && make blst lib
Generate NodeJS bindings and run the TypeScript tests against them
cd ../bindings/node.js && yarn install && make test
After doing this once, you can re-build (if necessary) and re-run the tests with
make build test
After making changes, regenerate the distributable JS and type defs
make bundle