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

	// algorithm is optional, so default to EdDSA
	if obj.Algorithm == 0 {
		obj.Algorithm = AlgorithmEdDSA
	}

	if obj.Type != KeyTypeOctet {
		return nil, nil, fmt.Errorf("%w: invalid key type", ErrInvalidPublicKey)
	}

	switch obj.Algorithm {
	case AlgorithmEdDSA:
	default:
		return nil, nil, fmt.Errorf("%w: invalid algorithm", ErrUnsupportedAlgorithm)
	}

	switch obj.Curve {
	case CurveEd25519:
	default:
		return nil, nil, ErrUnsupportedCurve
	}

	if len(obj.XCoordinate) != ed25519.PublicKeySize {
		return nil, nil, fmt.Errorf("%w: invalid x-coordinate size", ErrInvalidPublicKey)
	}

	key = &EdDSAPublicKey{
		key: obj.XCoordinate,
	}
	remaining = raw[decoder.NumBytesRead():]
	return key, remaining, nil
}
// UnmarshalEdDSAPublicKey unmarshals an EdDSA key using the COSE_Key format.
UnmarshalEdDSAPublicKey unmarshals an EdDSA key using the COSE_Key format.
// UnmarshalEdDSAPublicKey unmarshals an EdDSA key using the COSE_Key format .
func UnmarshalEdDSAPublicKey(raw []byte) (key *EdDSAPublicKey, remaining []byte, err error) {
	var obj publicKeyStructureOKP
	decoder := cbor.NewDecoder(bytes.NewReader(raw))
	err = decoder.Decode(&obj)
	if err != nil {
		return nil, nil, err
	}
	if obj.Algorithm == 0 {
		obj.Algorithm = AlgorithmEdDSA
	}
	if obj.Type != KeyTypeOctet {
		return nil, nil, fmt.Errorf("%w: invalid key type", ErrInvalidPublicKey)
	}
	switch obj.Algorithm {
	case AlgorithmEdDSA:
	default:
		return nil, nil, fmt.Errorf("%w: invalid algorithm", ErrUnsupportedAlgorithm)
	}
	switch obj.Curve {
	case CurveEd25519:
	default:
		return nil, nil, ErrUnsupportedCurve
	}
	if len(obj.XCoordinate) != ed25519.PublicKeySize {
		return nil, nil, fmt.Errorf("%w: invalid x-coordinate size", ErrInvalidPublicKey)
	}
	key = &EdDSAPublicKey{
		key: obj.XCoordinate,
	}
	remaining = raw[decoder.NumBytesRead():]
	return key, remaining, nil
}
func UnmarshalEdDSAPublicKey ( raw [ ] byte ) ( key * EdDSAPublicKey , remaining [ ] byte , err error ) { var obj publicKeyStructureOKP decoder := cbor . NewDecoder ( bytes . NewReader ( raw ) ) err = decoder . Decode ( & obj ) if err != nil { return nil , nil , err } if obj . Algorithm == 0 { obj . Algorithm = AlgorithmEdDSA } if obj . Type != KeyTypeOctet { return nil , nil , fmt . Errorf ( " " , ErrInvalidPublicKey ) } switch obj . Algorithm { case AlgorithmEdDSA : default : return nil , nil , fmt . Errorf ( " " , ErrUnsupportedAlgorithm ) } switch obj . Curve { case CurveEd25519 : default : return nil , nil , ErrUnsupportedCurve } if len ( obj . XCoordinate ) != ed25519 . PublicKeySize { return nil , nil , fmt . Errorf ( " " , ErrInvalidPublicKey ) } key = & EdDSAPublicKey { key : obj . XCoordinate , } remaining = raw [ decoder . NumBytesRead ( ) : ] return key , remaining , nil }
UnmarshalEdDSAPublicKey unmarshals an EdDSA key using the COSE_Key format.
UnmarshalEdDSAPublicKey unmarshals an EdDSA key using the COSE_Key format .
// algorithm is optional, so default to EdDSA