0% found this document useful (0 votes)
40 views69 pages

BCT Unit 1 ND 2 Notes by

blockchain notes for beginners

Uploaded by

clashwizard41
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views69 pages

BCT Unit 1 ND 2 Notes by

blockchain notes for beginners

Uploaded by

clashwizard41
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 69

UNIT-1

INTRODUCTION
INDEX
Overview of block chain.
Public ledgers.
Bitcoin
Smart contract.
Block in block chain.
Is a distributed or decentralized databases or ledger that is

shared among the nodes of a computer network . And it is

very difficult to change is called Block chain Technology.

OR Is an advanced database mechanism that allows

transparent information sharing within a business network.


History of block chain Technology
It came in existence in 1991. where cryptographically secured
chain of blocks is described for a first time by Stuart Haber and
W Scott.

In 1998 computer scientist Nick Szabo works on bitgold, a


decentralized digital currency.

In 2009, Satoshi Nakamoto , Implements first blockchain as the


public ledger for transaction made using Bitcoin.
Centralized and Decentralized database
Centralized revolves around us , ex. Such as Facebook, gpay you are
using Centralized system. Other such as youtube are also centralized.

What is centralized?
◦ It means that central authority is in control of the data and
functions. So if you are using Facebook, company facebook has
complete control over the different aspects of their features
including the ability to decide who and who cannot join.
TECHNICAL PERSPECTIVE OF
CENTRAIZED DATABASE
In technical perspective, centralized system requires third
party intermediatery to verify data.

Ex: If you are sending a message to your friend using the


facebook then the data will be verified first and then send
to receiver.
Drawback of Centralized database.
Here everything is stored in a centralized place, it is bound to get
hacked or misused for other purposes.

Ex: Yahoo, in 2015, noticed one of the biggest hacks where group of
hackers was able to view private emails of millions of accounts.

In centralization decision making is given to only to some centralized


people.
Advantages of centralized database.
1. Data Integrity.

2. Data redundancy.

3. Data is more secure.

4. Cheaper .
Decentralized Database
 Decentralized database does not have central owner or a single

authority.

Unlike the centralized database the entire data is spread across

multiple servers. And controlled by several users.


Advantages of Decentralized database
1. Decentralized: This eliminates single point failure.

2. Distributed: data is distributed among several nodes. This ensures that


data can always be accessed even if one or more nodes down.

3. Security: this uses cryptographic technique to give full privacy.

4. Immutability: the data once stored cannot be altered or manipulated.

5. Scalability
1.2 Public Ledgers.
1. A public ledger derives its name from age-old record keeping
system used to record information such as news, Price and
analysis.
2. The Public ledger was available for general public viewing as well
as for verification.
3. It is also known as distributed ledger is a type of database that is
shared, replicated among the members of a decentralized
network.
4. All the information on this ledger is securely and accurately
stored using cryptography.
5. Here every record has a time stamp and unique cryptographic
signature.
1.3 Bitcoin
1. Bitcoin is a crypto currency, a virtual currency designed to act as
money and form of payments outside the control of any one
person, group. Thus removing the need for third party
involvement in financial transactions.

2. Bitcoin was introduced to the public in 2009 by an anonymous


developer or group of developers using the name Satoshi
Nakamoto.
History Of Bitcoin
1. In August 2008, the domain name Bitcoin.org was registered.

2. Today this domain is WhoisGuard protected it means the identity of the


person who registered it is not public information.

3. In October 2008, a person or group Using the name Satoshi Nakamoto


announced the cryptography mailing list. And in 2009 it became public.

4. On Jan 3, 2009, the first Bitcoin block is mined i.e block 0 and name given to
that is Genesis block.
Purpose of Bitcoin
 Bitcoin was created as a way for people to send money over the
internet.

 The digital currency was intended to provide an alternative payment


system that would operate free of central control but otherwise be
used just like traditional currency.
How Bitcoin Works
 Bitcoin can currently be subdivided by seven decimal places. A thousandth of
Bitcoin is known as mili and hundred millionth of Bitcoin is known as a Satoshi.

 A private key is used to prove ownership of fund to the network when making
transaction.

 Person could simply memorise their private key and need nothing else to
retrieve or spend their virtual cash.
Smart Contract
 Smart contracts are computer programs or protocols for automated
transactions that are stored on a blockchain and run in response to meeting
certain conditions.

 smart contracts are self executing contracts.

Using it makes transactions traceable, transparent, and irreversible.

 Is also called digital agreement. And its function as a multi signature


account.so that spending funds only occurs when a required percentage of
people agree.
How Smart Contract work
 Smart contracts work by following simple “if/when…then” statements that are
written into code on a blockchain.

 Computer executes the actions when predefined conditions are met and
verified.

 These actions like releasing funds to the parties, registering a vehicle, sending
notification or issuing ticket.
Benefits of Smart Contract
1. Speed, efficiency and accuracy.

2. Trust and transparency:

3. Security: Blockchain transactions are encrypted, which makes


them very hard to hack.

4. Savings: No third party involvement so cost is reduced.


Application of Smart Contract
1. Vending Machine: Once you drop a coin in and select your option a
predefined automated routine execution results in you getting you a
selected option.

2. Tenant can pay rent using Bitcoin. The smart contract will manage the
settlement process automatically.

3. Supply Chain Management: In 2017 he use of smart contract in supply


chain management. the result has been greatly improved transparency
and ease to track and trace for food products.
Block in Block Chain
1. Blocks are data structures within the blockchain database, where transaction
data are permanently recorded.

2. A block records some or all of the most recent transaction not yet validated
by the network. Once data is validated the block is closed.

3. The new block is created for new transactions to be entered into and
validated.

A block is thus a permanent store of records that, once written cannot be


altered or removed.
What Block contain
1. Version: the crypto currency version being used.

2. Previous block hash or address: contains a hash of the previous blocks


header.

3. Hash Merkle root : Hash of transactions in the Merkle tree of the current
block.

4. Time : A timestamp to place the block in the blockchain.

5. Nounce : The encrypted number that a miner solve to verify the block
and close it.
Transactions
Blockchain technology is mostly about the transactions that
we make digitally for ourselves.
Transaction life cycle in blockchain technology.
◦ This lifecycle allows the journey of single transaction as it makes its way
through each stage in the process of joining blockchain.

◦ Transaction is nothing but is the process of sending money from sender to


receiver.
Distributed Consensus
 A consensus mechanism refers to any number of methodologies used to achieve
agreement, trust, and security across a decentralized computer network.

 It is a fault tolerant mechanism that is used in blockchain.

 In centralized system, we have central authority to verify the data. But in


distributed we have to use consensus mechanism to verify sender and data.
Public vs. Private Blockchain
Public Blockchain
• Public blockchain is one where anyone can join and participate
in the core activities of the blockchain. Anyone can read, write
and audit the ongoing activities.
• Advantages:
• New participants can easily join.
• Disadvantages:
• It needs heavy energy consumption for security.
Private Blockchain
• Participants can join a private blockchain network only through an
invitation where their identity or other required information is authentic
and verified. The validation is done by network operator.
• Advantages:
• It is operated as per organization needs. Only those with permission can
read, write and audit.
• Disadvantages:
• The private block chains are susceptible to data breach and other
security threats. This is because limited number of validators are
present.
Permissioned model of Blockchain
 Permissioned model are hybrid of public and private blockchain.
Permissioned blockchain is a distributed ledger that is not publically
accessible. It can only be accessed by users with permission.
 The users can perform specific actions granted to them by the
ledger administrator.
 In this anyone can access them as long as they have permission
from admin.
Addition permissioned user as an extra blockchain security system.
Understanding Crypto Currency to
Blockchain..
 Cryptocurrency, sometimes called crypto, is any form of currency that exists
digitally and uses cryptography to secure transactions.

 Crytocurrencies don’t have central authority, instead using a decentralized


system to record transactions and issue new units.

 Cryptocurrency that doesn’t rely on banks to verify transactions.

 Crytocurrency received its name because it uses encryption to verify


transactions.
How does Crypto currency works
1. MINING:

•Cryptocurrencies are not controlled by the government or central authorities.

•Cryptocurrencies are generated through a process called “mining” This is the


complex process.

•Basically miners are required to solve certain mathematical puzzles over


specially equipped computer system to be rewarded with bitcoins in exchange.

•In real world it would take a person just 10 minutes to mine one Bitcoin.
2. Buying, Selling and Storing
• Users today can buy Cryptocurrencies from central exchange, brokers and
individual currency owner or sell it to them.

• Exchanges or platforms like coinbase are the easiest ways to buy or sell
Cryptocurrencies.

• Once bought Cryptocurrencies can be stored in digital wallet.

•Digital wallets can be hot or cold. Hot means wallet is connected to


internet. Which makes it easy to transact.

•Cold storage is safer but makes it harder to transact.


Examples of Crypto Currency
Bitcoin: founded in 2009, Bitcoin was the first Cryptocurrency and is still the
most commonly used.

Ethereum: Developed in 2015, it is most popular Cryptocurrency after Bitcoin.

Ripple: Ripple is a distributed ledger system that was founded in 2012. Ripple
can be used to track different kinds of transactions. The company behind it
has worked with various banks and financial institutes.
Overview of Security aspects of
Blockchain
Blockchain technology produces a structure of data with many security
qualities.

It is based on principles of cryptography, decentralization and consensus


which ensures trust in transactions,

All the transactions within a block are validated and agreed upon by the
consensus mechanism, ensuring each transaction is true and correct.
Basic Crypto Primitives: Cryptographic
Hash Function
• A cryptographic hash function is an algorithm that takes an arbitrary
amount of data input and produce a fixed size output of ciphered
text called hash value or just hash.

• A Bitcoin’s blockchain uses SHA-256 hashing algorithm.

• Ethereum uses Keccak-256 to hash information


Properties of a hash function

 Non-reversibility or one –way function: A good hash should make


it very hard to reconstruct the original password from output or
hash.

 Diffusion or avalanche effect : A change in just one bit of the


original password should result in change to half the bits of its hash.
It means when a password is changed slightly the output of
enciphered text should change significantly.

.
Continue….

 Non-Predictable: the hash value should not be predictable from


password.

Determinism: A given password must always generate the same


hash value
Merkle tree
• Merkle tree is a fundamental part of blockchain technology. It is a
mathematical data structure composed of hashes of different block of
data. And which serve as a summary of all the transaction in a block.

• Both Bitcoin and Ethereum use Merkle trees structure.

• Merkle tree also known as hash tree.


Digital Signature
• Digital signing in blockchain technology aims to authenticate
transactions. That means checking if the sender is authorized to
make the transactions.

•The user has to prove to network that he’s authorized to spend his
balance.

•Digital signatures are almost impossible to forge because they are


based on number theory. That is known as public key cryptography.
Public Key Cryptography
In public key cryptography involves a pair of keys known as public key and private
keys, which are associated with an entity that needs to authenticate.

Public key cryptography enable:

1. Encryption and decryption: Which allow two communicating parties disguise data
they send to each other.

2. Non-repudiation: which prevents the data from being altered and the sender of the
data from claiming , at a later date, that the data is never sent.
UNIT 2
BITCOIN AND BLOCKCHAIN
Contents
• Creation of coins, payments and double spending, Bitcoin scripts,
Bitcoin p2p networks, Transaction in Bitcoin network, Block mining,
Block propagation and block delay, Working with consensus in
Bitcoin: Distributed consensus in open environment, consensus in a
Bitcoin network, proof of work(POW)- basic introduction, hash cash
POW, Bitcoin POW, Attack on POW and monopoly problems, Proof
of stake, Proof of burn and proof of elapsed time, the life of Bitcoin
miner, Mining difficulties, mining pool.
Creation of coins
A crypto currency is a digital currency, which uses cryptography for

secure transactions. It is designed to act as a medium of exchange on a

computer network without relying on a central authority such as a

government or a bank to manage it. Since crypto currencies have no

central issuing or regulatory authority, they use a decentralized system

to record transactions and issue new units. Cryptocurrency

uses blockchain technology


How is Cryptocurrency Created?
• The units of crypto currency are created through a process called mining.
Mining is the process of creating new Cryptocurrency by solving puzzles.

• The people involved in the process of mining are known as blockchain


miners.

• Mining is the process of validating crypto currency transactions and


creating new units of crypto currency. The mining process uses powerful
computer hardware and software to solve complex mathematical problems
that generate coins.
Types of crypto currency
• Cryptocurrencies are broadly divided into two groups – coins
and tokens.

• A coin is a crypto currency 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.
S No. Coins Tokens

A new blockchain must be created Tokens can use an existing

1. for the coin. blockchain

An in-depth understanding of how Tokens use open-source


blockchain works and programming skills code and are relatively
2. are required. easier to create.

Due to the creation of a new blockchain, Creating tokens is faster


3. the investment can be significant. and cheaper.
payments and double spending

• Double spending means spending the same money twice. As we know,


any transaction can be processed only in two ways. One is offline, and
another is online.

• Offline: A transaction which involves physical currency or cash is


known as an offline transaction.

• Online: A transaction which involves digital cash is known as an


online transaction.
• In a physical currency, the double-spending problem can never
arise. But in digital cash-like bitcoin, the double-spending
problem can arise. Hence, bitcoin transactions have a possibility
of being copied and rebroadcasted. It opens up the possibility
that the same BTC could be spent twice by its owner.

How Bitcoin handles the Double Spending Problem?

• Bitcoin handles the double-spending problem by implementing


a confirmation mechanism and maintaining a universal ledger
called blockchain.
Bitcoin scripts
• Bitcoin script is the language Bitcoin uses to do everything it
can do , from sending funds from wallet to allowing the
creation of multiuser accounts. Bitcoin script that controls how
bitcoins are spent and transferred.
• Bitcoin Script (also known as Bitcoin Scripting Language or
Script) is a simple, low level, stack-based programming
language that enables the processing of transactions on the
Bitcoin blockchain.
• Bitcoin script consist of opcodes, data and variables that are
pushed and pop from stack. Opcodes are operations such as
arithmetic, logic, hashing and verification. Data are literal
values like public keys, signature that are pushed on to stack.
Variables are placeholders for data.
• to execute Bitcoin script we use library that provide high
level interface and abstraction. Libraries are available for
various programming language such as python, javascript,
ruby and c++.
• Some of the most popular libraries are Bitcoin script
debugger, Bitcore-lib, Bitcoin-ruby and bitcoinj.
• All these libraries are used to create and sign transactions,
parse and create script , access the blockchain.
• There are several online platform and tools that can help,
such as bitcoin script playground, a web based sandbox.
Where you can write run and debug.
P2P Bitcoin networks

• Peer-to-Peer (P2P) technology is based on the decentralization


concept, which lets network participants conduct transactions
without needing any middle-man, intermediaries or central server.

• decentralized peer-to-peer system where each computer keeps a


complete copy of the ledger and verifies its authenticity with other
nodes to guarantee the data is accurate. In contrast, transactions at a
bank are kept secret and are only overseen by the bank.
Bitcoin p2p networks
• Above Fig. is peer 2 peer network. It means each node
having local copy of all blocks.
• Suppose node1’s second block hash value get changed then
automatically all next blocks are shown some error.
• But in this network after some time each node verifies their
block content.

• And depending on majority they finalize the content.


Transaction in Bitcoin network

• What Is a Bitcoin Transaction?

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, software 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.

• 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 . 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. The
transaction is then broadcast to the network to be included in the
blockchain.
Block mining
• 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.
Block propagation or Block relay

• Blocks are the founding pillers of blockchain which stores a set of


information and links to one another to form a chain of information.

• The way Bitcoin works, is that every time a transaction is executed it


needs to be stored in a so called digital container called block and
preserved immutability .
• The lack of scalability is known to be the foremost obstacle standing in the way of
mass adoption of blockchain technology. So to increase scalability we need to
understand block propagation delay.
• Block propagation means after mining sharing block with all nodes.
• Block propagation time is 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.
Distributed consensus in open environment

• Consensus is a process of agreement between distrusting nodes on a final


state of data. In order to achieve consensus different algorithms can be
used. It is Easy to reach an agreement between two nodes (for example in
client-server systems) but when multiple nodes are participating in a
distributed system and they need to agree on a single value it becomes
very difficult to achieve consensus. This concept of achieving consensus
between multiple nodes is known as distributed consensus.
POW(Proof of work)
• The POW algorithm is used to verify the transaction and create a new
block in blockchain.
• The idea of POW was first published in 1993 by Cynthia Dwork.
• Proof of work is competitive process that uses publically available
transaction information to attempt to generate a hexadecimal
number less than the network target for that mining period.
• Under POW consensus thousands of mining programs work on one
block until the hash is solved then move to the next block.
Hash cash 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. Hashcash was proposed in 1997 by Adam Back.
Attacks on POW
1. Sybil attack: In Sybil attack the attacker attempts to fill the network
with the client under its control. When this happen the attacker can
actually control over the network and these client can do different kind
of action based on instruction from attacker.
2. Denial of service attack: in this attack the attacker sends a lot of data
to a particular node so that node will not able to process normal
Bitcoin transaction.
Solution –1. Sybil attack
To prevent Sybil attacks we have to diversify the connections i.e
allowing outbound connection to one IP per / 16 IP address.
• Solution –2. DOS attack.
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
Monopoly problem
• Why monopoly problem existed?
• Miners are getting less rewards over the time. So, they are
discouraged to join as a miner.
• The difficulty of puzzle is increasing which is not possible to be solved
by normal user.
Solution of Monopoly Problem:
• Proof of Stake (POS) emerged as a solution to this problem.
Proof of Stake
• A person can mine or validate block transactions according
to how many coins he or she holds. This means that the
more Bitcoin owned by a miner, the more mining power he
or she has.

• The first crypto currency to adopt the POS method


was Peercoin. In Peercoin, the coin age is used as a variation
of stake.
Proof of Burn

• PoB works on the principle of allowing the miners to “burn” or


“destroy” the virtual currency tokens.

• This algorithm is implemented to avoid the possibility of any coin


double spending.

• This is used to reduce the high energy consumption issue of POW.

• Long term commitment.


Proof of elapsed time
• consensus mechanism that prevent high resource utilization and
energy consumption.
• It keep the process more efficient by using lottery system.
• The algorithm uses randomly generated elapsed time to decide
mining right and block winners on blockchain network.
• POET is developed by Intel.
• POET is similar to POW but consumes less power because it allows
node to sleep and switch to other task for specified time.
Mining Difficulty
• Mining difficulty measures computational power required to validate
Bitcoin transactions and how hard it is to find new blocks and earn
rewards.
• High difficulty means that it will take more computing power to mine
the same number of blocks making the network more secure against
attacks.
• The mining difficulty algorithm is programmed to keep the entire
system stable by maintaining a 10 min duration for finding new
blocks.
Mining Pool
• Here individual miners or users come together and pool their
computational resources in order to improve their chances of mining a
block and share the rewards received among them.

• The mining pool operator manages activities such as recording the work
performed by each pool member, managing their hashes, assigning
reward shares to each member and even the work to be performed by
them individually.

• In return, a mining pool fee is deducted from the rewards distributed to


each member, which is computed based on the pool-sharing mechanism
and depending on how these crypto currency mining pools share rewards.

You might also like