Codenotary Trustcenter Blog

Using Immudb Vault To Store Documents Immutably and Safe from Tampering

Written by Moshe | Jul 18, 2023 8:35:07 AM

Immutable data storage refers to a method of storing data where once a piece of data is written, it cannot be modified or deleted. Instead, any changes to the data result in the creation of a new version. This approach offers several advantages over traditional mutable data storage methods. Immudb Vault is the leading cloud solution to store and share data immutably. See https://vault.immudb.io 

immudb vault is based on the industry-leading immutable database, immudb (www.immudb.io). It is a lightweight, high-performance immutable database that provides cryptographic verification and tamper-proof audibility.

It is designed to store and manage critical data in a secure and efficient manner. It supports ACID transactions and can store data in either key/value, SQL, or document model.  immudb is most commonly used in applications that require strong data integrity guarantees, such as financial systems, supply chain management, and healthcare applications.

 

In this blog, we will explore the benefits of storing data immutably and discuss how to store a file in the immudb vault using a bash script with curl.

Advantages of Immutable Data Storage

  1. Data Integrity: Data stored in immudb Vault ensures the integrity of the stored data. Once a piece of data is written, it cannot be modified or tampered with. This property is particularly useful in scenarios where data integrity is critical, such as financial transactions, consumer data records, or server audit logs.
  2. Auditability: Immutable data storage provides a reliable audit trail. Since data cannot be modified or deleted, it becomes easier to track changes and identify the source of any discrepancies. This feature is valuable in compliance-driven industries where maintaining an accurate record of data modifications is essential.
  3. Versioning and Time Travel: Immutable data storage allows for easy versioning and time travel. Each change to the data creates a new version, enabling users to access and retrieve previous versions of the data. This capability is beneficial in scenarios where historical data analysis or rollback functionality is required.
  4. Security: Immutable data storage enhances data security. By preventing modifications or deletions, it reduces the risk of unauthorized access or data breaches. Additionally, it provides a tamper-evident mechanism, making it easier to detect any unauthorized changes to the data.

Store data in immudb Vault

Immudb Vault makes it very easy to store and retrieve data. Below is an example using a Linux shell script in Bash storing a JSON file in immudb Vault. 

#!/bin/bash
IMMUDB_API_TOKEN="your_api_token"
FILE_PATH="/path/to/your/file"

curl -X "PUT"   "https://vault.immudb.io/ics/api/v1/ledger/default/collection/default/document" \
  -H "accept: application/json" \
  -H "X-API-Key: $IMMUDB_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d @"$FILE_PATH"

Make sure to replace "your_api_token" with the API token you obtained from the immudb vault service at https://vault.immudb.io, and "/path/to/your/file" with the actual path to the file you want to store.

Run the script: Open a terminal, navigate to the directory where you saved the bash script, and execute it using the following command:

bash script_name.sh

Replace "script_name.sh" with the actual name of your bash script.

Upon successful execution, the file will be stored in the immudb vault, ensuring its immutability and providing the associated advantages discussed earlier.

Read data from immudb Vault

You (or somebody else that you want to share data with) can then retrieve the file by doing:

IMMUDB_API_RO_TOKEN="your_read-only_api_token"
curl -sX ”POST”  “https://vault.immudb.io/ics/api/v1/ledger/default/collection/default/documents/search” \
  -H “accept: application/json” \
  -H ”X-API-Key: $IMMUDB_API_RO_TOKEN” \
  -H “Content-Type: application/json” \
  -d ”{'page':1,'perPage':1}”

In case you need nicer formatting you can use jq (i. e. sudo apt install jq):

IMMUDB_API_RO_TOKEN="your_read-only_api_token"
curl -sX ”POST”  “https://vault.immudb.io/ics/api/v1/ledger/default/collection/default/documents/search” \
  -H “accept: application/json” \
  -H ”X-API-Key: $IMMUDB_API_RO_TOKEN” \
  -H “Content-Type: application/json” \
  -d ”{'page':1,'perPage':1}” | jq '.'

Conclusion

In conclusion, storing data immutably offers numerous advantages in terms of data integrity, auditability, security, and simplified data replication. By leveraging immudb's immutable database and following the steps outlined above, you can securely store files in the immudb vault and harness the benefits of immutable data storage.