{"record":{"id":"cfeaca086d7d0a3f","repo":"grafana/k6","slug":"unable-to-convert-ecdh-public-key-to-ecdsa-public","errorCode":null,"errorMessage":"unable to convert ECDH public key to ECDSA public key, curve: %s","messagePattern":"unable to convert ECDH public key to ECDSA public key, curve: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/webcrypto/elliptic_curve.go","lineNumber":712,"sourceCode":"\t}, nil\n}\n\nfunc convertPublicECDHtoECDSA(k *ecdh.PublicKey) (*ecdsa.PublicKey, error) {\n\tvar crv elliptic.Curve\n\tswitch k.Curve() {\n\tcase ecdh.P256():\n\t\tcrv = elliptic.P256()\n\tcase ecdh.P384():\n\t\tcrv = elliptic.P384()\n\tcase ecdh.P521():\n\t\tcrv = elliptic.P521()\n\tdefault:\n\t\treturn nil, errors.New(\"curve not supported for converting to ECDSA key\")\n\t}\n\n\tx, y := elliptic.Unmarshal(crv, k.Bytes()) //nolint:staticcheck // we need to use the Unmarshal function\n\tif x == nil {\n\t\treturn nil, fmt.Errorf(\"unable to convert ECDH public key to ECDSA public key, curve: %s\", crv.Params().Name)\n\t}\n\n\treturn &ecdsa.PublicKey{\n\t\tCurve: crv,\n\t\tX:     x,\n\t\tY:     y,\n\t}, nil\n}\n\nfunc ensureKeysUseSameCurve(k1, k2 CryptoKey) error {\n\tecAlg1, ok1 := k1.Algorithm.(EcKeyAlgorithm)\n\tecAlg2, ok2 := k2.Algorithm.(EcKeyAlgorithm)\n\tif !ok1 || !ok2 {\n\t\treturn errors.New(\"keys are not valid elliptic curve keys\")\n\t}\n\n\tif ecAlg1.NamedCurve != ecAlg2.NamedCurve {\n\t\treturn errors.New(\"keys have different curves \" + string(ecAlg1.NamedCurve) + \" and \" + string(ecAlg2.NamedCurve))","sourceCodeStart":694,"sourceCodeEnd":730,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/webcrypto/elliptic_curve.go#L694-L730","documentation":"Returned by convertPublicECDHtoECDSA when an ECDH public key on a known curve (P-256/P-384/P-521) cannot be unmarshalled into ECDSA point coordinates: elliptic.Unmarshal returns a nil x, meaning the key bytes do not encode a valid point on the stated curve. The curve name is included in the message. Encountered when exporting an ECDH key as JWK.","triggerScenarios":"Thrown at internal/js/modules/k6/webcrypto/elliptic_curve.go:711 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Regenerate or re-import the ECDH key — the raw public key bytes are likely corrupted or truncated","Verify the key was generated on the curve claimed in its parameters"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8d06114777191d21ef885d05c5f8aa9e1ed838ae","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}