Читать книгу Introduction to Blockchain Technology - Tiana Laurence - Страница 23

From blocks to hashes

Оглавление

The way that blockchains ensure their records are not corrupted is by using hashes. A hash is similar to symmetric encryption, except that instead of having a key that unlocks the data, the data itself creates a fixed length key via a one-way mathematical proof. The data is the key.

A hashing algorithm is used to take a data input of any size and produce a fixed length string. The fixed length string is the hash and acts as a “signature” or “fingerprint” for the data input. If any of the input data is changed, it will create a completely new digital fingerprint, or rather hash, as can be seen in figure 12.

In the case of blockchains, the data input is a block of transactions.

Each block is run through a hashing algorithm to produce a unique hash that only that block could produce. This unique hash is represented by a fixed length string of numbers and letters. Bitcoin, for example, used a hashing algorithm called SHA256 (Secure Hashing Algorithm 256).

What this means is that all the data in the block can only ever create one unique fixed-length string of numbers and letters. If any of the data in the block is changed or missing, then it would create an entirely different hash. This allows the nodes that are securing the blockchain records to quickly check that everything is intact and has not changed.


Figure 13 Hashes.

The hashes of each block are published in the next consecutive block creating a chain of records. The hashes prove the order of the blocks and, by default, the order of the transfer of cryptocurrency from one address to another.

Here are some key features of hashes:

■ All hashes are deterministic, no matter how many times a block is run through a hash function you will always get the same result.

■ Hashes are easy for nodes to compute. Think of this like Sudoku. It is easy to see that the puzzle was solved correctly, but it is difficult to reproduce.

■ Hashes must be very sensitive to changes in data input. Any change to the blockchain record will create a completely different hash.

■ Hashes must be what is known as “collision resistant”. This means that it is practically impossible to create the same hash from two different sets of data.

Introduction to Blockchain Technology

Подняться наверх