Cryptography behind Bitcoin is quite complex. I tried to explain as simple as I can. Specifically, Bitcoin stays secure because of keys, which are basically chunks of information that can be used to make mathematical guarantees about messages, like hey this is really from me when you create an account on the Bitcoin network, which you might have heard called a “wallet.” That account is linked to two unique keys: a private key and a public key. In this case, the private key can take some data and basically mark it, also known as signing it, so that other people can verify those signatures later if they want. So let’s say I want to send a message to the network that says, “Michael sends 3 bitcoins to olive.” I sign that message that message using my private key, which only I have access to. And nobody else can replicate. Then, I send that signed message out to the bitcoin network, and everyone can use my public key to make sure my signature checks out. That way, everyone keeping track of all the bitcoin trading knows to add my transaction to their copy of the blockchain. In other words, if the public key works, that’s proof that the message was signed by my private key and is something I wanted to send. Unlike a handwritten signature, or a credit card number, this proof of identity isn’t something that can be faked by a scam artist.
The “who” part of each transaction is obviously important, to make sure the right people are swapping bitcoins. But the “when” matters as, well. If you had a thousand dollars in your bank account, for example, and tried to buy two things for a thousand dollars each, the bank would honour the first purchase and deny the second one. If the bank didn’t do that you’d be able to spend the same money multiple times. Which might sound awesome, but it’s also terrible. A financial system can’t work like that because no one would get paid. So if I only have enough money to pay olive or hank, but try to pay them both, there’s a check built into the bitcoin system. Both the Bitcoin network and your wallet automatically check your previous transactions to make sure you have enough bitcoins to send in the first place. But there’s another problem that might happen with timing. Because lots of people are keeping copies of the blockchain all over the world, network delays mean that you won’t always receive the transaction requests in the same order. So now you’ve got a bunch of people with a bunch of slightly different blocks to pick from, but none of them is necessarily wrong. Okay, Bitcoin. How do you solve that problem? Turns out, it’s by actually solving problems. Math problems. The process is called Bitcoin Mining.