Maths behind Bitcoin
A Primer on Public Key Cryptography, Encryption, Blockchains, and Mining.
Public Key Cryptography
This notion of public-key encryption is one of the greatest inventions in human history. If you think about ciphers from the pre-World War I era and war, you would have the same key to encrypt and decrypt. That notion is great if you can securely transmit that key to another person and trust that they’re going to keep it secret.
But the brilliant idea behind it is I have a key that only I can use to send email as me, but there is a way that you can send email to me. Applied in another context, you can send me money or encrypt a message that only my private key can decrypt. You can publish your public key to the whole world and say, here is an encrypted message that anyone could read if they had the private key. It means that only the person for whom the message is intended — even if the message is intercepted — is the person who can read it.
Creating Digital Scarcity
So what’s the problem? If I sent you an email, you could copy that email, and you can forward that email. I can copy other people on that email. Great for email, bad for the money. I don’t want you to be able to send me $100, but then also copy someone else on that $100 and essentially double-spend the money, triple spend, or a thousand times spend. This was a problem that nobody had a good way to solve. This is what was just so revolutionary about Bitcoin and Nakamoto’s solution.
The big idea in software — think back to Windows 95 — was creating infinite replication, creating abundance. Microsoft prints a copy of Windows 95 for basically zero marginal cost. They put it in the box. There’s, of course, distribution cost, but cloning the bits over and over and over again made this incredible business model.
Then the internet rolls around. Suddenly, you’ve got zero cost distribution, which compounds the abundance from the zero cost replication of software. Now, it doesn’t cost you anything to make a copy, and it doesn’t cost you anything to deliver it.
Everything that we know to be true up to this point is that if something’s digital, it can be copied everywhere quickly. The big idea — which is completely genius and previously thought to be impossible before Bitcoin — is creating scarcity with the software on the internet. Absent the fact that now we know Bitcoin is a thing. It would’ve sounded ludicrous if not then elegantly laid out in this nine-page paper of here’s how we’re going to do it.
How do you do that? The solution that Satoshi proposes is a “peer-to-peer distributed timestamp server to generate computational proof of the chronological order of transactions.”
Why is chronological order important? Go back to the I’m emailing you $100, and I’m copying somebody else on that transaction example. Whoever gets the $100 first, then it’s spent. The next transaction is void.
Of course, the way this actually works — we talked about public-key encryption — is when I’m sending it to you, I sign it with my private key. I take that bitcoin, which is a hash that has all the other signatures that came before it in there. I know that’s not technically exactly right, but that’s the reasonable way to think about it. I sign it with my private key, and I send it. If they wanted to sign something from my wallet that I owned, anybody else out there, they couldn’t. They only have my public key. I’m the only one who can sign it and send it to someone else.
Now, of course, someone else can verify that I sent it to them because they have my public key. They can quickly do some work, check it, and say that it came from you. But they don’t need to know my private key to do that check.
If this system were to exist, all these transactions would be going out into the network. How do you track which ones are the valid, correct, unique, scarce ones? The way that Satoshi proposes you do this is you have a distributed system of the ledger. Everybody can see the entire chain of transactions of every transaction that has ever happened within the system.
That’s a really interesting concept and a little counterintuitive where he’s saying, in a third party system where you have a Mint or The Federal Reserve, you send that information to them, and they keep track of it. That’s the only way to ensure that money is not getting double-spent.
He’s saying, what if he flipped out on his head — he, they, she, whoever it is — and saying, what if everybody has a copy of the ledger and everybody just has the complete transaction history of every single bitcoin right there on their computer? That’s my proposed solution.
If you’re doing that, he proposes that people who would choose to grab these transactions that are being broadcast out and generate computational proof of which ones came first and which ones were the right ones. If somebody’s trying to send a bitcoin multiple times, which ones happen first, and are the correct transactions should be added to this ledger.
He’s saying a whole set of people out there have decided they want to host the entire transaction history on their computer. They’re going to do some work to verify. They’re going to go back through, and they’re going to say, I’m going to do some math to do some checks and say, hey, are all of these transactions valid? They’re going to run their computers to do that and verify the integrity of all these transactions.
If they verify and say this is good, they will propagate it out to more computers and more people on the network. Essentially, there is one canonical version around there that everybody’s copying off of that has a bunch of thumbs up on and say I’ve checked this. It’s good.
How do you design this system, so it’s not just total chaos of everyone doing this? You make it computationally actually pretty hard to prove that you have the correct order of transactions. That means that once one of these superusers, one of these nodes, broadcasts a set of transactions, everybody can be pretty reasonably assured that it’s correct.
Though you chain these transactions together into one ledger, that goes back to the beginning. Suppose you make it hard to compute each block. In that case, you make it impossible for anybody else to change that ledger then because the block is cryptographically chained to the previous block. That’s hard to do, and the system adapts so that it always takes on average about 10 minutes for everybody to create one of these blocks.
To go back, change, and fake some of the previous transactions, you would have to re-compute the entire chain back to the beginning becomes an exponential problem. If you could do this, not only would you have to broadcast it out to a material part of the network and not just have it on your machine, but tell your friends, have them tell their friends, and all that. Suppose somebody wanted to come in with a lot more computing power than other miners on the system. In that case, they could recreate all the transaction hashes back to the beginning, insert around fake transactions, give themselves 100,000 bitcoins, and then pass it off as the new one.
There were only a handful of other crappy laptops doing this in the early days. Sure, your compute power would outmuscle a lot of these early ones. But that’s not going to happen as soon as it reaches a sufficient scale. It becomes a network effect economy because the more transactions that are happening, the more blocks that get created, and the more computing power that’s working on that block, the harder and harder and harder it becomes to forge it until you get to a point where we are now. You would need the total amount of computing power that is gone into Bitcoin since the beginning plus some more to break it. That’s just not possible.
There’s no way at this point because it’s been operating for so long with so many nodes on the network, so many transactions happening, so many miners mining. It’s impossible. Now you can guarantee — this is what Satoshi saw. If you could get to this kind of network with this density, scale, and operating history, it would be impossible to crack it. Then all of the fraud, double counting, and costs on the system that we just talked about with the traditional financial system wouldn’t apply anymore.
We’re talking about laying the groundwork for a system of accounts where you can be super sure that it’s legit if you’re sent money. That there’s not a risk that they didn’t actually have that money, and you’re going to have to do some chargeback. You know it’s legit because you’ve got everything we just described going into, saying that if I receive this bitcoin to my address, it’s not going to get undone, or it’s at least extremely unlikely that it’s going to get undone because of all this work that’s going into it.
There are people who have a complete copy of the blockchain of the entire transaction ledger leading up to now. It’s sitting on their computer, and they’re doing work. They’re going through and running cryptographic algorithms to ensure the authenticity of all those transactions and check and make sure that these are all correct.
Of course, they need to be compensated for that because they’re taking electricity, running their machines, the fans are on a real high. In all likelihood, their GPUs and now even more specialized mining hardware exist in a data center somewhere close to a river to have easy access to cheap renewable energy.
Maybe back in 2009, researchers like Nakamoto and the people he shared this with originally would have done this out of the goodness of their hearts because it’s cool, but that’s not going to scale. What was initially a by-product and is now the incentive of mining one of these blocks is that the first coin on the block gets given to you as a thank you for verifying the integrity here.
Without getting too far into the specifics of how that works, what it means is you’re getting paid for your labor, or you’re getting paid at least for the energy that you’re putting into helping the system remain verifiable and authentic.
It’s not just the first coin. It’s the first several coins on a block. It started with 50. If you mined a block, which again happens every 10 minutes, you got 50 bitcoins in the beginning. Now it’s down to six and a quarter. Six and a quarter because it halves every time.
One Way Functions
There are certain types of math problems that are very easy to do in one direction but very difficult to undo in the other direction.
A classic example of this is the product of two prime numbers. If you multiplied prime number A by prime number B, it’s fairly easy to do that math. You can imagine literally doing it on paper. You can imagine writing a computer program to do it, bringing those numbers into the registers and assembly code, multiplying them together.
But suppose you’re given the product of those two numbers, especially when all the numbers you dealt with are very large. In that case, you can imagine that it gets extremely difficult and would be very inefficient to try and figure out what the initial two prime numbers were that created that product. The magic that makes this one-way function work is that it’s easy to multiply two prime numbers together but very difficult to factor large primes.
The implication here is that it’s very easy to check someone’s work when they tell you they have the answer to this product. They provide you with one of the factors or one of those initial prime numbers. You can quickly do that math and say, yup, this checks out. But it’s super hard for you to stumble onto the exact two initial numbers without knowing any other piece of information.
Let’s rewind to 1874. William Stanley Jevons wrote in the Principles of Science — keep in mind this is little under a hundred years before the personal computer was created. “Can the reader say what two numbers multiplied together will produce the number 8,616,469,799? It will be quite unlikely that anyone but myself will ever know.”
He came on to the very first idea of the one-way function. Now a computer can very quickly, through brute force, figure out what the two — guess and check, guess and check, guess and check — factors of that number are. But you can imagine that if that number were extremely large, it would take modern computers a very long time. Or frankly, if you make them large enough, it is impossible for computers today to undo that problem. It requires just way, way, way too much work. If you make them bigger than that, then you can say, assuming computers get better at a certain rate, this problem is never undoable. There’s a scary thing that exists here, which is at some point, we have not proven for sure that one-way functions exist. We’ve tried to undo them in many different ways, and mathematicians everywhere have tried to prove this problem.
It’s a scary thing to rely on public/private key encryption, encryption of all kinds, and hashing. Everything in Bitcoin is based on it and anything with any password that you log into anywhere too. Your email is based on it.
A minute ago, when we said that you would have to put all the computing power that’s gone into Bitcoin back into trying to forge it, that would not be the case if you had a way to break this encryption. Suppose you invented a novel algorithm that mathematically could undo that work just as officially as it was done instead of inefficiently. In that case, we know how to do it now, which is basically brute force. But the point is that it would break Bitcoin. That would also break all security. You could log in to any account anywhere. So it would break the traditional system too.
One other little aside is this notion of public-key encryption: I can broadcast my public key so anybody can send something to me, but only I have the private key. I am the only person who can either decrypt the message, send it to someone else, or however you decide to leverage that. This concept is born out of that 1874 discovery of prime factorization.
Pretty amazingly, two different groups of people took this idea and turned it into this public/private key discovery right around the same time — 1973 in Britain — but they kept it a secret because they wanted to use it for defense. After all, it’s freaking brilliant that you have the notion of transmitting messages more securely on the battlefield. The very same idea was discovered within the same time. It ultimately was publicly announced in 1977 — now known as RSA encryption.
It’s crazy that private/public key encryption was discovered in the same decade by different people who had no notion of each other. The first set of people desperately tried to keep it a national security secret. It’s like the world was just ready for the discovery. Technology and modern math had advanced to the point where two different groups could independently make the same invention based on the same foundation.
For the complete history, technology, and future of cryptocurrencies, give a read to our book “In Crypto We Trust: The Origins and Future of a Cultural Revolution”.
- Crypto Margin Trading Exchanges | Earn Bitcoin | Mudrex Invest
- WazirX vs CoinDCX vs Bitbns | BlockFi vs CoinLoan vs Nexo
- Bitsler Review | WazirX vs CoinSwitch vs CoinDCX
- 7 Top Copy Trading Platforms |BuyCoins Review
- ProfitTradingApp for Binance Review | XT.COM Review
- SmithBot Review | 4 Best Free Open Source Trading Bots
- Leveraged Token | Best Crypto Exchange | Paxful Review