/** * @pwngh/economy-lab * * Copyright (c) Preston Neal * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */ import type { AccountRef } from './accounts.js'; import type { Checkpoint, Digest, StoredLink } from './ports.js'; /** What {@link parseExport} returns, for custom tooling over an export file. */ export type ParsedExport = { /** Each account's chain links in lineage order (oldest first), as the file carried them. */ lineage: Map; /** The embedded signed checkpoint, or null when none had been sealed at export time. */ checkpoint: Checkpoint | null; }; /** * Parses `read.export` lines into per-account lineage plus the embedded checkpoint. Blank lines * are skipped. Throws when the first line does not declare the {@link EXPORT_FORMAT} marker, on * an unknown line type, and on empty input — a truncated or foreign file fails loudly instead * of parsing to an empty ledger. */ export declare function parseExport(lines: Iterable): ParsedExport; /** What {@link verifyExport} resolves to: the chain verdict, then the checkpoint check. */ export type VerifyReport = { /** True when every account's chain re-derives link by link from the file alone. */ chainIntact: boolean; /** The first failing link as the prover reports it; nothing when the chain is intact. */ firstBreak: unknown; /** How many account chains the file carried and the prover walked. */ accounts: number; checkpoint: { /** Whether the file embedded a checkpoint at all. */ present: boolean; id?: string; /** The key id the checkpoint was sealed under, when the seal recorded one. */ kid?: string | null; /** False when no checkpoint is embedded or no public key was supplied. */ signatureChecked: boolean; /** Present only when `signatureChecked`; true when the seal verifies against a supplied key. */ verified?: boolean; }; }; /** * Runs the full offline verification: re-prove every account's chain from the file's links, * then check the embedded checkpoint's root and signature against the supplied public keys. * The checkpoint verifies against the exported tip, so a checkpoint sealed before the last * postings reports as unverified until the ledger is exported right after a seal. * * @example * import { readFileSync } from 'node:fs'; * const lines = readFileSync('ledger-export.jsonl', 'utf8').split('\n'); * const report = await verifyExport(lines, [publishedSigningKeyHex]); * if (!report.chainIntact) throw new Error('export chain broken'); */ export declare function verifyExport(lines: Iterable, publicKeysHex: ReadonlyArray, digest?: Digest): Promise;