trusted-setups
Easily access KZG (EIP-4844) + PeerDAS (EIP-7594) / ETH trusted setups in JS.
Exports 5 files:
small-kzg.js - 400KB KZG setup
small-peerdas.js - ~800KB KZG+PeerDAS setup
fast-kzg.js - fast ~800KB KZG setup for eth-signer
fast-peerdas.js - fast 3.1MB KZG+PeerDAS setup for eth-signer
trusted_setup.json, for c-kzg and others
Usage
npm install @paulmillr/trusted-setups
The package is located in namespace for security / anti-squatting reasons.
We test against eth-signer,
kzg-wasm and
c-kzg.
Other libraries with similar API should also work.
import { trustedSetup } from '@paulmillr/trusted-setups/small-kzg.js';
type trustedSetup = {
g1_lagrange: string[];
g2_monomial: string[];
g1_monomial: string[];
}
import { KZG } from 'micro-eth-signer/kzg';
const kzg = new KZG(trustedSetup);
const strip0x = items => items.map((i) => i.substring(2)).join('');
const g1 = strip0x(trustedSetup.g1_lagrange);
const g2 = strip0x(trustedSetup.g2_monomial);
const opts = { n1: 4096, n2: 65, g1, g2 };
const kzg = await loadKZG(opts);
const __dirname = dirname(fileURLToPath(import.meta.url));
ckzg.loadTrustedSetup(1, __dirname + '/trusted_setup.json');
trustedSetup.g1_lagrange.slice(0, 2)
trustedSetup.g2_monomial.slice(0, 2)
Verification
npm install && npm run build will build files from trusted_setup.txt, which was copied from
c-kzg-4844.
Its checksum is d39b9f2d047cc9dca2de58f264b6a09448ccd34db967881a6713eacacf0f26b7.
License
MIT License
Copyright (c) 2024 Paul Miller (https://paulmillr.com)