Skip to content

Make KeyProvider and ParticipantKeyHandler work consistently for shared key and sender key scenarios (e2ee) - #850

Merged
lukasIO merged 7 commits into
mainfrom
lukas/e2ee-fixes
Aug 24, 2023
Merged

lukasIO merged 7 commits into
mainfrom
lukas/e2ee-fixes

Conversation

@lukasIO

@lukasIO lukasIO commented Aug 23, 2023 •

Copy link
Copy Markdown
Contributor

main motivation for these fixes was an inconsistency in setting the local participant's keys, which expected the participantId to be undefined. This caused a bug when trying to set individual sender keys instead of using a shared-key provider.
Initially this was done because when setKey on a KeyProvider was called, we had no way of figuring out whether or not that participant is actually the local participant, until we're connected to the server and have the participant identity info.

This PR

  • replaces strings with dedicated event enums in e2ee event emitters
  • introduces a enabledEncryptionMap that tracks whether or not encryption is enabled for a specific participant (previously this was handled as part of the ParticipantKeyHandler)
  • updates local participant encryption keys on SignalConnected (the earliest we know the identity without manually parsing the token)
  • introduces a dedicated initAck worker message in order not to have to mis-use the existing enable message for that purpose
  • uses a dedicated sharedKeyHandler that handles all key interactions when sharedKey is set to true. Previously an instance was created for each participant, but in the shared key scenario that makes less sense. the only downside is that ratcheting doesn't work independently now, but I don't really see a reason in the shared key scenario for ratcheting anyways.

@changeset-bot

changeset-bot Bot commented Aug 23, 2023 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ff4e6a5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
livekit-client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Aug 23, 2023 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
dist/livekit-client.esm.mjs 76.24 KB (0%)
dist/livekit-client.umd.js 81.69 KB (0%)

@lukasIO
lukasIO marked this pull request as ready for review August 23, 2023 16:20
@lukasIO lukasIO changed the title e2ee fixes [e2ee] Make KeyProvider and ParticipantKeyHandler work consistently for shared key and sender key scenarios Aug 23, 2023

@davidzhao davidzhao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lg!

Comment thread src/e2ee/E2eeManager.ts Resolved
Comment thread src/room/Room.ts
this.e2eeManager.setParticipantCryptorEnabled(enabled),
]);
await Promise.all([this.localParticipant.setE2EEEnabled(enabled)]);
if (this.localParticipant.identity !== '') {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good to be safe here. could this this be true?

@lukasIO lukasIO Aug 24, 2023 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

localParticipant.identity gets initialized with an empty string on room creation. As long as we don't know the actual identity, it doesn't make sense to enable the cryptor with a wrong/dummy identity. We do however use the most recent setting for localParticipant.isE2EEEnabled on SignalConnected now to enable the cryptor once we know the local participant's identity.

@lukasIO lukasIO changed the title [e2ee] Make KeyProvider and ParticipantKeyHandler work consistently for shared key and sender key scenarios Make KeyProvider and ParticipantKeyHandler work consistently for shared key and sender key scenarios (e2ee) Aug 24, 2023
@lukasIO
lukasIO merged commit d399413 into main Aug 24, 2023
@lukasIO
lukasIO deleted the lukas/e2ee-fixes branch August 24, 2023 14:00
@github-actions github-actions Bot mentioned this pull request Aug 24, 2023
afgarcia86 pushed a commit to afgarcia86/client-sdk-js that referenced this pull request Mar 19, 2026
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants