func (k *SecretKey) GetPublicKey() *PublicKey {
	key := &PublicKey{}
	key.PublicKey = k.PublicKey
	return key
}
GetPublicKey from secret key
package crypto
import (
	"crypto/aes"
	"crypto/cipher"
	"crypto/ecdsa"
	"crypto/elliptic"
	"crypto/rand"
	"crypto/sha1"
	"crypto/sha256"
	"crypto/x509"
	"encoding/base32"
	"encoding/base64"
	"encoding/binary"
	"encoding/pem"
	"errors"
	"hash"
	"io"
	"golang.org/x/crypto/hkdf"
)
var (
	eciesKeyLen       = aes.BlockSize
	Base64Encode      = base64.RawURLEncoding
	Base32Encode      = base32.StdEncoding.WithPadding(base32.NoPadding)
	ErrInvalidKey     = errors.New("InvalidKey")
	ErrInvalidMessage = errors.New("InvalidMessage")
)
type PublicKey struct {
	ecdsa.PublicKey
}
type SecretKey struct {
	ecdsa.PrivateKey
}
func LoadPublicKey(key []byte) (*PublicKey, error) {
	pk := &PublicKey{}
	pk.Curve = elliptic.P256()
	if len(key) <= 0 {
		return nil, ErrInvalidKey
	}
	pk.X, pk.Y = elliptic.Unmarshal(pk.Curve, key)
	if pk.X == nil || pk.Y == nil {
		return nil, ErrInvalidKey
	}
	return pk, nil
}
func LoadSecretKey(key []byte) (*SecretKey, error) {
	block, _ := pem.Decode(key)
	if block == nil {
		return nil, ErrInvalidKey
	}
	sk := &SecretKey{}
	privateKey, err := x509.ParseECPrivateKey(block.Bytes)
	if err != nil {
		return nil, err
	}
	sk.PrivateKey = *privateKey
	return sk, nil
}
func GenerateSecretKey(secret []byte) *SecretKey {
	var r io.Reader
	if len(secret) > 0 {
		r = hkdf.Expand(sha1.New, secret, []byte("chanify"))
	} else {
		r = rand.Reader
	}
	key, _ := ecdsa.GenerateKey(elliptic.P256(), r)
	k := &SecretKey{}
	k.PrivateKey = *key
	return k
}
func (k *PublicKey) MarshalPublicKey() []byte {
	return marshalPublicKey(&k.PublicKey)
}
func (k *PublicKey) ToID(code byte) string {
	return formatToID(code, k.MarshalPublicKey())
}
func (k *PublicKey) Verify(msg []byte, sig []byte) bool {
	hash := sha256.Sum256([]byte(msg))
	return ecdsa.VerifyASN1(&k.PublicKey, hash[:], sig)
}
func (k *PublicKey) Encrypt(data []byte) ([]byte, error) {
	seckey, _ := ecdsa.GenerateKey(k.Curve, rand.Reader)
	Z, _ := calcSharedKey(seckey, &k.PublicKey)
	X := elliptic.Marshal(k.Curve, seckey.X, seckey.Y)
	K := x963KDF(Z, X, sha256.New)
	key := K[:eciesKeyLen]
	nonce := K[eciesKeyLen:]
	block, _ := aes.NewCipher(key)
	aesgcm, _ := cipher.NewGCMWithNonceSize(block, eciesKeyLen)
	cipherData := aesgcm.Seal(nil, nonce, data, nil)
	return append(X, cipherData...), nil
}