import type { Network } from "../config/networks.js"; /** * Bitcoin address derivation result */ export interface BitcoinAddress { /** * Native SegWit address (bc1q... for mainnet, tb1q... for testnet) */ address: string; /** * Compressed public key as hex string */ publicKey: string; } /** * Taproot address derivation result */ export interface TaprootAddress { /** * Taproot address (bc1p... for mainnet, tb1p... for testnet) */ address: string; /** * Internal public key (x-only, 32 bytes) as hex string */ internalPubKey: string; } /** * Taproot key pair derivation result (includes private key for signing) * * SECURITY: This interface exposes the private key as Uint8Array. * The private key should: * - NEVER be serialized to hex string * - NEVER be logged or stored persistently * - Only be held in memory during signing operations * - Be cleared after use (session lock) */ export interface TaprootKeyPair extends TaprootAddress { /** * Private key as raw bytes (32 bytes) * SECURITY: Never serialize. Use only for Taproot signing. */ privateKey: Uint8Array; /** * Internal public key as raw bytes (32 bytes, x-only) * Used for building Taproot transactions. */ internalPubKeyBytes: Uint8Array; } /** * Nostr key pair derivation result (includes private key for NIP-01 event signing) * * Derived via NIP-06 path m/44'/1237'/0'/0/0 (coin type 1237 per SLIP-44). * * SECURITY: This interface exposes the private key as Uint8Array. * The private key should: * - NEVER be serialized to hex string * - NEVER be logged or stored persistently * - Only be held in memory during signing operations * - Be cleared after use (session lock) */ export interface NostrKeyPair { /** * Private key as raw bytes (32 bytes) for BIP-340 Schnorr signing. * SECURITY: Never serialize. Use only for Nostr event signing. */ privateKey: Uint8Array; /** * Public key as x-only bytes (32 bytes, no 02/03 prefix). * This is the Nostr public key used in NIP-01 events. */ publicKey: Uint8Array; } /** * Bitcoin key pair derivation result (includes private key for signing) * * SECURITY: This interface exposes the private key as Uint8Array. * The private key should: * - NEVER be serialized to WIF or hex string * - NEVER be logged or stored persistently * - Only be held in memory during signing operations * - Be cleared after use (session lock) */ export interface BitcoinKeyPair extends BitcoinAddress { /** * Private key as raw bytes (32 bytes) * SECURITY: Never serialize to WIF/hex. Use only for signing. */ privateKey: Uint8Array; /** * Public key as raw bytes (33 bytes compressed) * Used for building P2WPKH transactions. */ publicKeyBytes: Uint8Array; } /** * Derive Bitcoin L1 native SegWit address from BIP39 mnemonic * * Follows BIP84 derivation path: * - Mainnet: m/84'/0'/0'/0/0 (coin type 0) * - Testnet: m/84'/1'/0'/0/0 (coin type 1) * * Returns native SegWit (P2WPKH) address: * - Mainnet: bc1q... prefix * - Testnet: tb1q... prefix * * Security: Only returns address and public key. Private key is never exposed. * * @param mnemonic - BIP39 mnemonic phrase (12 or 24 words) * @param network - Network to derive address for ('mainnet' | 'testnet') * @returns Bitcoin address and public key * * @example * ```typescript * const { address, publicKey } = deriveBitcoinAddress(mnemonic, 'mainnet'); * console.log(address); // bc1q... * console.log(publicKey); // 02... or 03... (33 bytes compressed) * ``` */ export declare function deriveBitcoinAddress(mnemonic: string, network: Network): BitcoinAddress; /** * Derive Bitcoin L1 key pair from BIP39 mnemonic (includes private key for signing) * * Follows BIP84 derivation path: * - Mainnet: m/84'/0'/0'/0/0 (coin type 0) * - Testnet: m/84'/1'/0'/0/0 (coin type 1) * * Returns native SegWit (P2WPKH) address and key pair: * - Mainnet: bc1q... prefix * - Testnet: tb1q... prefix * * SECURITY WARNING: This function returns the private key as Uint8Array. * - NEVER serialize the private key to WIF or hex string * - NEVER log or store the private key persistently * - Only hold in memory during signing operations * - Clear from memory when wallet is locked * * @param mnemonic - BIP39 mnemonic phrase (12 or 24 words) * @param network - Network to derive keys for ('mainnet' | 'testnet') * @returns Bitcoin address, public key, and private key (Uint8Array) * * @example * ```typescript * const { address, publicKey, privateKey } = deriveBitcoinKeyPair(mnemonic, 'mainnet'); * console.log(address); // bc1q... * console.log(publicKey); // 02... or 03... (33 bytes compressed) * // privateKey is Uint8Array(32) - use for signing, never serialize * ``` */ export declare function deriveBitcoinKeyPair(mnemonic: string, network: Network): BitcoinKeyPair; /** * Derive Bitcoin L1 Taproot address from BIP39 mnemonic * * Follows BIP86 derivation path: * - Mainnet: m/86'/0'/0'/0/0 (coin type 0) * - Testnet: m/86'/1'/0'/0/0 (coin type 1) * * Returns Taproot (P2TR) address: * - Mainnet: bc1p... prefix * - Testnet: tb1p... prefix * * Security: Only returns address and internal public key. Private key is never exposed. * * @param mnemonic - BIP39 mnemonic phrase (12 or 24 words) * @param network - Network to derive address for ('mainnet' | 'testnet') * @returns Taproot address and internal public key * * @example * ```typescript * const { address, internalPubKey } = deriveTaprootAddress(mnemonic, 'mainnet'); * console.log(address); // bc1p... * console.log(internalPubKey); // 32-byte x-only pubkey (hex) * ``` */ export declare function deriveTaprootAddress(mnemonic: string, network: Network): TaprootAddress; /** * Derive Bitcoin L1 Taproot key pair from BIP39 mnemonic (includes private key for signing) * * Follows BIP86 derivation path: * - Mainnet: m/86'/0'/0'/0/0 (coin type 0) * - Testnet: m/86'/1'/0'/0/0 (coin type 1) * * Returns Taproot (P2TR) address and key pair: * - Mainnet: bc1p... prefix * - Testnet: tb1p... prefix * * SECURITY WARNING: This function returns the private key as Uint8Array. * - NEVER serialize the private key * - NEVER log or store the private key persistently * - Only hold in memory during signing operations * - Clear from memory when wallet is locked * * @param mnemonic - BIP39 mnemonic phrase (12 or 24 words) * @param network - Network to derive keys for ('mainnet' | 'testnet') * @returns Taproot address, internal public key, and private key (Uint8Array) * * @example * ```typescript * const { address, internalPubKey, privateKey } = deriveTaprootKeyPair(mnemonic, 'mainnet'); * console.log(address); // bc1p... * console.log(internalPubKey); // 32-byte x-only pubkey (hex) * // privateKey is Uint8Array(32) - use for signing, never serialize * ``` */ export declare function deriveTaprootKeyPair(mnemonic: string, network: Network): TaprootKeyPair; /** * Derive Nostr key pair from BIP39 mnemonic using NIP-06 derivation path * * Follows NIP-06 derivation path: * - m/44'/1237'/0'/0/0 (coin type 1237 per SLIP-44, same for mainnet and testnet) * * Returns x-only public key and raw private key for BIP-340 Schnorr signing: * - publicKey: 32 bytes (x-coordinate only, no 02/03 prefix) * - privateKey: 32 bytes (raw scalar) * * SECURITY WARNING: This function returns the private key as Uint8Array. * - NEVER serialize the private key to hex string * - NEVER log or store the private key persistently * - Only hold in memory during signing operations * - Clear from memory when wallet is locked * * @param mnemonic - BIP39 mnemonic phrase (12 or 24 words) * @param network - Network parameter (unused for Nostr; path is network-independent) * @returns Nostr x-only public key and private key (both Uint8Array) * * @example * ```typescript * const { publicKey, privateKey } = deriveNostrKeyPair(mnemonic, 'mainnet'); * // publicKey is Uint8Array(32) - x-only Nostr public key * // privateKey is Uint8Array(32) - use for Schnorr signing, never serialize * ``` */ export declare function deriveNostrKeyPair(mnemonic: string, _network: Network): NostrKeyPair; //# sourceMappingURL=bitcoin.d.ts.map