What Is Bitcoin and How Does It Work?

 

By Shahid Shaikh

Bitcoin is a peer-to-peer electronic payment system created in 2009 by Satoshi Nakamoto. Bitcoin allows one to send money to anyone in the world, without the need for a central authority such as banks to issue accounts or process payments.

Bitcoin was created as a solution to the current financial system, where a marginal number of large corporations and banks control the financial world and the processing of transactions across the world.

It centralizes the control of finance and commerce and forces people to trust the banks to act responsibly.

"The central bank must be trusted not to debase the currency, but the history of fiat currencies is full of breaches of that trust," Satoshi said in the P2P Foundation.

Due to this trust issue, a major financial crisis affected the world at the end of 2007. This crisis inspired Satoshi to create Bitcoin.

Bitcoin is a computer program. You can download it precompiled, or you can download the source code from Github and compile it
yourself. Once you run the Bitcoin program on your computer, you become part of the network; you are a peer!

Once your computer becomes a part of the network, the program
will connect to other computers running the same program. Once
connected, computers will start sharing a file and try to sync the files with each other; this file is nothing but a Blockchain. Once your computer is up to date with the Blockchain files, you can start submitting the transaction.

Does everyone need to run the Bitcoin program to send/receive Bitcoin? Well, no. You can download a Bitcoin wallet and start making Bitcoin transactions. Those who wish to become a peer or miners in the network need to run the Bitcoin program

Does everyone need to run the Bitcoin program to send/receive Bitcoin? Well, no. You can download a Bitcoin wallet and start making Bitcoin transactions. Those who wish to become a peer or miners in the network need to run the Bitcoin program

This peer-to-peer nature of the system creates a trust-free, electronic cash system that runs with a solid consensus mechanism.


Now, let’s look over the technical aspects of Bitcoin.


Blocks

Block is the data structure that holds transactions in an immutable form. Bitcoin stores users’ transactions in the blocks, and later they form a chain to build a Blockchain network.

As we discussed in the previous sections, the block is generated by the miner by the process of mining. The mining process requires a consensus algorithm to reach an agreement in the network.

Block consists of the block header, which is used by the miner to generate the hash. Block header consists of the following:

  • Version: The version of the block
  • Previous block hash: Hash of the last identified block, thus forming a chain
  • Merkle root: Hash of all of the transactions in the block
  • Time: Timestamp
  • Bits: Hexadecimal version of the target value
  • Nonce: Is a 32-bit random whole number that is adjusted by the miners, so that it becomes a valid number to be used to provide the hash of the block that should be less than the target hash.


The first two fields are self-explanatory, and we have already discussed them in the previous sections. Let’s learn about the Merkle tree.


Merkle Tree

Merkle tree is the data structure in which every leaf node is labelled with the cryptographic hash of the data, and every non-leaf node is labelled with the hash of its child nodes, forming a tree to the root with one hash value.

As you can see in the following image, hash 0-0 and hash 0-1 is the hash value of data block L1 and L2. Later, Hash 0-0 and 0-1 will be hashed together to form Hash 0 and so on until we reach a root hash:

As shown in the preceding screenshot, the Merkle root contains transactions that are hashed together in a way the binary tree is formed.

Merkle tree is formed by hashing the transaction IDs in a pair. Transaction IDs are used if needed, and we can perform a recheck using the transaction 


ID in a tree.

To generate a Merkle tree, we take a pair of transaction IDs (TXID) and hash them twice using the SHA256 algorithm. The resulting hash is then hashed with another hashed pair twice to generate a single hash. This goes on till we generate a root hash.

Merkle trees are best suited for applications such as Bitcoin, where the size of the data matters. Due to the use of the Merkle tree, the block size is retained to 1Mb max in Bitcoin.


Let’s learn about the next field in the block header—Bits.


Bits

Bits is the field in the block header that stores the target value in the compact. Target is the value that is required for the miner to generate the block hash that is less than the target. We studied it in the Blockchain core concepts section.

Let’s look at an example.

Here’s what a target value looks like:

0x00000000000000000696f4000000000000000000000000000000000000000000

Storing such long values will require size, and mind you, the target will keep changing in the future.

To solve this, the target is compacted, and it looks like this in the block header field:

0x180696f4

It’s easy to store and takes less size.

Here’s how to decode a bit. It’s divided into two parts. The first two bits after 0x represent the number of 0s in the target value, and the remaining values are appended after 0. The rest of the field is then filled with 0s till it reaches 48 bit.

So, 0x180696f4 value can be written as:

0x----18 times zero---0696f4---rest zeros----

This way, we can decode the bits in the actual target value.

In the next section, we’ll look at the field, the miner used to generate the hash of the block that is lower than the target value.

Nonce

The Nonce is the field in the block header that is used by the miner to generate a hash. Bitcoin uses proof of work consensus algorithms. In proof of work, Miner has to generate a hash that is lower than the target value decided by the network.

Target value starts with several 0s, and it’s really difficult to get such a hash using the SHA256 algorithm on a random basis. So, Nonce comes into the picture, Miner uses the Nonce field to generate a hash, and if it is not lower than the target value, Miner increments the Nonce and tries again.

When the lucky number or Nonce is found, a hash is generated. Miner announces the block in the network, and every other node verifies and makes a copy of it in their Blockchain.

So, Nonce plays a crucial role in Bitcoin mining.

We have studied the block and important block header fields, so let’s move ahead and learn about Bitcoin transactions.




Transactions

When someone tries to transfer Bitcoin from one account to another, a new transaction is formed and added to the block by the miner.

The transaction contains data that is required for proper Bitcoin transfer. Transaction data consists of the amount that the user wants to send, account information such as from and to addresses, transaction information required for the network such as transaction Ids, and so on.

Transaction in Bitcoin contains the following information:

  • The transaction ID is also referred widely as TXID
  • Transaction data such as INPUT, OUTPUT, and so on
  • Fees
  • Weight
  • UTXO

Let’s learn about each one of them in brief.

TXID

TXID is a 32 bytes hexadecimal number that is referred to as transaction ID and used to identify the transaction in Bitcoin.

TXID is generated by hashing the transaction data twice using the SHA256 hashing algorithm.

Satoshi Nakamoto sent the first-ever Bitcoin transaction to Hal Finney, and the ID of the transaction is this:

f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16


Do you want to make money online?


Join First and Fast Communication System (Fnfcom) and make up to 4500Ksh daily.


You can also buy shares at Fnfcom and earn 163% on invested capital in three months.


Comments

Popular posts from this blog

Make Money Online Today (Step By Step Guide)

4 SECRET TECHNIQUES TO MAKE YOUR BUSINESS MORE AUTHENTIC

6 MOST SUCCESSFUL INCOME STREAMS EVERY WRITER SHOULD CONSIDER

6 WAYS TO MAKE ONLINE MEETINS BETTER