WIP: Fix: Room-based encryption for message sharing between clients #12

Closed
VoxHash wants to merge 18 commits from fix/room-based-encryption into main
VoxHash commented 2025-12-08 02:18:11 -05:00 (Migrated from github.com)

Problem

Users in the same room couldn't read each other's messages. Each client was receiving a unique per-client encryption key, which meant messages encrypted by one client couldn't be decrypted by other clients in the same room.

Solution

Changed the encryption key strategy from per-client keys to room-based keys:

  • All clients in the same room now share the same encryption key
  • Server sends the room key (instead of per-client key) during key exchange
  • Messages encrypted with the room key can be decrypted by all clients in that room

Changes

Server (\cmd_chat/server/server.py)

  • Modified /get_key\ endpoint to return room key instead of per-client key
  • Room keys are shared among all clients in the same room

Client (\cmd_chat/client/)

  • Updated key request to include
    oom_id\ parameter in POST data
  • Clients automatically request new room key when switching rooms
  • Added graceful error handling to skip messages that can't be decrypted

Renderers

  • Added try-except blocks to gracefully handle decryption failures
  • Prevents crashes when encountering messages encrypted with old keys

Testing

Tested with two clients in the same room:

  • Client 1 sends message encrypted with room key
  • Client 2 receives message decrypts successfully with same room key
  • Both clients can read each other's messages

Breaking Changes

Important: Users must restart the server and reconnect clients to get the new room keys. Old messages encrypted with per-client keys will be skipped gracefully (no crash).

  • Fixes issue where users couldn't communicate in the same room
  • Part of v3.2.1 release
  • See CHANGELOG.md for full details
## Problem Users in the same room couldn't read each other's messages. Each client was receiving a unique per-client encryption key, which meant messages encrypted by one client couldn't be decrypted by other clients in the same room. ## Solution Changed the encryption key strategy from per-client keys to room-based keys: - All clients in the same room now share the same encryption key - Server sends the room key (instead of per-client key) during key exchange - Messages encrypted with the room key can be decrypted by all clients in that room ## Changes ### Server (\cmd_chat/server/server.py\) - Modified \/get_key\ endpoint to return room key instead of per-client key - Room keys are shared among all clients in the same room ### Client (\cmd_chat/client/\) - Updated key request to include \ oom_id\ parameter in POST data - Clients automatically request new room key when switching rooms - Added graceful error handling to skip messages that can't be decrypted ### Renderers - Added try-except blocks to gracefully handle decryption failures - Prevents crashes when encountering messages encrypted with old keys ## Testing Tested with two clients in the same room: - Client 1 sends message encrypted with room key - Client 2 receives message decrypts successfully with same room key - Both clients can read each other's messages ## Breaking Changes **Important**: Users must restart the server and reconnect clients to get the new room keys. Old messages encrypted with per-client keys will be skipped gracefully (no crash). ## Related - Fixes issue where users couldn't communicate in the same room - Part of v3.2.1 release - See CHANGELOG.md for full details

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
emilycodestar/cmd-chat!12
No description provided.