Generate bindings using SWIG and node-gyp
This commit is contained in:
parent
a581964b11
commit
6ec86af547
|
@ -1 +1,3 @@
|
|||
build
|
||||
ckzg.node
|
||||
ckzg_wrap.cxx
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
clean:
|
||||
rm -rf build
|
||||
rm -f ckzg.node
|
||||
rm -f ckzg_wrap.cxx
|
||||
|
||||
build: ../../src/c_kzg_4844.c
|
||||
swig -c++ -javascript -node ckzg.swg
|
||||
node-gyp rebuild
|
||||
cp build/Release/ckzg.node .
|
||||
|
||||
test:
|
||||
env NODE_PATH=.: node runnable.js
|
|
@ -1,8 +1,9 @@
|
|||
{
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'c-kzg',
|
||||
'target_name': 'ckzg',
|
||||
'sources': [
|
||||
'ckzg_wrap.cxx',
|
||||
'../../src/c_kzg_4844.c',
|
||||
],
|
||||
'include_dirs': [ '../../inc' ],
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/* File : ckzg.swg */
|
||||
%module ckzg
|
||||
|
||||
%{
|
||||
#include "../../src/c_kzg_4844.h"
|
||||
%}
|
||||
|
||||
extern C_KZG_RET load_trusted_setup(KZGSettings *out,
|
||||
FILE *in);
|
||||
|
||||
extern void free_trusted_setup(
|
||||
KZGSettings *s);
|
||||
|
||||
extern C_KZG_RET compute_aggregate_kzg_proof(KZGProof *out,
|
||||
const Polynomial blobs[],
|
||||
size_t n,
|
||||
const KZGSettings *s);
|
||||
|
||||
extern C_KZG_RET verify_aggregate_kzg_proof(bool *out,
|
||||
const Polynomial blobs[],
|
||||
const KZGCommitment expected_kzg_commitments[],
|
||||
size_t n,
|
||||
const KZGProof *kzg_aggregated_proof,
|
||||
const KZGSettings *s);
|
||||
|
||||
extern void blob_to_kzg_commitment(KZGCommitment *out,
|
||||
const BLSFieldElement blob[FIELD_ELEMENTS_PER_BLOB],
|
||||
const KZGSettings *s);
|
||||
|
||||
extern C_KZG_RET verify_kzg_proof(bool *out,
|
||||
const KZGCommitment *polynomial_kzg,
|
||||
const BLSFieldElement *z,
|
||||
const BLSFieldElement *y,
|
||||
const KZGProof *kzg_proof,
|
||||
const KZGSettings *s);
|
|
@ -0,0 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
console.log('testing...');
|
||||
|
||||
const blst = require('ckzg');
|
||||
|
||||
console.log(blst);
|
|
@ -904,7 +904,7 @@ static void g1_lincomb(g1_t *out, const g1_t *p, const fr_t *coeffs, const uint6
|
|||
}
|
||||
}
|
||||
|
||||
void blob_to_kzg_commitment(KZGCommitment *out, const Polynomial blob, const KZGSettings *s) {
|
||||
void blob_to_kzg_commitment(KZGCommitment *out, const BLSFieldElement blob[FIELD_ELEMENTS_PER_BLOB], const KZGSettings *s) {
|
||||
g1_lincomb(out, s->g1_values, blob, FIELD_ELEMENTS_PER_BLOB);
|
||||
}
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ C_KZG_RET verify_aggregate_kzg_proof(bool *out,
|
|||
const KZGSettings *s);
|
||||
|
||||
void blob_to_kzg_commitment(KZGCommitment *out,
|
||||
const Polynomial blob,
|
||||
const BLSFieldElement blob[FIELD_ELEMENTS_PER_BLOB],
|
||||
const KZGSettings *s);
|
||||
|
||||
C_KZG_RET verify_kzg_proof(bool *out,
|
||||
|
|
Loading…
Reference in New Issue