Following a single text string "Hello" from User A's terminal keystrokes to User B's screen render.
Step-by-Step Execution Path
Client A Keystroke: User A types "Hello" and presses send. The front-end triggers
sendMessage("Hello", "recipient_uuid").Symmetric Key Lookup: The front-end fetches the 256-bit symmetric session key for the target from local memory.
Encryption: The crypto handler generates 12 random bytes (IV) and encrypts the string "Hello" into a base64 ciphertext (e.g.
+x09jF/3...) and extracts a 16-byte auth tag.Socket Emission: The client emits the packet over a TLS-encrypted WebSocket channel to the node backend.
Backend Interception: The message controller extracts the packet, logs routing metadata, and executes an INSERT query to database to save the ciphertext.
Relay routing: The socket server routes the payload to User B's active socket channel:
socket.to("user_recipient_uuid").emit("receive_message", packet).Decryption: User B's browser triggers the event, retrieves the session key, and executes the WebCrypto GCM decryption. The output string "Hello" is rendered on the viewport.