Pulsars
0 %
Log inSign up

A tamper-evident chain

Chaining blocks by hashing

A blockchain (or "chain of blocks") is a shared ledger in which data is grouped into blocks, which are themselves linked to one another by hashing. This simple idea is enough to make history nearly impossible to tamper with without anyone noticing.

Reminder: a hash function

A cryptographic hash function (SHA-256 for Bitcoin) takes data of any size and returns a fixed-size hash, for example 256 bits. It has two crucial properties:

  • deterministic: the same data always gives the same hash;
  • avalanche effect: changing a single input bit completely upends the output hash.

Recovering the input from the hash is infeasible: it is a one-way function.

Chaining the blocks

Each block contains three essential things: its data (transactions), a number, and above all the hash of the previous block. It is this last field that creates the chain.

   Bloc 0            Bloc 1            Bloc 2
+-----------+     +-----------+     +-----------+
| prec: 000 |     | prec: H0  |     | prec: H1  |
| données   |     | données   |     | données   |
| ...       |     | ...       |     | ...       |
+-----------+     +-----------+     +-----------+
| emp.: H0  |---->| emp.: H1  |---->| emp.: H2  |
+-----------+     +-----------+     +-----------+

The first block, with no predecessor, is called the genesis block. The hash H1 of block 1 is computed from all of its contents, including the prec: H0 field. So H1 depends on H0, which depends on the contents of block 0. The dependency propagates step by step.

Why it is tamper-evident

Suppose an attacker wants to modify a transaction in block 0.

Modif. du bloc 0  ->  son empreinte H0 change  ->  devient H0'
Or le bloc 1 contient "prec: H0" (l'ancienne valeur)
   =>  le bloc 1 ne pointe plus correctement : chaîne rompue
Pour réparer, il faut recalculer H1 -> H1'
   =>  mais alors le bloc 2 (qui contient "prec: H1") casse
   =>  et ainsi de suite jusqu'au dernier bloc

Modifying a single block therefore forces you to recompute all the following blocks. This is the cascade effect. The ledger is said to be tamper-evident: any tampering leaves a visible trace.

What this guarantees, and what it does not

Chaining by hashing guarantees the integrity of history: nobody can quietly modify an old block, because the final hash would no longer match. Anyone, by recomputing the hashes from top to bottom, immediately detects the anomaly.

Hashing alone, however, does not stop an attacker from patiently recomputing the whole sequence. What makes this recomputation economically impossible is an additional mechanism—proof of work—which we will see in chapter 2.

In summary

  • A blockchain is a sequence of blocks, each containing the hash of the previous block.
  • Thanks to the avalanche effect of hashing, modifying a block changes its hash and cascades to invalidate all the following blocks.
  • The ledger is therefore tamper-evident: any alteration is immediately detectable by recomputing the hashes.
  • Hashing ensures integrity, but it is proof of work that will make rewriting truly infeasible.