func addressFromHash(hash []byte, prefix uint16) (Address, error) {
	if len(hash) != 20 {
		return Address{}, e.Errorf(e.ErrInvalidAddress, "Address hash should be 20 bytes but it is %v bytes", len(hash))
	}
	data := make([]byte, 0, AddressSize)
	data = append(data, (*[2]byte)(unsafe.Pointer(&prefix))[:]...)
	data = append(data, hash...)
	chksum := checksum(data)
	data = append(data, chksum[:]...)
	return AddressFromRawBytes(data)
}
/ this is a private constructor
package crypto
import (
	"bytes"
	"unsafe"
	e "github.com/gallactic/gallactic/errors"
	"github.com/mr-tron/base58/base58"
)
const AddressSize = 26
type Address struct {
	data addressData
}
type addressData struct {
	Address [AddressSize]byte
}
func AddressFromString(text string) (Address, error) {
	bs, err := base58.Decode(text)
	if err != nil {
		return Address{}, e.Errorf(e.ErrInvalidAddress, "%v", err.Error())
	}
	return AddressFromRawBytes(bs)
}
func AddressFromRawBytes(bs []byte) (Address, error) {
	if len(bs) != AddressSize {
		return Address{}, e.Errorf(e.ErrInvalidAddress, "Address should be %d bytes, but it is %v bytes", AddressSize, len(bs))
	}
	var addr Address
	copy(addr.data.Address[:], bs[:])
	if err := addr.EnsureValid(); err != nil {
		return Address{}, err
	}
	return addr, nil
}
func ContractAddress(bs []byte) (Address, error) {
	return addressFromHash(bs, prefixContractAddress)
}
func AccountAddress(bs []byte) (Address, error) {
	return addressFromHash(bs, prefixAccountAddress)
}
func ValidatorAddress(bs []byte) (Address, error) {
	return addressFromHash(bs, prefixValidatorAddress)
}