You are on page 1of 24

Unit 2.

Bitcoin and Block chain

2.1Creation of coins

The units of cryptocurrency are created through a process called mining. Mining is the
process of validating cryptocurrency transactions and creating new units of cryptocurrency.
The mining process uses powerful computer hardware and software to solve complex
mathematical problems that generate coins.

Cryptocurrencies use blockchain technology. Therefore, whenever a cryptocurrency


transaction occurs, cryptocurrency miners (who also act as nodes on the blockchain network
where these types of cryptocurrency transactions take place) try to decrypt the block
containing the transaction information. The block not only verifies the transaction but also
provides information about who sent how much cryptocurrency to whom, when and on what
date. Once a block is decrypted and accepted as authentic by the majority of nodes in the
blockchain network, the block is added to the blockchain. The verification process is very
resource-intensive in terms of the required computing power. As a result, individual
cryptocurrency miners often find the process too expensive, So because of this miners join
mining pools to share computing power.

Coins and Tokens

Cryptocurrencies are broadly divided into two groups – coins and tokens. A coin is a
cryptocurrency application that runs on its own blockchain, where all transactions take place.
Tokens, on the other hand, work on existing blockchain infrastructure and are typically used
for physical objects like smart contracts. digital services, etc.

Create Coin and Token:

1. Creating a coin: The coin creation process is not that challenging. You can simply copy
Bitcoin’s code, add a new variable, or even change its value, and that’s it – you have your
blockchain and your coin. However, you must understand the code and know how to modify
it, which requires extensive programming knowledge.

2. Creating a Token: As mentioned above, the token works with the existing blockchain
infrastructure. Therefore, if you create a token on a high-performance blockchain such as
Ethereum, your token should run on a highly secure network and also be secure from fraud
attacks. Tokenization is less expensive in terms of money and time when you leverage your
existing decentralized architecture and implement a consensus mechanism.

Popular solutions for making cryptocurrency

Ethereum: Ethereum is the first blockchain to offer a token creation service. It offers a
superior level of trust due to its maturity and strong position in the cryptocurrency market.
All tokens built on Ethereum use the ERC-20 standard. Tokens on Ethereum can only be
written in Solidity (its own programming language).
EOS: EOS tokens use the EOSIO. Token standard and can be created with C++ or any other
language like python, java, etc. that compiles to WebAssembly. With no transaction fees,
blockchains offer excellent scalability, high transactions per second, and cost-effectiveness.

NEO: Neo is an open-source community-driven blockchain platform, Neo’s vision is to be an


open network for a smart economy. Neo uses the NEP-5 standard. Unlike Ethereum, you can
create your own tokens on it using almost any high-level programming language like Java,
Python, etc. HTTP API can be used to interact with the blockchain.

Steps to Create a Cryptocurrency

Below are the steps to create a cryptocurrency:

1. Choose a Consensus Mechanism: Consensus mechanisms are the protocols that consider a
particular transaction legitimate and add to the block.

2. Pick a Blockchain Platform: Choosing the right blockchain platform for your business
depends on the consensus mechanism you choose.

3. Design The Nodes: You need to determine how your blockchain will work and function,
and design your nodes accordingly.

4. Establish Blockchain’s Internal Architecture: Set up the internal architecture of the


blockchain, Be sure about all the aspects before the launch as you won’t be able to change
several parameters of the blockchain after it’s launched and running.

5. Integrate APIs: Some platforms don’t offer pre-built APIs.Don’t worry, there are several
third-party blockchain API providers like ChromaWay, Gem, Colu, BlockCypher, etc.

6. Designing the UI: Building a top-notch cryptocurrency is useless if your UI is bad. You
need to ensure that the web, FTP server, and external databases are up-to-date and that front-
end and back-end programming is done with future upgrades in mind.
7. Legalize your cryptocurrency: Make sure your cryptocurrency is ready and compliant with
upcoming international cryptocurrency regulations. That way, your work is preserved, and no
sudden surprises can sabotage your efforts to create a new cryptocurrency.

Cryptocurrency mining reward

Cryptocurrency miners need money. They receive a small fraction of new units of
cryptocurrency for completing “blocks” of verified transactions that are added to the
blockchain.

Miners are paid in the cryptocurrency they wish to mine.

So when miners decide to decrypt a block of bitcoins, they get paid in bitcoins.

By pooling resources, miners increase their chances of success and share the cost, but only
receive a portion of the reward. This is known as a Cryptocurrency mining reward.

Pricing Cryptocurrencies

To understand cryptocurrency pricing, let’s take the most famous example of Bitcoin.

Like most other commodities in the market, the price of Bitcoin is determined by the
interaction of supply and demand and expectations of future prices.

For cryptocurrencies, pricing is entirely based on market dynamics.

If the market believes that the price of Bitcoin will rise in the future, they will now be more
people who are ready to pay more for it.

On the other hand, if the market believes that the price will fall in the future, there will be
more people selling cryptocurrencies now, and the price will be higher than at the future
level.

When selling, there are many people who accept lower prices than usual and expect lower
prices in the future.

Many Individual influencers can also significantly influence the price of cryptocurrencies.

Bitcoin Halving

The reward for mining, i.e. the amount of bitcoins a miner earns through successful
authentication, is fixed. However, this reward is numerically halved every four years. So,
when Bitcoin was introduced, miners could earn 50 BTC as a reward for successfully
processing a block. This is called the Bitcoin halving. After the first halving, this number was
reduced to 25, followed by 12.5, and the last halving as of 2020, which is currently 6.25. The
next halving is planned for 2024.

Cryptocurrencies in the Market


Currently, According to Forbes in 2022 top Five best cryptocurrencies in the market are
given below:

Bitcoin (BTC): Market cap of Bitcoin (BTC) is $880 billion.

Ethereum (ETH): Market cap of Ethereum (ETH) is $415 billion.

Tether (USDT): Market cap of Tether (USDT) is Over $79 billion.

Binance Coin (BNB): Market cap of Binance Coin (BNB) is Over $68 billion.

U.S. Dollar Coin (USDC): Market cap of the U.S. Dollar Coin (USDC) is Over $53 billion.

Advantages of Cryptocurrency

Self-governed and managed: Cryptocurrencies do not have a central issuing or regulatory


authority, they use a decentralized system to record transactions. Records of cryptocurrency
transactions are stored by miners on their hardware. Miners receive transaction fees as a
reward. Therefore miners keep transaction records accurate and up-to-date.

Secure and private: Privacy and security have always been the main concerns of
cryptocurrencies. Cryptocurrencies use blockchain technology, which uses encryption for
secure transactions. This makes cryptocurrencies more secure than ordinary electronic
transactions.

Currency exchanges can be done easily: Cryptocurrencies can be purchased in multiple


currencies such as USD, EUR, GBP, INR, or JPY. With the help of various cryptocurrency
wallets and exchanges, it is possible to convert one currency to another with minimal
transaction fees by trading cryptocurrencies between different wallets.

Transparency and anonymity: Due to the distributed nature of the blockchain, every
transaction is recorded and not changed. At the same time, if a crypto address is not publicly
verified, no one knows who made the transaction and who received the cryptocurrency.

A fast way to transfer funds: Cryptocurrencies have always been the best solution for
transactions. Cryptocurrency transactions, both international and domestic, are lightning-fast.
This is because verification takes very little time.

Low transaction fees: Compare with Banks and other financial institutions, Cryptocurrencies
charge relatively small amount transaction fees.

Disadvantages of Cryptocurrency

Decentralized but still operated by some organizations: Cryptocurrencies are known for their
decentralized nature. However, the circulation and quantity of some currencies in the market
are still controlled by their creators and some organizations.

Can be used for illegal transactions: Due to the high privacy and security of cryptocurrency
transactions, it is difficult for governments to track users by wallet address or track their
details. Bitcoin has historically been used as a currency exchange for many illegal businesses,
such as buying drugs on the dark web.

Data losses can cause financial losses: Developers want to create virtually untraceable source
code, strong protection from hackers, and authentication protocols that are hard to penetrate.
This makes investing in cryptocurrencies safer than investing in physical cash or bank vaults.
However, if the user loses the wallet’s private key, it cannot be retrieved. The wallet remains
locked along with the number of coins in it. This will bring financial losses to users.

Cryptocurrencies are highly volatile: Cryptocurrency markets are volatile and fluctuate
frequently, even for famous cryptocurrencies like Bitcoin. Investing in cryptocurrencies is
risky because you never know if it will be a profitable investment or not.

Cryptocurrencies Transactions are irreversible: If you enter an incorrect cryptocurrency


address then there is no way to reverse a transaction.

Cryptocurrency storage:- If the user loses the wallet’s private key, it cannot be retrieved. The
wallet remains locked along with the number of coins inside. This will result in the financial
loss of the user.

2.2Payments and double spending

Blockchain is a list of blocks. Each block comprises some information associated with
some hash. Blockchain is used nowadays widely for transactions. It is an immutable,
distributed, and decentralized ledger. The working of Blockchain is as follows. Suppose a
user wants to make a transaction. A block is created and sent to other users. Users validate
the block and the transaction gets executed. The block is added and the users get incentives.

Understanding Double Spending

Although Blockchain is secured, still it has some loopholes. Hackers or malicious users
take advantage of these loopholes to perform their activities.

Double spending means the expenditure of the same digital currency twice or more to avail
the multiple services. It is a technical flaw that allows users to duplicate money.

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.

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.

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

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.

The hacker gets incentives as well for the fake blocks that have been mined and confirmed.
How Does Double Spending Happen?

Double spending can never arise physically. It can happen in online transactions. This
mostly occurs when there is no authority to verify the transaction. It can also happen if the
user’s wallet is not secured. Suppose a user wants to avail of services from Merchant ‘A’
and Merchant ‘B’.

The user first made a digital transaction with Merchant ‘A’.

The copy of the cryptocurrency is stored on the user’s computer.

So the user uses the same cryptocurrency to pay Merchant ‘B’

Now both the merchants have the illusion that the money has been credited since the
transactions were not confirmed by the miners.

This is the case of double spending.

Example: Suppose a user has 1 BTC. He/She wants to avail of services from merchant A and
merchant B. The user creates multiple copies of the same BTC and stores it. The user first
sends the original BTC to Merchant A and gets the service. Simultaneously, the user sends
the copied version of 1 BTC to Merchant B. Since the second transaction was not confirmed
by other miners, the merchant accepts the bitcoin and sends the service. But the
cryptocurrency that was sent is invalid. This is the case of Double Spending.
Types Of Double Spending Attacks

There are different types of Double Spending attacks:

Finney Attack: Finney Attack is a type of Double spending Attack. In this, a merchant
accepts an unauthorized transaction. The original block is eclipsed by the hacker using an
eclipse attack. The transaction is performed on an unauthorized one. After that, the real block
shows up and again the transaction is done automatically for the real block. Thus the
merchant loses money two times.

Race attack: is an attack in which there is a ‘race’ between two transactions. The attacker
sends the same money using different machines to two different merchants. The merchants
send their goods but transactions get invalid.

51% Attack: This type of attack is prevalent in small blockchains. Hackers usually take over
51% of the mining power of blockchain and therefore can do anything of their own will.

How Bitcoin Handles Double Spending?

Bitcoin is one of the most popular blockchains. To combat Double spending it uses some
security measures. There are two types of examples of double spending in BTC.

The first case is making duplicates of the same bitcoin and sending it to multiple users.

The second case is performing the transaction and reversing the already sent transaction after
getting the service.

To tackle these double-spending issues, some security measures are taken. They are:

Validation: Validation of transactions by a maximum number of nodes in the network. Once


a block is created, it is added to a list of pending transactions. Users send validation for the
block. If the verifications are done then only the block is added to the blockchain.
Timestamp: The confirmed transactions are timestamped, therefore they are irreversible. If a
transaction is involved with a bitcoin it is verified and done. But in the future, if other
transactions are made with the same bitcoin, the transactions will be canceled.

Block Confirmations: Merchants get block confirmations so that they are assured that there
was no case of double spending. In bitcoin, a minimum of 6 confirmations are done.

Saving copies: A copy of each transaction is kept at each node so in case of network failure
the whole network does not go down.

These security features have reduced double spending to a large extent. Let us discuss a
detailed example of how bitcoin handles double-spending.

A user wants to spend 2 BTC. He/She can create multiple copies of the same cryptocurrency.

The user can send the same cryptocurrency to two different addresses say ‘Bob’ and ‘Alice’.

Both of these transactions are sent to the pool of unconfirmed transactions.

The first transaction T1 would be approved via the confirmation mechanism.

The confirmation mechanism states that a minimum of six confirmations by miners should be
done for block validation. The block is added to the network.

However, the second transaction T2 didn’t get sufficient confirmation so it would be


recognized as invalid by the confirmation process. The block with the highest number of
confirmations is accepted and the other one is rejected. So transaction T1 is valid, and Alice
received the bitcoin.

Solutions To Prevent Double Spending

Double Spending can be prevented using two approaches: Centralized and Decentralized
Centralized Approach: In this case, a secured third party is employed to verify the
transactions. The third-party can track each of the user’s balances. Suppose a user makes a
transaction. The third-party identifies the transaction with a unique identity. Then it verifies
the transaction and allows the transaction. The problem is that suppose we want to make
transactions with other countries where a third party is not required. So in such cases,
decentralized systems come into play. another drawback is if the whole system fails, the users
cannot have access.

Decentralized Approach: This approach is used by Bitcoin. In this, there is no involvement of


central authority. Each transaction is verified using powerful algorithms. The decentralized
approach proved to be more secure than the centralized approach. Protocols are established
and each protocol does its job at each step. Therefore this also promotes transparency.

How to Combat Double Spending?

Double spending has been minimized to a large extent as companies are using many security
features. But we as users also have some responsibility so that such attacks don’t happen.

Any user should wait for a minimum of six confirmations of the transaction before
performing another transaction. In the blockchain, more the confirmations by different users,
lesser will be double spending attacks.

Users should keep their hardware resources safe so that hackers do not misuse them for their
own purposes. Often hackers target the hardware part because the hardware is costly. If they
somehow steal the hardware, they can roll back any transaction or alter information.

Users should delete spam mails and avoid phishing to avoid unnecessary malware attacks
Phishing is a very common attack by hackers as hackers target login credentials.

Software should be updated regularly with the latest antivirus installed. If the software is not
up to date then the bugs present can cause major damage.

How Successful Double Spending is Administered?

With the increasing dependency on the blockchain, double spending attacks have also
become a major problem. Many companies have adopted security features.

Features like confirmation of the transaction by the nodes have been adopted. A minimum of
six confirmations is required to approve the transaction.

The blocks once created are immutable. They are made irreversible so that no transaction is
reverted back.

The network’s distributed ledger of transactions autonomously records each transaction. Each
node has a copy of all transactions that are being done in the network.

Verification of each transaction’s authenticity is done by Blockchain protocols to prevent


double-spending. The concept of hashing is adopted. Here each block has a unique hash.
Disadvantages of Blockchain Concerning Double Spending

There are many disadvantages of blockchain concerning Double Spending:

Control of the blockchain: The biggest disadvantage is if the hackers manage to take control
of 51% computation power, they can do any transaction of their own will and can steal other
users’ money. Therefore there is a threat to security as millions and millions of money are
involved in transactions.

Alteration of information: Transaction information can also be altered by hackers. They can
mine blocks and hide the original blocks using attacks like Eclipse attack, Finney Attack, etc.

No authority: The third major problem is no central authority is present to verify the
transactions. But these problems will be eliminated if companies take proper security
measures and users are also aware of the measures.

2.3Bitcoin Scripts

Bitcoin uses a scripting system for transactions. Forth-like, Script is simple, stack-based, and
processed from left to right. It is intentionally not Turing-complete, with no loops.

A script is essentially a list of instructions recorded with each transaction that describe how
the next person wanting to spend the Bitcoins being transferred can gain access to them. The
script for a typical Bitcoin transfer to destination Bitcoin address D simply encumbers future
spending of the bitcoins with two things: the spender must provide

1. a public key that, when hashed, yields destination address D embedded in the script,
and

2. a signature to prove ownership of the private key corresponding to the public key just
provided.

Scripting provides the flexibility to change the parameters of what's needed to spend
transferred Bitcoins. For example, the scripting system could be used to require two private
keys, or a combination of several keys, or even no keys at all.

A transaction is valid if nothing in the combined script triggers failure and the top stack item
is True (non-zero) when the script exits. The party that originally sent the Bitcoins now being
spent dictates the script operations that will occur last in order to release them for use in
another transaction. The party wanting to spend them must provide the input(s) to the
previously recorded script that results in the combined script completing execution with a
true value on the top of the stack.

This document is for information purposes only. De facto, Bitcoin script is defined by the
code run by the network to check the validity of blocks.

The stacks hold byte vectors. When used as numbers, byte vectors are interpreted as little-
endian variable-length integers with the most significant bit determining the sign of the
integer. Thus 0x81 represents -1. 0x80 is another representation of zero (so called negative
0). Positive 0 is represented by a null-length vector. Byte vectors are interpreted as Booleans
where False is represented by any representation of zero and True is represented by any
representation of non-zero.

Leading zeros in an integer and negative zero are allowed in blocks but get rejected by the
stricter requirements which standard full nodes put on transactions before retransmitting
them. Byte vectors on the stack are not allowed to be more than 520 bytes long. Opcodes
which take integers and bools off the stack require that they be no more than 4 bytes long, but
addition and subtraction can overflow and result in a 5 byte integer being put on the stack.

Opcodes

This is a list of all Script words, also known as opcodes, commands, or functions.

There are some words which existed in very early versions of Bitcoin but were removed out
of concern that the client might have a bug in their implementation. This fear was motivated
by a bug found in OP_LSHIFT that could crash any Bitcoin node if exploited and by other
bugs that allowed anyone to spend anyone's bitcoins. The removed opcodes are sometimes
said to be "disabled", but this is something of a misnomer because there is absolutely no
way for anyone using Bitcoin to use these opcodes (they simply do not exist anymore in the
protocol), and there are also no solid plans to ever re-enable all of these opcodes. They are
listed here for historical interest only.

New opcodes can be added by means of a carefully designed and executed softfork using
OP_NOP1-OP_NOP10.

Zero, negative zero (using any number of bytes), and empty array are all treated as false.
Anything else is treated as true.

2.4Bitcoin P2P Network

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


model that consists of a group of devices (nodes) that collectively store and share files where
each node acts as an individual peer. In this network, P2P communication is done without
any central administration or server, which means all nodes have equal power and perform
the same tasks.

P2P architecture is suitable for various use cases and can be categorized into structured,
unstructured, and hybrid peer-to-peer networks. The unstructured peer-to-peer networks are
formed by nodes randomly from connection to each other, but they are inefficient than
structured ones. In structured peer-to-peer systems, the nodes are organized, and every node
can efficiently search the network for the desired data. Hybrid models are actually a
combination of P2P and client-server models, and when compared to the structured and
unstructured P2P systems, these networks tend to present improved overall performance.
Today, P2P networks are the foundation of most of the cryptocurrencies, thus, making up a
significant portion of the blockchain industry. Want to get in-depth knowledge
about Blockchain technology? Check out the best blockchain certification courses now.
P2P vs. Traditional Client-Server Systems
Before understanding the role of these networks in blockchain, let’s distinguish between P2P
and traditional client-server architecture. The critical difference between both the systems is
that in Client-Server, there is a dedicated server and specific clients whereas, in P2P, it is
maintained by a distributed network of users, where each node can act both as a server and a
client.

Role of P2P in Blockchain


P2P is a technology that is based on a very simple principle, and that is the concept of
decentralization. The peer-to-peer architecture of blockchain allows all cryptocurrencies to be
transferred worldwide, without the need of any middle-man or intermediaries or central
server. 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.

Blockchain is a decentralized ledger tracking of one or more digital assets on a peer-to-peer


network. When we say a peer-to-peer network, it means a decentralized peer-to-peer network
where all the computers are connected in some way, and where each maintains a complete
copy of the ledger and compares it to other devices to ensure the data is accurate. This is
unlike a bank, where transactions are stored privately and are managed only by the bank.

P2P: Pros & Cons


Let’s talk about the advantages first. Here are few undeniable benefits of the P2P network in
the blockchain.

 As blockchain is a decentralized system of peer to peer network, it is highly available due


to decentralization.
 Because of P2P networking capability, even if one peer gets down, the other peers are still
present. Thus nobody can take down the blockchain.
 P2P networks offer greater security compared to traditional client-server systems.
 When you are using cloud computing to store your data, you need to trust AWS and
Google drives, but with the blockchain, because it utilizes peer to peer network you don’t
need to trust any third parties which can modify your crucial data. These are non-resistant
to censorship by central authorities.
 These networks are virtually immune to the Denial-of-Service (DoS) attacks.
 The distributed peer-to-peer network, when paired with a majority consensus requirement,
gives blockchains a relatively high degree of resistance to malicious activity.

P2P network in blockchain, however, raises few concerns. As in blockchain, instead of a


central server, distributed ledgers must be updated on every single node, adding transactions
requires a considerable amount of computational power. Although this provides an increased
level of security, it significantly reduces efficiency, and this acts as one of the main
hindrances in terms of scalability and mass adoption.

2.5 Transaction in Bitcoin Network

A transaction is a transfer of Bitcoin value on the blockchain. In very simple terms, a


transaction is when participant A gives a designated amount of Bitcoin they own to
participant B.
Transactions are created through mobile, desktop or hardware wallets.

How Does A Bitcoin Transaction Work?


For Bitcoin users, sending a transaction is as simple as entering an amount and an address in
their wallet and pressing send. They don’t have to worry about the technicalities of how it
works. Many users are curious how it works in practice though.

Bitcoin makes use of public-key cryptography to ensure the integrity of transactions created
on the network. In order to transfer bitcoin, each participant has pairs of public
keys and private keys that control pieces of bitcoin they own. A public key is a series of
letters and numbers that a user must share in order to receive funds. In contrast, a private key
must be kept secret as it authorizes the spending of any funds received by the associated
public key.

Using the private key associated with their bitcoin, a user can sign transactions and thereby
transfer the value to a new owner. The transaction is then broadcast to the network to be
included in the blockchain.

Overview of a Bitcoin Transaction


To better illustrate how value is transferred in the Bitcoin network, we will walk through an
example transaction, where Alice sends .05 bitcoin to Bob.

At a high level, a transaction has three main parts:

1. Inputs. The bitcoin address that contains the bitcoin Alice wants to send. To be more
accurate, it is the address from which Alice had previously received bitcoin to and is
now wanting to spend.
2. Outputs. Bob’s public key or bitcoin address.
3. Amounts. The amount of bitcoin Alice wants to send.
In order for Alice to send the .05 bitcoin to Bob, she signs a message with the transaction
details using her private key. The message contains the input, output, and amount as
described above. The transaction is then broadcast to the rest of the Bitcoin network where
nodes verify that Alice’s private key is able to access the inputs (by checking that Alice’s
private key matches the public key she is claiming to own).

Once a transaction is broadcasted to a node, this node then passes it along the network until it
reaches a mining node. Miners will then order this transaction into what is called a block
template. This is a blueprint for the block which the miner is attempting to add to the
blockchain. If a miner finds the next block in the chain, then this block template is mined and
becomes an immutable block on the blockchain. Finally, this block is broadcasted to the
network’s nodes who will include it in their copy of the chain.
Bitcoin Transaction Fees

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.

Each block in the blockchain can only contain up to 1MB of information. Since space is
limited, a limited number of transactions can be included in each block. Miners receive both a
block subsidy (newly minted bitcoin) and transaction fees for ordering transactions into
blocks. This means they are incentivized to prioritize the transaction with the highest fees.
During times of high network congestion, where a large number of users want to transact, the
transactions with the highest fees are more likely to be included in the next block.

2.6Block Mining

A peer-to-peer computer process, Blockchain mining is used to secure and verify bitcoin
transactions. Mining involves Blockchain miners who add bitcoin transaction data to
Bitcoin’s global public ledger of past transactions. In the ledgers, blocks are secured by
Blockchain miners and are connected to each other forming a chain.
When we talk in-depth, as opposed to traditional financial services systems, Bitcoins have no
central clearinghouse. Bitcoin transactions are generally verified in decentralized clearing
systems wherein people contribute computing resources to verify the same. This process of
verifying transactions is called mining. It is probably referred to as mining as it is analogous
to mining of commodities like gold—mining gold requires a lot of effort and resources, but
then there is a limited supply of gold; hence, the amount of gold that is mined every year
remains roughly the same. In the same manner, a lot of computing power is consumed in the
process of mining bitcoins. The number of bitcoins that are generated from mining dwindles
over time. In the words of Satoshi Nakamoto, there is only a limited supply of bitcoins. Only
21 million bitcoins will ever be created.

At its core, the term ‘Blockchain mining’ is used to describe the process of adding transaction
records to the bitcoin blockchain. This process of adding blocks to the Blockchain is how
transactions are processed and how money moves around securely on Bitcoins. This process
of Blockchain mining is performed by a community of people around the world called
‘Blockchain miners.’
Anyone can apply to become a Blockchain miner. These Blockchain miners install and run a
special Blockchain mining software that enables their computers to communicate securely
with one another. Once a computer installs the software, joins the network, and begins
mining bitcoins, it becomes what is called a ‘node.’ Together, all these nodes communicate
with one another and process transactions to add new blocks to the blockchain which is
commonly known as the bitcoin network. This bitcoin network runs throughout the day. It
processes equivalent to millions of dollars in bitcoin transactions and has never been hacked
or experienced downtime since its launch in 2009.
Types of Mining

The process of mining can get really complex and a regular desktop or PC cannot cut it.
Hence, it requires a unique set of hardware and software that works well for the user. It helps
to have a custom set specific to mining certain blocks.

The mining process undertaking can be divided into three categories:

1. Individual Mining

When mining is done by an individual, user registration as a miner is necessary. As soon as a


transaction takes place, a mathematical problem is given to all the single users in the
blockchain network to solve. The first one to solve it gets rewarded.

Once the solution is found, all the other miners in the blockchain network will validate the
decrypted value and then add it to the blockchain. Thus, verifying the transaction.

2. Pool Mining

In pool mining, a group of users works together to approve the transaction. Sometimes, the
complexity of the data encrypted in the blocks makes it difficult for a user to decrypt the
encoded data alone. So, a group of miners works as a team to solve it. After the validation of
the result, the reward is then split between all users.

3. Cloud Mining

Cloud mining eliminates the need for computer hardware and software. It’s a hassle-free
method to extract blocks. With cloud mining, handling all the machinery, order timings, or
selling profits is no longer a constant worry.

While it is hassle-free, it has its own set of disadvantages. The operational functionality is
limited with the limitations on bitcoin hashing. The operational expenses increase as the
reward profits are low. Software upgrades are restricted and so is the verification process.
Uses of Block chain Mining

1. Validating Transactions

Bitcoin transactions take place in huge figures every day. Cryptocurrencies function without
a central administrator and the insecurity can be substantial with the transactions that
transpire. So, what is the authentication method with such cryptocurrencies? With each
transaction, new blocks are added to the blockchain in the network and the validation lies in
the mining results from the blockchain miners.

2. Confirming Transactions

Miners work the blockchain mining process to confirm whether the transaction is authentic or
not. All confirmed transactions are then included in the blockchain.

3. Securing Network

To secure the transaction network, bitcoin miners work together. With more users mining the
blockchain, blockchain network security increases. Network security ensures that there are no
fraudulent activities happening with cryptocurrencies.

2.7Block propagation and block relay

The lack of scalability is known to be the foremost obstacle standing in the way of mass
adoption of blockchain technology.

· All existing blockchain projects look for solutions that could improve the
performance of their network.

· After the invention of decentralized peer-to-peer network Bitcoin, researchers got


interested in what determines the limits of Bitcoin’s scaling.

· Soon the core issue was determined and described in terms of block propagation
time or block propagation delay.

· It is an average time that is needed for the new block to reach most nodes in the
network.

· In a large-decentralized network like Bitcoin, whenever the new block is generated,


it is broadcasted according to the Gossip protocol.
· If some node has got the new valid block, it informs nodes connected to it about its
new possession.

· Then the node transfers this block to those nodes which asked it to do that. Before
the block reaches each full-node in the network, it passes through 7 intermediary
nodes.

· It is important that every honest node verifies the block before relaying it to other
peers.
· It is important that even in the worst-case scenario, the propagation delay should be
reasonable so that miners will keep their nodes synchronized most of the time and will
always verify proposed blocks.

· Whenever people talk about the scalability of the blockchain, they mention
the transaction throughput of the system.

· However, people forgot that improvements in


transaction throughput shouldn’t compromise the network’s security or raise data
storage requirements for nodes desiring to participate in the network.

· These modifications could decrease the number of independent transaction


validators in the network, thereby reducing decentralization.

· Transaction throughput in Bitcoin could be easily calculated using the formula:


where
· Bsize is the block size in bytes,

· Tsize is the average size of transaction record in the block,

· Btime is the average time between consecutive blocks in the blockchain.

Working with Consensus in Bitcoin


A blockchain is a decentralized peer-to-peer system with no central authority figure. While
this creates a system that is devoid of corruption from a single source, it still creates a major
problem.
· How are any decisions made?
· How does anything get done?

Think of a normal centralized organization.

All the decisions are taken by the leader or a board of decision makers. This is not possible in
a blockchain because a blockchain has no “leader”. For the blockchain to make decisions,
they need to come to a consensus using “consensus mechanisms”.
So,
1. How do these consensus mechanisms work and why did we need them?
2. What are some of the consensus mechanisms used in cryptocurrencies?

What are consensus mechanisms?


Consensus decision-making is a group decision-making
process in which group members develop, and agree to support
a decision in the best interest of the whole.

Consensus is a dynamic way of reaching agreement in a group. While


voting just settles for a majority rule without any thought for the feelings and
well-being of the minority, a consensus on the other hand makes sure that an
agreement is reached which could benefit the entire group as a whole.

From a more idealistic point-of-view, Consensus can be used by a group of people


scattered around the world to create a more equal and fair society.

A method by which consensus decision-making is achieved is called “consensus


mechanism”.
Objectives of a consensus mechanism are:
Agreement Seeking:
A consensus mechanism should bring about as much agreement from the group as
possible.
Collaborative:
All the participants should aim to work together to achieve a result that puts the best
interest of the group first.
Cooperative:
All the participants should not put their own interests first and work as a team
more than individuals.
Egalitarian:
A group trying to achieve consensus should be as egalitarian as possible. What this
basically means that each vote has equal weightage. One person’s vote cannot be
more important than another’s.
Inclusive:
As many people as possible should be involved in the consensus process. It should not
be like normal voting where people do not really feel like voting because they believe
that their vote won’t have any weightage in the long run.
Participatory:
The consensus mechanism should be such that everyone should actively participate in
the overall process.
We have defined what consensus mechanisms are and what they should aim for.
We need to think - which consensus mechanisms should be used for an entity like
blockchain.
Before bitcoin, there were loads of iterations of peer-to-peer decentralized
currency systems which failed because they were unable to answer the biggest
problem when it came to reaching a consensus. This problem is called
“Byzantine Generals Problem”.
Imagine that there is a group of Byzantine generals and they want to attack a city. They are
facing two very distinct problems:
· The generals and their armies are extremely far apart so centralized authority is
impossible, which makes coordinated attack very tough.

· The city has a huge army and the only way that they can win is if they all attack
at once.

This is where we face a problem.


This has clear references to blockchain as well. The chain is a huge network; how can you
possibly trust them? If you were sending someone 4 Ether from your wallet, how would you
know for sure that someone in the network isn’t going to tamper with it and change 4 to 40
Ether?
List of consensus mechanisms which can solve the Byzantine Generals problem.
1. Proof Of Work
2. Proof Of Stake
3. Delegated Proof Of Stake
4. Delegated Byzantine Fault Tolerance (DBFT)

2.8 Working with Consensus in Bitcoin


We know that Blockchain is a distributed decentralized network that provides immutability,
privacy, security, and transparency. There is no central authority present to validate and
verify the transactions, yet every transaction in the Blockchain is considered to be
completely secured and verified. This is possible only because of the presence of
the consensus protocol which is a core part of any Blockchain network. 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. In this way,
consensus algorithms achieve reliability in the Blockchain network and establish trust
between unknown peers in a distributed computing environment. Essentially, the consensus
protocol makes sure that every new block that is added to the Blockchain is the one and
only version of the truth that is agreed upon by all the nodes in the Blockchain. The
Blockchain consensus protocol consists of some specific objectives such as coming to an
agreement, collaboration, co-operation, equal rights to every node, and mandatory
participation of each node in the consensus process. Thus, a consensus algorithm aims at
finding a common agreement that is a win for the entire network. Now, we will discuss
various consensus algorithms and how they work.
1. Proof of Work (PoW): This consensus algorithm is used to select a miner for the next
block generation. Bitcoin uses this PoW consensus algorithm. The central idea behind
this algorithm is to solve a complex mathematical puzzle and easily give out a solution.
This mathematical puzzle requires a lot of computational power and thus, the node who
solves the puzzle as soon as possible gets to mine the next block. For more details on
PoW, please read Proof of Work (PoW) Consensus
2. Practical Byzantine Fault Tolerance (PBFT): Please refer to the existing article
on practical Byzantine Fault Tolerance(pBFT).
3. Proof of Stake (PoS): This is the most common alternative to PoW. Ethereum has
shifted from PoW to PoS consensus. 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 stake. After that, all the
validators will start validating the blocks. Validators will validate blocks by placing a
bet on it if they discover a block which they think can be added to the chain. Based on
the actual blocks added in the Blockchain, all the validators get a reward proportionate
to their bets and their stake increase accordingly. In the end, a validator is chosen to
generate a new block based on their economic stake in the network. Thus, PoS
encourages validators through an incentive mechanism to reach to an agreement.
4. Proof of Burn (PoB): With PoB, instead of investing into expensive hardware
equipment, validators ‘burn’ coins by sending them to an address from where they are
irretrievable. By committing the coins to an unreachable address, validators earn a
privilege to mine on the system based on a random selection process. Thus, burning
coins here means that validators have a long-term commitment in exchange for their
short-term loss. 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. The more coins they burn, the better are their chances of being selected to mine
the next block. While PoB is an interesting alternative to PoW, the protocol still wastes
resources needlessly. And it is also questioned that mining power simply goes to those
who are willing to burn more money.
5. Proof of Capacity: In the Proof of Capacity consensus, validators are supposed to
invest their hard drive space instead of investing in expensive hardware or burning
coins. The more hard drive space validators have, the better are their chances of getting
selected for mining the next block and earning the block reward.
6. Proof of Elapsed Time: PoET is one of the fairest consensus algorithms which chooses
the next block using fair means only. It is widely used in permissioned Blockchain
networks. In this algorithm, every validator on the network gets a fair chance to create
their own block. All the nodes do so by waiting for random amount of time, adding a
proof of their wait in the block. The created blocks are broadcasted to the network for
others consideration. The winner is the validator which has least timer value in the
proof part. The block from the winning validator node gets appended to the Blockchain.
There are additional checks in the algorithm to stop nodes from always winning the
election, stop nodes from generating a lowest timer value.
There also exist other consensus algorithms like Proof of Activity, Proof of Weight, Proof
of Importance, Leased Proof of Stake, etc. It is therefore important to wisely choose one as
per the business network requirement because Blockchain networks cannot function
properly without the consensus a
2.9Hashcash PoW

Hashcash is a proof-of-work system used to limit email spam and denial-of-service attacks,
and more recently has become known for its use in bitcoin (and other cryptocurrencies) as
part of the mining algorithm.

How it works
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. For email uses, a textual
encoding of a hashcash stamp is added to the header of an email to prove the sender has
expended a modest amount of CPU time calculating the stamp prior to sending the email. In
other words, as the sender has taken a certain amount of time to generate the stamp and send
the email, it is unlikely that they are a spammer. The receiver can, at negligible computational
cost, verify that the stamp is valid. However, the only known way to find a header with the
necessary properties is brute force, trying random values until the answer is found; though
testing an individual string is easy, satisfactory answers are rare enough that it will require a
substantial number of tries to find the answer.
The hypothesis is that spammers, whose business model relies on their ability to send large
numbers of emails with very little cost per message, will cease to be profitable if there is even
a small cost for each spam they send. Receivers can verify whether a sender made such an
investment and use the results to help filter email.
2.10 Bitcoin PoW

Proof of work (PoW) describes a system that requires a not-insignificant but feasible amount
of effort in order to deter frivolous or malicious uses of computing power, such as sending
spam emails or launching denial of service attacks. The concept was subsequently adapted to
securing digital money by Hal Finney in 2004 through the idea of "reusable proof of work"
using the SHA-256 hashing algorithm.

Understanding Proof of Work


This explanation will focus on proof of work as it functions in the bitcoin network. Bitcoin
is a digital currency that is underpinned by a kind of distributed ledger known as a
"blockchain." This ledger contains a record of all bitcoin transactions, arranged in sequential
"blocks," so that no user is allowed to spend any of their holdings twice. In order to prevent
tampering, the ledger is public, or "distributed"; an altered version would quickly be rejected
by other users

The way that users detect tampering in practice is through hashes, long strings of numbers
that serve as proof of work. Put a given set of data through a hash function (bitcoin uses
SHA-256), and it will only ever generate one hash. Due to the "avalanche effect," however,
even a tiny change to any portion of the original data will result in a totally unrecognizable
hash. Whatever the size of the original data set, the hash generated by a given function will
be the same length. The hash is a one-way function: it cannot be used to obtain the original
data, only to check that the data that generated the hash matches the original data.

2.11 Attacks on PoW and the monopoly problem

As we know, the idea of Proof of Work was by Cynthia Dwork and Moni Naor. This
permissionless consensus uses double SHA 256 which makes it secure from hackers. With
proof of work, miners compete with each other to complete the transaction and get the
bounty. Even it has many advantages like solving the double-spending problem and very
difficult to tamper it, but it is not impossible to tamper if the hacker has high computational
power.

we will see two major attacks by which PoW based systems can crash. They are :
1. Sybil Attacks
2. Denial of Service(DOS) Attacks
These are explained as following below with their solutions.
1. Sybil Attacks :
In 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.
In Simple language, The attacker can include multiple nodes in the network who can
collectively compromise the Proof of Work mechanism.
Solution –
To prevent Sybil attacks we have to diversify the connections i.e allowing outbound
connection to one IP per / 16 IP address. So by diversifying the network it is expected that
if the attacker generates multiple false miners the attacker will generate them within the
same clustered network or subnet.
Note :
Although this solution makes hard to launch sybil attacks but it doesn’t make it impossible.
2. Denial of Service (DOS) Attacks :
In this attack, 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.
Solution –
To prevent DOS attacks there are several rules bitcoin have which are:
 No forwarding of orphaned blocks.
 No forwarding of double-spend transactions.
 No forwarding of same block or transactions
 Disconnect a peer that sends too many messages
 Restrict the block size to 1 MB (1mb according to Satoshi Nakamoto)
 Limit the size of the bitcoin script up to 10000 bytes.
As we have seen above there are 2 major attacks that can alter transactions in Proof of
Work (PoW) based systems and we also discussed the solution for that. Now the question
comes Can we break Bitcoin PoW?
The answer would be YES, even after taking care of all types of attacks Bitcoin PoW is
computationally difficult to break, but not impossible. Because attackers can deploy high
power servers to do more work than the total work of the blockchain. There is a known case
of successful double-spending.
2.11Proof of Burn and Proof of Elapsed Time
Proof of elapsed time (PoET) is a blockchain network consensus mechanism that prevents
high resource utilization and energy consumption; it keeps the process more efficient by
following a fair lottery system.

The algorithm uses a randomly generated elapsed time to decide mining rights and block
winners on a blockchain network. By running a trusted code within a secure environment,
the PoET algorithm also enhances transparency by ensuring lottery results are verifiable by
external participants.

Understanding Proof of Elapsed Time (PoET)

A consensus mechanism is a method used by blockchain networks to verify transactions and


create more blocks. Proof of elapsed time (PoET) is a consensus mechanism often used on
permissioned blockchain networks to decide the mining rights or the block winners on the
network. Permissioned blockchain networks are types that require any would-be participant
to identify themselves before they are allowed to join.

The PoET network consensus mechanism needs to ensure two crucial factors. First, it
ensures that the participating nodes genuinely select a time that is indeed random and not a
shorter duration chosen purposely by the participants to win. Second, it establishes that the
winner has completed the waiting time.

The PoET concept was invented in early 2016 by Intel Corporation (INTC), the chip
manufacturing giant.1 It offers a readymade high-tech tool to solve the computing problem
of "random leader election." The ingrained mechanism allows applications to execute trusted
code in a protected environment, ensuring that both requirements—randomly selecting the
waiting time for all participating nodes and genuine completion of waiting time by the
winning participant—are fulfilled
In conjunction with other organizations such as the Linux Project and IBM, Intel sponsored
the open-source Hyperledger Sawtooth project, which uses the PoET consensus
mechanism. Hyperledger Sawtooth is a distributed ledger solution that is both scalable and
adaptable for many uses at the enterprise level.1

How Does PoET Work?


Based on the principle of a fair lottery system where every node is equally likely to be
chosen, the PoET mechanism spreads the chances of winning across the largest possible
number of network participants.

Under PoET, each participating node in the network must wait for a randomly chosen
period; the first to complete the designated waiting time wins the new block. Each node in
the blockchain network generates a random wait time and sleeps for that specified duration.

The one to wake up first—that is, the one with the shortest wait time—wakes up and
commits a new block to the blockchain, broadcasting the necessary information to the whole
peer network. The same process then repeats for the discovery of the next block.
How Is PoET Different from PoW?
Essentially, the workflow is similar to the consensus mechanism followed by Bitcoin's proof
of work (PoW) algorithm, but without its high power consumption. It allows a node to sleep
and switch to other tasks for the specified time, thereby increasing the network's efficiency.

The mechanism of running trusted code within a secure environment also takes care of many
other network necessities. It ensures that the trusted code runs within the secure environment
and is not alterable by any participant. It also ensures that the results are verifiable by
participants or other permissioned entities, thereby enhancing the transparency of the
network consensus.

PoET controls the cost of the consensus process and keeps it nimble so that it remains
proportional to the value derived from the process, an essential requirement for
the cryptocurrency economy to continue flourishing.

What Is Hyperledger Sawtooth?


Hyperledger Sawtooth is a distributed ledger—similar to a blockchain—designed for
enterprise uses like supply chain and logistics. It could even be used for inventory
management, accounting, or other business tasks that consume time and are prone to error.

Is There a Proof of Elapsed Time Coin?


PoET is primarily used in Hyperledger Sawtooth. As of January 2022, there isn't a
cryptocurrency that uses PoET.

What Is the Difference Between Proof of Work and Proof of Elapsed Time?
PoW is a competitive work mechanism, where PoET is a random selection mechanism.

Investing in cryptocurrencies and other Initial Coin Offerings (“ICOs”) is highly risky and
speculative, and this article is not a recommendation by Investopedia or the writer to invest
in cryptocurrencies or other ICOs. Since each individual's situation is unique, a qualified
professional should always be consulted before making any financial decisions.
Investopedia makes no representations or warranties as to the accuracy or timeliness of the
information contained herein.

You might also like