import type { LedgerRecord } from './record.js'; /** * Optional ECDSA signing of ledger records. The hash chain alone is * tamper-EVIDENT: an attacker who edits a record must re-hash and re-link * everything after it, which is detectable but not preventable. A signature * over each record hash makes the ledger tamper-RESISTANT: re-hashed records * cannot be re-signed without the private key, so a full-rewrite attack fails * signature verification even when the rebuilt chain self-validates. * * Signatures cover the record HASH, not the record content: the hash already * binds every content field (see computeRecordHash), so signing it transitively * signs the content — and keeps `sig` itself outside the hashed material. */ export interface KeyPairPem { readonly privateKeyPem: string; readonly publicKeyPem: string; } export declare function generateKeyPair(): KeyPairPem; /** Sign a record hash; returns the DER-encoded ECDSA signature as base64. */ export declare function signRecordHash(hashHex: string, privateKeyPem: string): string; /** Verification is a predicate: any malformed input is simply not a valid signature. */ export declare function verifyRecordSignature(hashHex: string, signatureB64: string, publicKeyPem: string): boolean; export interface SignatureCheck { /** False only on invalid signatures — unsigned records are a warning, not a failure. */ readonly ok: boolean; readonly total: number; readonly signed: number; readonly verified: number; /** Records without `sig` (they predate the key or were written by an unkeyed store). */ readonly unsigned: number; readonly invalidSeqs: readonly number[]; } /** * Verify every signed record against the store's public key. Only meaningful * alongside verifyChain: this checks that each stored `hash` was signed by the * key holder, while the chain check proves `hash` still matches the content. */ export declare function verifyLedgerSignatures(records: readonly LedgerRecord[], publicKeyPem: string): SignatureCheck;