From 83934fad4d61b1fd5ed7476e2f9886b8b21689bb Mon Sep 17 00:00:00 2001 From: Chai-k <141635030+Chai-k@users.noreply.github.com> Date: Thu, 10 Aug 2023 13:13:28 +0530 Subject: [PATCH 1/7] Create app.java --- K Chaitra/app.java | 114 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 K Chaitra/app.java diff --git a/K Chaitra/app.java b/K Chaitra/app.java new file mode 100644 index 0000000..f734a4d --- /dev/null +++ b/K Chaitra/app.java @@ -0,0 +1,114 @@ +package startproject; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.List; + +class Transaction { + String sender; + String receiver; + double amount; + long timestamp; + + public Transaction(String sender, String receiver, double amount) { + this.sender = sender; + this.receiver = receiver; + this.amount = amount; + this.timestamp = System.currentTimeMillis(); + } +} + +class Block { + int indexValue; + String previoushashKey; + List transactions; + String hashKey; + long timestamp; + + public Block(int indexValue, String previoushashKey, List transactions) { + this.indexValue = indexValue; + this.previoushashKey = previoushashKey; + this.transactions = transactions; + this.timestamp = System.currentTimeMillis(); + this.hashKey = calculatehashKey(); + } + + String calculatehashKey() { + try { + MessageDigest digest = MessageDigest.getInstance("SHA-256"); + String data = indexValue + previoushashKey + transactions.toString() + timestamp; + byte[] hashKeyBytes = digest.digest(data.getBytes()); + + StringBuilder hexString = new StringBuilder(); + for (byte hashKeyByte : hashKeyBytes) { + String hex = Integer.toHexString(0xff & hashKeyByte); + if (hex.length() == 1) hexString.append('0'); + hexString.append(hex); + } + + return hexString.toString(); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + return null; + } + } +} + +class Blockchain { + private List chain; + + public Blockchain() { + chain = new ArrayList<>(); + chain.add(createGenesisBlock()); + } + + private Block createGenesisBlock() { + return new Block(0, "0", new ArrayList<>()); + } + + public Block getLatestBlock() { + return chain.get(chain.size() - 1); + } + + public void addBlock(List transactions) { + int indexValue = chain.size(); + String previoushashKey = getLatestBlock().hashKey; + + Block newBlock = new Block(indexValue, previoushashKey, transactions); + chain.add(newBlock); + } + + public boolean isValid() { + for (int i = 1; i < chain.size(); i++) { + Block currentBlock = chain.get(i); + Block prevBlock = chain.get(i - 1); + + if (!currentBlock.hashKey.equals(currentBlock.calculatehashKey()) || + !currentBlock.previoushashKey.equals(prevBlock.hashKey)) { + return false; + } + } + return true; + } +} + +public class HugoByteBlockChain { + + public static void main(String[] args) { + Blockchain blockchain = new Blockchain(); + + List transactions = new ArrayList<>(); + transactions.add(new Transaction("Chaitra", "Harish", 20.0)); + transactions.add(new Transaction("Harish", "Sunil", 5.0)); + transactions.add(new Transaction("Sunil", "Chaitra", 3.0)); + + blockchain.addBlock(transactions); + + if (blockchain.isValid()) { + System.out.println("Blockchain is valid."); + } else { + System.out.println("Blockchain is not valid."); + } + } +} From 751418d59012818f6e13af4e40e90e46137d685a Mon Sep 17 00:00:00 2001 From: Chai-k <141635030+Chai-k@users.noreply.github.com> Date: Thu, 10 Aug 2023 13:14:20 +0530 Subject: [PATCH 2/7] Create README.md --- K Chaitra/README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 K Chaitra/README.md diff --git a/K Chaitra/README.md b/K Chaitra/README.md new file mode 100644 index 0000000..3388320 --- /dev/null +++ b/K Chaitra/README.md @@ -0,0 +1,2 @@ +K# evaluation +For assignment From ee5e18173093e69d05a63a4374c2ccf02ab9f2d0 Mon Sep 17 00:00:00 2001 From: Chai-k <141635030+Chai-k@users.noreply.github.com> Date: Thu, 10 Aug 2023 13:17:48 +0530 Subject: [PATCH 3/7] Update README.md --- K Chaitra/README.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/K Chaitra/README.md b/K Chaitra/README.md index 3388320..c8831eb 100644 --- a/K Chaitra/README.md +++ b/K Chaitra/README.md @@ -1,2 +1,18 @@ -K# evaluation -For assignment +Steps to Compile and run the Java Code + +======================================================================= + +Step 1 : Write a program on the notepad and save it with .java extension(for example, DemoFile.java) . + +Step 2 : open Command prompt. + +Step 3 : Set the directory in which the .java file is saved. + +Step 4 : Use the "javac" command to compile the Java program. It generates a .class file in the same folder. It also shows an error if any. + --> javac DemoFile.java + +Step 5 : Use the "java" command to run the Java program. + --> java DemoFile + + +======================================================================= From a7e7fec2478c5c354cd28c1ce5a2b3d7327bf7e0 Mon Sep 17 00:00:00 2001 From: Chai-k <141635030+Chai-k@users.noreply.github.com> Date: Thu, 10 Aug 2023 13:19:33 +0530 Subject: [PATCH 4/7] Create Security-implications.txt --- K Chaitra/Security-implications.txt | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 K Chaitra/Security-implications.txt diff --git a/K Chaitra/Security-implications.txt b/K Chaitra/Security-implications.txt new file mode 100644 index 0000000..a40a30c --- /dev/null +++ b/K Chaitra/Security-implications.txt @@ -0,0 +1,30 @@ +Security Implications of Using Blockchain for Financial Transactions: + +1. Immutability: The immutability of blockchain ensures that past transactions cannot be altered, providing a high level of security against fraudulent activities and unauthorized modifications. + +2. Transparency: All participants in the network have access to the entire transaction history. This transparency can help prevent fraudulent activities and ensure accountability among participants. + +3. Decentralization: The decentralized nature of blockchain reduces the risk of single points of failure, making it more resilient against cyberattacks and data breaches.A decentralized blockchain network distributes control and decision-making power among participants. + +4. Cryptographic Security: Blockchain uses cryptographic techniques to secure transactions and ensure confidentiality, integrity, and authenticity. This includes hashing algorithms for block integrity and digital signatures for transaction authentication. + +5. Reduced Intermediaries: Blockchain has the potential to eliminate or minimize intermediaries in financial transactions, reducing associated risks and costs. + +6. Trustless Transactions: Blockchain enables trustless transactions, where parties do not need to trust a central authority. Instead, they rely on the consensus protocol and cryptographic proofs to verify transactions. + +7. Consensus Mechanisms: The choice of consensus mechanism (e.g., Proof of Work, Proof of Stake) impacts the security and performance of the blockchain network. Each mechanism has its strengths and weaknesses, and the security implications may vary accordingly. The security and effectiveness of these mechanisms are crucial for preventing attacks and ensuring fair participation. + +8. Smart Contract Security: Smart contracts, self-executing code on the blockchain, can have vulnerabilities that could lead to financial losses if exploited. Careful development, testing, and auditing of smart contracts are crucial for secure financial transactions. + +9. Private Keys and Wallet Security: Users must protect their private keys and wallets diligently. Losing a private key can result in permanent loss of access to funds. + +10. 51% Attack: In proof-of-work blockchains, a malicious entity controlling 51% or more of the network's computing power could potentially manipulate the chain. However, this is generally less feasible for well-established and widely adopted blockchains. + +11. Regulatory Compliance: While blockchain offers enhanced security, financial institutions using blockchain for transactions must also comply with existing regulations, including anti-money laundering (AML) and know-your-customer (KYC) requirements. + +12. Scalability and Performance: As the number of transactions increases, scalability and performance become critical. High transaction fees or slow confirmation times could impact the usability and attractiveness of blockchain for financial transactions. + +13. Upgrades and Forks: Blockchain networks may undergo upgrades or forks, which could introduce new security considerations and risks during the transition. + + +In conclusion, blockchain technology has the potential to revolutionize financial transactions by providing security, transparency, and decentralization. However, proper implementation, continuous security audits, and adherence to regulatory requirements are essential for realizing its full potential in the financial sector. As with any technology, careful consideration of the specific use case and understanding the security implications are crucial for successful and secure blockchain adoption. From ba1b71476ede6d98ac5f143dcfa6ea3cc95738e5 Mon Sep 17 00:00:00 2001 From: Chai-k <141635030+Chai-k@users.noreply.github.com> Date: Thu, 10 Aug 2023 13:19:55 +0530 Subject: [PATCH 5/7] Update README.md --- K Chaitra/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/K Chaitra/README.md b/K Chaitra/README.md index c8831eb..380d714 100644 --- a/K Chaitra/README.md +++ b/K Chaitra/README.md @@ -9,7 +9,7 @@ Step 2 : open Command prompt. Step 3 : Set the directory in which the .java file is saved. Step 4 : Use the "javac" command to compile the Java program. It generates a .class file in the same folder. It also shows an error if any. - --> javac DemoFile.java + --> javac DemoFile.java Step 5 : Use the "java" command to run the Java program. --> java DemoFile From dec7291d4fedf0c0cc7cd477a3e3252ba15b6833 Mon Sep 17 00:00:00 2001 From: Chai-k <141635030+Chai-k@users.noreply.github.com> Date: Thu, 10 Aug 2023 13:20:22 +0530 Subject: [PATCH 6/7] Update README.md --- K Chaitra/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/K Chaitra/README.md b/K Chaitra/README.md index 380d714..b6b7ac3 100644 --- a/K Chaitra/README.md +++ b/K Chaitra/README.md @@ -9,7 +9,8 @@ Step 2 : open Command prompt. Step 3 : Set the directory in which the .java file is saved. Step 4 : Use the "javac" command to compile the Java program. It generates a .class file in the same folder. It also shows an error if any. - --> javac DemoFile.java + + --> javac DemoFile.java Step 5 : Use the "java" command to run the Java program. --> java DemoFile From 37403b291921bb1bb01e5a767bfd1637386d9e61 Mon Sep 17 00:00:00 2001 From: Chai-k <141635030+Chai-k@users.noreply.github.com> Date: Thu, 10 Aug 2023 13:21:04 +0530 Subject: [PATCH 7/7] Update README.md --- K Chaitra/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/K Chaitra/README.md b/K Chaitra/README.md index b6b7ac3..1b87712 100644 --- a/K Chaitra/README.md +++ b/K Chaitra/README.md @@ -10,10 +10,11 @@ Step 3 : Set the directory in which the .java file is saved. Step 4 : Use the "javac" command to compile the Java program. It generates a .class file in the same folder. It also shows an error if any. - --> javac DemoFile.java + --> javac DemoFile.java Step 5 : Use the "java" command to run the Java program. - --> java DemoFile + + --> java DemoFile =======================================================================