Skip to content

MSC4195: MatrixRTC Transport using LiveKit Backend#4195

Open
hughns wants to merge 24 commits intomatrix-org:mainfrom
hughns:hughns/matrixrtc-livekit
Open

MSC4195: MatrixRTC Transport using LiveKit Backend#4195
hughns wants to merge 24 commits intomatrix-org:mainfrom
hughns:hughns/matrixrtc-livekit

Conversation

@hughns
Copy link
Copy Markdown
Member

@hughns hughns commented Sep 16, 2024

Rendered

Implementation

Dependencies:

To-do:

  • Define error responses for POST /get_token

@hughns hughns changed the title MatrixRTC using LiveKit backend MSC4195: MatrixRTC using LiveKit backend Sep 16, 2024
@turt2live turt2live added voip proposal A matrix spec change proposal client-server Client-Server API kind:core MSC which is critical to the protocol's success needs-implementation This MSC does not have a qualifying implementation for the SCT to review. The MSC cannot enter FCP. labels Sep 25, 2024
@hughns hughns force-pushed the hughns/matrixrtc-livekit branch from 054a23c to 6072744 Compare December 17, 2024 07:22

The homeserver restriction could be applied by checking the `matrix_server_name` field of the OpenID token before validating the token.

The `room_id` could be validated too, and checking that the Matrix user from the OpenID token is a member of the room.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

From my understanding there's no API that allows room_id validation. Without that implementing access control in a federated environment seems infeasible however.

Given that all members in a session use one SFU via oldest_membership, just validating against matrix_server_name (authenticated using TLS / OpenID) would require allowlisting any server that users might want to join from.

Ideally access control could check either for an allowlisted server or for an existing session with the oldest member being on an allowlisted server, gating an SFU to sessions being started by their "own" users.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The implementation in element-hq/lk-jwt-service#67 does allow limiting creation of new SFU rooms based on servers in a given allowlist, but still allows arbitrary users to join

Copy link
Copy Markdown

@networkException networkException Dec 8, 2025

Choose a reason for hiding this comment

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

With the context provided in element-hq/synapse#18967, I believe we can do better by not using ID tokens or a lk-jwt-service altogether.

Instead of a client authenticating against all remote SFUs using an ID token, an extended /transports Client-Server API can return matching credentials, obtained by the user's homeserver over federation. This removes the need for the somewhat bespoke ID token mechanism (which needs to do server name lookup over HTTP and DNS as a fallback. By design that also doesn't play nicely with MAS and OIDC native Matrix), reusing existing server to server authentication. Crucially, this allows for proper per-room tokens.

@ara4n ara4n added the matrix-2.0 Required for Matrix 2.0 label Sep 5, 2025
@github-project-automation github-project-automation bot moved this to Tracking for review in Spec Core Team Workflow Sep 5, 2025
@fkwp fkwp changed the title MSC4195: MatrixRTC using LiveKit backend MSC4195: MatrixRTC Transport using LiveKit Backend Oct 14, 2025
@fkwp fkwp marked this pull request as ready for review October 14, 2025 13:16
Comment on lines +362 to +375
End-to-end encryption is mapped into the LiveKit frame level encryption mechanism described
[here](https://github.com/livekit/livekit/issues/1035).

Where a shared password is used by the application it is used as the `string` input to the LiveKit
key derivation function (which uses PBKDF2) and all participants use the same derived key for
encryption and decryption.

Where a per-participant key is used it is imported as the byte array input to the LiveKit key
derivation function (which uses HKDF). The `index` field of the `m.rtc.encryption_keys` event is
used as the key index for the key provider.

On receipt of the `m.rtc.encryption_keys` event the application can associate the received key with
the LiveKit participant identity by calculating the pseudonymous LiveKit participant identity as
described above.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would like more details on how to implement this.
I've been trying to get it to work in matrix-jukebox, but had no success in getting compatibility with Element Call.
(I'm implementing the old version of the spec without slots and multiSFU for now)

@turt2live turt2live added 00-weekly-pings Tracking for weekly pings in the SCT office. 00 to make it first in the labels list. and removed needs-implementation This MSC does not have a qualifying implementation for the SCT to review. The MSC cannot enter FCP. labels Jan 30, 2026
@turt2live turt2live moved this from Tracking for review to Proposed for FCP readiness in Spec Core Team Workflow Jan 30, 2026
encryption and decryption.

Where a per-participant key is used it is imported as the byte array input to the LiveKit key
derivation function (which uses HKDF). The `index` field of the `m.rtc.encryption_keys` event is
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It seems like multiple LiveKit SDKs (Rust, Flutter) only support using PBKDF2, so using HKDF here is going to limit compatibility with non-web based clients out of the box

See:
livekit/rust-sdks#796
livekit/client-sdk-flutter#974

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This also affects the SDKs using Rust-FFI (like python and maybe others)

@turt2live turt2live added blocked Something needs to be done before action can be taken on this PR/issue. and removed 00-weekly-pings Tracking for weekly pings in the SCT office. 00 to make it first in the labels list. labels Feb 10, 2026
@turt2live
Copy link
Copy Markdown
Member

This is blocked on MSC4143's block: #4143 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked Something needs to be done before action can be taken on this PR/issue. client-server Client-Server API kind:core MSC which is critical to the protocol's success matrix-2.0 Required for Matrix 2.0 proposal A matrix spec change proposal voip

Projects

Status: Proposed for FCP readiness

Development

Successfully merging this pull request may close these issues.

9 participants