import { LedgerKeyPair } from "../../../types/src"; import { EncryptedString } from './common/exchange'; /** * Creates a new random key pair for signing ledger * requests. Key pair is created using ed25519 algorithm. * * This function is aware of runtime environment and uses * appropriate crypto libraries depending on it. It works both * in node and browsers. * * @returns new key pair */ export declare function createKeyPair(): Promise; /** * Encrypts ed25519 secret key with password by using pkcs5 * specification. Although pkcs5 supports multiple options for * digest and encryption algorithms, for our purposes we are * using strict choices when encrypting the key: * - PBES2 encryption scheme * - PBKDF2 key derivation function * - SHA-256 digest for deriving key from passphrase * - AES-CBC-256 encryption algorithm for encrypting the key * * @param secret raw base64 encoded ed25519 secret * @param password encryption password * @returns encrypted secret in pkcs5 format encoded as base64 * @see https://www.rfc-editor.org/rfc/rfc2898 */ export declare function encryptSecretKey(secret: LedgerKeyPair['secret'], password: string): Promise; /** * Decrypts ed25519 secret key with password by using pkcs5 * specification. Although pkcs5 supports multiple options for * digest and encryption algorithms, for our purposes we are * using strict choices when decrypting the key: * - PBES2 encryption scheme * - PBKDF2 key derivation function * - SHA-256 digest for deriving key from passphrase * - AES-CBC-256 encryption algorithm for encrypting the key * * @param secret encrypted secret in pkcs5 format encoded as base64 * @param password decryption password * @returns raw base64 encoded ed25519 secret * @see https://www.rfc-editor.org/rfc/rfc2898 */ export declare function decryptSecretKey(secret: LedgerKeyPair['secret'], password: string): Promise; /** * Checks if given ed25519 secret is encrypted using pkcs5 * specification. * * @param secret secret * @returns true if secret is encrypted, false otherwise * @see https://www.rfc-editor.org/rfc/rfc2898 */ export declare function isSecretKeyEncrypted(secret: LedgerKeyPair['secret']): boolean; /** * Generates a new RSA key pair. This function is only available in Node.js, in browser it is not available. * @returns */ export declare function createRsaKeyPair(): Promise<{ format: string; public: string; secret: string; }>; /** * Generates a new aes key. * @returns Base64 encoded string representing the key */ export declare function createAesKey(): Promise; /** * Encrypts a given string with a string password. There are no requirements for the format of either. * @param secret String to encrypt * @param password Password to encrypt with * @returns */ export declare function encryptWithPassword(secret: string, password: string): Promise<{ unpacked: EncryptedString; packed: string; }>; /** * Decrypts a given encrypted string with a string password. * @param encrypted Components of encrypted string (see `EncryptedString`), or those same components encoded into a string (see `exportEncryptedString` and `importEncryptedString`). * @param password Password to decrypt with * @returns */ export declare function decryptWithPassword(encrypted: EncryptedString | string, password: string): Promise; /** * Checks if a string is a valid encoded `EncryptedString` * @param value * @returns */ export declare function isStringEncryptedPackage(value: string): boolean;