Hi dear community. I've been struggling on this E2...
# server-api
p
Hi dear community. I've been struggling on this E2EE problem for hours so I'm turning to you for help! I want to enable voice recording server side with NodeJs on an encrypted (E2EE) conversation. I understand I need to use a server side participant that uses the same shared secret and decrypt the conversation • ✅ I can create clients that use E2EE fine • ❌ but when I use Node participant, I can't initialise the room with E2EE enabled, I get an setup error The doc seems very simple for Node: https://docs.livekit.io/home/client/tracks/encryption/ But it fails. Looking at the src I see the default keyProviderOptions advanced settings get erased by our simple setting object keyProviderOptions
Copy code
const keyProviderOptions = {
  sharedKey: yourSecureKey, // Your externally distributed encryption key
};
I tweaked the source to initialize it correctly but the decrypt doesn't seem to work and I can't debug what is happening. Anyone done something similar or hints? Thanks pals
r
I assume you already looked at the implementation section of the link you shared? https://docs.livekit.io/home/client/tracks/encryption/#implementation-guide What sort of setup errors are you getting?
p
Thx for helping 🙌 Yes I used the implementation section to build the React voice clients (working) and the node.js tab to test the server Nodejs end. I get the following exception below. It seems that the config object recommended in the doc :
Copy code
// 1. Initialize the key provider with options
const keyProviderOptions = {
  sharedKey: yourSecureKey, // Your externally distributed encryption key
};

// 2. Configure E2EE options
const e2eeOptions = {
  keyProviderOptions,
};
will erase some needed encryption parameters in the default keyProviderOptions when processed by the room object here https://github.com/livekit/node-sdks/blob/c4f195aae64653c6b718cd34c19fffbed09c59c8/packages/livekit-rtc/src/room.ts#L177 I tried this fix in room.js and no more exception, but decryption seems to not work properly const e2eeOptions = { ...defaultE2EEOptions }; e2eeOptions.keyProviderOptions.sharedKey = opts.e2ee.keyProviderOptions.sharedKey; const options = { ...defaultRoomOptions, e2ee: e2eeOptions}; EXCEPTION : ❌ Error: Error: cannot encode field livekit.proto.E2eeOptions.encryption_type to binary: required field not set at Object.writeMessage ([...]/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js10131) at _E2eeOptions.toBinary ([...]/node_modules/@bufbuild/protobuf/dist/esm/message.js7513) at writeMessageField ([...]/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js37728) at writeField ([...]/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js31717) at Object.writeMessage ([...]/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js10817) at _RoomOptions.toBinary ([...]/node_modules/@bufbuild/protobuf/dist/esm/message.js7513) at writeMessageField ([...]/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js37728) at writeField ([...]/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js31717) at Object.writeMessage ([...]/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js10817) at _ConnectRequest.toBinary ([...]/node_modules/@bufbuild/protobuf/dist/esm/message.js7513)
Hello guys, any thoughts on this?
r
To enable voice recording on a server-side Node.js participant in an encrypted (E2EE) conversation, you need to ensure that the E2EE options are correctly configured. The error you are encountering suggests that the
E2eeOptions
are not being set up properly, specifically the
encryption_type
field is required but not being set. Here's a breakdown of what you need to do: 1. Ensure All Required Fields are Set: The
E2eeOptions
must include all required fields, including
encryption_type
. It seems that when you are creating the
e2eeOptions
, you are not including the necessary default settings. 2. Modify the Key Provider Options: Instead of directly assigning the
keyProviderOptions
, you should spread the default options and then set the
sharedKey
. This way, you retain any other necessary parameters that might be required for E2EE to function correctly. Here’s an example of how you might set this up: (Note: this code not tested, it was generated by AI)
Copy code
const defaultE2EEOptions = {
  encryption_type: 'your_encryption_type', // Set the appropriate encryption type
  keyProviderOptions: {
    // other default options if necessary
  },
};

const keyProviderOptions = {
  sharedKey: yourSecureKey, // Your externally distributed encryption key
};

const e2eeOptions = { ...defaultE2EEOptions, keyProviderOptions };

const options = {
  ...defaultRoomOptions,
  e2ee: e2eeOptions,
};

// Now create and connect to the room with the options
const room = new Room();
await room.connect(url, token, options);
1. Debugging Decryption Issues: If you have modified the source code and the decryption still does not work, you may want to add logging to see what keys are being used and whether they match between the participants. Ensure that the keys are being set correctly and that the encryption process is functioning as expected. 2. Check for Updates in the SDK: If you are using an older version of the SDK, consider checking for updates or documentation changes that might address your issue. If you continue to face issues, providing more specific details about the decryption process and any errors you encounter would be helpful for further troubleshooting. Notes: • Ensure that the
encryption_type
is set according to the encryption algorithm you are using. • The
sharedKey
must be securely distributed to all participants who need to decrypt the media. • The LiveKit documentation on E2EE provides additional context and examples that may be useful.
p
thanks @refined-appointment-81829, but this doesn't solve the issue : • defaultE2EEOptions and and keyProviderOptions are not exported so we can't get them. I cheated and traced the default configuration for e2eeOptions in room.ts src and hardcoded it for my own e2eeOptions => I can enter the conversation and get the audio flow as a participant, but I get a blank audio : no data. How can I trace if the decryption is happening correctly?
r
Sorry, this is pretty far outside my area of knowledge.
p
Thanks! Anyone with an experience with E2EE on node (or Python) ?