code: public static KeyPair generateKeyPair(String jcaAlgorithmName, String jcaProviderName, SignatureAlgorithm alg,
                                            SecureRandom random) {
          Assert.notNull(alg, "SignatureAlgorithm argument cannot be null.");
          Assert.isTrue(alg.isEllipticCurve(), "SignatureAlgorithm argument must represent an Elliptic Curve algorithm.");
          try {
              KeyPairGenerator g;
  
              if (Strings.hasText(jcaProviderName)) {
                  g = KeyPairGenerator.getInstance(jcaAlgorithmName, jcaProviderName);
              } else {
                  g = KeyPairGenerator.getInstance(jcaAlgorithmName);
              }
  
              String paramSpecCurveName = EC_CURVE_NAMES.get(alg);
              ECGenParameterSpec spec = new ECGenParameterSpec(paramSpecCurveName);
              g.initialize(spec, random);
              return g.generateKeyPair();
          } catch (Exception e) {
              throw new IllegalStateException("Unable to generate Elliptic Curve KeyPair: " + e.getMessage(), e);
          }
      }
docs: Generates a new secure-random key pair of sufficient strength for the specified Elliptic Curve {@link
  SignatureAlgorithm} (must be one of {@code ES256}, {@code ES384} or {@code ES512}) using the specified {@link
  SecureRandom} random number generator via the specified JCA provider and algorithm name.
  
  @param jcaAlgorithmName the JCA name of the algorithm to use for key pair generation, for example, {@code
  ECDSA}.
  @param jcaProviderName  the JCA provider name of the algorithm implementation (for example {@code "BC"} for
  BouncyCastle) or {@code null} if the default provider should be used.
  @param alg              alg the algorithm indicating strength, must be one of {@code ES256}, {@code ES384} or
  {@code ES512}
  @param random           the SecureRandom generator to use during key generation.
  @return a new secure-randomly generated key pair of sufficient strength for the specified Elliptic Curve {@link
  SignatureAlgorithm} (must be one of {@code ES256}, {@code ES384} or {@code ES512}) using the specified {@link
  SecureRandom} random number generator via the specified JCA provider and algorithm name.
  @see #generateKeyPair()
  @see #generateKeyPair(SignatureAlgorithm)
  @see #generateKeyPair(SignatureAlgorithm, SecureRandom)