private KeySpec constructJavaPrivateKeySpec(OpenSSLX25519PrivateKey privateKey)
            throws InvalidKeySpecException {
      if (OpenSSLXDHKeyFactory.javaXecPrivateKeySpec == null) {
          throw new InvalidKeySpecException("Could not find java.security.spec.XECPrivateKeySpec");
      }
      try {
            Constructor<?> c = OpenSSLXDHKeyFactory.javaXecPrivateKeySpec.getConstructor(
                    AlgorithmParameterSpec.class, byte[].class);
            @SuppressWarnings("unchecked")
            KeySpec result = (KeySpec) c.newInstance(javaX25519AlgorithmSpec, privateKey.getU());
            return result;
        } catch (NoSuchMethodException | InstantiationException | IllegalAccessException |
                 InvocationTargetException e) {
          throw new InvalidKeySpecException(
                    "Could not find java.security.spec.XECPrivateKeySpec", e);
        }
    }
An implementation of a {@link KeyFactorySpi} for XEC keys based on BoringSSL.
common/src/main/java/org/conscrypt/OpenSSLXDHKeyFactory.java