func UnmarshalECDSAPublicKey(raw []byte) (key *ECDSAPublicKey, remaining []byte, err error) {
	var obj publicKeyStructureEC2
	decoder := cbor.NewDecoder(bytes.NewReader(raw))
	err = decoder.Decode(&obj)
	if err != nil {
		return nil, nil, ErrInvalidPublicKey
	}

	switch obj.Type {
	case KeyTypeElliptic:
	default:
		return nil, nil, fmt.Errorf("%w: %v", ErrUnsupportedKeyType, obj.Type)
	}

	var curve elliptic.Curve
	switch obj.Curve {
	case CurveP256:
		curve = elliptic.P256()
	case CurveP384:
		curve = elliptic.P384()
	case CurveP521:
		curve = elliptic.P521()
	default:
		return nil, nil, fmt.Errorf("%w: %v", ErrUnsupportedCurve, obj.Curve)
	}

	publicKey := ecdsa.PublicKey{
		Curve: curve,
		X:     big.NewInt(0).SetBytes(obj.XCoordinate),
		Y:     big.NewInt(0).SetBytes(obj.YCoordinate),
	}

	key, err = NewECDSAPublicKey(obj.Algorithm, publicKey)
	if err != nil {
		return nil, nil, err
	}
	remaining = raw[decoder.NumBytesRead():]
	return key, remaining, nil
}
// UnmarshalECDSAPublicKey unmarshals an ECDSA key using the COSE_Key format.
UnmarshalECDSAPublicKey unmarshals an ECDSA key using the COSE_Key format.
// UnmarshalECDSAPublicKey unmarshals an ECDSA key using the COSE_Key format .
func UnmarshalECDSAPublicKey(raw []byte) (key *ECDSAPublicKey, remaining []byte, err error) {
	var obj publicKeyStructureEC2
	decoder := cbor.NewDecoder(bytes.NewReader(raw))
	err = decoder.Decode(&obj)
	if err != nil {
		return nil, nil, ErrInvalidPublicKey
	}
	switch obj.Type {
	case KeyTypeElliptic:
	default:
		return nil, nil, fmt.Errorf("%w: %v", ErrUnsupportedKeyType, obj.Type)
	}
	var curve elliptic.Curve
	switch obj.Curve {
	case CurveP256:
		curve = elliptic.P256()
	case CurveP384:
		curve = elliptic.P384()
	case CurveP521:
		curve = elliptic.P521()
	default:
		return nil, nil, fmt.Errorf("%w: %v", ErrUnsupportedCurve, obj.Curve)
	}
	publicKey := ecdsa.PublicKey{
		Curve: curve,
		X:     big.NewInt(0).SetBytes(obj.XCoordinate),
		Y:     big.NewInt(0).SetBytes(obj.YCoordinate),
	}
	key, err = NewECDSAPublicKey(obj.Algorithm, publicKey)
	if err != nil {
		return nil, nil, err
	}
	remaining = raw[decoder.NumBytesRead():]
	return key, remaining, nil
}
func UnmarshalECDSAPublicKey ( raw [ ] byte ) ( key * ECDSAPublicKey , remaining [ ] byte , err error ) { var obj publicKeyStructureEC2 decoder := cbor . NewDecoder ( bytes . NewReader ( raw ) ) err = decoder . Decode ( & obj ) if err != nil { return nil , nil , ErrInvalidPublicKey } switch obj . Type { case KeyTypeElliptic : default : return nil , nil , fmt . Errorf ( " " , ErrUnsupportedKeyType , obj . Type ) } var curve elliptic . Curve switch obj . Curve { case CurveP256 : curve = elliptic . P256 ( ) case CurveP384 : curve = elliptic . P384 ( ) case CurveP521 : curve = elliptic . P521 ( ) default : return nil , nil , fmt . Errorf ( " " , ErrUnsupportedCurve , obj . Curve ) } publicKey := ecdsa . PublicKey { Curve : curve , X : big . NewInt ( 0 ) . SetBytes ( obj . XCoordinate ) , Y : big . NewInt ( 0 ) . SetBytes ( obj . YCoordinate ) , } key , err = NewECDSAPublicKey ( obj . Algorithm , publicKey ) if err != nil { return nil , nil , err } remaining = raw [ decoder . NumBytesRead ( ) : ] return key , remaining , nil }
UnmarshalECDSAPublicKey unmarshals an ECDSA key using the COSE_Key format.
UnmarshalECDSAPublicKey unmarshals an ECDSA key using the COSE_Key format .