func (s *EccSigner) SignBytes(buf []byte) ([]byte, error) {
	if s.priv == nil {
		return nil, ErrInvalidPrivateKey
	}
	h := s.hash.New()
	if _, err := h.Write(buf); err != nil {
		return nil, err
	}
	r, i, err := ecdsa.Sign(rand.Reader, s.priv, h.Sum(nil))
	if err != nil {
		return nil, err
	}
	return s.Mksig(r, i)
}
SignBytes creates a signature for buf.
package jwt
import (
	"crypto"
	"crypto/ecdsa"
	"crypto/elliptic"
	"crypto/rand"
	"math/big"
)
type EccSigner struct {
	alg    Algorithm
	curve  elliptic.Curve
	hash   crypto.Hash
	priv   *ecdsa.PrivateKey
	pub    *ecdsa.PublicKey
	keyLen int
}
func NewEllipticSigner(alg Algorithm, curve elliptic.Curve) func(Store, crypto.Hash) (Signer, error) {
	curveBitSize := curve.Params().BitSize
	keyLen := curveBitSize / 8
	if curveBitSize%8 > 0 {
		keyLen++
	}
	return func(store Store, hash crypto.Hash) (Signer, error) {
		var ok bool
		var privRaw, pubRaw interface{}
		var priv *ecdsa.PrivateKey
		var pub *ecdsa.PublicKey
		if privRaw, ok = store.PrivateKey(); ok {
			if priv, ok = privRaw.(*ecdsa.PrivateKey); !ok {
				return nil, ErrInvalidPrivateKey
			}
			if curveBitSize != priv.Curve.Params().BitSize {
				return nil, ErrInvalidPrivateKeySize
			}
		}
		if pubRaw, ok = store.PublicKey(); ok {
			if pub, ok = pubRaw.(*ecdsa.PublicKey); !ok {
				return nil, ErrInvalidPublicKey
			}
		}
		if priv == nil && pub == nil {
			return nil, ErrMissingPrivateOrPublicKey
		}
		return &EccSigner{
			alg:    alg,
			curve:  curve,
			hash:   hash,
			priv:   priv,
			pub:    pub,
			keyLen: keyLen,
		}, nil
	}
}
func (s *EccSigner) Mksig(r, i *big.Int) ([]byte, error) {
	buf := make([]byte, 2*s.keyLen)
	rb := r.Bytes()
	if n := copy(buf[s.keyLen-len(rb):], rb); n != len(rb) {
		return nil, ErrMismatchedBytesCopied
	}
	sb := i.Bytes()
	if n := copy(buf[s.keyLen+(s.keyLen-(len(sb))):], sb); n != len(sb) {
		return nil, ErrMismatchedBytesCopied
	}
	return buf, nil
}