func ExtendUint8(b []uint8, needLen int) []uint8 {
	b = b[:cap(b)]
	if n := needLen - cap(b); n > 0 {
		b = append(b, make([]uint8, n)...)
	}
	return b[:needLen]
}
ExtendUint16 extends a uint16 buffer to a given size
package ssz
import (
	"encoding/binary"
	"fmt"
	"math/bits"
)
func MarshalSSZ(m Marshaler) ([]byte, error) {
	buf := make([]byte, m.SizeSSZ())
	return m.MarshalSSZTo(buf[:0])
}
var (
	ErrOffset       = fmt.Errorf("incorrect offset")
	ErrSize         = fmt.Errorf("incorrect size")
	ErrBytesLength  = fmt.Errorf("bytes array does not have the correct length")
	ErrVectorLength = fmt.Errorf("vector does not have the correct length")
	ErrListTooBig   = fmt.Errorf("list length is higher than max value")
	ErrEmptyBitlist = fmt.Errorf("bitlist is empty")
	ErrInvalidVariableOffset = fmt.Errorf("invalid ssz encoding. first variable element offset indexes into fixed value data")
)
func UnmarshallUint64(src []byte) uint64 {
	return binary.LittleEndian.Uint64(src)
}
func UnmarshallUint32(src []byte) uint32 {
	return binary.LittleEndian.Uint32(src[:4])
}
func UnmarshallUint16(src []byte) uint16 {
	return binary.LittleEndian.Uint16(src[:2])
}
func UnmarshallUint8(src []byte) uint8 {
	return uint8(src[0])
}
func UnmarshalBool(src []byte) bool {
	if src[0] == 1 {
		return true
	}
	return false
}
func MarshalUint64(dst []byte, i uint64) []byte {
	buf := make([]byte, 8)
	binary.LittleEndian.PutUint64(buf, i)
	dst = append(dst, buf...)
	return dst
}
func MarshalUint32(dst []byte, i uint32) []byte {
	buf := make([]byte, 4)
	binary.LittleEndian.PutUint32(buf, i)
	dst = append(dst, buf...)
	return dst
}
func MarshalUint16(dst []byte, i uint16) []byte {
	buf := make([]byte, 2)
	binary.LittleEndian.PutUint16(buf, i)
	dst = append(dst, buf...)
	return dst
}
func MarshalUint8(dst []byte, i uint8) []byte {
	dst = append(dst, byte(i))
	return dst
}
func MarshalBool(dst []byte, b bool) []byte {
	if b {
		dst = append(dst, 1)
	} else {
		dst = append(dst, 0)
	}
	return dst
}
func WriteOffset(dst []byte, i int) []byte {
	return MarshalUint32(dst, uint32(i))
}
func ReadOffset(buf []byte) uint64 {
	return uint64(binary.LittleEndian.Uint32(buf))
}
func safeReadOffset(buf []byte) (uint64, []byte, error) {
	if len(buf) < 4 {
		return 0, nil, fmt.Errorf("")
	}
	offset := ReadOffset(buf)
	return offset, buf[4:], nil
}
func extendByteSlice(b []byte, needLen int) []byte {
	b = b[:cap(b)]
	if n := needLen - cap(b); n > 0 {
		b = append(b, make([]byte, n)...)
	}
	return b[:needLen]
}
func ExtendUint64(b []uint64, needLen int) []uint64 {
	b = b[:cap(b)]
	if n := needLen - cap(b); n > 0 {
		b = append(b, make([]uint64, n)...)
	}
	return b[:needLen]
}
func ExtendUint16(b []uint16, needLen int) []uint16 {
	b = b[:cap(b)]
	if n := needLen - cap(b); n > 0 {
		b = append(b, make([]uint16, n)...)
	}
	return b[:needLen]
}