protected function decryptData($obj, $default = null)
    {
        if (is_null($this->cryptokey)) {
            throw InvalidSetupException::nullSecret();
        }
        if (! isset($obj->nonce)) {
            return $default;
        }
        if (! isset($obj->ciphertext)) {
            return $default;
        }
        if ($this->aesgcm) {
            try {
                $serialized = sodium_crypto_aead_aes256gcm_decrypt(
                    $obj->ciphertext,
                    $obj->nonce,
                    $obj->nonce,
                    $this->cryptokey
                );
            } catch (\Error $e) {
                error_log($e->getMessage());
                return $default;
            }
        } else {
            try {
                $serialized = sodium_crypto_aead_chacha20poly1305_ietf_decrypt(
                    $obj->ciphertext,
                    $obj->nonce,
                    $obj->nonce,
                    $this->cryptokey
                );
            } catch (\Error $e) {
                error_log($e->getMessage());
                return $default;
            }
        }
        if ($serialized === false) {
            return $default;
        }
        try {
            $value = unserialize($serialized);
        } catch (\Error $e) {
            error_log($e->getMessage());
            return $default;
        }
        sodium_memzero($serialized);
        return $value;
    }