Skip to main content

107. Hash-Based Verification on Blockchain

Status: Accepted Date: 2025-07-06

Context

We want to use the TON blockchain to create a tamper-proof, verifiable record of data generated by our application (e.g., the result of an Arcana tarot reading). Storing the full data directly on the blockchain is not feasible for two main reasons:

  1. Cost: Storing large amounts of data on a blockchain is prohibitively expensive.
  2. Privacy: The data we want to verify might be private or sensitive. Storing it on a public blockchain would be a major privacy violation.

We need a way to get the integrity and tamper-proof benefits of a blockchain without these drawbacks.

Decision

We will adopt a Hash-Based Verification pattern. Instead of storing the raw data on the blockchain, we will only store a cryptographic hash (e.g., SHA-256) of the data.

The workflow will be:

  1. The application generates some data (e.g., a tarot reading result as a JSON object).
  2. It calculates a cryptographic hash of this data.
  3. It sends a transaction to the TON blockchain containing only this hash. This transaction is stored immutably on the blockchain with a timestamp.
  4. The application stores the original data in its own database, along with the transaction ID of the on-chain hash record.

To verify the data later, a user can take the original data, re-calculate its hash, and prove that this hash matches the one that was recorded on the blockchain at a specific time.

Consequences

Positive:

  • Cost-Effective: Storing a 32-byte hash is thousands of times cheaper than storing kilobytes of raw data on-chain.
  • Preserves Privacy: The raw data never touches the public blockchain, so user privacy is completely preserved.
  • Tamper-Proof Timestamping: This pattern provides a perfect, immutable, and decentralized proof that a specific piece of data existed in a specific state at a specific time. It is impossible to retroactively change the data without invalidating the on-chain hash.
  • Simple and Efficient: Hashing is a very fast and standard cryptographic operation.

Negative:

  • Data Not On-Chain: The raw data is not "backed up" on the blockchain. If our application's database is lost, the on-chain hash cannot be used to recover the original data.
  • Verification Requires Off-Chain Data: To perform a verification, the user needs access to the original, off-chain data.

Mitigation:

  • Clarify Purpose: This pattern is for verification, not for decentralized storage or backup. Its purpose is to prove data integrity, not to ensure data availability. Our standard database backup procedures are still responsible for availability.
  • Clear User Workflow: The verification process will be made clear. The application will provide the user with both the original data and a link to the on-chain transaction, making the verification process straightforward.