Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cipher ¶
type Cipher interface { Encrypt(keyID [8]byte, content []byte) ([]byte, error) Decrypt(data []byte) ([]byte, error) }
func NewClientCipher ¶
NewClientCipher creates new client-side Cipher.
type Envelope ¶
Envelope is a data inside encrypted part of encrypted message.
compatible with MTProto 1.0 and 2.0
https://core.telegram.org/mtproto/description#encrypted-message-encrypted-data
func DeserializeEnvelope ¶
type Int256 ¶
type Int256 = [32]byte
func Keys ¶
Keys returns (aes_key, aes_iv) pair for AES-IGE.
See https://core.telegram.org/mtproto/description#defining-aes-key-and-initialization-vector
Example:
key, iv := crypto.Keys(authKey, messageKey, crypto.Client) cipher, err := aes.NewCipher(key[:]) if err != nil { return nil, err } encryptor := ige.NewIGEEncrypter(cipher, iv[:])
type MsgID ¶
type MsgID uint64
MsgID is a unique identifier of a message in MTProto protocol.
Scheme of message_id (showed):
|1-31|32-61|62|63| |A |B |C |D |
Where:
- A: Approximately equal current unix time
- B: Any random unique 30-bit number
- C: Indicates the message initiator: 0 — for client-initiated (request or server response), 1 — for server-initiated (notification or client response to server request).
- D: message side (0 means client sent message, 1 means server did)
More info: https://core.telegram.org/mtproto/description#message-identifier-msg-id
func GenerateMessageID ¶
GenerateMessageId essentially gives unix timestamp, but in a horribly specific way.
See MsgID for more info how it works
type Side ¶
type Side int8
func (Side) X ¶
Initial vector extension for AES key. See more here: https://core.telegram.org/mtproto/description#defining-aes-key-and-initialization-vector
if side is odd (server side) — returns 8
type Unencrypted ¶
func DeserializeUnencrypted ¶
func DeserializeUnencrypted(data []byte) (*Unencrypted, error)
More info: https://core.telegram.org/mtproto/description#unencrypted-message
func (*Unencrypted) Serialize ¶
func (msg *Unencrypted) Serialize() (res []byte)
compatible with MTProto 1.0 and 2.0
More info: https://core.telegram.org/mtproto/description#unencrypted-message