what is Blockchain or how does Bitcoin and other POW cryptos works?
Blockchain and bitcoin is everywhere, so why do techies think it will revolutionize the current internet. We will find it in this article.
So when I ask people what do they know about blockchain technology or bitcoin in general? I get answers like it is scam, it takes lot of resource to mine, it is very slow, bunch of stupid number etc.
I have tried my best to explain the technology in a very simple way, before you start reading article let me clarify some of the frequently used terms or words here. Keep calm and keep reading everything will make sense in the end.
- Hash - it is a digital signature eg: "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
- SHA-256 function - A cryptographic program to return an output with 256 bit of data.
- Block - Block is a 1 mb file which consists of pending transaction data, hash metadata of previous block, time stamps etc.
- Blockchain - The series or chain of blocks (1mb files) which consists of history of transaction till the current date which are stored on nodes (computers supporting bitcoin network, if you install bitcoin wallet and run it, you are one of the node in bitcoin network) in blockchain network.
Makes sense? don't worry keep reading.
HASH
Hash is the digital signature with 256 bit of random alpha numeric string, If you have a mac type shasum -a 256 hello, it will generate digital signature of word hello, you can run sha-256 function on any data like .pdf , .doc or .iso files to generate its hash.
The great thing about hash function is it is a one way function that means you can not predict or create actual document from the generated hash, as an analogy think hash as a human finger print, you can not create or human from his finger print. And another beauty of this function is if even a slightest bit of document chances hash of the modified document will change completely, it is called cascading effect and helps to maintain integrity of document.
But WTF it has to do with blockchain? HOLD up buddy keep reading.
If you run sha-256 hash function on word "Hello", the generated hash is "66a045b452102c59d840ec097d59d9467e13a3f34f6494e539ffd32c1bb35f18", the chances of being 1st bit of hash to be 0 is 50%, changes of 2 bits of hash to be 0 is 25% and difficulty to get prefix bits as consistent 0 decreases exponentially.
Now consider a scenario, If I ask you to generate a hash with initial two bit as 0, of input data - "Hello + x" where x is variable number. The only way to find the hash is you have to bruteforce the value of x with different number and run sha-256 function on it and assert the hash generated, if you satisfy the requirement , you will stop and tell others. here X may be 23874, so it says it took 23874 iteration to generate desired output this is called Prof Of Work.
eg.
Run hash function on "hello + 1" - > "some random hash". Check if hash generated satisfies requirement if not try another x value.
so next "hello + 2" -> "new random hash" check it against requirement.
Keep repeating this process as fast as you can to find value of x and desired hash, if you can get it, it means you did some work to generate the output
Same concept applies in bitcoin and other crypto currencies (implementing POW algorithm), which we called Mining.
In Bitcoin, a block is created by a miner and he starts mining (in our case finding the value of x and desired hash), as of writing (01/26/2018) the current difficulty level of bitcoin's latest blocks hash (desired hash) is "0000000000000000000a914e2ba03949ed57cf58e952bf9c344123def2eb8cd8",so the possibility of generating this hash in first attempt is 0.00009537%
To assert above hash it is taking "11388083790000000000" combination of hash/second for about 10 minutes to mine a block which is approximatly "6832850274000000000000" combination of hash to mine a block (difficulty is of DEC 7 2017), when I say mine it mean to perform transactions on bitcoin blockchain and to generate 12 bitcoins the system.
so you can say every 10 minutes 12 bitcoins are generated or mined (this are decided based on rules and network consunses).
Now If you are wondering can you mine bitcoin with your laptop? yes I tried and hash rate generates by my PC (intel core i5, 6 gb ram, 1.8 ghz/s ) produced 80 hash/second. LOL. Imagine what type of systems we need to mine bitcoin.
So why is bitcoin mining so difficult?
Because of its algorithm bitcoin mining takes on an average 10 minutes to mine a block, so lets say you are the first person to mine a bitcoin block and it takes 56H/s for 10 minutes to mine a block and you are earning 50 bitcoins every 10 minutes ( imagine you are in 2009), now your neighbor finds out and he also mines bitcoin with little stronger PC
now he is solving problem or finding desired hash in 9.5 minutes he is now earning all bitcoins and you are earning nothing so you decide to buy powerful hardware to mine it, now you are earning instead of him and race goes on but as per the bitcoin algorithm, it adjust its difficulty to 10 minutes per block, so in other words more miners, more difficulty and more expense.
It takes approximately 1000+ dollars to mine a single bitcoin in 2018 (of course due to miming competition, if competition reduces price to mine also reduces) moreover bitcoin network uses up as much yearly electricity as a medium-sized country like New - Zealand, is it worth it?
So what happens after you mine a bitcoin?
So you understood what is mining but what happens when miners mines a block, he will broadcast to every node and miners in blockchain with his hash and proof of work (in our case it is x), once it is validated by nodes in network the block is hooked with existing block thuscreating blockchain, now miners with focus on mining next block.So this is a very basic explanation of blockchain and bitcoin, if you are really interested
please read bitcoin's white papar https://bitcoin.org/bitcoin.pdf
I hope you enjoyed reading. :)
Thank you.
Abhishek Patel
http://www.iamabhishekpatel.com