checkpoint 2

This commit is contained in:
dancoffman 2022-11-01 19:40:28 -07:00
parent 354281a9d8
commit 2846d0b470
No known key found for this signature in database
GPG Key ID: 47B1F53E36A9B3CC
6 changed files with 19 additions and 2212 deletions

View File

@ -3,8 +3,8 @@ clean:
rm -f ckzg.node
rm -f ckzg_wrap.cxx
build: ckzg.c ckzg.h
swig -javascript -node ckzg.swg
build: ckzg.cxx ckzg.h
swig -c++ -javascript -node ckzg.swg
node-gyp rebuild
cp build/Release/ckzg.node .

View File

@ -3,10 +3,11 @@
{
'target_name': 'ckzg',
'sources': [
'ckzg.cxx',
'ckzg_wrap.cxx',
'../../src/c_kzg_4844.c',
],
'include_dirs': [ '../../inc' ]
},
'include_dirs': ['../../inc', '../../src'],
'libraries': ['/Users/coffman@coinbase.com/src/c-kzg/bindings/node.js/libckzg.a'],
}
]
}

View File

@ -1,10 +1,12 @@
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include "c_kzg_4844.h"
#include "ckzg.h"
void testFunction() {}
KZGSettings* loadTrustSetup(const char* file) {
KZGSettings* out = malloc(sizeof(KZGSettings));
KZGSettings* out = (KZGSettings*)malloc(sizeof(KZGSettings));
if (out == NULL) return NULL;
@ -34,10 +36,10 @@ void blobToKzgCommitment(uint8_t out[48], const uint8_t blob[FIELD_ELEMENTS_PER_
}
int verifyAggregateKzgProof(const uint8_t blobs[], const uint8_t commitments[], size_t n, const uint8_t proof[48], const KZGSettings *s) {
Polynomial* p = calloc(n, sizeof(Polynomial));
Polynomial* p = (Polynomial*)calloc(n, sizeof(Polynomial));
if (p == NULL) return -1;
KZGCommitment* c = calloc(n, sizeof(KZGCommitment));
KZGCommitment* c = (KZGCommitment*)calloc(n, sizeof(KZGCommitment));
if (c == NULL) { free(p); return -1; }
C_KZG_RET ret;
@ -62,8 +64,8 @@ int verifyAggregateKzgProof(const uint8_t blobs[], const uint8_t commitments[],
}
C_KZG_RET computeAggregateKzgProof(uint8_t out[48], const uint8_t blobs[], size_t n, const KZGSettings *s) {
Polynomial* p = calloc(n, sizeof(Polynomial));
if (p == NULL) return -1;
Polynomial* p = (Polynomial*)calloc(n, sizeof(Polynomial));
if (p == NULL) return C_KZG_ERROR;
for (size_t i = 0; i < n; i++)
for (size_t j = 0; j < FIELD_ELEMENTS_PER_BLOB; j++)

View File

@ -3,6 +3,8 @@
#include <stdlib.h>
#include "c_kzg_4844.h"
void testFunction();
KZGSettings* loadTrustSetup(const char* file);
void freeTrustedSetup(KZGSettings *s);

File diff suppressed because it is too large Load Diff

View File

@ -6,4 +6,6 @@ const kzg = require('ckzg');
console.log(kzg);
kzg.testFunction();
console.log('Invoking function...', kzg.testFunction());
console.log('Invoking freeTrustedSetup...', kzg.freeTrustedSetup(null));