Vai al contenuto

Spedizione nei 27 paesi dell'UE · Nessun dazio doganale nell'UE · Garanzia 1 anno

How a blockchain works and is secured. Er, how does mining work again?

di Romain Schlick

What is a blockchain, how is it secured, and what exactly does mining do? In this 2022 educational video (in French), recorded shortly after Ethereum mining ended, we go back to basics: the principles of a blockchain, hashing, the nonce, how blocks are chained, difficulty, mining pools and the 51% attack. It is aimed at beginners as well as miners who want to consolidate their knowledge, with a few simplifications to keep it accessible.

What is a blockchain?

A blockchain, or chain of blocks, is first and foremost a tool for storing and transmitting information: a kind of database, comparable to a large ledger in which you record information that can no longer be falsified. There are several types:

  • Public or private: on a public blockchain, anyone can take part and send transactions. This is the case for Bitcoin, Ethereum or Ripple, and most cryptocurrencies. Private blockchains are mostly used for B2B purposes, such as Hyperledger Fabric or the ones developed at JP Morgan;
  • Permissionless or permissioned: a permissionless blockchain lets people act anonymously, without knowing the participants' identity. This is the kind we use in mining. On a permissioned blockchain, participants must be identified;
  • Centralised or decentralised: a decentralised blockchain has no central node. It relies on a peer-to-peer network in which each full node holds a complete copy of the blockchain and takes part in the network.

The journey of a transaction

Take wallet A sending bitcoins to wallet B. The transaction is broadcast to the network, then grouped with others into a block. This block is passed to the nodes of the network, which validate it using cryptographic techniques, mainly proof of work. Once validated, the block is added to the chain and wallet B receives the funds. Three principles make this possible: a distributed database, a consensus protocol to validate transactions, and the immutability of past transactions.

Hashing and the nonce

Hashing is at the heart of security. On Bitcoin, the algorithm used is SHA-256: whatever the input data, the hash function produces a result, the hash, a long string of characters. The same data always gives the same hash, but the slightest change, for example to the amount of a transaction, gives a completely different hash: any tampering is immediately visible.

The nonce is a number that can only be used once in cryptography. It is the core of proof of work: it works in combination with hashing and prevents the block's information from being manipulated. Mining means trying a huge number of nonce values until you get a valid hash, i.e. one that meets the difficulty set by the network.

Chained blocks: why the past cannot be rewritten

A block contains its number, the transaction data, the nonce, its hash and the hash of the previous block. This last element is what creates the chain: if someone changes the content of block 1, its hash changes, block 2, which contained the old hash, becomes invalid, and so on for all the following blocks. To change a past transaction, you would therefore have to re-mine every block that follows, an enormous amount of computation.

To go further: Bitcoin, Ethereum and many cryptocurrencies organise their transactions internally in a Merkle tree.

Difficulty and mining pools

Difficulty adjusts automatically so that the time between two blocks stays stable: if more miners arrive and blocks are found too quickly, the difficulty goes up. Put simply, the difficulty corresponds to the network's computing power multiplied by the target block time. Example on Ethereum Classic at the time of filming: a network hashrate of about 143 TH/s, i.e. 0.143 PH/s, and a block roughly every 13 seconds give a difficulty close to the one displayed, about 1.88 PH. This mechanism is essential: after Ethereum's Merge, Ergo ran into serious problems because its mining difficulty was not updating correctly.

In a mining pool, a component called the stratum orchestrates the sharing of work: it sends each miner part of the proof of work, with its own difficulty. Miners send back their solutions (the shares), and the pool, connected to the blockchain, broadcasts the block to the network when it is found.

The 51% attack and forks

To impose a modified version of the blockchain, an attacker needs to control more than 50% of the network's computing power. This is why new proof-of-work cryptocurrencies are vulnerable in their early days, especially at the time of filming: with Ethereum mining over, so much computing power was available that large miners could flood a given cryptocurrency, exceed 50% of its hashrate and carry out a 51% attack.

A blockchain can also split temporarily: this is called a fork. Two separate paths coexist for a while, then the network eventually converges on a single chain.

Smart contracts, their principles and how to implement them could be the subject of a future video: let us know in the comments if you are interested.

To choose where to send your computing power, read our article How to choose your mining pool and find all our videos on our tutorials page. Want to help secure the Bitcoin network? Discover our Bitcoin miners.

Articolo precedente
Articolo successivo

Grazie per l'iscrizione!

Questa e-mail è già registrata!

Acquista il look

Scegli le opzioni

Modifica l'opzione
Back In Stock Notification

Scegli le opzioni

this is just a warning
Accedi
Carrello
0 articoli