miniproto.crypto.mtproto.message_key
miniproto.crypto.mtproto.message_key
Section titled “miniproto.crypto.mtproto.message_key”message_key(auth_key: bytes, plaintext_with_padding: BytesLike, *, client_to_server: bool = True) -> bytesDerive the 16-byte MTProto 2.0 message key.
Parameters:
- auth_key (
bytes) – Exactly 256 bytes of authorization-key material. - plaintext_with_padding (
BytesLike) – Complete plaintext including valid MTProto padding. - client_to_server (
bool) – Uses the client-to-server offset when true (the default); false selects the server-to-client offset.
Returns:
bytes– The direction-bound message key used for AES key and IV derivation.
Raises:
ValueError– Ifauth_keyhas an invalid length.
This deterministic derivation does not validate the supplied padding; use
:func:encrypt_payload to create a complete encrypted payload.