how to enable e2ee on android client and python ag...
# ask-ai
g
how to enable e2ee on android client and python agent?
t
Thanks for reaching out, Oliver. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To enable end-to-end encryption (E2EE) on both the LiveKit Android client and Python agent, follow these steps: Python Agent/Client 1. Configure
E2EEOptions
with your shared key and encryption type:
Copy code
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:
Copy code
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 Docs
g
setSharedKey doesn't seem to work with bytearray on android?
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!
g
python agent
Copy code
room_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
Copy code
app.room.e2eeOptions?.keyProvider?.setSharedKey(sharedKey)
app.room.connect(url, token, ConnectOptions())
sharedKey is "my_shared_key" I get
Copy code
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