This article is also available on udemy.com in a form of a udemy course.
Use the coupon code LIFEDIRECTOR.EU to get it for free
or coupon FUTURE_CLUB to get it for $10.99.
Number of years ago a revolutionary technology called Blockchain showed up on the scene and it is probably the biggest invention since the creation of the Internet. The first cryptocurrency using the Blockchain was Bitcoin and since then, thousands of other alternative coins arose.
Blockchain has no central point (of failure), that is why it’s almost impossible for authorities and corporations to control or regulate it. In this article we are going to show you how is the mining done, why is it so difficult and we are going to take a look at various ways how to store bitcoins.
Before we begin – Bitcoin = protocol, bitcoin, BTC = currency.
Cryptocurrencies use the kind of decentralization which takes the power over money from the banks, meaning no institution can tamper with the currency development. All that is due to the great invention of Blockchain.
It is, generally speaking, a globally distributed ledger. It is a chain of blocks, in which are the already completed transactions held with the help of strong cryptographic functions.
It‘s politically and architecturally decentralized, so it cannot be controlled or regulated by any institution, and it is divided into multiple computational units, typically a global network of computers. But logically it is centralized, because it behaves like a single entity, like a powerful supercomputer – doing only a single set of tasks.
Almost anything can be saved on the Blockchain, and it is possible to do so without the need of third parties – the value is transferred directly between people and nobody is taking any fees, at least not directly (see section „How is bitcoin made“). And on top of that, what was once written into the Blockchain, is unchangeable and permanent, thanks to high cryptographic security.
Mining new blocks
As we already know, a blockchain is a chain of blocks. This blockchain is distributed across all of the active nodes on the internet, similar to P2P torrents, where some of those nodes are so called miners. When one wants to send a transaction, one first needs to sign it with his own private key and the signed tx is then sent into the world. Miners now can test its validity by reading it by using the corresponding public key, which is, as the name suggests, publicly available (see Wallets and private keys). More validation takes place after that, including the double spend test – if one did not already spend the coins and is not trying to send non-existent coins.
All of that is possible thanks to the complete Bitcoin Blockchain transactional history being public, so searching for transactions is only a question of using your public key (and the Bitcoin address derived from it). Although the Blockchain history is public, nothing stops me from using multiple anonymous addresses.
If all the tasks completed successfully, now is the time to “pack” the tx into the block (one could say it is being “mined into the block”) and this new block is cryptographically linked to the previous block (using ECDSA, SHA-256 hash), so a kind of a linked-list is created. It should be noted that the solution to a block is a result of very taxing cryptographic operations, which aim to find the right solution (hash) of a block – the difficulty of these operations therefore makes a great security measure, because creating a hash from some variables is very easy, but to find these variables, from which was the hash created is insanely difficult. That is the core of asymmetric cryptography, on which the Blockchain and mining is based on. The asymmetry lies in the result to be easy to verify, but to find the result we would need asymmetrically more computing power (which makes mining an NP-complete problem in terms of computer science).
Bitcoin protocol is self regulating and it dynamically changes the difficulty every 2016 mined blocks (difficulty determines how computationally difficult is to find the hash of a block – by using leading zeroes metric – i.e. the random hash of a block must have 1500 leading zeroes, if it does, the hash is valid. Else keep looking, miner). So, if there is only one PC connected to the Bitcoin network and mining, it would take approximately 10 minutes to find the hash of a block. But if a million PC’s start to mine in the network, it will automatically adjust and mining will take again, around 10 minutes.
As we know, the txs are being clustered into blocks, which the miners proceed to connect with the previous block. With the 10 minute per block limit and the size of one block being 1MB (today), there could be around 2700 txs stuffed into the block (txs have variable size, which depends on fragmentation of the coin in the wallet) – we get the speed of 7 txs per second.
The security of Blockchain technology lies in the interlinked blocks. If an attacker wanted to change one transaction, he would have to change not only the one block in which the tx is, but also all of the blocks after it, because the hash function will change, if the contents of the block change. And he would also has to have at least half of the computational power of the Blockchain network to change it.
To see how insanely big computational power he would need today, let’s look at this. The combined computational power of the Bitcoin Blockchain network today is around 22 Exahashes/sec. For example, the Russian supercomputer under the city of Sarov has the power of 1 Petahash/sec (1000 Peta = 1 Exa). If you do the math you could see that the attacker would need tens of thousands of supercomputers to change one transaction. Just an anecdote – a group of Sarov nuclear scientists tried to use their supercomputer for bitcoin mining in Feb 2018, but they were caught.
Mining today is done on GPUs, but it is no longer profitable, that is the ASIC chips are made – they are specifically designed for cryptocurrency mining. But you can still use your GPU, or even CPU, to mine some altcoins. The most famous altcoin which you can mine on GPU is Ethereum, but it will switch to Proof of Stake algorithm this year, rendering itself unminable.
How is bitcoin made?
Bitcoin is created when a new block is mined. More precisely, the reward is given to the miner, who found the right solution of the block (hash). The reward is currently 12.5 bitcoin + all of the transactional fees in the block. The reward is halving every 210000 blocks (so every 4 years (1 block ~= 10 minutes)), so next time it will be 6.25 bitcoin. Presumably the price of bitcoin will be way higher at that time.
(Now is the block reward 12.5 BTC, so 12.5BTC@7800USD = 100,000 USD)
The transaction fee can be specified by the user, but the miners will of course prioritize the higher fee txs, because it means a higher reward for them. When you use low tx fee, you can wait dozens of blocks (or hundreds of minutes (1 block ~= 10 minutes). In any case, it is still better score than bank payment have – you have to wait anywhere between few days to few weeks, considering the overseas payments.
Alternative coins (altcoins), i.e. Litecoin or Dogecoin have the time on block set to lower values, LTC is on average 2.5 minutes and DOGE it‘s a minute.
Difficulty and Mining
Solo mining is not at all profitable nowadays. The difficulty of finding one bitcoin on your own, using your own hardware, is about the same as searching for one particular seed of sand on the whole Planet Earth. That is why the miners started to form groups, so called pools, where is their the computational power shared for the purpose of mining bitcoins. When are their endeavors successful, the found coin is democratically shared between everyone, depending on the work done.
New services are being created utilizing this new niche market, where you can share your GPU‘s computational power to this pool (nicehash.com) and obtain financial rewards.
The total amount of bitcoin that we will be able to ever mine is set to 21 million BTC. After the last block is mined the mining does not stop, but the blocks will no longer provide a reward in bitcoin, but only in the tx fees put inside them by clients. There are some theories about Bitcoin switching to the Proof of Stake algorithm (instead of Proof of Work we just described – you have to prove you have put some work into confirming the transaction, like electricity/money – if that was not the case, anyone could confirm even erroneous or badly intended transactions).
In Proof of Stake there is no need for mining, the transactions will be confirmed using distributed consensus algorithm on all of the nodes. The proof here is the age of your coins, amount of coins or any other significant metric. Higher amount can mean more weight to your vote. Ethereum should switch to PoS sometimes in 2018.
Wallets and private keys
Every wallet, be it software wallet (Bitcoin Armory, Electrum) or hardware wallet (Ledger Nano S, Trezor) holds one or more private keys. These privates keys are mathematically entangled to all of the Bitcoin addresses generated for this wallet.
The private key is a signature which allows you to spend coins held in the wallet, that is why it is crucial to store the key safely and in multiple places – who knows the key has access to all of your wallet‘s funds. And who does not know they key, or forgets it, will probably never be able to access the coins in his wallet again. In the case of a SW wallet it‘s wise to backup the key, be it on a paper or to write it in a book and hide it in a safe place. In the case of HW wallet, which holds the key inside we can use the same steps as with SW wallet and use additional protection in the form of locking it into a safe. Well, then you can have the HW wallet Trezor („safe“ in czech) hidden in the trezor 😀 You can also use cryptosteel, steel plates to backup your private key symbols. And if you are really paranoid, you could bury the cryptosteel into the cement, like John Wick does with his weapons.
Bitcoin private key is a 256 bit number. Most wallets use 12-24 English words, from which is the private key derived using a hash function. The key is generated using asymmetric cryptography, so it is primitive to create an address (public key) from the private key, but almost impossible to do it vice versa.
Stay tuned for the next article, about altcoins!