Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

kzg-wasm

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kzg-wasm - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

10

dist/browser/index.d.ts

@@ -17,8 +17,8 @@ export type TrustedSetup = {

freeTrustedSetup: () => void;
blobToKzgCommitment: (blob: Uint8Array) => Uint8Array;
computeBlobKzgProof: (blob: Uint8Array, commitment: Uint8Array) => Uint8Array;
verifyBlobKzgProofBatch: (blobs: Uint8Array[], commitments: Uint8Array[], proofs: Uint8Array[]) => boolean;
verifyKzgProof: (commitment: Uint8Array, z: Uint8Array, y: Uint8Array, proof: Uint8Array) => boolean;
verifyBlobKzgProof: (blob: Uint8Array, commitment: Uint8Array, proof: Uint8Array) => boolean;
blobToKZGCommitment: (blob: string) => string;
computeBlobKZGProof: (blob: string, commitment: string) => string;
verifyBlobKZGProofBatch: (blobs: string[], commitments: string[], proofs: string[]) => boolean;
verifyKZGProof: (commitment: string, z: string, y: string, proof: string) => boolean;
verifyBlobKZGProof: (blob: string, commitment: string, proof: string) => boolean;
}>;
//# sourceMappingURL=index.d.ts.map

@@ -15,6 +15,6 @@ import { hexToBytes } from './util.js';

const freeTrustedSetup = module.cwrap('free_trusted_setup_wasm', null, []);
const blobToKzgCommitmentWasm = module.cwrap('blob_to_kzg_commitment_wasm', 'string', ['array']);
const computeBlobKzgProofWasm = module.cwrap('compute_blob_kzg_proof_wasm', 'string', ['array', 'array']);
const verifyBlobKzgProofWasm = module.cwrap('verify_blob_kzg_proof_wasm', 'string', ['array', 'array', 'array']);
const verifyKzgProofWasm = module.cwrap('verify_kzg_proof_wasm', 'string', ['array', 'array', 'array', 'array']);
const blobToKZGCommitmentWasm = module.cwrap('blob_to_kzg_commitment_wasm', 'string', ['array']);
const computeBlobKZGProofWasm = module.cwrap('compute_blob_kzg_proof_wasm', 'string', ['array', 'array']);
const verifyBlobKZGProofWasm = module.cwrap('verify_blob_kzg_proof_wasm', 'string', ['array', 'array', 'array']);
const verifyKZGProofWasm = module.cwrap('verify_kzg_proof_wasm', 'string', ['array', 'array', 'array', 'array']);
/**

@@ -30,18 +30,18 @@ *

*
* @param blob - a blob of data formatted as a flattened Uint8Array of 4096 big endian KZG field elements
* @returns a KZG commitment corresponding to the input blob formatted as a 48 byte Uint8Array
* @param blob - a blob of data formatted as prefixed hex string containing 4096 big endian KZG field elements
* @returns a KZG commitment corresponding to the input blob formatted as a 48 byte prefixed hex string
*/
const blobToKzgCommitment = (blob) => {
const blobHex = '0x' + blobToKzgCommitmentWasm(blob);
return hexToBytes(blobHex);
const blobToKZGCommitment = (blob) => {
const blobHex = '0x' + blobToKZGCommitmentWasm(hexToBytes(blob));
return blobHex;
};
/**
*
* @param blob - a blob of data formatted as a flattened Uint8Array of 4096 big endian KZG field elements
* @param commitment - a KZG commitment corresponding to a blob formatted as a 48 byte Uint8Array
* @returns a 48 byte KZG proof corresponding to the blob and KZG commitment
* @param blob - a blob of data formatted as a flattened prefixed hex string of 4096 big endian KZG field elements
* @param commitment - a KZG commitment corresponding to a blob formatted as a 48 byte prefixed hex string
* @returns a 48 byte KZG proof as prefixed hex string corresponding to the blob and KZG commitment
*/
const computeBlobKzgProof = (blob, commitment) => {
const proofHex = '0x' + computeBlobKzgProofWasm(blob, commitment);
return hexToBytes(proofHex);
const computeBlobKZGProof = (blob, commitment) => {
const proofHex = '0x' + computeBlobKZGProofWasm(hexToBytes(blob), hexToBytes(commitment));
return proofHex;
};

@@ -53,5 +53,5 @@ /**

* @param proofs - an array of corresponding KZG proofs
* @returns returns true if all proofs are verified against their blobs and commitments; false otherise
* @returns returns true if all proofs are verified against their blobs and commitments; false otherwise
*/
const verifyBlobKzgProofBatch = (blobs, commitments, proofs) => {
const verifyBlobKZGProofBatch = (blobs, commitments, proofs) => {
if (blobs.length !== commitments.length && commitments.length !== proofs.length) {

@@ -61,3 +61,3 @@ throw new Error('number of blobs, commitments, and proofs, must match');

for (let x = 0; x < blobs.length; x++) {
const res = verifyBlobKzgProofWasm(blobs[x], commitments[x], proofs[x]);
const res = verifyBlobKZGProofWasm(hexToBytes(blobs[x]), hexToBytes(commitments[x]), hexToBytes(proofs[x]));
if (res !== 'true')

@@ -70,9 +70,9 @@ return false;

*
* @param blob - a blob of data formatted as a flattened Uint8Array of 4096 big endian KZG field elements
* @param commitment - a 48 byte KZG commitment corresponding to the blob
* @param proof - a 48 byte KZG proof corresponding to the blob and commitment
* @param blob - a blob of data formatted as a flattened prefixed hex string of 4096 big endian KZG field elements
* @param commitment - a 48 byte KZG commitment corresponding to the blob formatted as a prefixed hex string
* @param proof - a 48 byte KZG proof corresponding to the blob and commitment formatted as a prefixed hex string
* @returns true if proof is verified; false otherwise
*/
const verifyBlobKzgProof = (blob, commitment, proof) => {
const res = verifyBlobKzgProofWasm(blob, commitment, proof);
const verifyBlobKZGProof = (blob, commitment, proof) => {
const res = verifyBlobKZGProofWasm(hexToBytes(blob), hexToBytes(commitment), hexToBytes(proof));
return res === 'true';

@@ -88,4 +88,4 @@ };

*/
const verifyKzgProof = (commitment, z, y, proof) => {
const res = verifyKzgProofWasm(commitment, z, y, proof);
const verifyKZGProof = (commitment, z, y, proof) => {
const res = verifyKZGProofWasm(hexToBytes(commitment), hexToBytes(z), hexToBytes(y), hexToBytes(proof));
return res === 'true';

@@ -95,5 +95,5 @@ };

return {
loadTrustedSetup, freeTrustedSetup, blobToKzgCommitment, computeBlobKzgProof, verifyBlobKzgProofBatch, verifyKzgProof, verifyBlobKzgProof
loadTrustedSetup, freeTrustedSetup, blobToKZGCommitment, computeBlobKZGProof, verifyBlobKZGProofBatch, verifyKZGProof, verifyBlobKZGProof
};
};
//# sourceMappingURL=index.js.map

@@ -17,8 +17,8 @@ export type TrustedSetup = {

freeTrustedSetup: () => void;
blobToKzgCommitment: (blob: Uint8Array) => Uint8Array;
computeBlobKzgProof: (blob: Uint8Array, commitment: Uint8Array) => Uint8Array;
verifyBlobKzgProofBatch: (blobs: Uint8Array[], commitments: Uint8Array[], proofs: Uint8Array[]) => boolean;
verifyKzgProof: (commitment: Uint8Array, z: Uint8Array, y: Uint8Array, proof: Uint8Array) => boolean;
verifyBlobKzgProof: (blob: Uint8Array, commitment: Uint8Array, proof: Uint8Array) => boolean;
blobToKZGCommitment: (blob: string) => string;
computeBlobKZGProof: (blob: string, commitment: string) => string;
verifyBlobKZGProofBatch: (blobs: string[], commitments: string[], proofs: string[]) => boolean;
verifyKZGProof: (commitment: string, z: string, y: string, proof: string) => boolean;
verifyBlobKZGProof: (blob: string, commitment: string, proof: string) => boolean;
}>;
//# sourceMappingURL=index.d.ts.map

@@ -18,6 +18,6 @@ "use strict";

const freeTrustedSetup = module.cwrap('free_trusted_setup_wasm', null, []);
const blobToKzgCommitmentWasm = module.cwrap('blob_to_kzg_commitment_wasm', 'string', ['array']);
const computeBlobKzgProofWasm = module.cwrap('compute_blob_kzg_proof_wasm', 'string', ['array', 'array']);
const verifyBlobKzgProofWasm = module.cwrap('verify_blob_kzg_proof_wasm', 'string', ['array', 'array', 'array']);
const verifyKzgProofWasm = module.cwrap('verify_kzg_proof_wasm', 'string', ['array', 'array', 'array', 'array']);
const blobToKZGCommitmentWasm = module.cwrap('blob_to_kzg_commitment_wasm', 'string', ['array']);
const computeBlobKZGProofWasm = module.cwrap('compute_blob_kzg_proof_wasm', 'string', ['array', 'array']);
const verifyBlobKZGProofWasm = module.cwrap('verify_blob_kzg_proof_wasm', 'string', ['array', 'array', 'array']);
const verifyKZGProofWasm = module.cwrap('verify_kzg_proof_wasm', 'string', ['array', 'array', 'array', 'array']);
/**

@@ -33,18 +33,18 @@ *

*
* @param blob - a blob of data formatted as a flattened Uint8Array of 4096 big endian KZG field elements
* @returns a KZG commitment corresponding to the input blob formatted as a 48 byte Uint8Array
* @param blob - a blob of data formatted as prefixed hex string containing 4096 big endian KZG field elements
* @returns a KZG commitment corresponding to the input blob formatted as a 48 byte prefixed hex string
*/
const blobToKzgCommitment = (blob) => {
const blobHex = '0x' + blobToKzgCommitmentWasm(blob);
return (0, util_js_1.hexToBytes)(blobHex);
const blobToKZGCommitment = (blob) => {
const blobHex = '0x' + blobToKZGCommitmentWasm((0, util_js_1.hexToBytes)(blob));
return blobHex;
};
/**
*
* @param blob - a blob of data formatted as a flattened Uint8Array of 4096 big endian KZG field elements
* @param commitment - a KZG commitment corresponding to a blob formatted as a 48 byte Uint8Array
* @returns a 48 byte KZG proof corresponding to the blob and KZG commitment
* @param blob - a blob of data formatted as a flattened prefixed hex string of 4096 big endian KZG field elements
* @param commitment - a KZG commitment corresponding to a blob formatted as a 48 byte prefixed hex string
* @returns a 48 byte KZG proof as prefixed hex string corresponding to the blob and KZG commitment
*/
const computeBlobKzgProof = (blob, commitment) => {
const proofHex = '0x' + computeBlobKzgProofWasm(blob, commitment);
return (0, util_js_1.hexToBytes)(proofHex);
const computeBlobKZGProof = (blob, commitment) => {
const proofHex = '0x' + computeBlobKZGProofWasm((0, util_js_1.hexToBytes)(blob), (0, util_js_1.hexToBytes)(commitment));
return proofHex;
};

@@ -56,5 +56,5 @@ /**

* @param proofs - an array of corresponding KZG proofs
* @returns returns true if all proofs are verified against their blobs and commitments; false otherise
* @returns returns true if all proofs are verified against their blobs and commitments; false otherwise
*/
const verifyBlobKzgProofBatch = (blobs, commitments, proofs) => {
const verifyBlobKZGProofBatch = (blobs, commitments, proofs) => {
if (blobs.length !== commitments.length && commitments.length !== proofs.length) {

@@ -64,3 +64,3 @@ throw new Error('number of blobs, commitments, and proofs, must match');

for (let x = 0; x < blobs.length; x++) {
const res = verifyBlobKzgProofWasm(blobs[x], commitments[x], proofs[x]);
const res = verifyBlobKZGProofWasm((0, util_js_1.hexToBytes)(blobs[x]), (0, util_js_1.hexToBytes)(commitments[x]), (0, util_js_1.hexToBytes)(proofs[x]));
if (res !== 'true')

@@ -73,9 +73,9 @@ return false;

*
* @param blob - a blob of data formatted as a flattened Uint8Array of 4096 big endian KZG field elements
* @param commitment - a 48 byte KZG commitment corresponding to the blob
* @param proof - a 48 byte KZG proof corresponding to the blob and commitment
* @param blob - a blob of data formatted as a flattened prefixed hex string of 4096 big endian KZG field elements
* @param commitment - a 48 byte KZG commitment corresponding to the blob formatted as a prefixed hex string
* @param proof - a 48 byte KZG proof corresponding to the blob and commitment formatted as a prefixed hex string
* @returns true if proof is verified; false otherwise
*/
const verifyBlobKzgProof = (blob, commitment, proof) => {
const res = verifyBlobKzgProofWasm(blob, commitment, proof);
const verifyBlobKZGProof = (blob, commitment, proof) => {
const res = verifyBlobKZGProofWasm((0, util_js_1.hexToBytes)(blob), (0, util_js_1.hexToBytes)(commitment), (0, util_js_1.hexToBytes)(proof));
return res === 'true';

@@ -91,4 +91,4 @@ };

*/
const verifyKzgProof = (commitment, z, y, proof) => {
const res = verifyKzgProofWasm(commitment, z, y, proof);
const verifyKZGProof = (commitment, z, y, proof) => {
const res = verifyKZGProofWasm((0, util_js_1.hexToBytes)(commitment), (0, util_js_1.hexToBytes)(z), (0, util_js_1.hexToBytes)(y), (0, util_js_1.hexToBytes)(proof));
return res === 'true';

@@ -98,3 +98,3 @@ };

return {
loadTrustedSetup, freeTrustedSetup, blobToKzgCommitment, computeBlobKzgProof, verifyBlobKzgProofBatch, verifyKzgProof, verifyBlobKzgProof
loadTrustedSetup, freeTrustedSetup, blobToKZGCommitment, computeBlobKZGProof, verifyBlobKZGProofBatch, verifyKZGProof, verifyBlobKZGProof
};

@@ -101,0 +101,0 @@ };

@@ -17,8 +17,8 @@ export type TrustedSetup = {

freeTrustedSetup: () => void;
blobToKzgCommitment: (blob: Uint8Array) => Uint8Array;
computeBlobKzgProof: (blob: Uint8Array, commitment: Uint8Array) => Uint8Array;
verifyBlobKzgProofBatch: (blobs: Uint8Array[], commitments: Uint8Array[], proofs: Uint8Array[]) => boolean;
verifyKzgProof: (commitment: Uint8Array, z: Uint8Array, y: Uint8Array, proof: Uint8Array) => boolean;
verifyBlobKzgProof: (blob: Uint8Array, commitment: Uint8Array, proof: Uint8Array) => boolean;
blobToKZGCommitment: (blob: string) => string;
computeBlobKZGProof: (blob: string, commitment: string) => string;
verifyBlobKZGProofBatch: (blobs: string[], commitments: string[], proofs: string[]) => boolean;
verifyKZGProof: (commitment: string, z: string, y: string, proof: string) => boolean;
verifyBlobKZGProof: (blob: string, commitment: string, proof: string) => boolean;
}>;
//# sourceMappingURL=index.d.ts.map

@@ -15,6 +15,6 @@ import { hexToBytes } from './util.js';

const freeTrustedSetup = module.cwrap('free_trusted_setup_wasm', null, []);
const blobToKzgCommitmentWasm = module.cwrap('blob_to_kzg_commitment_wasm', 'string', ['array']);
const computeBlobKzgProofWasm = module.cwrap('compute_blob_kzg_proof_wasm', 'string', ['array', 'array']);
const verifyBlobKzgProofWasm = module.cwrap('verify_blob_kzg_proof_wasm', 'string', ['array', 'array', 'array']);
const verifyKzgProofWasm = module.cwrap('verify_kzg_proof_wasm', 'string', ['array', 'array', 'array', 'array']);
const blobToKZGCommitmentWasm = module.cwrap('blob_to_kzg_commitment_wasm', 'string', ['array']);
const computeBlobKZGProofWasm = module.cwrap('compute_blob_kzg_proof_wasm', 'string', ['array', 'array']);
const verifyBlobKZGProofWasm = module.cwrap('verify_blob_kzg_proof_wasm', 'string', ['array', 'array', 'array']);
const verifyKZGProofWasm = module.cwrap('verify_kzg_proof_wasm', 'string', ['array', 'array', 'array', 'array']);
/**

@@ -30,18 +30,18 @@ *

*
* @param blob - a blob of data formatted as a flattened Uint8Array of 4096 big endian KZG field elements
* @returns a KZG commitment corresponding to the input blob formatted as a 48 byte Uint8Array
* @param blob - a blob of data formatted as prefixed hex string containing 4096 big endian KZG field elements
* @returns a KZG commitment corresponding to the input blob formatted as a 48 byte prefixed hex string
*/
const blobToKzgCommitment = (blob) => {
const blobHex = '0x' + blobToKzgCommitmentWasm(blob);
return hexToBytes(blobHex);
const blobToKZGCommitment = (blob) => {
const blobHex = '0x' + blobToKZGCommitmentWasm(hexToBytes(blob));
return blobHex;
};
/**
*
* @param blob - a blob of data formatted as a flattened Uint8Array of 4096 big endian KZG field elements
* @param commitment - a KZG commitment corresponding to a blob formatted as a 48 byte Uint8Array
* @returns a 48 byte KZG proof corresponding to the blob and KZG commitment
* @param blob - a blob of data formatted as a flattened prefixed hex string of 4096 big endian KZG field elements
* @param commitment - a KZG commitment corresponding to a blob formatted as a 48 byte prefixed hex string
* @returns a 48 byte KZG proof as prefixed hex string corresponding to the blob and KZG commitment
*/
const computeBlobKzgProof = (blob, commitment) => {
const proofHex = '0x' + computeBlobKzgProofWasm(blob, commitment);
return hexToBytes(proofHex);
const computeBlobKZGProof = (blob, commitment) => {
const proofHex = '0x' + computeBlobKZGProofWasm(hexToBytes(blob), hexToBytes(commitment));
return proofHex;
};

@@ -53,5 +53,5 @@ /**

* @param proofs - an array of corresponding KZG proofs
* @returns returns true if all proofs are verified against their blobs and commitments; false otherise
* @returns returns true if all proofs are verified against their blobs and commitments; false otherwise
*/
const verifyBlobKzgProofBatch = (blobs, commitments, proofs) => {
const verifyBlobKZGProofBatch = (blobs, commitments, proofs) => {
if (blobs.length !== commitments.length && commitments.length !== proofs.length) {

@@ -61,3 +61,3 @@ throw new Error('number of blobs, commitments, and proofs, must match');

for (let x = 0; x < blobs.length; x++) {
const res = verifyBlobKzgProofWasm(blobs[x], commitments[x], proofs[x]);
const res = verifyBlobKZGProofWasm(hexToBytes(blobs[x]), hexToBytes(commitments[x]), hexToBytes(proofs[x]));
if (res !== 'true')

@@ -70,9 +70,9 @@ return false;

*
* @param blob - a blob of data formatted as a flattened Uint8Array of 4096 big endian KZG field elements
* @param commitment - a 48 byte KZG commitment corresponding to the blob
* @param proof - a 48 byte KZG proof corresponding to the blob and commitment
* @param blob - a blob of data formatted as a flattened prefixed hex string of 4096 big endian KZG field elements
* @param commitment - a 48 byte KZG commitment corresponding to the blob formatted as a prefixed hex string
* @param proof - a 48 byte KZG proof corresponding to the blob and commitment formatted as a prefixed hex string
* @returns true if proof is verified; false otherwise
*/
const verifyBlobKzgProof = (blob, commitment, proof) => {
const res = verifyBlobKzgProofWasm(blob, commitment, proof);
const verifyBlobKZGProof = (blob, commitment, proof) => {
const res = verifyBlobKZGProofWasm(hexToBytes(blob), hexToBytes(commitment), hexToBytes(proof));
return res === 'true';

@@ -88,4 +88,4 @@ };

*/
const verifyKzgProof = (commitment, z, y, proof) => {
const res = verifyKzgProofWasm(commitment, z, y, proof);
const verifyKZGProof = (commitment, z, y, proof) => {
const res = verifyKZGProofWasm(hexToBytes(commitment), hexToBytes(z), hexToBytes(y), hexToBytes(proof));
return res === 'true';

@@ -95,5 +95,5 @@ };

return {
loadTrustedSetup, freeTrustedSetup, blobToKzgCommitment, computeBlobKzgProof, verifyBlobKzgProofBatch, verifyKzgProof, verifyBlobKzgProof
loadTrustedSetup, freeTrustedSetup, blobToKZGCommitment, computeBlobKZGProof, verifyBlobKZGProofBatch, verifyKZGProof, verifyBlobKZGProof
};
};
//# sourceMappingURL=index.js.map
{
"name": "kzg-wasm",
"version": "0.4.0",
"version": "0.5.0",
"description": "a WASM compilation of c-kzg-4844",

@@ -5,0 +5,0 @@ "scripts": {

@@ -9,3 +9,3 @@ # KZG-WASM

This module exposes a single export, an async function called `loadKZG` which loads and compiles the WASM object, loads a trusted setup (defaults to the official setup from the KZG ceremony) and returns an object that exposes the API defined in the `KZG` type interface in [`@ethereum/util`](https://github.com/ethereumjs/ethereumjs-monorepo/blob/e1221c98f3be0ba4224416f10d91ed4aa50130d8/packages/util/src/kzg.ts#L4)
This module exposes a single export, an async function called `loadKZG` which loads and compiles the WASM object, loads a trusted setup (defaults to the official setup from the KZG ceremony) and returns an object that exposes the API defined in the `KZG` type interface in `@ethereum/util`

@@ -12,0 +12,0 @@ To use with the `@ethereumjs` libraries, do the following:

@@ -22,6 +22,6 @@ import { hexToBytes } from './util.js'

const freeTrustedSetup = module.cwrap('free_trusted_setup_wasm', null, []) as () => void
const blobToKzgCommitmentWasm = module.cwrap('blob_to_kzg_commitment_wasm', 'string', ['array']) as (blob: Uint8Array) => string
const computeBlobKzgProofWasm = module.cwrap('compute_blob_kzg_proof_wasm', 'string', ['array', 'array']) as (blob: Uint8Array, commitment: Uint8Array) => string
const verifyBlobKzgProofWasm = module.cwrap('verify_blob_kzg_proof_wasm', 'string', ['array', 'array', 'array']) as (blob: Uint8Array, commitment: Uint8Array, proof: Uint8Array) => string
const verifyKzgProofWasm = module.cwrap('verify_kzg_proof_wasm', 'string', ['array', 'array', 'array', 'array'])
const blobToKZGCommitmentWasm = module.cwrap('blob_to_kzg_commitment_wasm', 'string', ['array']) as (blob: Uint8Array) => string
const computeBlobKZGProofWasm = module.cwrap('compute_blob_kzg_proof_wasm', 'string', ['array', 'array']) as (blob: Uint8Array, commitment: Uint8Array) => string
const verifyBlobKZGProofWasm = module.cwrap('verify_blob_kzg_proof_wasm', 'string', ['array', 'array', 'array']) as (blob: Uint8Array, commitment: Uint8Array, proof: Uint8Array) => string
const verifyKZGProofWasm = module.cwrap('verify_kzg_proof_wasm', 'string', ['array', 'array', 'array', 'array']) as (commitment: Uint8Array, z: Uint8Array, y: Uint8Array, proof: Uint8Array) => string

@@ -39,8 +39,8 @@ /**

*
* @param blob - a blob of data formatted as a flattened Uint8Array of 4096 big endian KZG field elements
* @returns a KZG commitment corresponding to the input blob formatted as a 48 byte Uint8Array
* @param blob - a blob of data formatted as prefixed hex string containing 4096 big endian KZG field elements
* @returns a KZG commitment corresponding to the input blob formatted as a 48 byte prefixed hex string
*/
const blobToKzgCommitment = (blob: Uint8Array) => {
const blobHex = '0x' + blobToKzgCommitmentWasm(blob)
return hexToBytes(blobHex)
const blobToKZGCommitment = (blob: string) => {
const blobHex = '0x' + blobToKZGCommitmentWasm(hexToBytes(blob))
return blobHex
}

@@ -50,9 +50,9 @@

*
* @param blob - a blob of data formatted as a flattened Uint8Array of 4096 big endian KZG field elements
* @param commitment - a KZG commitment corresponding to a blob formatted as a 48 byte Uint8Array
* @returns a 48 byte KZG proof corresponding to the blob and KZG commitment
* @param blob - a blob of data formatted as a flattened prefixed hex string of 4096 big endian KZG field elements
* @param commitment - a KZG commitment corresponding to a blob formatted as a 48 byte prefixed hex string
* @returns a 48 byte KZG proof as prefixed hex string corresponding to the blob and KZG commitment
*/
const computeBlobKzgProof = (blob: Uint8Array, commitment: Uint8Array) => {
const proofHex = '0x' + computeBlobKzgProofWasm(blob, commitment)
return hexToBytes(proofHex)
const computeBlobKZGProof = (blob: string, commitment: string) => {
const proofHex = '0x' + computeBlobKZGProofWasm(hexToBytes(blob), hexToBytes(commitment))
return proofHex
}

@@ -65,5 +65,5 @@

* @param proofs - an array of corresponding KZG proofs
* @returns returns true if all proofs are verified against their blobs and commitments; false otherise
* @returns returns true if all proofs are verified against their blobs and commitments; false otherwise
*/
const verifyBlobKzgProofBatch = (blobs: Uint8Array[], commitments: Uint8Array[], proofs: Uint8Array[]) => {
const verifyBlobKZGProofBatch = (blobs: string[], commitments: string[], proofs: string[]) => {
if (blobs.length !== commitments.length && commitments.length !== proofs.length) {

@@ -73,3 +73,3 @@ throw new Error('number of blobs, commitments, and proofs, must match')

for (let x = 0; x < blobs.length; x++) {
const res = verifyBlobKzgProofWasm(blobs[x], commitments[x], proofs[x])
const res = verifyBlobKZGProofWasm(hexToBytes(blobs[x]), hexToBytes(commitments[x]), hexToBytes(proofs[x]))
if (res !== 'true') return false

@@ -82,9 +82,9 @@ }

*
* @param blob - a blob of data formatted as a flattened Uint8Array of 4096 big endian KZG field elements
* @param commitment - a 48 byte KZG commitment corresponding to the blob
* @param proof - a 48 byte KZG proof corresponding to the blob and commitment
* @param blob - a blob of data formatted as a flattened prefixed hex string of 4096 big endian KZG field elements
* @param commitment - a 48 byte KZG commitment corresponding to the blob formatted as a prefixed hex string
* @param proof - a 48 byte KZG proof corresponding to the blob and commitment formatted as a prefixed hex string
* @returns true if proof is verified; false otherwise
*/
const verifyBlobKzgProof = (blob: Uint8Array, commitment: Uint8Array, proof: Uint8Array) => {
const res = verifyBlobKzgProofWasm(blob, commitment, proof)
const verifyBlobKZGProof = (blob: string, commitment: string, proof: string) => {
const res = verifyBlobKZGProofWasm(hexToBytes(blob), hexToBytes(commitment), hexToBytes(proof))
return res === 'true'

@@ -100,4 +100,4 @@ }

*/
const verifyKzgProof = (commitment: Uint8Array, z: Uint8Array, y: Uint8Array, proof: Uint8Array) => {
const res = verifyKzgProofWasm(commitment, z, y, proof)
const verifyKZGProof = (commitment: string, z: string, y: string, proof: string) => {
const res = verifyKZGProofWasm(hexToBytes(commitment), hexToBytes(z), hexToBytes(y), hexToBytes(proof))
return res === 'true'

@@ -109,5 +109,5 @@ }

return {
loadTrustedSetup, freeTrustedSetup, blobToKzgCommitment, computeBlobKzgProof, verifyBlobKzgProofBatch, verifyKzgProof, verifyBlobKzgProof
loadTrustedSetup, freeTrustedSetup, blobToKZGCommitment, computeBlobKZGProof, verifyBlobKZGProofBatch, verifyKZGProof, verifyBlobKZGProof
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc