miniproto.crypto.mtproto.derive_aes_key_iv
miniproto.crypto.mtproto.derive_aes_key_iv
Section titled “miniproto.crypto.mtproto.derive_aes_key_iv”derive_aes_key_iv(auth_key: bytes, msg_key: bytes, *, client_to_server: bool = True) -> tuple[bytes, bytes]Derive the AES-256 key and 32-byte IGE IV required by MTProto 2.0.
Parameters:
- auth_key (
bytes) – Exactly 256 bytes of authorization-key material. - msg_key (
bytes) – Exactly 16 bytes produced for the same traffic direction. - client_to_server (
bool) – Selects the client-to-server offset by default; set false for server-to-client traffic.
Returns:
Raises:
ValueError– If the authorization key or message key has an invalid length.
Native and fallback implementations are output-compatible. This only derives material; it never transmits or clears the supplied key bytes.