Blockchain Technology Notes
Blockchain Technology Notes
Introduction to Cryptography:
Cryptography is the science of using mathematics to encrypt and decrypt data.
Cryptography enables you to store sensitive information or transmit it across insecure networks
so that it cannot be read by anyone except the intended recipient. The art and science of
concealing the messages to introduce secrecy in information security is recognized as
cryptography. Cryptography is the practice of securing communication from unauthorized
access by converting the original information into a secret code that can only be read by
authorized individuals.
Cryptography is the study of secure communications techniques that allow only the
sender and intended recipient of a message to view its contents. The term is derived from the
Greek word kryptos, which means hidden. As civilizations evolved, human beings got
organized in tribes, groups, and kingdoms. This led to the emergence of ideas such as power,
battles, supremacy, and politics. These ideas further fuelled the natural need of people to
communicate secretly with selective recipient which in turn ensured the continuous evolution
of cryptography as well.
The roots of cryptography are found in Roman and Egyptian civilizations. Ancient
Egyptians were known to use these methods in complex hieroglyphics, and Roman Emperor
Julius Caesar is credited with using one of the first modern ciphers. Some 4000 years ago, the
Egyptians used to communicate by messages written in hieroglyph. Caesar Shift Cipher relies
on shifting the letters of a message by an agreed number (three was a common choice), the
recipient of this message would then shift the letters back by the same number and obtain the
original message. The Caesar cipher is named after Julius Caesar, who used it with a shift of
three to protect messages of military significance.
It involves techniques for secure communication in the presence of third parties, often
referred to as adversaries or attackers. Cryptography uses mathematical algorithms to convert
1
the original message, called plaintext, into an unintelligible form, called ciphertext. Only
individuals who have the knowledge to convert the ciphertext back into plaintext can access
the original message. It is closely associated to encryption, which is the act of scrambling
ordinary text into what's known as ciphertext and then back again upon arrival.
2
• Encryption Key: It is a value that is known to the sender. The sender inputs the
encryption key into the encryption algorithm along with the plaintext in order to
compute the ciphertext.
• Decryption Key: It is a value that is known to the receiver. The decryption key is
related to the encryption key but is not always identical to it. The receiver inputs the
decryption key into the decryption algorithm along with the ciphertext to compute the
plaintext.
• An interceptor (an attacker) is an unauthorized entity who attempts to determine the
plaintext. He can see the ciphertext and may know the decryption algorithm. He,
however, will never know the decryption key.
Features Of Cryptography:
1. Confidentiality: Information can only be accessed by the person for whom it is
intended and no other person except him can access it.
2. Integrity: Information cannot be modified in storage or transition between sender and
intended receiver without any addition to information being detected.
3. Non-repudiation: The creator/sender of information cannot deny his intention to send
information at later stage.
4. Authentication: The identities of sender and receiver are confirmed. As well as
destination/origin of information is confirmed.
Types of Cryptography:
In general, there are three types of cryptography.
1. Symmetric Key Cryptography
2. Asymmetric Key Cryptography
3. Hash Functions
1. Symmetric Key Cryptography: It is a process to change the form of any message to
protect it from reading by anyone. In Symmetric-key encryption the message is
encrypted by using a key and the same key is used to decrypt the message which makes
it easy to use but less secure. It also requires a safe method to transfer the key from one
party to another. Such an approach of encoding data has been largely used to facilitate
secret communication between governments and militaries. With this form of
cryptography, the key should be known to both the sender and the receiver. The
complexity with this approach is the distribution of the key.
3
Examples of symmetric-key algorithms: Advanced Encryption Standard (AES) and
Data Encryption Standard (DES), Triple Data Encryption Standard (Triple DES),
International Data Encryption Algorithm (IDEA).
2. Asymmetric Key Cryptography: It uses a pair of keys for the encryption and
decryption of the data – the keys are known as the public key and private key,
respectively. The private key is kept a secret with the owner and is used to decrypt the
data encrypted with the public key made available to everyone in the public domain.
Another use of this type of algorithm is for user authentication where the data encrypted
with the private key can be decrypted with the public key to verify the fact that only the
owner of the private key can encrypt the data. Since this type of algorithm doesn’t rely
on a single key for security, it overcomes the limitation of the symmetric key algorithms
and is used for information exchange on the internet as a part of various information
exchange protocols. One of the major limitations of these algorithms as compared to
symmetric algorithms is that they are computationally expensive hence using them
frequently within a process is not easy.
4
Examples of Asymmetric-key algorithms: Rivest Shamir Adleman (RSA), Digital Signature
Standard (DSS), Digital Signature Algorithm (DSA), Elliptical Curve Cryptography (ECC),
Diffie-Hellman exchange method.
The size of cipher text is the same or The size of cipher text is the same or
smaller than the original plain text. larger than the original plain text.
It provides confidentiality,
It only provides confidentiality. authenticity, and non-repudiation.
The length of key used is 128 or 256 The length of key used is 2048 or
bits higher
Security is less as only one key is It is more secure as two keys are
used for both encryption and used here- one for encryption and
decryption purpose. the other for decryption.
5
Symmetric Key Encryption Asymmetric Key Encryption
3. Hash Functions: A cryptographic hash function is a hash function that takes an arbitrary block
of data and returns a fixed-size bit string, the cryptographic hash value, such that any
(accidental or intentional) change to the data will (with very high probability) change the hash
value. The data to be encoded are often called the message, and the hash value is sometimes
called the message digest or simply digest.
7
ensuring the security of participants, transactions, and safeguards against double-
spending. It helps in securing different transactions on the blockchain network. It
ensures that only the individuals for whom the transaction data is intended can obtain,
read and process the transaction. Cryptography plays a crucial role in blockchain
technology by ensuring the security, integrity, and privacy of transactions and data.
Some of the key cryptographic techniques used in blockchain include:
• Hash functions: Hash functions are used to convert the data in a block into a fixed-
length digital fingerprint or hash. This ensures the integrity of the data as even a small
change in the data results in a completely different hash. A hash function is a
mathematical function that takes in an input (or 'message') of arbitrary length and
produces a fixed-size output. Message authentication: Hash functions are used to
verify the integrity of messages or data, ensuring that they have not been tampered with
or modified. Digital signatures: Hash functions are used in digital signature schemes
to provide a unique identifier for a message or document. Password storage: Hash
functions are often used to store passwords securely, so that the original password is
not stored in plain text and is not easily recoverable. Data indexing: Hash functions
are used in databases and search engines to quickly locate data based on its hash value.
Encryption: Hash functions can also be used in encryption algorithms to create a
unique encryption key based on the hash of a given input.
• Public key cryptography: Public key cryptography is used to authenticate and encrypt
transactions. In blockchain, each user has a public and private key. The public key is
used to encrypt the transaction, while the private key is used to decrypt it. This ensures
that only the intended recipient can read the transaction.
8
• Digital signatures: Digital signatures are used to verify the authenticity of transactions.
In blockchain, each user signs their transactions with their private key, which is then
verified using their public key. A digital signature is a mathematical scheme for
verifying the authenticity and integrity of digital documents or messages. It is a way of
providing assurance that a document or message has not been altered or tampered with
since it was digitally signed by the sender. Digital signatures work by using
cryptographic algorithms to create a unique digital signature that can only be generated
by the sender of the document. This signature is created by combining the document's
content with the sender's private key, which is kept secret and known only to the sender.
To verify the authenticity of a digital signature, the recipient of the document or
message can use the sender's public key to decrypt the signature and compare it with a
newly generated signature created from the same content. If the two signatures match,
it provides assurance that the document or message has not been tampered with since it
was digitally signed. Digital signatures are widely used in electronic transactions, such
as online banking and e-commerce, to provide a secure and reliable way to authenticate
the identity of the sender and ensure the integrity of the transmitted data. They are also
commonly used in government and legal contexts, where the authenticity and integrity
of documents are of utmost importance.
9
• Merkle trees: Merkle trees are used to verify the integrity of data in a block. Each
block contains a Merkle tree, which is a hierarchical data structure that summarizes all
the transactions in the block. This allows for efficient and secure verification of the
data. Merkle trees, also known as hash trees, are a data structure used to efficiently
verify the integrity and consistency of large amounts of data. They were invented by
Ralph Merkle in 1979. Merkle trees are built by recursively hashing pairs of data until
a single hash value, called the root hash, is produced. Each level of the tree contains
hash values of the data below it. The leaves of the tree are the original data items. One
of the key properties of Merkle trees is that changing any piece of data in the tree results
in a different root hash value. This property allows for the efficient detection of any
changes or errors in the data. Merkle trees are commonly used in distributed systems,
such as blockchain, to ensure the integrity of data stored across multiple nodes. In a
blockchain, each block contains a Merkle tree of the transactions included in that block,
and the root hash of the tree is included in the block header. This allows nodes to quickly
verify that the transactions in a block have not been tampered with by checking the root
hash against the block header.
10
• Public-key or asymmetric cryptography: In public key cryptography (PKI), also
known as asymmetric cryptography, there are two related keys called the public and
private key. While the public key may be freely distributed, the paired private key must
remain confidential. The public key is used for encryption and the private key is used
for decryption. The most used asymmetric cryptography algorithms are RSA and ECC.
TLS/SSL certificates frequently use RSA keys, and the recommended size of these keys
is continually increasing (e.g.,1024 bit to 2048 bit) to maintain sufficient cryptographic
strength. An alternative to RSA is ECC, which can offer the same level of cryptographic
strength at much smaller key sizes, offering improved security with reduced
computational and storage requirements.
• Hash-function: No key is used in this algorithm, but a fixed-length value is calculated
from the plaintext, which makes it impossible for the contents of the plaintext to be
recovered. Hash functions are often used by computer systems to encrypt passwords. A
popular hash algorithm is 256-SHA.
11
and a secret key to scramble the original message, making it unreadable to anyone who
doesn't have the key.
• Decryption: Decryption is the process of transforming ciphertext back into plaintext
using the same cryptographic algorithm and secret key that were used for encryption.
Only those who have the key can decrypt the message.
• Hashing: Hashing is the process of taking an input and generating a fixed-size output,
called a hash. A hash function should be one-way, meaning that it is practically
impossible to recover the original input from the hash.
• Digital signatures: A digital signature is a mathematical technique used to verify the
authenticity and integrity of a message or document. It involves using a private key to
create a unique digital signature, which can then be verified using the corresponding
public key.
• Key management: Key management involves generating, storing, distributing, and
revoking cryptographic keys. Secure key management is critical to the security of
cryptographic systems.
• Random number generation: Random numbers are often used in cryptography to
provide a source of unpredictability. A good random number generator should be
unpredictable and unbiased.
Cryptocurrency and its Benefits: Cryptocurrency is a digital or virtual currency that uses
cryptography for security and operates independently of a central bank. Cryptocurrencies use
decentralized technology, such as blockchain, to enable peer-to-peer transactions and to create
a secure and transparent way to transfer funds without the need for a middleman or
intermediary. cryptocurrencies became a worldwide phenomenon during the talk that they are
visiting to replace general currencies within the near future. Cryptocurrencies adoption
continues to understand momentum partially due to the world’s progression towards a cashless
society. The fact that some people, nowadays, transact through electronic money continues to
affirm suggestions that cryptocurrencies could be the currencies of the long term. However, it
will take it slow before they find their way into the mainstream sector, given the strong
opposition from regulators worldwide. Cryptocurrencies have gained popularity as a
speculative investment, as well as a means of payment for goods and services in some cases.
However, the lack of regulation and the potential for volatility have also raised concerns among
some investors and regulators. Some of the most popular cryptocurrencies include Bitcoin,
Ethereum, and Litecoin etc…
12
Benefits of Cryptocurrency:
13
Parameters Centralized Distributed Decentralized
Network/hardware Maintained & Spread across multiple Resources are owned &
resources controlled by single data centres & shared by network
entity in a geographies; owned by members; difficult to
centralized location network provider maintain since no one
owns it
Solution Maintained & Maintained & Each member has exact
components controlled by controlled by solution same copy of distributed
central entity provider ledger
Data Maintained & Typically owned & Only added through
controlled by managed by customer group consensus
central entity
Control Controlled by Typically, a shared No one owns the data &
central entity responsibility between everyone owns the data
network provider,
solution provider &
customer
Single Point of Yes No No
Failure
Fault tolerance Low High Extremely high
Security Maintained & Typically, a shared Increases as # of
controlled by responsibility between network members
central entity network provider, increase
solution provider &
customer
Performance Maintained & Increases as Decreases as # of
controlled by network/hardware network members
central entity resources scale up and increase
out
Example ERP system Cloud computing Blockchain
14
Decentralized systems are designed to distribute computing power and data storage
across a network of nodes or computers, thereby eliminating the need for a central authority.
This design has many benefits, such as increased scalability, improved fault tolerance, and
enhanced security. However, decentralized systems also present unique security, integrity, and
privacy challenges that must be addressed to ensure the reliability and trustworthiness of the
system.
1. Security Issues:
a. Sybil attacks: Attackers can create multiple identities or nodes to take control
of the network.
b. Distributed Denial of Service (DDoS) attacks: Attackers can flood the
network with fake traffic or requests, making it difficult for legitimate users to
access the system.
c. 51% attacks: If an attacker controls more than 50% of the network's computing
power, they can modify or reverse transactions and disrupt the system's
operation.
d. Smart contract vulnerabilities: Decentralized systems rely on smart contracts,
which are code executed on the blockchain. If there are vulnerabilities in the
smart contract code, attackers can exploit them to steal funds or cause other
damage.
e. Malicious code execution: Decentralized systems are vulnerable to malware
and malicious code that can compromise the integrity of the system.
2. Integrity Issues:
a. Double Spending: Decentralized systems must ensure that users cannot spend
the same asset twice.
b. Timestamp tampering: Attackers can manipulate the timestamp on
transactions to change their order or perform fraudulent activities.
c. Forking attacks: If the network splits into two or more versions, attackers can
manipulate transactions and block confirmations.
3. Privacy Issues:
a. Public Ledger: Decentralized systems rely on a public ledger or blockchain,
which makes all transactions publicly visible. While the user's identity is
hidden, it is still possible to track their transactions and infer information about
their behaviour.
15
b. Pseudonymous Identities: While user identities are not directly linked to their
real-world identities, attackers can use statistical analysis and other techniques
to infer users' identities.
c. Data Leakage: Decentralized systems rely on a distributed network of nodes to
store and process data. If one of these nodes is compromised, sensitive data can
be leaked.
To mitigate these security, integrity, and privacy challenges, decentralized systems can
use cryptographic techniques such as encryption, digital signatures, and multi-factor
authentication. Additionally, implementing robust governance frameworks and consensus
mechanisms can help ensure the reliability and trustworthiness of the network.
***************
16
Unit II: Introduction to Blockchain Technology
What is Bitcoin?
A blockchain is a distributed ledger with growing lists of records (blocks) that are
securely linked together via cryptographic hashes. Each block contains a cryptographic hash
of the previous block, a timestamp, and transaction data (generally represented as a Merkle
tree, where data nodes are represented by leaves). Since each block contains information about
the previous block, they effectively form a chain (compare linked list data structure), with each
additional block linking to the ones before it. Consequently, blockchain transactions are
irreversible in that, once they are recorded, the data in any given block cannot be altered
retroactively without altering all subsequent blocks.
Blockchains are typically managed by a peer-to-peer (P2P) computer network for use
as a public distributed ledger, where nodes collectively adhere to a consensus algorithm
protocol to add and validate new transaction blocks. Although blockchain records are not
unalterable, since blockchain forks are possible, blockchains may be considered secure by
design and exemplify a distributed computing system with high fault tolerance. A blockchain
was created by a person (or group of people) using the name (or pseudonym) Satoshi Nakamoto
in 2008 to serve as the public distributed ledger for bitcoin cryptocurrency transactions, based
on previous work by Stuart Haber, W. Scott Stornetta, and Dave Bayer.
The implementation of the blockchain within bitcoin made it the first digital currency
to solve the double-spending problem without the need of a trusted authority or central server.
The bitcoin design has inspired other applications and blockchains that are readable by the
public and are widely used by cryptocurrencies. The blockchain may be considered a type of
payment rail. Private blockchains have been proposed for business use. The blockchain is
essentially a decentralized database or ledger that stores and verifies transactions. Each block
in the chain contains a number of transactions and is linked to the previous block through a
cryptographic hash function, creating a chain of blocks that can't be altered without affecting
the entire network.
The use of cryptographic hashing ensures the security of the blockchain network. The
information in a block cannot be altered without changing the hash of the block, which would
be immediately detected by the network. Additionally, the decentralized nature of the
blockchain means that there is no central authority controlling the network, which makes it
very difficult for any one entity to manipulate or corrupt the data. The potential uses of
blockchain technology go beyond cryptocurrency and include areas such as supply chain
management, voting systems, healthcare, and more. Its secure and transparent nature has made
it a popular choice for industries looking to increase trust and efficiency in their operations.
History of Blockchain:
1991: In 1991, researcher scientists named Stuart Haber and W. Scott Stornetta introduce
Blockchain Technology. These scientists wanted some Computational practical Solution for
time-stamping the digital documents so that they couldn’t be tempered or misdated. So both
scientists together developed a system with the help of Cryptography. In this System, the time-
stamped documents are stored in a Chain of Blocks.
1992: After that in 1992, Merkle Trees formed a legal corporation by using a system developed
by Stuart Haber and W. Scott Stornetta with some more features. Hence, Blockchain
Technology became efficient to store several documents to be collected into one block. Merkle
used a Secured Chain of Blocks that stores multiple data records in a sequence. However, this
technology became unused when the Patent came into existence in 2004.
2000: In the year 2000, Stefan Konst published his theory of cryptographic secured chains,
plus ideas for implementation.
2004: In the year 2004, Cryptographic activist Hal Finney introduced a system for digital cash
known as “Reusable Proof of Work”. This step was the game-changer in the history of
Blockchain and Cryptography. This System helps others to solve the Double Spending Problem
by keeping the ownership of tokens registered on a trusted server.
2008: After that 2008, Satoshi Nakamoto conceptualized the concept of “Distributed
Blockchain” in his white paper:” A Peer-to-Peer Electronic Cash System”. He modified the
model of Merkle Tree and created a system that is more secure and contains the secure history
of data exchange. His System follows a peer-to-peer network of time stamping. His system
became so useful that Blockchain become the backbone of Cryptography.
2009: After that, the evolution of Blockchain is steady and promising and became a need in
various fields. In 2009, Satoshi Nakamoto Releases Bitcoin White Paper. Blockchain
technology is so secure that the following surprising news will give proof of that. A person
named, James Howells was an IT worker in the United Kingdom, he starts mining bitcoins
which are part of Blockchain in 2009 and stopped this in 2013. He spends $17,000 on it and
after he stopped, he sells the parts of his laptop on eBay and keep the drive with him so that
when he needs to work again on bitcoin, he will utilize it but while cleaning his house in 2013,
he thrashed his drive with garbage and now his bitcoins cost nearly $127 million. This money
now remains unclaimed in the Bitcoin system.
2014: The year 2014 is marked as the turning point for blockchain technology. Blockchain
technology is separated from the currency and Blockchain 2.0 is born. Financial institutions
and other industries started shifting their focus from digital currency to the development of
blockchain technologies.
2015: In 2015, Ethereum Frontier Network was launched, thus enabling developers to write
smart contracts and dApps that could be deployed to a live network. In the same year, the Linux
Foundation launched the Hyperledger project.
2016: The word Blockchain is accepted as a single word instead of two different concepts as
they were in Nakamoto’s original paper. The same year, a bug in the Ethereum DAO code was
exploited resulting in a hard fork of the Ethereum Network. The Bitfinex bitcoin exchange was
hacked resulting in 120,000 bitcoins being stolen.
2017: In the year 2017, Japan recognized Bitcoin as a legal currency. Block.one company
introduced the EOS blockchain operating system which was designed to support commercial
decentralized applications.
2018: Bitcoin turned 10 in the year 2018. The bitcoin value continued to drop, reaching the
value of $3,800 at the end of the year. Online platforms like Google, Twitter, and Facebook
banned the advertising of cryptocurrencies.
2019: In the year 2019, Ethereum network transactions exceeded 1 million per day. Amazon
announced the general availability of the Amazon Managed Blockchain service on AWS.
2020: Stablecoins were in demand as they promised more stability than traditional
cryptocurrencies. The same year Ethereum launched Beacon Chain in preparation for Ethereum
2.0.
2022: Ethereum has shifted from Proof of Work (PoW) to Proof of Stake (PoS) consensus
mechanism. The original Ethereum mainnet merged with Beacon Chain which has Proof-of-
Stake. Now it is existing as one chain. Ethereum’s energy consumption has reduced by
~99.95%.