Chapter 1: Blockchain and Bitcoin

crypto_astronuts
9 min readDec 20, 2021

--

Episode 3(part 2): In this post, we are going to read about how blockchain technology works and how Bitcoin uses it to process its network.

Note: I wrote this article in summary note style

Part 1

Blockchain Technology: Part 2

https://bernardmarr.com/what-is-the-difference-between-blockchain-and-bitcoin/

Review

A transaction is a transfer of value between Bitcoin wallets that gets included in the blockchain. Bitcoin wallets keep a secret piece of data called a private key(More on private key subtopic) or seed, which is used to sign transactions, providing mathematical proof that they have come from the owner of the wallet. The signature also prevents the transaction from being altered by anybody once it has been issued. All transactions are broadcast to the network and usually begin to be confirmed within 10–20 minutes, through a process called mining(More on mining subtopic).

The public key and private key

Public key

The public key is a unique personal address that is shared in the blockchain. A public key is a cryptographic code that is created using asymmetric-key encryption algorithms and is used to convert a message into an unreadable format. As the bitcoin public key is made up of an extremely long string of numbers, it is compressed and shortened to form the public address. If an owner loses their public key, it is possible to recreate it using the private key.

Signature

A cryptographic signature is a mathematical mechanism that allows someone to prove ownership. In the case of Bitcoin, a Bitcoin wallet and its private key are linked by some mathematical functions. When your Bitcoin software signs a transaction with the appropriate private key, the whole network can see that the signature matches the bitcoins being spent. However, there is no way for the world to guess your private key to steal your hard-earned bitcoins.

Private key

A private key is a secret piece of data that proves your right to spend bitcoins from a specific wallet through a cryptographic signature. Your private key is stored in your computer if you use a software wallet; they are stored on some remote servers if you use a web wallet(and on paper if you use a paper wallet). Private keys must never be revealed as they allow you to spend bitcoins for their respective Bitcoin wallet.

Private and Public Keypair

A public key coupled with a private key helps to keep a user’s holdings secure in the digital ecosystem. As the term “public” suggests, a public key is a unique personal address that is shared in the blockchain and everyone can see it, while a private key works as a password that you must keep just to yourself.

A bitcoin public key is tied to only one private key, which is needed to verify the signature by the receiver. This means that the private key owner is the only one who can perform the encryption of it. Since it is impossible to regenerate the private key from a public key or address, if an owner loses their private key, any bitcoin or altcoins located at this public address will be inaccessible. However, if the owner loses the public key, it is possible to recreate it with the private key.

Genesis block

Is the first block of a chain which in the bitcoin case is the first block that contains the 10-bitcoin transaction to Hal Finney’s wallet. (2009)

Note:

  • Each block has its timestamp, in the bitcoin network every 10 minutes a block is created.
  • The longest chain is the main chain.
  • A blockchain is a growing list of records, called blocks, that are linked together using cryptography. Each block contains a cryptographic hash of the previous block, a timestamp, and data. Data could be anything in the bitcoin case it is transaction records.

Miners and mining

Mining is a distributed consensus system that is used to confirm pending transactions by including them in the blockchain. It enforces a chronological order in the blockchain, protects the neutrality of the network, and allows different computers to agree on the state of the system.

To be confirmed, transactions must be packed in a block that fits very strict cryptographic rules that will be verified by the network.

These rules prevent previous blocks from being modified because doing so would invalidate all the subsequent blocks.

Mining also creates the equivalent of a competitive lottery that prevents any individual from easily adding new blocks consecutively to the blockchain.

In this way, no group or individuals can control what is included in the blockchain or replace parts of the blockchain to roll back their own spends.

The process of minting new bitcoins is in some ways similar to the process of extracting precious metals from the earth. For this reason, it has come to be known as ‘bitcoin mining.’

A simplified overview of bitcoin mining is as follows:

  • People compete to earn bitcoin rewards by applying computing power in a process known as ‘Proof of Work’ (PoW). The process is named such because only participants (miners) who have proven they’ve dedicated sufficient resources (work) will have a chance at winning the rewards.
  • Rewards are twofold:
    (1) the ‘block reward,’ which is newly minted bitcoin. The block reward is currently set at 6.25 bitcoins (but will be cut in half from early May 2024, then cut in half again four years later, and so on).
    (2) the fees associated with all transactions in the current block. End users wishing to make a transaction must attach a fee to the proposed transaction as an incentive for miners to include it in the next block.

How are blocks added to the blockchain?
To add a candidate block to the blockchain, you hash the data in the block header with an extra number (nonce)and hope that the result is below a certain target value.

The target is calculated from the difficulty, which is a value set by the bitcoin network to regulate how difficult it is to add a block of transactions to the blockchain.

Difficulty
A value set by the bitcoin network that is designed to regulate how quickly blocks are solved. It adjusts every 2016 block to try and create an average of 10 minutes between blocks. In every blockchain the determination process of the difficulty is different but in Bitcoin's case, it’s like a number that the produced hash by miners should be smaller than that number. (the hash itself is a number, it is a hexadecimal number.)

Nonce
Each miner node should find a nonce which is a number that is the answer that completes(the mathematical puzzle that is mentioned before) the block creation process and each node finds it sooner get the reward and has mined the block.

This number is called a nonce, and it’s basically a dummy field that miners use to help them get a block hash below the target value.

What happens if two miners mine the same block at the same time? Which of the two blocks will be accepted? Who gets the block reward?
Firstly, I must clarify that although the two miners have mined an acceptable block, the blocks will almost certainly be different. It is not exactly the same block. This is because each miner will have chosen different transactions from the mempool and will have added them in their block in the order in which they have considered appropriate. Then each one of the two miners will have solved their own block with the nonce found by Proof of Work that gives a solution to their specific block as they have built it.

At this point, we find ourselves with two resolved blocks perfectly valid to be the next addition to the Blockchain and consequently grant the block reward to the responsible miner.

At this time, the decision on which block will be chosen depends on all the other miners in the network.

Depending on different factors, such as the computational strength of the miners working on each version or even luck, soon a next block will be discovered in one of the two versions before the other. When the longest version starts spreading across the network, miners who had accepted the other version will have no choice but to discard the one they were working on since, in Proof of Work, the longest blockchain always wins, (understood as the one with the most accumulated computational work).

Halving

After every 210,000 blocks mined, or roughly every four years, the block reward given to Bitcoin miners for processing transactions is cut in half. This event is referred to as halving because it cuts in half the rate at which new bitcoins are released into circulation. This is Bitcoin’s way of enforcing synthetic price inflation until all bitcoins are released.

This rewards system will continue until around the year 2140 when the proposed limit of 21 million is reached. At that point, miners will be rewarded with fees, which network users will pay, for processing transactions. These fees ensure that miners still have the incentive to mine and keep the network going.

Bitcoin price surge after each Halving

--

--

crypto_astronuts

This page is only intended to be used as a knowledge system for myself and others who enjoy reading it.