Blockchain Technologies Module 1
Blockchain Technologies Module 1
1) Explain Cryptography ?
Cryptography is the technique of securing information and communications
through the use of codes so that only those for whom the information is
intended can understand and process it. This prevents unauthorized access to
information. The word "cryptography" is derived from the Greek words
"kryptos" meaning hidden and "graphein" meaning writing. It involves
converting plain text into cipher text through encryption and then converting it
back to plain text through decryption. Here are the key points to understand
cryptography:
1. Techniques:
Encryption: The process of converting plain text into cipher text using
an algorithm and a key.
Decryption: The process of converting cipher text back into plain text
using an algorithm and a key.
2. Features:
Non-repudiation: Ensuring that the sender cannot deny having sent the
information.
3. Types:
Symmetric Key Cryptography: Uses the same key for both encryption
and decryption. It is efficient for encrypting large amounts of data.
Example: Advanced Encryption Standard (AES).
BLOCKCHAIN MODULE 1 1
Asymmetric Key Cryptography: Uses a pair of keys, a public key for
encryption and a private key for decryption. It provides higher security
and is used for key exchange, digital signatures, and encryption.
Example: RSA (Rivest-Shamir-Adleman).
4. Applications:
BLOCKCHAIN MODULE 1 2
Cryptographic hash functions are essential tools in the field of cryptography.
They take an input (or 'message') and return a fixed-size string of bytes,
typically a hash value or digest, which appears random. Here are the key
properties that make cryptographic hash functions valuable for securing data:
1. Deterministic:
A given input will always produce the same hash output. This
consistency ensures that any change in the input will result in a different
hash, making it reliable for verification.
2. Fast Computation:
The hash function must be able to return the hash value quickly, making
it practical for use in real-time applications and systems.
3. Preimage Resistance:
5. Collision Resistance:
6. Avalanche Effect:
Regardless of the input size, the hash function outputs a hash of a fixed
size. This uniformity simplifies processing and storage of hash values.
BLOCKCHAIN MODULE 1 3
8. Efficiency:
The avalanche effect refers to the phenomenon where a tiny alteration to the
input of a cryptographic hash function (such as changing a single bit) causes a
drastic and seemingly random change in the resulting hash output. This means
that even a minimal modification in the input leads to a hash value that looks
entirely different from the original.
Importance
1. Unpredictability:
The avalanche effect ensures that the output hash appears random and
uncorrelated to the input, making it difficult for attackers to predict
2. Security Enhancement:
By ensuring that similar inputs do not produce similar hash outputs, the
avalanche effect helps protect against various attacks
3. Data Integrity:
When verifying the integrity of data, the avalanche effect ensures that
any minor alteration in the input data (intentional or accidental) results
in a completely different hash. This makes it easy to detect changes in
the data
Example
Consider a simple example using a hypothetical hash function:
BLOCKCHAIN MODULE 1 4
Input 2: "Hello, world!"
In this example, the only difference between Input 1 and Input 2 is the
capitalization of the letter "W" in "World". Despite this minor change, the hash
outputs
Mathematical Illustration
Suppose we have a hash function H . For an input X and a slightly modified
input X' , the avalanche effect ensures that:
H(X) ≠ H(X’)
Applications
Encryption Protocols: The avalanche effect is used in encryption protocols
to ensure that similar plaintexts do not produce similar ciphertexts, which
helps in preventing attacks that exploit such patterns.
Digital Signatures: It ensures that any change to the signed document will
result in a completely different signature, thus invalidating the signature if
any tampering occurs.
1. Ensuring data integrity: Secure hash functions like SHA-256 are used to
create a unique digital fingerprint or hash value for each block of
transactions in the blockchain. This hash value is computed using the
transaction data and some other metadata like the previous block's hash.
Any change to the transaction data will result in a completely different hash
value, thereby ensuring data integrity.
2. Linking blocks: The hash of the previous block is stored in the current
block's header. This cryptographically links the blocks together in a chain.
BLOCKCHAIN MODULE 1 5
Any attempt to tamper with a block's data will cause its hash to change,
breaking the chain.
Key Concepts
1. Key-Value Storage:
DHTs store data in the form of key-value pairs. The key is typically a
unique identifier, and the value is the data associated with that key.
2. Distributed Nodes:
The data is distributed across multiple nodes in the network. Each node
is responsible for storing a subset of the key-value pairs.
3. Hash Functions:
BLOCKCHAIN MODULE 1 6
A hash function maps keys to specific nodes in the network. This
mapping ensures that each key-value pair is stored on the appropriate
node.
2. Storing Data:
3. Retrieving Data:
To retrieve a value, the key is hashed, and the request is routed to the
node responsible for that key.
Properties of DHTs
1. Scalability:
2. Fault Tolerance:
3. Decentralization:
BLOCKCHAIN MODULE 1 7
4. Load Balancing:
2. Kademlia:
3. Pastry:
4. Tapestry:
Applications of DHTs
1. Peer-to-Peer Networks:
BLOCKCHAIN MODULE 1 8
DHTs can be used in blockchain and cryptocurrency networks to
manage data distribution, such as storing blockchain ledgers and
ensuring efficient data retrieval.
The leaf nodes of a Merkle tree contain the hashes of individual data
blocks. These are the lowest level of the tree.
2. Non-Leaf Nodes:
Each non-leaf node is the hash of the concatenation of its two child
nodes. This process continues up the tree, combining pairs of nodes at
each level.
The topmost node, called the Merkle root, represents the hash of all the
underlying data. It is derived from the combination of all leaf and
intermediate nodes.
2. Pairwise Hashing:
These hashes are then paired, and each pair is concatenated and
hashed to form the parent nodes.
3. Recursive Hashing:
BLOCKCHAIN MODULE 1 9
This process of pairwise concatenation and hashing is repeated until
only one hash remains, which is the Merkle root.
Merkle trees ensure the integrity of data blocks. Any change in a single
data block will result in a completely different hash at the leaf level,
which propagates up the tree, altering the Merkle root. This makes it
easy to verify whether data has been tampered with.
2. Efficient Verification:
3. Scalability:
Merkle trees are highly scalable and can handle large amounts of data
efficiently. They are used in systems where data integrity and efficient
verification are paramount.
2. Distributed Systems:
Version Control Systems: Systems like Git use Merkle trees to manage
changes and ensure the integrity of file versions.
3. Digital Signatures:
BLOCKCHAIN MODULE 1 10
Merkle trees can be used to efficiently sign multiple data blocks. A
single Merkle root can be signed instead of signing each individual
block, reducing computational overhead.
Merkle Proofs
Merkle proofs are used to verify that a specific data block is included in the
Merkle tree without having to reveal the entire dataset. A Merkle proof includes:
The hashes of the siblings along the path from the target data block to the
Merkle root.
The verifier can recompute the hashes from the target data block up to the
Merkle root and compare it with the known Merkle root to confirm the integrity
and inclusion of the data block.
Example
Consider a Merkle tree with four transactions (T1, T2, T3, T4):
3. Hash the results to form the Merkle root: H(H(H(T1) + H(T2)) + H(H(T3) +
H(T4))).
If a single transaction (e.g., T2) changes, H(T2) will change, altering H(H(T1) +
H(T2)) and ultimately the Merkle root, signaling data modification.
BLOCKCHAIN MODULE 1 11
Merkle Trees: Hash functions are used to build Merkle trees, a structure
that allows efficient and secure verification of data integrity. Each leaf node
of the Merkle tree is a hash of a data block (e.g., a transaction), and non-
leaf nodes are hashes of their respective child nodes. The root of the tree,
known as the Merkle root, represents the entire dataset.
BLOCKCHAIN MODULE 1 12
Efficiency: Merkle proofs are logarithmic in size, making them efficient and
practical for verifying large datasets.
5. Digital Signatures
Transaction Authentication:
Security: This process ensures that transactions are authorized and have
not been tampered with, providing security and trust in the blockchain
network.
6. Address Generation
Wallet Addresses:
Public Key Hashing: Hash functions are used to create blockchain wallet
addresses. A user's public key is hashed to produce a shorter, fixed-length
address. This makes addresses easier to handle and more secure.
7. Data Fingerprinting
Unique Identifiers:
BLOCKCHAIN MODULE 1 13
Cryptography involves the use of various types of keys to secure information.
The main types of cryptographic keys are:
1. Symmetric Keys
Symmetric key cryptography, also known as private key cryptography, uses the
same key for both encryption and decryption. This means that both the sender
and receiver must possess the same key and keep it secret.
Block Ciphers and Stream Ciphers: Block ciphers encrypt data in fixed-
size blocks, whereas stream ciphers encrypt data as a continuous stream
of bits or bytes.
2. Asymmetric Keys
Asymmetric key cryptography, also known as public key cryptography, uses a
pair of keys: a public key for encryption and a private key for decryption. The
public key can be distributed openly, while the private key must remain
confidential.
RSA: One of the most widely used asymmetric algorithms, based on the
mathematical difficulty of factoring the product of two large prime numbers
【 3†source .】
Elliptic Curve Cryptography (ECC): Provides similar security to RSA but
with smaller key sizes, making it more efficient. ECC is used in many
modern applications, including digital signatures and secure
【
communications 3†source . 】
Digital Signature Algorithm (DSA): Another widely used asymmetric
algorithm specifically designed for digital signatures.
BLOCKCHAIN MODULE 1 14
3. Hybrid Systems
These systems combine symmetric and asymmetric cryptography to leverage
the strengths of both. Typically, asymmetric cryptography is used to exchange
a symmetric key, which is then used to encrypt the actual data.
Static Keys: Long-term keys that are used over multiple sessions.
Overview
Inventors: Cryptographers Joan Daemen and Vincent Rijmen.
Security: No effective attack has been found against AES that is better than
brute-force methods.
BLOCKCHAIN MODULE 1 15
Block Size: AES processes data in fixed-size blocks of 128 bits (16 bytes).
Encryption Process
The AES algorithm transforms the plaintext data into ciphertext through multiple
rounds of processing. The number of rounds depends on the key size:
Each round consists of four main operations applied to a 4x4 byte matrix called
the "state."
1. AddRoundKey
Purpose: Introduces the key material into the state, providing security.
2. SubBytes
Description: Each byte in the state matrix is replaced with a byte from a
fixed substitution table called the S-box.
3. ShiftRows
Description: The rows of the state matrix are shifted left by different
offsets. The first row is not shifted, the second row is shifted by one
byte, the third row by two bytes, and the fourth row by three bytes.
4. MixColumns
Final Round
BLOCKCHAIN MODULE 1 16
In the last round of AES, the MixColumns step is omitted, and only
AddRoundKey, SubBytes, and ShiftRows are performed.
1. Modulus Generation:
3. Public Key:
The public key consists of the modulus \( n \) and the exponent \( e \).
Thus, the public key is \((n, e)\). This key can be shared openly.
4. Private Key:
1. Encryption:
BLOCKCHAIN MODULE 1 17
A message \( M \) (represented as an integer) is encrypted using the
recipient's public key \( (n, e) \).
2. Decryption:
The recipient can decrypt the ciphertext \( C \) using their private key \(
d \).
Example
Public Key: \( (n, e) \)
Private Key: \( d \)
For encryption:
Digital signatures are verifiable by the receiving party, ensuring that the
signature is valid and that the message indeed comes from the claimed
sender.
2. Unforgeability:
Only the sender of the message can generate the digital signature using
their private key. This property ensures that no one else can forge the
BLOCKCHAIN MODULE 1 18
signature, providing protection against forgery. This is also referred to
as non-repudiation, meaning the sender cannot deny having signed the
message.
3. Non-reusability:
The digital signature cannot be detached from the original message and
reused with another message. The signature is uniquely bound to the
corresponding message, preventing it from being copied and reused in
a different context.
The hash value is then encrypted with the sender's private key to create
the digital signature. Since the private key is known only to the sender,
this step ensures the authenticity of the signature.
The original message along with the digital signature is sent to the
recipient.
4. Verification:
The recipient decrypts the digital signature using the sender's public
key to obtain the original hash value.
BLOCKCHAIN MODULE 1 19
The recipient also hashes the received message using the same hash
function.
If the hash value obtained from the decrypted signature matches the
hash value of the received message, the signature is verified,
confirming the authenticity and integrity of the message.
Uses:
Digital signatures have a wide range of applications, including but not limited to:
1. Email Security:
Digital signatures are used to ensure that email content has not been
altered and to verify the sender’s identity.
2. Software Distribution:
3. Blockchain Transactions:
4. Document Signing:
5. Authentication:
6. Integrity Verification:
BLOCKCHAIN MODULE 1 20
The RSA digital signature algorithm is a widely used cryptographic technique
that ensures the authenticity and integrity of a message. It operates using
public and private key pairs and involves the following steps:
Purpose: Calculate the hash value of the data packet to ensure data
integrity. The hash value acts as a fixed-size representation of the
original data.
Process: Encrypt the hash value using the signer's private key. This
encrypted hash is the digital signature.
Reason: Only the signer has access to their private key, so only they
can generate a valid signature. The recipient can later verify this
signature using the signer's public key.
Process:
First, create a digital signature by signing the hash of the data with
the sender's private key.
BLOCKCHAIN MODULE 1 21
Encrypt the combined data and signature using the receiver's public
key.
Process:
Verification Process
To verify an RSA digital signature, the recipient performs the following steps:
Use their private key to decrypt the message and the signature (if the
"sign then encrypt" method was used).
Compute the hash of the received data using the same hash function
used by the sender.
Decrypt the digital signature using the sender's public key to obtain the
original hash.
Compare the decrypted hash with the hash computed from the received
data. If they match, the signature is valid, confirming the authenticity
and integrity of the message.
BLOCKCHAIN MODULE 1 22
15) Explain the different services provided by
cryptography ?
Services Provided by Cryptography
Cryptography offers a range of services to ensure secure communication and
data integrity. Here are the primary services provided by cryptography, as
extracted from the provided PDF:
1. Confidentiality:
2. Data Integrity:
3. Authentication:
4. Non-repudiation:
Prevents entities from denying their actions. Digital signatures are used
to provide proof of the origin and integrity of data, ensuring that the
sender cannot deny having sent the information.
5. Access Control:
BLOCKCHAIN MODULE 1 23
Design of SHA-256 and Its Compression Function
SHA-256 is a cryptographic hash function that produces a 256-bit digest from
an input message of arbitrary length. The algorithm works in several steps to
ensure the security and integrity of the hash output. Here's an explanation of
the design of SHA-256 and its compression function:
Design of SHA-256
1. Pre-processing:
Buffer Initialization: Eight 32-bit words are initialized. These words are
the fractional parts of the square roots of the first eight prime numbers.
2. Hash Computation:
Intermediate Hash Value: After processing all blocks, the final hash
value is obtained by concatenating the intermediate hash values.
Compression Function
The compression function of SHA-256 involves several steps, including logical
functions and modular additions. Here’s a simplified overview:
BLOCKCHAIN MODULE 1 24
Logical Functions: The Ch (choose) function and Maj (majority)
function are used.
3. Processing Steps:
For each of the 64 rounds, the working variables are updated using the
following operations:
BLOCKCHAIN MODULE 1 25
1. Data Hashing: Initially, each piece of data (e.g., transactions in a
blockchain) is hashed. These hashes become the leaf nodes of the Merkle
tree.
2. Pairwise Hashing: The leaf nodes are paired, and each pair is hashed
together to form the parent nodes. This process continues iteratively until a
single hash, known as the Merkle root, is produced at the top of the tree.
3. Merkle Root: The Merkle root represents the entire dataset's integrity. Any
change in the dataset would alter the corresponding leaf hash, which in
turn would alter all parent hashes up to the Merkle root.
Merkle Root
/ \\
Hash_AB Hash_CD
/ \\ / \\
Hash_A Hash_B Hash_C Hash_D
/ \\ / \\ / \\ / \\
Data1 Data2 Data3 Data4 Data5 Data6 Data7 Data8
BLOCKCHAIN MODULE 1 26
An elliptic curve is defined by the equation y2 = x3 + ax + b over a
finite field, where a and bare constants that determine the shape of the
curve. For ECC to be used in cryptography, the curve must be non-
singular, meaning it has no cusps or self-intersections.
The points on the elliptic curve form a group, which is a set equipped
with an operation (point addition) that satisfies certain axioms
(associativity, existence of an identity element, and existence of
inverses). These points and their properties are central to ECC.
1. Key Generation:
ECC uses pairs of keys: a public key and a private key. The private key
is a randomly selected number, while the public key is a point on the
elliptic curve obtained by multiplying the base point (a predefined point
on the curve) by the private key.
Decryption: The recipient then uses their private key to reverse the
process and retrieve the original message.
3. Digital Signatures:
ECC is also used for creating digital signatures. The process involves
generating a signature using the private key and verifying it with the
public key, ensuring the integrity and authenticity of the message.
Advantages of ECC:
Security with Smaller Key Sizes: ECC offers comparable security to RSA
but with much smaller key sizes. For example, a 256-bit key in ECC
provides equivalent security to a 3072-bit key in RSA.
BLOCKCHAIN MODULE 1 27
Scalability: Due to its efficiency, ECC is well-suited for applications
requiring high performance and low power consumption.
Applications of ECC:
Cryptocurrencies: ECC is used in cryptocurrencies like Bitcoin and
Ethereum for secure transactions.
Key Concepts
Node Responsibility:
Each node in the DHT network is responsible for storing and managing
a portion of the data.
Data Storage:
Data and its key are forwarded to the appropriate node for storage.
Data Retrieval:
BLOCKCHAIN MODULE 1 28
Client uses the key associated with the data to send a request to the
network.
Applications of DHTs
Peer-to-Peer (P2P) Networks:
Distributed Databases:
Benefits of DHTs
Scalability:
Fault Tolerance:
Decentralization:
BLOCKCHAIN MODULE 1 29
BLOCKCHAIN MODULE 1 30