Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Understanding Blockchain: How it Works and Implementing in Java, Summaries of Java Programming

An introduction to Blockchain technology, explaining how it functions as a decentralized and distributed ledger, and how it ensures security through digital signatures. It also covers the implementation of a Blockchain in Java, including the process of mining a block and adding it to the blockchain. Java's reliability, portability, and plugin architecture make it an ideal choice for Blockchain development.

What you will learn

  • What are the important attributes of Blockchain?
  • Why is Java an ideal choice for Blockchain development?
  • What are the steps involved in implementing a Blockchain in Java?
  • How does Blockchain ensure security?
  • How does the process of mining a block work in Blockchain?

Typology: Summaries

2021/2022

Uploaded on 09/28/2022

mayank.ziaa
mayank.ziaa 🇮🇳

1 document

1 / 19

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
BLOCK CHAIN &
IMPLEMENTATION
(JAVA)
GROUP 1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13

Partial preview of the text

Download Understanding Blockchain: How it Works and Implementing in Java and more Summaries Java Programming in PDF only on Docsity!

BLOCK CHAIN &

IMPLEMENTATION

(JAVA)

GROUP 1

GROUP MEMBERS

● RAHUL SUMAN
● ANURAG PRASAD
● ADESH YADAV
● MAYANK CHOUBEY
● VANSH THAKUR
21BCY
21BSA
21BSA
21BSA
21BSA

BLOCKCHAIN

Yes, Blockchain = Block + Chain = listOf(block)

The blockchain is a distributed and decentralised ledger that stores data such as transactions, and that is publicly shared across all the nodes of its network.

● (^) Ledger The ledger is the main record holder which holds the list of the block. ● (^) Stores data The block stores the data(information). The data can be anything or of any type, we can think of. Here, we are taking the transactional information as data as an example. ● (^) Distributed and Decentralized Ledger Normally, there is the central machine which is responsible for doing everything with the data. But in the blockchain, there are many machines(so it is not centralised) and all the machines are connected peer to peer with each other. And all those machines are having the same ledger. Hence, the blockchain is distributed and decentralised ledger. In other words, the blockchain is distributed as the ledger itself that is shared with everyone using the same blockchain network. Each one gets the copy of the entire ledger and gets the update when something is added

Steps showing how the blockchain works:
● A wants to make a transaction.
● A creates the transaction.
● A submits the transaction to the network.
● A machine in the network verifies the transaction and gives the
approval.
● The new block is created in the blockchain for the A’s
transaction.
● The updated blockchain is broadcasted to the everyone in the
network.
● The transfer is done.

HOW DOES BLOCKCHAIN

WORKS?

● It uses cryptography to generate digital signatures. There is
a concept of the private key and the public key to work with
the digital signatures.
● Each one of us gets the own private key and the other’s
public key.
● Private key: This key can be only accessed by the individual
owner of that key.
● Public key: Each one of us are having access to each
other’s public keys in the network.
IF BLOCKCHAIN IS DISTRIBUTED, HOW THE
BLOCKCHAIN IS SECURE?
And then, I submit the transaction(information, public key, the
digital signature which was created above) to the network for the
approval.

● (^) In the process, the network decrypts the digital signature using the public key provided and extracts the information from that signature. ● (^) If the original information matches with the information extracted from the signature as shown in the above image, then it approves else it declines. ● (^) If the information does not match, there can be the following cases:

  • (^) The original information was manipulated somewhere in-between.
  • (^) The digital signature was generated with the private key which does not correspond to the public key provided. ● (^) This is how the network will be able to catch the manipulation. Hence, the blockchain is secure

IMPLEMENTING A BLOCKCHAIN IN JAVA Mining a Block We represent a block by a hash value. Generating the hash value of a block is called “mining” the block. Mining a block is typically computationally expensive to do as it serves as the “proof of work”. The hash of a block typically consists of the following data:

  • (^) Primarily, the hash of a block consists of the transactions it encapsulates
    • The hash also consists of the timestamp of the block's creation
  • (^) It also includes a nonce, an arbitrary number used in cryptography
  • (^) Finally, the hash of the current block also includes the hash of the previous block Multiple nodes in the network can compete to mine the block at the same time. Apart from generating the hash, nodes also have to verify that the transactions being added in the block are legitimate. The first to mine a block wins the race!

Adding a Block into Blockchain While mining a block is computationally expensive, verifying that a block is legitimate is relatively much easier. All nodes in the network participate in verifying a newly mined block. Thus, a newly mined block is added into the blockchain on the consensus of the nodes. Now, there are several consensus protocols available which we can use for verification. The nodes in the network use the same protocol to detect malicious branch of the chain. Hence, a malicious branch even if introduced will soon be rejected by the majority of the nodes.

CALCULATING THE HASH

  • (^) Creating Blocks : To create a block, a Block class is implemented. In the class Block:
  • hash will contain the hash of the block and
  • previousHash will contain the hash of the previous block.
  • String data is used to store the data of the block and
  • long timeStamp ” is used to store the timestamp of the block. Here long data type is used to store the number of milliseconds.
  • calculateHash () to generate the hash

THANK

YOU!