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

namespace MyTelegram.Schema.Messages;

///<summary>
/// Confirms creation of a secret chat
/// <para>Possible errors</para>
/// Code Type Description
/// 400 CHAT_ID_INVALID The provided chat id is invalid.
/// 400 ENCRYPTION_ALREADY_ACCEPTED Secret chat already accepted.
/// 400 ENCRYPTION_ALREADY_DECLINED The secret chat was already declined.
/// See <a href="https://corefork.telegram.org/method/messages.acceptEncryption" />
///</summary>
[TlObject(0x3dbc0415)]
public sealed class RequestAcceptEncryption : IRequest<MyTelegram.Schema.IEncryptedChat>
{
    public uint ConstructorId => 0x3dbc0415;
    ///<summary>
    /// Secret chat ID
    /// See <a href="https://corefork.telegram.org/type/InputEncryptedChat" />
    ///</summary>
    public MyTelegram.Schema.IInputEncryptedChat Peer { get; set; }

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

    ///<summary>
    /// 64-bit fingerprint of the received key
    ///</summary>
    public long KeyFingerprint { get; set; }

    public void ComputeFlag()
    {

    }

    public void Serialize(IBufferWriter<byte> writer)
    {
        ComputeFlag();
        writer.Write(ConstructorId);
        writer.Write(Peer);
        writer.Write(GB);
        writer.Write(KeyFingerprint);
    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Peer = buffer.Read<MyTelegram.Schema.IInputEncryptedChat>();
        GB = buffer.ReadBytes();
        KeyFingerprint = buffer.ReadInt64();
    }
}
