import { loadNetwork as loadNetwork$1 } from '@provablehq/sdk/dynamic.js'; export { DEVNODE_ADDR, DEVNODE_PRIVATE_KEY } from '@provablehq/veil-aleo-devnode'; import { GenerateFreezelistProofParameters, LocalAccount, RecordProvider, StandaloneRecordScanner, RecordManagementConfig, PublicClient, WalletClient } from '@provablehq/veil-core'; import { P as ProvableSession, a as ProvableKeyedAuth, b as ProvingConfigWithSession, c as ProvableCredentialStore, d as ProvableWalletClient } from './provableApi-BTVe8yl5.js'; export { A as AuthenticateProvableApiParameters, e as AuthenticateProvableApiReturnType, C as CreateProvableSessionOptions, f as ProvableApiActions, g as ProvableApiCredentials, h as ProvableJwt, i as ProvableSessionConsumers, R as RegisterProvableApiParameters, j as authenticateProvableApi, k as createProvableSession, m as memoryCredentialStore, p as provableApiActions, r as registerProvableApi } from './provableApi-BTVe8yl5.js'; import '@provablehq/sdk'; /** * Names the derivation-path convention used to turn a seed into Aleo keys. * * `'standard'` uses the SLIP-0044-registered Aleo coin type (`m/44'/683'`); * `'legacy'` uses the pre-registration path (`m/44'/0'`) some older wallets * chose. Pick `'legacy'` only to recover accounts created by such a wallet. */ type AleoDerivationId = 'standard' | 'legacy'; /** SLIP-0044 registered Aleo coin type. */ declare const STANDARD_PATH = "m/44'/683'"; /** Pre-SLIP-0044-registration derivation path. Some older wallets used this. */ declare const LEGACY_PATH = "m/44'/0'"; /** * Hierarchical-deterministic key node for the BLS12-377 curve Aleo uses. * * Follows the SLIP-0010 construction (HMAC-SHA512 chains, hardened-only * derivation) with an Aleo-specific master key tag, matching shield-core. * All operations are pure and local — nothing touches the network. Start * from {@link BLS12377HDKey.fromMasterSeed} (or {@link mnemonicToHDKey}) * rather than the constructor; the 32-byte `key` of a derived node is the * seed for an Aleo private key. */ declare class BLS12377HDKey { readonly key: Uint8Array; readonly chainCode: Uint8Array; /** * Wraps raw node material. Callers normally use * {@link BLS12377HDKey.fromMasterSeed} instead of constructing directly. * * @param key 32-byte private key material of this node. * @param chainCode 32-byte chain code used to derive children. */ constructor(key: Uint8Array, chainCode: Uint8Array); /** * Derives the master node from a BIP-39 seed. Pure and local. * * @param seed Seed bytes, typically the 64-byte output of * {@link mnemonicToSeed}. * @returns The root node from which paths are derived. */ static fromMasterSeed(seed: Uint8Array): BLS12377HDKey; /** * Derives the descendant node at a hardened path. Pure and local. * * @param path Path of the form `m/44'/683'` — every segment MUST be * hardened (trailing `'`) and below 2^31. * @returns A new node; this node is unchanged. * @throws If the path is malformed, contains a non-hardened segment, or a * segment is out of range. */ derive(path: string): BLS12377HDKey; /** Alias for {@link BLS12377HDKey.derive}, kept for HD-key API parity. */ derivePath(path: string): BLS12377HDKey; /** * Derives the account node at `m/{index}'/0'` relative to this node. Pure * and local. Applied to a {@link DERIVATION_PATHS} node, this yields the * account at that index. * * @param index Zero-based account index, below 2^31; hardening is applied * internally. * @returns The account-level node. * @throws If the index is negative, fractional, or 2^31 or greater. */ deriveChild(index: number): BLS12377HDKey; } /** * Generates a fresh BIP-39 mnemonic from the English wordlist. * * Draws entropy from the platform CSPRNG; no network access. The phrase is * the root secret for every account derived from it — the caller MUST store * it securely and never log it. * * @param strength Entropy in bits: 128 yields 12 words, 256 yields 24. * Defaults to 128. * @returns A space-separated mnemonic phrase. * * @example * import { generateMnemonic, mnemonicToHDKey } from '@provablehq/veil-aleo-sdk' * * const mnemonic = generateMnemonic() * const account0 = mnemonicToHDKey(mnemonic) */ declare function generateMnemonic(strength?: 128 | 256): string; /** * Checks a full mnemonic phrase against BIP-39: English wordlist membership, * word count, and checksum. Pure and local. * * @param mnemonic Space-separated candidate phrase. * @returns True only if the phrase can be used for key derivation; a single * wrong or reordered word fails the checksum. */ declare function validateMnemonic(mnemonic: string): boolean; /** * Checks whether a single word belongs to the English BIP-39 wordlist. Pure * and local. Use for per-word feedback while a phrase is being typed; * validating the complete phrase still requires {@link validateMnemonic}. * * @param word Candidate word, lowercase. * @returns True if the word is one of the 2048 list entries. */ declare function validateWord(word: string): boolean; /** * Converts a mnemonic to its 64-byte BIP-39 seed via PBKDF2-HMAC-SHA512 with * an empty passphrase. Pure, local, and deterministic. * * The mnemonic is not validated here — call {@link validateMnemonic} first; * an invalid phrase still produces a seed, only for the wrong accounts. * * @param mnemonic Space-separated BIP-39 phrase. * @returns Seed bytes for {@link BLS12377HDKey.fromMasterSeed}. */ declare function mnemonicToSeed(mnemonic: string): Uint8Array; /** * Derives the Aleo account key at the given index from a mnemonic in one * step: seed, master node, derivation path, account child. Pure and local. * This is the usual entry point for turning a stored phrase into key * material. * * @param mnemonic Space-separated BIP-39 phrase. * @param options.index Zero-based account index, below 2^31. Defaults to 0. * @param options.derivation Path convention. Defaults to `'standard'` * (`m/44'/683'`); pass `'legacy'` to recover accounts from wallets that * predate the SLIP-0044 registration. * @returns The account node; its `key` bytes seed the Aleo private key. * @throws If the index is out of range. * * @example * import { mnemonicToHDKey } from '@provablehq/veil-aleo-sdk' * * const hdKey = mnemonicToHDKey(mnemonic, { index: 1 }) */ declare function mnemonicToHDKey(mnemonic: string, options?: { index?: number; derivation?: AleoDerivationId; }): BLS12377HDKey; /** * @provablehq/veil-aleo-sdk * * Loads `@provablehq/sdk` for a specific Aleo network and exposes the SDK's * functionality bound to that network's setup parameters. * * Usage: * import { loadNetwork } from '@provablehq/veil-aleo-sdk' * import { http } from '@provablehq/veil-core' * * const aleo = await loadNetwork('mainnet') * * const account = aleo.privateKeyToAccount('APrivateKey1...') * const { publicClient, walletClient } = aleo.createAleoClient({ * privateKey: 'APrivateKey1...', * networkUrl: 'https://edge.provable.com/api/v2', * }) * * Switching networks: load a new handle. Existing accounts remain valid — * Aleo private keys, view keys, and addresses are network-agnostic. */ /** Networks supported by `@provablehq/sdk/dynamic.js`. */ type SupportedNetwork = 'mainnet' | 'testnet'; /** * Base URL of Provable's hosted delegated proving service. * * The default `proverUrl` for `mode: 'delegated'`. A base, so the active network * is appended — which is what lets `switchChain` re-target proving. Served by * the edge gateway, which needs no credentials; a provisioned key is optional. */ declare const DEFAULT_PROVER_URL = "https://edge.provable.com/api/prove"; /** * Base URL of Provable's hosted Record Scanner Service. * * The default `url` for both scanner factories. A base — the SDK appends the * network segment, which is what lets a scanner follow `switchChain`. Served by * the edge gateway, which needs no credentials; a provisioned key is optional. */ declare const DEFAULT_SCANNER_URL = "https://edge.provable.com/api/scanner"; /** * Base URL of Provable's hosted Aleo node API. * * The default `networkUrl` for `createAleoClient`. A base — the transport * appends the network segment, so `switchChain` re-targets reads and * broadcasts. Served by the edge gateway, which needs no credentials. */ declare const DEFAULT_NETWORK_URL = "https://edge.provable.com/api/v2"; type SdkModule = Awaited>>; /** * A network-bound SDK handle. All functions on this handle use the binary * set loaded for the named network. * * Most key/account operations (`privateKeyToAccount`, `mnemonicToAccount`, * `generateAccount`, `decryptRecord`, `verifySignature`) are mathematically * network-agnostic — the same private key (or mnemonic) derives the same * address and view key regardless of which network's binary was loaded. * Proving and program operations (`createProvingConfig`, `createAleoClient`, * scanners) are network-bound. */ interface AleoSdk { /** * Generates and validates an exclusion witness without network access or signing. * @param options Subject, published tree, and expected on-chain root. * @returns An encoded `[MerkleProof; 2]` transaction input. * @throws When the subject is frozen or the tree does not prove the expected root. * @example * const proof = await sdk.generateFreezelistProof({ address, tree, root }) */ generateFreezelistProof(options: GenerateFreezelistProofParameters): Promise; /** The network this handle is bound to. */ readonly network: SupportedNetwork; /** Creates a `LocalAccount` from an Aleo private key. */ privateKeyToAccount(privateKey: string): LocalAccount<'privateKey'>; /** * Creates a `LocalAccount` from a BIP39 mnemonic phrase using Aleo's * BLS12-377 HD derivation (matches Shield wallet derivation). * * Defaults to the SLIP-0044 Aleo coin type path `m/44'/683'`, account * index 0. Pass `derivation: 'legacy'` to use the pre-registration path * `m/44'/0'` for compatibility with older wallets. */ mnemonicToAccount(mnemonic: string, options?: { index?: number; derivation?: AleoDerivationId; }): LocalAccount<'mnemonic'>; /** * Generates a fresh BIP39 mnemonic and derives its Aleo account in one call. * Pure and local — no network access. The caller MUST persist the returned * mnemonic; it is the only way to re-derive the account. * * @param options.strength Entropy bits: 128 (12 words, default) or 256 (24 words). * @param options.index Account index on the derivation path. Defaults to 0. * @param options.derivation Derivation path id. Defaults to `'standard'` * (`m/44'/683'`); pass `'legacy'` for pre-registration `m/44'/0'` wallets. * @returns The generated mnemonic and the account derived from it. * * @example * const { mnemonic, account } = aleo.generateMnemonicAccount() * // store `mnemonic` safely; `account.address` is ready to use */ generateMnemonicAccount(options?: { strength?: 128 | 256; index?: number; derivation?: AleoDerivationId; }): { mnemonic: string; account: LocalAccount<'mnemonic'>; }; /** Creates a new random Aleo account. */ generateAccount(): LocalAccount<'privateKey'>; /** Decrypts a record ciphertext using a view key. */ decryptRecord(viewKey: string, ciphertext: string): string; /** Verifies a signature against a message and address. */ verifySignature(address: string, message: Uint8Array, signature: string): boolean; /** Creates an `AleoNetworkClient` for direct SDK access. */ createNetworkClient(url: string): InstanceType; /** * Creates a `ProvingConfig` for `createWalletClient({ proving })`. * * @param options.proverUrl Base URL of the delegated proving service — the * network segment is appended, so do not include it. That is what lets * `switchChain` re-target proving instead of leaving it on the network the * client started from. A base that already ends in `/mainnet` or `/testnet` * is re-targeted rather than doubled. Defaults to * {@link DEFAULT_PROVER_URL} under `mode: 'delegated'`; unused under * `mode: 'local'`, which reaches no prover. * @param options.consumerId Optional consumer id for the legacy JWT model. * With `apiKey` it forms the pair a session mints JWTs from when * `proverUrl` names a legacy gateway such as * `https://api.provable.com/prove`. On the default gateway the pair is * carried and nothing mints. Omit both for the default gateway. * @param options.apiKey Optional API key paired with `consumerId`. For a * provisioned gateway key use `auth` instead. * @param options.session Optional Provable API session. When present the * configuration authenticates from it and withholds `apiKey`/`consumerId` * from the prover client, so one party mints JWTs. The session is attached * to the returned configuration, which is what lets * `authenticateProvableApi` find it on a client. * @param options.auth Optional provisioned-key auth for the edge gateway. * Every proving request carries the key verbatim; nothing registers or * mints, and a 401 is terminal. Mutually exclusive with `session`, * `apiKey`, and `consumerId` — combining them throws. */ createProvingConfig(options: { mode: 'delegated' | 'local'; networkUrl: string; proverUrl?: string; apiKey?: string; consumerId?: string; account?: LocalAccount<'privateKey'>; confirmationTimeout?: number; useFeeMaster?: boolean; session?: ProvableSession; auth?: ProvableKeyedAuth; }): ProvingConfigWithSession; /** * Creates a record scanner backed by Provable's Record Scanner Service. * * The first `requestRecords` call registers the account's view key with the * service (a network round-trip) to obtain the UUID scanning requires; * subsequent calls reuse it. `setAccount` resets the registration. * * The provider implements `switchNetwork`, so a wallet client carrying it * re-targets record scanning when `switchChain` runs — the scanner rebuilds * against the new network and re-registers lazily on the next scan. * * @param options.url Base URL of the service (the SDK appends the network * segment — do not include it). Defaults to {@link DEFAULT_SCANNER_URL}. * @param options.consumerId Optional consumer id for the legacy JWT model. * With `apiKey` it forms the pair a session mints JWTs from when `url` * names a legacy gateway such as `https://api.provable.com/scanner`. On * the default gateway the pair is carried and nothing mints. Required * alongside `apiKey`, since a lone key is ambiguous with a provisioned * key. Omit both for the default gateway. * @param options.apiKey Optional API key paired with `consumerId`. For a * provisioned gateway key use `auth` instead. * @param options.session Optional Provable API session to authenticate from, * shared with delegated proving. `createAleoClient` supplies its own * session through `setSession` on the returned provider, so a caller who * passes the scanner to that factory does not need this. * @param options.waitForSync Waits for scanner synchronization before each page. Defaults to false. * @param options.syncTimeoutMs Synchronization timeout in milliseconds. Defaults to 300000. * @param options.startBlock Optional block height to begin scanning from at * registration. Defaults to 0 (full history). * @param options.auth Optional provisioned-key auth for the edge gateway. * Every scan carries the key verbatim; nothing registers or mints, and a * 401 is terminal. Mutually exclusive with `session`, `apiKey`, and * `consumerId` — combining them throws. * @returns The provider, plus `setSession` and `setAuth` for a factory to * share one credential source across proving and scanning after * construction, and `url`, the base the scanner targets, so the factory * can tell whether a legacy gateway is in play. */ createRemoteScanner(options?: { waitForSync?: boolean; syncTimeoutMs?: number; url?: string; consumerId?: string; apiKey?: string; session?: ProvableSession; startBlock?: number; auth?: ProvableKeyedAuth; }): RecordProvider & { url: string; setSession: (session: ProvableSession) => void; setAuth: (auth: ProvableKeyedAuth) => void; }; /** * Creates a standalone record scanner with an explicit view key. * * Like {@link createRemoteScanner}, the first `requestRecords` registers the * view key with the service (a network round-trip) to obtain the scanning UUID. * * @param options.url Base URL of the service (the SDK appends the network * segment). Defaults to {@link DEFAULT_SCANNER_URL}. * @param options.consumerId Optional consumer id from the retired consumer * model. Accepted so existing configuration keeps loading; the gateway * needs no consumer, so nothing is sent or minted from it. Required * alongside `apiKey`, since a lone key is ambiguous with a provisioned key. * @param options.viewKey The view key (`AViewKey1…`) to scan and decrypt with. * @param options.apiKey Optional API key paired with `consumerId`. For a * provisioned gateway key use `auth` instead. * @param options.session Optional Provable API session to authenticate from. * Supplied at construction only — a standalone scanner is not pluggable * into a wallet client, so nothing shares a session with it later. * @param options.startBlock Optional block height to begin scanning from at * registration. Defaults to 0 (full history). * @param options.auth Optional provisioned-key auth for the edge gateway. * Every scan carries the key verbatim; nothing registers or mints, and a * 401 is terminal. Mutually exclusive with `session`, `apiKey`, and * `consumerId` — combining them throws. */ createStandaloneScanner(options: { url?: string; consumerId?: string; viewKey: string; apiKey?: string; session?: ProvableSession; startBlock?: number; auth?: ProvableKeyedAuth; }): StandaloneRecordScanner; /** * Creates a fully-wired Aleo client from a private key. * * Targets the Provable gateway, which needs no credentials: with nothing but * the private key the client reads and broadcasts through the hosted node, * proves through the hosted delegated prover with the FeeMaster paying fees, * and scans records through the hosted scanner. Every one of those is an * option for a self-hosted or legacy service. A consumer pair together with * legacy URLs (`https://api.provable.com/...`) selects the legacy JWT model, * with one session minting for proving and scanning; a provisioned gateway * key goes through `auth`. * * @param options.networkUrl Base URL of the Aleo node both clients read from * and broadcast to, without the network segment. Defaults to * {@link DEFAULT_NETWORK_URL}; pass an override for a self-hosted node or * a devnode. * @param options.provingMode Where proofs are produced. Defaults to * `'delegated'`; `'local'` proves in-process and reaches no prover. * @param options.useFeeMaster Whether the delegated prover pays the fee from * its FeeMaster account instead of the caller's public credits. Defaults * to true, so a faucet-funded account with no public credits can write. * Pass false when the account funds its own fees. Only meaningful under * delegated proving. * @param options.recordManagement Optional shared record reservations and recovery. * Defaults to disabled. Set enabled: true to reserve inputs during writes * and track unfinished transactions. * @param options.records Record provider behind `requestRecords`. Defaults * to `createRemoteScanner()` against the hosted scanner; pass a scanner * built with a custom `url` or any `RecordProvider` to override. * @param options.apiKey Optional API key for the legacy JWT model. Paired * with `consumerId`, it seeds the session that mints JWTs at the legacy * gateway `proverUrl` or the scanner's `url` names. On the default gateway * the pair is carried and nothing mints. * @param options.consumerId Optional consumer id for the legacy JWT model. * @param options.proverUrl Base URL of the delegated proving service — the * network segment is appended, so do not include it. That is what lets * `switchChain` re-target proving. Defaults to {@link DEFAULT_PROVER_URL}, * since `provingMode` itself defaults to `'delegated'`; pass an override for * a self-hosted prover. * @param options.confirmationTimeout Milliseconds to wait for a submitted * transaction to confirm. Defaults to 60_000 (one minute), which covers a * healthy confirmation with room to spare; a transaction still absent after * that is more often one the node never included than one about to land. * Raise it for a congested network or a multi-transition call that takes * longer to include, rather than treating a slow confirmation as a failure. * @param options.username Ignored. Nothing registers anymore; accepted so * existing calls compile. * @param options.credentialStore Optional store holding a consumer pair for * the legacy JWT model. Read once and never written. Defaults to * `memoryCredentialStore()`. A client left fully unconfigured does not * share its session with `records`, so a scanner aimed at the gateway stays * exactly as it was built. * @param options.session Optional pre-built session, for a caller that owns * one already. Takes precedence over the credential options. * @param options.auth Optional provisioned key for the gateway. Selects the * keyed model for the whole client: proving and scanning carry the key on * every request and no session exists. Mutually exclusive with every * consumer option (`apiKey`, `consumerId`, `username`, `credentialStore`, * `session`) — gateway keys are handed out by an operator, not registered. * @returns A public client, a wallet client carrying * `authenticateProvableApi`, and the account. * * @example * const { walletClient } = aleo.createAleoClient({ privateKey }) * const txId = await walletClient.writeContract({ program, function: 'transfer_public', inputs }) */ createAleoClient(options: { recordManagement?: RecordManagementConfig; privateKey: string; networkUrl?: string; provingMode?: 'delegated' | 'local'; proverUrl?: string; apiKey?: string; consumerId?: string; useFeeMaster?: boolean; confirmationTimeout?: number; username?: string | (() => string); credentialStore?: ProvableCredentialStore; session?: ProvableSession; auth?: ProvableKeyedAuth; /** * Record provider for `requestRecords`. Defaults to * `aleo.createRemoteScanner()` against the hosted scanner; pass a scanner * with a custom `url` or any custom `RecordProvider` to override. */ records?: RecordProvider & { url?: string; setSession?: (session: ProvableSession) => void; setAuth?: (auth: ProvableKeyedAuth) => void; }; }): { publicClient: PublicClient; walletClient: ProvableWalletClient; account: LocalAccount<'privateKey'>; }; } /** * Loads `@provablehq/sdk` for the named network and returns a network-bound * handle. The SDK module cache memoizes the load — calling twice for the * same network returns the same binary set without re-instantiating. */ declare function loadNetwork(name: SupportedNetwork): Promise; /** Creates a new random Aleo account (uses static SDK binaries). */ declare function generateAccount(): LocalAccount<'privateKey'>; /** * Creates a fully-wired client pair pointing at a local Aleo Devnode instance. * * Devnode is a lightweight local Aleo node (similar to Foundry's Anvil) that * bypasses consensus and skips ZK proof generation, enabling rapid program iteration. * The seeded account is pre-funded; both key and socket address can be overridden. * * The returned wallet client supports `executeContract`. Its confirmation wait * resolves once the devnode includes the transaction in a block — automatic * after broadcast by default; under `manualBlockCreation` the caller must * advance blocks (e.g. a test client's `advanceBlock`) while the call is * pending. Record outputs owned by the client's account are decrypted to * plaintext in the result; foreign records are dropped. * * @param options.recordManagement Optional shared record reservations and recovery. * Defaults to disabled; local chains should supply a distinct chainId when enabled. * @example * ```ts * // Zero-config — uses seeded key and localhost:3030 * const { publicClient, walletClient, account } = createDevnodeClient() * * // Custom key or socket address * const { publicClient, walletClient, account } = createDevnodeClient({ * privateKey: 'APrivateKey1...', * socketAddr: '127.0.0.1:4040', * }) * ``` */ declare function createDevnodeClient(options?: { recordManagement?: RecordManagementConfig; privateKey?: string; /** Socket address of the devnode, e.g. "127.0.0.1:3030" */ socketAddr?: string; }): { publicClient: PublicClient; walletClient: WalletClient; account: LocalAccount<'privateKey'>; }; export { type AleoDerivationId, type AleoSdk, BLS12377HDKey, DEFAULT_NETWORK_URL, DEFAULT_PROVER_URL, DEFAULT_SCANNER_URL, LEGACY_PATH, ProvableCredentialStore, ProvableKeyedAuth, ProvableSession, ProvableWalletClient, ProvingConfigWithSession, STANDARD_PATH, type SupportedNetwork, createDevnodeClient, generateAccount, generateMnemonic, loadNetwork, mnemonicToHDKey, mnemonicToSeed, validateMnemonic, validateWord };