Major improvements:
- Replaced 226 Chinese comments with clear English equivalents across 16 files
- Backend security files: Complete English documentation for KEK-DEK architecture
- Frontend drag-drop hooks: Full English comments for file operations
- Database routes: English comments for all encryption operations
- Removed V1/V2 version identifiers, unified to single secure architecture
Files affected:
- Backend (11 files): Security session, user/system key managers, encryption operations
- Frontend (5 files): Drag-drop functionality, API communication, type definitions
- Deleted obsolete V1 security files: encryption-key-manager, database-migration
Benefits:
- International developer collaboration enabled
- Professional coding standards maintained
- Technical accuracy preserved for all cryptographic terms
- Zero functional impact, TypeScript compilation and tests pass
🎯 Linus-style simplification: Code now speaks one language - engineering excellence.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Problem Analysis:
- Fixed salt disaster: All same-type fields used identical encryption keys
- Exposed user password KEK protection as completely fake security theater
- System generated random password while claiming user password protection
- 500+ lines of complex migration logic for non-existent backward compatibility
Linus-Style Solutions Applied:
✅ "Delete code > Write code" - Removed 1167 lines of fake complexity
✅ "Complexity is evil" - Eliminated all special cases and migration paths
✅ "Practical solutions" - System auto-starts with secure random keys
✅ "Good taste" - Each field gets unique random salt, true data isolation
Core Changes:
• FIXED: Each encrypted field now gets unique random salt (no more shared keys)
• DELETED: MasterKeyProtection.ts - entire fake KEK protection system
• DELETED: encryption-test.ts - outdated test infrastructure
• SIMPLIFIED: User password = authentication only (honest design)
• SIMPLIFIED: Random master key = data protection (more secure than user passwords)
Security Improvements:
- Random keys have higher entropy than user passwords
- Simpler system = smaller attack surface
- Honest design = clear user expectations
- True field isolation = breaking one doesn't compromise others
Before: Break 1 password → Get all passwords of same type
After: Each field independently encrypted with unique keys
"Theory and practice sometimes clash. Theory loses. Every single time." - Linus
This removes theoretical security theater and implements practical protection.
This commit fixes critical issues with the database encryption system:
**Database Write Operations Fixed:**
- Modified credential creation/update operations to use EncryptedDBOperations
- Fixed SSH data and credential access to properly decrypt data
- All sensitive data writes now go through encryption layer
**Database Schema Migration:**
- Added missing columns (private_key, public_key, detected_key_type) to ssh_credentials table
- Fixed "no such column" SQLite errors during encrypted operations
**Application Startup Order:**
- Fixed DatabaseEncryption initialization timing issues
- Moved encryption-dependent modules to load after encryption initialization
- Prevents "DatabaseEncryption not initialized" errors
**Key Management Improvements:**
- Enhanced EncryptedDBOperations.insert() to return properly decrypted data with all fields
- Fixed TypeScript type issues with database insert operations
- Improved error handling for database encryption context
All credential operations now properly encrypt sensitive data including SSH keys,
passwords, and authentication tokens before writing to database.