@Override
    protected byte[] convertPublicKey(PublicKey key) throws InvalidKeyException {
        if (!(key instanceof OpenSSLX25519PublicKey)) {
            throw new InvalidKeyException("Only OpenSSLX25519PublicKey accepted");
        }

        return ((OpenSSLX25519PublicKey) key).getU();
    }
Elliptic Curve Diffie-Hellman key agreement backed by the OpenSSL engine.
common/src/main/java/org/conscrypt/OpenSSLXDHKeyAgreement.java