/** * Paper Key Service for the BrightChain identity system. * * Provides generation, validation, recovery, and template creation * for 24-word BIP39 mnemonic paper keys. Paper keys serve as the * primary mechanism for account backup, device provisioning, and * account recovery. * * This service wraps the existing BIP39/ECIES infrastructure from * {@link @digitaldefiance/ecies-lib} and exposes a focused API for * paper key operations. * * Requirements: 1.1, 1.2, 1.3, 1.4, 1.8 */ import { ECIESService, Member, PlatformID, SecureString } from '@digitaldefiance/ecies-lib'; import { IPaperKeyTemplate } from '../../interfaces/identity/paperKey'; /** * Service for generating, validating, and recovering from BIP39 paper keys. * * All methods require an {@link ECIESService} instance, which is obtained * from {@link ServiceProvider}. This keeps the service stateless and * compatible with the existing dependency-injection pattern used * throughout BrightChain. * * @example * ```typescript * const eciesService = ServiceProvider.getInstance().eciesService; * * // Generate a new paper key * const paperKey = PaperKeyService.generatePaperKey(eciesService); * * // Validate it * const isValid = PaperKeyService.validatePaperKey(paperKey, eciesService); * * // Recover a member from it * const member = PaperKeyService.recoverFromPaperKey(paperKey, eciesService); * * // Generate a printable template * const template = await PaperKeyService.generateTemplate( * paperKey, * member.id.toString(), * ); * ``` */ export declare class PaperKeyService { /** * Generate a new 24-word BIP39 mnemonic paper key (256-bit entropy). * * Uses the ECIESService's mnemonic generator which internally calls * `@scure/bip39.generateMnemonic(wordlist, 256)`. * * **Validates: Requirement 1.1** — Generate 24-word BIP39 mnemonics * * @param eciesService - The ECIES service instance for key generation * @returns A {@link SecureString} containing the 24-word mnemonic */ static generatePaperKey(eciesService: ECIESService): SecureString; /** * Validate that a paper key is a well-formed BIP39 mnemonic. * * Checks both structural validity (24 words, valid BIP39 checksum) * by attempting to derive a wallet from the mnemonic. If derivation * succeeds the mnemonic is valid; if it throws, the mnemonic is invalid. * * **Validates: Requirement 1.2** — Validate paper key format using BIP39 validation * * @param paperKey - The mnemonic string to validate * @param eciesService - The ECIES service instance for validation * @returns `true` if the paper key is a valid 24-word BIP39 mnemonic, `false` otherwise */ static validatePaperKey(paperKey: string, eciesService: ECIESService): boolean; /** * Recover a {@link Member} identity from a paper key mnemonic. * * Reconstructs the full member (with private key and wallet loaded) * from the BIP39 mnemonic. The recovered member can immediately * perform cryptographic operations (sign, encrypt, etc.). * * **Validates: Requirement 1.3** — Recover Member identity from a valid paper key * * @param paperKey - The 24-word BIP39 mnemonic * @param eciesService - The ECIES service instance for key derivation * @param name - Optional display name for the recovered member (default: 'Recovered User') * @returns A fully-initialised {@link Member} with wallet and private key loaded * @throws {Error} If the paper key is invalid or key derivation fails */ static recoverFromPaperKey(paperKey: string, eciesService: ECIESService, name?: string): Member; /** * Generate a printable paper key template. * * Produces an {@link IPaperKeyTemplate} containing the mnemonic words, * a QR code data URL for mobile scanning, creation timestamp, * storage instructions, and security warnings. * * The QR code encodes the full mnemonic string and is generated * using the `qrcode` library (same pattern as {@link TOTPEngine}). * * **Validates: Requirements 1.4, 1.8, 1.10** — Printable template with QR code and warnings * * @param paperKey - The 24-word BIP39 mnemonic to template * @param memberId - The member ID to associate with the template * @returns A promise resolving to the complete {@link IPaperKeyTemplate} */ static generateTemplate(paperKey: string, memberId: string): Promise; } //# sourceMappingURL=paperKeyService.d.ts.map