@libp2p/keychain
Version:
Key management and cryptographically protected messages
37 lines • 1.88 kB
TypeScript
import type { ECDSAPrivateKey, Ed25519PrivateKey, PrivateKey, RSAPrivateKey, Secp256k1PrivateKey } from '@libp2p/interface';
import type { Multibase } from 'multiformats/bases/interface';
/**
* Exports the given PrivateKey as a base64 encoded string.
* The PrivateKey is encrypted via a password derived PBKDF2 key
* leveraging the aes-gcm cipher algorithm.
*/
export declare function exporter(privateKey: Uint8Array, password: string): Promise<Multibase<'m'>>;
export type ExportFormat = 'pkcs-8' | 'libp2p-key';
/**
* Converts an exported private key into its representative object.
*
* Supported formats are 'pem' (RSA only) and 'libp2p-key'.
*/
export declare function exportPrivateKey(key: PrivateKey, password: string, format?: ExportFormat): Promise<Multibase<'m'>>;
/**
* Exports the key into a password protected `format`
*/
export declare function exportEd25519PrivateKey(key: Ed25519PrivateKey, password: string, format?: ExportFormat): Promise<Multibase<'m'>>;
/**
* Exports the key into a password protected `format`
*/
export declare function exportSecp256k1PrivateKey(key: Secp256k1PrivateKey, password: string, format?: ExportFormat): Promise<Multibase<'m'>>;
/**
* Exports the key into a password protected `format`
*/
export declare function exportECDSAPrivateKey(key: ECDSAPrivateKey, password: string, format?: ExportFormat): Promise<Multibase<'m'>>;
/**
* Exports the key as libp2p-key - a aes-gcm encrypted value with the key
* derived from the password.
*
* To export it as a password protected PEM file, please use the `exportPEM`
* function from `@libp2p/rsa`.
*/
export declare function exportRSAPrivateKey(key: RSAPrivateKey, password: string, format?: ExportFormat): Promise<Multibase<'m'>>;
export declare function exportToPem(privateKey: RSAPrivateKey, password: string): Promise<string>;
//# sourceMappingURL=export.d.ts.map