great-oil-61627
07/22/2025, 4:54 AMtall-airline-16756
07/22/2025, 4:54 AMtall-airline-16756
07/22/2025, 4:55 AME2EEOptions with your shared key and encryption type:
import logging
from livekit import rtc
from livekit.agents import JobContext
async def entrypoint(ctx: JobContext):
e2ee_config = rtc.E2EEOptions(
key_provider_options=rtc.KeyProviderOptions(
shared_key=b"my_shared_key",
),
encryption_type=rtc.EncryptionType.GCM,
)
await ctx.connect(e2ee=e2ee_config)
• All participants must use the same shared key.
• You can manage keys and ratchet them for added security using the e2ee_manager after connecting.
Android Client
1. Create a BaseKeyProvider and E2EEOptions before connecting:
val keyProvider = BaseKeyProvider(
ratchetSalt = "LKFrameEncryptionKey",
magicBytes = "LK-ROCKS",
ratchetWindowSize = 16,
sharedKey = true,
failureTolerance = -1,
keyRingSize = 16,
discardFrameWhenCryptorNotReady = false
)
val e2eeOptions = E2EEOptions(
keyProvider = keyProvider,
encryptionType = Encryption.Type.GCM
)
room.e2eeOptions = e2eeOptions
keyProvider.setSharedKey("your_shared_key".toByteArray())
room.connect(url, token)
• Set the shared key before connecting.
• Key management (enable/disable, ratcheting) is available via the E2EE manager.
Key Management and Security Notes
• You are responsible for securely generating, storing, and distributing encryption keys. LiveKit does not store or transport keys.
• E2EE must be configured before connecting to the room.
• Encryption applies to media tracks (audio/video), not signaling or data messages. Sources: examples/primitives/e2ee.py | livekit-rtc/livekit/rtc/room.py | livekit-android-sdk/src/main/java/io/livekit/android/e2ee/E2EEOptions.kt | End-to-end encryption | LiveKit Docsgreat-oil-61627
07/22/2025, 5:00 AMtall-airline-16756
07/22/2025, 5:01 AMgreat-oil-61627
07/22/2025, 4:41 PMroom_key = base64.b64decode(
<http://requests.post|requests.post>("<http://127.0.0.1:11436/api/server/room-key>", json={"roomName": ctx.room.name}).text)
print(room_key)
await ctx.connect(e2ee=E2EEOptions(key_provider_options=KeyProviderOptions(shared_key=room_key)))
room_key is b'my_shared_key'
kotlin client
app.room.e2eeOptions?.keyProvider?.setSharedKey(sharedKey)
app.room.connect(url, token, ConnectOptions())
sharedKey is "my_shared_key"
I get
2025-07-22 12:32:56.914 3372-3405 E2EEManager ai.mytelo.voiceassistant I Sender::onFrameCryptionStateChanged: abcd, state: OK
2025-07-22 12:32:57.824 3372-3405 E2EEManager ai.mytelo.voiceassistant I Receiver::onFrameCryptionStateChanged: agent-AJ_hfwePmsXZA5U, state: DECRYPTIONFAILED