Lecture 1 - Description of Blockchain
Lecture 1 - Description of Blockchain
Lecture 1
Sayed Faheem Qadry
20/03/2022
1
22:37
Origin of the Blockchain
20/03/2022 2
22:37
Electronic Systems and Trust
• Before Blockchain, the idea of cryptocurrency and the systems reliable to
operate that currency was just a dream.
• The internet was required to be distributed, reliable and it was needed to be
used by almost all of the population as it connects the world together digitally.
• When value takes a digital form that is when it is moved from physical items like
coins, notes, metals like gold, silver, platinum etc., to digital, there is a need for
the trust among the people involved in the transactions.
• Trust is never stable in the financial world.
• This is one of the main reasons in the pile of events that lead to the creation of
the mighty digital currency BITCOIN. The Blockchain technology is an effort that
was made to re-establish the long lost trust in digital transactions.
• It is made up of technology to build trust, specifically cryptography which is
used to deal with critical data, to automate and enforce the trust into the
system. 20/03/2022 3
22:37
• Bitcoin was the first working cryptocurrency system that was built using the
Blockchain technology.
Distributed vs Centralized vs Decentralized
Centralized architecture
In the centralized architecture, there are two types of nodes that
participate in the system. The first one is the server or super node and
the second one is the client or user node. The super node is the heart of
the network which stores the data and provides services to the clients
connected to it.
Decentralized architecture
It is distributed to multiple super nodes or servers. Every super node in
the network is connected with at least one another super node. Each
super node contains the same copy of data available and must provide
the same services as other nodes.
Distributed architecture
A distributed system is the same as a decentralized system 20/03/2022
with no 4
central owners. In distributed systems, users have the same level
22:37
of
data access, though user privileges can be restricted if needed.
20/03/2022 5
22:37
What is Blockchain?
20/03/2022 6
22:37
What is Blockchain?
• Blockchain is a transaction record database that is distributed, validated and
maintained around the world by a network of computers. Instead of a single
central authority such as a bank, a large community oversees the records in
Blockchain, and no individual person has control over these records.
• Blockchain is based on decentralized technologies. This functions as a peer-
to-peer (P2P) network.
• Blockchain can be defined as “A peer-to-peer, decentralized, distributed
ledger that records transactions efficiently, and in a verifiable and robust
fashion.”
• Some real-life examples:
Records of sale and purchase of raw material
Bank account statements
Excel sheets tracking hospital equipment 20/03/2022
22:37
7
20/03/2022 8
22:37
Components of blockchain
20/03/2022 9
22:37
How does Blockchain work?
20/03/2022 10
22:37
20/03/2022 11
22:37
Block
Overview
20/03/2022 12
22:37
How blockchain looks like?
20/03/2022 13
22:37
What
makes
Blockchain
different?
20/03/2022 14
22:37
Why is Blockchain a
Distributed, P2P
Network?
20/03/2022 15
22:37
• In a P2P network, there is no central governing authority.
• All nodes in a P2P distributed network are equal to each other.
• Anyone connected to the network is free to share and download
any file shared by other users in the network.
• Peer-to-Peer systems are classified as:
Unstructured - No specific organization of the nodes. Participants
communicate randomly with one another.
Structured - Allows nodes to precisely search for files, even if the content
is not available.
Hybrid - Combines the conventional client-server model with some facets
of the peer-to-peer architecture.
20/03/2022 16
22:37
Types of P2P networks
• 1. Unstructured P2P Networks:
• An unstructured P2P network facilitates the users with an easy connection with other
devices. In this kind of P2P network, all systems play their role, but clients suffer to find
the rare content as there is a lack of structure. The churn rate of such networking is too
high; however, users are still joining and releasing this type of network.
• 2. Structured P2P Network:
• Unlike an unstructured P2P network, the structured network is difficult to set up.
However, this network facilitates the users with efficient access to search the rare
content residing on the network. The churn rate of such kind of networking is minimal.
• 3. Hybrid P2P Network:
• The functionality of a hybrid P2P network is like a client-server network. In this type of
networking, a centralized peer is defined that accomplishes various activities as
servers perform. It retains all information on the connected system and replies to the
requests asking for that specific information. The centralized system has20/03/2022
optimum
22:37
17
knowledge of which resources can be shared and which resources are free.
20/03/2022 18
22:37
Distributed P2P network
• The traditional client-server network keeps all the required information in
one place, which makes it easy to update. But the network is controlled by
a number of administrators with permissions.
• In a distributed P2P network of blockchain architecture, each participant
within the network maintains, approves, and updates new entries.
• The system is controlled by everyone within the blockchain network and
not just by a single authority.
• Each member ensures that all records and procedures are in order, which
results in data validity and security.
• The P2P architecture of blockchains provides benefits of greater security
than traditional client-server based networks as distribution of large
numbers of nodes creates an immune system to the Denial-of-Service
20/03/2022 19
22:37
attack.
Blockchain • A blockchain is a decentralized ledger of all
Vs transactions across a peer-to-peer network,
Cryptocurren whereas cryptocurrency is a medium of
cy exchange, created and stored
electronically in the blockchain.
20/03/2022 20
22:37
Types of Blockchain
20/03/2022 21
22:37
Public Blockchain
• A public blockchain is permissionless. In a public blockchain, anybody
can access the network and read, write or participate without an
explicit authorization and permission.
• A public blockchain is decentralized and has no single network-
controlled entity.
• Data on a public blockchain is protected because data cannot be
changed or manipulated until it has been checked on the blockchain.
• Public blockchain has more complex rules and consensus algorithm
for better security. It is computationally expensive to mine and add a
Block. Here, the computational power is also distributed globally.
• Well-known examples of a public blockchain are Bitcoin and 20/03/2022
Ethereum. 22:37
22
Federated/Consortium Blockchain
• A Consortium or Federated Blockchain is a private, permissioned
blockchain - as opposed to public blockchain – where entities can only
become members of the network by prior approval or voting.
• This kind of blockchain is group-owned system where sole autonomy
is removed. Permissions are vested in a group of companies or
individuals.
• Here, more than one central node is in-charge, that provide access to
pre-selected nodes to read, write, and audit the blockchain. Only
consortium members can make, validate, and review transactions.
• This sort of blockchain is suitable for use between companies that
often have dealings with each other. While these are more secure,
they come at the cost of decentralization. However, this suits
enterprise use cases and business processes.
20/03/2022 23
20/03/2022 24
22:37
Blockchain Architecture
20/03/2022 25
22:37
20/03/2022 26
22:37
Blockchain Architecture
• Enterprise and Legacy Applications: Applications that are
developing or already implemented in the blockchain
solution, and have some extensive features.
• Integration Platforms: Layer with different kinds of
protocols like the SOAP and REST, governance, and API
management.
• Blockchain Access layer: It provides the basic features to
fetch and write data to the blockchain.
• Analytics Layer: It consists of reporting, dashboard or
analytics-based system that provides the analytical result of
the final data.
20/03/2022 27
22:37
Understanding
Tokens
20/03/2022 28
22:37
What are Tokens?
20/03/2022 29
22:37
Significance of Tokens
Tokens are not confined to a particular role; hence they could
address multiple functions within their native ecosystem such as:
• Tokens can be used as entry points for Blockchain applications, and
users will require tokens to use the decentralized applications.
• Individuals' qualifications for possessing specific voting rights
could potentially be represented via tokens.
• Tokens also act as suitable entities for enhancing the holders' user
experience.
• Tokens can be used as a store of value for internal and external
transactions in a certain ecosystem, as well as provide a different
type of monetary system, such as digital assets.
• The exchange of value is another important use of tokens.
20/03/2022
22:37
30
Crypto Tokens
20/03/2022 32
22:37
Fungible Tokens
• These are those types of cryptographic
tokens that are basically identical or
Fungible uniform and can be interchanged with
other fungible tokens of the same type
without any issues. Such tokens relate to
and Non- the things we use every day, and it
applies to real-world assets as well as
Fungible Non-Fungible
digital assets. Tokens
Tokens • Non-fungible tokens are special tokens
that represent unique, collectible items.
They are unique in the sense that they
cannot be split or exactly changed for
other non-fungible tokens of the same
type.
20/03/2022 33
22:37
Fungible Vs. Non-Fungible Tokens
20/03/2022 34
22:37
Ethereum Token Standards
20/03/2022 35
22:37
Merkle Tree and Hashing
20/03/2022 36
22:37
Merkle Tree
• A Merkle tree is a hash-based data structure wherein each leaf
node is a hash of a data block, and each non-leaf node is a hash
of its offspring. Merkle trees usually have a factor of branching 2,
which means that each node has up to 2 children.
• The Merkle trees are used for effective data validation in
distributed systems. They are secure because instead of using
complete files, they use hashes. Hashes are ways to encrypt files
that are slightly smaller than the real file.
• The verification of integrity is substantially reduced despite of
larger data size.
• It requires little disk space or memory as the proofs are
computationally fast and easy.
20/03/2022 37
22:37
20/03/2022 38
22:37
Why Merkle Tree is vital in
Blockchain?
• For confirming a past transaction, a node would need
to reach out to the network in order to get copies of
the ledger from its peers.
• The node would need to compare each entry line by
line.
• Any discrepancy between the ledgers, compromise
the security of the network.
• Every verification request would require large packets
of information to be sent over the network.
• A lot of processing power is consumed to compare the
ledgers, to ensure that there had been no changes.
20/03/2022 39
22:37
Hashing
• Hashing is the process of having an input item of any length,
converting it into an output item of a fixed length.
• Transactions of different lengths are run through a given hashing
algorithm, and all give an output of a fixed length, called as hash.
• Hash size will depend on the hash function used, but the output
using a particular hashing algorithm will be of a specific size.
• Cryptographic hash functions are one of the most important
techniques in the field of cryptography and are used to
accomplish many safety goals such as authentication, digital
signatures, generation of pseudo numbers, digital steganography,
digital time-stamping, etc.
• Commonly used hashing algorithms is Bitcoin’s Secure
20/03/2022 40
Hashing Algorithm 256, often known as SHA-256. 22:37
Blocks, Wallets
and Addresses
20/03/2022 41
22:37
Blocks
20/03/2022 42
22:37
Version Number
• This a 4-byte field which provides the version number used in the block. There a
different block versions that form a part of the history in the development of Bitcoin.
• Version 1 was introduced in the genesis block (January 2009), the very first block
generated on the Bitcoin network’s blockchain.
• Version 2 was introduced in Bitcoin Core 0.7.0 (September 2012) as a User Activated
Soft Fork (UASF). As described in BIP34, valid version 2 blocks require a block height
parameter in the coinbase. BIP34 also describes rules for rejecting certain blocks.
Bitcoin Core 0.7.0 and later versions began to reject version 2 blocks without the block
height in coinbase starting at block height 224,412 (March 2013) and began to reject
new version 1 blocks three weeks later at block height 227,930.
• Version 3 blocks were introduced in Bitcoin Core 0.10.0 (February 2015) as a UASF.
When the fork reached full enforcement (July 2015), it required strict DER encoding of
ECDSA signatures in new blocks as described in BIP66. Transactions that don’t use
strict DER encoding had previously been non-standard since Bitcoin Core 0.8.0
(February 2012).
• Version 4 blocks specified in BIP65 and introduced in Bitcoin Core 0.11.2 (November
20/03/2022
2015) as a UASF became active in December 2015. These blocks now support 22:37 the new
43
high, so the protocol code ensures that the difficulty must be decreased.
Nonce
• The nonce is a 4-byte field that is an arbitrary number of miners
change to modify the header hash in order to produce a hash less
than or equal to the target threshold.
• The nonce is like the “magic number” because whoever discovers it
first will become the block validator. The reward is then put into the
coinbase field and it is given to the miner who discovered the nonce
first. The nonce must be equal or less than the difficulty target.
• Discovering the nonce is the main activity miners engage in during
the consensus mechanism of validating blocks.
• The miners are competing with one another by trying to solve a
cryptographic puzzle that must be below the difficulty target. It was
coded in a protocol to be rather difficult so that not just anyone in a
permissionless system can discover the nonce.
•
20/03/2022
Thus, a difficulty target was specified that adjusts the value based on
47
22:37
• The “bits” is the difficulty target which has been encoded into a numeric value. The lower the
value of the difficulty target, the harder it is to generate a block. The difficulty value has a
hexadecimal form that was converted to 419486617.
• The “mrkl_root” is the hash of all the transactions inside the block. This has been hashed using
the SHA256 algorithm.
• The “nonce” is the discovered value that the miner who validated the block has used. This is the
number used to generate the block that was added to the blockchain.
• The “prev_block” is the hash of the previous block header. This is what links a block to the rest
of the blockchain.
• The “time” is indicated when the miners started hashing on the block. The example uses a
different format for the time, but it is originally the number of seconds based on the Unix epoch
20/03/2022 49
22:37
time.
• The “ver” field is the version number of the block which follows the consensus rules of that
Target
• The target adjusts every 2016 blocks (roughly two weeks) to try and ensure
that blocks are mined once every 10 minutes on average.
• Current (17th Mar 2022) BT target is
0000000000000000000a40c0000000000000000000000000000000000000000
0
• BT target history https://learnmeabitcoin.com/technical/target
• If blocks during this period were being mined faster than every 10 minutes, the
target will adjust downwards to make it more difficult to get below the target
for the next period of blocks.
• If blocks were being mined slower than every 10 minutes, the target will adjust
upwards to make is easier to get below the target for the next period of blocks.
• The target gets stored in the bits field in the block header of every block.
• Each node on the network operates independently, so there is no “single target
value” being sent around the network. However, because all nodes adopt the
20/03/2022
longest chain of blocks as their blockchain, they will each end up calculating
22:37
50
the same target as everyone else, so effectively all nodes end up sharing the
same current target.
Why does bitcoin use a target?
20/03/2022 51
22:37
Blocks
• Every block contains a hash of all the previous block.
• This has the effect of generating a series of blocks from the
genesis block to the present block.
20/03/2022 52
22:37
Wallets
• A blockchain wallet is a software program that enables users to
buy, sell, and monitor balance for their digital currency or assets.
• A wallet stores private and public keys for a user.
• A blockchain wallet allows anyone to quickly share assets.
Transactions, as they are signed cryptographically, are safe.
• The wallet can be accessed from web browsers, even from the
mobile phones, and the user's privacy and identities are
protected.
• A blockchain wallet offers all the features available for safe and
secure transactions and exchanges of funds between various
parties. 20/03/2022 53
22:37
Blockchain Wallet Features
• Simple to use - It's almost like the other app or a wallet that
you use for your everyday purchases.
• Completely secure - Wallet is said to be secure as it keeps
your private key secure.
• Enables instantaneous transfers across geographies -
Transfer of funds do not have any geographical barrier.
• Low Transaction fees - There is a significantly smaller cost of
exchanging funds than the conventional banks.
• Enable multi-cryptocurrency transfers - It makes you do
basic currency conversions.
20/03/2022 54
22:37
Wallet Types
There are two types of wallet used in Blockchain:
• Hot Wallet: Hot wallets are online wallets through which it is easy to
quickly transfer cryptocurrencies. Private keys in the hot wallet are
stored in the cloud for quicker transfer. Hot wallets can be easily
accessible 24/7 online and can be accessed from a laptop or mobile
computer, but if compromised, there is a chance of unrecoverable theft.
• Examples: Coinbase and Blockchain.info
• Cold Wallet: Cold wallets are offline digital wallets where the transfers
are digitally signed and then electronically disclosed. Private keys are
kept in independent hardware that is not connected to internet or the
cloud, but stored on a paper document. The cold wallet transaction
approach helps to shield the wallet from unauthorized entry.
• Examples: Trezor and Ledger 20/03/2022
22:37
55
Hot
Col
20/03/2022 d 56
22:37
Address
20/03/2022 57
22:37
Bitcoin addresses
• P2PKH (Pay to Pubic Key Hash) Legacy Address Format
• P2PKH is one of the oldest bitcoin addresses in the crypto world and is still a legacy bitcoin
address format that has been used in the crypto world. Though it is not segwit compatible, users
can still send bitcoins to other segwit addresses. Transactions with P2PKH is slightly costlier than
other segwit addresses because these addresses are longer and take bigger space. P2PKH
addresses always start with 1 and maybe 26 to 36 characters long.
1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2 is an example of P2PKH address.
• P2SH (Pay to Script Hash) Address Format
• P2SH is newer than P2PKH and starts with 3 unlike 1 in P2PKH. P2SH is slightly complicated than
its older counterpart P2PKH and has several functionalities. Transactions with P2SH are more
elaborate and has high-security features including a multi-signature facility. The 34-character long
address allows multiple digital transactions with multiple addresses and that too at lower fees
compared to P2PKH. For those who want to do non-native segwit transactions, they can use a
feature called P2WPKH-in-P2SH which is quite simple. The 34-character address reduces the risk
of human errors and allows easy transfer of funds.
• Bech32 Segwit Address
• Bech32 is a new bitcoin address and is the most advanced one compared to the other two
addresses. It starts with “bc1” and is longer than P2PKH and P2SH. Bech32 is a segwit address
20/03/2022
and supports multiple wallets and several other addresses and is the most popular address
22:37
that
58 is
used today. Transactions with Bech32 are faster and fees are lower and also reduces the chance
of human error.
How to Get a Bitcoin Address
• To get a Bitcoin address, you first need to download a Bitcoin
wallet, which is software that allows you to securely send,
receive, and store Bitcoin funds in the Bitcoin network.
• Bitcoin wallets also store your private key, which is essentially
your Bitcoin password. The software will generate a brand new
Bitcoin address for you every time you create an invoice or
receive a payment request for Bitcoins too.
• There are four types of Bitcoin wallets that you can use:
mobile, web, desktop, and hardware.
• Most blockchain experts recommend generating a new Bitcoin
address each time you send or receive a payment, though. This
personal security measure makes it harder for people to trace
20/03/2022 59
where your Bitcoin funds come from and where they go. 22:37
What is Cryptography?
• Cryptography is a technique to secure data by writing or
generating codes that make the information unreadable for
the unauthorized individual.
• It is derived from mathematical concepts and a set of rule-
based calculations.
• Cryptographic Algorithms usually involves three things:
Cryptographic Key Generation
Digital Signing
Verification to Protect Privacy
• Modern Cryptography includes Confidentiality, Integrity, Non
Repudiation and Authentication.
20/03/2022 60
22:37
Types of Cryptography
• There are various types of Cryptography:
• Symmetric Key Cryptography: It is an encryption scheme
where a single common key is used by the sender and recipient
of messages to encrypt and decrypt messages. Symmetric Key
Schemes are quicker and easier, but the issue is that in a
secure manner, sender and recipient have to swap key
somehow. The Data Encryption System (DES) is the most
common symmetric key cryptography system.
• Asymmetric Key Cryptography: Under this scheme,
information is encrypted and decrypted using a pair of keys. For
encryption, a public key is used and a private key is used for
decryption. The private key and the public key are unique. Even
if the public key is known by everyone the intended receiver
20/03/2022
22:37
61
can only decode it because he/she alone knows the private key.
Public Key
20/03/2022 64
22:37
SHA-256
• Secure Hash Algorithms (SHA) are a family of cryptographic
functions designed to keep data secure. It operates by using a
hash function to transform the data: an algorithm consisting of
bitwise operations, modular additions, and compression functions.
• A fixed-size string that looks nothing like the original is then
generated by the hash function. These algorithms are designed to
be one-way functions, ensuring that it is nearly difficult to convert
them back into the original data until they are converted into their
respective hash values.
• SHA-1, SHA-2, and SHA-3 are a few algorithms of this type, each of
which was successively built in reaction to hacker assaults with
progressively stronger encryption. Because of the commonly
revealed bugs, SHA-0, for example, is now redundant. 20/03/2022
22:37
65
Transaction Execution
and
Distribution
20/03/2022 66
22:37
Transaction
• A transaction is a new record of exchange of some value or data between
two public addresses of the blockchain .
• Transactions can happen in new node and takes time to get verified when
a new block is created containing that transactions.
• Transactions are data structures that encode the transfer of value between
participants in the bitcoin System.
• The process of transaction verification and recording is immediate and
permanent.
• Transaction is approved through a process known as consensus.
• Although most transactions are organized as address payments (based on
a script called Pay-to-Public-Key-Hash, or P2PKH),
• bitcoin transactions may also use other forms of scripts, besides addresses
and amounts, and contain additional details.
20/03/2022 67
22:37
How Transaction is Committed?
• Stage 1: Initiation of transaction proposal
User signs the transaction.
• Stage 2: Transaction is broadcasted
Transaction is broadcasted in to the network.
• Stage 3: Transaction is verified
Peers receive the transaction and verify it against their records. If
verified, it is added to a block.
• Stage 4: Transaction Commitment.
Block is added to the blockchain.
20/03/2022 68
22:37
Benefits of using
Blockchain
Technology
20/03/2022 69
22:37
No Third-Party Intermediaries
20/03/2022 70
22:37
Greater Transparency
20/03/2022 72
22:37
High Security
20/03/2022 73
22:37
Faster Dealings and Cost Savings
20/03/2022 74
22:37
Improved Traceability
20/03/2022 75
22:37
20/03/2022 76
22:37
What are different
Blockchain Technologies?
20/03/2022 77
22:37
Bitcoin
• Bitcoin is a globally known cryptocurrency and digital payment
system. It was the first decentralized digital currency whose
ledger is maintained by blockchain openly.
• Bitcoin is an implementation of blockchain distributed ledger
technology and the transactions in bitcoin blockchain takes
place directly between users, without an intermediary.
• Bitcoin is an open-source which means nobody owns or regulate
bitcoin but everybody can participates.
• There are no physical Bitcoins, just balances stored on a public
database that everyone has open access to, which is checked by
a vast amount of processing power along with all Bitcoin
transactions.
• Bitcoins are not distributed or funded as an asset by any banks or
20/03/2022
22:37
78
govts.
Ethereum
• Ethereum is also an open source software platform, based on
Blockchain technology that enables developers to build and deploy
decentralized applications. It was initiated by Vitalik Buterin in late
2013.
• It offers Decentralized Virtual Machine aka Ethereum Virtual Machine
(EVM) which can execute scripts using an international network of
public nodes.
• Development for Ethereum was funded by an online public crowdsale
during July-August 2014, by buying the Ethereum value token (Ether).
• It allows us to create and run Smart Contracts and Distributed
Applications (DApps) without any downtime, fraud, control, or
intervention by a third party.
• Ethereum is not just a framework but also a programming language
20/03/2022
running on a blockchain that lets developers create and publish
22:37
79
distributed applications.
Hyperledger
• Hyperledger is a multi-project open source blockchain platform
created to advance cross-industry blockchain technologies.
• It is a global collaboration, hosted by The Linux Foundation,
including leaders in Finance, Banking, Internet of Things, Supply
chains, Manufacturing, and Technology.
• Hyperledger acts as an operating system for marketplaces, data-
sharing networks, micro-currencies, and decentralized digital
communities.
• It has the potential to vastly lessen the expense and complications
in getting things done in the real world.
• It serves as a neutral home for various distributed ledger
frameworks including Hyperledger Fabric, Sawtooth, Indy, as well
as tools like Hyperledger Caliper and libraries like Hyperledger
20/03/2022
22:37
80
Ursa.
Other technologies
• NEO
• EOS
• Corda
• Quorum
• Stellar
20/03/2022 81
22:37
Summary
20/03/2022 82
22:37
How to identify if we need Blockchain