By now you’ve all heard of a blockchain and that it’s the backbone of cryptocurrencies like BitCoin, Ethereum, LiteCoin and others. I’m not here to tell you that blockchains are the solution to every problem or that blockchains are the next best technology that everyone will use. You’ve heard that 100 times. I’m going to explain, in as simple and straightforward a way as possible HOW a blockchain is put together and how cryptography is central and core to the whole thing.
You’ll discover, on your own, that putting a couple of old ideas together creates something phenomenally more powerful than the individual parts summed together.
First, let’s list the parts:
- A simple transaction (a record showing a FROM address, a TO address, an amount being transferred, and a time stamp).
- A “block”, which is just a list of transactions.
- Hashing (the result of a complex math problem using the numbers of all the bytes of a file (or a block and/or a transaction record)), to uniquely identify a larger chunk of data.
That’s it! No, really! A block chain and a cryptocurrency contain no more than that. Well, a cryptocurrency needs computers to do the calculations for the hashing and encryption, etc…, but they just build and validate the block chain.
So, here is what a block chain is in a nutshell:
- Every transaction ever taken place since the creation of the blockchain.
- The list of transactions are divided into “blocks”. If you create your own blockchain, you get to decide how big a block is and how many transactions are placed in a block. In BitCoin, for example, a block used to be 1MB max (it was updated in August of 2017 to be bigger). A new block is added to the blockchain every 10 minutes.
- The transaction is digitally signed by the sender so the network can confirm the owner of the cryptocurrency is truly authorizing the transfer.
- Each transaction in the block has a hash that uniquely identifies the transaction. No 2 transactions will ever have the same hash.
- Once all transactions for the next block are ready, the hash from the prior block is added to the new block and that hash, plus all the transactions, are hashed to create a final hash of the new block.
- Critically important: That prior hash being added to the new block is what LINKS the new block back to the prior block! That’s what makes it a “chain”. Each new block references the old one and the new block’s hash is dependent on the old one, which was dependent on ITS older one, and so on, all the way back to the first “genesis” block. The new hash is the way it is because of ALL the older hashes are the way they are. If any single transaction anywhere in the blockchain were different, so would ALL the hashes be different following that one.
That’s it! Really, that’s all there is.
But, some really important things have happened as a result of those simple pieces:
- Every processing computer on that network has a full copy of the entire blockchain.
- There’s no central blockchain server. The blockchain exists ONLY on the hard drives of the machines of the volunteers.
That means a hacker can’t hack “the bitcoin server” and change records, because no such central server exists. He’d have to hack into EVERY bitcoin node and change it.
Something else important happens with the technology:
- When a BitCoin node computes the hash of a block, it doesn’t just compute the hash ONCE, it computes TRILLIONS and TRILLIONS of hashes. A single, home laptop, would probably take years to compute that hash. Why? The network won’t accept just any hash. The hash produced MUST match a pre-defined pattern. Specifically, it has to, by pure chance, come up with a hash that begins with a bunch of zeros. The amount of zeros needed increases over time as computers get faster, to ensure that Moore’s law doesn’t overtake the network. These hashing computations NEED to take a long time. MANY BitCoin nodes are competing with each other to find that magical hash value. The first one that finds it, submits it to multiple peers on the network for confirmation. Confirmation is instant. Once confirmed, the block is accepted into the blockchain and it’s distributed to every node on the network so they can all add it to their local copy of the blockchain. And the computer that found the hash is awarded with 12.5 new BitCoins (worth about $92,000 at the time of this writing). Those computers that spend all their time crunching numbers to produce those hashes are called “miners”.
So, why are miners required to compute all those useless hashes only to find yet another useless hash? Because it has to cost the miners something to do it. It’s too expensive to do that if there’s no reward, so a hacker is not going to waste their time doing it. If a hacker tried to submit a false hash, the network would ban them from the network.
When a miner submits their hash, and it’s confirmed by other miners, that hash is a “proof of work”.
Aside from making it too expensive to submit false hashes, it makes it impossible to change records in the blockchain. If you tried to change a record from 24 hours ago, you’d have to rehash it, then rehash the next block (because remember, the NEXT block has been hashed with the prior block’s hash… the one you’re CHANGING!). You’d have to rehash EVERY block after the one you’re changing. It takes about $1,000 worth of electricity to mine a block and thousands of specialized computers to get it done in time. In a 24 hour period, there are 144 new blocks, so it would cost you $144,000 to rehash them all. Every 10 minutes back in time of a transaction you’re trying to alter will cost you another $1,000 in electricity.
Then, you’d have to somehow hack EVERY SINGLE bitcoin mining rig and REPLACE all their local copies of the blockchain.
There simply is not enough computer power in the world to accomplish that task. Because while you’re doing that, the bitcoin network (the fastest supercomputer on the planet), is still churning out new blocks every 10 minutes. You’d need the combined computational power of the ENTIRE bitcoin network, PLUS MORE to catch up with them.
It’s no longer a hacking challenge, but a thermodynamic problem that you simply cannot do.
THAT is why any record written to the blockchain is permanent and unalterable. That was accomplished with extra hashing of blocks and distributing copies of the blockchain all over the network.
Back to Cryptography
Hashing: Again, hashing is taking a string of bytes, pushing them through a particular algorithm, and producing a fixed length, unique string of bytes, always the same size (for the SHA256 hashing algorithm, the one that BitCoin uses, that’s 256 bits long or 32 bytes long), regardless of the size of the original string. A hash is non-reversible. That means that you CANNOT reverse a hash to recreate the original data that was used. Think of it in the same way you think of the remainder to a division math problem. For example, 13/5 = 2, with a remainder of 3. But how many other divisions have a remainder of 3? An infinite number of them. So, if all you have is the remainder, you have no way to determine what the original 2 numbers were. That’s kind of how a hash works.
Important to cryptocurrency (and blockchains): You must have a “wallet” to keep your cryptocurrency in. That wallet is simply this: You create a new public/private encryption key pair. Your private key is generated from random numbers put through an algorithm. Your public key is generated from your private key by putting it through another algorithm. Your wallet address is simply a hash of your public key. You can freely give people your public key and your wallet address. Your address is what you want people to have so they can send you money.
Signing: For more details on signing, please see:
But here’s a short explanation: When you encrypt data, you use the recipient’s PUBLIC key. When they DECRYPT your message, they use their PRIVATE key. But, if you want to PROVE that YOU sent the message, you’d also SIGN it. That simply means that you encrypt with your PRIVATE key. The recipient DECRYPTS it with your PUBLIC key. Anything encrypted with your private key can be decrypted with your public key. Since your public key is public and anyone can decrypt it, it’s not considered decryption. And since ONLY YOU can encrypt anything with your private key and your public key can’t decrypt ANYTHING not encrypted with your private key, then that proves YOU are the one that encrypted it. You digitally “signed” it.
When you transfer digital money on a blockchain, you digitally sign your transaction to move money out of your “wallet” (again, your wallet address is a hash of your public key).
The network refuses to transfer money from one address to another unless the transaction is digitally signed by the “from” wallet addresses owner.
Encryption: You don’t really encrypt anything in most blockchains, but I’ll mention encryption here, just so it’s not ignored from the conversation. But “signing” and “hashing” are considered subsets of the larger “encryption” concepts.
Benefits of all these pieces of technology put together:
- An immutable (unchangeable), public ledger. You never have to worry about someone changing a past transaction.
- Decentralized. There’s no single place that a hacker can attack and no single place a dishonest website owner can manipulate, and no single place for a tyrannical government to shut down, and no single company to go out of business, tacking everything with it.
- You are 100% in control of your own cryptocurrency. No one, not EVEN the government can technologically steal your funds or stop you from sending or receiving money on the blockchain.
- It’s virtually unhackable, not even someone with resources as deep as say the NSA.
See these images?
You’ll find actual working versions of them at the top and bottom of this article. Please click the appropriate buttons in it to let your friends know about this article.
Check back later for updates too!