Socket
Socket
Sign inDemoInstall

@ethereumjs/util

Package Overview
Dependencies
Maintainers
4
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ethereumjs/util - npm Package Compare versions

Comparing version 9.0.2 to 9.0.3

5

dist/cjs/blobs.d.ts

@@ -0,4 +1,5 @@

import type { Kzg } from './kzg.js';
export declare const getBlobs: (input: string) => Uint8Array[];
export declare const blobsToCommitments: (blobs: Uint8Array[]) => Uint8Array[];
export declare const blobsToProofs: (blobs: Uint8Array[], commitments: Uint8Array[]) => Uint8Array[];
export declare const blobsToCommitments: (kzg: Kzg, blobs: Uint8Array[]) => Uint8Array[];
export declare const blobsToProofs: (kzg: Kzg, blobs: Uint8Array[], commitments: Uint8Array[]) => Uint8Array[];
/**

@@ -5,0 +6,0 @@ * Converts a vector commitment for a given data blob to its versioned hash. For 4844, this version

9

dist/cjs/blobs.js

@@ -6,3 +6,2 @@ "use strict";

const bytes_js_1 = require("./bytes.js");
const kzg_js_1 = require("./kzg.js");
/**

@@ -52,6 +51,6 @@ * These utilities for constructing blobs are borrowed from https://github.com/Inphi/eip4844-interop.git

exports.getBlobs = getBlobs;
const blobsToCommitments = (blobs) => {
const blobsToCommitments = (kzg, blobs) => {
const commitments = [];
for (const blob of blobs) {
commitments.push(kzg_js_1.kzg.blobToKzgCommitment(blob));
commitments.push(kzg.blobToKzgCommitment(blob));
}

@@ -61,4 +60,4 @@ return commitments;

exports.blobsToCommitments = blobsToCommitments;
const blobsToProofs = (blobs, commitments) => {
const proofs = blobs.map((blob, ctx) => kzg_js_1.kzg.computeBlobKzgProof(blob, commitments[ctx]));
const blobsToProofs = (kzg, blobs, commitments) => {
const proofs = blobs.map((blob, ctx) => kzg.computeBlobKzgProof(blob, commitments[ctx]));
return proofs;

@@ -65,0 +64,0 @@ };

@@ -147,2 +147,12 @@ import { bytesToHex as _bytesToUnprefixedHex } from 'ethereum-cryptography/utils.js';

/**
* Calculates max bigint from an array of bigints
* @param args array of bigints
*/
export declare const bigIntMax: (...args: bigint[]) => bigint;
/**
* Calculates min BigInt from an array of BigInts
* @param args array of bigints
*/
export declare const bigIntMin: (...args: bigint[]) => bigint;
/**
* Convert value from bigint to an unpadded Uint8Array

@@ -149,0 +159,0 @@ * (useful for RLP transport)

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.utf8ToBytes = exports.equalsBytes = exports.bytesToUtf8 = exports.bigInt64ToBytes = exports.int32ToBytes = exports.bytesToBigInt64 = exports.bytesToInt32 = exports.concatBytes = exports.randomBytes = exports.compareBytes = exports.intToUnpaddedBytes = exports.bigIntToUnpaddedBytes = exports.bigIntToHex = exports.validateNoLeadingZeroes = exports.short = exports.addHexPrefix = exports.toUnsigned = exports.fromSigned = exports.toBytes = exports.unpadHex = exports.unpadArray = exports.unpadBytes = exports.setLengthRight = exports.setLengthLeft = exports.zeros = exports.bigIntToBytes = exports.intToBytes = exports.intToHex = exports.hexToBytes = exports.bytesToInt = exports.bytesToBigInt = exports.bytesToHex = exports.unprefixedHexToBytes = exports.bytesToUnprefixedHex = void 0;
exports.utf8ToBytes = exports.equalsBytes = exports.bytesToUtf8 = exports.bigInt64ToBytes = exports.int32ToBytes = exports.bytesToBigInt64 = exports.bytesToInt32 = exports.concatBytes = exports.randomBytes = exports.compareBytes = exports.intToUnpaddedBytes = exports.bigIntToUnpaddedBytes = exports.bigIntMin = exports.bigIntMax = exports.bigIntToHex = exports.validateNoLeadingZeroes = exports.short = exports.addHexPrefix = exports.toUnsigned = exports.fromSigned = exports.toBytes = exports.unpadHex = exports.unpadArray = exports.unpadBytes = exports.setLengthRight = exports.setLengthLeft = exports.zeros = exports.bigIntToBytes = exports.intToBytes = exports.intToHex = exports.hexToBytes = exports.bytesToInt = exports.bytesToBigInt = exports.bytesToHex = exports.unprefixedHexToBytes = exports.bytesToUnprefixedHex = void 0;
const random_js_1 = require("ethereum-cryptography/random.js");

@@ -372,2 +372,14 @@ // eslint-disable-next-line no-restricted-imports

/**
* Calculates max bigint from an array of bigints
* @param args array of bigints
*/
const bigIntMax = (...args) => args.reduce((m, e) => (e > m ? e : m));
exports.bigIntMax = bigIntMax;
/**
* Calculates min BigInt from an array of BigInts
* @param args array of bigints
*/
const bigIntMin = (...args) => args.reduce((m, e) => (e < m ? e : m));
exports.bigIntMin = bigIntMin;
/**
* Convert value from bigint to an unpadded Uint8Array

@@ -374,0 +386,0 @@ * (useful for RLP transport)

@@ -5,3 +5,8 @@ /**

export interface Kzg {
loadTrustedSetup(filePath: string): void;
loadTrustedSetup(trustedSetup?: {
g1: string;
g2: string;
n1: number;
n2: number;
}): void;
blobToKzgCommitment(blob: Uint8Array): Uint8Array;

@@ -12,8 +17,10 @@ computeBlobKzgProof(blob: Uint8Array, commitment: Uint8Array): Uint8Array;

}
export declare let kzg: Kzg;
/**
* @deprecated This initialization method is deprecated since trusted setup loading is done directly in the reference KZG library
* initialization or should othewise be assured independently before KZG libary usage.
*
* @param kzgLib a KZG implementation (defaults to c-kzg)
* @param trustedSetupPath the full path (e.g. "/home/linux/devnet4.txt") to a kzg trusted setup text file
* @param a dictionary of trusted setup options
*/
export declare function initKZG(kzgLib: Kzg, trustedSetupPath: string): void;
export declare function initKZG(kzg: Kzg, _trustedSetupPath?: string): void;
//# sourceMappingURL=kzg.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.initKZG = exports.kzg = void 0;
function kzgNotLoaded() {
throw Error('kzg library not loaded');
}
// eslint-disable-next-line import/no-mutable-exports
exports.kzg = {
loadTrustedSetup: kzgNotLoaded,
blobToKzgCommitment: kzgNotLoaded,
computeBlobKzgProof: kzgNotLoaded,
verifyKzgProof: kzgNotLoaded,
verifyBlobKzgProofBatch: kzgNotLoaded,
};
exports.initKZG = void 0;
/**
* @deprecated This initialization method is deprecated since trusted setup loading is done directly in the reference KZG library
* initialization or should othewise be assured independently before KZG libary usage.
*
* @param kzgLib a KZG implementation (defaults to c-kzg)
* @param trustedSetupPath the full path (e.g. "/home/linux/devnet4.txt") to a kzg trusted setup text file
* @param a dictionary of trusted setup options
*/
function initKZG(kzgLib, trustedSetupPath) {
exports.kzg = kzgLib;
exports.kzg.loadTrustedSetup(trustedSetupPath);
function initKZG(kzg, _trustedSetupPath) {
kzg.loadTrustedSetup();
}
exports.initKZG = initKZG;
//# sourceMappingURL=kzg.js.map

@@ -0,4 +1,5 @@

import type { Kzg } from './kzg.js';
export declare const getBlobs: (input: string) => Uint8Array[];
export declare const blobsToCommitments: (blobs: Uint8Array[]) => Uint8Array[];
export declare const blobsToProofs: (blobs: Uint8Array[], commitments: Uint8Array[]) => Uint8Array[];
export declare const blobsToCommitments: (kzg: Kzg, blobs: Uint8Array[]) => Uint8Array[];
export declare const blobsToProofs: (kzg: Kzg, blobs: Uint8Array[], commitments: Uint8Array[]) => Uint8Array[];
/**

@@ -5,0 +6,0 @@ * Converts a vector commitment for a given data blob to its versioned hash. For 4844, this version

import { sha256 } from 'ethereum-cryptography/sha256.js';
import { utf8ToBytes } from './bytes.js';
import { kzg } from './kzg.js';
/**

@@ -47,3 +46,3 @@ * These utilities for constructing blobs are borrowed from https://github.com/Inphi/eip4844-interop.git

};
export const blobsToCommitments = (blobs) => {
export const blobsToCommitments = (kzg, blobs) => {
const commitments = [];

@@ -55,3 +54,3 @@ for (const blob of blobs) {

};
export const blobsToProofs = (blobs, commitments) => {
export const blobsToProofs = (kzg, blobs, commitments) => {
const proofs = blobs.map((blob, ctx) => kzg.computeBlobKzgProof(blob, commitments[ctx]));

@@ -58,0 +57,0 @@ return proofs;

@@ -147,2 +147,12 @@ import { bytesToHex as _bytesToUnprefixedHex } from 'ethereum-cryptography/utils.js';

/**
* Calculates max bigint from an array of bigints
* @param args array of bigints
*/
export declare const bigIntMax: (...args: bigint[]) => bigint;
/**
* Calculates min BigInt from an array of BigInts
* @param args array of bigints
*/
export declare const bigIntMin: (...args: bigint[]) => bigint;
/**
* Convert value from bigint to an unpadded Uint8Array

@@ -149,0 +159,0 @@ * (useful for RLP transport)

@@ -348,2 +348,12 @@ import { getRandomBytesSync } from 'ethereum-cryptography/random.js';

/**
* Calculates max bigint from an array of bigints
* @param args array of bigints
*/
export const bigIntMax = (...args) => args.reduce((m, e) => (e > m ? e : m));
/**
* Calculates min BigInt from an array of BigInts
* @param args array of bigints
*/
export const bigIntMin = (...args) => args.reduce((m, e) => (e < m ? e : m));
/**
* Convert value from bigint to an unpadded Uint8Array

@@ -350,0 +360,0 @@ * (useful for RLP transport)

@@ -5,3 +5,8 @@ /**

export interface Kzg {
loadTrustedSetup(filePath: string): void;
loadTrustedSetup(trustedSetup?: {
g1: string;
g2: string;
n1: number;
n2: number;
}): void;
blobToKzgCommitment(blob: Uint8Array): Uint8Array;

@@ -12,8 +17,10 @@ computeBlobKzgProof(blob: Uint8Array, commitment: Uint8Array): Uint8Array;

}
export declare let kzg: Kzg;
/**
* @deprecated This initialization method is deprecated since trusted setup loading is done directly in the reference KZG library
* initialization or should othewise be assured independently before KZG libary usage.
*
* @param kzgLib a KZG implementation (defaults to c-kzg)
* @param trustedSetupPath the full path (e.g. "/home/linux/devnet4.txt") to a kzg trusted setup text file
* @param a dictionary of trusted setup options
*/
export declare function initKZG(kzgLib: Kzg, trustedSetupPath: string): void;
export declare function initKZG(kzg: Kzg, _trustedSetupPath?: string): void;
//# sourceMappingURL=kzg.d.ts.map

@@ -1,20 +0,11 @@

function kzgNotLoaded() {
throw Error('kzg library not loaded');
}
// eslint-disable-next-line import/no-mutable-exports
export let kzg = {
loadTrustedSetup: kzgNotLoaded,
blobToKzgCommitment: kzgNotLoaded,
computeBlobKzgProof: kzgNotLoaded,
verifyKzgProof: kzgNotLoaded,
verifyBlobKzgProofBatch: kzgNotLoaded,
};
/**
* @deprecated This initialization method is deprecated since trusted setup loading is done directly in the reference KZG library
* initialization or should othewise be assured independently before KZG libary usage.
*
* @param kzgLib a KZG implementation (defaults to c-kzg)
* @param trustedSetupPath the full path (e.g. "/home/linux/devnet4.txt") to a kzg trusted setup text file
* @param a dictionary of trusted setup options
*/
export function initKZG(kzgLib, trustedSetupPath) {
kzg = kzgLib;
kzg.loadTrustedSetup(trustedSetupPath);
export function initKZG(kzg, _trustedSetupPath) {
kzg.loadTrustedSetup();
}
//# sourceMappingURL=kzg.js.map
{
"name": "@ethereumjs/util",
"version": "9.0.2",
"version": "9.0.3",
"description": "A collection of utility functions for Ethereum",

@@ -97,11 +97,5 @@ "keywords": [

},
"devDependencies": {},
"peerDependencies": {
"c-kzg": "^2.1.2"
"devDependencies": {
"kzg-wasm": "^0.3.1"
},
"peerDependenciesMeta": {
"c-kzg": {
"optional": true
}
},
"engines": {

@@ -108,0 +102,0 @@ "node": ">=18"

import { sha256 } from 'ethereum-cryptography/sha256.js'
import { utf8ToBytes } from './bytes.js'
import { kzg } from './kzg.js'
import type { Kzg } from './kzg.js'
/**

@@ -58,3 +59,3 @@ * These utilities for constructing blobs are borrowed from https://github.com/Inphi/eip4844-interop.git

export const blobsToCommitments = (blobs: Uint8Array[]) => {
export const blobsToCommitments = (kzg: Kzg, blobs: Uint8Array[]) => {
const commitments: Uint8Array[] = []

@@ -67,3 +68,3 @@ for (const blob of blobs) {

export const blobsToProofs = (blobs: Uint8Array[], commitments: Uint8Array[]) => {
export const blobsToProofs = (kzg: Kzg, blobs: Uint8Array[], commitments: Uint8Array[]) => {
const proofs = blobs.map((blob, ctx) => kzg.computeBlobKzgProof(blob, commitments[ctx]))

@@ -70,0 +71,0 @@

@@ -406,2 +406,14 @@ import { getRandomBytesSync } from 'ethereum-cryptography/random.js'

/**
* Calculates max bigint from an array of bigints
* @param args array of bigints
*/
export const bigIntMax = (...args: bigint[]) => args.reduce((m, e) => (e > m ? e : m))
/**
* Calculates min BigInt from an array of BigInts
* @param args array of bigints
*/
export const bigIntMin = (...args: bigint[]) => args.reduce((m, e) => (e < m ? e : m))
/**
* Convert value from bigint to an unpadded Uint8Array

@@ -408,0 +420,0 @@ * (useful for RLP transport)

@@ -5,3 +5,8 @@ /**

export interface Kzg {
loadTrustedSetup(filePath: string): void
loadTrustedSetup(trustedSetup?: {
g1: string // unprefixed hex string
g2: string // unprefixed hex string
n1: number // bytes per element
n2: number // 65
}): void
blobToKzgCommitment(blob: Uint8Array): Uint8Array

@@ -22,22 +27,11 @@ computeBlobKzgProof(blob: Uint8Array, commitment: Uint8Array): Uint8Array

function kzgNotLoaded(): never {
throw Error('kzg library not loaded')
}
// eslint-disable-next-line import/no-mutable-exports
export let kzg: Kzg = {
loadTrustedSetup: kzgNotLoaded,
blobToKzgCommitment: kzgNotLoaded,
computeBlobKzgProof: kzgNotLoaded,
verifyKzgProof: kzgNotLoaded,
verifyBlobKzgProofBatch: kzgNotLoaded,
}
/**
* @deprecated This initialization method is deprecated since trusted setup loading is done directly in the reference KZG library
* initialization or should othewise be assured independently before KZG libary usage.
*
* @param kzgLib a KZG implementation (defaults to c-kzg)
* @param trustedSetupPath the full path (e.g. "/home/linux/devnet4.txt") to a kzg trusted setup text file
* @param a dictionary of trusted setup options
*/
export function initKZG(kzgLib: Kzg, trustedSetupPath: string) {
kzg = kzgLib
kzg.loadTrustedSetup(trustedSetupPath)
export function initKZG(kzg: Kzg, _trustedSetupPath?: string) {
kzg.loadTrustedSetup()
}

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

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

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