func (pv PrivateKey) String() string {
	if len(pv.data.PrivateKey) == 0 {
		return ""
	}
	prefix := prefixPrivateKey
	data := make([]byte, 0, ed25519.PrivateKeySize+6)
	data = append(data, (*[2]byte)(unsafe.Pointer(&prefix))[:]...)
	data = append(data, pv.data.PrivateKey...)
	chksum := checksum(data)
	data = append(data, chksum[:]...)
	return base58.Encode(data)
}
String return the base58 encoding text of the private key with the prefix and checksum
package crypto
import (
	"bytes"
	"crypto/rand"
	"crypto/sha256"
	"io"
	"unsafe"
	"github.com/gallactic/gallactic/errors"
	"github.com/mr-tron/base58/base58"
	"golang.org/x/crypto/ed25519"
)
type PrivateKey struct {
	data privateKeyData
}
type privateKeyData struct {
	PrivateKey []byte
}
func PrivateKeyFromString(text string) (PrivateKey, error) {
	data, err := base58.Decode(text)
	if err != nil {
		return PrivateKey{}, e.Errorf(e.ErrInvalidPrivateKey, "%v", err.Error())
	}
	if len(data) != ed25519.PrivateKeySize+6 {
		return PrivateKey{}, e.Errorf(e.ErrInvalidPrivateKey, "Private key should be %v bytes but it is %v bytes", ed25519.PrivateKeySize+6, len(data))
	}
	err = validateChecksum(data)
	if err != nil {
		return PrivateKey{}, e.Errorf(e.ErrInvalidPrivateKey, err.Error())
	}
	err = validatePrefix(data, prefixPrivateKey)
	if err != nil {
		return PrivateKey{}, e.Errorf(e.ErrInvalidPrivateKey, err.Error())
	}
	bs := data[2 : ed25519.PrivateKeySize+2]
	return PrivateKeyFromRawBytes(bs)
}
func PrivateKeyFromRawBytes(bs []byte) (PrivateKey, error) {
	if len(bs) == 0 {
		return PrivateKey{}, nil
	}
	pv := PrivateKey{
		data: privateKeyData{
			PrivateKey: bs,
		},
	}
	if err := pv.EnsureValid(); err != nil {
		return PrivateKey{}, err
	}
	return pv, nil
}
func GenerateKeyFromSecret(secret string) (PublicKey, PrivateKey) {
	hasher := sha256.New()
	hasher.Write(([]byte)(secret))
	return GenerateKey(bytes.NewBuffer(hasher.Sum(nil)))
}
func GenerateKey(random io.Reader) (PublicKey, PrivateKey) {
	if random == nil {
		random = rand.Reader
	}
	pubKey, privKey, _ := ed25519.GenerateKey(random)
	pk, _ := PublicKeyFromRawBytes(pubKey)
	pv, _ := PrivateKeyFromRawBytes(privKey)
	return pk, pv
}
func (pv PrivateKey) RawBytes() []byte {
	return pv.data.PrivateKey
}