miniproto.crypto.native.mtproto_decode_message
miniproto.crypto.native.mtproto_decode_message
Section titled “miniproto.crypto.native.mtproto_decode_message”mtproto_decode_message(auth_key: bytes, packet: BytesLike, *, client_to_server: bool = False) -> tuple[bytes, int, int, int, int, bytes, bytes]Decrypt, authenticate, and parse an MTProto encrypted message.
Parameters:
- auth_key (
bytes) – Exactly 256 bytes of authorization-key material. - packet (
BytesLike) – Packet containing the 8-byte auth-key ID, 16-byte message key, and block-aligned ciphertext. - client_to_server (
bool) – Defaults to false for inbound server-to-client packets.
Returns:
tuple[bytes, int, int, int, int, bytes, bytes]–(auth_key_id, server_salt, session_id, msg_id, seq_no, body, padding).
Raises:
ValueError– If the packet is malformed, keys mismatch, lengths are invalid, or padding violates MTProto 2.0 constraints.
This checks the packet’s auth-key identifier and message key, but transport ordering, replay handling, and message semantics remain the caller’s job.