import { FunctionKeyPair } from "../../models/keyPair.js"; import { KeyFingerprint } from "../verifier/interface.js"; import { KeyLocator, KeyStore, ProvingKeyLocator, VerifyingKeyLocator } from "./interface.js"; import { ProvingKey, VerifyingKey } from "../../wasm.js"; /** * Browser-compatible {@link KeyStore} backed by IndexedDB. * * This is the browser counterpart to {@link LocalFileKeyStore} (which requires Node.js `fs`). * It persists proving and verifying keys across page reloads and browser sessions using the * IndexedDB API available in all modern browsers and Web Workers. * * **Environment**: Browser / Web Worker only. Instantiating this class is safe in any * environment, but the first IndexedDB operation will reject with a clear error when * `globalThis.indexedDB` is not available (e.g., Node.js, SSR contexts). Guard your * imports accordingly if you bundle for server-side rendering. * * **Security**: Keys are stored as plaintext `Uint8Array` in IndexedDB. Any script * running on the same origin — including scripts injected via XSS — can read the stored * proving and verifying keys. Do **not** use this keystore for data that must remain * confidential under an XSS-capable adversary; encrypt sensitive material at the * application layer before persisting, or use an in-memory store. * * @example * ```ts * import { IndexedDBKeyStore, ProgramManager } from "@provablehq/sdk"; * * const keyStore = new IndexedDBKeyStore(); * const pm = new ProgramManager(); * pm.setKeyStore(keyStore); * // Keys synthesized during execution are now cached in IndexedDB * // and reloaded automatically on subsequent runs. * ``` */ export declare class IndexedDBKeyStore implements KeyStore { /** * Schema version of the database. Version 2 adds {@link IndexedDBKeyStore.SIZE_INDEX}. * Code that opens the same database directly must use this version or later. */ static readonly DB_VERSION = 2; /** * Index on each key's byte size. A key cursor over it lists the cached keys and their * sizes without reading the key bytes. */ static readonly SIZE_INDEX = "metadata.size"; private readonly dbName; private readonly storeName; private readonly keyVerifier; private dbPromise; /** * @param dbName IndexedDB database name. Defaults to `"aleo-keystore"`. */ constructor(dbName?: string); /** Opens (or creates) the database, returning a cached promise. */ private openDB; /** Runs a single read-write transaction and returns the request result. */ private tx; private validateComponent; private validateNonNegative; private serializeLocator; private checksumToFingerprint; getKeyBytes(locator: KeyLocator): Promise; getProvingKey(locator: ProvingKeyLocator): Promise; getVerifyingKey(locator: VerifyingKeyLocator): Promise; setKeys(proverLocator: ProvingKeyLocator, verifierLocator: VerifyingKeyLocator, keys: FunctionKeyPair): Promise; setKeyBytes(keyBytes: Uint8Array, locator: KeyLocator): Promise; getKeyMetadata(locator: KeyLocator): Promise; has(locator: KeyLocator): Promise; delete(locator: KeyLocator): Promise; clear(): Promise; }