Blockchain - SLC - Chapter4 - Bitcoin - Lecture1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 67

BLOCKCHAIN TECHNOLOGIES

MODULE-4 Presented by-


Dr. Subhalaxmi Chakraborty
BITCOIN CST & CSIT Department

LECTURE- 1
MODULE-5

Blockchain 1.0: Need for Bitcoin, Commonly used terminologies: Mining, Block
frequency, Mining Pool, Block: Block Header, Hash, Markle root, Timestamp. SHA 256,
Bitcoin Mining and its types. Proof of Work, Mining Pool, Hashcash. Block
Propagation and Relay. Bitcoin scripting language and their use. Transaction in
Bitcoin.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 2


CRYPTOCURRENCY
The term cryptocurrency evolved from the word “crypto”
“Crypto” means concealed or secret ---
“currency” means money
Bitcoin is the first cryptocurrency
Cryptocurrencies are digital currencies designed to be faster, cheaper and more
reliable than money
In earlier days, form of trading where people exchanged goods and services
according to their needs, known as Bartering.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 3


NEED FOR BITCOIN
The three key requirements that eventually brought the birth of Bitcoin are as follows
A system where one can directly transact with another person without involving third
party like bank, to verify and validate the transaction and thus avoiding the cost of
mediation.

A system that is not controlled by central authority and assure the value of the money
is maintained.

A system where transparency of the transaction is maintained, while maintaining


privacy of the user
4/12/2023 DR. SUBHALAXMI CHAKRABORTY 4
ABILITY OF BITCOIN TO SOLVE THE PROBLEM OF
TRUST
The bitcoin system or protocol solved the problem of trust by allowing the willing parties to
directly transact with one another using cryptography

The bitcoin protocol uses Secure Hash Algorithm 256 bit(SHA 256) as hashing algorithm

Bitcoin is powered by blockchain technology

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 5


FORK
Cryptocurrency and blockchain projects, all have open source code.
Developers can copy the open source software and modify it to either build
compatible applications ie, wallet on existing blockchain or build a completely new
cryptocurrency network eg. Litecoin.
The process of duplication of an existing blockchain is called forking.
There are two types of fork
i)hard fork
Ii)soft fork

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 6


SOFT FORK
When the blockchain protocol is altered in a backwards-compatible way.
In soft fork you tend to add new rules such that they do not clash with the old rules.
That means there is no connection between the old rules and new rules. Rules in soft
fork are tightened.
When there is a change in the software that runs on the nodes (better called as ‘full
nodes’) to function as a network participant, the change is such that the new blocks
mined on the basis of new rules (in the Blockchain protocol) are also considered valid
by the old version of the software. This feature is also called as backwards-
compatibility

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 7


HARD FORK
When the blockchain protocol is altered in a non backwards-compatible way. Hard
fork is opposite of Soft fork, here the rules are loosened.

When there is a change in the software that runs on the full nodes to function as a
network participant, the change is such that the new blocks mined on the basis of new
rules (in the Blockchain protocol) are not considered valid by the old version of the
software

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 8


CHARACTERISTICS OF BLOCKCHAIN
Decentralised-
Fiat currencies are issued by government and regulated by central bank. Thus govt issued policies and
control of supply can affect the value of the currency.
Cryptocurrency, on the other hand is not controlled by any bank of central govt.
Form of existence-
While fiat can exist in both physical and (coin and paper) and digital form that allow electronics transfer of
money. Cryptocurrency can only exist in digital form.
Limited supply-
Supply of cryptocurrency is limited. The maximum no of cryptos that can be generated or mined is defined
when genesis block is created.
Global access-
The decentralised nature of blockchain allows anyone to access and transact in cryptocurrency irrespective of
their geographical location as long as they can access the internet. This allows faster processing times and
very low transaction fees as third party intervention is removed.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 9


CHARACTERISTICS OF BLOCKCHAIN
Transparency-
In standard transactions, the personal details are stored in tradition databases and these
transactions can be monitored, tracked and retrieved by the central authority. Privacy is a
major concern.
In cryptocurrency, a transaction is linked to the person’s cryptocurrency addresses and not the
person’s name address or any personal details
Impossible to duplicate-

Irreversible-
These cryptocurrency transactions are irreversible, unlike traditional currency transaction. Once
a transaction is recorded and verified, it is irreversible.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 10


CRYPTOCURRENCY WALLETS
Bitcoin or other cryptocurrency transactions can be done only using digital wallet.

A digital wallet is a software program that stores your private and public keys
enabling the user to transact crypto assets.

It helps to interact with various blockchains to enable the users to send and
receive digital currency and monitor their balance

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 11


HOT WALLETS
Hot wallets are connected to the Internet
This means that funds stored in hot wallets are more accessible, and are easier for
hackers to gain access to.
Using a hot wallet can be risky because computer networks have hidden vulnerabilities
that can be targeted by hackers or malware programs to break into the system.
he risks can be mitigated by using a hot wallet with stronger encryption, or by using
devices that store private keys in a secure enclave.

Examples of hot wallets include:


Web-based wallets
Mobile wallets
Desktop wallets

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 12


DESKTOP WALLET
Desktop wallet can be downloaded and installed on the user’s desktop or lap
As they are locally stored, the user has complete control of the wallet.
But as the wallet is dependent on the security features installed on your computer.
Hence if the computer gets hacked or is virus infected, the fund may be at risk.
Popular desktop wallets are Exodus, Bitcoin core, Electrum, etc.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 13


MOBILE WALLET
Mobile wallets are designed to operate on smart devices.
Mobiles are more vulnerable to malicious apps and viruses than desktop wallets
Hence, it is recommended that security features like wallet encryption are installed on
the mobile devices

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 14


ONLINE WALLET
Online wallets are called web wallet
They run on cloud hence user does not need to download or install any application
They can be accessed by any computing device via a web browser
Online wallets are hosted and controlled by a third party, hence are most vulnerable

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 15


COLD WALLETS

A cold wallet is entirely offline.


While they’re certainly not as convenient as hot wallets, they are far more secure.
An example of a physical medium used for cold storage is a piece of paper or an
engraved piece of metal.
Examples of cold wallets include:
Paper wallets
Hardware wallets

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 16


HARDWARE WALLET
Hardware wallets are physical , electronic devices that use Random Number
Generator to generate public/private key that is stored in the device
It connects to the internet whenever the user needs to send or receive payments and
disconnects once transaction is executed.
Transactions are confirmed through private keys that ae saved offline.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 17


DIFFERENCE BETWEEN HOT WALLET AND COLD WALLET
HOT WALLET COLD WALLET

Connectivity Online storage ; Connected to Offline storage; not connected to


internet the internet
Purpose Recommended for short term Recommended for long term
storage. Convenient for regular storage
day to day transactions
Accessibility Easily accessible and preferred Not easily accessible
by traders and new users
Cost Free Usage Need to be purchased

Security Susceptible to cyber attacks and No risk of attacks from internet


malware connections, however it should be
physically protected from loss or
breakage
Types Software wallets, online wallets Hardware wallets, paper wallet

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 18


TYPES OF CRYPTOCURRENCY
Altcoin-
Bitcoin is the frontrunner in the cryptoworld. It is widely used.
Many variants of the bitcoin have arisen using open source protocol, creating new
currencies with a set of different features.
The term 'Altcoin' is a combination of two words: 'alt' and 'coin' where alt means
'alternative' and coin means 'cryptocurrency'.
So altcoins are any cryptocurrency that is not Bitcoin.
They generally project themselves as better replacements for Bitcoin.
Some of the most well-known Altcoins (based on market cap) are Ethereum, Ripple,
Tether, Bitcoin Cash, Bitcoin SV, and Litecoin

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 19


MAIN FEATURES OF ALTCOINS
They are peer to peer digital currencies that involve a mining process.
They possess their independent blockchain.
They possess the characteristic of money.- Fungible, divisible and limited supply, used
as a means of payment

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 20


TOKENS
Another category of cryptocurrency on the top of existing blockchain.
It facilitates the creation of decentralised applications.
The basic principle is that running several applications on a shared blockchain is
more practical and business sevvy than executing a single application on a
blockchain.
Tokens are created from standard templates from blockchain platforms like Ethereum,
Lisk or Wavesplatform.
The functional variances are possible through the use of smart contracts.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 21


It is perhaps easiest to think of ERC20 as a set of basic guidelines and functions that
any new token created in the Ethereum network must follow.
An ERC20 token is a standard used for creating and issuing smart contracts on the
Ethereum blockchain.
Smart contracts can then be used to create smart property or tokenized assets that
people can invest in. ERC stands for "Ethereum request for comment," and the ERC20
standard was implemented in 2015.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 22


HOW TOKENS DIFFER FROM ALTCOINS
They are digital assests that are built perform a specific function within the project
ecosystem but not operational as a typical cryptocurrency.
For example, a dinner voucher will entitle you to dinner at the restaurant and a
cinema ticket to a movie. So you cannot use dinner voucher to watch a movie and
viceversa.
Same principle is applicable for tokens, where token can be used to provide a
service only for specific project/blockchain.
They donot have purchasing power. Tokens can be bought with coins but coins cannot
be bought with tokens.
They are built to interact with decentralised applications that sit on an existing
blockchain network like Ethereum. Hence they are easier to create than coins

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 23


WHAT IS ICO?

ICO stands for Initial Coin Offering.


Tokens are created and distributed to the public through the crowd funding method
called Initial Coin Offering.
Here, tokens are issued in exchange for funding a potential blockchain project.
Based on the function of the token, they are typically divided into two types
i) Utility token
Ii) Security token

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 24


4/12/2023 DR. SUBHALAXMI CHAKRABORTY 25
CRYPTOMINING
Miners generate wealth through mining process.
Blockchains vary in the mining systems that they use. A miner needs to have some level
of technical knowledge and expertise in setting up computing software and
equipment.
Miner use computing power to validate and produce a block.
However they all have some form of consensus algorithm and incentive system.
Bitcoin uses POW consensus mining algorithm and the successful miner gets a block
reward of 6.25 BTC.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 26


TYPES OF MINERS
i) Solo mining
When the mining process is performed solely by the miner itself.

i) Pool mining
When the miner collaborate with others to perform the mining task, referred as
pool mining

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 27


SOLO MINING
The miner works independently to find the block.
They typically have large mining equipment and don’t rely on any third party.
The miner connects to the network via their wallet.
Once they can create the block successfully, the hash is accepted by the network and
added to the block.
Then the block is confirmed, they are rewarded in cryptocurrency.
The main advantage of solo mining is that the miner is credited with full block
reward.
The main disadvantage is long time is taken by the miner to find a block compared
to pool mining as that utilises more resources and power.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 28


POOL MINING
When a group of miners join their collective computational resources over the
network towards faster processing of the hash function.

 The miners submit the block hashes into the pool. If any of the hash becomes
successful in creating the block in the blockchain network, the mining pool distributes
the reward between all the agreed.

Here all the miners who contributed to the pool benefit irrespective of whether they
produced the winning hash.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 29


POOL MINING(CONTINUING)
1) CPU Mining-

Central Processing Unit(CPU) mining is the earliest form where a miner utilizes central
processors to mine cryptocurrency.
Here, anyone with a laptop or desktop with required software installed can mine.
The process is slow consuming large amount of electricity.
Financially unviable.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 30


POOL MINING(CONTINUING)
2) GPU Mining-
Graphics Processing Unit(GPU) mining is the process where a miner utilises a
graphics processor to perform block validation

GPU mining is more efficient and cost effective, offering higher processor
power than CPU.

GPU is upgradable and higher resale value.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 31


POOL MINING(CONTINUING)
3) ASIC Mining-
ASIC stands for Application Specific Integrated Circuit.
A miner utilises an ASIC to perform block validation in ASIC mining.
They are more efficient , faster and can mine more coins in less time

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 32


CLOUD MINING
It is a mechanism by which a miner or a cloud mining company rents out cloud mining services to
other miners for a pre assigned period.

It is more cost effective for miners as they do not have to pay for setting up mining equipment.

The miner will open an account with the company and agree to the contract period, including the
hash power and can immediately start on the cloud mining services.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 33


AIRDROP
A strong community is the backbone of a value creating blockchain network.

Airdrop is a promotional activity aimed at spreading awareness among the


blockchain community.

It is a distribution event where a blockchain project distributes free coins or tokens
to wallet addresses to create a market for the project and a buzz among investors.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 34


BENEFITS OF AIRDROP
Airdrops are free money given out to early adopters in form of free coins or free
tokens. Start up companies use airdrops as an effective marketing strategy to spread
the word about their upcoming product, coin or platform.

It is mainly aimed at investors for funds, increasing the user base and for wider
distribution of coins/tokens.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 35


VARIOUS BENEFITS OF AIRDROPS TO THE BLOCKCHAIN
ENTERPRISE ARE:
i)Marketing and hype-
Airdrop is an excellent way to get people interested in cryptocurrency,
especially to create the much-needed hype around ICOs and free coins and
projects. Dropping free coin in a wallet can lead to free advertising for the
blockchain project or cryptocurrency through word of mouth, social media,
websites, and forums, leading to a strong user community and network
allowing for the cryptocurrency to appreciate in time.
ii)Rewarding loyalty supporters and investors: Airdrops are used by so companies as
exchange and trading platforms to incentivize users to continue to buy and use
tokens/coins on such platforms. If a user keeps substantial token in their wallet, the
company rewards them with free tokens. Also, t providing loyalty services like
promoting the cryptocurrency in social views, signing up on the platform, etc.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 36


VARIOUS BENEFITS OF AIRDROPS TO THE BLOCKCHAIN
ENTERPRISE ARE:
iii)Wider and even distribution of tokens:
Airdrops are an effective method for achieving wide and even distribution,
especially for utility tokens projects. It helps these projects to gain new users
and contributors, and at the same time, retain existing users which ultimately
leads to a high level of engagement within the community.

iv) Lead database generation: Airdrops are a great mechanism adopted by


blockchain based companies for lead generation. Users are requested to fill online
form coins/tokens. This valuable user information can be used by companies to
develop targated marketing campaigns and strategies.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 37


COMMON TERMINOLOGIES
Mining-
Creation of bitcoin is called mining.

Mining is the mechanism whereby the nodes called ‘miners’ in the bitcoin world
validate the new transaction and add them to the block chain ledger.

Miners compete with one another to solve complex mathematical problem (PoW) 
coming up with 64 digit hexadecimal number( hash )using massive computing power,
energy and time.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 38


BLOCK FREQUENCY

Bitcoin transactions are being registered into blockchain once in ten minutes.

Miners will first check the transaction. After viewing the transaction, the software will give a

complex target hash for the miners to solve.

If miners can solve the hash, then the computer will give bitcoins as a reward to the miner.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 39


INDUSTRIAL MINING
When all nodes are of uniform size and power, every node gets equal opportunity.

It is a fare competition to get a reward.

However, there are some nodes which do industrial sized mining and connect to a

massive set of computers , consume enormous power and use complicated software.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 40


HALFING POLICY
Block frequency and Halving are momentary policies of bitcoin.
Now a days 6.25 bitcoins as a reward to solve the hash.
From the year 2009 to 2012, 50 bitcoins were given as a reward.
The reward will be reduced to half for every four year.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 41


BITCOIN HEADER
Each block(of transactions) has three necessary information namely
I. Block Header
II. Hash of Previous block header
III. Merkel Root

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 42


BLOCKHEADER,HASH,MERKLE ROOT
Blockheader:
In bitcoin blockchain, the hash function of the previous block header is stored as a
reference in the next subsequent block to ensure the blocks are correctly connected.
Hash:
A hash function converts the data into a fixed from any arbitrary size.
Mainly, SHA 256 algorithm is used for bitcoin.
MerkleRoot:
A merkle root is created by hashing together pairs of transaction ids to give a short
and unique fingerprint for all the transactions in the block.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 43


MERKLE ROOT

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 44


MEMPOOL
Transactions are added to the mempool(Memory Pool) attached to each node.
The are unconfirmed transactions, which are to be included in the block after
validation.
Blocks are added in every 10 minutes but transactions happen all time.
Mempool is the staging area of the transactions where 10000 transactions can be
there at a time.
When a minor successfully mines, a set of transactions are added from mempool to
the block and the block is connected to the blockchain.
Once the trasactions are added to the blockchain, they are removed from the
mempool.
4/12/2023 DR. SUBHALAXMI CHAKRABORTY 45
BLOCK PROPAGATION
When a miner announces a block, the block needs to propagate to all the nodes in
the network, using goppip protocol (Transactions are propagated using gossip
protocol)

The concept of gossip communication is similar to the employees spreading rumours


in a company.
A node should perform the following functions
Validate transaction
Make sure the nonce is valid
Check if each transaction in the block is valid.
If all the above three conditions are valid, then the block is eligible for further propagation in the network.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 46


VARIOUS TYPES OF BITCOIN MINING
Mining is a mechanism whereby nodes called “miners” in the bitcoin validate the
new transactions and add them to the blockchain ledger.
For mining computers with high processing power along with graphics card are
required.
Miners compete to solve a complex mathematical problem based on the
cryptographic hash algorithm.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 47


BITCOIN MINING
Population hash set=16^64
Mining Difficulty=[Target hash set/Population hash set]
There are mainly two types of bitcoin mining:
Software mining
Hardware mining

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 48


O

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 49


POW

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 50


POW

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 51


IN ORDER TO GENERATE THE HASH

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 52


POW

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 53


POW

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 54


4/12/2023 DR. SUBHALAXMI CHAKRABORTY 55
4/12/2023 DR. SUBHALAXMI CHAKRABORTY 56
4/12/2023 DR. SUBHALAXMI CHAKRABORTY 57
4/12/2023 DR. SUBHALAXMI CHAKRABORTY 58
4/12/2023 DR. SUBHALAXMI CHAKRABORTY 59
4/12/2023 DR. SUBHALAXMI CHAKRABORTY 60
4/12/2023 DR. SUBHALAXMI CHAKRABORTY 61
BLOCK TIME
Block time is the length of time it takes to create a new block
in a cryptocurrency blockchain.

The Bitcoin network was designed for blocks to be


mined every 10 minutes on average, so the difficulty
increases (decreases) as the computational power behind
miners increases (decreases) to ensure that blocks continue to
be mined every 10 minutes on average.

Block frequency –every 10 minutes(for bitcoin)


4/12/2023 DR. SUBHALAXMI CHAKRABORTY 62
A block is verified by miners, who compete against each other to verify
the transactions and solve the hash, which creates another block.

Under the proof-of-work consensus mechanism, cryptocurrency is


rewarded for solving a block's hash and creating a new block.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 63


MINING POOL
While success in individual mining grants complete ownership of the reward, the odds of
achieving success is very low because of high power and resource requirements. Mining
is often not a profitable venture for individuals. So the concept of mining pool came.

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

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

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

Mining pools require less of each individual participant in terms of hardware and
electricity costs and increase the chances of profitability.
4/12/2023 DR. SUBHALAXMI CHAKRABORTY 64
A small number of mining pools, such as AntPool, Poolin, and F2Pool dominate the bitcoin
mining process, according to blockchain.com.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 65


PROBLEM OF DOUBLE SPENDING
Double spending means spending the same money twice.

 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.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 66


HOW BITCOIN HANDLES THE DOUBLE SPENDING
PROBLEM?

Let us suppose you have 1 BTC and try to spend it


twice. You made the 1 BTC transaction to Alice.
Again, you sign and send the same 1 BTC transaction to
Bob.
Both transactions go into the pool of unconfirmed
transactions where many unconfirmed transactions are
stored already. The unconfirmed transactions are
transactions which do not pick by anyone.
Now, whichever transaction first got confirmations and
was verified by miners, will be valid.
Another transaction which could not get enough
confirmations will be pulled out from the network.

In this example, transaction T1 is valid, and Alice will


receive the bitcoin.

4/12/2023 DR. SUBHALAXMI CHAKRABORTY 67

You might also like