package crypto

import 

// EncryptedMessage of protocol.
type EncryptedMessage struct {
	AuthKeyID [8]byte
	MsgKey    bin.Int128

	EncryptedData []byte
}

// Decode implements bin.Decoder.
func ( *EncryptedMessage) ( *bin.Buffer) error {
	if  := .ConsumeN(.AuthKeyID[:], 8);  != nil {
		return 
	}
	{
		,  := .Int128()
		if  != nil {
			return 
		}
		.MsgKey = 
	}
	// Consuming the rest of the buffer.
	.EncryptedData = append(.EncryptedData[:0], make([]byte, .Len())...)
	if  := .ConsumeN(.EncryptedData, .Len());  != nil {
		return 
	}
	return nil
}

// DecodeWithoutCopy is like Decode, but EncryptedData references to given buffer instead of
// copying.
func ( *EncryptedMessage) ( *bin.Buffer) error {
	if  := .ConsumeN(.AuthKeyID[:], 8);  != nil {
		return 
	}
	{
		,  := .Int128()
		if  != nil {
			return 
		}
		.MsgKey = 
	}
	// Consuming the rest of the buffer.
	.EncryptedData = .Buf
	return nil
}

// Encode implements bin.Encoder.
func ( EncryptedMessage) ( *bin.Buffer) error {
	.Put(.AuthKeyID[:])
	.PutInt128(.MsgKey)
	.Put(.EncryptedData)
	return nil
}