import * as CoreEngine from '../core/Engine.js' import type * as Errors from '../core/Errors.js' import * as Ed25519 from './Ed25519.js' import * as Hash from './Hash.js' import * as keystore from './internal/keystore.js' import * as MlDsa44 from './MlDsa44.js' import * as Mnemonic from './Mnemonic.js' import * as Secp256k1 from './Secp256k1.js' import * as X25519 from './X25519.js' import type * as internal from './internal/instantiate.js' export { AsyncScopeError, get, InvalidSlotValueError, reset, set, UnknownPrimitiveError, UnknownSlotError, with, } from '../core/Engine.js' export type { Bls, Ecdh, Ecdsa, Eddsa, Engine, Hash, HashState, Keystore, MlDsa, Mnemonic, } from '../core/Engine.js' /** * Compiles and installs every WASM implementation this entrypoint provides. * * Slot compilation starts concurrently. Nothing is installed until every slot * resolves successfully. * * Call this once, during startup, before any crypto call. Ox resolves the * engine at call time, so values computed beforehand used whatever was * installed then. * * @example * ```ts twoslash * // @noErrors * import { Engine, Hash } from 'ox/wasm' * * await Engine.install() * * Hash.sha256('0xdeadbeef') * ``` * * @returns The engine that was installed. */ export async function install(): Promise { return CoreEngine.install({ Ed25519: Ed25519.engine(), Hash: Hash.engine(), Keystore: keystore.engine(), MlDsa44: MlDsa44.engine(), Mnemonic: Mnemonic.engine(), Secp256k1: Secp256k1.engine(), X25519: X25519.engine(), }) } export declare namespace install { type ReturnType = engine.ReturnType type ErrorType = | engine.ErrorType | CoreEngine.install.ErrorType | Errors.GlobalErrorType } /** * Compiles every WASM implementation this entrypoint provides, without * installing it. * * Reach for this where an engine has to exist as a value, such as a benchmark * or an [`Engine.with`](/api/Engine/with) scope. Use the individual module's * `engine` function to select only some slots. * * @example * ```ts twoslash * // @noErrors * import { Engine, Hash } from 'ox' * import { Engine as Wasm } from 'ox/wasm' * * const wasm = await Wasm.engine() * * Engine.with(wasm, () => Hash.sha256('0xdeadbeef')) * ``` * * @returns An engine, ready to install. */ export async function engine(): Promise { const [ed25519, hash, keystoreEngine, mlDsa44, mnemonic, secp256k1, x25519] = await Promise.all([ Ed25519.engine(), Hash.engine(), keystore.engine(), MlDsa44.engine(), Mnemonic.engine(), Secp256k1.engine(), X25519.engine(), ]) return { Ed25519: ed25519, Hash: hash, Keystore: keystoreEngine, MlDsa44: mlDsa44, Mnemonic: mnemonic, Secp256k1: secp256k1, X25519: x25519, } } export declare namespace engine { /** Every slot this entrypoint supplies, each with its primitives present. */ type ReturnType = { Ed25519: Ed25519.engine.ReturnType Hash: Hash.engine.ReturnType Keystore: { pbkdf2Sha256: NonNullable } MlDsa44: MlDsa44.engine.ReturnType Mnemonic: Mnemonic.engine.ReturnType Secp256k1: Secp256k1.engine.ReturnType X25519: X25519.engine.ReturnType } type ErrorType = internal.MemoryError | Errors.GlobalErrorType }