Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NodeJS bindings #1

Closed
wants to merge 44 commits into from
Closed
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
a581964
Working node-gyp
dgcoffman Nov 1, 2022
6ec86af
Generate bindings using SWIG and node-gyp
dgcoffman Nov 1, 2022
354281a
Checkpoint
dgcoffman Nov 2, 2022
2846d0b
checkpoint 2
dgcoffman Nov 2, 2022
2030336
I learned about extern C
dgcoffman Nov 2, 2022
002fc3f
Tweaks
dgcoffman Nov 2, 2022
fdcab9d
Install node-gyp with yarn
dgcoffman Nov 2, 2022
40db00f
Add napi version
dgcoffman Nov 2, 2022
b169d4a
Remove SWIG
dgcoffman Nov 2, 2022
d478234
Revert changes that were only to make SWIG work
dgcoffman Nov 2, 2022
726fd38
Revert unnecessary platform-specific makefile change
dgcoffman Nov 2, 2022
ac17623
TypeScript test
dgcoffman Nov 2, 2022
da8d5dd
Try to test VerifyKzgProof (does not work)
dgcoffman Nov 2, 2022
dbf2a1d
Plausibly working BlobToKzgCommitment
dgcoffman Nov 3, 2022
fcd7fbd
Checkpoint
dgcoffman Nov 3, 2022
a5ca064
Some cleanup
dgcoffman Nov 3, 2022
672346f
Closer to working
dgcoffman Nov 3, 2022
b8151db
Cleanup
dgcoffman Nov 3, 2022
1514d5b
computeAggregateKzgProof + verifyAggregateKzgProof test passes
dgcoffman Nov 3, 2022
4bfce9a
Test verifyKzgProof
dgcoffman Nov 3, 2022
3201111
Actually return the result of verify_kzg_proof
dgcoffman Nov 3, 2022
ab04cdd
Add a test for mismatch
dgcoffman Nov 4, 2022
05fd880
Run all the tests
dgcoffman Nov 4, 2022
0a99015
Attempt more consistency. Remove test for verifyKzgProof which is not…
dgcoffman Nov 4, 2022
83bed36
Add return types
dgcoffman Nov 4, 2022
bbc90b7
Use rollup to product distributable JS file
dgcoffman Nov 4, 2022
7668c4f
Generate type defs
dgcoffman Nov 4, 2022
b031251
Do not run prettier on dist
dgcoffman Nov 4, 2022
b661552
Always make, never package.json scripts
dgcoffman Nov 4, 2022
c3d11f9
build is a dep of test
dgcoffman Nov 4, 2022
3f66b35
Fix type
dgcoffman Nov 4, 2022
92242c7
Have gyp copy the .node file
dgcoffman Nov 4, 2022
e90e485
Add blst as submodule
dgcoffman Nov 4, 2022
a29b158
Make task for blst
dgcoffman Nov 4, 2022
09d8405
nodejs binding make build should do less
dgcoffman Nov 4, 2022
be0f51b
make blst now works
dgcoffman Nov 4, 2022
46fb7cc
Update README
dgcoffman Nov 4, 2022
f819fe1
Patch blst submodule sha
dgcoffman Nov 4, 2022
82c89e1
Add gypfile to package.json
dgcoffman Nov 4, 2022
8ca4fd9
Merge branch '4844_3038' into dgcoffman/nodejs-bindings
dgcoffman Nov 4, 2022
ac65930
Use BYTES_PER_FIELD_ELEMENT
dgcoffman Nov 4, 2022
062e4e0
Simplify, given updated API
dgcoffman Nov 4, 2022
1d20797
Regen dist
dgcoffman Nov 4, 2022
84bd55b
Be better at TypeScript
dgcoffman Nov 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ doc/
inc/blst.h*
inc/blst_aux.h*
.vscode/
*.json
.clang-format
*bindings/*/*.so
*bindings/csharp/*.exe
Expand Down
3 changes: 3 additions & 0 deletions bindings/node.js/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build
*.node
node_modules
2 changes: 2 additions & 0 deletions bindings/node.js/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ignore artifacts:
build
8 changes: 8 additions & 0 deletions bindings/node.js/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"overrides": [
{
"files": "binding.gyp",
"options": { "parser": "json" }
}
]
}
11 changes: 11 additions & 0 deletions bindings/node.js/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
clean:
yarn clean
rm -rf build
rm -f *.node
rm -f *.a
rm -f *.o

build: kzg.cxx Makefile
cd ../../src; make lib
yarn build
cp build/Release/kzg.node .
19 changes: 19 additions & 0 deletions bindings/node.js/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
This directory contains the code necessary to generate NodeJS bindings for C-KZG.

First, install:

```
yarn install
```

Then build

```
make build
```

Run the TypeScript tests

```
yarn test
```
6 changes: 6 additions & 0 deletions bindings/node.js/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
presets: [
["@babel/preset-env", { targets: { node: "current" } }],
"@babel/preset-typescript",
],
};
27 changes: 27 additions & 0 deletions bindings/node.js/binding.gyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"targets": [
{
"target_name": "kzg",
dgcoffman marked this conversation as resolved.
Show resolved Hide resolved
"cflags!": ["-fno-exceptions"],
"cflags_cc!": ["-fno-exceptions"],
"xcode_settings": {
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
"CLANG_CXX_LIBRARY": "libc++",
"MACOSX_DEPLOYMENT_TARGET": "13.0"
},
"sources": ["kzg.cxx"],
"include_dirs": [
"../../inc",
"../../src",
"<!@(node -p \"require('node-addon-api').include\")"
],
"libraries": [
"<(module_root_dir)/c_kzg_4844.o",
"<(module_root_dir)/sha256.o",
"<(module_root_dir)/../../lib/libblst.a"
],
"dependencies": ["<!(node -p \"require('node-addon-api').gyp\")"],
"defines": ["NAPI_DISABLE_CPP_EXCEPTIONS"]
}
]
}
5 changes: 5 additions & 0 deletions bindings/node.js/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
};
Loading