func NewPublicKeyFromString(s string) (PublicKey, error) {
	data := base58.Decode(s)
	return NewPublicKey(data)
}
NewPublicKeyFromString creates a new public key from a base58 encoded string data.
package crypto
import (
	"encoding/hex"
	"errors"
	"fmt"
	"github.com/btcsuite/btcd/btcec"
	"github.com/btcsuite/btcutil/base58"
	"github.com/libonomy/libonomy-p2p/log"
)
type Key interface {
	String() string  
	Bytes() []byte   
	Pretty() string  
}
type PrivateKey interface {
	Key
	GetPublicKey() PublicKey  
	Sign([]byte) ([]byte, error)
	Decrypt(in []byte) ([]byte, error)
	InternalKey() *btcec.PrivateKey
}
type PublicKey interface {  
	Key
	Verify(data []byte, sig []byte) (bool, error)
	VerifyString(data []byte, sig string) (bool, error)
	Encrypt(in []byte) ([]byte, error)
	InternalKey() *btcec.PublicKey
}
type publicKeyImpl struct {
	k *btcec.PublicKey
}
type privateKeyImpl struct {
	k *btcec.PrivateKey
}
func GenerateKeyPair() (PrivateKey, PublicKey, error) {
	privKey, err := btcec.NewPrivateKey(btcec.S256())
	if err != nil {
		return nil, nil, err
	}
	return &privateKeyImpl{privKey}, &publicKeyImpl{privKey.PubKey()}, nil
}
func NewPrivateKey(data []byte) (PrivateKey, error) {
	if len(data) != 32 {
		return nil, errors.New("expected 32 bytes input")
	}
	privk, _ := btcec.PrivKeyFromBytes(btcec.S256(), data)
	return &privateKeyImpl{privk}, nil
}
func NewPrivateKeyFromString(s string) (PrivateKey, error) {
	data := base58.Decode(s)
	return NewPrivateKey(data)
}
func (p *privateKeyImpl) InternalKey() *btcec.PrivateKey {
	return p.k
}
func (p *privateKeyImpl) Bytes() []byte {
	return p.k.Serialize()
}
func (p *privateKeyImpl) String() string {
	bytes := p.Bytes()
	return base58.Encode(bytes)
}
func (p *privateKeyImpl) GetPublicKey() PublicKey {
	pubKey := p.k.PubKey()
	return &publicKeyImpl{k: pubKey}
}
func (p *privateKeyImpl) Pretty() string {
	pstr := p.String()
	maxRunes := 6
	if len(pstr) < maxRunes {
		maxRunes = len(pstr)
	}
	return fmt.Sprintf("<PrivKey %s>", pstr[:maxRunes])
}
func (p *privateKeyImpl) Sign(in []byte) ([]byte, error) {
	signature, err := p.k.Sign(in)
	if err != nil {
		return nil, err
	}
	return signature.Serialize(), nil
}
func (p *privateKeyImpl) Decrypt(in []byte) ([]byte, error) {
	return btcec.Decrypt(p.k, in)
}
func NewPublicKey(data []byte) (PublicKey, error) {
	k, err := btcec.ParsePubKey(data, btcec.S256())
	if err != nil {
		log.Error("Failed to parse public key from binay data", err)
		return nil, err
	}
	return &publicKeyImpl{k}, nil
}