The application is built using JavaFX including blockchain concepts. The motive of this application is to help people learning Blockchain Technology while visualizing the internal working of the blockchain in simplest way possible.
The model is motivated from https://blockchaintrainingalliance.com/pages/lab-blocks which provides a web application of Blockchain's internal working.
- Prev : This represents the hash of the previous block in the blockchain, to maintain immutability. If the block is the initial block, or the Genesis Block, then the previous hash is set to 0 (default).
- Nonce : In blockchain, nonce is a 32-bit (4-byte) integer value whic is set so that the hash of the block will contain a run of leading zeros. The run of leading zeros in the hash generated is also known as Difficulty which is directly linked with nonce value. The greater the difficulty, the more difficult to get the nonce value. Any change to the block data will make the block hash completely different. Nonce of a block is only generated which the block is mined.
- Hash : It represents the hash of the block as a whole. blockHash = GenerateSHA-256( #{nonce}#{prev}#{data} ).
Fig.1 - Initial State of the blockchain network where all the node are set to empty with default nonce value and auto generated hash of each block in the blockchain.
Step 1: Type the following into the data field of Block #1 and click "MINE": Ashish paid Rajat Rs. 100
Fig.2 - The Block #1 is appended into the blockchain and mined.
Step 2: Type the following into the data field of Block #2 and click "MINE": Rajat paid Akash Rs. 150
Fig.3 - The Block #2 is appended into the blockchain and mined. A link is formed with the previous block
Step 3: Type the following into the data field of Block #3 and click "MINE": Akash paid Zain Rs.100
Fig.4 - The Block #3 is appended into the blockchain and mined. A link is formed with the previous block.
Step 4: Now, go back to Block #1, and try to change the Rs. 100 to Rs. 50 and click "MINE".
Fig.5 - Block #1 has been tampered with new value which resulted in the link break in the blockchain.
It could be visualized that the block has changed its color from green to red as the current nonce is not valid for the current block status. The data has been tampered within on the block and the chain has been broken.
For any hacker to hack the blokchain, they would need to mine all the blocks in this chain to make his update valid for this chain. But in public blockchain, there are nearly 14,000 nodes distrubuted with repitition of data in each node. Thus, this update would no longer match the ledger of the other peer on the network to get a consensus of >= 51%.