Bitcoin and Blockchain

Bitcoin and Blockchain

Creation of Coins

  1. The units of cryptocurrency are created through a process called mining.

  2. Mining is the process of validating cryptocurrency transactions and creating new units of cryptocurrency.

  3. Bitcoin miners are processing transactions and securing the network using specialized hardware and are collecting new bitcoins in exchange.

  4. Bitcoin protocol is designed in such a way that new bitcoins are created at a fixed rate.

  5. Bitcoins are created at a decreasing and predictable rate.

  6. Every Bitcoin node in the world will reject anything that does not comply with the rules it expects the system to follow

Payment in Bitcoin

  1. Bitcoin is accepted as a mode of payment for goods and services at many merchants and retailer. To use bitcoin, digital wallets are required.

  2. Cryptocurrency wallets contain private keys to the bitcoin, which needs to be entered while conduction a transaction.

  3. Bitcoin was initially designed and released as a peer-to-peer payment method.

  4. An online business can easily accept Bitcoin by adding this payment option to its other online payment options: credit cards, PayPal, etc.

Double Spending

  1. Double spending means spending the same money twice, It is a technical flaw that allows users to duplicate money.

  2. Since digital currencies are nothing but files, a malicious user can create multiple copies of the same currency file and can use it in multiple places.

  3. This issue can also occur if there is an alteration in the network or copies of the currency are only used and not the original one

  4. There are also double spends that allow hackers to reverse the transactions so that transactions happens two times.

  5. By doing this, the user loses money two times one for the fake block created by the hacker and for the original block as well.

  6. Double spending can never arise physically. It can happen in online transactions.

Bitcoin Script

  1. Bitcoin Script is a simple programming language used to interact with the Bitcoin software

  2. Script was implemented by Satoshi Nakamoto in the release of Bitcoin Core version 0.1.

  3. Bitcoin Script uses a data structure that can be thought of as a linear structure represented by a physical stack or pile, items can be added or removed in LIFO queue.

  4. Bitcoin has a few different scripts, with Pay-to-Public-Key-Hash (P2PKH) being the most popular

  5. Turing incomplete means that Script for Bitcoin and other cryptocurrencies does not allow infinite loops.

Bitcoin P2P Network

  1. Peer to peer network, commonly known as P2P is a decentralized network.

  2. The peer-to-peer architecture of blockchain allows all cryptocurrencies to be transferred worldwide, without the need of any central authority or third-party.

  3. With the distributed peer-to-peer network, anyone who wishes to participate in the process of verifying and validating blocks can set up a Bitcoin node.

  4. Blockchain is a decentralized ledger tracking one or more digital assets on a peer-to-peer network.

  5. Advantages - Highly available due to decentralization, offers greater security, non-resistant to censorship by central authorities, good networking capability

  6. Disadvantages- requires high amount of computational power

Transaction in Bitcoin network

  1. Bitcoin transaction is a transfer of bitcoins from one address to another. The valid transaction must be signed by the sender.

  2. All bitcoin transactions are published to the mempool, where they are considered pending.

  3. Transactions are created through mobile, desktop or hardware wallets

  4. In order to transfer bitcoin, each participant has a pair of public keys and private keys that control pieces of bitcoin.

  5. Bitcoin makes use of public-key cryptography to ensure the integrity of transactions created on the network.

  6. Bitcoin users can control how quickly their transactions are processed by setting the fee rate. The higher the fee rate, the faster the transaction will be processed.

Block mining

  1. Blockchain mining is used to secure and verify bitcoin transactions.

  2. Mining involves blockchain miners who add bitcoin transaction data to bitcoin’s global public ledger of past transactions.

  3. The mining process undertaking can be divided into three categories -

  • individual mining - When mining is done by an individual, user registration as a miner is necessary.

  • Pool mining - In pool mining, a group of users works together to approve the transaction

  • cloud mining - Cloud mining eliminates the need for computer hardware and software. It’s a hassle-free method to extract blocks.

Block propagation and block relay

  1. Block propagation problem is well known, that prevents bitcoin from scaling

  2. Block propagation time is the average time that is needed for the new block to reach the majority of nodes in the network

  3. block relay is a protocol that allows two nodes with roughly similar sets of unconfirmed transactions to minimize both the bandwidth and the latency required to transfer a block that confirms many of those same transactions.

Working with Consensus in Bitcoin

  1. A Consensus algorithm is a procedure through which all the peers of the blockchain network reach a common agreement about the present state of the distributed ledger.

  2. In this way, consensus algorithms help to achieve reliability in the Blockchain network and establish trust between unknown peers in a distributed computing environment.

  3. There are different types of consensus algorithm which are as follows: Proof of Work (PoW), Proof of Stake (PoS), Proof of burn (PoB), Proof of Elapsed Time(PoET)

Proof of Work (PoW)

  1. Cryptocurrencies like Ethereum, Litecoin, and Bitcoin are currently using PoW consensus algorithm.

  2. It is a consensus mechanism in which computing power is used to verify cryptocurrency transaction and add them to the blockchain.

  3. The idea behind this algorithm is to solve a complex mathematical puzzle that requires a lot of computational power and easily gives out a solution.

  4. Proof of work is used widely in cryptocurrency mining, for validating transactions and mining new tokens.

  5. Challenges with PoW - The 51% risk, Time consuming, Resource consumption, Not instantaneous transaction

Hashcash in PoW

  1. Hashcash is a cryptographic hash-based proof-of-work algorithm that requires a selectable amount of work to compute, but the proof can be verified efficiently.

  2. HashCash was a solution designed to combat spam by generating a proof of work that allowed verifying that a certain email was not spam.

  3. Hashcash is a proof-of-work system used to limit E-mail spam and denial-of-service attacks. Hashcash was proposed in 1997 by Adam Back

Attack on PoW

Two major attacks by which PoW based systems can crash -

  1. Sybil Attacks : The attacker attempts to fill the network with the clients under its control. When this thing happens the attacker can actually control or get a monopoly over the network and these clients can do different kinds of actions based on the instruction from the attacker. They can refuse to relay the valid blocks or they can only relay the blocks which are generated by the attackers and those blocks can lead to double-spending.

  2. Denial of Service (DoS) Attacks : the attacker sends a lot of data to a particular node so that node will not able to process normal Bitcoin transactions. As a result, the metabolism of the mining procedure will get delayed which wastes the power for computation and in that meantime, the attacker can also send new nodes to the network resulting in a monopoly which is nothing but a Sybil attack.

Proof of Stake (PoS)

  1. Ethereum has shifted from PoW to PoS consensus in September 2022.

  2. In this type of consensus algorithm, instead of investing in expensive hardware to solve a complex puzzle, validators invest in the coins of the system by locking up some of their coins as stakes.

  3. After that, Validators will start validating the blocks. Validators will validate blocks by placing a bet on them, if they discover a block that they think can be added to the chain.

  4. Based on the actual blocks added in the Blockchain, all the validators get a reward proportionate to their bets, and their stake increase accordingly.

Proof of Burn (PoB)

  1. In PoB, instead of investing in expensive hardware equipment, validators ‘burn’ coins by sending them to an address from where they are irretrievable.

  2. By committing the coins to an unreachable address, validators earn the privilege to mine on the system based on a random selection process.

  3. Depending on how the PoB is implemented, miners may burn the native currency of the Blockchain application or the currency of an alternative chain, such as bitcoin.

  4. The more coins they burn, the better their chances of being selected to mine the next block

  5. While PoB is an interesting alternative to PoW, the protocol still wastes resource needlessly.

Proof of Elapsed Time (PoET)

  1. PoET is one of the fairest consensus algorithm which choose the next block using fair means only. It is widely used in Permissioned blockchains.

  2. In this algorithm, every validator gets a fair chance to create their own block.

  3. All the nodes do so by waiting for a random amount of time, adding proof of their wait in the block.

  4. The created blocks are broadcasted to the network for others’ consideration. The winner is the validator which has the least timer value in the proof part. The block from the winning validator node gets appended to the Blockchain.

Life of a bitcoin miner

Miners’ job is just like auditors i.e. to verify the legitimacy of the bitcoin transactions.

Miners help to prevent the double spending problem.

Miners are minting the currency. In the absence of miners, Bitcoin as the network would still exist and be usable but there would be no additional bitcoin.

Mining Pool

  1. Cryptocurrency mining pools are groups of miners who share their computational resources.

  2. Mining pools utilize these combined resources to strengthen the probability of finding a block or otherwise successfully mining for cryptocurrency.

  3. If the mining pool is successful and receives a reward, that reward is divided among participants in the pool.