matrixlib.devices module

Device-related functionality

class matrixlib.devices.DeviceKeysManager(c: Client, key: bytes)

Manages a device’s keys for end-to-end encryption

Arguments:

c:

the client object

key:

a 32-byte binary used to encrypt the objects in storage

property fingerprint_key: str
property identity_key: str
sign_json(json_object: dict) dict

Sign a JSON object using the device’s signing key

The input object is modified to include the signature.

class matrixlib.devices.DeviceTracker(c: Client)

Tracks user devices to ensure that we’re up to date

Arguments:

c:

the client object

async get_device_keys(users: Iterable[str], force_download=False, timeout: int | None = None) dict[str, dict[str, dict]]

Get the device keys for the given users.

Arguments:

users:

the user IDs to fetch device keys for

force_download:

whether to ignore the cache and force downloading of all device keys from the server

timeout:

a timeout in milliseconds for the homeserver to wait for responses from remote homeservers

Returns a dict mapping the user IDs to a dict with the following keys:

device_keys:

a dict mapping the user’s device IDs to device keys

FIXME: add cross-signing keys

matrixlib.devices.verify_json_ed25519(signature_key: str, user_id: str, device_id: str, json_object: dict) None

Verify a signed JSON object using a public key