Friday, November 11, 2016

Understanding Bitcoin technology


A short summary of what i understood so far about Bitcoin technology:
  1. It is a digital cryptocurrency - uses asymmetric encryption (private/public key pairs) during transactions and hashing (SHA256) to generate bitcoin addresses (which is analogous to a bank account number)
  2. The main author of this technology and initial software is Satoshi Nakamoto but no one knows him/her/them. Satoshi released the bitcoin software in Jan 2009. 
  3. It is decentralized - like gold and unlike paper currency which is centrally managed by governments of countries - so it is also called Digital Gold.
  4. An upper limit is set to the number of bitcoins that will be mined or generated. It is 21 million bitcoins (or BTC or XBT) and this number will be reached by the year 2040. At present the total bitcoins are around 16 million at the time of this writing (https://blockchain.info/charts/total-bitcoins). That the upper limit is fixed so the value of the bitcoin will keep increasing as time goes by. This is called deflation. For paper currency government's print more money to offset any deficit causing the existing value of money to reduce - and this is inflation. Bitcoin, like gold, is deflationary and its value keeps increasing unlike paper currency whose value is decreasing due to inflation.
  5. The lowest unit in bitcoin cryptocurrency is (0.000000001 bitcoin) which is called a "satoshi". Then there is 0.0000001 micro bitcoin or bit and 0.0001 milli bitcoin. So we can go very granular and can make transactions with very small fractions like 0.000345 bitcoin or BTC.
  6. Value of 1BTC at the time of this writing is $717 approx.
  7. It uses a peer-to-peer (P2P) network of computers. 
  8. A set of transactions is grouped in a structure called "block" and added to the end of the "blockchain". Blockchain is like a ledger of all transactions ever done using bitcoins. All nodes running the bitcoin software get a copy of this ledger (initially it takes quite a while to download the blockchain data). After initial download all transactions are added to the blockchain. 
  9. Every 10 mins the blocks of transactions will be synched to all nodes in the bitcoin network but only one node  (also called "miners") that wins a lottery (there could be just one such winner usually) will be able to change the blockchain and add the blocks of transactions it received to the blockchain. This then makes the transactions permanent in the blockchain and it will be synched to all thousands of miner nodes in the P2P network (thus no one central node maintains the ledger and it is virtually impossible to delete a transaction once done). The idea is that every 10 mins only one node in the P2P network will win the chance to add blocks to the blockchain. 
  10. If there happens to be a collision (meaning 2 nodes win the lottery at the same time) then only one of them will hold once in the next 10 mins the next winner node adds a block to one of the previous lottery winning node's blockchain. Then that (longest blockchain) remains as the source of truth and the other blockchain becomes orphaned. This protocol where nodes in the distributed computing environment arrive at a consensus and choose a winner every 10 mins is said to solve a byzantine general's problem that was deemed unsolvable earlier.
  11. The miners are rewarded in 2 ways - 
    1. each transaction has a fee associated with it that is earned as a reward by the miner that wins the lottery. It is generally a small value (0.0002 BTC at the time of this writing in Bitcoin-core wallet program). 
    2. when bitcoins were introduced in Jan 2009 then miners that used to win in those days until next 4 years were rewarded with 50 BTC every 10mins. Then in the following 4 years this reward was halved to 25 BTC and then in the following 4 years to 12.5 BTC and so on. This value will keep reducing and so the reward fee value will keep increasing. The reason that it is reducing is to ensure the total "mined" or generated bitcoins will not go beyond 21 Million BTC.
  12. The incentive to "find" a block (akin to mining and finding gold) in bitcoin is why several folks invested in hardware that can do bitcoin mining on the P2P network and be compensated by the fee associated with all transactions that make that block they find and also the share of new bitcoins mined which also goes to the miner that found the block.

No comments:

Popular micro services patterns

Here are some popular Microservice design patterns that a programmer should know: Service Registry  pattern provides a  central location  fo...