func KeypairFromHex(hexString string) (*Keypair, error) {
	privBytes, err := hex.DecodeString(hexString)
	if err != nil {
		return nil, err
	}
	return KeypairFromBytes(privBytes), nil
}
KeypairFromHex is a keypair from a hex string.
package keystore
import (
	"encoding/hex"
	"github.com/decred/dcrd/dcrec/secp256k1"
	"github.com/phoreproject/synapse/chainhash"
	"github.com/phoreproject/synapse/shard/transfer"
	"github.com/phoreproject/synapse/wallet/address"
)
type Keypair struct {
	key secp256k1.PrivateKey
	pubkey secp256k1.PublicKey
}
func (k *Keypair) Transfer(shardID uint32, nonce uint32, to address.Address, amount uint64) (*transfer.ShardTransaction, error) {
	fromPkhBytes := address.HashPubkey(&k.pubkey, shardID)
	var fromPkh [20]byte
	copy(fromPkh[:], fromPkhBytes)
	toPkh, err := to.ToPubkeyHash()
	if err != nil {
		return nil, err
	}
	tx := transfer.ShardTransaction{
		FromPubkeyHash: fromPkh,
		ToPubkeyHash:   toPkh,
		Amount:         amount,
		Nonce:          nonce,
	}
	message := tx.GetTransactionData()
	messageHash := chainhash.HashH(message[:])
	sigBytes, err := secp256k1.SignCompact(&k.key, messageHash[:], false)
	if err != nil {
		return nil, err
	}
	copy(tx.Signature[:], sigBytes)
	return &tx, nil
}
func (k *Keypair) GetAddress(shardID uint32) address.Address {
	addr := address.PubkeyToAddress(&k.pubkey, shardID)
	return addr
}
func (k *Keypair) GetPubkeyHash(shardID uint32) [20]byte {
	var pkh [20]byte
	out := address.HashPubkey(&k.pubkey, shardID)
	copy(pkh[:], out)
	return pkh
}
func GenerateRandomKeypair() (*Keypair, error) {
	randKey, err := secp256k1.GeneratePrivateKey()
	if err != nil {
		return nil, err
	}
	pub := randKey.PubKey()
	return &Keypair{
		key: *randKey,
		pubkey: *pub,
	}, nil
}