/** * Key escrow / recovery — Shamir's Secret Sharing over GF(256). * * Problem: a heart's signing key is the root of all its authority. Lose it * and the identity is dead forever. Hand it to one person and you've given * them full control. Both outcomes are operationally unacceptable. * * Solution: split the secret into N shares such that any K of them can * reconstruct it, and any K-1 of them reveal NOTHING. Distribute shares to * independent trustees (hardware vaults, family members, offline media, * legal custodians). Recovery needs a quorum but no single party is trusted. * * Properties (inherited from Shamir 1979): * - Information-theoretic security: K-1 shares leak zero bits. * - Linear: shares can be mixed/rotated without touching the secret. * - No setup: pure polynomial math, no trusted dealer beyond split-time. * * Implementation notes: * - Arithmetic in GF(256) with irreducible polynomial 0x11b (Rijndael). * - Secret is processed byte-by-byte; each byte gets its own independent * polynomial. This is the standard Shamir construction. * - Shares are tagged with index (1..255). Index 0 is reserved for the * secret itself (f(0)). * - We bind each share to a "secretId" so shares from different secrets * can't be mixed. The id is also returned on reconstruction so callers * can verify they're combining the right shares. * - Threshold K must satisfy 2 ≤ K ≤ N ≤ 255. * * Constant-time discipline (the HashiCorp Vault CVE-2023-25000 lesson): * GF(256) multiplication is implemented branch-free via Russian-peasant * bitwise operations, with no log/exp table lookups. Inversion uses * Fermat's little theorem (a^254 = a^-1 in GF(256)) via a fixed addition * chain — always the same number of squarings and multiplications * regardless of input. This closes the cache-timing side channel that * table-based implementations have on shared hosts. The fast path (log/exp * tables) is retained internally only for unit tests that cross-check the * constant-time output against the classical algorithm. */ import { type CryptoProvider } from '../core/crypto-provider.js'; /** One piece of a split secret. Need K of these to reconstruct. */ export interface SecretShare { /** Opaque id binding this share to its siblings. Same across all shares. */ secretId: string; /** Share index (1..255). Must be unique within the share set. */ index: number; /** How many shares are needed to reconstruct (the threshold). */ threshold: number; /** Total number of shares issued. */ totalShares: number; /** Length of the original secret in bytes (included for integrity check). */ secretLength: number; /** Base64-encoded share bytes — one byte per secret byte. */ shareB64: string; } export interface SplitOptions { threshold: number; totalShares: number; /** Optional custom id (otherwise random). Lets callers label the share set. */ secretId?: string; provider?: CryptoProvider; } export declare function splitSecret(secret: Uint8Array, opts: SplitOptions): SecretShare[]; export declare function reconstructSecret(shares: readonly SecretShare[], provider?: CryptoProvider): Uint8Array; /** * Check that a specific subset of shares reconstructs to a known secret. * Useful as a post-split sanity check, or as a test harness for trustees. * Returns true iff reconstruction yields bytes matching `expected`. */ export declare function verifyShares(shares: readonly SecretShare[], expected: Uint8Array, provider?: CryptoProvider): boolean; /** * Exhaustively check that EVERY K-subset of the N shares reconstructs the * secret. N choose K grows fast — callers should limit to small parameter * sizes (e.g. 5-of-5 = 1 combination, 3-of-5 = 10 combinations). For larger * sets, random sampling is sufficient. */ export declare function verifyAllSubsetsReconstruct(shares: readonly SecretShare[], expected: Uint8Array, provider?: CryptoProvider): boolean; //# sourceMappingURL=key-escrow.d.ts.map