Saturday, November 17, 2018

Blockchain

All transactions are recorded as block. All blocks are linked in such a way that each block knows its previous block. All blocks are hashed for security.

Blockchain provides
1) Shared database between multiple parties.
2) Parties can have conflicting interests.
3) All parties will have same rule.
4) Transaction logs are immutable.

Blockchain is a decentralized system with many nodes.
Each node has copy of entire chain.
Data becomes immutable once entered in a block.
Each node competes to solve hashing puzzle.

Blockchain is a global singleton.

In blocks do not store huge data. e.x. Instead of storing image, store hash of that image to validate.

Transactions are ATOMIC.
Run independently.
Inspectable.

Hashing: SHA 256 is used for hashing.
Hashing is one way. From output hash string, input can not be determined.

Merkle tree: A hash tree of hashes. e.g. if there are two blocks of two transactions each then
for each block of two transactions hashes will have one hash block.

                                                             SHA 1
                                                      123456678901

                 SHA1                                                                           SHA1
              222222222222                                                         333333333333333

SHA1                             SHA1                           SHA1                                             SHA1
44444444                 555555555555             66666666666666666                    77777777777777


Block :- consists of data and resulting hash.
Noune is input to hash algorithm to determine first few characters of hash.
Mining block :- to determine how to find nounce to have required hash.
Block :- Sub parts
     Number :-  e.g. 10 (block position in chain)
     Message :-  e.g. Export of grains
     Hash :-   a12e2345tgfd23456983475jsdfhgs234
     Nounce :- 57645
     Timestamp :- 26372364673264
     Previous :- gsfd7465jfv72763hsgf26345hsd23h

If in any block data is changed then its hash will change, nounce, timestamp will change & it will not match with 'Previous Hash' of next block. It will fail Merkle tree hash.

If same block of data is used to perform multiple transactions(fraud) it will create a fork & to create a fork it needs computing power of all blocks in chain, so it it is very difficult to fraudulently used same block twice for different transactions.

Securing Data :- Using Obfuscation and encryption. Data encryption is done using AES (Advanced Encryption Standard) which is a two way. Data can be decrypted using passphrase.

Each node is identified by publick key.