(to continue the previous blog)
Which problems that blockchain has tackled?
- Distributed ledger/database of ownership: remove completely the role of centralize custodian
- Time-stamping (double-spending): a mechanism to avoid A transfer same “coin” to both B and C. Without centralized trusted custodians, due to the nature of digital communication, it is more feasible to happen. Imagine: without centralized custodian, how to sell same house to two different buyers?
- Consensus via proof-of-work: Once a transaction (ownership transfer) is submitted (broadcasting), it must be validated and recorded in the “distributed ledger” database. Assume everyone owns the same ledger copies, now some receive a broadcast of transferring from A to B: $latex Coin_{k+1}=Sign(Hash(Coin_k, P_B), S_A)$ and some receive a broadcast of transferring to C: $latex Coin_{k+1}=Sign(Hash(Coin_k, P_C), S_A)$. How everyone reach a consensus of which transfer comes first and invalidating the second one?
First, each new transaction, once validated, will be in a new block that linked to previous blocks in a recursive manner. The new block has a header hash that is created based on the new transaction & a random number (nounce) & the hash of previous block. In this way, the blocks are linked sequentially. It means that if one ledger is tampered in any block, one can recompute its hash and verify with other ledgers to identify its invalidity.
Another trick is that the random number is mined such that the hash begins with certain 0-zeros. Meaning that there are computational effort spent to create new block, i.e., proof of work. Also, in some ways, the one who spent efforts to create new block, i.e., validator node, will be rewarded with new coins as incentives. There will be a “race” among node validating the same or different block of new transactions to find “the nounce”.
Lastly, once one validator node successfully creates a new block, it will broadcasting the new hash (and block?) so that other can update their ledger with this new node and move on the validating the new block. One principle is that the longer chain should be considered as a “truth”. It implies that if one tries to tamper the existing block, it would need to create blocks faster against the “race” of other honest nodes. If the “race” is fierce, the chain quickly gets longer, dimishing the chance to tamper data.
Imagine: we have 10 personels as validators. I announce to all the network that I will sell my house to B (message 1) and at the same time sell to C (message 2). Assuming that at one time, 6 personels are validating message 1 and remained 4 personels validating message 2. All can validate that I own the house based on the current state of ledger, hence accepting both message 1 or 2, just the matter of which one comes first (time-stamping). The proof of work is that a validator need to do 100 push-up before accepting my message. Only who does the job fastest (physical limit) will be able to convince other validator and be rewarded. Later if one want to change record that I transfer the house to C instead by compromising one validator, this one needs to convince (all) other validators to agree to his up-to-date and longest ledger. The longer the chain means he would need to do push up more times and still the fastest! The proof of work is to make this task impossible, statistically.
One question remained is how to validate a transaction against the current state of ledger? Meaning that if I hear A transfer to B, how can I validate A’s ownership of the asset against my best knowledge? To be explored.
Second concern is exactly on the modification of existing data. How would that be achieved? By B transfer back to A and then A to C again?
Lastly, enhancing the ownership hash to something more complex while keeping blockchain as the infrastructure, we get to smart contract and more fancy stuffs.
(*) mainly after reading the original paper “Bitcoin: A peer-to-peer electronic cash system” by Satoshi Nakamoto