Skip to content
  • Message Journey · Cryptography

Message Journey

LearnViaNotes @learnvianotes· 1 min read

Following a single text string "Hello" from User A's terminal keystrokes to User B's screen render.

Step-by-Step Execution Path

  1. Client A Keystroke: User A types "Hello" and presses send. The front-end triggers sendMessage("Hello", "recipient_uuid").

  2. Symmetric Key Lookup: The front-end fetches the 256-bit symmetric session key for the target from local memory.

  3. 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.

  4. Socket Emission: The client emits the packet over a TLS-encrypted WebSocket channel to the node backend.

  5. Backend Interception: The message controller extracts the packet, logs routing metadata, and executes an INSERT query to database to save the ciphertext.

  6. Relay routing: The socket server routes the payload to User B's active socket channel: socket.to("user_recipient_uuid").emit("receive_message", packet).

  7. 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.

Free for students and teachers

Write notes like this one

Cards for every idea, quizzes and flashcards, read aloud — on the web and your phone.

Something wrong with this note? Open it to report