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

namespace MyTelegram.Schema;

///<summary>
/// Encrypted chat
/// See <a href="https://corefork.telegram.org/constructor/encryptedChat" />
///</summary>
[TlObject(0x61f0d4c7)]
public sealed class TEncryptedChat : IEncryptedChat
{
    public uint ConstructorId => 0x61f0d4c7;
    ///<summary>
    /// Chat ID
    ///</summary>
    public int Id { get; set; }

    ///<summary>
    /// Check sum dependent on the user ID
    ///</summary>
    public long AccessHash { get; set; }

    ///<summary>
    /// Date chat was created
    ///</summary>
    public int Date { get; set; }

    ///<summary>
    /// Chat creator ID
    ///</summary>
    public long AdminId { get; set; }

    ///<summary>
    /// ID of the second chat participant
    ///</summary>
    public long ParticipantId { get; set; }

    ///<summary>
    /// <code>B = g ^ b mod p</code>, if the currently authorized user is the chat's creator,<br>or <code>A = g ^ a mod p</code> otherwise<br>See <a href="https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange">Wikipedia</a> for more info
    ///</summary>
    public ReadOnlyMemory<byte> GAOrB { get; set; }

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

    public void ComputeFlag()
    {

    }

    public void Serialize(IBufferWriter<byte> writer)
    {
        ComputeFlag();
        writer.Write(ConstructorId);
        writer.Write(Id);
        writer.Write(AccessHash);
        writer.Write(Date);
        writer.Write(AdminId);
        writer.Write(ParticipantId);
        writer.Write(GAOrB);
        writer.Write(KeyFingerprint);
    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Id = buffer.ReadInt32();
        AccessHash = buffer.ReadInt64();
        Date = buffer.ReadInt32();
        AdminId = buffer.ReadInt64();
        ParticipantId = buffer.ReadInt64();
        GAOrB = buffer.ReadBytes();
        KeyFingerprint = buffer.ReadInt64();
    }
}