![New axobject-query Maintainer Faces Backlash Over Controversial Decision to Support Legacy Node.js Versions](https://cdn.sanity.io/images/cgdhsj6q/production/86e6ebdea652d20da070ebbda20134b839972db7-1024x1024.webp?w=800&fit=max&auto=format)
Security News
New axobject-query Maintainer Faces Backlash Over Controversial Decision to Support Legacy Node.js Versions
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.
c-kzg
Advanced tools
Readme
This is a TypeScript library for EIP-4844 that implements the Polynomial
Commitments
API. The core functionality was originally a stripped-down copy of
C-KZG, but has been heavily modified
since then. This package wraps that native c-kzg
C code in C/C++ NAPI
bindings for use in node.js applications.
Spec: https://github.com/ethereum/consensus-specs/blob/dev/specs/eip4844/polynomial-commitments.md
Installation requires compilation of C code. Target environment must have:
yarn add c-kzg
# or
npm i -S c-kzg
import {
BYTES_PER_BLOB,
Blob,
Bytes48,
blobToKzgCommitment,
computeBlobKzgProof,
verifyBlobKzgProofBatch,
} from "c-kzg";
const blobs = [] as Blob[];
const commitments = [] as Bytes48[];
const proofs = [] as Bytes48[];
for (let i = 0; i < BATCH_SIZE; i++) {
blobs.push(Buffer.alloc(BYTES_PER_BLOB, "*"));
commitments.push(blobToKzgCommitment(blobs[i]));
proofs.push(computeBlobKzgProof(blobs[i], commitments[i]));
}
const isValid = verifyBlobKzgProofBatch(blobs, commitments, proofs);
loadTrustedSetup
/**
* Sets up the c-kzg library. Pass in a properly formatted trusted setup file
* to configure the library. File must be in json format, see TrustedSetupJson
* interface for more details, or as a properly formatted utf-8 encoded file.
*
* @remark This function must be run before any other functions in this
* library can be run.
*
* @param {string} filePath - The absolute path of the trusted setup
*/
loadTrustedSetup(filePath: string): void;
blobToKzgCommitment
/**
* Convert a blob to a KZG commitment.
*
* @param {Blob} blob - The blob representing the polynomial to be committed to
*/
blobToKzgCommitment(blob: Blob): KZGCommitment;
computeKzgProof
/**
* Compute KZG proof for polynomial in Lagrange form at position z.
*
* @param {Blob} blob - The blob (polynomial) to generate a proof for
* @param {Bytes32} zBytes - The generator z-value for the evaluation points
*
* @return {ProofResult} - Tuple containing the resulting proof and evaluation
* of the polynomial at the evaluation point z
*/
computeKzgProof(blob: Blob, zBytes: Bytes32): ProofResult;
computeBlobKzgProof
/**
* Given a blob, return the KZG proof that is used to verify it against the
* commitment.
*
* @param {Blob} blob - The blob (polynomial) to generate a proof for
* @param {Bytes48} commitmentBytes - Commitment to verify
*/
computeBlobKzgProof(
blob: Blob,
commitmentBytes: Bytes48,
): KZGProof;
verifyKzgProof
/**
* Verify a KZG poof claiming that `p(z) == y`.
*
* @param {Bytes48} commitmentBytes - The serialized commitment corresponding to
* polynomial p(x)
* @param {Bytes32} zBytes - The serialized evaluation point
* @param {Bytes32} yBytes - The serialized claimed evaluation result
* @param {Bytes48} proofBytes - The serialized KZG proof
*/
verifyKzgProof(
commitmentBytes: Bytes48,
zBytes: Bytes32,
yBytes: Bytes32,
proofBytes: Bytes48,
): boolean;
verifyBlobKzgProof
/**
* Given a blob and its proof, verify that it corresponds to the provided
* commitment.
*
* @param {Blob} blob - The serialized blob to verify
* @param {Bytes48} commitmentBytes - The serialized commitment to verify
* @param {Bytes48} proofBytes - The serialized KZG proof for verification
*/
verifyBlobKzgProof(
blob: Blob,
commitmentBytes: Bytes48,
proofBytes: Bytes48,
): boolean;
verifyBlobKzgProofBatch
/**
* Given an array of blobs and their proofs, verify that they corresponds to
* their provided commitment.
*
* Note: blobs[0] relates to commitmentBytes[0] and proofBytes[0]
*
* @param {Blob} blobs - An array of serialized blobs to verify
* @param {Bytes48} commitmentBytes - An array of serialized commitments to
* verify
* @param {Bytes48} proofBytes - An array of serialized KZG proofs for
* verification
*/
verifyBlobKzgProofBatch(
blobs: Blob[],
commitmentsBytes: Bytes48[],
proofsBytes: Bytes48[],
): boolean;
FAQs
NodeJS bindings for C-KZG
The npm package c-kzg receives a total of 637 weekly downloads. As such, c-kzg popularity was classified as not popular.
We found that c-kzg demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.
Security News
Results from the 2023 State of JavaScript Survey highlight key trends, including Vite's dominance, rising TypeScript adoption, and the enduring popularity of React. Discover more insights on developer preferences and technology usage.
Security News
The US Justice Department has penalized two consulting firms $11.3 million for failing to meet cybersecurity requirements on federally funded projects, emphasizing strict enforcement to protect sensitive government data.