auth.bindTempAuthKey #

Binds a temporary authorization key temp_auth_key_id to the permanent authorization key perm_auth_key_id.

For more information, see Perfect Forward Secrecy.

Layer 223

boolFalse#bc799737 = Bool;
boolTrue#997275b5 = Bool;
---functions---
auth.bindTempAuthKey#cdd42a05 perm_auth_key_id:long nonce:long expires_at:int encrypted_message:bytes = Bool;

Parameters #

NameTypeDescription
perm_auth_key_idlongPermanent auth_key_id to bind to
noncelongRandom long from Binding message contents
expires_atintUnix timestamp to invalidate temporary key, see Binding message contents
encrypted_messagebytesSee Generating encrypted_message

Result #

Bool

Generating encrypted_message #

The client begins by creating a special binding message:

Binding message contents #

bind_auth_key_inner#75a3f765 nonce:long temp_auth_key_id:long perm_auth_key_id:long temp_session_id:long expires_at:int = BindAuthKeyInner;
noncelongRandom long
temp_auth_key_idlongTemporary auth_key_id
perm_auth_key_idlongPermanent auth_key_id to bind to
temp_session_idlongSession id, which will be used to invoke auth.bindTempAuthKey method
expires_atintUnix timestamp to invalidate temporary key

Encrypting the binding message #

This binding message is encrypted in the usual way, but with MTProto v1 using the perm_auth_key. In other words, one has to prepend random:int128 (it replaces the customary session_id:long and salt:long that are irrelevant in this case), then append the same msg_id that will be used for the request, a seqno equal to zero, and the correct msg_len (40 bytes in this case); after that, one computes the msg_key:int128 as SHA1 of the resulting string, appends padding necessary for a 16-byte alignment, encrypts the resulting string using the key derived from perm_auth_key and msg_key, and prepends perm_auth_key_id and msg_key to the encrypted data as usual.

Binding #

Once encrypted_message is ready, an auth.bindTempAuthKey request is sent to the server using temp_auth_key and temp_session_id. Don't forget to rewrite client info using initConnection when the binding is completed.

Both users and bots can use this method #

This method can be invoked over an unauthenticated connection » #

Possible errors #

CodeTypeDescription
400ENCRYPTED_MESSAGE_INVALIDEncrypted message invalid.
400EXPIRES_AT_INVALIDThe specified expires_at timestamp is invalid.
400TEMP_AUTH_KEY_ALREADY_BOUNDThe passed temporary key is already bound to another perm_auth_key_id.
400TEMP_AUTH_KEY_EMPTYNo temporary auth key provided.

Perfect Forward Secrecy #

Binding temporary authorization key to permanent ones.

long #

A basic bare type, elements of which correspond to two-element sequences, representing 64-bit signed numbers (little-endian).

int #

A basic bare type, the values of which correspond to single-element sequences, i.e. numbers from -2^31 to 2^31-1 which in this case represent themselves.

Mobile Protocol: Detailed Description #

A description of MTProto 2.0, used by major Telegram clients as of version 4.6.

Calling API Methods #

Additional options for calling methods.

initConnection #

Initialize connection