Class: MTProto::Type::AuthKey::SetClientDHParams

Inherits:
Object
  • Object
show all
Defined in:
lib/mtproto/type/auth_key/set_client_dh_params.rb

Constant Summary collapse

CONSTRUCTOR =
0xf5045f1f

Class Method Summary collapse

Class Method Details

.build(nonce:, server_nonce:, encrypted_data:) ⇒ Object

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
18
19
20
21
# File 'lib/mtproto/type/auth_key/set_client_dh_params.rb', line 11

def self.build(nonce:, server_nonce:, encrypted_data:)
  raise ArgumentError, 'Nonce must be 16 bytes' unless nonce.bytesize == 16
  raise ArgumentError, 'Server nonce must be 16 bytes' unless server_nonce.bytesize == 16

  body = Serializer.serialize_int(CONSTRUCTOR)
  body += nonce
  body += server_nonce
  body += Serializer.serialize_bytes(encrypted_data)

  body
end