cyphertap
Version:
Nostr, Lightning and Ecash on a single Button component
28 lines (27 loc) • 1.21 kB
TypeScript
import { NDKPrivateKeySigner } from '@nostr-dev-kit/ndk';
/**
* Encrypt a private key using a password
*
* @param privateKey - The private key to encrypt as Uint8Array
* @param password - The password to use for encryption
* @param logn - Scrypt difficulty parameter (default: 16)
* @param ksb - Key security byte (default: 0x02)
* @returns - Encrypted key as a bech32-encoded string with 'ncryptsec' prefix
*/
export declare function encrypt(privateKey: Uint8Array, password: string, logn?: number, ksb?: 0x00 | 0x01 | 0x02): string;
/**
* Decrypt an encrypted private key
*
* @param encryptedKey - The encrypted key as a bech32-encoded string
* @param password - The password used for encryption
* @returns - Decrypted private key as Uint8Array
*/
export declare function decrypt(encryptedKey: string, password: string): Uint8Array;
/**
* Encrypt an NDKPrivateKeySigner with a password, returning a NIP-49 encrypted string
*/
export declare function encryptSigner(signer: NDKPrivateKeySigner, password: string): string;
/**
* Create an NDKPrivateKeySigner from a NIP-49 encrypted key
*/
export declare function decryptToSigner(encryptedKey: string, password: string): NDKPrivateKeySigner;