// <auto-generated/>
// ReSharper disable All

namespace MyTelegram.Schema.Messages;

///<summary>
/// Sends a request to start a secret chat to the user.
/// <para>Possible errors</para>
/// Code Type Description
/// 400 DH_G_A_INVALID g_a invalid.
/// 400 INPUT_USER_DEACTIVATED The specified user was deleted.
/// 400 USER_ID_INVALID The provided user ID is invalid.
/// See <a href="https://corefork.telegram.org/method/messages.requestEncryption" />
///</summary>
[TlObject(0xf64daf43)]
public sealed class RequestRequestEncryption : IRequest<MyTelegram.Schema.IEncryptedChat>
{
    public uint ConstructorId => 0xf64daf43;
    ///<summary>
    /// User ID
    /// See <a href="https://corefork.telegram.org/type/InputUser" />
    ///</summary>
    public MyTelegram.Schema.IInputUser UserId { get; set; }

    ///<summary>
    /// Unique client request ID required to prevent resending. This also doubles as the chat ID.
    ///</summary>
    public int RandomId { get; set; }

    ///<summary>
    /// <code>A = g ^ a mod p</code>, see <a href="https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange">Wikipedia</a>
    ///</summary>
    public byte[] GA { get; set; }

    public void ComputeFlag()
    {

    }

    public void Serialize(IBufferWriter<byte> writer)
    {
        ComputeFlag();
        writer.Write(ConstructorId);
        writer.Write(UserId);
        writer.Write(RandomId);
        writer.Write(GA);
    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        UserId = buffer.Read<MyTelegram.Schema.IInputUser>();
        RandomId = buffer.ReadInt32();
        GA = buffer.ReadBytes();
    }
}
