Architecting Immutable Data Integrity with Amazon QLDB and Blockchain
Hashing detects tampering, but it doesn't prevent it. Here is an architectural pattern for securing business-critical files using Amazon QLDB and the Symbol Blockchain.
Join the DZone community and get the full member experience.
Join For FreeIn the current landscape of ransomware and sophisticated SQL injection attacks, standard database security is no longer sufficient. We rely heavily on cryptographic hashes (such as SHA-256) to verify data integrity. The logic is simple: if the hash changes, the data was altered.
But there is a flaw in this logic. If an attacker gains administrative access to your database, they can modify the data and the stored hash simultaneously. The “seal” is broken, and you have no way of proving the original state of the document.
To achieve true data integrity, we need to move from tamper detection (hashing) to tamper prevention (immutability).
This article outlines a dual-layer architecture designed to secure high-value business documents (contracts, invoices, audit logs). We will explore using Amazon QLDB for centralized, immutable logging and the Symbol blockchain for decentralized, permanent file preservation.
Layer 1: The Centralized Immutable Ledger (Amazon QLDB)
For high-volume transaction data where performance is key, a centralized immutable ledger is the ideal middle ground between a standard RDBMS and a blockchain.
Amazon QLDB (Quantum Ledger Database) provides a transparent, immutable, and cryptographically verifiable transaction log. Unlike a standard PostgreSQL or MySQL table, where UPDATE or DELETE commands overwrite data, QLDB appends changes to a journal.
The Architecture
- Ingestion: Business data is generated.
- Hashing: A SHA-256 hash is calculated from the data payload.
- Registration: The data and its hash are written to QLDB.
If an attacker attempts to modify a record, the QLDB journal preserves the full history. You can cryptographically verify that the data at time T matches the hash stored at time T.
Implementation: Verifying Integrity
Below is a conceptual Python workflow for detecting tampering by comparing a computed hash against the immutable ledger.
import hashlib
# Conceptual import for QLDB driver
from pyqldb.driver.qldb_driver import QldbDriver
def calculate_hash(data_string):
"""Generate SHA-256 hash of the business data."""
return hashlib.sha256(data_string.encode('utf-8')).hexdigest()
def verify_integrity(driver, document_id, current_data):
"""
Compare the current file's hash against the immutable QLDB record.
"""
# 1. Calculate current hash
current_hash = calculate_hash(current_data)
# 2. Fetch the original hash stored in QLDB
# In QLDB, you query the history function to get the original committed state
query = "SELECT hash_value FROM history(BusinessTable) WHERE doc_id = ?"
cursor = driver.execute_lambda(lambda executor: executor.execute_statement(query, document_id))
original_record = next(cursor, None)
if not original_record:
return "ERROR: Record not found."
stored_hash = original_record['hash_value']
# 3. Compare
if current_hash == stored_hash:
return "SUCCESS: Data integrity verified."
else:
return "ALERT: Tampering detected!"
Layer 2: Full On-Chain Preservation (Symbol Blockchain)
QLDB is excellent for transaction logs, but what about the actual files (PDFs, images)? If your cloud storage bucket is wiped or corrupted, the ledger can tell you what you lost, but it cannot restore it.
To solve this, we utilize the Symbol blockchain. Unlike legacy blockchains that are purely currency-focused, Symbol supports complex data structures and on-chain storage via NFTs (Non-Fungible Tokens) and messages.
The Pattern: Documents as NFTs
A business file can be treated as a unique digital asset. By uploading the file data (or, for larger files, only its hash) to the blockchain, we create a fully on-chain record.
- Availability: As long as the blockchain network exists, the file exists. It is decentralized across hundreds of nodes.
- Timestamping: Block time provides irrefutable proof of existence.
- Ownership: The NFT structure proves who created the document.
Architecture Diagram
The following diagram illustrates the hybrid approach: internal systems use QLDB for speed, while critical assets are anchored to a public blockchain.

The Cost of Immutability
Storing data on a public blockchain incurs transaction fees (“gas”).
- Hash only: Extremely cheap and useful for integrity verification.
- Full file (on-chain): More expensive but guarantees long-term survival.
For critical documents (such as signed legal agreements), the cost is often negligible compared to the value of the asset. For example, storing a small PDF might cost only a few cents in network fees, yet it ensures that even if enterprise servers are destroyed, the document can still be retrieved from the blockchain network.
Analyzing the Trade-offs
When architecting for data integrity, consider these factors:
| Feature | Hash + Database | Hash + QLDB | Full On-Chain (Blockchain) |
| Tamper Resistance | Low (Admin can rewrite) | High (Journaled) | Extreme (Decentralized) |
| Performance | High | High | Low (Block times) |
| Cost | Low | Moderate | High (Storage fees) |
| Privacy | Private | Private | Public (unless encrypted) |
| Use Case | General App Data | Audit Logs, Financials | Contracts, IP, Compliance |
Conclusion
The traditional approach of storing a file and its hash in the same database is a security anti-pattern. It creates a false sense of security that collapses under privileged insider attacks or ransomware.
By decoupling data from its verification record — using QLDB for high-speed audit logs and a blockchain for critical asset preservation — architects can build systems that are not merely tamper-evident, but tamper-resistant.
Key takeaway: For your most critical data, do not rely on a single administrator password. Rely on cryptographic consensus.
Opinions expressed by DZone contributors are their own.
Comments