Aight! We’ve talked about Computer Science and we’ve talked about some design features used in blockchain. Now let’s put it all together and cap this series off.
What is blockchain? It is a linked list of data structures that uses cryptographic hashing to sign each data structure, thus including it in the canonical chain. Here’s the block used by Bitcoin (most other cryptos will have mostly the same components).
You can see the transactions in the Block Content section, and you can see info (such as the hash of the previous block) in the Header section. Let’s relate this all together and draw a true picture of a blockchain (specifically Bitcoin) block. To do so, we’re gonna be dealing with a whole bunch of cryptographic hashes.
Hashing: A Redux
If you want the nitty gritty detail, you can go here. However, since we’re not writing a mining algorithm or a storefront, I’ll spare you the minutae. If you want an awesome video that explains exactly what I’m about to talk about, but in visual form? Here ya go! Want to learn more about blockchain than you ever wanted to know, but all at a layperson level? You’re welcome!
Here’s a Bitcoin block:
Let’s work from the bottom up.
txns
The payload of a Bitcoin block is an array of transactions. Each transaction looks like this:
I show the transaction mainly to show you that it contains two things: tx_in and tx_out. This is how it works, you combine a certain number of prior transactions in the blockchain (inputs) and then dole out the coins contained in those transactions in the outputs. If the inputs go over how much you’re paying the other person, you add an output to pay yourself back the overage. It’s much like cash. Just like handing bills to the cashier and receiving change back, you hand over inputs, and receive back an output for the overage.
Let’s do a quick example. Oscar wants to pay ZARDOZ for the Gift of the Gun, and he wants to pay $150. Oscar has previously received money from Office Manager Mohammed for “Jihad related expenses” for the amount of $110. Oscar has also previously received money from Preet Bahahahaha for “Woodchipping services” in the amount of $65. In order to pay ZARDOZ, Oscar sets up the transaction by including the previous Jihad and Woodchipping transactions as inputs, and creates two outputs: one to ZARDOZ for $150, and one back to Oscar for the remainder ($25). Then those Jihad and Woodchipping transactions are marked as fulfilled, meaning that they can’t be used again as inputs.
txn_count
This is fairly self explanatory. This contains the number of transactions in the block.
nonce
From here on up in the block, everything is contained in the header. Remember that the hash of the block is really the hash of the header. The txn and txn_count parts of the block are not used in calculating the hash. However, we’ll find out really soon why the transactions are still reflected in the block hash.
Nonce is related to mining. I’ve alluded to the way that blocks are created, and I’ll discuss it more in the next section, but suffice it to say that the nonce is a random number and has no purpose besides in calculating the hash. The way that a block is added to the blockchain is that the block’s hash must be below a certain number. How do you get the hash below a certain number? You adjust the source data used to make the hash. Since the hash comes from the header and the nonce is in the header, you can change the nonce until the hash is below a certain number. Notice that simply changing the nonce to a lower number doesn’t guarantee that the hash is a lower number. This is where luck and random chance come into play. We’ll talk more in the next section about this.
bits
Bits goes with the nonce. It is the “certain number” mentioned above that the hash needs to go below for the block to be accepted.
timestamp
Timestamp is self explanatory. It’s the time when the block was created.
Merkle Root
We’ve discussed the Merkle root before, but haven’t really nailed it down. Let’s do that now. The 10,000 foot view is that the Merkle root is the hash of all of the transactions. The hash of the block (which is actually the hash of the block header) takes the Merkle root into account when calculated.
The Merkle tree is a binary tree (each parent node has two children) that hashes from the bottom up. The bottom row of the Merkle tree contains the hashes of each transaction. The middle row hashes adjacent bottom row hashes (it’s a hash of a hash). The top row is a hash of a hash of a hash and contains information from all of the transactions. Notice what it would take to modify or replace a transaction. If STEVE SMITH tries to replace TX4 with FAKE_TX4, he has to recalculate three different hashes, as well (all of the hashes that include TX4 in them).
Prev Hash
This has been discussed at length in the prior two parts. This is the hash of the prior block, the link between the current block and the prior block.
Version
The version of the blockchain tells everybody what rules this block has been assembled under. This makes it possible to improve a blockchain without having to toss out all of the old blocks.
Mining
We’ve hinted at what mining is already, but now we can put all the pieces together. When transactions are posted to the blockchain network (all of the computers mining and transacting on that blockchain), they are packaged up into a block to be added to the end of the blockchain. How this happens is technical and a bit beyond this overview. Once a block is packaged up, the mining process begins. The block, sans block hash and nonce, is sent out to the network for mining. Computers that are set up as miners begin to calculate the block hash. Remember that the block hash is calculated from data that includes the Merkle root, the previous block’s hash, and the nonce. All of those pieces of data are constant except for the nonce. Therefore, miners, upon calculating the block hash, adjust the nonce to try to get the block hash to be less than the current difficulty number (represented by the bits field).
Once a miner has calculated a block hash below the current difficulty number, they submit the hashed block to the network. If they’re the first to do so, they “win”. They end up getting a small payment of cryptocurrency for their efforts. The payment is based on an algorithm that reduces the amount of currency created for a successful mine until an end date when no more currency will be created for that coin. At that time, miners will only be compensated by transaction fees (which are currently in the tenths of a percent range).
As you can imagine, it’s not easy to do this. Bitcoin, for example, is designed so that, on average, the winner mines the block in about 10 minutes. Given the vast amount of processing power dedicated to Bitcoin mining across the world, the chance of a single desktop computer winning even once a month is slim. In some other cryptocurrencies, it is easier, but even a second tier crypto like Monero would average one or two wins a month for a standard desktop computer. At that point, you’re probably not making enough to pay for the electricity you used.
That’s where mining pools come in. It’s a fairly simple concept. Take a bunch of computers, let them mine as a cohesive unit, and split the winnings across members based on a pre-defined formula.
The Big Picture of Blockchain and Different Applications
We’ve talked about blockchain in the context of cryptos, but there are a ton of different potential applications for blockchain. The main “hot topic” for blockchain use is reputation analysis. Rather than having to go through a reputation broker (Uber, AirBnB, Yelp) to find out whether the person driving that car or renting that room or cooking that meal is trustworthy, you can reach out to the decentralized blockchain to find their reputation.
This is a fairly simplistic application of reputation analysis, but the reason folks are excited is the application of such a thing to automation technology. What if, for example, you didn’t have to put in a reservation to get a hotel room? If your reputation is high enough and the room is available, the lockbox automatically opens and gives you the key to the room. All you have to do is tell the system how long you plan on staying there, and you’re set.
Another application is identity management. Does the cashier really need to see your name, address, and other personal info to know that you’re old enough to buy alcohol? There’s a whole bunch of identity leakage that sets each and every one of us up for identity theft. One proposed use of blockchain is to provide customized identity services. The cashier can query the blockchain as to whether you’re old enough to buy alcohol, but can’t access your address. Amazon can get your address, but can’t get your social security number. Starbucks can get your first name, but not your last name.
What about securing your finances? This isn’t entirely separate from cryptocurrencies, but what if every transaction you made was from a different account? Instead of giving your bank account info or your credit card number to merchants, you give the equivalent of a Visa gift card with the exact amount of the transaction on it. If Target gets breached and your info is leaked to malevolent actors, it’s not an issue, because it points to an empty one-time account.
Finally, the application that I think would be the most interesting. Traffic management via blockchain. As automated cars become a more likely reality, most of the traffic management interaction methods that have been designed to be centralized or distributed in nature. A decentralized traffic management system would reduce the efficacy of government meddling and the potential for an enforced monopoly a la internet service provider.
Cryptocurrencies
I’m not going to list out all the cryptocurrencies in detail. I trust y’all to DDG it yourselves. Let me just point out a few of the big ones in passing.
Bitcoin – The original and most famous. There is relatively little anonymity in using Bitcoin, as shown by the Silk Road FBI takedown. It’s also relatively slow to get new blocks integrated, at an average of 10 minutes per block.
Bitcoin Cash – A fork of Bitcoin meant to scale to more users a bit easier by making the blocks bigger.
LiteCoin – Billed as “silver to Bitcoin’s gold”. It generates blocks 4x faster (2.5 minutes per block), will generate more coins than BitCoin, and some different internal algorithms.
Ethereum – Ethereum is much more than a cryptocurrency. It creates smart contracts that can take advantage of automation. Want to unlock your guestroom when somebody has enough reputation points? Ethereum is probably the best blockchain to start from to do this sort of thing.
Monero – Billed as the “secure cryptocurrency,” it is designed slightly differently from BitCoin so that bad actors (like the FBI) can’t trace one transaction back and see your entire transaction history. Secure is a relative term, because, as seen in the Silk Road incident, there are weaknesses wherever you have to give personal info (shipping, currency conversion)
Drawbacks and Limitations
This could be an article in and of itself, but I’ll just hit a few that are top of mind.
- Blockchain length – The immense size of the Bitcoin (and other large cryptos’) blockchain means that you either need to rely on somebody else’s node to get plugged in (by using an exchange) or you need to wait a few days for all of the blocks to be downloaded.
- Block acceptance time – In Bitcoin, it takes an average of 10 minutes for your transaction to be included in an accepted block, and due to forks (when two different blocks are accepted in two different parts of the network), folks recommend waiting an hour before declaring the transaction “completed.” That obviously doesn’t work for somebody trying to walk out the checkout line at the supermarket.
- Scalability – This is kinda wrapped up in the last two, but the number of transactions in a block are limited by a maximum size. Therefore, as more and more transactions occur, the chance of your transaction making the first block goes down substantially. Then, you have to wait not only 10 minutes for your block to be mined, but you have to wait an unknown amount of time until your transaction is included in a mined block. This is where transaction fees come into play. When there are 50,000 transactions, which ones are you going to try to make into a block as a miner? The ones that pay the best, of course.
- Security – We’ve discussed some security concerns already, but blockchain doesn’t resolve the single biggest threat in online transactions: the other party in the transaction retaining and ultimately misappropriating your personal information.
I hope this series was helpful to y’all! I’ve certainly learned a ton!
Don’t get hacked…
Thanks for these. I’m not going to pretend to have a solid grasp of the technology, but I feel like I’ve gotten a better grip of the general idea from your articles on the subject.
Very very illuminating. Thanks for this,
One comment I was going to make in the second part, was an analogy (less important now) that the block chain is like a Chain Sinnet in that once you have moved along the structure, you can’t change any part of the prior structure without unpicking all the intervening chain links and reconstructing them.
And then, the chain won’t look the same as the other copies created at the same time as the original.
Unnecessary now that tm’s done all the hard work, but it was useful for senior management at my firm.
I totally understood all of that.
Excellent work, Trshmnstr. Thank you so much for this series!
I’m beginning to think that trsh may be some kind of genius savant.
I’ve been skimming and waiting for installment #3 before I really dig into this series. Thanks for doing it, it looks very informative.
I think I’m going to copy/paste all three into one pdf so I can spend some time reading it on my Kindle.
Great series trshmnstr! I appreciate all the effort and information.
I can’t believe I’m the first person to mention Dogecoin
No, THIS is a Doge Coin!
+1 CANALZ!
Glibcoin – a limited use cryptocurrency, usable only for Glibs merch. Try to hack it and you get a “Fuck Off, Slaver” message. If you try to spend more than you have, it will inform you “No, fuck you, cut spending” until you get to an allowable transaction amount.
*rises for extended ovation*
I prefer cosmocoin where its value and purpose is decided by the New York Times editorial board
You can buy fruit sushi, hair styling products and tire changing services with that, right?
In Suave We Trust
*polite applause*
Cosmocoin is the Nick Gillespie of cryptocurrencies.
So how do we base it? 1 Glibtoin = value of one orphan?
thanks for the three articles on blockchain.
A couple of guys at the office and I tried out Bitcoin when it first came out. We loaded it on a few computers and set them to mining. I had a couple of Bitcoins and one of my lead developers had 7 Bitcoins. At that point there wasn’t really anything you could do with them. I think there was a shop out in California that would accept Bitcoin payments, maybe that is all.
So I ended up deciding that it was interesting and everything, but not terribly useful. I ended up just deleting everything and chalking it up to an interesting experience, someone like running seti at home. I think they went up in value to about $0.70 a couple of months after that and the lead developer kept doing it until he had about 10 Bitcoins. he was about to sell them when they get up around 7 Bucks, but then it crashed back down to below a dollar. I think he ended up selling out when they got up around 3 bucks.
Long story short, don’t take investment advice from me.
“How this happens is technical and a bit beyond this overview.”
I’ll say.
/blank Homer stare.
Mr. trshmnstr, can you repeat that
This could, should, and must be a future article. If not by you, then by someone else.
I, for one, have shied away from crypto for anything other than an intellectual toy as the whole Bitcoin thing reeks of tulip mania to me. I’d appreciate the perspective of someone better versed in Finance than I am.
I think your guess is as good as anyone’s, because we’re talking about something that might change just about everything. There’s no way to predict the value of it, but we can maybe try to get a hint.
If your context is living in a relatively stable country, sure it can seem a curiosity; things work fairly well day-to-day, so why fix something that isn’t broken?
But let’s say you live in Venezuela; if the state says the exchange rate is 10:1, but the market says it is 100,000:1, think about even just the raw utility value, to the increasingly dysfunctional economy at large, of a viable alternative currency, let alone one that lends itself to avoiding the eye of the state.
Let’s pick a number out of the air and say that the state’s manipulation is stifling business to the tune of 30% of its potential (through resulting inefficiency, business closings, etc), and that this lost potential could be recovered by the sole change of adopting a functional currency. I’m not saying that’s the number, and I’m glossing over lots of factors, but nevertheless, such a number exists, and I think it would be difficult to argue that it is small.
So I see this as at least one fundamental difference between cryptocurrency and tulips, and I think the question for the world at large is not one of if, but when. As to the value of it in real terms, I think that just depends on the unknown of how dysfunctional the current system is, in comparison to what it could be.
If you have money to play with, go for it. If you have some money, risk averse but still insist on trying it, limit it to a tiny percentage of your portfolio. If you can’t stand market volatility stay away and go prepare a veal roast.
When your significant other catches you reading Sugarfree post on Glibertarians.com.
https://www.npr.org/2018/01/02/550202212/utah-sen-orrin-hatch-announces-retirement-with-speculation-focused-on-romney
I’ll take the good news, and try to ignore the speculation about Romney.
MIA LOVE FOR SENATE!
At least I can comment on your link, which beat mine by 4 minutes, and say that as a libertarian, I’d like to punch Orrin Hatch right in the mouth.
<Return of the Romulan
Well, the Democrats can always hope so. Here’s the stupid party’s best chance to some of the wishy washies the lost, back, and snatch defeat from the jaws of victory. Stupid Party.
Sigh…
Return of the Romulan
Sigh again… always read the next link up…
Thanks for the rundown trshmnstr.
I may be mistaken about this, but it seems blockchain is basically a method for reducing vulnerability in a world with increasing amounts of personal information being transferred digitally.
Given that, isn’t it possible that blockchain could become more or less completely obsolete in the near future if an objectively superior method for achieving the same process is invented/discovered/implemented?
for achieving the same result, I mean