// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// PasswordKdfAlgoUnknown represents TL type `passwordKdfAlgoUnknown#d45ab096`.
// Unknown KDF (most likely, the client is outdated and does not support the specified
// KDF algorithm)
//
// See https://core.telegram.org/constructor/passwordKdfAlgoUnknown for reference.
type PasswordKdfAlgoUnknown struct {
}

// PasswordKdfAlgoUnknownTypeID is TL type id of PasswordKdfAlgoUnknown.
const PasswordKdfAlgoUnknownTypeID = 0xd45ab096

// construct implements constructor of PasswordKdfAlgoClass.
func ( PasswordKdfAlgoUnknown) () PasswordKdfAlgoClass { return & }

// Ensuring interfaces in compile-time for PasswordKdfAlgoUnknown.
var (
	_ bin.Encoder     = &PasswordKdfAlgoUnknown{}
	_ bin.Decoder     = &PasswordKdfAlgoUnknown{}
	_ bin.BareEncoder = &PasswordKdfAlgoUnknown{}
	_ bin.BareDecoder = &PasswordKdfAlgoUnknown{}

	_ PasswordKdfAlgoClass = &PasswordKdfAlgoUnknown{}
)

func ( *PasswordKdfAlgoUnknown) () bool {
	if  == nil {
		return true
	}

	return true
}

// String implements fmt.Stringer.
func ( *PasswordKdfAlgoUnknown) () string {
	if  == nil {
		return "PasswordKdfAlgoUnknown(nil)"
	}
	type  PasswordKdfAlgoUnknown
	return fmt.Sprintf("PasswordKdfAlgoUnknown%+v", (*))
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PasswordKdfAlgoUnknown) () uint32 {
	return PasswordKdfAlgoUnknownTypeID
}

// TypeName returns name of type in TL schema.
func (*PasswordKdfAlgoUnknown) () string {
	return "passwordKdfAlgoUnknown"
}

// TypeInfo returns info about TL type.
func ( *PasswordKdfAlgoUnknown) () tdp.Type {
	 := tdp.Type{
		Name: "passwordKdfAlgoUnknown",
		ID:   PasswordKdfAlgoUnknownTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *PasswordKdfAlgoUnknown) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode passwordKdfAlgoUnknown#d45ab096 as nil")
	}
	.PutID(PasswordKdfAlgoUnknownTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PasswordKdfAlgoUnknown) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode passwordKdfAlgoUnknown#d45ab096 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PasswordKdfAlgoUnknown) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode passwordKdfAlgoUnknown#d45ab096 to nil")
	}
	if  := .ConsumeID(PasswordKdfAlgoUnknownTypeID);  != nil {
		return fmt.Errorf("unable to decode passwordKdfAlgoUnknown#d45ab096: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PasswordKdfAlgoUnknown) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode passwordKdfAlgoUnknown#d45ab096 to nil")
	}
	return nil
}

// PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow represents TL type `passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow#3a912d4a`.
// This key derivation algorithm defines that SRP 2FA login¹ must be used
//
// Links:
//  1. https://core.telegram.org/api/srp
//
// See https://core.telegram.org/constructor/passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow for reference.
type PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow struct {
	// One of two salts used by the derivation function (see SRP 2FA login¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/srp
	Salt1 []byte
	// One of two salts used by the derivation function (see SRP 2FA login¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/srp
	Salt2 []byte
	// Base (see SRP 2FA login¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/srp
	G int
	// 2048-bit modulus (see SRP 2FA login¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/srp
	P []byte
}

// PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPowTypeID is TL type id of PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow.
const PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPowTypeID = 0x3a912d4a

// construct implements constructor of PasswordKdfAlgoClass.
func ( PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow) () PasswordKdfAlgoClass {
	return &
}

// Ensuring interfaces in compile-time for PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow.
var (
	_ bin.Encoder     = &PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow{}
	_ bin.Decoder     = &PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow{}
	_ bin.BareEncoder = &PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow{}
	_ bin.BareDecoder = &PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow{}

	_ PasswordKdfAlgoClass = &PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow{}
)

func ( *PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow) () bool {
	if  == nil {
		return true
	}
	if !(.Salt1 == nil) {
		return false
	}
	if !(.Salt2 == nil) {
		return false
	}
	if !(.G == 0) {
		return false
	}
	if !(.P == nil) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow) () string {
	if  == nil {
		return "PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow(nil)"
	}
	type  PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow
	return fmt.Sprintf("PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow%+v", (*))
}

// FillFrom fills PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow from given interface.
func ( *PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow) ( interface {
	() ( []byte)
	() ( []byte)
	() ( int)
	() ( []byte)
}) {
	.Salt1 = .()
	.Salt2 = .()
	.G = .()
	.P = .()
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow) () uint32 {
	return PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPowTypeID
}

// TypeName returns name of type in TL schema.
func (*PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow) () string {
	return "passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow"
}

// TypeInfo returns info about TL type.
func ( *PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow) () tdp.Type {
	 := tdp.Type{
		Name: "passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow",
		ID:   PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPowTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Salt1",
			SchemaName: "salt1",
		},
		{
			Name:       "Salt2",
			SchemaName: "salt2",
		},
		{
			Name:       "G",
			SchemaName: "g",
		},
		{
			Name:       "P",
			SchemaName: "p",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow#3a912d4a as nil")
	}
	.PutID(PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPowTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow#3a912d4a as nil")
	}
	.PutBytes(.Salt1)
	.PutBytes(.Salt2)
	.PutInt(.G)
	.PutBytes(.P)
	return nil
}

// Decode implements bin.Decoder.
func ( *PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow#3a912d4a to nil")
	}
	if  := .ConsumeID(PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPowTypeID);  != nil {
		return fmt.Errorf("unable to decode passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow#3a912d4a: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow#3a912d4a to nil")
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow#3a912d4a: field salt1: %w", )
		}
		.Salt1 = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow#3a912d4a: field salt2: %w", )
		}
		.Salt2 = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow#3a912d4a: field g: %w", )
		}
		.G = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow#3a912d4a: field p: %w", )
		}
		.P = 
	}
	return nil
}

// GetSalt1 returns value of Salt1 field.
func ( *PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow) () ( []byte) {
	if  == nil {
		return
	}
	return .Salt1
}

// GetSalt2 returns value of Salt2 field.
func ( *PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow) () ( []byte) {
	if  == nil {
		return
	}
	return .Salt2
}

// GetG returns value of G field.
func ( *PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow) () ( int) {
	if  == nil {
		return
	}
	return .G
}

// GetP returns value of P field.
func ( *PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow) () ( []byte) {
	if  == nil {
		return
	}
	return .P
}

// PasswordKdfAlgoClassName is schema name of PasswordKdfAlgoClass.
const PasswordKdfAlgoClassName = "PasswordKdfAlgo"

// PasswordKdfAlgoClass represents PasswordKdfAlgo generic type.
//
// See https://core.telegram.org/type/PasswordKdfAlgo for reference.
//
// Example:
//
//	g, err := tg.DecodePasswordKdfAlgo(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.PasswordKdfAlgoUnknown: // passwordKdfAlgoUnknown#d45ab096
//	case *tg.PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow: // passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow#3a912d4a
//	default: panic(v)
//	}
type PasswordKdfAlgoClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() PasswordKdfAlgoClass

	// TypeID returns type id in TL schema.
	//
	// See https://core.telegram.org/mtproto/TL-tl#remarks.
	TypeID() uint32
	// TypeName returns name of type in TL schema.
	TypeName() string
	// String implements fmt.Stringer.
	String() string
	// Zero returns true if current object has a zero value.
	Zero() bool
}

// DecodePasswordKdfAlgo implements binary de-serialization for PasswordKdfAlgoClass.
func ( *bin.Buffer) (PasswordKdfAlgoClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case PasswordKdfAlgoUnknownTypeID:
		// Decoding passwordKdfAlgoUnknown#d45ab096.
		 := PasswordKdfAlgoUnknown{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PasswordKdfAlgoClass: %w", )
		}
		return &, nil
	case PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPowTypeID:
		// Decoding passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow#3a912d4a.
		 := PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PasswordKdfAlgoClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode PasswordKdfAlgoClass: %w", bin.NewUnexpectedID())
	}
}

// PasswordKdfAlgo boxes the PasswordKdfAlgoClass providing a helper.
type PasswordKdfAlgoBox struct {
	PasswordKdfAlgo PasswordKdfAlgoClass
}

// Decode implements bin.Decoder for PasswordKdfAlgoBox.
func ( *PasswordKdfAlgoBox) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("unable to decode PasswordKdfAlgoBox to nil")
	}
	,  := DecodePasswordKdfAlgo()
	if  != nil {
		return fmt.Errorf("unable to decode boxed value: %w", )
	}
	.PasswordKdfAlgo = 
	return nil
}

// Encode implements bin.Encode for PasswordKdfAlgoBox.
func ( *PasswordKdfAlgoBox) ( *bin.Buffer) error {
	if  == nil || .PasswordKdfAlgo == nil {
		return fmt.Errorf("unable to encode PasswordKdfAlgoClass as nil")
	}
	return .PasswordKdfAlgo.Encode()
}