Читать книгу Bitcoin For Dummies - Peter Kent - Страница 42

Hashing the blocks

Оглавление

All these blocks of data containing a record of transactions are, as you’ve discovered, stored on multiple computers — thousands of them, in scores of countries. That’s a powerful thing in itself; how can you hack all those computers? But there’s more; the chaining of the blocks from which blockchains get their name further complicates any attempt at hacking. Here’s how it works.

The Bitcoin network uses a hash to identify each block of transactions. The block is passed through a special hashing algorithm, a bit of complex mathematics that has very useful characteristics.

 When you hash a block of information, you end up with a very large string of characters.

 This string of characters is unique, and only matches that particular piece of hashed data. It acts like a fingerprint, uniquely identifying a particular block of data.

 Every time you hash the data, you will always end up with the same unique hash number.

 If you were to change a single character in the list of transactions, the hash would no longer match. That is, should you hash the modified data again, you would end up with a completely different hash.

How does this hashing mathematics do all this? You don’t need to know! We don’t know, after all, so why should you? Just accept that the mathematics does all this (it does), and don’t worry about how (just as you accept how your smartphone works do you really know how it functions?).

So here’s how the overall process works:

1 A node puts together a block of transactions.

2 The hash — the long string of characters acting as a “fingerprint” — copied from the previous block is also added to the block of transactions.

3 The node then hashes the block, previous-block’s hash and all. That is, it passes the combination to the hashing algorithm, which reads it and then creates the “fingerprint” the hash.Here’s a real example, taken from the Bitcoin blockchain:00000000000000000012b707bf6d172f0de94cfb311113c5d26dfe92764acc95

4 The hash is added to the block of transactions.

5 The block of transactions is added to the blockchain.

So, as the process moves along, and more transactions are added, we have a series of blocks of data, each containing two hashes: the hash identifying the previous block, and the new hash identifying the current block (including the current transactions and the previous block’s hash).

That’s how blocks are chained together into the blockchain (see Figure 2-1). Each block contains the previous block’s hash — in effect, a copy of the previous block’s unique fingerprint. Each block is also, in effect, identifying its position in the blockchain; the hash from the previous block identifies the order in which the current block sits.


FIGURE 2-1: Each block’s hash is stored in the next block of data. The hashes chain the blocks together in an orderly fashion.

Bitcoin For Dummies

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