import * as Bytes from '../core/Bytes.js'; import * as Errors from '../core/Errors.js'; import type * as CoreKzg from '../core/Kzg.js'; export * from '../core/Kzg.js'; /** * Trusted setup points accepted by `create`. * * Point arrays use the established Ethereum trusted-setup field names. Each * field may also be supplied as one packed byte array. */ export type TrustedSetup = { /** 4,096 G1 points in Lagrange form. */ readonly g1_lagrange: Bytes.Bytes | readonly string[]; /** 4,096 G1 points in monomial form. */ readonly g1_monomial: Bytes.Bytes | readonly string[]; /** 65 G2 points in monomial form. */ readonly g2_monomial: Bytes.Bytes | readonly string[]; }; /** * Creates an independently owned WASM implementation of [`Kzg.Kzg`](/api/Kzg). * * The factory compiles the c-kzg artifact once per JavaScript realm. Every call * instantiates separate WASM memory and trusted-setup state. Call `dispose` when * the instance is no longer needed. * * Operations on an instance are synchronous and run to completion. JavaScript * workers do not share an instance, so create one in each worker that needs KZG. * * @example * ```ts twoslash * // @noErrors * import { Setups } from 'ox/trusted-setups' * import { Kzg } from 'ox/wasm' * * const kzg = await Kzg.create({ * trustedSetup: Setups.mainnet * }) * // Pass `kzg` anywhere that accepts `Kzg.Kzg`. * * kzg.dispose() * ``` * * @param options - Trusted setup and precomputation options. * @returns An initialized KZG implementation with explicit disposal. */ export declare function create(options: create.Options): Promise; export declare namespace create { /** Options for `create`. */ type Options = { /** * Fixed-base MSM window from 0 through 8. * * `0` performs no fixed-base precomputation and uses the least memory. * Larger values improve proof generation at an exponential memory cost. * * @default 0 */ precompute?: number | undefined; /** Ethereum trusted-setup points. */ trustedSetup: TrustedSetup; }; /** An initialized KZG implementation with explicit lifecycle ownership. */ type ReturnType = CoreKzg.Kzg & { /** * Releases the trusted setup and makes every operation throw. * * Disposal is idempotent. */ dispose(): void; }; type ErrorType = DisposedError | InvalidInputError | InvalidPrecomputeError | InvalidTrustedSetupError | MemoryError | WasmError | Errors.GlobalErrorType; } /** Thrown when an operation is called after its KZG instance was disposed. */ export declare class DisposedError extends Errors.BaseError { readonly name = "Kzg.DisposedError"; constructor(); } /** Thrown when a KZG operation receives malformed input. */ export declare class InvalidInputError extends Errors.BaseError { readonly name = "Kzg.InvalidInputError"; constructor({ message }: { message: string; }); } /** Thrown when `precompute` is outside the supported memory bound. */ export declare class InvalidPrecomputeError extends Errors.BaseError { readonly name = "Kzg.InvalidPrecomputeError"; constructor({ precompute }: { precompute: number; }); } /** Thrown when c-kzg rejects the trusted setup. */ export declare class InvalidTrustedSetupError extends Errors.BaseError { readonly name = "Kzg.InvalidTrustedSetupError"; constructor(options?: { message?: string | undefined; }); } /** Thrown when the KZG artifact reaches its 128 MiB memory limit. */ export declare class MemoryError extends Errors.BaseError { readonly name = "Kzg.MemoryError"; constructor(); } /** Thrown when the KZG artifact traps or reports an internal error. */ export declare class WasmError extends Errors.BaseError { readonly name = "Kzg.WasmError"; constructor(options?: { cause?: Error | undefined; operation?: string | undefined; }); } //# sourceMappingURL=Kzg.d.ts.map