func (j *jsonKey) ECDSA() (publicKey *ecdsa.PublicKey, err error) {
	j.precomputedMux.RLock()
	if j.precomputed != nil {
		var ok bool
		if publicKey, ok = j.precomputed.(*ecdsa.PublicKey); ok {
			j.precomputedMux.RUnlock()
			return publicKey, nil
		}
	}
	j.precomputedMux.RUnlock()
	if j.X == "" || j.Y == "" || j.Curve == "" {
		return nil, fmt.Errorf("%w: ecdsa", ErrMissingAssets)
	}
	var xCoordinate []byte
	if xCoordinate, err = base64.RawURLEncoding.DecodeString(j.X); err != nil {
		return nil, err
	}
	var yCoordinate []byte
	if yCoordinate, err = base64.RawURLEncoding.DecodeString(j.Y); err != nil {
		return nil, err
	}
	publicKey = &ecdsa.PublicKey{}
	switch j.Curve {
	case p256:
		publicKey.Curve = elliptic.P256()
	case p384:
		publicKey.Curve = elliptic.P384()
	case p521:
		publicKey.Curve = elliptic.P521()
	}
	publicKey.X = big.NewInt(0).SetBytes(xCoordinate)
	publicKey.Y = big.NewInt(0).SetBytes(yCoordinate)
	j.precomputedMux.Lock()
	j.precomputed = publicKey
	j.precomputedMux.Unlock()
	return publicKey, nil
}
ECDSA parses a jsonKey and turns it into an ECDSA public key.
package keyfunc
import (
	"crypto/ecdsa"
	"crypto/elliptic"
	"encoding/base64"
	"fmt"
	"math/big"
)
const (
	es256 = "ES256"
	es384 = "ES384"
	es512 = "ES512"
	p256 = "P-256"
	p384 = "P-384"
	p521 = "P-521"
)