c-kzg-4844/bindings/node.js/README.md

58 lines
1.1 KiB
Markdown
Raw Normal View History

2022-11-03 22:13:49 +00:00
This directory contains the code necessary to generate NodeJS bindings for C-KZG.
2022-11-04 06:44:08 +00:00
```js
2022-11-03 22:13:49 +00:00
2022-11-04 06:44:08 +00:00
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;
2022-11-03 22:13:49 +00:00
```
2022-11-04 06:44:08 +00:00
Spec: https://github.com/ethereum/consensus-specs/blob/dev/specs/eip4844/polynomial-commitments.md
2022-11-04 07:13:02 +00:00
First,
2022-11-04 06:44:08 +00:00
`npm install -g yarn` if you don't have it.
Install the blst submodule
```sh
git submodule update --init
2022-11-03 22:13:49 +00:00
```
2022-11-04 06:44:08 +00:00
Build blst and c_kzg_4844.c
2022-11-03 22:13:49 +00:00
```
2022-11-04 06:44:08 +00:00
cd src && make blst lib
2022-11-03 22:13:49 +00:00
```
2022-11-04 06:44:08 +00:00
Generate NodeJS bindings and run the TypeScript tests against them
2022-11-03 22:13:49 +00:00
2022-11-04 06:44:08 +00:00
```sh
cd ../bindings/node.js && yarn install && make test
2022-11-03 22:13:49 +00:00
```
2022-11-04 06:44:08 +00:00
After doing this once, you can re-build (if necessary) and re-run the tests with
```sh
make build test
2022-11-03 22:13:49 +00:00
```
2022-11-04 07:13:02 +00:00
After making changes, regenerate the distributable JS and type defs
```sh
make bundle
```