diff --git a/bindings/node.js/kzg.cxx b/bindings/node.js/kzg.cxx index fc2f1b8..52f1563 100644 --- a/bindings/node.js/kzg.cxx +++ b/bindings/node.js/kzg.cxx @@ -135,7 +135,7 @@ Napi::Value BlobToKzgCommitment(const Napi::CallbackInfo& info) { Polynomial polynomial; for (size_t i = 0; i < FIELD_ELEMENTS_PER_BLOB; i++) - bytes_to_bls_field(&polynomial[i], &blob[i * BYTES_PER_FIELD]); + bytes_to_bls_field(&polynomial[i], &blob[i * BYTES_PER_FIELD_ELEMENT]); KZGCommitment commitment; blob_to_kzg_commitment(&commitment, polynomial, kzg_settings); @@ -168,7 +168,7 @@ Napi::Value ComputeAggregateKzgProof(const Napi::CallbackInfo& info) { for (size_t field_index = 0; field_index < FIELD_ELEMENTS_PER_BLOB; field_index++) { bytes_to_bls_field( &polynomial[blob_index][field_index], - &blob_bytes[field_index * BYTES_PER_FIELD] + &blob_bytes[field_index * BYTES_PER_FIELD_ELEMENT] ); } } @@ -222,7 +222,7 @@ Napi::Value VerifyAggregateKzgProof(const Napi::CallbackInfo& info) { // Populate the polynomial with a BLS field for each field element in the blob for (size_t field_index = 0; field_index < FIELD_ELEMENTS_PER_BLOB; field_index++) { - bytes_to_bls_field(&polynomial[blob_index][field_index], &blob_bytes[field_index * BYTES_PER_FIELD]); + bytes_to_bls_field(&polynomial[blob_index][field_index], &blob_bytes[field_index * BYTES_PER_FIELD_ELEMENT]); } // Extract a G1 point for each commitment @@ -358,7 +358,7 @@ Napi::Object Init(Napi::Env env, Napi::Object exports) { // Constants exports["FIELD_ELEMENTS_PER_BLOB"] = Napi::Number::New(env, FIELD_ELEMENTS_PER_BLOB); - exports["BYTES_PER_FIELD"] = Napi::Number::New(env, BYTES_PER_FIELD); + exports["BYTES_PER_FIELD_ELEMENT"] = Napi::Number::New(env, BYTES_PER_FIELD_ELEMENT); return exports; } diff --git a/bindings/node.js/kzg.ts b/bindings/node.js/kzg.ts index 4597730..9ec3c76 100644 --- a/bindings/node.js/kzg.ts +++ b/bindings/node.js/kzg.ts @@ -14,7 +14,7 @@ type SetupHandle = Object; // The C++ native addon interface type KZG = { FIELD_ELEMENTS_PER_BLOB: number; - BYTES_PER_FIELD: number; + BYTES_PER_FIELD_ELEMENT: number; loadTrustedSetup: (filePath: string) => SetupHandle; @@ -45,7 +45,7 @@ type KZG = { }; export const FIELD_ELEMENTS_PER_BLOB = kzg.FIELD_ELEMENTS_PER_BLOB; -export const BYTES_PER_FIELD = kzg.BYTES_PER_FIELD; +export const BYTES_PER_FIELD_ELEMENT = kzg.BYTES_PER_FIELD_ELEMENT; // Stored as internal state let setupHandle: SetupHandle | undefined; diff --git a/bindings/node.js/test.ts b/bindings/node.js/test.ts index e504ca2..0b61441 100644 --- a/bindings/node.js/test.ts +++ b/bindings/node.js/test.ts @@ -5,12 +5,12 @@ import { blobToKzgCommitment, computeAggregateKzgProof, verifyAggregateKzgProof, - BYTES_PER_FIELD, + BYTES_PER_FIELD_ELEMENT, FIELD_ELEMENTS_PER_BLOB, } from "./kzg"; const SETUP_FILE_PATH = "../../src/trusted_setup.txt"; -const BLOB_BYTE_COUNT = FIELD_ELEMENTS_PER_BLOB * BYTES_PER_FIELD; +const BLOB_BYTE_COUNT = FIELD_ELEMENTS_PER_BLOB * BYTES_PER_FIELD_ELEMENT; const generateRandomBlob = () => new Uint8Array(randomBytes(BLOB_BYTE_COUNT)); diff --git a/inc/.gitignore b/inc/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/src/c_kzg_4844.h b/src/c_kzg_4844.h index 4de5249..45aecea 100644 --- a/src/c_kzg_4844.h +++ b/src/c_kzg_4844.h @@ -36,7 +36,6 @@ extern "C" { #define BYTES_PER_COMMITMENT 48 #define BYTES_PER_PROOF 48 -#define BYTES_PER_FIELD 32 #define FIELD_ELEMENTS_PER_BLOB 4096 #define BYTES_PER_FIELD_ELEMENT 32 static const uint8_t FIAT_SHAMIR_PROTOCOL_DOMAIN[] = {70, 83, 66, 76, 79, 66, 86, 69, 82, 73, 70, 89, 95, 86, 49, 95}; // "FSBLOBVERIFY_V1_"