Cryptography & Blockchain Basics
Cryptography & Blockchain Basics
UNIT-I
Cryptography:
Cryptography is the practice and study of techniques for securing communication and information from adversaries.
It involves creating and analyzing protocols that prevent third parties or the public from reading private messages.
Cryptography plays a crucial role in ensuring data confidentiality, integrity, authentication, and non-repudiation.
1. Encryption: The process of converting plaintext (readable data) into ciphertext (unreadable data) using
algorithms and keys. Only those with the corresponding decryption key can revert the ciphertext to its original
form.
2. Decryption: The reverse process of encryption, turning ciphertext back into plaintext using the appropriate
decryption key.
3. Public Key Infrastructure (PKI): A system that uses pairs of public and private keys to facilitate secure
communication. The public key is shared openly, while the private key is kept secret.
4. Digital Signatures: A cryptographic technique that verifies the origin and integrity of a message or
document. It involves using a private key to create a digital signature, which can be verified using the
corresponding public key.
5. Hash Functions: Algorithms that produce a fixed-size string of characters (hash value) from input data of
any size. Hash functions are commonly used to verify data integrity.
Blockchain:
Blockchain is a decentralized and distributed ledger technology that underlies cryptocurrencies like Bitcoin. It is
designed to provide a secure and transparent way of recording transactions across multiple parties without the need
for a central authority.
1. Decentralization: Instead of relying on a central authority, blockchain uses a network of nodes to validate
and record transactions. This decentralization enhances security and reduces the risk of a single point of
failure.
2. Consensus Mechanisms: To agree on the state of the ledger, blockchain networks use consensus algorithms.
Popular mechanisms include Proof of Work (used by Bitcoin) and Proof of Stake. These ensure that all nodes
in the network come to a common agreement.
3. Blocks and Chains: Transactions are grouped into blocks, and each block is linked to the previous one using
cryptographic hashes, forming a chain. This ensures the integrity of the entire transaction history.
4. Smart Contracts: Self-executing contracts with the terms of the agreement directly written into code. Smart
contracts automatically execute and enforce the terms when predefined conditions are met.
5. Immutability: Once a block is added to the blockchain, it is extremely difficult to alter. This immutability
enhances the security and trustworthiness of the data stored on the blockchain.
UNIT-I
• Cryptography is a broader concept focused on securing communication and data. It involves the
use of mathematical algorithms and keys to protect information, ensuring confidentiality, integrity,
authentication, and non-repudiation. Cryptography is a tool or set of techniques used to achieve
secure communication and data protection.
• Blockchain, on the other hand, is a specific technology and infrastructure for recording and
verifying transactions in a decentralized and tamper-resistant manner. While it utilizes cryptographic
techniques (such as hashing and digital signatures) for security, its primary purpose is to establish
trust in a distributed network without the need for a central authority.
2. Scope:
• Cryptography is a broader field that encompasses various techniques and methods to secure
information. It can be applied in various contexts, such as securing messages, encrypting data, and
creating digital signatures.
• Cryptography can be applied in centralized systems where a central authority manages keys and
security measures. It is not inherently decentralized.
• Blockchain is designed to be decentralized. It eliminates the need for a central authority to validate
and record transactions, relying on a network of nodes and consensus mechanisms to achieve trust
and security.
4. Use Cases:
• Blockchain is often associated with cryptocurrencies, such as Bitcoin and Ethereum. However, its
applications extend to various industries, including supply chain management, healthcare, finance,
and voting systems, where the goal is to create transparent and tamper-resistant ledgers.
Blockchain Technology
The primary objective of blockchain technology is to provide a decentralized, secure, transparent, and immutable
system for recording and verifying transactions and data.
Consider a digital ledger, like an online spreadsheet, that records transactions. Instead of being stored on a single
computer or server, this ledger is duplicated across a network of computers, called nodes.
UNIT-I
1. Decentralization: This network of computers forms a decentralized system. No single entity controls the
entire network or the data stored within it. Instead, every participant (or node) in the network has a copy of
the ledger.
2. Blocks and Chains: The ledger is divided into blocks, each containing a list of transactions. Once a block is
filled with transactions, it is added to the existing chain of blocks, forming a chronological sequence of
transactions, hence the term "blockchain".
3. Consensus Mechanisms: To ensure the integrity and security of the blockchain, a consensus mechanism is
employed. This mechanism determines how agreements are reached among the nodes regarding the validity
of transactions and the addition of new blocks to the chain. Examples of consensus mechanisms include Proof
of Work (PoW), Proof of Stake (PoS), and Delegated Proof of Stake (DPoS).
4. Immutability: Once a block is added to the blockchain, it becomes virtually impossible to alter its contents.
Each block contains a cryptographic hash of the previous block, creating a link between them. Any attempt
to modify a block would require altering all subsequent blocks in the chain, which is computationally
infeasible and would require the consensus of the majority of nodes in the network.
5. Transparency: The blockchain ledger is transparent and publicly accessible. Anyone with access to the
internet can view the entire transaction history recorded on the blockchain. This transparency fosters trust
among participants and enables accountability.
6. Security: Blockchain technology employs cryptographic techniques to secure transactions and ensure data
integrity. Each participant in the network has a unique cryptographic identity, and transactions are
authenticated using digital signatures.
7. Applications: Blockchain technology has a wide range of applications beyond cryptocurrencies like Bitcoin.
It can be used for decentralized finance (DeFi), supply chain management, voting systems, identity
verification, smart contracts, and more. Essentially, any scenario that requires secure, transparent, and
tamper-resistant record-keeping can potentially benefit from blockchain technology.
Blockchain Origins
The origins of blockchain trace back to a combination of various technologies, ideas, and developments.
1. Cryptography:
The foundation of blockchain technology lies in cryptography, particularly cryptographic techniques like
hash functions and digital signatures. Hash functions create unique, fixed-size outputs (hashes) for input data,
ensuring data integrity and tamper resistance. Digital signatures provide cryptographic proof of the
authenticity and integrity of digital messages.
2. Distributed Systems:
The concept of distributed systems, where multiple independent entities collaborate to achieve a common
goal without a central authority, is fundamental to blockchain. Early distributed systems, such as peer-to-peer
(P2P) networks and file-sharing protocols, laid the groundwork for decentralized data storage and
communication.
3. Cypherpunk Movement:
The cypherpunk movement, which emerged in the late 1980s and 1990s, advocated for the use of
cryptography and privacy-enhancing technologies to protect individual freedoms and privacy in the digital
UNIT-I
age. Cypherpunks envisioned decentralized systems that would empower individuals and circumvent
centralized control and surveillance.
Several digital currency experiments preceded Bitcoin and influenced the development of blockchain
technology. Notable examples include DigiCash, created by cryptographer David Chaum in the early 1990s,
and b-money and Bit Gold, proposed by Wei Dai and Nick Szabo, respectively, in the late 1990s and early
2000s. These experiments explored concepts like digital cash and decentralized consensus mechanisms.
5. Bitcoin Whitepaper:
The pivotal moment in blockchain history came with the release of the Bitcoin whitepaper titled "Bitcoin: A
Peer-to-Peer Electronic Cash System" by an individual or group using the pseudonym Satoshi Nakamoto in
2008. Bitcoin introduced the concept of a decentralized, peer-to-peer electronic cash system built on
blockchain technology, combining cryptographic techniques, distributed consensus, and game theory to
enable secure and trustless transactions.
6. Genesis Block:
On January 3, 2009, Satoshi Nakamoto mined the first block, known as the "genesis block," of the Bitcoin
blockchain, marking the official launch of the Bitcoin network. The genesis block included a headline from
The Times newspaper referencing the financial crisis, symbolizing Bitcoin's mission to provide an alternative
to traditional financial systems.
Following Bitcoin's inception, blockchain technology has evolved and diversified rapidly. Numerous
alternative cryptocurrencies (altcoins) and blockchain platforms have emerged, each with its unique features,
consensus mechanisms, and use cases. Additionally, blockchain technology has extended beyond digital
currencies to encompass applications in various industries, including finance, supply chain management,
healthcare, and decentralized finance (DeFi).
Thus, blockchain's origins are rooted in a convergence of cryptography, distributed systems, and digital currency
experiments, catalyzed by the release of the Bitcoin whitepaper and the subsequent launch of the Bitcoin network.
Since then, blockchain technology has continued to evolve, driving innovation and disruption across multiple sectors.
Blockchain Challenges
While blockchain technology offers numerous benefits, it also faces several challenges that need to be addressed for
widespread adoption and scalability. Some key challenges are:
1. Scalability:
• One of the significant challenges facing blockchain is scalability. As the number of transactions
increases, public blockchains may experience congestion, slower transaction times, and higher fees.
Scalability solutions, such as sharding, layer 2 protocols, and consensus algorithm improvements,
are being developed to address this challenge.
2. Interoperability:
• Interoperability refers to the ability of different blockchain networks to communicate and interact
with each other seamlessly. Currently, most blockchains operate in isolation, hindering the transfer
UNIT-I
of assets and data between different platforms. Interoperability standards and protocols are needed
to facilitate seamless communication between disparate blockchain networks.
3. Privacy:
• While blockchain offers transparency and immutability, it also raises concerns about privacy,
particularly for sensitive or confidential data. Public blockchains store all transaction data on a
transparent ledger, posing challenges for industries that require privacy protections, such as
healthcare and finance. Privacy-enhancing technologies, such as zero-knowledge proofs and secure
multi-party computation, aim to address these concerns.
4. Regulatory Uncertainty:
• The regulatory landscape surrounding blockchain and cryptocurrencies varies significantly across
jurisdictions, leading to uncertainty and compliance challenges for businesses and users. Regulatory
clarity and harmonization are essential to foster innovation while addressing concerns related to
consumer protection, money laundering, and financial stability.
5. Energy Consumption:
• Proof of Work (PoW) consensus mechanisms, used by popular blockchains like Bitcoin and
Ethereum, require substantial computational power and energy consumption for mining activities.
This energy-intensive process has raised environmental concerns and criticism regarding the
sustainability of blockchain networks. Transitioning to more energy-efficient consensus
mechanisms, such as Proof of Stake (PoS), can mitigate these environmental impacts.
• Blockchain technology often suffers from a steep learning curve and complex user interfaces,
hindering mainstream adoption. Improving user experience through intuitive interfaces, education,
and user-friendly applications is crucial for driving widespread adoption of blockchain technology.
7. Security Risks:
• Despite its robust cryptographic security features, blockchain is not immune to security risks, such
as 51% attacks, smart contract vulnerabilities, and governance issues. Ensuring the security and
integrity of blockchain networks require constant vigilance, robust security protocols, and ongoing
auditing and testing.
In the context of technology or systems, a mechanism refers to a method or process designed to achieve a particular
outcome or function. Mechanisms can be found in various domains, including computing, engineering, biology, and
social sciences.
• Examples of Mechanisms:
UNIT-I
• Encryption Mechanisms: Encryption mechanisms are used to secure data by converting it into a
form that can only be read or understood by authorized parties. This ensures confidentiality and
privacy. Examples include symmetric-key encryption and asymmetric-key encryption.
• Routing Mechanisms: In networking, routing mechanisms determine the paths that data packets
take to reach their destinations. This includes algorithms and protocols used to manage traffic on
networks.
• Error Correction Mechanisms: Error correction mechanisms detect and correct errors that may
occur during data transmission or storage. This is crucial for ensuring data integrity and reliability.
• Fault Tolerance Mechanisms: These mechanisms ensure that a system can continue operating
properly even in the presence of faults or failures. Redundancy, error detection, and error correction
techniques are examples of fault tolerance mechanisms.
• Load Balancing Mechanisms: Load balancing mechanisms distribute workloads across multiple
resources (such as servers or processors) to ensure optimal performance, resource utilization, and
scalability. Examples include round-robin scheduling and dynamic load balancing algorithms.
• Access Control Mechanisms: Access control mechanisms regulate access to resources or services
based on predefined policies or permissions. This includes mechanisms like access control lists
(ACLs), role-based access control (RBAC), and attribute-based access control (ABAC).
• Smart Contracts: Smart contracts are self-executing contracts with terms directly written into code.
Once deployed on a blockchain, smart contracts automatically enforce and execute the terms of the
agreement when predefined conditions are met. Smart contracts enable decentralized applications
(DApps) to run on blockchain networks, automating processes and reducing the need for
intermediaries.
• Cryptographic Hash Functions: Cryptographic hash functions are secure algorithms that take an
input (or message) and produce a fixed-size output (hash) of a predetermined length. These functions
are integral to blockchain technology for ensuring data integrity, creating digital signatures, and
linking blocks in a blockchain. Common hash functions include SHA-256 and Keccak-256, which
are widely used in blockchain networks like Bitcoin and Ethereum.
Blockchain Networks:
Blockchain network broadly are classified into 4 types and they are:
1. Public Blockchain: Public Blockchain network is accessible to the public without any limitations of
validation and participants. As it does not have any central authority an individual is unable to manipulate
the network tha stores unchangeable data. They are sourced by crypto economics which includes economic
UNIT-I
incentives and cryptographic verification using mechanisms such as Bitcoin and Ethereum. They are
considered to be ‘fully decentralized.
Advantages
• Public Blockchain provides protection to applications from developers, as there are certain things that have
no access to the developers as well.
2. Private Blockchain: It is a restrictive network; only authorized people have access to it. The authorizers
have the power to choose entities and blockchain developers and they are granted permission during the
development phase. After the launch of the network, the whole sole responsibility lies with the administrator
to allow new access or revoke existing users. Private companies use it in order to store sensitive data.
Advantages
• The company running can easily change the rules of the blockchain, modify banners, and revert transactions.
• Validators are known beforehand only thus the risk of minor collusion does not apply.
3. Consortium Blockchain: It is a process where the consensus process is controlled by a pre- selected set of
nodes.a semi- decentralised network where multiple entities operate. Under this network several entities have
a network to view and share information. Banks, large organisations, and government institutes use
consortium blockchain to carry out daily transactions.
Advantages
• Replaces legacy systems, simplifying document handling and getting rid of semi manual compliance
mechanisms.
4. Hybrid Blockchain: It is a network that possesses properties of both private and public blockchain networks.
It provides versatile nodes wherein the individual can set preferences to share or discrete data. The
architecture can be differentiated by the fact that they are not open to everyone but still offers blockchain
facilities like integrity, privacy, transparency and security.
Advantages
• Hybrid blockchain is flexible in nature, in a way that one can alter the level of transparency, decentralization
and security requirements
Blockchain technology is like a light in the dark in the healthcare section of the society. It can be used to fill the gaps
in the existing systems that further leads to thefts, sharing of unwanted information and corruption. Some of the major
impacts on the Healthcare sector are:
UNIT-I
• Safer Electronic Records: According to HIPAA, there were 642 healthcare data breaches of 500 or more
records in 2020. Johns Hopkins University reported that the 3rd leading cause of death in the US was medical
errors. Blockchain Technology serves the best solution for such problems as it enables safer and more
accurate information and healthcare records. Blockchain can be linked to existing electronic health records
and act as an overarching single-view of the patient’s file.
• Transparency in Supply Chain: With the increase in awareness and need the healthcare sector also needs
to maintain authenticity of medications. Blockchain technology known for its tracking changes enables it to
meet the standardization and removal of unwanted products.
• Authentication for Staff Credentials: Along with authenticating medications, patient records,
manufactures. Blockchain Technology also helps in verifying staff identities This enables both hospital and
patients to maintain privacy of records and data.
• Remote Monitoring IoT Security: With the advancement in technology there are various devices
like smartwatches, ECG sensors and pulse oximeters etc. available at an affordable rate. This allows greater
insight into a patient's health profile and provides more information for the doctors to act upon.
2. Real Estate
• Real estate is a huge industry involving a lot of tedious procedures like ownership processing, loans,
registrations etc. a blockchain network provides a transparent and authentic platform by providing
transparency, removing intermediaries, adding verifiability and reducing costs.
• It provides a medium that is feasible for both buyer and seller. It also removes any middle man termed as
intermediaries or brokers resulting in saving brokerage fees as well.
• The properties can also be registered digitally adding verifiability to the property including its owner.
• Decentralized Finance (DeFi) is the core of the banking and financing industry. It is an open source of
movement to change how financial applications function on decentralized architecture.
• At the core level there is no centralization present which rules out the main problem of fund misuse.
• Ethereum is the key blockchain platform used in the decentralized finance system.
• Blockchain networks can also be used to establish an end-to-end user-friendly banking system by redefining
the baking process and making it more technologically systemized.
• Transfer of assets or value is another crucial task wherein blockchain can be used to simplify the process
without the need for a centralized entity.
4. Media
• It is one of those sectors which are constantly developing based on the social- economical region.
UNIT-I
• With free media comes tons of problems like IP infringement, centralized content, and monetization issues.
• In the media, a decentralized method based on blockchain technology is groundbreaking since it solves the
majority of the difficulties.
• The content producer can publish their work on a decentralized platform with no restrictions on distribution.
• Finally, each piece of content includes codes that can be exploited to detect IP violation.
• As a result, if someone commits an IP infringement, the system will be able to recognize it and take
appropriate action based on the smart contract definitions.
1. Transactions:
In the context of blockchain, a transaction refers to the transfer of digital assets or information from one participant to
another. Transactions can represent various types of activities, such as sending cryptocurrency tokens, recording data,
executing smart contracts, or updating account balances.
• Sender and Receiver: A transaction typically involves a sender, who initiates the transaction, and
a receiver, who receives the assets or information.
• Amount: Transactions specify the quantity or value of the assets being transferred.
• Timestamp: The time at which the transaction occurred is recorded to establish the chronological
order of transactions.
• Digital Signature: Transactions are digitally signed by the sender to authenticate their identity and
authorize the transfer.
• Transaction ID: Each transaction is assigned a unique identifier, known as a transaction ID or hash,
which is used to track and reference the transaction on the blockchain.
2. Blocks:
Blocks are containers that store a collection of validated transactions on the blockchain. When transactions occur, they
are grouped together into blocks by network participants, such as miners in a Proof of Work (PoW) blockchain. Once
a block is filled with transactions, it is added to the existing chain of blocks, forming a chronological sequence of
transactions known as the blockchain.
UNIT-I
• Transactions: A block contains a list of transactions that have been validated and confirmed by
network participants.
• Header: The header of a block contains metadata, such as the block's timestamp, a reference to the
previous block (known as the hash of the previous block), and a unique identifier (block hash or
block ID).
• Merkle Root: A cryptographic hash of all the transactions in the block, known as the Merkle root,
is included in the block's header to efficiently summarize the transaction data.
• Block Size and Time: The size of a block and the time it takes to generate a new block vary depending on
the blockchain protocol. In Bitcoin, for example, blocks are limited to a certain size (currently 1 MB) and are
generated approximately every 10 minutes on average.
Thus, transactions represent the transfer of assets or information on the blockchain, while blocks contain validated
transactions grouped together and added to the blockchain in a chronological sequence. Together, transactions and
blocks form the backbone of the blockchain ledger system, enabling secure, transparent, and decentralized record-
keeping and value transfer.
Working:
As we know, a P2P network has no central server overlooking them; the users or nodes are responsible for maintaining
the network. Every node participating in the network acts as a server that can upload, download, and share files with
other nodes. The nodes use their hard drives instead of a central server to store this data. As these capabilities to
transmit, receive and store files lie with each node, the P2P network is more secure, fast and efficient.
It is important to note that to make peer nodes easily locatable to new peers that join the network, the P2P architecture
must have many active nodes in the blockchain network, as this is when it functions best. If many nodes leave the
network, it is necessary to ensure enough are left to pick up the slack.
UNIT-I
The network is categorized into three types of P2P networks based on their architectural differences.
In this network, an organized structure is used in which the nodes interact, making it possible for the nodes to easily
search for files even if the data is unavailable. Due to this organized structure, some amount of centralization exists in
this type of network. Despite providing easy access to data, a structured P2P network is more challenging and costly
to set up.
In this type of network, there is no set structure for the nodes to follow. Participants can join or leave the network as
and when they desire. This lack of a definite structure leads participants to communicate randomly with each other.
This network is easy to build, but it requires high CPU power as all nodes must remain active to process a high number
of transactions. Memory usage is also increased as search queries are sent to the whole network. An unstructured peer-
to-peer network is best applicable for high churn activity, such as for a social platform.
A hybrid P2P network is a combination of a peer-to-peer and client-server model. The network has a central server
that stores information on the location of resources and uses this server to conduct searches. In comparison to the
structured and unstructured P2P network, a hybrid P2P network has better performance. It provides centralization,
which is required for specific queries while providing the benefits of a decentralized network.
P2P networking architecture is a fundamental element in blockchain technology, as it allows cryptocurrencies (e.g.
Bitcoin network) to be transferred globally without any intermediary, middleman or central server. The creator of
Bitcoin, Satoshi Nakamoto, referred to it as a “peer-to-peer electronic cash system” which was created with the aim
of having a P2P digital form of money.
Blockchain leverages the P2P network technology to provide a decentralized ledger for one or more digital assets. In
this decentralized P2P network, all the nodes or computers are connected to one another in some way. A complete
copy of the ledger is maintained by each node and is compared to other nodes to ensure the accuracy of data. This is
the opposite of a bank, where transactions are privately stored and can only be managed by the bank.
• Low cost
In a P2P network, every node acts as a server, and there is no central server. This saves the cost of buying an expensive
server, making it a cost-effective network.
• Scalable
Bottlenecks faced in a centralized server model, when the number of clients increases, are eliminated in a P2P network
as each node can be a server. The P2P network is designed to be scalable, as an increase in the number of clients results
in an equal increase in the number of servers.
• Resilient
Compared to centralized networks, a P2P network is more resilient to failure as the loss of a single node does not bring
down the entire network.
UNIT-I
• Slow performance
Every node or computer in the P2P network is accessed by other nodes, slowing down the user’s performance.
• Data is vulnerable
The absence of a central server sometimes makes this network hard to manage, as controlling or monitoring illegal or
prohibited activity is difficult. No central authority manages operations, so data becomes vulnerable to malware
attacks.
A huge amount of computing power is required for P2P networks since each node acts as both the client and the server.