Home  >  Blog  >   Blockchain

What is Bitcoin and how does it work?

Rating: 5
  
 
4126

In the traditional financial transaction system the buying party and selling party, need an intermediary usually a bank or a financial institution to facilitate and keep records of the transaction.

The trusted intermediary charges money to facilitate transactions and asks for important and sensitive information about involving parties. 

To solve this problem and eliminating the intermediary Satoshi Nakamoto (Pseudonym) introduced Bitcoin and devised the first Blockchain database.

What is Bitcoin Purpose and How does it Work?

Bitcoin is a decentralized, peer-to-peer electronic cryptocurrency. There is no governing body or issuing authority for Bitcoin. Bitcoin network operates on cryptographic protocol and the public database is fault-tolerant and resistant to corruption.

Bitcoin network operates without a central repository or a centralized administration and the transactions directly take place between users. Bitcoins can be converted to other real-world currencies and can be used for payment.

Bitcoins are created by mining. Mining is the process by which volunteers known as miners lend their computing power to verify transactions and record them in a public ledger. Miners keep the network secure.

Blockchain:

Blockchain is a distributed database. In Bitcoin network Blockchain is a public ledger that records transactions. It is fault-tolerant and resistant to modifications that can corrupt the records.

All nodes share a copy of Blockchain, when a node joins the network it downloads all the blocks and verifies it. So modifying the Blockchain is nearly impossible, as everyone in the network has its copy and if someone modifies it, all other nodes will reject the modified block.

The blockchain contains all the transaction history that ever been happened in the network. Each block has a hash value referring to the previous block. 

Genesis Block:

The genesis block is the first block in the blockchain. It does not have a hash value referring to the previous block. The genesis block was hardcoded and first mined by Satoshi Nakamoto. To mine genesis block it requires custom codes.

Flow of Genesis Block

If you want to enrich your career and become a professional in Bitcoin, then visit Mindmajix - a global online training platform: "Bitcoin Certification Course" This course will help you to achieve excellence in this domain. 

How are Bitcoins generated?

Bitcoins are created by a proof of work concept known as mining. Mining is the process by which miners lend their computing power to verify and record a transaction into the Blockchain. Bitcoin mining is a difficult process and requires a lot of computing resources.

By verifying the transactions miners prevent double-spending of bitcoin. Without miners, the network would be vulnerable, and hence for their volunteer service, miners are awarded new Bitcoins.

While the software and network were created for the first time, Satoshi Nakamoto mined 50 Bitcoins as a reward for mining the genesis block. 21 million bitcoin will come into existence ever. The block reward started at 50 bitcoins per block, and halves every 210,000 blocks.

This means that each block up until block 210,000 will reward 50 bitcoins, but block 210,001 will reward just 25. Block halving happens every four years with an average of 10 minutes time for a block.

MindMajix Youtube Channel

Value of Bitcoin:

Bitcoin is just like any other currency and can be used for trade exchange. The value of bitcoins has increased a lot in the last 7 years and changes just like gold and you have to check the market to get the value for the day.

How do you get Bitcoins?

You can create a wallet by downloading wallet software. There are many wallets available for bitcoin both software and hardware-based wallet. The wallet will give you a payment address and a private key.

The private key is very important and if lost you cannot access the wallet and all Bitcoins will be lost. Once you generate your address, you can accept payment. You can request payment online by being completely anonymous and share your payment address with the payee.

You can buy bitcoins from coindesk, zebpay, and there are other apps that trade in bitcoin. But before buying and investing in bitcoin you should check auction sites to get bitcoin value.

Bitcoin can be earned by mining. However, mining is a pain-taking process. It involves highly sophisticated custom mining devices and a lot of electrical power. Before investing in you should run a profit calculator.

How does Bitcoin make money?

Bitcoin is open-source software and the network is public. There are no owners of the bitcoin network and the developers do not make any money by creating it. However, they can receive donations.

The network is self-sufficient due to volunteers mining and verifying the block and the miners who are rewarded by new bitcoins.

Bitcoin Mining

Bitcoin mining is a resource-intensive and compute-intensive difficult task. By mining, miners verify and the transaction to the block and make it secure. By design, the mining process is difficult so that the number of blocks may remain steady each day as found by the miners.

Computation:

By mining, the miners run the proof of work algorithm that converts the transaction data to a 64 digit hash and the hash must be less than or equal to the target value.

Now the hash must follow certain rules. It should start with at least eight leading zeros. So miners generate random nonce to create the hash.

Nonce (Number only used once) is a 32-bit field. It is generated randomly and if a hash contains a nonce that is less than or equal to the target value then the block is verified and bitcoins are rewarded. If you change the nonce the hash will be completely different.

To generate the hash many nonce values are given input and each time computation runs to generate the desired hash.

The mining algorithm Bitcoin uses is called Hashcash and is derived from Back’s Hashcash algorithm [B+02]. The idea behind the algorithm is that the miner needs to assemble a block in such a way that the hash of the block header is the solution to a partial pre-image of a hash, i.e. the hash digest that is produced by hashing the header needs to be below a well defined numerical value.

The hashing algorithm used is the NIST standard SHA256. The header is actually hashed twice to be a valid block, where the difficulty is a numerical value that needs to be bigger than the resulting hash value: difficulty > h(h(BlockHeader)) From the properties of cryptographical hash functions (see Section 2.1.1), it is infeasible to find such a value – except to try and brute force the output, which is exactly what the miners do. Of course, the block header has a certain structure, so all values cannot be changed at random.

The consensus protocol of Bitcoin has been dubbed Nakamoto Consensus after the original idea from Satoshi Nakamoto [Nak08]. The Nakamoto consensus is a strategy of operation that makes it so, if most nodes adhere to it, the biggest reward that can be gained for a node is achieved by staying with this strategy.

Computation Algorithm

Now the mining fees for each successful block every 12.5 bitcoins.

Field
Purpose
Update timeSize (bytes)
VersionBlock version numberSoftware upgrade time4
Hash of the previous block256 bit hash of the previous blockA new block comes in32
Hash Merkel root256 hash of all block headersA transaction is accepted32
TimeCurrent Unix timestampEvery few seconds4
BitsCurrent target in a compact formatThe difficulty is adjusted4
nonce
A 32-bit number (starts at 0)
A hash is tried (increments)4

Bitcoin uses hashcash algorithm for computing the SHA256.

SHA256(SHA256(Block_Header))

Frequently asked Bitcoin Interview Questions

Example python code:

import hashlib
>>> header_hex = ("01000000" +
 "81cd02ab7e569e8bcd9317e2fe99f2de44d49ab2b8851ba4a308000000000000" +
 "e320b6c2fffc8d750423db8b1eb942ae710e951ed797f7affc8892b0f1fc122b" +
 "c7f5d74d" +
 "f2b9441a" +
 "42a14695")
>>> header_bin = header_hex.decode('hex')
>>> hash = hashlib.sha256(hashlib.sha256(header_bin).digest()).digest()
>>> hash.encode('hex_codec')
'1dbd981fe6985776b644b173a4d0385ddc1aa2a829688d1e0000000000000000'
>>> hash[::-1].encode('hex_codec')
'00000000000000001e8d6829a8a21adc5d38d0a473b144b6765798e61f98bd1d'

import hashlib, struct
ver = 2
prev_block = "000000000000000117c80378b8da0e33559b5997f2ad55e2f7d18ec1975b9717"
mrkl_root = "871714dcbae6c8193a2bb9b2a69fe1c0440399f38d94b3a0f1b447275a29978a"
time_ = 0x53058b35 # 2014-02-20 04:57:25
bits = 0x19015f53
 
# https://en.bitcoin.it/wiki/Difficulty
exp = bits >> 24
mant = bits & 0xffffff
target_hexstr = '%064x' % (mant * (1<<(8*(exp - 3))))
target_str = target_hexstr.decode('hex')
 
nonce = 0
while nonce < 0x100000000:
    header = ( struct.pack("

Output:

0            5c56c2883435b38aeba0e69fb2e0e3db3b22448d3e17b903d774dd5650796f76

1            28902a23a194dee94141d1b70102accd85fc2c1ead0901ba0e41ade90d38a08e

2            729577af82250aaf9e44f70a72814cf56c16d430a878bf52fdaceeb7b4bd37f4

3            8491452381016cf80562ff489e492e00331de3553178c73c5169574000f1ed1c

39            03fd5ff1048668cd3cde4f3fb5bde1ff306d26a4630f420c78df1e504e24f3c7

990            0001e3a4583f4c6d81251e8d9901dbe0df74d7144300d7c03cab15eca04bd4bb

52117            0000642411733cd63264d3bedc046a5364ff3c77d2b37ca298ad8f1b5a9f05ba

1813152        00000c94a85b5c06c9b06ace1ba7c7f759e795715f399c9c1b1b7f5d387a319f

19745650        000000cdccf49f13f5c3f14a2c12a56ae60e900c5e65bfe1cc24f038f0668a6c

243989801        0000000ce99e2a00633ca958a16e17f30085a54f04667a5492db49bcae15d190

856192328        0000000000000000e067a478024addfecdc93628978aa52d91fabd4292982a50

Mining Systems:

CPU: When bitcoin came, first it was possible to mine using CPU. However, CPU mining is not efficient and the computing cost does not generate profit. Therefore, CPU mining is now removed from client software.

GPU: GPU mining is faster compared to CPU mining. However, the system costs a very high price.

FPGA: Field Programmable Gate Array mining is a faster and efficient way to mine.

ASIC: Application Specific Integrated Circuit is specially purposed hardware for bitcoin mining.

Cloud Mining Pool: You can join a pool at a price to mine bitcoin.

How does bitcoin works?

Bitcoin works as a decentralized peer-to-peer electronic payment system. We can get started without understanding many technical details about it.

Once you get a wallet and have some bitcoin you can start the transaction. Bitcoins are accepted as a trading currency. You can have as many as bitcoin address for accepting bitcoins.

Bitcoin Usage:

Bitcoin is accepted by many businesses. Most VPN providers and file-sharing services use bitcoin to accept payments and donations in form of bitcoin and as there is no central authority and bitcoin is peer to peer no one can hold on releasing funds.

For in-depth knowledge on Bitcoin, click on below:

Join our newsletter
inbox

Stay updated with our newsletter, packed with Tutorials, Interview Questions, How-to's, Tips & Tricks, Latest Trends & Updates, and more ➤ Straight to your inbox!

Course Schedule
NameDates
Bitcoin CourseMar 23 to Apr 07View Details
Bitcoin CourseMar 26 to Apr 10View Details
Bitcoin CourseMar 30 to Apr 14View Details
Bitcoin CourseApr 02 to Apr 17View Details
Last updated: 29 Apr 2023
About Author

Arogyalokesh is a Technical Content Writer and manages content creation on various IT platforms at Mindmajix. He is dedicated to creating useful and engaging content on Salesforce, Blockchain, Docker, SQL Server, Tangle, Jira, and few other technologies. Get in touch with him on LinkedIn and Twitter.

read more
Recommended Courses

1 / 2