// 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{}
)

// SecureCredentialsEncrypted represents TL type `secureCredentialsEncrypted#33f0ea47`.
// Encrypted credentials required to decrypt telegram passport¹ data.
//
// Links:
//  1. https://core.telegram.org/passport
//
// See https://core.telegram.org/constructor/secureCredentialsEncrypted for reference.
type SecureCredentialsEncrypted struct {
	// Encrypted JSON-serialized data with unique user's payload, data hashes and secrets
	// required for EncryptedPassportElement decryption and authentication, as described in
	// decrypting data »¹
	//
	// Links:
	//  1) https://core.telegram.org/passport#decrypting-data
	Data []byte
	// Data hash for data authentication as described in decrypting data »¹
	//
	// Links:
	//  1) https://core.telegram.org/passport#decrypting-data
	Hash []byte
	// Secret, encrypted with the bot's public RSA key, required for data decryption as
	// described in decrypting data »¹
	//
	// Links:
	//  1) https://core.telegram.org/passport#decrypting-data
	Secret []byte
}

// SecureCredentialsEncryptedTypeID is TL type id of SecureCredentialsEncrypted.
const SecureCredentialsEncryptedTypeID = 0x33f0ea47

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

func ( *SecureCredentialsEncrypted) () bool {
	if  == nil {
		return true
	}
	if !(.Data == nil) {
		return false
	}
	if !(.Hash == nil) {
		return false
	}
	if !(.Secret == nil) {
		return false
	}

	return true
}

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

// FillFrom fills SecureCredentialsEncrypted from given interface.
func ( *SecureCredentialsEncrypted) ( interface {
	() ( []byte)
	() ( []byte)
	() ( []byte)
}) {
	.Data = .()
	.Hash = .()
	.Secret = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *SecureCredentialsEncrypted) () tdp.Type {
	 := tdp.Type{
		Name: "secureCredentialsEncrypted",
		ID:   SecureCredentialsEncryptedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Data",
			SchemaName: "data",
		},
		{
			Name:       "Hash",
			SchemaName: "hash",
		},
		{
			Name:       "Secret",
			SchemaName: "secret",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *SecureCredentialsEncrypted) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode secureCredentialsEncrypted#33f0ea47 as nil")
	}
	.PutID(SecureCredentialsEncryptedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *SecureCredentialsEncrypted) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode secureCredentialsEncrypted#33f0ea47 as nil")
	}
	.PutBytes(.Data)
	.PutBytes(.Hash)
	.PutBytes(.Secret)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *SecureCredentialsEncrypted) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode secureCredentialsEncrypted#33f0ea47 to nil")
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode secureCredentialsEncrypted#33f0ea47: field data: %w", )
		}
		.Data = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode secureCredentialsEncrypted#33f0ea47: field hash: %w", )
		}
		.Hash = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode secureCredentialsEncrypted#33f0ea47: field secret: %w", )
		}
		.Secret = 
	}
	return nil
}

// GetData returns value of Data field.
func ( *SecureCredentialsEncrypted) () ( []byte) {
	if  == nil {
		return
	}
	return .Data
}

// GetHash returns value of Hash field.
func ( *SecureCredentialsEncrypted) () ( []byte) {
	if  == nil {
		return
	}
	return .Hash
}

// GetSecret returns value of Secret field.
func ( *SecureCredentialsEncrypted) () ( []byte) {
	if  == nil {
		return
	}
	return .Secret
}