private KeySpec constructJavaXecPublicKeySpec(OpenSSLX25519PublicKey publicKey)
            throws InvalidKeySpecException {
        if (OpenSSLXDHKeyFactory.javaXecPublicKeySpec == null) {
            throw new InvalidKeySpecException("Could not find java.security.spec.XECPublicKeySpec");
        }
        try {
            Constructor<?> c = OpenSSLXDHKeyFactory.javaXecPublicKeySpec.getConstructor(
                    AlgorithmParameterSpec.class, BigInteger.class);
            @SuppressWarnings("unchecked")
            KeySpec result = (KeySpec) c.newInstance(javaX25519AlgorithmSpec,
                    new BigInteger(1, ArrayUtils.reverse(publicKey.getU())));
            return result;
        } catch (NoSuchMethodException | InstantiationException | IllegalAccessException |
                 InvocationTargetException e) {
            throw new InvalidKeySpecException(
                    "Could not find java.security.spec.XECPublicKeySpec", e);
        }
    }
An implementation of a {@link KeyFactorySpi} for XEC keys based on BoringSSL.
common/src/main/java/org/conscrypt/OpenSSLXDHKeyFactory.java