UNPKG

safevibe

Version:

Safevibe CLI - Simple personal secret vault for AI developers and amateur vibe coders

53 lines (52 loc) 1.53 kB
/** * Cryptographic key management for Safevibe * * For demo purposes, we use simplified encryption. * In production, this would use: * - X25519 key exchange * - ChaCha20-Poly1305 for encryption * - age encryption format * - Proper key derivation functions */ export interface KeyPair { publicKey: string; privateKey: string; } export interface EncryptionResult { ciphertext: string; nonce: string; } /** * Generate a new X25519 key pair * For demo: generates from random bytes */ export declare function generateKeyPair(): KeyPair; /** * Derive a key pair from a seed (for deterministic generation) */ export declare function deriveKeyPair(seed: string): KeyPair; /** * Encrypt data using the private key * For demo: simple XOR cipher with nonce */ export declare function encryptData(data: string, privateKey: string): EncryptionResult; /** * Decrypt data using the private key */ export declare function decryptData(ciphertext: string, nonce: string, privateKey: string): string; /** * Hash a secret name for storage */ export declare function hashSecretName(name: string): string; /** * Save key pair to file securely */ export declare function saveKeyPair(keyPair: KeyPair, filePath: string): Promise<void>; /** * Load key pair from file */ export declare function loadKeyPair(filePath: string): Promise<KeyPair>; /** * Generate a deterministic project key from user key + project ID */ export declare function deriveProjectKey(userPrivateKey: string, projectId: string): string;