Explaining exact file roles, exported methods, dependencies, and security relevance inside secure E2EE chat modules.
Key System Files
| File Path | Core Exported Functions | Dependencies | Security Relevance |
|---|---|---|---|
| utils/crypto.js | generateKeys(), deriveSharedKey(), encryptGCM(), decryptGCM() | crypto-web-api / Node.js crypto | Provides cryptographic primitives. Ensures standard AES-GCM and Curve25519 usage. |
| controllers/keyManager.js | storePrivateKey(), getDecryptedPrivateKey(), rotateSessionKey() | IndexedDB API, PBKDF2 utilities | Handles secure storage and memory isolation of user key bundles. |
| server/socket.js | initSocketServer(), verifySocketJWT(), handleConnections() | socket.io, jsonwebtoken | Authenticates inbound real-time channels and manages transport namespaces. |
| handlers/messageHandler.js | onSendMessage(), persistPayload(), ackDelivery() | models/Message, socketInstance | Routes encrypted payloads to rooms and saves raw ciphertext metadata. |
| models/Message.js | MessageSchema, indexes | Mongoose ORM / Prisma | Defines database constraints for ciphertext, IV, and authTag. Ensures no plaintext columns. |