docs: private static JsonWebKeyCurveName getCurveFromKeyPair(KeyPair keyPair, Provider provider) {
  
          try {
              ECPublicKey key = (ECPublicKey) keyPair.getPublic();
              ECParameterSpec spec = key.getParams();
              EllipticCurve crv = spec.getCurve();
  
              List<JsonWebKeyCurveName> curveList = Arrays.asList(JsonWebKeyCurveName.P_256, JsonWebKeyCurveName.P_384,
                      JsonWebKeyCurveName.P_521, JsonWebKeyCurveName.P_256K);
  
              for (JsonWebKeyCurveName curve : curveList) {
                  ECGenParameterSpec gps = new ECGenParameterSpec(CURVE_TO_SPEC_NAME.get(curve));
                  KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC", provider);
                  kpg.initialize(gps);
  
                  // Generate dummy keypair to get parameter spec.
                  KeyPair apair = kpg.generateKeyPair();
                  ECPublicKey apub = (ECPublicKey) apair.getPublic();
                  ECParameterSpec aspec = apub.getParams();
                  EllipticCurve acurve = aspec.getCurve();
  
                  // Matches the parameter spec
                  if (acurve.equals(crv)) {
                      return curve;
                  }
              }
  
              // Did not find a supported curve.
              throw new NoSuchAlgorithmException("Curve not supported.");
          } catch (GeneralSecurityException e) {
              throw new IllegalStateException(e);
          }
      }