public static function signAndEncrypt(
        HiddenString $message,
        SignatureSecretKey $secretKey,
        PublicKey $recipientPublicKey,
        $encoding = Halite::ENCODE_BASE64URLSAFE
    ): string {
        if ($recipientPublicKey instanceof SignaturePublicKey) {
            $publicKey = $recipientPublicKey->getEncryptionPublicKey();
        } elseif ($recipientPublicKey instanceof EncryptionPublicKey) {
            $publicKey = $recipientPublicKey;
        } else {
            // @codeCoverageIgnoreStart
            throw new InvalidKey('An invalid key type was provided');
            // @codeCoverageIgnoreEnd
        }
        $signature = self::sign($message->getString(), $secretKey, true);
        $plaintext = new HiddenString($signature . $message->getString());
        \sodium_memzero($signature);

        $myEncKey = $secretKey->getEncryptionSecretKey();
        return self::encrypt($plaintext, $myEncKey, $publicKey, $encoding);
    }