From 0982690a9b5f199fb0eb6834ce6a5d85991d4061 Mon Sep 17 00:00:00 2001 From: Abhishek Harde <47945971+abhiyana@users.noreply.github.com> Date: Wed, 14 Jun 2023 15:43:30 +0530 Subject: [PATCH 1/6] Create README.md --- README.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..37268ec --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +# evaluation +This repository contrain Assessment Submission of task given by HogoByte. + +# Blockchain Ledger +This is a simple implementation of a blockchain ledger in C++. It allows you to add transactions, create blocks, validate the ledger, and print the ledger. + +## Prerequisites +To compile and run this code, you need to have the following installed on your system: + +- C++ compiler (supporting C++11 or later) +- OpenSSL library + + +## Compilation +To compile the code, follow these steps: + +1. Clone the repository or download the source code files. +2. Open a terminal or command prompt. +3. Navigate to the directory where the source code files are located. +4. Run the following command to compile the code: + - g++ blockchain.cpp -o program -lssl -lcrypto (This command uses the g++ compiler, sets the C++ version to C++11, and links against the OpenSSL library.) + +## Execution +1. Open a terminal or command prompt. +2. If there are no compilation errors, an executable file named `program` will be generated in the same directory. + Navigate to the directory where the `blockchain` executable is located. + - ./program + +## Usage +Here's a brief description of the available operations: + +1. **Add Transaction**: Allows you to add a transaction to the transaction pool. +2. **Add Block**: Creates a new block with the transactions in the transaction pool and adds it to the blockchain. +3. **Validate Ledger**: Checks the integrity and validity of the blockchain. +4. **Print Ledger**: Displays the entire blockchain with block details and transactions. +5. **Exit**: Quits the program. + + + From e614544f2624e0c8f56f8598347e78cdd1abbe4f Mon Sep 17 00:00:00 2001 From: Abhishek Harde <47945971+abhiyana@users.noreply.github.com> Date: Wed, 14 Jun 2023 15:44:32 +0530 Subject: [PATCH 2/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 37268ec..0732a96 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ To compile the code, follow these steps: ## Execution 1. Open a terminal or command prompt. 2. If there are no compilation errors, an executable file named `program` will be generated in the same directory. - Navigate to the directory where the `blockchain` executable is located. + Navigate to the directory where the `program` executable is located. - ./program ## Usage From a150ecd6502d7f72ed5b2e520985dc24a2498524 Mon Sep 17 00:00:00 2001 From: abhiyana Date: Wed, 14 Jun 2023 19:45:35 +0530 Subject: [PATCH 3/6] Added Solution --- Solution/block.cpp | 3 + Solution/block.h | 17 ++ Solution/blockchain.cpp | 201 ++++++++++++++++++++ Solution/blockchain.h | 24 +++ Solution/financial_transactions_security.md | 34 ++++ Solution/program | Bin 0 -> 31960 bytes Solution/transaction.cpp | 3 + Solution/transaction.h | 13 ++ 8 files changed, 295 insertions(+) create mode 100644 Solution/block.cpp create mode 100644 Solution/block.h create mode 100644 Solution/blockchain.cpp create mode 100644 Solution/blockchain.h create mode 100644 Solution/financial_transactions_security.md create mode 100755 Solution/program create mode 100644 Solution/transaction.cpp create mode 100644 Solution/transaction.h diff --git a/Solution/block.cpp b/Solution/block.cpp new file mode 100644 index 0000000..0c58724 --- /dev/null +++ b/Solution/block.cpp @@ -0,0 +1,3 @@ +#include "block.h" + +// No additional implementation required for the block structure diff --git a/Solution/block.h b/Solution/block.h new file mode 100644 index 0000000..8805451 --- /dev/null +++ b/Solution/block.h @@ -0,0 +1,17 @@ +#ifndef BLOCK_H +#define BLOCK_H + +#include +#include "transaction.h" + +struct Block { + int index; + std::string blockHash; + std::string previousHash; + TransactionNode* transactions; + Block* previousBlock; + + Block() : transactions(nullptr), previousBlock(nullptr) {} +}; + +#endif // BLOCK_H diff --git a/Solution/blockchain.cpp b/Solution/blockchain.cpp new file mode 100644 index 0000000..9bc775c --- /dev/null +++ b/Solution/blockchain.cpp @@ -0,0 +1,201 @@ +#include "blockchain.h" +#include +#include +#include +#include +#include + +using namespace std; + +Blockchain::Blockchain() { + + //Initialize the transactionPool to nullptr + transactionPool = nullptr; + + // Initialize the chain with a genesis block + chainHead = new Block; + chainHead->index = 0; + chainHead->blockHash = calculateHash(""); + chainHead->previousHash = ""; + chainHead->transactions = nullptr; +} + +Blockchain::~Blockchain() { + // Delete the blockchain chain + Block* currentBlock = chainHead; + while (currentBlock != nullptr) { + TransactionNode* currentTransaction = currentBlock->transactions; + while (currentTransaction != nullptr) { + TransactionNode* nextTransaction = currentTransaction->next; + delete currentTransaction; + currentTransaction = nextTransaction; + } + Block* nextBlock = currentBlock->previousBlock; + delete currentBlock; + currentBlock = nextBlock; + } +} + +void Blockchain::addBlock(TransactionNode* transactions) { + // Create a new block + Block* newBlock = new Block; + + // Concanate all transactions to stringBuilder and calculate Hash + TransactionNode* tempHead = transactions; + string transactionBuilder = ""; + while(tempHead != NULL) { + transactionBuilder += tempHead->transaction; + tempHead = tempHead->next; + } + string blockHash = calculateHash(transactionBuilder); + + // new block have it's own hash and previous block hash + newBlock->blockHash = blockHash; + newBlock->previousHash = chainHead->blockHash; + newBlock->transactions = transactions; + newBlock->index = chainHead->index + 1; + + // Update the chain head + newBlock->previousBlock = chainHead; + chainHead = newBlock; + + // Remove old transactions + transactionPool = nullptr; + cout<<"Block successfully added to Blockchain..."<next = transactionPool; + transactionPool = newTransaction; + cout<<"Transaction Successfully added.."<previousBlock != nullptr) { + //calculate hash of previous block + TransactionNode* transactionhead = currentBlock->previousBlock->transactions; + string transactions = ""; + while(transactionhead != NULL) { + transactions += transactionhead->transaction; + transactionhead = transactionhead->next; + } + + string prevBlockHash = calculateHash(transactions); + + if (currentBlock->previousHash != prevBlockHash) { + return false; // Invalid chain + } + currentBlock = currentBlock->previousBlock; + } + + return true; // return true if Valid chain +} + + + + +void Blockchain::printChain() const { + Block* currentBlock = chainHead; + while (currentBlock != nullptr) { + cout << "Block Index: " << currentBlock->index << endl; + cout << "Block Hash: " << currentBlock->blockHash << endl; + cout << "Previous Hash: " << currentBlock->previousHash << endl; + + cout << "Transactions:" << endl; + TransactionNode* currentTransaction = currentBlock->transactions; + while (currentTransaction != nullptr) { + cout << " - " << currentTransaction->transaction << endl; + currentTransaction = currentTransaction->next; + } + + cout << "------------------------" << endl; + cout<previousBlock; + } +} + + + +string Blockchain::calculateHash(const string& data) const { + EVP_MD_CTX* mdContext = EVP_MD_CTX_new(); + + EVP_DigestInit(mdContext, EVP_sha256()); + EVP_DigestUpdate(mdContext, data.c_str(), data.length()); + + unsigned char hash[EVP_MAX_MD_SIZE]; + unsigned int hashLength; + EVP_DigestFinal(mdContext, hash, &hashLength); + + EVP_MD_CTX_free(mdContext); + + stringstream ss; + ss << hex << setfill('0'); + for (unsigned int i = 0; i < hashLength; ++i) { + ss << setw(2) << static_cast(hash[i]); + } + + return ss.str(); +} + + + +//main function +int main() { + cout << "Starting Blockchain Ledger..." << endl; + Blockchain blockchain; + + while (true) { + int inputNumber; + cout << "Enter a number to perform an operation:" << endl; + cout << "1: Add Transaction" << endl; + cout << "2: Add Block" << endl; + cout << "3: Validate Ledger" << endl; + cout << "4: Print Ledger" << endl; + cout << "5: Exit" << endl; + cin >> inputNumber; + cout< +#include "block.h" +#include "transaction.h" + +class Blockchain { +private: + Block* chainHead; +public: + TransactionNode* transactionPool; + Blockchain(); + ~Blockchain(); + void addBlock(TransactionNode* transactions); + void addTransaction(const std::string& transaction); + bool validateChain() const; + void printChain() const; + +private: + std::string calculateHash(const std::string& data) const; +}; + +#endif // BLOCKCHAIN_H diff --git a/Solution/financial_transactions_security.md b/Solution/financial_transactions_security.md new file mode 100644 index 0000000..d6c2df5 --- /dev/null +++ b/Solution/financial_transactions_security.md @@ -0,0 +1,34 @@ +# Introduction +Blockchain technology has gained significant attention in recent years, particularly in the realm of financial transactions. This report aims to discuss the security implications of utilizing a blockchain for financial transactions. We will explore the key security considerations and benefits offered by blockchain technology in this context. + +## 1. Immutable Transaction History +One of the fundamental security benefits of a blockchain is its immutability. Once a transaction is added to the blockchain, it becomes extremely difficult to alter or tamper with. This property ensures the integrity of financial transactions, reducing the risk of fraudulent activities and unauthorized modifications. + +## 2. Distributed Consensus +Blockchain relies on distributed consensus mechanisms, such as proof-of-work or proof-of-stake, to validate and verify transactions. This decentralized approach eliminates the need for a central authority, reducing the vulnerability to single points of failure and potential attacks. Consensus mechanisms ensure that a majority of participants in the network agree on the validity of transactions, making it difficult for malicious actors to manipulate the system. + +## 3. Cryptographic Security +Blockchain utilizes strong cryptographic algorithms to secure transactions. Transactions are digitally signed, ensuring the authenticity and integrity of the involved parties. Cryptographic hashing algorithms, such as SHA-256, are used to create unique transaction identifiers, providing a high level of data integrity and preventing data manipulation. + +## 4. Transparency and Auditability +Blockchain's transparent nature allows all participants to view and verify transactions. This transparency enhances accountability and helps detect and prevent fraudulent activities. Additionally, the auditability of blockchain enables easy tracing and tracking of transactions, contributing to regulatory compliance and reducing the risk of money laundering and other illicit activities. + +## 5. Smart Contract Security +Smart contracts, executable code stored on the blockchain, enable the automation and enforcement of financial agreements. However, they introduce their own security considerations. Flaws in smart contracts can lead to vulnerabilities and potential exploits. Thorough code audits, formal verification techniques, and adherence to best practices are essential to mitigate these risks. + +## 6. Network Security +The security of a blockchain network depends on the underlying consensus mechanism and the robustness of its nodes. Proof-of-work mechanisms, such as those used in Bitcoin, require significant computational power to launch a successful attack. However, alternative consensus mechanisms, such as proof-of-stake or delegated proof-of-stake, introduce different security considerations that need to be carefully evaluated. + +## 7. External Security Threats +While blockchain technology itself provides strong security measures, it does not eliminate the risk of external threats. Users' private keys, used to sign transactions, must be securely stored to prevent unauthorized access. Malware, phishing attacks, and social engineering are potential risks that can compromise the security of blockchain-based financial transactions. Educating users about these risks and promoting secure practices is crucial. + +# Conclusion +Utilizing a blockchain for financial transactions offers several security advantages over traditional centralized systems. Its immutability, distributed consensus, cryptographic security, transparency, and auditability contribute to enhancing the integrity, accountability, and trustworthiness of financial transactions. However, it is important to acknowledge that blockchain technology is not immune to all security risks, and additional measures, such as secure key management and user awareness, are essential for a holistic security approach. + +By understanding the security implications and taking appropriate precautions, blockchain technology can play a pivotal role in revolutionizing the security and efficiency of financial transactions, leading to increased trust, reduced fraud, and enhanced financial inclusion. + +## References +- https://consensys.net/blockchain-use-cases/finance/ +- https://www.salesforce.com/eu/blog/2020/02/how-financial-services-are-implementing-blockchain-technology.html +- https://www.leewayhertz.com/10-use-cases-of-blockchain-in-finance/ + diff --git a/Solution/program b/Solution/program new file mode 100755 index 0000000000000000000000000000000000000000..78884924f040c339f167342af35040ad493302b5 GIT binary patch literal 31960 zcmeHweSDPFmH(Yd0ujLkD>jOi@daOs#7sy45i}46C*{SF5KCL=lgVU~OieOzULdj3 z#*L|rF&b^P*t#ut+qJE>;%>EUD}2!PZD$m^>SpJLu*C;p)aIEpKQclVxlDVBy$mIP?j5% z zC?o|{eb=CzGL_)?@K0$@wo%q+*AGi&1q#aQ*`iNV&dQ%zVp+xdzmz($%xFQ~I567KO2Rk35R-`h3{@|~hqW4U9mfW@C<~h4& zmdmV+-~lw?)C@TnKzK$vl*~jw8RH-m{dqJX6TQKv-bFU`&Y6)}&RI6}$6>Tg_5KWo z%S1n8dS-g14SgR5P$oHsO?#Vc?DL)teZZ#P3vBocZQ7M{n!xW$dZ=K5HJXWP`YSz^GV{+J(X zOih5>4G95%i$4&GwRxJjkPw=+F@(#?SR)!f(Gs4Gpe+*i3d3MQe^bRKV^fjgsa$MS z#!8LKU~Kz`loyt?7qZ0IxYoXFDoc#YQe%_b@OV&1ZKH3SP&?ch^^n#ZxcJrXsoJz$ zl&p-E1efk>7>R~4w_vOo+lnkbaDo#EB%*hDS(;E}SEQNo1SOU5kb^EivzrAyyYpRTr30>B48M6PvICn=oCK8lo?nw~IL>mOczr=S+TH zzl?@6+%y*SY;1yTK5`<#SVJUCGvgFI(HxSKpIa6|nP@O($hAf`b+Rj8%R1A{y84qE z^BGv7&MjO>XFv(Be>ib2uU@n9`7p zhHl`cd4FU5NX?U#YAQ|nSS41>sW}67A?uCCaKPUvmVX*XaQn*)gL@dV>amvzMk3*e znrtTTHpRxuM$}<6gs^GDQ1AsX%obrTtZLpKLen+|qw%Jo^zAy@bD{A-aodCD7TWYR z`DuOO#=uZ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ok^_L=%f+K`Q-9Siyq0C^&I`(qhOOdam1X>? WdKE8T^T=5K$5Fv?iKT!AW&aB?mV|!* literal 0 HcmV?d00001 diff --git a/Solution/transaction.cpp b/Solution/transaction.cpp new file mode 100644 index 0000000..69965fc --- /dev/null +++ b/Solution/transaction.cpp @@ -0,0 +1,3 @@ +#include "transaction.h" + +// No additional implementation required for the transaction structure diff --git a/Solution/transaction.h b/Solution/transaction.h new file mode 100644 index 0000000..ee2b401 --- /dev/null +++ b/Solution/transaction.h @@ -0,0 +1,13 @@ +#ifndef TRANSACTION_H +#define TRANSACTION_H + +#include + +struct TransactionNode { + std::string transaction; + TransactionNode* next; + + TransactionNode(const std::string& transaction) : transaction(transaction), next(nullptr) {} +}; + +#endif // TRANSACTION_H From cc1bf59efc1b6082e88323d83c265ad41e057443 Mon Sep 17 00:00:00 2001 From: Abhishek Harde <47945971+abhiyana@users.noreply.github.com> Date: Wed, 14 Jun 2023 20:27:56 +0530 Subject: [PATCH 4/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0732a96..5c4cb0d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# evaluation +# Introduction This repository contrain Assessment Submission of task given by HogoByte. # Blockchain Ledger From 4aca383d8b7a48d56bff94192346fec305ca3381 Mon Sep 17 00:00:00 2001 From: Abhishek Harde <47945971+abhiyana@users.noreply.github.com> Date: Wed, 14 Jun 2023 20:28:23 +0530 Subject: [PATCH 5/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5c4cb0d..ce7f90d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Introduction This repository contrain Assessment Submission of task given by HogoByte. -# Blockchain Ledger +## Blockchain Ledger This is a simple implementation of a blockchain ledger in C++. It allows you to add transactions, create blocks, validate the ledger, and print the ledger. ## Prerequisites From 5c294e95a7d721c861d7c8ec895b8cc922750bf6 Mon Sep 17 00:00:00 2001 From: Abhishek Harde <47945971+abhiyana@users.noreply.github.com> Date: Wed, 14 Jun 2023 20:30:20 +0530 Subject: [PATCH 6/6] Update README.md --- README.md | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/README.md b/README.md index ce7f90d..997fb5f 100644 --- a/README.md +++ b/README.md @@ -35,5 +35,83 @@ Here's a brief description of the available operations: 4. **Print Ledger**: Displays the entire blockchain with block details and transactions. 5. **Exit**: Quits the program. +## Example +Starting Blockchain Ledger... + +Enter a number to perform an operation: +1: Add Transaction +2: Add Block +3: Validate Ledger +4: Print Ledger +5: Exit + +1 + +Enter Transaction: Abhishek to Rajat, 50 INR +Transaction Successfully added.. + +Enter a number to perform an operation: +1: Add Transaction +2: Add Block +3: Validate Ledger +4: Print Ledger +5: Exit + +1 + +Enter Transaction: Abhishek to Swapnil, 40 INR +Transaction Successfully added.. + +Enter a number to perform an operation: +1: Add Transaction +2: Add Block +3: Validate Ledger +4: Print Ledger +5: Exit + +2 + +Block successfully added to Blockchain... + +Enter a number to perform an operation: +1: Add Transaction +2: Add Block +3: Validate Ledger +4: Print Ledger +5: Exit + +4 + +Block Index: 1 +Block Hash: 2f64366f6d4433eaf48293313f1f82668afcee78f5f0394042dda4327a20cc8e +Previous Hash: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 +Transactions: + - Abhishek to Swapnil, 40 INR + - Abhishek to Rajat, 50 INR +------------------------ +Block Index: 0 +Block Hash: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 +Previous Hash: +Transactions: + +------------------------- +Enter a number to perform an operation: +1: Add Transaction +2: Add Block +3: Validate Ledger +4: Print Ledger +5: Exit + +3 + +Blockchain is valid. + +Enter a number to perform an operation: +1: Add Transaction +2: Add Block +3: Validate Ledger +4: Print Ledger +5: Exit +