fix: Switch E2EE to per-participant keys instead of shared key

Element Call uses per-participant keys, not shared key mode.
Bot now generates its own key, publishes it, and sets both
keys via key_provider.set_key() after connecting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Christian Gick
2026-02-22 06:41:20 +02:00
parent ced2783a09
commit b65d04389b
2 changed files with 59 additions and 29 deletions

12
bot.py
View File

@@ -448,12 +448,9 @@ class Bot:
model = self.room_models.get(room_id, DEFAULT_MODEL)
caller_device_id = content.get("device_id", "")
# Publish a placeholder key first to trigger Element Call
# to share its key with us. We'll republish the real shared
# key once we receive the caller's key.
# Generate bot's own E2EE key (16 bytes like Element Call)
import secrets
placeholder_key = secrets.token_bytes(16)
await self._publish_encryption_key(room_id, placeholder_key)
bot_key = secrets.token_bytes(16)
vs = VoiceSession(
nio_client=self.client,
@@ -461,8 +458,9 @@ class Bot:
device_id=BOT_DEVICE_ID,
lk_url=LK_URL,
model=model,
publish_key_cb=lambda key: asyncio.ensure_future(
self._publish_encryption_key(room_id, key)),
bot_key=bot_key,
publish_key_cb=lambda key, rid=room_id: asyncio.ensure_future(
self._publish_encryption_key(rid, key)),
)
# Check timeline for caller's key