{"id":39118754,"date":"2021-08-08T06:30:39","date_gmt":"2021-08-08T06:30:39","guid":{"rendered":"https:\/\/stockviz.biz\/index.php\/2021\/08\/08\/bitcoins-secret-sauce\/"},"modified":"2021-09-14T11:07:18","modified_gmt":"2021-09-14T05:37:18","slug":"bitcoins-secret-sauce","status":"publish","type":"post","link":"https:\/\/stockviz.biz\/index.php\/2021\/08\/08\/bitcoins-secret-sauce\/","title":{"rendered":"Bitcoin&#039;s Secret Sauce"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">or: How I Learned to Stop Worrying and Love Nation State Attacks.<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Bitcoin\u2019s secret sauce, and how it works, was on full display these last few weeks. Bitcoin was designed to work against the most powerful of adversaries, and boy \u2013 did the adversary show up!<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com\/public\/images\/ecd2fe7f-c8c9-4387-b01a-436e800a24a2_584x320.jpeg\" alt=\"batman-v-superman-dawn-of-justice_bb788b6f\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">The China Syndrome<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A few months ago, 45% to 75% of Bitcoin mining happened inside China. Then the Chinese government banned it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There are anecdotal accounts from people on the ground are seeing Bitcoin mining operations being shut down by law enforcement agents. And there are similar accounts from people on the ground elsewhere in the world where containers full of mining hardware are being shipped to, lock, stock and barrel.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And then there is the Bitcoin blockchain &#8211; the source of absolute truth.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I have a copy of the Bitcoin blockchain on my computer, and could actually run the numbers myself and see that the production of Bitcoin blocks slowed down dramatically. Here\u2019s a plot of how long it took, on average, to find 2016 blocks from 12-May-2014 to 18-July-2021.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com\/public\/images\/f89876d6-17bb-4359-9993-ba4783aefea1_640x480.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Bitcoin blocks, on an average, are supposed to be generated once every 600 seconds. But you can see the spike in this number on the graph towards the end, going all the way up to 832 seconds. This means that during that period, the total number of active miners went down dramatically, and that led to the inter-block average-gap increasing equally dramatically from 600 seconds to 832 seconds.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Putting the anecdotal and canonical sources of data together, we can be reasonably certain that the Chinese mining ban lead to a global drop in Bitcoin mining.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Does it matter?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Not really. Miners come, miners go \u2013 Bitcoin chugs along. That is what it is designed to do. Bitcoin targets a block production rate of 600 seconds per block. If Bitcoin\u2019s design had been na\u00efve, whenever its dollar value went up, more miners would enter the system to make more money, and blocks would arrive faster than 600 seconds. Similarly, if its value went down (or if governments kicked them out), miners would leave the system, and blocks would arrive much slower than 600 seconds. The block production rate on either side of 600 would persist, and reflect the total number of miners in the system.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But no, that\u2019s not what happens. No matter how many miners are in the system, it always takes around 600 seconds to mine a block. This is done through the difficulty adjustment algorithm, also known as Satoshi\u2019s stroke of genius.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Difficulty Adjustment a.k.a Bitcoin\u2019s Secret Sauce<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Before we get to the difficulty adjustment algorithm, we have to first understand why keeping the inter-block interval of 600 seconds is important. Bitcoin works because everyone can check whether their perceived ownership of their own Bitcoin is fact or fiction. To check this, you need access to Bitcoin\u2019s data? Where is this data? How big is it? How do I access it? Bitcoin\u2019s data is not held by some central custodian, or a bank. It\u2019s held by everyone who is interested. It includes all transaction from the genesis block onwards &#8211; from January 2009. But storing everything with everyone sounds crazy &#8211; and to be honest, it is crazy. But the more you think about it, the more you realize that there are no other easier ways of doing self-validation, other than offloading the \u201cdo I control my money or not?\u201d question to someone else &#8211; and trusting them. Bitcoin prefers the opposite: self-validation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So, if we accept the crazy idea that everyone stores a copy of the blockchain, we have a fundamental tradeoff &#8211; the blockchain cannot get very big (by growing very fast). It also cannot stay static: new transactions need to be added every so often to facilitate economic activity. Currently, the blockchain is around 377 GB, and growing at around 50 GB per year. If it grows too fast, not everyone will be able to hold their own copy. If it doesn\u2019t grow fast enough, there is not enough transaction space to accommodate the demand for transactions. Under these constraints, Satoshi decided that a 1MB block every 10 minutes is a good tradeoff. To keep this tradeoff constant, blocks cannot be generated slower or faster. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">What happens if Bitcoin\u2019s value skyrockets and everyone wants to be a miner? Remember that a miner who generates a new block gets to keep the newly minted Bitcoin that comes out of each block. So, if the value of Bitcoin goes up, expect more miners to materialize. To accommodate this, Satoshi designed a simple algorithm that makes mining harder or easier depending on how long it takes to generate the previous 2016 blocks.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The Bitcoin protocol contains a positive number called \u201cdifficulty\u201d, whose value is currently 13,672,594,272,814. This number controls how hard or easy it is to mine a block. Let\u2019s say the total time taken to mine the previous 2016 blocks was greater than 2016 times 600 seconds, by a factor of X. This difficulty number is then adjusted lower by the same factor X. If the time taken to mine the previous 2016 blocks was lower, the difficulty number is adjusted upwards \u2013 again by the factor X. That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As far as \u201calgorithms\u201d go, this is as simple as it gets. It\u2019s middle school level arithmetic. Other than combining existing ideas from cryptography and distributed systems, Satoshi\u2019s only novel contribution was this middle school level formula. The genius, as they say, is in the simplicity of it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When these erstwhile Chinese miners turned down their mining hardware around end of June\/beginning of July 2021, Bitcoin\u2019s mining difficulty dropped from 19 trillion to 14 trillion, by around 5 trillion \u2013 which is around 28%. The reduced difficulty made it easier for the remaining online Bitcoin miners to start generating blocks every 10 minutes again. The next 2016 block average was 630 seconds. Voila!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As Bitcoin\u2019s value increased from 0 to wherever it is today, miners have only entered the system \u2013 and have rarely left. Difficulty has always gone up \u2013 to accommodate this increase in value. So, how does this difficulty number actually make it easier or harder to mine a Bitcoin block?<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The Proof of Work Function<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Bitcoin, famously, relies the \u201cpartial hash-preimage puzzle\u201d to build its Proof of Work function:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com\/public\/images\/1a7f71c1-8ce2-434f-ba1b-3c2357080c55_577x118.png\" alt=\"\" width=\"367\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">You double hash data from the block you want to generate, and check if that hash value is less than the target on the right hand side of the equation. If it\u2019s not, you change the block data, and try again, and again, and again, and again. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, if I double hash make-believe block-data, say the string \u201cBitcoin forever!\u201d, I get the number:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">99399038078883646938846821706752581723151100264172406332358249387420489004987.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The current value of the&nbsp;target is:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1971823790658122626473078926498088015421759366553927680.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So, it doesn\u2019t work. I need to keep trying the function again and again with different block-data to hit gold. The actual previous Bitcoin block\u2019s hash was 888160945014446794317532755205888398236464272495427689, which is under the required target, and that miner struck gold \u2013 so to speak. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the difficulty number goes up, the mining target goes down, and finding block-data that double-hashes to a number lower than that target gets harder. It\u2019s like tossing a 6 sided dice and wanting to hit a number less than or equal to 1. It happens only once every 6 times. If difficulty were to reduce, the target would move to a number less than or equal to 2. That happens every 3 times \u2013 mining just got easier.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Why go into the nitty gritty details of this function, with all the associated arithmetic and probability? I want to get into the properties that this unique function has, that makes it ideal for Bitcoin mining &#8211; and resisting nation state attacks.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Parameterizability<\/strong>: The function provides very fine degree of control over how much harder or easier we want the function evaluation to be. If you increase or decrease the difficulty number, the function becomes easier or harder to evaluate, respectively.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Memorylessness or Progress-free ness<\/strong>: Even if you have already run the function a million times, it still doesn\u2019t give you any advantage over the next run. Each run of the function is what is called a Bernoulli trial \u2013 with the odds of hitting gold the same no matter how many times you have tried in the past. This makes sure that larger miners have no other advantage than just the larger chance of producing a block. If this property weren\u2019t there, the largest miner would *always* win, even if they had just 0.0001% more power than the next largest miner.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The other incredible advantage of Memorylessness is that a miner can be turned off, put in a container, shipped elsewhere and plugged back in. The only loss the miner incurs is the Bitcoin that could have been mined in that interim time when the machine was turned off. Most physical objects being built, or even computations that are being performed on computers rely on previous data or \u201cprogress\u201d that has been done, stored and retrieved, so that we can continue the process further. Shutting down something abruptly, without needing to store any state of progress, and starting elsewhere without any extraneous loss is&nbsp;<em>not that common<\/em>. This allows Bitcoin miners to be incredibly mobile and seek out the cheapest electricity wherever it exists. They are, in the true sense, plug-and-play.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Hard to compute, but easy to verify<\/strong>: To get the double-hash value which is under the target needs millions of trials of the function. But once someone finds it, the rest of us can verify it immediately with just a single iteration of the function. This, again, makes decentralization possible \u2013 where all of us can run the Bitcoin software on our computers and check that the miners are doing the right thing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Replacing this function is not that easy. Most attempts have kept the general idea, and have tinkered with the specifics.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A nation state the size of China attacked Bitcoin where it\u2019s supposed to hurt: Bitcoin Mining and all they managed to get in return was a giant shrug of indifference by the protocol. Yet another instance of Bitcoin living up to its promise of being designed to last forever. This self-adjusting nature of Bitcoin &#8211; that makes it change itself based on market conditions, with no one central entity being in charge &#8211; separates it from all other forms of money. Fiat money always has a central planner. Bitcoin has a protocol.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">Our crypto series in reverse-chronological order:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><p><a href=\"https:\/\/stockviz.biz\/index.php\/2021\/06\/27\/governance-decentralized\/\">Governance, Decentralized<\/a><\/p><\/li><li><p><a href=\"https:\/\/stockviz.biz\/index.php\/2021\/06\/06\/defi-for-the-rest-of-us\/\">DeFi for the rest of us<\/a><\/p><\/li><li><p><a href=\"https:\/\/stockviz.biz\/index.php\/2021\/05\/09\/so-doge\/\">So Doge<\/a><\/p><\/li><li><p><a href=\"https:\/\/stockviz.biz\/index.php\/2021\/03\/28\/on-nfts\/\">On NFT&#8217;s<\/a><\/p><\/li><li><p><a href=\"https:\/\/stockviz.biz\/index.php\/2021\/02\/28\/bitcoin-is-forever\/\">Bitcoin is Forever<\/a><\/p><\/li><li><p><a href=\"https:\/\/stockviz.biz\/index.php\/2021\/01\/31\/define-ethereum\/\">define: ethereum<\/a><\/p><\/li><li><p><a href=\"https:\/\/stockviz.biz\/index.php\/2021\/01\/24\/define-bitcoin\/\">define: bitcoin<\/a><\/p><\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Freefloat Talk on Crypto, July 2021 Edition: Shyam, Kishan, and Tejaswi\" width=\"1020\" height=\"574\" src=\"https:\/\/www.youtube.com\/embed\/C85mNQd6CPI?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>or: How I Learned to Stop Worrying and Love Nation State Attacks. Bitcoin\u2019s secret sauce, and how it works, was on full display these last few weeks. Bitcoin was designed to work against the most powerful of adversaries, and boy \u2013 did the adversary show up! The China Syndrome A few months ago, 45% to &hellip; <\/p>\n","protected":false},"author":43,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4053,3471],"tags":[4063],"class_list":["post-39118754","post","type-post","status-publish","format-standard","hentry","category-crypto","category-investing-insight","tag-bitcoin","entry"],"_links":{"self":[{"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/posts\/39118754","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/users\/43"}],"replies":[{"embeddable":true,"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/comments?post=39118754"}],"version-history":[{"count":0,"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/posts\/39118754\/revisions"}],"wp:attachment":[{"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/media?parent=39118754"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/categories?post=39118754"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/tags?post=39118754"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}