Skip to content

miniproto.auth.key_exchange.AuthKeyExchange

miniproto.auth.key_exchange.AuthKeyExchange

Section titled “miniproto.auth.key_exchange.AuthKeyExchange”
AuthKeyExchange(transport: AuthKeyTransport, *, dc_id: int, rsa_keys: tuple[RSAKey, ...], test_mode: bool = False, random_bytes: Callable[[int], bytes] | None = None) -> None

Perform Telegram’s RSA- and DH-protected MTProto authorization handshake.

Parameters:

  • transport (AuthKeyTransport) – Unencrypted transport connected to the selected data center.
  • dc_id (int) – Logical Telegram DC identifier to authorize.
  • rsa_keys (tuple[RSAKey, …]) – Trusted Telegram RSA public keys for the selected environment.
  • test_mode (bool) – Encode positive DC IDs for Telegram’s test environment when true.
  • random_bytes (Callable[[int], bytes] | None) – Cryptographically secure random-byte source; defaults to :func:os.urandom.

Validate trusted keys and initialize exchange-specific dependencies.

Parameters:

  • transport (AuthKeyTransport) – Connected capability used to send unencrypted handshake requests.
  • dc_id (int) – Logical Telegram data-center ID to authorize.
  • rsa_keys (tuple[RSAKey, …]) – Trusted public keys eligible for server fingerprint selection.
  • test_mode (bool) – Encode positive DC IDs for Telegram’s test environment when true.
  • random_bytes (Callable[[int], bytes] | None) – Optional secure random-byte source; defaults to :func:os.urandom.

Raises:

  • ValueError – If no trusted Telegram RSA key was supplied.