func createECDSAP256SHA256WithDERNoPrefixPublicKey()

in server/signedcontainer/internal/convert/convert.go [47:63]


func createECDSAP256SHA256WithDERNoPrefixPublicKey(pubKey crypto.PublicKey) (*tinkecdsa.PublicKey, error) {
	ecdsaPubKey, ok := pubKey.(*ecdsa.PublicKey)
	if !ok {
		return nil, fmt.Errorf("public key is not an ECDSA public key: %v", pubKey)
	}
	ecdhPubKey, err := ecdsaPubKey.ECDH()
	if err != nil {
		return nil, err
	}
	// Turn this into a Tink key.
	params, err := tinkecdsa.NewParameters(tinkecdsa.NistP256, tinkecdsa.SHA256, tinkecdsa.DER, tinkecdsa.VariantNoPrefix)
	if err != nil {
		return nil, err
	}
	// Will fail if the point is not on the curve.
	return tinkecdsa.NewPublicKey(ecdhPubKey.Bytes(), 0, params)
}