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

namespace MyTelegram.Schema.Messages;

///<summary>
/// New set of configuring parameters.
/// See <a href="https://corefork.telegram.org/constructor/messages.dhConfig" />
///</summary>
[TlObject(0x2c221edd)]
public sealed class TDhConfig : IDhConfig
{
    public uint ConstructorId => 0x2c221edd;
    ///<summary>
    /// New value <strong>prime</strong>, see <a href="https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange">Wikipedia</a>
    ///</summary>
    public int G { get; set; }

    ///<summary>
    /// New value <strong>primitive root</strong>, see <a href="https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange">Wikipedia</a>
    ///</summary>
    public ReadOnlyMemory<byte> P { get; set; }

    ///<summary>
    /// Version of set of parameters
    ///</summary>
    public int Version { get; set; }

    ///<summary>
    /// Random sequence of bytes of assigned length
    ///</summary>
    public ReadOnlyMemory<byte> Random { get; set; }

    public void ComputeFlag()
    {

    }

    public void Serialize(IBufferWriter<byte> writer)
    {
        ComputeFlag();
        writer.Write(ConstructorId);
        writer.Write(G);
        writer.Write(P);
        writer.Write(Version);
        writer.Write(Random);
    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        G = buffer.ReadInt32();
        P = buffer.ReadBytes();
        Version = buffer.ReadInt32();
        Random = buffer.ReadBytes();
    }
}