public function generateKeyPair($keyOption = null)
    {
        if (null === $keyOption) {
            $keyOption = new RsaKeyOption();
        }
        if (\is_int($keyOption)) {
            @trigger_error('Passing a keySize to "generateKeyPair" is deprecated since version 1.1 and will be removed in 2.0. Pass an instance of KeyOption instead', E_USER_DEPRECATED);
            $keyOption = new RsaKeyOption($keyOption);
        }
        Assert::isInstanceOf($keyOption, KeyOption::class);

        try {
            $privateKey = $this->generator->generatePrivateKey($keyOption);
        } catch (KeyGenerationException $e) {
            throw new KeyPairGenerationException('Fail to generate a KeyPair with the given options', 0, $e);
        }

        return new KeyPair(
            $privateKey->getPublicKey(),
            $privateKey
        );
    }