Blockchain Networking and Consensus Mechanisms Lecture PDF
Document Details
Uploaded by SoftStarlitSky8040
Uzma Jafar
Tags
Summary
This lecture covers fundamental blockchain networking concepts, including peer-to-peer networks, consensus mechanisms, and cryptography. It also explores distributed applications (DApps) and different consensus algorithms like Proof of Work and Proof of Stake.
Full Transcript
Blockchain Networking and Consensus Mechanisms This week, we will explore P2P networks underpin blockchain’s decentralization. Consensus mechanisms ensure security and integrity. DApps showcase real-world applications of blockchain. By Uzma Jafar Key Takeaways Peer-to-peer networks enable dec...
Blockchain Networking and Consensus Mechanisms This week, we will explore P2P networks underpin blockchain’s decentralization. Consensus mechanisms ensure security and integrity. DApps showcase real-world applications of blockchain. By Uzma Jafar Key Takeaways Peer-to-peer networks enable decentralization. They eliminate reliance on centralized authorities, fostering trust and 1 transparency. Consensus algorithms ensure trust and security. They establish agreement among network participants, preventing 2 manipulation and fraud. 3 DApps are revolutionizing industries with decentralized technology. They offer new possibilities for efficiency, transparency, and accessibility. Introduction to Blockchain Networking Peer-to-peer (P2P) network architecture is fundamental to blockchain. Every node acts as both a client and a server, eliminating central authorities and ensuring decentralization. Nodes communicate directly to propagate data like transactions and blocks. This distributed network structure enhances security and resilience, making it difficult for any single entity to control or manipulate the blockchain. Examples: Bitcoin: Nodes verify transactions and propagate new blocks. Ethereum: Runs decentralized applications (DApps) via smart contracts. Ensuring Secure Peer-to-Peer Communication 1. Confidentiality 2. Integrity 3. Non-repudiation 4. Authentication 1. Confidentiality We have two people, A and B. A wants to send a message to B. This message could be something simple, like "Hi" or "Hello," or it could be highly sensitive, like bank details. If this information is sent over an open network, anyone could intercept and read it. For example, if A sends a message to B and someone like C intercepts it, C would be able to see the contents of the message. This is a situation we want to avoid. Regardless of whether the message is casual or confidential, we need to ensure that all data remains private and secure. 2. Integrity A wants to send a message to B. The message could be something as simple as “Hey, let’s take lunch around 1 p.m.” Now, while we don’t want anyone to see this message. However, C, a third party, intercepts the message. Not only does C read the message, but they also modify it to say, “Hey, let’s have dinner around 9 p.m.” This creates a serious problem: when B receives the message, it’s no longer the same as what A originally sent. This is an issue of data integrity. The original message has been tampered with during transmission. We must ensure that the data sent by A reaches B exactly as intended, without being altered by anyone else. 3. Non-Repudiation Suppose A sends a message to B saying, “Hey, let’s take lunch around 1 p.m.” B arrives at the meeting place, but A doesn’t show up. Later, A claims, “I never sent you that message!” This creates a problem because there’s no proof that A actually sent the message. To ensure non-repudiation, there must be a way to prove that A did indeed send the message. This means A cannot deny having sent it, and B can confidently verify the message's origin. This is crucial to avoid disputes and hold parties accountable for their actions. 4. Authentication B receives a message saying, “Hey, let’s take lunch around 1 p.m.,” and the message claims to be from A. But how can B be sure that A actually sent the message? What if C sent the message pretending to be A? Or what if someone else entirely is impersonating A? This creates a problem because there’s no guarantee of the sender's identity. We need to ensure that only A can send messages claiming to be from A, and no one else can impersonate them. This is where authentication becomes critical, as it verifies the true identity of the sender and ensures the message genuinely comes from who it claims to. Modern Cryptography Modern cryptography relies on the idea that some problems are so hard to solve that breaking them with current computers is nearly impossible. While these problems can theoretically be solved, it would take too much time and computing power to be practical. Cryptographic algorithms aim to balance security and efficiency by using complex math problems, like factoring large numbers or solving elliptic curve equations, that are tough for computers to crack. This is why cryptography often depends on key lengths and the time and cost it would take to break the encryption. There are three general classes of modern, software-based cryptography: 1. Hash functions 2. Symmetric encryption 3. Asymmetric encryption How Cryptography Works Together on Blockchain 1. Hashing: Creates a unique identifier for each block and transaction. 2. Cryptography: Focus on securing the communication and data within the blockchain. 3. Consensus: Ensures that all nodes agree on the validity of transactions and the order of blocks. Hash 1. Arbitrary Length 2. Hashing is not Encryption; it is one-way cryptographic function 3. Convert data GBs to Bits Famous Hashing Algorithms 1. MD (Message Digest) 2. MD2, MD3, MD5 etc 3. MD5 got attacked so people moves to SHA 4. SHA (Secure Hash Algorithem) designed by NSA (National Securitry Agency) SHA-1, SHA-2, etc. 5. SHA-2 was developed in 2001 as an improvement on SHA-1. Famous Hashing Algorithms Continue 6. The SHA-2 family consists of six hash functions with digests (hash values) that are 224, 256, 384 or 512 bits: 7. SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, SHA-512/256. 8. Each function has a different hash length and level of security. 9. SHA-256 is a cryptographic hash function that produces a 256-bit output value. 10. SHA-256 and SHA-512 are novel hash functions whose lengths are 256 bits and 512 bits, 32-byte and 64-byte, respectively. 11. Hashing is primarily used to verify data integrity. 12. Encryption is used to secure data confidentiality Hashing Encryption Node Communication in Blockchain 1 Communication Protocols 2 Transaction Broadcast Nodes in a blockchain network communicate using When a transaction occurs, it is broadcast to the network. protocols. These protocols enable nodes to share Nodes receive and validate the transaction. If the transaction information and maintain consistency in the ledger. One is valid, it is added to the mempool, or memory pool, a pool common protocol is the gossip protocol, where nodes of unconfirmed transactions. broadcast information to their peers. 3 Block Propagation 4 Synchronization Once a block is created, it is propagated to the network. Nodes synchronize with each other to ensure that they have Nodes receive and verify the block. If the block is valid, it is the same copy of the blockchain. This process helps maintain added to the blockchain. consistency and prevents forks in the blockchain. Introduction to Consensus Mechanisms Consensus mechanisms are essential for blockchain networks. They ensure that all nodes in the network agree on the current state of the blockchain. This agreement is crucial for maintaining the integrity and security of the blockchain. Consensus All nodes agree on the blockchain state. Fault Tolerance The network can continue operating even if some nodes fail. Resistance Protection against malicious actors trying to manipulate the blockchain. There are various consensus mechanisms, each with its own strengths and weaknesses. Some of the most common include Proof of Work (PoW), Proof of Stake (PoS), and other mechanisms like PBFT, DPoS, and Zero-Knowledge Proofs. Consensus in Blockchain Consensus is the process of achieving agreement across a decentralized network. This is crucial for blockchain technology, as it ensures that all participants have a shared and consistent view of the blockchain's state. One of the major challenges in achieving consensus is the Byzantine Generals Problem. This problem arises when some nodes in the network may be malicious or faulty, and their actions can disrupt the consensus process. Network latency is another challenge. In a decentralized network, messages can take time to travel between nodes, leading to delays in reaching consensus. Techniques like voting-based, stake-based, or computational work-based consensus algorithms address these challenges. Proof of Work (PoW) Proof of Work (PoW) is a computationally intensive process used to validate transactions on a blockchain. It involves solving a cryptographic puzzle, which requires significant computing power. This process ensures the security of the network by making it difficult for malicious actors to manipulate the blockchain. PoW is energy-intensive but highly secure. It has been used by prominent cryptocurrencies like Bitcoin and Ethereum (before the merge). While it offers robust security, PoW's energy consumption and slower transaction speeds are drawbacks. According to the Ethereum Foundation, the current Proof-of-Work system consumes roughly 5.13 gigawatts on a continuous basis, whereas the Proof-of- Stake system consumes only 2.62 MW, or about 99.95% less energy. Example: Bitcoin mining rewards (currently 6.25 BTC per block). 91 TWh 8 million More Energy Usage average U.S. Mining pools -> centralization households According to current estimates, Bitcoin mining consumes a significant amount of electricity, with estimations suggesting that it uses around 91 terawatt-hours (TWh) annually, which is comparable to the electricity usage of a country like Finland;meaning mining one Bitcoin can require a substantial amount of power depending on the mining setup and efficiency. Proof of Stake (PoS) Proof of stake (PoS) is a consensus mechanism used in blockchain networks to verify transactions. PoS is a way to select validators, or participants, to validate transactions and add them to the blockchain.Validators are chosen based on how much cryptocurrency they hold (escrow) and are rewarded with new cryptocurrency if they validate transactions correctly. To become a validator, a minimum of 32 ETH must be staked. The selection is based on the following: 1 Coin-age based selection 2 Random Block selection It combines the amount of cryptocurrency held by a user The validator is chosen with a combination of ‘lowest hash (stake) with the duration it has been held (age). value’ and ‘highest stake’. The node having the best For example, if you hold 10 coins for 30 days, your coin age is weighted-combination of these becomes the new validator. 10 × 30 = 300 coin-days. 1 Key advantages, Fast, Efficient & Scalability 2 Key Consideration Offers excellent network scalability while significantly While providing these advantages, there are potential reducing environmental impact through lower energy challenges regarding wealth concentration among major requirements. stakeholders. Note: PoS has no “miners” but instead has “validators” and it doesn’t let people “mine” blocks instead “mint” or “forge” blocks. Casper Proof of Stake (PoS) is implemented on Ethereum. Ethereum transitioned from Proof of Work (PoW) to Proof of Stake through the Ethereum Merge in September 2022. 51% If Bitcoin would be converted to proof-of-stake, acquiring 51% of all the coins would set you as of December 5, 2024, Bitcoin's market capitalization is approximately $2 trillion. Therefore, 51% of Bitcoin's market cap equals about $1.02 trillion. So the 51% attack is actually less likely to happen with proof-of-stake. Zero-Knowledge Proofs (ZKPs) What are ZKPs? Zero-knowledge proofs (ZKPs) are a cryptographic method where one party proves possession of information without revealing it. This is achieved through a series of interactions between the prover and the verifier. ZKPs are used in various applications, including privacy in transactions, identity verification, and secure computation. They offer enhanced privacy and verifiable information without disclosure. Zero-Knowledge Proofs (ZKPs) Types of ZKPs There are two main types of ZKPs: zk-SNARKs and zk-STARKs. zk- SNARKs are more efficient but require a trusted setup, while zk- STARKs are more transparent but computationally more demanding. ZKPs are a powerful tool for enhancing privacy and security in blockchain systems. They enable secure and verifiable transactions without compromising sensitive information. Alternative Consensus Algorithms Delegated Proof of Stake (DPoS) is a consensus mechanism where stakeholders vote for validators. This approach allows for faster transaction speeds and lower energy consumption compared to traditional Proof of Work (PoW) systems. Practical Byzantine Fault Tolerance (PBFT) is a consensus algorithm commonly used in private blockchains. It ensures that a network can operate reliably even if some nodes are malicious or faulty. PBFT is known for its high level of security and efficiency. Hybrid mechanisms combine elements of PoW and PoS to leverage the strengths of both approaches. These hybrid systems aim to achieve a balance between security, scalability, and energy efficiency. Byzantine Generals Problem What Are Distributed Applications DApps? Decentralized applications (DApps) run on blockchain networks. They are open-source, operate autonomously, and have a token-based economy. DApps are built on smart contracts, which are self- executing programs that automate transactions and agreements. Examples of DApps include DeFi platforms like Uniswap, which allow users to trade cryptocurrencies without intermediaries, and NFT marketplaces like OpenSea, where users can buy, sell, and trade non- fungible tokens. What Is Dapps Architecture? Decentralized Applications DApps are applications that run on a decentralized network, typically a blockchain. They are not controlled by a single entity, making them Examples of DApps resistant to censorship and Examples of DApps include downtime. decentralized exchanges, crypto wallets, and blockchain games. They offer new Open Source and Transparent possibilities for financial DApps are often open source, services, gaming, and more. meaning their code is publicly available for anyone to inspect and contribute to. This transparency fosters trust and accountability. Thank You!