/** * Utility functions for Memory element operations * * PERFORMANCE CONSIDERATIONS: * - ID generation should be fast (<1ms) * - Hash functions optimized for memory verification * - Index operations designed for O(log n) complexity * * SECURITY CONSIDERATIONS: * - Hash functions normalize Unicode to prevent bypass attempts * - Content verification detects external modifications * - Protects against manual editing and tampering */ /** * Generate a unique ID for memory entries * Format: mem_{timestamp}_{random} * * @returns Unique memory entry ID * @example * generateMemoryId() // "mem_1699234567890_x7k2n9p4m" */ export declare function generateMemoryId(): string; /** * Generate a content hash for memory integrity verification * Uses SHA-256 for cryptographic strength with Unicode normalization * * SECURITY: Normalizes content to prevent Unicode-based bypass attempts * where attackers use homographs or invisible characters to create * content that appears identical but has a different hash * * @param content - The content to hash (will be normalized) * @returns Hex-encoded hash string */ export declare function generateContentHash(content: string): string; /** * Verify memory content integrity * * SECURITY: This function detects: * - External tool modifications (didn't use our hash function) * - Manual human editing of YAML files * - Filesystem corruption * - Tampering attempts (including Unicode tricks) * * @param content - The content to verify (will be normalized) * @param expectedHash - The expected hash value * @returns True if content matches hash after normalization */ export declare function verifyContentIntegrity(content: string, expectedHash: string): boolean; /** * Calculate shard key for memory distribution * Used for distributing memories across multiple files * * SECURITY: Normalizes input to ensure consistent sharding * regardless of Unicode representation * * @param memoryId - The memory ID (will be normalized) * @param shardCount - Number of shards (default 16) * @returns Shard index (0 to shardCount-1) */ export declare function calculateShardKey(memoryId: string, shardCount?: number): number; /** * Parse memory ID to extract timestamp * * @param memoryId - The memory ID to parse * @returns Timestamp or null if invalid format */ export declare function parseMemoryTimestamp(memoryId: string): number | null; //# sourceMappingURL=utils.d.ts.map