From 2edb01fc2a60c0bc20cb2ed69f155a5860712b4b Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Wed, 28 Jun 2023 19:44:28 +0000 Subject: [PATCH] Update content of files --- .../mtproto/samples-auth_key.html | 1116 ++++++----------- 1 file changed, 392 insertions(+), 724 deletions(-) diff --git a/data/web/corefork.telegram.org/mtproto/samples-auth_key.html b/data/web/corefork.telegram.org/mtproto/samples-auth_key.html index 0aa4aafcc3..2228ecdc1e 100644 --- a/data/web/corefork.telegram.org/mtproto/samples-auth_key.html +++ b/data/web/corefork.telegram.org/mtproto/samples-auth_key.html @@ -44,470 +44,267 @@ For example, for the abridged version of the transport », the…">

samples-auth_key

-

+

In the examples below, the transport headers are omitted:

For example, for the abridged version of the transport », the client sends 0xef as the first byte (important: only prior to the very first data packet), then the packet length is encoded with a single byte (0x01-0x7e = data length divided by 4; or 0x7f followed by 3 bytes (little endian) divided by 4) followed by the data itself. In this case, server responses have the same structure (although the server does not send 0xefas the first byte).

Detailed documentation on creating authorization keys is available here ».

-

1. request req_pq_multi

+

1. request req_pq_multi

-

Sent payload (excluding transport headers/trailers):

-
0000 | 00 00 00 00 00 00 00 00 00 00 00 00 26 8A 9C 64
-0010 | 14 00 00 00 F1 8E 7E BE FC B5 7C 8A 19 24 E6 2D
-0020 | B2 2C FC 63 91 60 82 0A
-

Payload serialization:

-
req_pq_multi#be7e8ef1 nonce:int128 = ResPQ;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterOffset, Length in bytesValueDescription
auth_key_id0, 80x00000000000000000 since the message is in plain text
message_id8, 80x00000000268a9c64Exact unixtime*2^32, +(4*N) if N messages with the same message ID were already generated
message_length16, 40x14000000 (20 in decimal)Message body length
%(req_pq_multi)20, 40xf18e7ebereq_pq_multi constructor number from TL schema
nonce24, 160xFCB57C8A1924E62DB22CFC639160820ARandom number
+Sent payload (excluding transport headers/trailers): +``` +0000 | 00 00 00 00 00 00 00 00 00 00 00 00 B8 8A 9C 64 +0010 | 14 00 00 00 F1 8E 7E BE 11 A6 CF 5E 75 A0 49 3C +0020 | 2B 49 CC E8 13 A9 81 7F +``` + +Payload serialization: +``` +req_pq_multi#be7e8ef1 nonce:int128 = ResPQ; +``` + +| Parameter | Offset, Length in bytes | Value | Description | +| --- | --- | --- | --- | +| auth\_key\_id | 0, 8 | `0x0000000000000000` | 0 since the message is in plain text | +| message\_id | 8, 8 | `0x00000000b88a9c64` | Exact `unixtime*2^32`, `+(4*N)` if N messages with the same message ID were already generated | +| message\_length | 16, 4 | `0x14000000` (20 in decimal) | Message body length | +| %(req\_pq\_multi) | 20, 4 | `0xf18e7ebe` | *req_pq_multi* constructor number from TL schema | +| nonce | 24, 16 | `0x11A6CF5E75A0493C2B49CCE813A9817F` | Random number | -

2. response respq

+ + + +

2. response respq

-

Received payload (excluding transport headers/trailers):

-
0000 | 00 00 00 00 00 00 00 00 01 4C 8A 2E 26 8A 9C 64
-0010 | 7C 00 00 00 63 24 16 05 FC B5 7C 8A 19 24 E6 2D
-0020 | B2 2C FC 63 91 60 82 0A 19 50 DF 44 0D 63 0B 94
-0030 | 1A 82 75 96 97 64 95 86 08 1B F6 DB 97 4F 6C 64
-0040 | 8B 00 00 00 15 C4 B5 1C 03 00 00 00 A5 B7 F7 09
+Received payload (excluding transport headers/trailers):
+```
+0000 | 00 00 00 00 00 00 00 00 01 24 DE 7C B8 8A 9C 64
+0010 | C4 00 00 00 63 24 16 05 11 A6 CF 5E 75 A0 49 3C
+0020 | 2B 49 CC E8 13 A9 81 7F 6E C1 8F 2E E4 4F 91 85
+0030 | BB DF D1 30 9C 7E 94 C3 08 1C 9C F4 0A A2 23 3D
+0040 | A7 00 00 00 15 C4 B5 1C 03 00 00 00 A5 B7 F7 09
 0050 | 35 5F C3 0B 21 6B E8 6C 02 2B B4 C3 85 FD 64 DE
-0060 | 85 1D 9D D0
-

Payload serialization:

-
resPQ#05162463 nonce:int128 server_nonce:int128 pq:string server_public_key_fingerprints:Vector<long> = ResPQ;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterOffset, Length in bytesValueDescription
auth_key_id0, 80x00000000000000000 since the message is in plain text
message_id8, 80x014c8a2e268a9c64Exact unixtime*2^32, +(4*N) if N messages with the same message ID were already generated
message_length16, 40x7c000000 (124 in decimal)Message body length
%(resPQ)20, 40x63241605resPQ constructor number from TL schema
nonce24, 160xFCB57C8A1924E62DB22CFC639160820AValue generated by client in Step 1
server_nonce40, 160x1950DF440D630B941A82759697649586Server-generated random number
pq56, 120x081BF6DB974F6C648B000000 (TL byte deserialization => bigendian conversion to decimal => 2015039326213923979)Single-byte prefix denoting length, an 8-byte string, and three bytes of padding
%(Vector long)68, 40x15c4b51cVector t constructor number from TL schema
count72, 40x03000000Number of elements in server_public_key_fingerprints
server_public_key_fingerprints[0]76, 80xA5B7F709355FC30B64 lower-order bits of SHA1(server_public_key)
server_public_key_fingerprints[1]84, 80x216BE86C022BB4C364 lower-order bits of SHA1(server_public_key)
server_public_key_fingerprints[2]92, 80x85FD64DE851D9DD064 lower-order bits of SHA1(server_public_key)
+0060 | 85 1D 9D D0 +``` + +Payload serialization: +``` +resPQ#05162463 nonce:int128 server_nonce:int128 pq:string server_public_key_fingerprints:Vector = ResPQ; +``` + +| Parameter | Offset, Length in bytes | Value | Description | +| --- | --- | --- | --- | +| auth\_key\_id | 0, 8 | `0x0000000000000000` | 0 since the message is in plain text | +| message\_id | 8, 8 | `0x0124de7cb88a9c64` | Exact `unixtime*2^32`, `+(4*N)` if N messages with the same message ID were already generated | +| message\_length | 16, 4 | `0xc4000000` (196 in decimal) | Message body length | +| %(resPQ) | 20, 4 | `0x63241605` | *resPQ* constructor number from TL schema | +| nonce | 24, 16 | `0x11A6CF5E75A0493C2B49CCE813A9817F` | Value generated by client in Step 1 | +| server\_nonce | 40, 16 | `0x6EC18F2EE44F9185BBDFD1309C7E94C3` | Server-generated random number | +| pq | 56, 12 | `0x081C9CF40AA2233DA7000000` (TL byte deserialization => bigendian conversion to decimal => 2061791055935913383) | Single-byte prefix denoting length, an 8-byte string, and three bytes of padding | +| %(Vector long) | 68, 4 | `0x15c4b51c` | *Vector t* constructor number from TL schema | +| count | 72, 4 | `0x03000000` | Number of elements in server_public_key_fingerprints | +| server\_public\_key\_fingerprints[0] | 76, 8 | `0xA5B7F709355FC30B` | 64 lower-order bits of `SHA1(server_public_key)` | +| server\_public\_key\_fingerprints[1] | 84, 8 | `0x216BE86C022BB4C3` | 64 lower-order bits of `SHA1(server_public_key)` | +| server\_public\_key\_fingerprints[2] | 92, 8 | `0x85FD64DE851D9DD0` | 64 lower-order bits of `SHA1(server_public_key)` | +

In our case, the client only has the following public keys, with the following fingerprints:

-
    -
  • 0x85FD64DE851D9DD0
  • -
-

Let's choose the only matching key, the one with fingerprint equal to 0x0x85FD64DE851D9DD0.

+* `0x85FD64DE851D9DD0` + +Let's choose the only matching key, the one with fingerprint equal to `0x0x85FD64DE851D9DD0`. -

2.1. decompose p and q

+ + + +

2.1. decompose p and q

-
pq = 2015039326213923979
-

Decompose into 2 prime cofactors: 1083870727 * 1859114077 = 2015039326213923979

-
p = 1083870727
-q = 1859114077
+``` +pq = 2061791055935913383 +``` +Decompose into 2 prime cofactors: `1363826801 * 1511768983 = 2061791055935913383` +``` +p = 1363826801 +q = 1511768983 +``` + -

2.2. encrypted_data generation

+ + + +

2.2. encrypted_data generation

-

Generated payload (excluding transport headers/trailers):

-
0000 | 95 5F F5 A9 08 1B F6 DB 97 4F 6C 64 8B 00 00 00
-0010 | 04 40 9A 8E 07 00 00 00 04 6E CF D4 5D 00 00 00
-0020 | FC B5 7C 8A 19 24 E6 2D B2 2C FC 63 91 60 82 0A
-0030 | 19 50 DF 44 0D 63 0B 94 1A 82 75 96 97 64 95 86
-0040 | 42 BE 51 23 68 86 D9 3B E2 61 F2 F7 50 29 CE 88
-0050 | 85 B7 23 7E 83 87 7E 36 27 B4 EC 8E 38 80 0F C9
-0060 | 02 00 00 00
-

Payload serialization:

-
p_q_inner_data_dc#a9f55f95 pq:string p:string q:string nonce:int128 server_nonce:int128 new_nonce:int256 dc:int = P_Q_inner_data;
+Generated payload (excluding transport headers/trailers):
+```
+0000 | 95 5F F5 A9 08 1C 9C F4 0A A2 23 3D A7 00 00 00
+0010 | 04 51 4A 58 71 00 00 00 04 5A 1B C3 97 00 00 00
+0020 | 11 A6 CF 5E 75 A0 49 3C 2B 49 CC E8 13 A9 81 7F
+0030 | 6E C1 8F 2E E4 4F 91 85 BB DF D1 30 9C 7E 94 C3
+0040 | 9E CB D3 D2 DD E2 5C 7F B4 17 AA CA FA 53 8E BA
+0050 | C2 2F 4C 73 80 1A 9A 82 D6 E4 F3 1B 73 85 ED E7
+0060 | 02 00 00 00
+```
+
+Payload serialization:
+```
+p_q_inner_data_dc#a9f55f95 pq:string p:string q:string nonce:int128 server_nonce:int128 new_nonce:int256 dc:int = P_Q_inner_data;
 p_q_inner_data_temp_dc#56fddf88 pq:string p:string q:string nonce:int128 server_nonce:int128 new_nonce:int256 dc:int expires_in:int = P_Q_inner_data;
 p_q_inner_data#83c95aec pq:string p:string q:string nonce:int128 server_nonce:int128 new_nonce:int256 = P_Q_inner_data;
-p_q_inner_data_temp#3c6a84d4 pq:string p:string q:string nonce:int128 server_nonce:int128 new_nonce:int256 expires_in:int = P_Q_inner_data;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterOffset, Length in bytesValueDescription
%(p_q_inner_data_dc)0, 40x955ff5a9p_q_inner_data_dc constructor number from TL schema
pq4, 120x081BF6DB974F6C648B000000 (TL byte deserialization => bigendian conversion to decimal => 2015039326213923979)Single-byte prefix denoting length, 8-byte string, and three bytes of padding
p16, 80x04409A8E07000000 (TL byte deserialization => bigendian conversion to decimal => 1083870727)First prime cofactor: single-byte prefix denoting length, 4-byte string, and three bytes of padding
q24, 80x046ECFD45D000000 (TL byte deserialization => bigendian conversion to decimal => 1859114077)Second prime cofactor: single-byte prefix denoting length, 4-byte string, and three bytes of padding
nonce32, 160xFCB57C8A1924E62DB22CFC639160820AValue generated by client in Step 1
server_nonce48, 160x1950DF440D630B941A82759697649586Value received from server in Step 2
new_nonce64, 320x42BE51236886D93BE261F2F75029CE8885B7237E83877E3627B4EC8E38800FC9Client-generated random number
dc96, 40x02000000 (2 in decimal)DC ID: 10000 (decimal) has to be added to the DC ID to connect to the test servers; it has to be made negative if the DC we're connecting to is a media (not CDN) DC.
+p_q_inner_data_temp#3c6a84d4 pq:string p:string q:string nonce:int128 server_nonce:int128 new_nonce:int256 expires_in:int = P_Q_inner_data; +``` + +| Parameter | Offset, Length in bytes | Value | Description | +| --- | --- | --- | --- | +| %(p\_q\_inner\_data\_dc) | 0, 4 | `0x955ff5a9` | *p_q_inner_data_dc* constructor number from TL schema | +| pq | 4, 12 | `0x081C9CF40AA2233DA7000000` (TL byte deserialization => bigendian conversion to decimal => 2061791055935913383) | Single-byte prefix denoting length, 8-byte string, and three bytes of padding | +| p | 16, 8 | `0x04514A5871000000` (TL byte deserialization => bigendian conversion to decimal => 1363826801) | First prime cofactor: single-byte prefix denoting length, 4-byte string, and three bytes of padding | +| q | 24, 8 | `0x045A1BC397000000` (TL byte deserialization => bigendian conversion to decimal => 1511768983) | Second prime cofactor: single-byte prefix denoting length, 4-byte string, and three bytes of padding | +| nonce | 32, 16 | `0x11A6CF5E75A0493C2B49CCE813A9817F` | Value generated by client in Step 1 | +| server\_nonce | 48, 16 | `0x6EC18F2EE44F9185BBDFD1309C7E94C3` | Value received from server in Step 2 | +| new\_nonce | 64, 32 | `0x9ECBD3D2DDE25C7FB417AACAFA538EBAC22F4C73801A9A82D6E4F31B7385EDE7` | Client-generated random number | +| dc | 96, 4 | `0x02000000` (2 in decimal) | DC ID: `10000` (decimal) has to be added to the DC ID to connect to the test servers; it has to be made negative if the DC we're connecting to is a media (not CDN) DC. | -

The serialization of P_Q_inner_data produces data, which is used to generate encrypted_data as specified in step 4.1.
-These are the inputs to the algorithm specified in step 4.1:

+ +

The serialization of P_Q_inner_data produces data, which is used to generate encrypted_data as specified in step 4.1.
These are the inputs to the algorithm specified in step 4.1:

-
data = 0x955FF5A9081BF6DB974F6C648B00000004409A8E07000000046ECFD45D000000FCB57C8A1924E62DB22CFC639160820A1950DF440D630B941A8275969764958642BE51236886D93BE261F2F75029CE8885B7237E83877E3627B4EC8E38800FC902000000
-random_padding_bytes = 0xC76F6E64DD5720EACBD95D8252BE2ECEA94A95E4B90462634209E1004C9CB2075334B8A3226DDA5C7B0702C6C84D8673621DE603FDFA3F9FA296C067CEC07DEB23CCF47790FE51382A7EF7818AE7998FA577EAAD40930AE95D8433DF
+``` +data = 0x955FF5A9081C9CF40AA2233DA700000004514A5871000000045A1BC39700000011A6CF5E75A0493C2B49CCE813A9817F6EC18F2EE44F9185BBDFD1309C7E94C39ECBD3D2DDE25C7FB417AACAFA538EBAC22F4C73801A9A82D6E4F31B7385EDE702000000 +random_padding_bytes = 0xE16FB664E3BCC08C6971B179152873E67803B43AF246EB90607572E59A1B6C74A0F86F7C251EDFC24A41E5677343EC06A90EA61CBB35C49AB5ACE6406875B32BDE207BF2E0EC850D6AEB134BC7C753B424D8499A183F50FB57AAD1CD +``` +

And this is the output:

-
encrypted_data = 0x388E852652880184BBBAF7EA6BA4CD7A5F3B3E09E26D46A1F463291C80735822576CF9366173E8345BB0A1102C765E80723A61A175840BA250AAD0AD88D8CF26D6AFD7380BB24324D9CBDC0D9AD5F880D89A4FD99E4CE303CE636032FFAE588E811EDDAC8B61C7983E5591AA945D883A65AA47BFBD507D38E7BBFB6ED516692448CDD051DC58109E9488D24DA3E633E3A00468E4600CEB1EF55B63C6DFFDAA7EC1CC5CE3FA42F656D3E5E08ED6F1625D1664D85AC229AB6EC49DAA02F97420DE361A1C42743FC4262EE2DA897C2D5861E7099AA684766A528603EBC46B5BF90F29CF8240A775E5CC3768660A8A1E6E31B23963ECA4E95608C4CF6BE05EB01414
+``` +encrypted_data = 0x805FA4619D56DB4C449F73319A5964B26FE47501FF6BE1D38D9DCCD8D5D89195243D466B9036A1589DCF88E76AE62FB76813C63C1753B19DBAD3D959B787F941B13DDF64653FD8B5A5C2DA9B144B321D94F972B3011CB049C2BC7340B406E514B1B1BDADDA9E33D1B93D92962574B14F8842FE5703EF8E36E84D5CF09C4B6848C3E6BC07C09ABFD2BA60713766246DAEBF595A4EF23642EA32F1858751B29238DF7205663655F509D311EC42A9F1CF65D2CF0BB5568E573A03E7BF8889F6D3209C048EB5948BDF6D80090A520C9D57EAB9B38CD0E29B3B177DF4AFDDFA048F59BEE32B65405FE030C9ED5F1A7D621E00B2A236CA83AB8F5B179253BF55C87171 +``` +

The length of the final string is 256 bytes.

-

3. request req_dh_params

+

3. request req_dh_params

-

Sent payload (excluding transport headers/trailers):

-
0000 | 00 00 00 00 00 00 00 00 04 00 00 00 26 8A 9C 64
-0010 | 40 01 00 00 BE E4 12 D7 FC B5 7C 8A 19 24 E6 2D
-0020 | B2 2C FC 63 91 60 82 0A 19 50 DF 44 0D 63 0B 94
-0030 | 1A 82 75 96 97 64 95 86 04 40 9A 8E 07 00 00 00
-0040 | 04 6E CF D4 5D 00 00 00 85 FD 64 DE 85 1D 9D D0
-0050 | FE 00 01 00 38 8E 85 26 52 88 01 84 BB BA F7 EA
-0060 | 6B A4 CD 7A 5F 3B 3E 09 E2 6D 46 A1 F4 63 29 1C
-0070 | 80 73 58 22 57 6C F9 36 61 73 E8 34 5B B0 A1 10
-0080 | 2C 76 5E 80 72 3A 61 A1 75 84 0B A2 50 AA D0 AD
-0090 | 88 D8 CF 26 D6 AF D7 38 0B B2 43 24 D9 CB DC 0D
-00A0 | 9A D5 F8 80 D8 9A 4F D9 9E 4C E3 03 CE 63 60 32
-00B0 | FF AE 58 8E 81 1E DD AC 8B 61 C7 98 3E 55 91 AA
-00C0 | 94 5D 88 3A 65 AA 47 BF BD 50 7D 38 E7 BB FB 6E
-00D0 | D5 16 69 24 48 CD D0 51 DC 58 10 9E 94 88 D2 4D
-00E0 | A3 E6 33 E3 A0 04 68 E4 60 0C EB 1E F5 5B 63 C6
-00F0 | DF FD AA 7E C1 CC 5C E3 FA 42 F6 56 D3 E5 E0 8E
-0100 | D6 F1 62 5D 16 64 D8 5A C2 29 AB 6E C4 9D AA 02
-0110 | F9 74 20 DE 36 1A 1C 42 74 3F C4 26 2E E2 DA 89
-0120 | 7C 2D 58 61 E7 09 9A A6 84 76 6A 52 86 03 EB C4
-0130 | 6B 5B F9 0F 29 CF 82 40 A7 75 E5 CC 37 68 66 0A
-0140 | 8A 1E 6E 31 B2 39 63 EC A4 E9 56 08 C4 CF 6B E0
-0150 | 5E B0 14 14
-

Payload serialization:

-
req_DH_params#d712e4be nonce:int128 server_nonce:int128 p:string q:string public_key_fingerprint:long encrypted_data:string = Server_DH_Params;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterOffset, Length in bytesValueDescription
auth_key_id0, 80x00000000000000000 since the message is in plain text
message_id8, 80x04000000268a9c64Exact unixtime*2^32, +(4*N) if N messages with the same message ID were already generated
message_length16, 40x40010000 (320 in decimal)Message body length
%(req_DH_params)20, 40xbee412d7req_DH_params constructor number from TL schema
nonce24, 160xFCB57C8A1924E62DB22CFC639160820AValue generated by client in Step 1
server_nonce40, 160x1950DF440D630B941A82759697649586Value received from server in Step 2
p56, 80x04409A8E07000000 (TL byte deserialization => bigendian conversion to decimal => 1083870727)First prime cofactor: single-byte prefix denoting length, 4-byte string, and three bytes of padding
q64, 80x046ECFD45D000000 (TL byte deserialization => bigendian conversion to decimal => 1859114077)Second prime cofactor: single-byte prefix denoting length, 4-byte string, and three bytes of padding
public_key_fingerprint72, 80x85FD64DE851D9DD0 (-3414540481677951611 in decimal)fingerprint of public key used
encrypted_data80, 2600xFE000100388E852652880184BBBAF7EA6BA4CD7A5F3B3E09E26D46A1F463291C80735822576CF9366173E8345BB0A1102C765E80723A61A175840BA250AAD0AD88D8CF26D6AFD7380BB24324D9CBDC0D9AD5F880D89A4FD99E4CE303CE636032FFAE588E811EDDAC8B61C7983E5591AA945D883A65AA47BFBD507D38E7BBFB6ED516692448CDD051DC58109E9488D24DA3E633E3A00468E4600CEB1EF55B63C6DFFDAA7EC1CC5CE3FA42F656D3E5E08ED6F1625D1664D85AC229AB6EC49DAA02F97420DE361A1C42743FC4262EE2DA897C2D5861E7099AA684766A528603EBC46B5BF90F29CF8240A775E5CC3768660A8A1E6E31B23963ECA4E95608C4CF6BE05EB01414See Generation of encrypted_data »
+Sent payload (excluding transport headers/trailers): +``` +0000 | 00 00 00 00 00 00 00 00 04 00 00 00 B8 8A 9C 64 +0010 | 40 01 00 00 BE E4 12 D7 11 A6 CF 5E 75 A0 49 3C +0020 | 2B 49 CC E8 13 A9 81 7F 6E C1 8F 2E E4 4F 91 85 +0030 | BB DF D1 30 9C 7E 94 C3 04 51 4A 58 71 00 00 00 +0040 | 04 5A 1B C3 97 00 00 00 85 FD 64 DE 85 1D 9D D0 +0050 | FE 00 01 00 80 5F A4 61 9D 56 DB 4C 44 9F 73 31 +0060 | 9A 59 64 B2 6F E4 75 01 FF 6B E1 D3 8D 9D CC D8 +0070 | D5 D8 91 95 24 3D 46 6B 90 36 A1 58 9D CF 88 E7 +0080 | 6A E6 2F B7 68 13 C6 3C 17 53 B1 9D BA D3 D9 59 +0090 | B7 87 F9 41 B1 3D DF 64 65 3F D8 B5 A5 C2 DA 9B +00A0 | 14 4B 32 1D 94 F9 72 B3 01 1C B0 49 C2 BC 73 40 +00B0 | B4 06 E5 14 B1 B1 BD AD DA 9E 33 D1 B9 3D 92 96 +00C0 | 25 74 B1 4F 88 42 FE 57 03 EF 8E 36 E8 4D 5C F0 +00D0 | 9C 4B 68 48 C3 E6 BC 07 C0 9A BF D2 BA 60 71 37 +00E0 | 66 24 6D AE BF 59 5A 4E F2 36 42 EA 32 F1 85 87 +00F0 | 51 B2 92 38 DF 72 05 66 36 55 F5 09 D3 11 EC 42 +0100 | A9 F1 CF 65 D2 CF 0B B5 56 8E 57 3A 03 E7 BF 88 +0110 | 89 F6 D3 20 9C 04 8E B5 94 8B DF 6D 80 09 0A 52 +0120 | 0C 9D 57 EA B9 B3 8C D0 E2 9B 3B 17 7D F4 AF DD +0130 | FA 04 8F 59 BE E3 2B 65 40 5F E0 30 C9 ED 5F 1A +0140 | 7D 62 1E 00 B2 A2 36 CA 83 AB 8F 5B 17 92 53 BF +0150 | 55 C8 71 71 +``` + +Payload serialization: +``` +req_DH_params#d712e4be nonce:int128 server_nonce:int128 p:string q:string public_key_fingerprint:long encrypted_data:string = Server_DH_Params; +``` + +| Parameter | Offset, Length in bytes | Value | Description | +| --- | --- | --- | --- | +| auth\_key\_id | 0, 8 | `0x0000000000000000` | 0 since the message is in plain text | +| message\_id | 8, 8 | `0x04000000b88a9c64` | Exact `unixtime*2^32`, `+(4*N)` if N messages with the same message ID were already generated | +| message\_length | 16, 4 | `0x40010000` (320 in decimal) | Message body length | +| %(req\_DH\_params) | 20, 4 | `0xbee412d7` | *req_DH_params* constructor number from TL schema | +| nonce | 24, 16 | `0x11A6CF5E75A0493C2B49CCE813A9817F` | Value generated by client in Step 1 | +| server\_nonce | 40, 16 | `0x6EC18F2EE44F9185BBDFD1309C7E94C3` | Value received from server in Step 2 | +| p | 56, 8 | `0x04514A5871000000` (TL byte deserialization => bigendian conversion to decimal => 1363826801) | First prime cofactor: single-byte prefix denoting length, 4-byte string, and three bytes of padding | +| q | 64, 8 | `0x045A1BC397000000` (TL byte deserialization => bigendian conversion to decimal => 1511768983) | Second prime cofactor: single-byte prefix denoting length, 4-byte string, and three bytes of padding | +| public\_key\_fingerprint | 72, 8 | `0x85FD64DE851D9DD0` (-3414540481677951611 in decimal) | `fingerprint` of public key used | +| encrypted\_data | 80, 260 | `encrypted_data` generated as specified above | See [Generation of encrypted_data »](#generation-of-encrypted-data) | -

4. response server_dh_params_ok

+ + + +

4. response server_dh_params_ok

-

Received payload (excluding transport headers/trailers):

-
0000 | 00 00 00 00 00 00 00 00 01 30 9A BA 26 8A 9C 64
-0010 | 7C 02 00 00 5C 07 E8 D0 FC B5 7C 8A 19 24 E6 2D
-0020 | B2 2C FC 63 91 60 82 0A 19 50 DF 44 0D 63 0B 94
-0030 | 1A 82 75 96 97 64 95 86 FE 50 02 00 3E 7F CD CE
-0040 | 47 75 C7 F1 4C 4C 81 A9 C2 C8 AC 52 25 7B 5B C4
-0050 | 16 8E E2 0D 55 57 5D B7 7D 53 2F D5 55 41 67 57
-0060 | E7 97 04 CF 24 09 45 EA 5E A0 EA AB 02 28 88 AF
-0070 | C9 41 D6 B4 FE 1E 92 19 53 3B F2 63 95 BB C4 5F
-0080 | D2 50 70 40 6E EA C0 E3 1A 8B 4E 2A 48 37 6D C9
-0090 | 28 12 1C 10 0B 21 7F 44 BE 40 52 17 1E 0F 0B C9
-00A0 | 85 97 30 97 DF 2E 12 3F 46 2D CA EA 61 BD 02 DD
-00B0 | AD B2 FD 53 3F F0 A6 F1 5D 43 E1 3A DC AB 73 6C
-00C0 | 7B 68 BA 83 8C 5C D8 A2 79 66 E4 63 B0 41 6F C7
-00D0 | FE D8 28 5A EB AA 9B 8B AA EB 6B AF FF A5 8B D4
-00E0 | 95 26 7F 55 87 8F 71 44 04 3F 8B FD B2 BE 0B A0
-00F0 | 1F 75 96 59 61 8D BD 21 80 7A 7B 06 36 C6 05 8B
-0100 | 09 77 D8 74 7B CC 06 19 EA 71 3E C0 09 36 28 95
-0110 | 25 6A F3 31 7F AA F3 A7 93 BC F3 40 31 A9 13 33
-0120 | 39 DE 68 56 2B 64 F0 61 1E 48 36 5B 20 C8 B2 66
-0130 | 0C 3C AE 74 16 8D E2 7D 6E A2 14 41 F9 23 52 79
-0140 | 6F 47 09 F3 A0 B7 0A 84 A5 72 D4 2E 44 57 9A A0
-0150 | 1D 26 8B 92 D8 04 A8 56 4F 1D 78 90 87 18 3C 8D
-0160 | 35 9B 03 EB 24 A3 4B 89 2D 42 60 13 4C D4 D9 53
-0170 | D4 11 FA 61 11 96 B4 23 99 0D AB C3 F0 B0 CA BA
-0180 | DA C6 81 AE 77 7F C3 D8 52 18 66 04 7B 5D 14 79
-0190 | DA 61 E9 AC C2 8D FA 3A 30 48 E7 12 E3 5C 58 B9
-01A0 | 80 E5 56 6D BF D8 2C 73 31 04 EF 0F 69 39 D7 1C
-01B0 | 0B 5A 31 B2 53 DE A2 DD 19 4A BD E5 C6 45 70 1D
-01C0 | 17 FE CA 5E 0C DA 04 3D D0 8F A0 F3 25 6C FF 58
-01D0 | B9 A9 F2 38 14 C1 DA 4F C9 0C DC 10 B0 33 45 6F
-01E0 | 36 1E 77 D4 10 57 3A 3E 8B 73 2D 54 02 6E E7 7D
-01F0 | CA E6 95 DE F7 72 E9 06 EA 7B 2B B6 F2 A6 34 77
-0200 | 2F 72 C0 D5 37 20 96 75 71 3A 4C E0 45 67 63 6E
-0210 | 25 AD AA E4 77 D1 73 65 36 E9 B1 78 CF 20 ED BB
-0220 | 66 25 05 C0 63 E5 E3 64 FD 45 0E 8F A4 90 CC A4
-0230 | 2D 56 F9 76 88 F5 7F 41 27 91 FB 91 78 BD 2A 6F
-0240 | F1 E7 51 21 69 5C F6 59 5C 8B 50 A6 DC 9A 5B 66
-0250 | 89 8E D1 4B 20 E1 32 B9 B4 9B 72 9A 6B F8 2B 9F
-0260 | 02 25 59 4C 8F 6C AF 82 D7 1B A7 0C 56 88 AB F9
-0270 | 0D 59 3C EA 46 6E FE 62 92 A5 D5 26 8A 14 CA 29
-0280 | D7 93 82 36 1B 9B 24 E5 37 CF F2 F5
-

Payload serialization:

-
server_DH_params_fail#79cb045d nonce:int128 server_nonce:int128 new_nonce_hash:int128 = Server_DH_Params;
-server_DH_params_ok#d0e8075c nonce:int128 server_nonce:int128 encrypted_answer:string = Server_DH_Params;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterOffset, Length in bytesValueDescription
auth_key_id0, 80x00000000000000000 since the message is in plain text
message_id8, 80x01309aba268a9c64Exact unixtime*2^32, +(4*N) if N messages with the same message ID were already generated
message_length16, 40x7c020000 (636 in decimal)Message body length
%(server_DH_params_ok)20, 40x5c07e8d0server_DH_params_ok constructor number from TL schema
nonce24, 160xFCB57C8A1924E62DB22CFC639160820AValue generated by client in Step 1
server_nonce40, 160x1950DF440D630B941A82759697649586Value received from server in Step 2
encrypted_answer56, 5960xFE5002003E7FCDCE4775C7F14C4C81A9C2C8AC52257B5BC4168EE20D55575DB77D532FD555416757E79704CF240945EA5EA0EAAB022888AFC941D6B4FE1E9219533BF26395BBC45FD25070406EEAC0E31A8B4E2A48376DC928121C100B217F44BE4052171E0F0BC985973097DF2E123F462DCAEA61BD02DDADB2FD533FF0A6F15D43E13ADCAB736C7B68BA838C5CD8A27966E463B0416FC7FED8285AEBAA9B8BAAEB6BAFFFA58BD495267F55878F7144043F8BFDB2BE0BA01F759659618DBD21807A7B0636C6058B0977D8747BCC0619EA713EC009362895256AF3317FAAF3A793BCF34031A9133339DE68562B64F0611E48365B20C8B2660C3CAE74168DE27D6EA21441F92352796F4709F3A0B70A84A572D42E44579AA01D268B92D804A8564F1D789087183C8D359B03EB24A34B892D4260134CD4D953D411FA611196B423990DABC3F0B0CABADAC681AE777FC3D8521866047B5D1479DA61E9ACC28DFA3A3048E712E35C58B980E5566DBFD82C733104EF0F6939D71C0B5A31B253DEA2DD194ABDE5C645701D17FECA5E0CDA043DD08FA0F3256CFF58B9A9F23814C1DA4FC90CDC10B033456F361E77D410573A3E8B732D54026EE77DCAE695DEF772E906EA7B2BB6F2A634772F72C0D537209675713A4CE04567636E25ADAAE477D1736536E9B178CF20EDBB662505C063E5E364FD450E8FA490CCA42D56F97688F57F412791FB9178BD2A6FF1E75121695CF6595C8B50A6DC9A5B66898ED14B20E132B9B49B729A6BF82B9F0225594C8F6CAF82D71BA70C5688ABF90D593CEA466EFE6292A5D5268A14CA29D79382361B9B24E537CFF2F5See Decomposition of encrypted_answer »
+Received payload (excluding transport headers/trailers): +``` +0000 | 00 00 00 00 00 00 00 00 01 B4 3E 13 B9 8A 9C 64 +0010 | 84 02 00 00 5C 07 E8 D0 11 A6 CF 5E 75 A0 49 3C +0020 | 2B 49 CC E8 13 A9 81 7F 6E C1 8F 2E E4 4F 91 85 +0030 | BB DF D1 30 9C 7E 94 C3 FE 50 02 00 02 8B E9 6A +0040 | 29 F1 57 72 A6 71 EF 62 76 1B BD 3A 34 01 09 E2 +0050 | E8 64 F9 20 51 3A F4 EA 20 F4 28 A1 DD 38 A1 03 +0060 | 3C 8E 3D 7E 48 E4 B2 7D 1C A4 98 A5 95 9F 1D AE +0070 | 30 67 65 A4 5D 28 C9 85 38 91 BC 63 BD C4 CF D7 +0080 | 60 48 BB 88 D2 EB A6 8D 14 B0 B0 4E 19 5A 56 1E +0090 | 6D 1B DE BA 72 8F CE D0 16 79 CE DF 2C C0 A9 68 +00A0 | 5F 41 C9 AB C7 F8 0E 4D A1 4F 0A 14 4E 4E 5E 4B +00B0 | E4 43 0D F9 21 CA 47 EE CB C7 D8 97 1A E4 E7 50 +00C0 | 69 AD DA 64 AC E5 50 55 AA 6D 07 2F A9 76 76 9A +00D0 | A1 3E AC 76 DF E5 AC EC F5 28 F3 E5 AC CD 97 A7 +00E0 | B2 F3 A1 71 0E AB D8 E6 17 D3 12 10 E5 90 E7 5B +00F0 | CD 08 30 FF 4A 73 C5 C6 F9 56 87 9A A3 EA 7E 9B +0100 | E3 18 77 5C F2 3F 2A DE DE 57 C5 FC 6D 48 EF BC +0110 | 68 CE 00 15 B7 EE 82 9B EA 33 43 40 39 44 F7 23 +0120 | 6A 1B DB 1B B5 98 A1 43 4D 1C 90 9C 9A 28 4B 94 +0130 | 7C AD B5 CC CE A1 F6 7F FB EC 67 03 03 AD 39 1C +0140 | 5A CC 12 01 82 35 B5 88 39 41 32 BE B5 44 FE 1A +0150 | 56 0B 64 2F A7 CD 93 F5 4E 6E 5F 58 33 38 7C E4 +0160 | 6C BE 79 26 46 E9 CA B1 DF 60 9C C2 99 51 D3 28 +0170 | 2F E1 B3 23 D7 9B 63 97 56 6F D7 0B 70 BF 66 F9 +0180 | E0 D6 B3 10 75 C6 5D EA EF 39 63 E3 37 B3 BE 64 +0190 | 7D E1 D6 4B 90 CA 34 24 01 83 A4 AD CD B4 6A BB +01A0 | E2 E6 70 7D E6 81 3C 41 E1 99 09 9A 13 35 3D 03 +01B0 | 58 8C EF B1 0C 5D 0C 3B EE 2C E6 64 10 F7 6C E3 +01C0 | DE B5 93 D2 67 86 FD CF 26 8A 36 E7 0A F7 43 50 +01D0 | CB D7 3A 4D 75 E4 92 62 56 D6 50 0A EA 89 AD 7A +01E0 | 58 18 DF 17 45 44 04 EE F8 73 84 1B 95 4A 94 2F +01F0 | 3C F0 B9 85 DC 3A 25 B2 AF 33 EA 3E 0D AE EC E5 +0200 | 51 C4 55 A4 53 27 36 D7 6B F7 5F 46 8E 13 0C 29 +0210 | 59 CF C9 D1 01 88 D1 36 55 01 3A B1 9D 6F 61 05 +0220 | FF 4B 7D CF 88 29 7B 44 A9 67 65 79 8E 8A D2 AB +0230 | 11 89 94 37 FB FF 8C 68 2E 3B 86 BC AB 4B 1C A7 +0240 | 70 41 53 FE AE FB 66 4E C5 13 E9 0F F1 5E AA 97 +0250 | 27 DD 6E 3D AB 31 E2 8A A5 6A 37 79 E2 D3 51 6A +0260 | 92 96 E2 CD 46 10 C5 F7 5A 21 64 8D EE B0 A0 6D +0270 | 1F FE 4F 6A 68 5F 86 98 A9 DF 17 F7 C9 58 4B C0 +0280 | 7C 59 5B E8 E1 8F 01 6B E5 70 3F 11 +``` + +Payload serialization: +``` +server_DH_params_fail#79cb045d nonce:int128 server_nonce:int128 new_nonce_hash:int128 = Server_DH_Params; +server_DH_params_ok#d0e8075c nonce:int128 server_nonce:int128 encrypted_answer:string = Server_DH_Params; +``` + +| Parameter | Offset, Length in bytes | Value | Description | +| --- | --- | --- | --- | +| auth\_key\_id | 0, 8 | `0x0000000000000000` | 0 since the message is in plain text | +| message\_id | 8, 8 | `0x01b43e13b98a9c64` | Exact `unixtime*2^32`, `+(4*N)` if N messages with the same message ID were already generated | +| message\_length | 16, 4 | `0x84020000` (644 in decimal) | Message body length | +| %(server\_DH\_params\_ok) | 20, 4 | `0x5c07e8d0` | *server_DH_params_ok* constructor number from TL schema | +| nonce | 24, 16 | `0x11A6CF5E75A0493C2B49CCE813A9817F` | Value generated by client in Step 1 | +| server\_nonce | 40, 16 | `0x6EC18F2EE44F9185BBDFD1309C7E94C3` | Value received from server in Step 2 | +| encrypted\_answer | 56, 596 | `0xFE500200028BE96A29F15772A671EF62761BBD3A340109E2E864F920513AF4EA20F428A1DD38A1033C8E3D7E48E4B27D1CA498A5959F1DAE306765A45D28C9853891BC63BDC4CFD76048BB88D2EBA68D14B0B04E195A561E6D1BDEBA728FCED01679CEDF2CC0A9685F41C9ABC7F80E4DA14F0A144E4E5E4BE4430DF921CA47EECBC7D8971AE4E75069ADDA64ACE55055AA6D072FA976769AA13EAC76DFE5ACECF528F3E5ACCD97A7B2F3A1710EABD8E617D31210E590E75BCD0830FF4A73C5C6F956879AA3EA7E9BE318775CF23F2ADEDE57C5FC6D48EFBC68CE0015B7EE829BEA3343403944F7236A1BDB1BB598A1434D1C909C9A284B947CADB5CCCEA1F67FFBEC670303AD391C5ACC12018235B588394132BEB544FE1A560B642FA7CD93F54E6E5F5833387CE46CBE792646E9CAB1DF609CC29951D3282FE1B323D79B6397566FD70B70BF66F9E0D6B31075C65DEAEF3963E337B3BE647DE1D64B90CA34240183A4ADCDB46ABBE2E6707DE6813C41E199099A13353D03588CEFB10C5D0C3BEE2CE66410F76CE3DEB593D26786FDCF268A36E70AF74350CBD73A4D75E4926256D6500AEA89AD7A5818DF17454404EEF873841B954A942F3CF0B985DC3A25B2AF33EA3E0DAEECE551C455A4532736D76BF75F468E130C2959CFC9D10188D13655013AB19D6F6105FF4B7DCF88297B44A96765798E8AD2AB11899437FBFF8C682E3B86BCAB4B1CA7704153FEAEFB664EC513E90FF15EAA9727DD6E3DAB31E28AA56A3779E2D3516A9296E2CD4610C5F75A21648DEEB0A06D1FFE4F6A685F8698A9DF17F7C9584BC07C595BE8E18F016BE5703F11` | See [Decomposition of encrypted_answer »](#conversion-of-encrypted-answer-into-answer) | -

4.1 server_dh_inner_data decryption and deserialization

+ + + +

4.1 server_dh_inner_data decryption and deserialization

Decrypt encrypted_answer using the process specified in step 5.

-

Generated payload (excluding transport headers/trailers):

-
0000 | BA 0D 89 B5 FC B5 7C 8A 19 24 E6 2D B2 2C FC 63
-0010 | 91 60 82 0A 19 50 DF 44 0D 63 0B 94 1A 82 75 96
-0020 | 97 64 95 86 03 00 00 00 FE 00 01 00 C7 1C AE B9
+Generated payload (excluding transport headers/trailers):
+```
+0000 | BA 0D 89 B5 11 A6 CF 5E 75 A0 49 3C 2B 49 CC E8
+0010 | 13 A9 81 7F 6E C1 8F 2E E4 4F 91 85 BB DF D1 30
+0020 | 9C 7E 94 C3 03 00 00 00 FE 00 01 00 C7 1C AE B9
 0030 | C6 B1 C9 04 8E 6C 52 2F 70 F1 3F 73 98 0D 40 23
 0040 | 8E 3E 21 C1 49 34 D0 37 56 3D 93 0F 48 19 8A 0A
 0050 | A7 C1 40 58 22 94 93 D2 25 30 F4 DB FA 33 6F 6E
@@ -524,313 +321,184 @@ server_DH_params_ok#d0e8075c nonce:int128 server_nonce:int128 encrypted_answer:s
 0100 | F4 7B F9 59 D9 56 85 0C E9 29 85 1F 0D 81 15 F6
 0110 | 35 B1 05 EE 2E 4E 15 D0 4B 24 54 BF 6F 4F AD F0
 0120 | 34 B1 04 03 11 9C D8 E3 B9 2F CC 5B FE 00 01 00
-0130 | 50 02 DA C7 09 FE 68 6A EB 84 BC FB AA 32 8A E6
-0140 | 1C 83 29 F8 99 AA A5 B2 1E 75 D0 2A 1D 5D AC 70
-0150 | D2 AB 13 0A 7E C4 E1 63 A2 62 9A F0 CF 91 DD E8
-0160 | D4 5C B9 A7 F4 A8 1C 49 1E 7B 92 11 DC 9B 3C 48
-0170 | 9E 09 CA FC 0A 35 51 37 AA A5 5B 7D 2B 10 F2 AC
-0180 | 38 47 1A C7 AA 29 CB 62 FA 8F 0D 46 8C F8 D8 AF
-0190 | 64 E2 93 37 60 24 86 BB 8F 8C BD 6D 62 8C 68 47
-01A0 | E4 9B 2D 8D 19 D3 55 67 3B EC 5A 72 0D 09 CB F9
-01B0 | 1C D5 98 DB 80 FE A5 B6 BF 4A F4 3D 61 DC 51 E3
-01C0 | D8 FC 64 E0 BF EF 09 B2 C0 EA D6 D2 93 EC B0 95
-01D0 | 2A CC 69 5B F6 C0 14 CF 93 88 4D 56 8A 95 A9 AE
-01E0 | 6E 28 65 DD 26 D5 B6 33 42 DA 79 32 6D DC D9 73
-01F0 | 14 7D 6F 28 D5 4B 0A A2 F5 90 9D 3D 8D 48 2A 03
-0200 | 5C 6F 2C 67 54 BD 6B AD 23 80 8E 6B E6 96 86 C0
-0210 | CD BD 98 28 9F 8F E7 80 32 EC 3D AF 96 E9 B6 AF
-0220 | F3 81 14 29 22 C2 A3 90 BC 57 E7 96 AE D5 5B DD
-0230 | 26 8A 9C 64
-

Payload serialization:

-
server_DH_inner_data#b5890dba nonce:int128 server_nonce:int128 g:int dh_prime:string g_a:string server_time:int = Server_DH_inner_data;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterOffset, Length in bytesValueDescription
%(server_DH_inner_data)0, 40xba0d89b5server_DH_inner_data constructor number from TL schema
nonce4, 160xFCB57C8A1924E62DB22CFC639160820AValue generated by client in Step 1
server_nonce20, 160x1950DF440D630B941A82759697649586Value received from server in Step 2
g36, 40x03000000 (3 in decimal)Value received from server in Step 2
dh_prime40, 2600xFE000100C71CAEB9C6B1C9048E6C522F70F13F73980D40238E3E21C14934D037563D930F48198A0AA7C14058229493D22530F4DBFA336F6E0AC925139543AED44CCE7C3720FD51F69458705AC68CD4FE6B6B13ABDC9746512969328454F18FAF8C595F642477FE96BB2A941D5BCD1D4AC8CC49880708FA9B378E3C4F3A9060BEE67CF9A4A4A695811051907E162753B56B0F6B410DBA74D8A84B2A14B3144E0EF1284754FD17ED950D5965B4B9DD46582DB1178D169C6BC465B0D6FF9CA3928FEF5B9AE4E418FC15E83EBEA0F87FA9FF5EED70050DED2849F47BF959D956850CE929851F0D8115F635B105EE2E4E15D04B2454BF6F4FADF034B10403119CD8E3B92FCC5B2048-bit prime, in big-endian byte order, to be checked as specified in the auth key docs
g_a300, 2600xFE0001005002DAC709FE686AEB84BCFBAA328AE61C8329F899AAA5B21E75D02A1D5DAC70D2AB130A7EC4E163A2629AF0CF91DDE8D45CB9A7F4A81C491E7B9211DC9B3C489E09CAFC0A355137AAA55B7D2B10F2AC38471AC7AA29CB62FA8F0D468CF8D8AF64E29337602486BB8F8CBD6D628C6847E49B2D8D19D355673BEC5A720D09CBF91CD598DB80FEA5B6BF4AF43D61DC51E3D8FC64E0BFEF09B2C0EAD6D293ECB0952ACC695BF6C014CF93884D568A95A9AE6E2865DD26D5B63342DA79326DDCD973147D6F28D54B0AA2F5909D3D8D482A035C6F2C6754BD6BAD23808E6BE69686C0CDBD98289F8FE78032EC3DAF96E9B6AFF381142922C2A390BC57E796AED55BDDg_a diffie-hellman parameter
server_time560, 40x268A9C64 (1687980582 in decimal)Server time
+0130 | BE 99 1E 94 4F 08 03 67 05 D6 C5 6A 2B A9 C2 10 +0140 | E0 A5 5F 9A 76 98 E8 C9 77 A5 33 6F A7 7A 50 0F +0150 | 5F E1 07 82 52 3B AC 3D D5 2B 41 D0 9E 11 E9 E0 +0160 | 8C B7 3C 06 5F 42 33 D6 97 8E F5 EE 9F 98 23 53 +0170 | 4A 69 FA 51 EE A5 10 2F 3F F1 48 84 25 34 E8 E5 +0180 | D1 F1 30 8C D0 23 A8 65 D3 C8 BA 31 35 8A 2B 8D +0190 | 30 19 68 EF 07 F7 63 0B 5E A9 80 ED 91 3C 7F B8 +01A0 | 23 A0 3C 47 98 89 57 16 BB 49 DA AB 67 F7 29 F7 +01B0 | 07 D4 1D F2 31 89 5B 35 40 4C FF E5 51 A4 96 D8 +01C0 | B5 A9 43 27 99 DF 16 AE C9 FF 65 A3 08 AB 3A 2C +01D0 | C7 1A 1F 15 EE 01 93 44 37 2B 49 AE E6 51 0E 77 +01E0 | 79 C7 8C 5A DD A1 BA C9 6D 9F E5 91 1D 06 83 53 +01F0 | FA B1 E3 0D BE E6 E3 F1 EA 95 27 94 30 4A EE 3C +0200 | 54 09 A0 19 27 E2 8C A7 39 CD 40 17 DC 25 DA 01 +0210 | 5B E4 1A B1 6D 81 47 85 EE 34 1C 7A 1D 18 08 DE +0220 | 54 30 B6 77 90 D0 E3 9F 2A 34 EC 58 0A 88 72 01 +0230 | B9 8A 9C 64 +``` + +Payload serialization: +``` +server_DH_inner_data#b5890dba nonce:int128 server_nonce:int128 g:int dh_prime:string g_a:string server_time:int = Server_DH_inner_data; +``` + +| Parameter | Offset, Length in bytes | Value | Description | +| --- | --- | --- | --- | +| %(server\_DH\_inner\_data) | 0, 4 | `0xba0d89b5` | *server_DH_inner_data* constructor number from TL schema | +| nonce | 4, 16 | `0x11A6CF5E75A0493C2B49CCE813A9817F` | Value generated by client in Step 1 | +| server\_nonce | 20, 16 | `0x6EC18F2EE44F9185BBDFD1309C7E94C3` | Value received from server in Step 2 | +| g | 36, 4 | `0x03000000` (3 in decimal) | Value received from server in Step 2 | +| dh\_prime | 40, 260 | `0xFE000100C71CAEB9C6B1C9048E6C522F70F13F73980D40238E3E21C14934D037563D930F48198A0AA7C14058229493D22530F4DBFA336F6E0AC925139543AED44CCE7C3720FD51F69458705AC68CD4FE6B6B13ABDC9746512969328454F18FAF8C595F642477FE96BB2A941D5BCD1D4AC8CC49880708FA9B378E3C4F3A9060BEE67CF9A4A4A695811051907E162753B56B0F6B410DBA74D8A84B2A14B3144E0EF1284754FD17ED950D5965B4B9DD46582DB1178D169C6BC465B0D6FF9CA3928FEF5B9AE4E418FC15E83EBEA0F87FA9FF5EED70050DED2849F47BF959D956850CE929851F0D8115F635B105EE2E4E15D04B2454BF6F4FADF034B10403119CD8E3B92FCC5B` | 2048-bit prime, in big-endian byte order, to be checked as specified in the auth key docs | +| g\_a | 300, 260 | `0xFE000100BE991E944F08036705D6C56A2BA9C210E0A55F9A7698E8C977A5336FA77A500F5FE10782523BAC3DD52B41D09E11E9E08CB73C065F4233D6978EF5EE9F9823534A69FA51EEA5102F3FF148842534E8E5D1F1308CD023A865D3C8BA31358A2B8D301968EF07F7630B5EA980ED913C7FB823A03C4798895716BB49DAAB67F729F707D41DF231895B35404CFFE551A496D8B5A9432799DF16AEC9FF65A308AB3A2CC71A1F15EE019344372B49AEE6510E7779C78C5ADDA1BAC96D9FE5911D068353FAB1E30DBEE6E3F1EA952794304AEE3C5409A01927E28CA739CD4017DC25DA015BE41AB16D814785EE341C7A1D1808DE5430B67790D0E39F2A34EC580A887201` | `g_a` diffie-hellman parameter | +| server\_time | 560, 4 | `0xB98A9C64` (1687980729 in decimal) | Server time | -

4.2. random 2048-bit number b is generated:

+ + + +

4.2. random 2048-bit number b is generated:

-
b = 0xBF21123EA6D16A4A5B083C07D8DA057598973ED1574E7498957653128FA0ED98FB46B27FB084C5DBEE3AE0FED8283D37E5AF1CB022967FF3504A8C5BB1EF359E71CF2218121E85C4450CBBA9CC6D0C3FC55EB690982945C7A19CCF6ACFE857F8C3BE7DA33F89A69C3DA5CF99651602E1EE54E3ED45B44DA21B8711714F61B20F82E345E19877F723751277DECA38B4F3945ED385CE7413810C75636B7A6B91CD6F3D0B2C76504E2814C48D271A22E58723362CFA7C2D3E89CBAC8CA7EEE144DCEBA6D5362FD97941F3D50620EB85EF4EAD6A8866F0547D697AA399188DB8FE78F0E530A1A9FF77C23FCAACE4D67A5ED85F740525553D8F7F9ECA9D5E36140401
+``` +b = 0x9C9EAF9F87B5DC44E231D36B74F708AB11E3D257EFA2A5FC39D77831827FCCA2C4220597E27EC84FFA02853E6B5FFFB463ACEAD0FFF22DA9537F96C090798E72A56B9E4D657E4509438D41A5E7A2EA3018481602973EE93861868BC5F5F3524F839FD25B45149C7C4B6C8FE17B6906A7F3755734D24DBF950F5325E554DE1B561219790F355F01735DDFE040F60CE7BEA1068829B02998133D0B6DE662CA133FDB070971EC757E2030A7F8DC7FB735BA2B48B73CBC0DFDA46D4C91D366E1366D3D7E7BD953854439E8B23072597330C79C34BB8A48ED2BDD5235C94B47BA23F31EA270A99FAA31EE2883F70EE745029D9E41D26A6C595F6B1E750F994BE7DB20 +``` -

4.3 generation of encrypted_data

+ + + +

4.3 generation of encrypted_data

-

Generated payload (excluding transport headers/trailers):

-
0000 | 54 B6 43 66 FC B5 7C 8A 19 24 E6 2D B2 2C FC 63
-0010 | 91 60 82 0A 19 50 DF 44 0D 63 0B 94 1A 82 75 96
-0020 | 97 64 95 86 00 00 00 00 00 00 00 00 FE 00 01 00
-0030 | 63 50 22 33 D1 89 A0 53 FD E1 86 0B 8B 32 50 0D
-0040 | 0B 46 4C F9 D0 A2 F7 26 EB 11 BF 1A 04 5E 74 94
-0050 | 2B EC 00 92 36 38 E8 D5 73 87 D2 3B 28 DB BD 12
-0060 | 4E 33 B2 34 98 33 ED CA DF C5 3A 31 20 AD AE EA
-0070 | 51 95 72 FC DB D8 96 B3 12 41 60 24 B9 51 01 A0
-0080 | 70 AE 92 6D 28 12 98 66 10 93 D8 5C 78 68 6B 89
-0090 | 2F EA EC A3 20 32 7B 2E 63 C2 AB 14 81 F5 58 B4
-00A0 | F1 DF 5D 58 57 F1 D0 52 98 63 A3 08 B4 87 31 2D
-00B0 | 80 3E 99 20 2C C7 35 0F 7A 20 FB 58 AE 3B 21 20
-00C0 | C6 4C 88 44 F4 4F A4 1A D8 4A B4 EE 5B C7 A0 E8
-00D0 | A6 51 51 01 1C E1 6D E9 42 BA D3 1B 41 74 79 BD
-00E0 | B3 32 65 8D 38 9D A9 77 AC 4E 9B C4 AA 97 DE 49
-00F0 | 88 9F BC 41 CB 4E 47 B6 78 FE EA 95 52 5A 87 52
-0100 | 9D E7 B3 B2 F7 72 9C 56 81 EC 19 61 1E B5 30 FF
-0110 | E4 5C CD 98 34 39 07 2B AA DA C7 8D 48 57 2C B3
-0120 | 41 0D 2A 83 9C 47 63 89 31 7E 99 70 2B B6 8D E2
-

Payload serialization:

-
client_DH_inner_data#6643b654 nonce:int128 server_nonce:int128 retry_id:long g_b:string = Client_DH_Inner_Data;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterOffset, Length in bytesValueDescription
%(client_DH_inner_data)0, 40x54b64366client_DH_inner_data constructor number from TL schema
nonce4, 160xFCB57C8A1924E62DB22CFC639160820AValue generated by client in Step 1
server_nonce20, 160x1950DF440D630B941A82759697649586Value received from server in Step 2
g_b36, 2600xFE00010063502233D189A053FDE1860B8B32500D0B464CF9D0A2F726EB11BF1A045E74942BEC00923638E8D57387D23B28DBBD124E33B2349833EDCADFC53A3120ADAEEA519572FCDBD896B312416024B95101A070AE926D281298661093D85C78686B892FEAECA320327B2E63C2AB1481F558B4F1DF5D5857F1D0529863A308B487312D803E99202CC7350F7A20FB58AE3B2120C64C8844F44FA41AD84AB4EE5BC7A0E8A65151011CE16DE942BAD31B417479BDB332658D389DA977AC4E9BC4AA97DE49889FBC41CB4E47B678FEEA95525A87529DE7B3B2F7729C5681EC19611EB530FFE45CCD983439072BAADAC78D48572CB3410D2A839C476389317E99702BB68DE2pow(g, b) mod dh_prime
retry_id296, 80x0000000000000000 (0 in decimal)Equal to zero at the time of the first attempt; otherwise, it is equal to auth_key_aux_hash from the previous failed attempt (see Item 9).
+Generated payload (excluding transport headers/trailers): +``` +0000 | 54 B6 43 66 11 A6 CF 5E 75 A0 49 3C 2B 49 CC E8 +0010 | 13 A9 81 7F 6E C1 8F 2E E4 4F 91 85 BB DF D1 30 +0020 | 9C 7E 94 C3 00 00 00 00 00 00 00 00 FE 00 01 00 +0030 | 21 26 A1 70 2C E3 6B 8D 98 9E 41 21 F4 F0 76 FE +0040 | D1 72 91 28 A7 25 30 A2 7B 5B 95 40 C1 20 6A 8E +0050 | 3D 9D F5 DA 38 88 F6 FC B2 EA 5E DD 35 6D 35 CE +0060 | 15 9F 2F B1 85 3E 36 F2 9F 1D D9 BC AD 09 21 2A +0070 | 4D 7D 77 AE BC FB 77 61 A4 D0 80 A4 DF 44 24 FD +0080 | 7B 9A B8 49 31 CA 75 B3 A8 33 55 3F D1 89 67 99 +0090 | 34 E6 71 10 9B DD 22 6F DA 59 9C 04 D3 03 BF 5D +00A0 | BD 4B 84 A2 BF DC BE D8 6F 02 F5 34 BB BF 0C 75 +00B0 | 18 BA 3A 25 DB 24 54 75 68 A9 C9 DE 14 FD 90 4C +00C0 | E0 51 07 61 4F 17 04 9F B2 5B D2 4E A4 A2 3E F0 +00D0 | 91 B5 3B 7D 6C 7E 9F 4C 3B CA D0 8D C2 3F 52 5B +00E0 | DD AA 79 AE 9C 46 75 B9 B5 18 E9 B6 F0 57 5C 6F +00F0 | F5 36 E0 A5 16 9E 0E 50 A2 3F EE 52 39 4F 24 BD +0100 | 46 6B B1 EE 5A EE EA 6F D7 7B 76 29 39 97 C7 11 +0110 | 3C E3 19 E4 AE 02 C6 6A 11 55 AC 51 43 BD 76 24 +0120 | B7 3B 42 FC 4E 8E D5 6F DF 5B 96 9C FC 3A A1 65 +``` + +Payload serialization: +``` +client_DH_inner_data#6643b654 nonce:int128 server_nonce:int128 retry_id:long g_b:string = Client_DH_Inner_Data; +``` + +| Parameter | Offset, Length in bytes | Value | Description | +| --- | --- | --- | --- | +| %(client\_DH\_inner\_data) | 0, 4 | `0x54b64366` | *client_DH_inner_data* constructor number from TL schema | +| nonce | 4, 16 | `0x11A6CF5E75A0493C2B49CCE813A9817F` | Value generated by client in Step 1 | +| server\_nonce | 20, 16 | `0x6EC18F2EE44F9185BBDFD1309C7E94C3` | Value received from server in Step 2 | +| g\_b | 36, 260 | `0xFE0001002126A1702CE36B8D989E4121F4F076FED1729128A72530A27B5B9540C1206A8E3D9DF5DA3888F6FCB2EA5EDD356D35CE159F2FB1853E36F29F1DD9BCAD09212A4D7D77AEBCFB7761A4D080A4DF4424FD7B9AB84931CA75B3A833553FD189679934E671109BDD226FDA599C04D303BF5DBD4B84A2BFDCBED86F02F534BBBF0C7518BA3A25DB24547568A9C9DE14FD904CE05107614F17049FB25BD24EA4A23EF091B53B7D6C7E9F4C3BCAD08DC23F525BDDAA79AE9C4675B9B518E9B6F0575C6FF536E0A5169E0E50A23FEE52394F24BD466BB1EE5AEEEA6FD77B76293997C7113CE319E4AE02C66A1155AC5143BD7624B73B42FC4E8ED56FDF5B969CFC3AA165` | `pow(g, b) mod dh_prime` | +| retry\_id | 296, 8 | `0x0000000000000000` (0 in decimal) | Equal to zero at the time of the first attempt; otherwise, it is equal to `auth_key_aux_hash` from the previous failed attempt (see Item 9). | +

The serialization of Client_DH_Inner_Data produces some string data. This is followed by encrypted_data:

data_with_hash := SHA1(data) + data + (0-15 random bytes); such that the length be divisible by 16;
 AES256_ige_encrypt (data_with_hash, tmp_aes_key, tmp_aes_iv) = 928A4957D0463B525C1CC48AABAA030A256BE5C746792C84CA4C5A0DF60AC799048D98A38A8480EDCF082214DFC79DCB9EE34E206513E2B3BC1504CFE6C9ADA46BF9A03CA74F192EAF8C278454ADABC795A566615462D31817382984039505F71CB33A41E2527A4B1AC05107872FED8E3ABCEE1518AE965B0ED3AED7F67479155BDA8E4C286B64CDF123EC748CF289B1DB02D1907B562DF462D8582BA6F0A3022DC2D3504D69D1BA48B677E3A830BFAFD67584C8AA24E1344A8904E305F9587C92EF964F0083F50F61EAB4A393EAA33C9270294AEDC7732891D4EA1599F52311D74469D2112F4EDF3F342E93C8E87E812DC3989BAECFE6740A46077524C75093F5A5405736DE8937BB6E42C9A0DCF22CA53227D462BCCC2CFE94B6FE86AB7FBFA395021F66661AF7C0024CA2986CA03F3476905407D1EA9C010B763258DB1AA2CC7826D91334EFC1FDC665B67FE45ED0

The length of the final string is 336 bytes.

-

5. request set_client_dh_params

+

5. request set_client_dh_params

-

Sent payload (excluding transport headers/trailers):

-
0000 | 00 00 00 00 00 00 00 00 08 00 00 00 26 8A 9C 64
-0010 | 78 01 00 00 1F 5F 04 F5 FC B5 7C 8A 19 24 E6 2D
-0020 | B2 2C FC 63 91 60 82 0A 19 50 DF 44 0D 63 0B 94
-0030 | 1A 82 75 96 97 64 95 86 FE 50 01 00 BC E0 FD 22
-0040 | 38 D8 27 BB C7 D4 AB E0 A0 2D F4 66 32 3A E9 C7
-0050 | 8A 73 5B AA CF E1 46 37 10 D9 18 53 81 29 6B 21
-0060 | 50 FA AD A2 0A 11 4D A6 31 C3 85 F1 1C B8 82 1A
-0070 | B7 6E C9 FC F2 9D 7A AB 83 4C 20 CA CC 73 3E 48
-0080 | 4F CC 66 78 CB 65 AD 95 0C 3A B3 65 48 8C 39 82
-0090 | 69 4A BF 33 F7 7D B0 03 95 4B 3C 73 F2 7F AA 98
-00A0 | 6C F9 0D 5E C5 82 B4 2D B7 74 B0 87 D5 84 C1 E7
-00B0 | 3E 1A 4D C6 99 59 E8 7B 00 B1 21 4E F6 16 4A 4C
-00C0 | 02 DA F4 BF E5 A0 99 37 9E 7D E2 73 33 31 43 C3
-00D0 | 2F F9 97 83 53 90 E1 93 11 96 1C EF 90 9A E0 FB
-00E0 | 30 23 1F 67 6B FE 55 E1 DA E1 38 3F FE 49 0A 4F
-00F0 | 88 FA 0F E2 82 D4 C4 60 E7 A0 16 D0 15 D9 71 85
-0100 | 68 0C 86 28 6F F6 C5 73 FA 4C FA 29 BD 81 FB 85
-0110 | A0 E2 24 B7 08 1E 70 1C DE 0C EB 6A B0 23 5E 6D
-0120 | A8 82 83 D3 42 A0 EA 74 CB 15 B0 B7 C8 0B 0D 25
-0130 | C5 C6 B4 47 A7 8C 63 0E 8D F1 F5 EA 72 C6 F8 71
-0140 | F7 C5 DA F8 3F 49 57 2A 4B 9A 37 4E 4D 6B 59 AC
-0150 | C4 26 7A 2D 2A C4 1B 46 28 8E 85 AA C5 69 85 9C
-0160 | 54 1B E0 3A F5 37 BE F4 69 F6 4A C5 DE FA 14 B8
-0170 | 8C 6E 30 19 7E 1C 17 AA A2 E4 90 4D 5E FF 32 30
-0180 | 20 D6 92 4C 56 6B D9 2E 5B E2 57 B8
-

Payload serialization:

-
set_client_DH_params#f5045f1f nonce:int128 server_nonce:int128 encrypted_data:string = Set_client_DH_params_answer;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterOffset, Length in bytesValueDescription
auth_key_id0, 80x00000000000000000 since the message is in plain text
message_id8, 80x08000000268a9c64Exact unixtime*2^32, +(4*N) if N messages with the same message ID were already generated
message_length16, 40x78010000 (376 in decimal)Message body length
%(set_client_DH_params)20, 40x1f5f04f5set_client_DH_params constructor number from TL schema
nonce24, 160xFCB57C8A1924E62DB22CFC639160820AValue generated by client in Step 1
server_nonce40, 160x1950DF440D630B941A82759697649586Value received from server in Step 2
encrypted_data56, 3400xFE500100BCE0FD2238D827BBC7D4ABE0A02DF466323AE9C78A735BAACFE1463710D9185381296B2150FAADA20A114DA631C385F11CB8821AB76EC9FCF29D7AAB834C20CACC733E484FCC6678CB65AD950C3AB365488C3982694ABF33F77DB003954B3C73F27FAA986CF90D5EC582B42DB774B087D584C1E73E1A4DC69959E87B00B1214EF6164A4C02DAF4BFE5A099379E7DE273333143C32FF997835390E19311961CEF909AE0FB30231F676BFE55E1DAE1383FFE490A4F88FA0FE282D4C460E7A016D015D97185680C86286FF6C573FA4CFA29BD81FB85A0E224B7081E701CDE0CEB6AB0235E6DA88283D342A0EA74CB15B0B7C80B0D25C5C6B447A78C630E8DF1F5EA72C6F871F7C5DAF83F49572A4B9A374E4D6B59ACC4267A2D2AC41B46288E85AAC569859C541BE03AF537BEF469F64AC5DEFA14B88C6E30197E1C17AAA2E4904D5EFF323020D6924C566BD92E5BE257B8Encrypted client_DH_inner_data, generated as follows
+Sent payload (excluding transport headers/trailers): +``` +0000 | 00 00 00 00 00 00 00 00 00 00 00 00 B9 8A 9C 64 +0010 | 78 01 00 00 1F 5F 04 F5 11 A6 CF 5E 75 A0 49 3C +0020 | 2B 49 CC E8 13 A9 81 7F 6E C1 8F 2E E4 4F 91 85 +0030 | BB DF D1 30 9C 7E 94 C3 FE 50 01 00 4A 19 2D B9 +0040 | 8C 3A 82 9E 71 89 03 A8 3F 87 2D 56 36 E3 03 D7 +0050 | 66 9E E0 53 4B 98 28 AF 8D D9 42 4E 68 F6 8E A4 +0060 | 0B D6 1D 36 74 CF BD 7A 13 79 D2 F2 6D 37 9E 13 +0070 | 04 6E 18 33 1A F0 00 3A 31 7B 41 AC B1 8C 84 9D +0080 | 3F 1C E5 76 6A C9 01 DF FD EC 20 D5 2F 22 BD 26 +0090 | F5 BD 0E 4A F5 05 E1 4E 7A 4E A6 5D 96 AC B0 9F +00A0 | A7 AF E7 28 2E F8 5E 9C 33 4D 6F 4C 72 12 95 6C +00B0 | 9D 46 19 C2 FC 07 38 AB 3D 59 DD AB CB B4 1F 61 +00C0 | FB 20 29 51 0B 00 C5 03 BC 29 8A 0F 55 F4 2D 54 +00D0 | A9 17 A2 92 54 CB EB F4 74 BA 0F DA F9 0D C5 71 +00E0 | B4 DB C3 85 C2 96 D1 78 6D 46 F9 63 26 EF F2 CE +00F0 | F9 84 E0 02 87 6B EC 81 4D 10 54 B8 9F C2 B3 58 +0100 | C9 73 CE 16 2D CA 58 5C A3 D1 3A FF 64 78 15 74 +0110 | 13 BC 6B CF D5 57 72 1A FF B1 A7 F5 FF 5B 47 90 +0120 | BA A1 22 41 6F B3 9C 1D 55 6B 8F 0A B7 11 02 86 +0130 | 02 0A E2 3C BE A3 0D 87 CB 9F 09 A0 BD 98 6D 07 +0140 | 09 79 7E FF 02 CC 8E 3C F2 FB CF 5A F8 01 74 16 +0150 | BE 1B A8 E5 39 27 0D B2 B9 6A 7C 52 4D A9 39 8C +0160 | 66 51 83 4E 80 19 0C DF 4A 68 C7 6E E0 69 7A 4B +0170 | 6F 61 9C 23 89 FF DB C9 C0 7F D3 C1 B9 C9 C1 E3 +0180 | 01 30 E0 5D BE 1E 71 01 2D 4E B1 3E +``` + +Payload serialization: +``` +set_client_DH_params#f5045f1f nonce:int128 server_nonce:int128 encrypted_data:string = Set_client_DH_params_answer; +``` + +| Parameter | Offset, Length in bytes | Value | Description | +| --- | --- | --- | --- | +| auth\_key\_id | 0, 8 | `0x0000000000000000` | 0 since the message is in plain text | +| message\_id | 8, 8 | `0x00000000b98a9c64` | Exact `unixtime*2^32`, `+(4*N)` if N messages with the same message ID were already generated | +| message\_length | 16, 4 | `0x78010000` (376 in decimal) | Message body length | +| %(set\_client\_DH\_params) | 20, 4 | `0x1f5f04f5` | *set_client_DH_params* constructor number from TL schema | +| nonce | 24, 16 | `0x11A6CF5E75A0493C2B49CCE813A9817F` | Value generated by client in Step 1 | +| server\_nonce | 40, 16 | `0x6EC18F2EE44F9185BBDFD1309C7E94C3` | Value received from server in Step 2 | +| encrypted\_data | 56, 340 | `encrypted_data` generated as specified above | Encrypted client_DH_inner_data, generated as follows | -

6. auth key generation

+ + + +

6. auth key generation

The clients computes the auth_key using formula g^{ab} mod dh_prime:

-
auth_key = 0x67084A6AC73ADB4F6F024825C0FBE8393D57D222A167784B71C03EA1F82F58DF072A7E6D7B12F9755AA58B2E9EB10951A917F55946C7306A3E2B233DA31FFE7FA1D1F5130BFB31163841E2F2BBD7E3175083F90188E96D133693C7DE938A25938F4AAF8AD7A2F249BFC3173E96BBB7BA90DE1DD7595A6F62EC3CCB7FE2230615B7DE3717E360CDA00A1B8AA79DE784B3D50D1F651C9444376EFC8F7C1B8CBDC43B207F081072A8C3FEEE62F84C180D3E46C8E66586D336D97E3BE1D3AAF2E4F238C0187B00219167449F46CE462B493E82C3EF897769CE698178B2EA316AE228ECE4BC209A98C64EF7BAE32403B2FE1965CE899EA96EB9B61C283B14C2DA27F7
+``` +auth_key = 0x601CF45E7710FAF92974966991717F290CBE12C1F33DDA0DDBC6EC216ABF9C40DF61D151CCB79245769A486B67D2787B30879EAC574F3352E1368CC90BBEF5E1949A665B9426E3E46C60692059F886A364DD8BB4A87DD9F89CFAB1D39C296333F3CE9F3906602FB5DF10B194DB5559092901C57F401B6ED658DBE28DF411B227D5385B678E1EF3ACD6FCD0FE6F4B6C757A3B32033A1DCD633195877C8FF2D434195E05579B638F098358FC87F2A22DDCC425F71E081DA43981F1C84462C40FF8C8C37997D1D462FB5B792D61AFB85781389D7372D913A9088D6CEC01AC9E39EDBC860BED23204E6E4423C65CD067726B2FA96425E8B45A25B62D1AC6988A2D2C +``` -

7. reply set_client_dh_params_answer

-

The server verifies and confirms that auth_key_hash is unique: since it's unique, it replies with the following:

+ + + +

7. reply set_client_dh_params_answer

+

The server verifies and confirms that auth_key_hash is unique: since it's unique, it replies with the following:

-

Received payload (excluding transport headers/trailers):

-
0000 | 00 00 00 00 00 00 00 00 01 D4 2A 11 27 8A 9C 64
-0010 | 4C 00 00 00 34 F7 CB 3B FC B5 7C 8A 19 24 E6 2D
-0020 | B2 2C FC 63 91 60 82 0A 19 50 DF 44 0D 63 0B 94
-0030 | 1A 82 75 96 97 64 95 86 DC 0E A4 DD 44 3A 6A 18
-0040 | E3 A3 7B 86 83 D7 FD 0A
-

Payload serialization:

-
dh_gen_ok#3bcbf734 nonce:int128 server_nonce:int128 new_nonce_hash1:int128 = Set_client_DH_params_answer;
+Received payload (excluding transport headers/trailers):
+```
+0000 | 00 00 00 00 00 00 00 00 01 38 B3 5A B9 8A 9C 64
+0010 | A8 00 00 00 34 F7 CB 3B 11 A6 CF 5E 75 A0 49 3C
+0020 | 2B 49 CC E8 13 A9 81 7F 6E C1 8F 2E E4 4F 91 85
+0030 | BB DF D1 30 9C 7E 94 C3 76 69 CC A2 EA D4 60 99
+0040 | 9B DE 54 21 79 5A B8 98
+```
+
+Payload serialization:
+```
+dh_gen_ok#3bcbf734 nonce:int128 server_nonce:int128 new_nonce_hash1:int128 = Set_client_DH_params_answer;
 dh_gen_retry#46dc1fb9 nonce:int128 server_nonce:int128 new_nonce_hash2:int128 = Set_client_DH_params_answer;
-dh_gen_fail#a69dae02 nonce:int128 server_nonce:int128 new_nonce_hash3:int128 = Set_client_DH_params_answer;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterOffset, Length in bytesValueDescription
auth_key_id0, 80x00000000000000000 since the message is in plain text
message_id8, 80x01d42a11278a9c64Exact unixtime*2^32, +(4*N) if N messages with the same message ID were already generated
message_length16, 40x4c000000 (76 in decimal)Message body length
%(dh_gen_ok)20, 40x34f7cb3bdh_gen_ok constructor number from TL schema
nonce24, 160xFCB57C8A1924E62DB22CFC639160820AValue generated by client in Step 1
server_nonce40, 160x1950DF440D630B941A82759697649586Value received from server in Step 2
new_nonce_hash156, 160xDC0EA4DD443A6A18E3A37B8683D7FD0AThe 128 lower-order bits of SHA1 of the byte string derived from the new_nonce string by adding a single byte with the value of 1, 2, or 3, and followed by another 8 bytes with auth_key_aux_hash. Different values are required to prevent an intruder from changing server response dh_gen_ok into dh_gen_retry.
-
+dh_gen_fail#a69dae02 nonce:int128 server_nonce:int128 new_nonce_hash3:int128 = Set_client_DH_params_answer; +``` + +| Parameter | Offset, Length in bytes | Value | Description | +| --- | --- | --- | --- | +| auth\_key\_id | 0, 8 | `0x0000000000000000` | 0 since the message is in plain text | +| message\_id | 8, 8 | `0x0138b35ab98a9c64` | Exact `unixtime*2^32`, `+(4*N)` if N messages with the same message ID were already generated | +| message\_length | 16, 4 | `0xa8000000` (168 in decimal) | Message body length | +| %(dh\_gen\_ok) | 20, 4 | `0x34f7cb3b` | *dh_gen_ok* constructor number from TL schema | +| nonce | 24, 16 | `0x11A6CF5E75A0493C2B49CCE813A9817F` | Value generated by client in Step 1 | +| server\_nonce | 40, 16 | `0x6EC18F2EE44F9185BBDFD1309C7E94C3` | Value received from server in Step 2 | +| new\_nonce\_hash1 | 56, 16 | `0x7669CCA2EAD460999BDE5421795AB898` | The 128 lower-order bits of SHA1 of the byte string derived from the `new_nonce` string by adding a single byte with the value of 1, 2, or 3, and followed by another 8 bytes with `auth_key_aux_hash`. Different values are required to prevent an intruder from changing server response dh_gen_ok into dh_gen_retry. | + +