A common and natural approach is to uses document hashes. This can prove that a copy of the document produced later is a genuine copy of the original, that it hasn't been tampered with and that the signer witnessed the document at a point of time in the past.
Off-chain:
- Alice has a document
- Alice hashes the document and gets a 32-byte hash which is unique to the doc
- Alice sends a signed transaction with the hash (as input data) to the contract
On-chain:
- The contract records that address (Alice) had hash (data) that this time (mined block).
Any method of document storage will do. That can be centralized, decentralized, or perhaps Alice will simply store it herself. At some point in the future Bob wants to see that Alice's document is genuine.
Off-chain:
- Bob: "Prove that this is the real document."
- Alice: "This contract history shows my address submitted the hash of this document in the past. You may check everything yourself."
On-chain (read-only)
- Bob: "Contract, do you have knowledge of this document?"
- Contract: "Yes. Alice sent that hash on [date]."
For the benefit of readers who may not be familiar with the way hash algos produce deterministic (same output every time) strings of bytes for any given input, the ideal hash algo
- produces output that is uncorrelated to the input (says nothing useful about the length or content of the input) and
- is unique for every input.
While it is theoretically possible that
two different inputs produce the same hash (called a hash collision),
it is improbable. In the case of the keccak256
algo, for example,
no hash collision has ever been discovered. Therefore, the idea of
forging a document that hashes to pre-determined output is virtually
impossible. This convinces Bob that the document Alice presents must indeed be the same document that was certified in the past and recorded on the blockchain.
Hope it helps.