public static function verifyAndDecrypt(
        string $ciphertext,
        SignaturePublicKey $senderPublicKey,
        SecretKey $givenSecretKey,
        $encoding = Halite::ENCODE_BASE64URLSAFE
    ): HiddenString {
        if ($givenSecretKey instanceof SignatureSecretKey) {
            $secretKey = $givenSecretKey->getEncryptionSecretKey();
        } elseif ($givenSecretKey instanceof EncryptionSecretKey) {
            $secretKey = $givenSecretKey;
        } else {
            throw new InvalidKey('An invalid key type was provided');
        }
        $senderEncKey = $senderPublicKey->getEncryptionPublicKey();
        $decrypted = self::decrypt($ciphertext, $secretKey, $senderEncKey, $encoding);
        $signature = Binary::safeSubstr($decrypted->getString(), 0, SODIUM_CRYPTO_SIGN_BYTES);
        $message = Binary::safeSubstr($decrypted->getString(), SODIUM_CRYPTO_SIGN_BYTES);
        if (!self::verify($message, $senderPublicKey, $signature, true)) {
            throw new InvalidSignature('Invalid signature for decrypted message');
        }
        return new HiddenString($message);
    }