Chapter 1: Introduction - RapsLepeli/Proof-of-Work-Implementation GitHub Wiki
Chapter 1: Introduction
Chapter 1: Introduction discusses the Problem statement, Scope of the Project, Limitations of the project and the document overview.
1.1 Introduction
Blockchain technology has revolutionized trust and security in the digital age. It is built upon decentralized networks and uses cryptography and consensus algorithms to ensure the integrity and authenticity of information. It has applications ranging from cryptocurrencies to supply chain management. It has the potential to transform industries and reshape the future of trust. When Algorithms provide this trust, it is called "Algorithmic Trust". Algorithmic Trust has several advantages over third-party or centralized trust, such as efficiency, transparency, security, and global accessibility (Vadapalli, 2022). Blockchain systems can streamline processes and eliminate the need for intermediaries, reducing costs and increasing efficiency. They can also be used to verify and audit transactions independently, reducing reliance on trust in centralized authorities (Vadapalli, 2022).
Blockchain systems are distributed systems that utilize a combination of technologies such as distributed ledgers, cryptography, and consensus algorithms to record immutable transactions on a distributed ledger. However, Blockchain systems face many challenges regarding algorithmic trust/consensus algorithms, such as high energy consumption, centralized control, reliance on third parties for security, participation unfairness, non-deterministic inefficient solutions to security, and time-consuming processes (Marin, 2018). The PoW consensus algorithm was chosen for this project as it is a widely used algorithm for Blockchain systems. It has high levels of security, allows block proposers to earn cryptocurrency rewards, and provides a decentralized method of verifying transactions.
1.2 Problem Statement
The system built in this project is named Blockchain: Proof-of-Work Consensus Algorithm Implementation (PoW Implementation). The project aims to implement a Blockchain Proof-of-Work (PoW) consensus algorithm to verify, validate, and complete transactions. A fully functional Blockchain system will include a data structure to record the transactions, the PoW consensus algorithm, a transaction, and a simple peer-to-peer network that simulates nodes or computers (wallets) participating in the Transaction.
An entire blockchain system will be built from scratch and used for research and testing. It will simulate how a fully functional blockchain system works; however, it will require minimal human interaction as all the essential functions of a blockchain system will be automated. This means multiple computers will not need to be set up to act as nodes participating in the Blockchain. Instead of having multiple computers act as nodes, multiple instances of the PoW Implementation are to be run on the same computer, and each instance of the application will act as its computer. The system built in this project is for testing purposes. It can be used as a data-capturing system for a new Blockchain consensus algorithm called Proof-of-Publicly Verifiable Randomness (PoPVR). However, this will be done for future research and will not be the focus of this project.
1.3 Scope of Project
The PoW implementation system built in this project will simulate a fully functional permissionless blockchain system. This system is for benchmarking and gaining a deep and complete understanding of how blockchain systems function. It will heavily focus on the PoW consensus algorithm, its implementation, and how it handles transactions.
The system to be developed will include the following: • A distributed blockchain data structure. The blockchain data structure is an ordered, back-linked list of blocks containing transactions. It can be stored in a simple database or as a file. A hash generated by the cryptographic hash technique SHA256 on the block header identifies each Block. For example, in the "prev block hash" field of the block header, each Block refers to a preceding block called the parent block (Marin, 2018). SHA256 stands for Secure hash algorithm with a length of 256 bits. It was developed by the US's National Security Agency in 2001 and is known as a one-way cryptographic function. This means it can encrypt data but not decrypt it back to its original form. Each Block contains the previous hash block and its hash (Fireship.IO, 2021). A single block also contains a timestamp of when it was created so that all blocks in the chain are placed chronologically. Before a block is added to the Blockchain, it is verified by other participants in the system. This ledger records all transactions in this system; only a single instance exists Figure 1 1 shows what a general blockchain data structure looks like
Figure 1 1: General Blockchain Data Structure
• A Peer-to-Peer network. Message passing on a blockchain network occurs over a peer-to-peer (P2P) network; P2P is a well-known network topology. P2P refers to a decentralized topology where nodes collaborate to share resources and services without a central authority to coordinate the processes (Blockchain Council, 2019). Each participant is a wallet, and this Wallet defines the participant's identity. Each Wallet has a public key (for receiving money) and a private key (for spending money). The Pubic-Private key pair is generated using a hashing technique called RSA (Rivest-Shamir-Adleman). Unlike SHA256, this full encryption algorithm can encrypt and decrypt data if one has the proper key (Fireship.IO, 2021).
To encrypt data, a public key is used. It converts the data into ciphertext, an unreadable version of the original data. The corresponding private key can fully decrypt the data back to its original form. However, the Pubic-Private key pair creates a digital signature in this instance. Instead of encrypting the data (Transaction), a hash of that data is created, and the hash is signed using a private key. Others can then verify the data by using the public key of the person who initiated it to check if it is valid. This means if by any chance another participant tempers with transaction data, verification will not work as the Transaction is untrustworthy. This means no one can temper the transaction message since it was signed. The Wallet can receive money and spend/send money. The developed simple P2P network simulates how it would function in a blockchain system Figure 1 2 Shows what a general P2P network looks like:
Figure 1 2:Simple P2P Network
• A consensus algorithm: Proof-of-Work (PoW) is the mechanism of choice for most cryptocurrencies (Geeks for Geeks, 2019) and in this project. The algorithm will verify transactions and add blocks to the blockchain data structure. This consensus forces each new Block to go through a mining process, where a difficult mathematical challenge is solved to confirm that the Block is valid. Once this problem has been solved, it is effortless to verify. Multiple nodes/participants compete to solve this challenge, which works like a lottery. The winner of the lottery gets rewards for solving the complex problem. This process is very resource-intensive and inefficient and takes a long time to complete. The problem states: find a hash for this Block, starting with five zeros or any number the Tester chooses. The only way to find this is through brute force and multiple hash computations. The system or the Tester automatically decides the problem's difficulty (the number of zeros that proceed to a hash). The hash is calculated using the MD5(Message-Digest) Algorithm. It is very similar to the SHA256 technique but faster and only 128 bits in length. Figure 1 3 Shows the results of PoW, where the correct block proposer solves a hash calculation before other network participants.
Figure 1 3:PoW Results
• A transaction. Refers to the action of transferring funds from one participant to another. A Transaction consists of the amount (can be Bitcoin, Firecoin, or just plain money) transferred, the payer and the payee. The Tester will decide how many wallets exist in the application during runtime. The wallets will then be allowed to send money to each other using their public keys. Every time a transaction starts, it will be hashed, signed, and sent into the system. The system will require the participants to verify the Transaction and then require a block. The Block will be created(mined) using the Tester's complex set beforehand. Once the Block is mined, it will be added to the single instance of the Blockchain.
1.4 Limitations of the Project
The developed system will have a minimal user interface due to the focus on the backend and the PoW algorithm to be implemented. It will consider that the end user already understands the purpose of the system, which is simulating transactions on the Blockchain and using the proposed algorithm as a consensus for algorithmic trust. Most of the parts in the system will be automated, so end users will not necessarily be the focus. This applies to the automated P2P network and wallets that do not require human interaction. The system will be able to run on any machine as it will be developed using the cross-platform .net core framework; however, it will only be limited to the Windows operating system for testing purposes. The minimum requirements for running the system: • Windows 10 operating system • Intel core I5 7th gen / AMD 2nd and 3rd Gen CPU’s • 8 Gb DDR4 Ram • 120Gb SSD • Access to the internet The system will run independently and not integrate with existing blockchain systems. It will only output the critical parts of a transaction, including transaction creation, hash generation, block addition and verification. The user interface is minimal, and the system will only output the critical parts of a transaction, such as transaction creation, hash generation, block addition and block verification. The system will handle user errors, such as transferring assets from one account to another, without considering that the first account might have insufficient funds and alert the user if they generate such errors. These user errors will not affect the system's performance since the core of the system is handling, processing, and completing correct instructions.
1.5 Document Overview
Chapter 1: Introduction
The introductory chapter provided an overview of the system, highlighting the problems prevalent in the current environment and the limitations of the solutions. The chapter also provided a brief description of the system. It also looked at the scope of the project's limitations and included a document overview.
Chapter 2: Literature Review
The literature review chapter will entail a comparative discussion of the existing consensus algorithms and the available technology. Introduce the terminology to be used. The discussion will provide sufficient background about the system to lay a solid foundation for the chapters that follow the literature review chapter.
Chapter 3: Requirements and analysis workflow
Chapter 3 is about the requirements and analysis workflow; the system's use cases will be described in this chapter, as well as the different scenarios in which the system will be used in the physical environment.
Chapter 4: Architectural Design
The architectural design chapter will provide an architectural layout of the system. The layout will encompass class diagrams to demonstrate how the system is interlinked. In addition, a database design will be included that will focus on the elements of the database. It will display the design of the database and the description thereof.
Chapter 5: Evaluation
The evaluation chapter will describe how the prospective users of the system evaluated the prototype. The chapter will also include the results of the evaluation and the corrective measures that were taken to address the problems that were encountered during the evaluation. Chapter 6: Source Code and Implementation The final chapter, chapter 6, will provide the code snippets of the system's most exciting and complex parts and the source code. The chapter will also explain the complexities of the code snippets.
1.6 Summary
Chapter 1: Introduction discusses the Problem statement, Scope of the Project, Limitations of the project and the document overview. Chapter 2: Literature review focuses on a comparative discussion of the existing systems and available technology, defines the terminology for the project, gives a sufficient background for the project, and gives a solid foundation for the system built in the project.