Modeling Blockchain with Python
Intro
- Chain of blocks that contain information.
- Each block contains data, hash and hash of previous block.
- data stored inside a block depends on type of blockchain
- hash, as a fingerprint, is unique and identifies a block with all of its content - it's being calculated once block created
- changing something inside the block causes the block's hash to change (that detects any atttempts of changes to block)
- hash of the previous block actually creates a chain
- having blocks chained in that way, it ensures security of the blockchain
- changing one block would make all of the following blocks in the chain invalid because of invalid 'has of previous block' - changing one block way back in the chain it would affect all of the hashes of blocks going forward - Additional security mechanism is the proof-of-work:
- recalculating new hashes can be performed very fast so it's not enough to keep blockchain secure
- proof-of-work mechanism slows down the creation of new blocks
- f.e. for bitcoin proof-of-work consumes 10 minutes to add new block to the chain
- because of proof-of-work, changes to one block would require recalculating the proof-of-work for all of the following block within the chain
- It's distributed which increases security level
- is uses peer-to-peer network
- when someone joins network he gets full copy of the blockchain - the node
- if there is an attempt to change the block it will be rejected by the rest of the nodes in the network
- the changes would be possible when affecting more than 50% of the network nodes at once which is very hard
- To make change to block you would need to change all of the blocks in the chain, recalculate the proof-of-work for each block and take control of min 50% of peer-to-peer network nodes. That sounds like impossible mission.
- Blockchain with security mechanizms stays stable and steady.
Features
App includes following features:
Demo
Below example shows how following blocks depends on the preceding ones.
- Every following block has its own hash and the hash of the preceding block assigned except for the first block.
- Small change on first block affects change of blocks hashes all the way through - see red frame indicates update of the first block:
Setup
No specific installation required.