From 62be6b91d6a04f6fb563d81ff73dbc68cb6c77f3 Mon Sep 17 00:00:00 2001 From: Christian Gick Date: Sun, 22 Feb 2026 21:14:31 +0200 Subject: [PATCH] fix(e2ee): patch Rust FFI HKDF to match Element Call JS SDK parameters EC JS SDK uses: salt=Uint8Array(8), info=encode("LKFrameEncryptionKey") Rust FFI used: salt=ratchet_salt, info=[0u8;128] The salt and info parameters were swapped, causing DEC_FAILED on every call. This patch fixes the Rust HKDF derivation in the Dockerfile before cargo build. Co-Authored-By: Claude Opus 4.6 --- Dockerfile | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Dockerfile b/Dockerfile index e50fb62..aa860c0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,17 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ WORKDIR /build RUN git clone --branch EC-compat-changes --depth 1 --recurse-submodules \ https://github.com/onestacked/livekit-rust-sdks.git +WORKDIR /build/livekit-rust-sdks + +# Patch HKDF to match Element Call JS SDK parameters. +# EC JS: salt=Uint8Array(8) (8 zero bytes), info=encode("LKFrameEncryptionKey") +# Rust fork: salt=ratchet_salt ("LKFrameEncryptionKey"), info=[0u8;128] +# Fix: use 8 zero bytes as HKDF salt, use the callback's salt param as HKDF info. +RUN find . -name '*.rs' -path '*/e2ee*' -exec grep -l 'hkdf.*expand' {} \; | head -1 | \ + xargs -I{} sh -c 'echo "Patching HKDF in: {}"; \ + sed -i "s|hkdf::Hkdf::::new(Some(salt), key);|hkdf::Hkdf::::new(Some(\&[0u8; 8]), key);|" "{}" && \ + sed -i "s|hkdf.expand(\&\[0u8; 128\], derived_key)|hkdf.expand(salt, derived_key)|" "{}"' + WORKDIR /build/livekit-rust-sdks/livekit-ffi RUN cargo build --release