0% found this document useful (0 votes)
41 views15 pages

Through Cryptographic Hashing and Consensus Mechanisms. Here's A Step

Uploaded by

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

Through Cryptographic Hashing and Consensus Mechanisms. Here's A Step

Uploaded by

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

UNIT -2

changing of blocks in blockchain


Changing blocks in a blockchain, also known as modifying the blockchain ledger, is virtually
impossible in public blockchains due to the way blockchains are designed to secure data
through cryptographic hashing and consensus mechanisms. Here’s a step-by-step look at
why changing blocks is so challenging:
1. Each Block is Linked by Cryptographic Hashes
• How It Works: Each block in a blockchain contains a unique identifier called a "hash,"
which is generated based on the block's data. The block also contains the hash of the
previous block, creating a chain of blocks.
• Why It’s Secure: Because each block is dependent on the hash of the previous block,
altering any block's data would change its hash, breaking the link between it and the
following block. To hide any modification, all subsequent blocks would need to be
recalculated, which requires enormous computational resources.
2. Proof-of-Work (PoW) and Proof-of-Stake (PoS) Consensus
• In PoW Blockchains: To modify a block in a PoW blockchain (like Bitcoin), an attacker
would need to re-mine the modified block and every block after it to bring the
blockchain back to its current state, which is computationally infeasible.
• In PoS Blockchains: In a PoS blockchain, validators need to "stake" cryptocurrency to
verify transactions and add blocks. An attacker would need to control a large amount
of the total staked tokens to change historical data, making it financially impractical.
3. The 51% Attack Requirement
• How It Works: To alter a blockchain, an attacker would need to control more than
51% of the network’s total computational power (in PoW) or total staked tokens (in
PoS).
• Why It’s Difficult: Acquiring this level of control is expensive and complex in
established blockchains. Even if an attacker managed to gain 51% control, they would
only be able to alter recent transactions. Older blocks would remain highly secure
due to the cost and difficulty of re-mining them.
4. Distributed and Decentralized Network
• What It Means: Blockchains are decentralized, meaning that copies of the blockchain
ledger are stored across many nodes (computers) around the world.
• Why It’s Secure: If an attacker tried to alter a block on one node, other nodes would
reject it because it wouldn’t match their version of the blockchain. For a successful
alteration, the attacker would need to change over 51% of all copies of the blockchain
simultaneously.
UNIT -2
5. Immutability through Finality
• Immutability: Once a block is confirmed and added to the blockchain, it is considered
immutable, meaning it cannot be changed. This immutability is what makes
blockchain technology so valuable for securely storing records.
• Finality in PoS: Some PoS blockchains also have "finality checkpoints," meaning once
a block passes a checkpoint, it is permanently unchangeable.
cryptographic hash functions properties in blockchain
ChatGPT said:
ChatGPT
Cryptographic hash functions are essential to blockchain technology. They ensure data
integrity, security, and immutability. Here are the key properties of cryptographic hash
functions that make them so effective for blockchain:
1. Deterministic
• What It Means: A given input will always produce the same output hash.
• Why It’s Important in Blockchain: Determinism ensures that every participant in the
network generates the same hash for identical blocks, which is essential for
consistency and verifying that data hasn't been tampered with.
2. Fixed Output Length
• What It Means: Regardless of the input’s size, the output hash is always of a fixed
length. For example, SHA-256 produces a 256-bit hash.
• Why It’s Important in Blockchain: A fixed-length output simplifies storage and
ensures uniformity across the blockchain. This consistency makes managing and
validating hashes straightforward, regardless of transaction complexity or block size.
3. Pre-Image Resistance
• What It Means: It is computationally infeasible to determine the original input solely
from its hash output.
• Why It’s Important in Blockchain: Pre-image resistance ensures that the hash
functions are secure because attackers can’t reverse-engineer a hash back to its
original data. This keeps transaction data secure and private.
4. Small Change Sensitivity (Avalanche Effect)
• What It Means: Even a tiny change in input (like altering a single character) will
drastically change the output hash.
UNIT -2
• Why It’s Important in Blockchain: The avalanche effect makes it easy to detect
tampering with data since any alteration, no matter how minor, will change the hash
entirely. This property is essential for blockchain’s data integrity and immutability.
5. Collision Resistance
• What It Means: It is infeasible to find two different inputs that produce the same
hash output.
• Why It’s Important in Blockchain: Collision resistance prevents two distinct data sets
from having the same hash, ensuring each block is unique. This property upholds
blockchain's security because any duplicated hash could imply falsified data,
undermining the chain’s trustworthiness.
6. Efficient Computability
• What It Means: Hash functions are designed to be quick and easy to compute, even
for large data sets.
• Why It’s Important in Blockchain: Efficiency enables fast validation and propagation
of transactions across the network. This supports scalability and ensures the network
can handle many transactions without delays.
7. Non-Randomness and Uniqueness
• What It Means: The same input will always produce the same output (determinism),
and every unique input will ideally produce a unique hash.
• Why It’s Important in Blockchain: Uniqueness reinforces security and data integrity
by ensuring each block or transaction has a distinct identifier, making it easier to trace
and verify data in the blockchain.
Second Pre-Image Resistance
Data Integrity: Second pre-image resistance ensures that each block and transaction is
unique and tamper-proof. Altering any information within a block would create a new hash,
signaling tampering.
Security Against Attacks: It prevents malicious users from replacing valid data with false
data that has the same hash, which could otherwise compromise the integrity of the
blockchain.
Blockchain Merkle Tree
Merkle tree is a fundamental part of blockchain technology. It is a mathematical data
structure composed of hashes of different blocks of data, and which serves as a summary of
all the transactions in a block. It also allows for efficient and secure verification of content in
a large body of data. It also helps to verify the consistency and content of the data. Both
Bitcoin and Ethereum use Merkle Trees structure. Merkle Tree is also known as Hash Tree.
UNIT -2
The concept of Merkle Tree is named after Ralph Merkle, who patented the idea in 1979.
Fundamentally, it is a data structure tree in which every leaf node labelled with the hash of
a data block, and the non-leaf node labelled with the cryptographic hash of the labels of its
child nodes. The leaf nodes are the lowest node in the tree.
How do Merkle trees work?
A Merkle tree stores all the transactions in a block by producing a digital fingerprint of the
entire set of transactions. It allows the user to verify whether a transaction can be included
in a block or not.
Merkle trees are created by repeatedly calculating hashing pairs of nodes until there is only
one hash left. This hash is called the Merkle Root, or the Root Hash. The Merkle Trees are
constructed in a bottom-up approach.
Every leaf node is a hash of transactional data, and the non-leaf node is a hash of its
previous hashes. Merkle trees are in a binary tree, so it requires an even number of leaf
nodes. If there is an odd number of transactions, the last hash will be duplicated once to
create an even number of leaf nodes.

The above example is the most common and simple form of a Merkle tree, i.e., Binary
Merkle Tree. There are four transactions in a block: TX1, TX2, TX3, and TX4. Here you can
see, there is a top hash which is the hash of the entire tree, known as the Root Hash, or
the Merkle Root. Each of these is repeatedly hashed, and stored in each leaf node, resulting
in Hash 0, 1, 2, and 3. Consecutive pairs of leaf nodes are then summarized in a parent node
by hashing Hash0 and Hash1, resulting in Hash01, and separately hashing Hash2 and Hash3,
resulting in Hash23. The two hashes (Hash01 and Hash23) are then hashed again to
produce the Root Hash or the Merkle Root.
UNIT -2
Merkle Root is stored in the block header. The block header is the part of the bitcoin block
which gets hash in the process of mining. It contains the hash of the last block, a Nonce, and
the Root Hash of all the transactions in the current block in a Merkle Tree. So having the
Merkle root in block header makes the transaction tamper-proof. As this Root Hash
includes the hashes of all the transactions within the block, these transactions may result in
saving the disk space.

The Merkle Tree maintains the integrity of the data. If any single detail of transactions or
order of the transaction's changes, then these changes reflected in the hash of that
transaction. This change would cascade up the Merkle Tree to the Merkle Root, changing
the value of the Merkle root and thus invalidating the block. So everyone can see that
Merkle tree allows for a quick and simple test of whether a specific transaction is included
in the set or not.
Merkle trees have three benefits:
o It provides a means to maintain the integrity and validity of data.
o It helps in saving the memory or disk space as the proofs, computationally easy and
fast.
o Their proofs and management require tiny amounts of information to be transmitted
across networks.
Proof of Work
Proof of Work (PoW) is a consensus mechanism used in blockchain networks to validate
transactions and secure the network. Here’s a simple step-by-step breakdown of how PoW
works:
Step 1: Transaction Creation
• What Happens: Users create transactions on the blockchain network. These
transactions contain details such as sender, receiver, and amount.
• Example: Alice wants to send 1 Bitcoin to Bob.
Step 2: Transaction Pool
UNIT -2
• What Happens: Created transactions are broadcast to the network and collected into
a pool of unconfirmed transactions (also known as the mempool).
• Example: Alice's transaction is added to the pool along with others waiting to be
confirmed.
Step 3: Block Formation
• What Happens: Miners (participants in the network) select transactions from the
pool to include in a new block.
• Example: A miner selects Alice’s transaction and several others to form a new block
of transactions.
Step 4: Finding a Nonce
• What Happens: To add the new block to the blockchain, miners must solve a complex
mathematical problem, which involves finding a nonce. This is a number that, when
combined with the block’s data and hashed, produces a hash that meets a certain
difficulty target.
• Example: The miner begins by trying different nonce values (starting from 0) and
hashing the block header until they find a hash that starts with a certain number of
zeros (the difficulty target).
Step 5: Hashing
• What Happens: The miner repeatedly hashes the block header with different nonce
values until they find a valid hash.
• Example: After many attempts, the miner finds that using a nonce of 456 produces a
valid hash that meets the difficulty requirement.
Step 6: Broadcasting the Block
• What Happens: Once a miner finds a valid hash, they broadcast the newly created
block to the entire network for verification.
• Example: The miner shares the block containing Alice’s transaction and the valid hash
with other nodes in the network.
Step 7: Verification by Other Nodes
• What Happens: Other nodes in the network verify the block and its hash. They check
if the hash is valid and if all included transactions are legitimate (i.e., they follow the
rules of the blockchain).
• Example: Nodes confirm that Alice’s transaction is valid and that the block's hash
meets the required criteria.
UNIT -2
Step 8: Adding the Block to the Blockchain
• What Happens: Once verified, the block is added to the blockchain, and the
transactions within it are confirmed.
• Example: Alice’s transaction is now part of the blockchain, and Bob receives the 1
Bitcoin.
Step 9: Miner Reward
• What Happens: The miner who successfully created and validated the block receives
a reward, usually in the form of newly created cryptocurrency (block reward) and
transaction fees from the transactions in the block.
• Example: The miner earns a reward of 6.25 Bitcoins (the current block reward) plus
transaction fees.
Proof of stake
Proof of Stake (PoS) is a consensus mechanism used in blockchain networks to validate
transactions and secure the network. It differs from Proof of Work (PoW) by relying on the
amount of cryptocurrency held (staked) by participants rather than computational power.
Here’s a simple step-by-step breakdown of how PoS works:
Step 1: Transaction Creation
• What Happens: Users create transactions on the blockchain, such as sending
cryptocurrency to another user.
• Example: Alice wants to send 1 Ethereum to Bob.
Step 2: Transaction Pool
• What Happens: Transactions are broadcast to the network and collected into a pool
of unconfirmed transactions.
• Example: Alice's transaction is added to this pool alongside others waiting to be
confirmed.
Step 3: Validators and Staking
• What Happens: Users (validators) must stake a certain amount of cryptocurrency to
participate in the validation process. The more coins they stake, the higher their
chances of being chosen to validate the next block.
• Example: Alice decides to stake 10 Ethereum to become a validator.
Step 4: Block Creation
• What Happens: The network selects a validator (or validators) to create the next
block based on their stake and possibly other factors like randomization.
UNIT -2
• Example: The network randomly selects Alice to create the next block because of her
stake.
Step 5: Validating Transactions
• What Happens: The chosen validator (Alice) compiles the transactions from the pool,
verifies their legitimacy, and creates a new block containing those transactions.
• Example: Alice verifies that her transaction to Bob is valid and adds it to the new
block.
Step 6: Broadcasting the Block
• What Happens: The newly created block is broadcast to the rest of the network for
verification.
• Example: Alice shares the block with other nodes in the network.
Step 7: Verification by Other Nodes
• What Happens: Other nodes verify the block and ensure all transactions within it are
legitimate. They check that the block follows network rules and that Alice’s
transaction is valid.
• Example: Nodes confirm that Alice’s transaction is legitimate and that the block
adheres to the consensus rules.
Step 8: Adding the Block to the Blockchain
• What Happens: Once verified, the new block is added to the blockchain, and all
transactions within it are confirmed.
• Example: Alice’s transaction is now permanently recorded on the blockchain, and Bob
receives the 1 Ethereum.
Step 9: Validator Reward
• What Happens: The validator (Alice) earns rewards, typically in the form of
transaction fees or newly minted cryptocurrency, for their role in creating and
validating the block.
• Example: Alice receives a small reward for successfully validating the block.
UNIT -2
Delegated Proof of Stake (DPoS) is a consensus mechanism used in blockchain networks
that aims to improve the efficiency and scalability of traditional Proof of Stake (PoS). Here’s
a simple and understandable breakdown of how DPoS works:
1. Understanding the Basics
• Delegation: In DPoS, token holders don’t directly participate in the validation of
transactions. Instead, they delegate their voting power to trusted representatives
(called delegates or witnesses) who will do the validating on their behalf.
2. How DPoS Works
Step 1: Token Ownership
• What Happens: Users own tokens or cryptocurrency on the blockchain network (like
EOS or TRON).
• Example: Alice holds 100 tokens on the DPoS blockchain.
Step 2: Voting for Delegates
• What Happens: Alice and other token holders can vote for delegates (also known as
block producers) based on their performance, reputation, and community
engagement.
• Example: Alice votes for Bob and Charlie as her chosen delegates to represent her
interests.
Step 3: Election of Delegates
• What Happens: The delegates with the most votes are elected to validate
transactions and create new blocks.
• Example: Bob and Charlie, along with a few others, are elected as delegates because
they received the most votes from token holders.
Step 4: Validation of Transactions
• What Happens: The elected delegates take turns validating transactions and creating
new blocks. They are responsible for maintaining the network and ensuring that
transactions are accurate and secure.
• Example: Bob validates transactions for a specific time period and creates the next
block in the blockchain.
Step 5: Earning Rewards
• What Happens: Delegates earn rewards (such as transaction fees or newly created
tokens) for their work in validating transactions and producing blocks.
UNIT -2
• Example: Bob receives rewards for successfully validating and adding blocks to the
blockchain.
Step 6: Distribution of Rewards
• What Happens: Some DPoS systems distribute a portion of the rewards back to the
token holders who voted for the delegates, creating an incentive for participation.
• Example: Since Alice voted for Bob, she may receive a small share of the rewards Bob
earns as a delegate.
3. Benefits of DPoS
• Efficiency: DPoS allows for faster transaction validation since only a limited number of
delegates are involved, reducing the time taken to create new blocks.
• Scalability: The system can handle more transactions as the number of validators is
limited to a manageable number of elected delegates.
• Decentralization with Representation: Token holders can influence the network by
voting for representatives while not needing to run their own nodes or spend
resources on validation.
• Incentive Alignment: Delegates are motivated to act in the best interest of token
holders to maintain their votes and stay elected.
UTXO model in blockchain
The UTXO (Unspent Transaction Output) model is a fundamental accounting model used in
some blockchains, such as Bitcoin, to manage and verify transactions. It differs from the
account-based model (used by Ethereum) by tracking the remaining balance from
transactions rather than directly tracking account balances. Here’s an easy-to-understand
breakdown of how the UTXO model works:
1. Understanding UTXO Basics
• In the UTXO model, every transaction produces outputs, which are amounts of
cryptocurrency sent to recipients.
• These outputs are unspent transaction outputs (UTXOs) until they are used as inputs
in a new transaction.
2. How the UTXO Model Works
Step 1: Starting with UTXOs
• What Happens: Every user has a set of UTXOs associated with their address. These
UTXOs represent the total funds available to them.
UNIT -2
• Example: Alice receives 2 Bitcoin from Bob and 3 Bitcoin from Carol, which are
recorded as two separate UTXOs in her wallet.
Step 2: Creating a New Transaction
• What Happens: When Alice wants to send Bitcoin, she selects one or more UTXOs as
inputs for her transaction.
• Example: Alice wants to send 4 Bitcoin to Dave. She selects her 3 BTC UTXO and 2 BTC
UTXO to use as inputs, giving her a total of 5 BTC to work with.
Step 3: Defining Outputs
• What Happens: Alice creates outputs for the transaction, which include the amount
she’s sending to Dave and any remaining change back to herself.
• Example: Alice’s transaction has:
o Output 1: 4 BTC sent to Dave.
o Output 2: 1 BTC (the remaining balance) sent back to Alice as change.
Step 4: Broadcasting the Transaction
• What Happens: Alice’s transaction is broadcast to the network, where miners verify
and record it on the blockchain. Her selected UTXOs are now considered “spent” and
can no longer be used.
• Example: The network confirms Alice’s transaction, and the 3 BTC and 2 BTC UTXOs
are marked as “spent.”
Step 5: Creating New UTXOs
• What Happens: Dave receives 4 BTC as a new UTXO, and Alice receives a new UTXO
of 1 BTC as her change.
• Example: Now, Alice has a 1 BTC UTXO, and Dave has a 4 BTC UTXO. These UTXOs can
now be used in future transactions.
3. Benefits of the UTXO Model
• Enhanced Security: Each transaction creates new UTXOs, ensuring traceability and
reducing the risk of double-spending.
• Parallel Processing: UTXOs are independent, allowing for transactions to be
processed in parallel, which can improve scalability.
• Privacy: By grouping different UTXOs into transactions, users can improve their
privacy as it’s harder to track balances directly.
UNIT -2
The Global State Model is a model used by some blockchains, such as Ethereum, to keep
track of the entire network's current state, including account balances, smart contract code,
and storage. It differs from the UTXO (Unspent Transaction Output) model used by Bitcoin,
as it tracks the state of each account directly rather than focusing on individual transaction
outputs.
Here’s a breakdown of how the Global State Model works in an easy-to-understand way:
1. Understanding the Basics of the Global State Model
• Global State: In the Global State Model, the blockchain maintains a global view of the
state of all accounts and smart contracts on the network.
• Accounts-Based: Each user and smart contract has an account that stores
information like balances, transaction history, and any associated data or code (in the
case of smart contracts).
2. How the Global State Model Works
Step 1: Account Creation
• What Happens: Every participant has an account on the blockchain. There are two
types of accounts in networks like Ethereum:
o Externally Owned Accounts (EOAs) for users, which hold balances and are
controlled by private keys.
o Smart Contract Accounts that contain code and data for smart contracts.
• Example: Alice creates an account, which will store her balance, transaction history,
and any interactions with smart contracts.
Step 2: Transaction Processing
• What Happens: Transactions in the Global State Model are processed to update
account balances or interact with smart contracts.
• Example: Alice sends 5 ETH to Bob, which triggers a change in both accounts'
balances in the global state. Alice’s balance decreases, and Bob’s balance increases by
5 ETH.
Step 3: State Updates
• What Happens: Every time a transaction is processed, the global state is updated to
reflect the new account balances, contract data, or any other changes.
• Example: Alice also interacts with a smart contract to deposit 3 ETH into a
decentralized finance (DeFi) application. The global state updates to show that the
DeFi smart contract account now holds the 3 ETH she deposited.
UNIT -2
Step 4: Storage and Execution in Smart Contracts
• What Happens: Smart contracts in the Global State Model can store data, execute
code, and interact with other accounts based on the transactions they receive. The
state of each smart contract is also tracked as part of the global state.
• Example: The DeFi smart contract has stored data about Alice’s deposit, and this
information is part of the blockchain’s global state.
Step 5: Keeping Track of the Global State
• What Happens: Every block in the blockchain contains a snapshot of the global state.
This snapshot records all balances, data, and contract states up to that point, allowing
the network to validate future transactions based on the current state.
• Example: After Alice’s transactions are processed, a new block is created that records
the updated state, including changes to both Alice’s and Bob’s accounts and the smart
contract.
3. Benefits of the Global State Model
• Direct Account Balances: Since each account has a direct balance, it’s easier to
manage funds without tracking multiple UTXOs as in Bitcoin.
• Smart Contract Functionality: This model allows for complex smart contract
functionality and interactions, essential for platforms like Ethereum that support
decentralized applications (dApps).
• Efficient State Tracking: The model tracks the current state of all accounts in one
place, making it easier to execute and verify transactions quickly.
Wallets
In the blockchain world, wallets are essential tools that allow users to store, send, and
receive cryptocurrencies securely. Blockchain wallets manage the private and public keys for
users, enabling secure access and transactions on the blockchain. Wallets can range from
software applications to hardware devices, each with unique security and usability features.
Here’s an easy breakdown of blockchain wallets:
1. Understanding How Blockchain Wallets Work
• Private Key: A secret code that allows access to your wallet and funds. Think of it as a
password; whoever has the private key can control the cryptocurrency in the wallet.
• Public Key: A code derived from the private key that can be shared publicly. It’s often
linked to a wallet address and allows others to send you funds.
• Wallet Address: An alphanumeric identifier derived from the public key. It’s similar to
an email address for receiving cryptocurrency.
UNIT -2

Different types of BlockChain Nodes.


In a blockchain network, different types of nodes (computers) help manage and maintain
the network. Each node has a specific role, making the system more secure and efficient.
Let’s go through the main types of nodes:
1. Full Node
Role: Full nodes are the backbone of the blockchain. They store a complete copy of the
entire blockchain (all transactions from the start) and help verify transactions.
Functions:
Validate every transaction and block in the network.
Store the full blockchain, so they keep the network’s history and ensure accuracy.
Example: Think of a full node like a library that has every book (transaction) ever written in
a series. It allows anyone to access and check any part of the blockchain’s history.
2. Miner Node
Role: Miner nodes are specialized nodes that focus on creating new blocks and adding them
to the blockchain. They compete with each other to solve complex mathematical problems
(known as mining).
Functions:
Verify and bundle multiple transactions into a block.
Solve a computational puzzle to “mine” the block (usually in Proof of Work blockchains like
Bitcoin).
When successful, they add the block to the blockchain and earn rewards.
Example: Imagine a group of people trying to solve a puzzle to win a prize. The first person
(miner) to solve it gets the reward and gets to write the next chapter in the blockchain’s
“history book.”
3. Lightweight Node (Light Node)
Role: Light nodes are “lighter” versions of full nodes. They don’t store the entire blockchain
but rely on full nodes for information.
Functions:
Use only the necessary data to verify specific transactions.
Connect to full nodes to access the rest of the blockchain data.
UNIT -2
Example: Think of a light node as a person using a summary or a table of contents to find
information instead of reading the whole book. It’s quicker but requires a connection to the
full library (full node) when more details are needed.
4. Administrator Node
Role: Administrator nodes exist in private or permissioned blockchains (used by companies
or organizations). They manage and control the network.
Functions:
Set permissions and grant access to specific users.
Monitor and regulate the network’s activities.
Example: Imagine an office network where the administrator manages who has access to
certain files. In a private blockchain, an administrator node ensures that only authorized
users can view or make changes.

You might also like