Expand description
sew-e2ee: the reference client library for end-to-end encrypted Sew calls.
Every Sew call is end-to-end encrypted. The keys exist only on participant devices (and, when a call is recorded, on the recorder the members admit), agreed with MLS (RFC 9420, openmls 0.9.0), and are fed into the LiveKit SDKs’ own frame encryption. This crate is that protocol, written once:
- Identity (
identity,trust,store): the P-256 device key interface (DeviceSigner), device certificates from the server’s call CA, the call credential (SewCallIdentityv2, scopecall:<channel_id>), the DS-signedLeafBindingtable, TOFU pins and the CRL. - Joining (
E2eeClient,PendingKp,PreparedKp): key packages made offline, uploaded for a single-usekey_package_ref, claimed by the voice join or the key join. - The call (
CallSession): a sans-IO state machine — per-sender keys from the MLS exporter by leaf index, slots(slot_base + e) mod 64, the two-phase install → ready → activate switch, retirement after 10 s, recovery without user action, the recorder release. - Bridges (
bridge): theKeyEventcontract every SDK bridge applies, theKeyRingshadow andCaps(and, with thetestingfeature only, the simulated SDKbridge::virtual_sdk::VirtualSdk). - The recorder side (
recorder):ReleaseOpener,RecorderKeyPair,identity::verify_tablefor the recorder;open_recording_chunkfor the admin download.
Sans-IO: no IO, no clock, no threads, no Send requirement. The host wires a session to its
own HTTP client and gateway connection: sew-call-client is a complete native host, and
Sew’s WASM build for browsers (@sew/e2ee) wraps it too (not published here).
The testing feature (an in-process delivery service model, a simulated SDK, test
certificates and crafted protocol messages) is for tests only: it is unstable and not covered
by semver, it exposes secret key material, and it builds malicious protocol messages. Never
enable it outside tests.
Re-exports§
pub use bridge::Caps;pub use bridge::KeyEvent;pub use bridge::KeyRing;pub use bridge::KeySink;pub use bridge::SinkAck;pub use bridge::SinkError;pub use chunk::ChunkLayout;pub use chunk::open_recording_chunk;pub use chunk::recording_chunk_layout;pub use code::SecurityCode;pub use config::E2eeConfig;pub use config::Params;pub use error::BindingError;pub use error::ChunkError;pub use error::DecodeError;pub use error::IdentityError;pub use error::JoinError;pub use error::ReleaseError;pub use error::SessionError;pub use error::TrustError;pub use identity::DeviceIdentity;pub use identity::DeviceSigner;pub use identity::EnrollAction;pub use identity::EnrollDraft;pub use identity::Enrollment;pub use identity::SignRequest;pub use identity::SoftwareSigner;pub use identity::VerifiedTable;pub use identity::verify_table;pub use ids::Epoch;pub use ids::FenceId;pub use ids::MemberId;pub use ids::Millis;pub use ids::RecordingId;pub use ids::RequestId;pub use ids::SignId;pub use ids::Slot;pub use ids::UnixMs;pub use keypackage::E2eeClient;pub use keypackage::PendingKp;pub use keypackage::PreparedKp;pub use keys::FrameIkm;pub use keys::ikm_context;pub use keys::lk_frame_key;pub use recorder::RecorderKeyPair;pub use recorder::ReleaseOpener;pub use recorder::Released;pub use roster::MediaLabel;pub use roster::RosterEntry;pub use roster::RosterState;pub use session::CallSession;pub use session::Counters;pub use session::E2eeStatus;pub use session::EngineMisbehaviour;pub use session::Input;pub use session::LeftReason;pub use session::Output;pub use session::SessionState;pub use session::Transition;pub use session::UndecryptReason;pub use session::UnknownCallBuffer;pub use store::DeviceStore;pub use store::MemoryDeviceStore;pub use store::Pins;pub use store::StoredDevice;pub use trust::TrustAnchors;pub use wire::ApiFailure;pub use wire::KeyReply;pub use wire::KeyRequest;
Modules§
- bridge
- The key-provider bridge contract.
- chunk
open_recording_chunk: for the admin download of an encrypted recording.- code
- The 30-digit security code: derived from the active epoch’s
epoch_authenticator()(RFC 9420 §8.7). Six groups of five digits: groupiis the big-endian integer of authenticator bytes[5i, 5i+5)mod 100,000, zero-padded. Identical on every member of one active epoch; changes every epoch; never modal; not secret, but never logged. - config
- Configuration, labels and limits.
- error
- Typed errors. No error ever holds key material: variants carry ids, epochs, slots, sizes and short static reasons only.
- identity
- Device identity, certificates, the call credential and the binding table.
- ids
- Ids and small value types. The string names (
r_…room, 32-hex join id,p_…engine identity) aresew_proto::e2ee’s types, re-exported under the names this crate’s API uses; the slot formula and the labels come fromsew_proto::e2ee::tls. - keypackage
- Key packages: made offline when the channel view opens
or a ring arrives, signed by the device key, uploaded for a single-use
key_package_ref, then claimed by the voice join or the key join (a move). - keys
- Per-sender frame keys.
- provider
CallProvider: sew-mls-crypto’sMlsCrypto(openmls’ crypto traits, HPKE without hpke-rs) with an in-memory store that is zeroized on drop.- recorder
- The recorder key handoff.
- roster
- The roster: built from the verified MLS tree only. The engine’s participant list is used by the app for media state only.
- session
CallSession: the per-call state machine.- store
- What persists: the device’s certificate and ids, and the TOFU pins of the
install’s CA key, DS key and
external_senderbytes. Nothing about a call is ever written (an app restart mid-call goes through the missed-epoch path). - trust
- Trust anchors: the install’s CA and DS keys, the
external_senderbytes and the CRL (READYcall_keys). - wire
- The key routes a session drives: this crate’s enums over
sew_proto::e2eerequest and response types, and the failure shape the driver feeds back.
Structs§
- Id
- A Sew entity id. Invariant:
1 ..= i64::MAX. - JoinId
- A Sew-minted join id: 32 lowercase hex characters (16 random bytes).
- LkIdentity
- An engine identity:
p_+ 26 base32 characters of the join id. - Room
Name - A call’s
call_id: its engine room,r_+ 26 base32 characters (random per call).
Enums§
- Consent
- A member’s consent for one recording (the key service’s
ConsentSource).
Type Aliases§
- Scope
- The call scope: always
call:<channel_id>(voice channels and DM calls alike). It has one constructor and no empty form.