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.0.1 to 0.1.0

.babelrc

6

dist/cjs/index.d.ts

@@ -1,2 +0,6 @@

export declare const initKzg: () => Promise<{
/**
* Initialization function that instantiates WASM code and returns an object matching the `KZG` interface exposed by `@ethereumjs/util`
* @returns object - the KZG methods required for all 4844 related operations
*/
export declare const createKZG: () => Promise<{
loadTrustedSetup: any;

@@ -3,0 +7,0 @@ freeTrustedSetup: any;

10

dist/cjs/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.initKzg = void 0;
exports.createKZG = void 0;
const util_js_1 = require("./util.js");
const kzg_js_1 = require("./wasm/kzg.js");
const initKzg = async () => {
/**
* Initialization function that instantiates WASM code and returns an object matching the `KZG` interface exposed by `@ethereumjs/util`
* @returns object - the KZG methods required for all 4844 related operations
*/
const createKZG = async () => {
const module = await (0, kzg_js_1.default)();

@@ -45,3 +49,3 @@ const loadTrustedSetup = module.cwrap('load_trusted_setup_file_from_wasm', null, []);

};
exports.initKzg = initKzg;
exports.createKZG = createKZG;
//# sourceMappingURL=index.js.map
export default kzg;
declare function kzg(moduleArg?: {}, ...args: any[]): Promise<any>;
declare function kzg(moduleArg?: {}): Promise<any>;
//# sourceMappingURL=kzg.d.ts.map

@@ -1,2 +0,6 @@

export declare const initKzg: () => Promise<{
/**
* Initialization function that instantiates WASM code and returns an object matching the `KZG` interface exposed by `@ethereumjs/util`
* @returns object - the KZG methods required for all 4844 related operations
*/
export declare const createKZG: () => Promise<{
loadTrustedSetup: any;

@@ -3,0 +7,0 @@ freeTrustedSetup: any;

import { hexToBytes } from './util.js';
import kzgWasm from './wasm/kzg.js';
export const initKzg = async () => {
/**
* Initialization function that instantiates WASM code and returns an object matching the `KZG` interface exposed by `@ethereumjs/util`
* @returns object - the KZG methods required for all 4844 related operations
*/
export const createKZG = async () => {
const module = await kzgWasm();

@@ -5,0 +9,0 @@ const loadTrustedSetup = module.cwrap('load_trusted_setup_file_from_wasm', null, []);

export default kzg;
declare function kzg(moduleArg?: {}, ...args: any[]): Promise<any>;
declare function kzg(moduleArg?: {}): Promise<any>;
//# sourceMappingURL=kzg.d.ts.map
{
"name": "kzg-wasm",
"version": "0.0.1",
"version": "0.1.0",
"description": "",
"scripts": {
"build": "scripts/ts-build.sh",
"build": "npm run build:ts && npm run transpileCJS && npm run fixRequire",
"build:ts": "scripts/ts-build.sh",
"transpileCJS": "rm dist/cjs/wasm/kzg.js && babel src/wasm/kzg.js -d dist/cjs/wasm",
"fixRequire": "sed -i.bak \"s/\\_require('url')/require('url')/g\" dist/cjs/wasm/kzg.js && rm dist/cjs/wasm/kzg.js.bak",
"clean": "rm -rf dist && rm -rf node_modules",

@@ -24,4 +27,8 @@ "test": "vitest run test/*",

"devDependencies": {
"@vitest/browser": "^1.2.2",
"@vitest/utils": "^1.2.2",
"@babel/cli": "^7.23.9",
"@babel/core": "^7.23.9",
"@babel/preset-env": "^7.23.9",
"@vitest/browser": "^1.3.1",
"@vitest/utils": "^1.3.1",
"babel-plugin-transform-import-meta": "^2.2.1",
"prettier": "^3.2.5",

@@ -31,7 +38,6 @@ "tsx": "^4.7.1",

"vite-plugin-node-polyfills": "^0.21.0",
"vite-plugin-top-level-await": "^1.4.1",
"vite-plugin-wasm": "^3.3.0",
"vitest": "^1.2.2",
"webdriverio": "^8.31.1"
"vitest": "^1.3.1",
"webdriverio": "^8.32.3"
}
}

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

This module exposes a single export, an async function called `initKzg` which loads and compiles the WASM object 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 `createKZG` which loads and compiles the WASM object 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)

@@ -15,3 +15,3 @@ To use with the `@ethereumjs` libraries, do the following:

```ts
import { initKzg } from 'kzg-wasm'
import { createKZG } from 'kzg-wasm'
import { Common, Chain, Hardfork } from '@ethereumjs/common'

@@ -21,3 +21,3 @@ import { initKZG } from '@ethereumjs/util'

const main = async () => {
const kzg = await initKzg()
const kzg = await createKZG()
initKZG(kzg, '')

@@ -24,0 +24,0 @@ const common = new Common({

import { hexToBytes } from './util.js'
import kzgWasm from './wasm/kzg.js'
export const initKzg = async () => {
/**
* Initialization function that instantiates WASM code and returns an object matching the `KZG` interface exposed by `@ethereumjs/util`
* @returns object - the KZG methods required for all 4844 related operations
*/
export const createKZG = async () => {
const module = await kzgWasm()

@@ -6,0 +10,0 @@

import { describe, it, assert, beforeEach } from 'vitest'
import { initKzg } from '../src/index.js'
import { createKZG } from '../src/index.js'
import { bytesToHex, hexToBytes } from '../src/util.js'

@@ -11,3 +11,3 @@

it('should initialize', async () => {
const kzg = await initKzg()
const kzg = await createKZG()
const res = kzg.loadTrustedSetup()

@@ -19,3 +19,3 @@ assert.equal(res, 0, 'loaded trusted setup')

it('should generate kzg commitments and verify proofs', async () => {
const kzg = await initKzg()
const kzg = await createKZG()
kzg.loadTrustedSetup()

@@ -34,3 +34,3 @@ const blob = new Uint8Array(BYTES_PER_BLOB)

it('should verify kzg proofs with points', async () => {
const kzg = await initKzg()
const kzg = await createKZG()
kzg.loadTrustedSetup()

@@ -37,0 +37,0 @@

import { defineConfig } from 'vitest/config'
import wasm from 'vite-plugin-wasm'
import topLevelAwait from 'vite-plugin-top-level-await'
import { nodePolyfills } from 'vite-plugin-node-polyfills'

@@ -23,3 +22,2 @@

}),
topLevelAwait(),
wasm()

@@ -26,0 +24,0 @@ ],

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 too big to display

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 too big to display

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 too big to display

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