If you still don’t understand bitcoin

Marc Gamet
Slash
Published in
7 min readMar 16, 2018

--

Trying to understand bitcoin and its underlying technology blockchain could be quite challenging. It is not the most intuitive concept you would ever have to dig into. Like most people I presume, I started by reading a lot of blog posts which talked about tokens, proof of work, byzantine general problem, private and public keys, handicap theory, wallets, and so on… and it took me a bit of time to draw the big picture in my head. Now that I am making more sense of it, I will try to help you if, like me, you are getting seriously into that space. The purpose of this blog post is not to explain in detail how bitcoin works but merely to try to make some of its seemingly complicated concepts simple so you can better draw the big picture in your head too. It is recommended to have already understood the basics before reading some parts of this post.

It’s just a mix of 4 ingredients

To create a crypto currency like bitcoin, you only need to mix 4 ingredients:

  • a peer to peer network
  • a ledger
  • digital signatures
  • a hashing algorithm

The peer to peer network allows users of the system to exchange information directly without the need to rely on any central service. No one has the authority to make decisions for everyone, but rather, everyone makes their own mind and try to reach a consensus. For example, when you use gmail and send an email to your friend, your message goes to Google’s servers who can decide whether or not to deliver the message. This is a centralised model. On the other hand, when you try to download torrents on a peer to peer network (Boo, don’t do that!!) no one can stop you because you get the file directly from people who are willing to share it.

The ledger is quite a straightforward concept. It allows the recording of transactions which everyone has access to (unlike in the “real” world, where only banks and other financial institutions have access to such transactions). When you send 1 BTC (Bitcoin) to your friend, it will be written in the ledger and everyone in the network will have access to that information.

The digital signatures are necessary to create transactions. When you create an account you get a public key used by everyone to identify you in the system and a private key, “your precious”, that you should keep safely under your pillow. When you want to send bitcoins to someone, you need to sign your transaction with your private key. This way, all the other users will be able to verify using your public key that the transaction was indeed initiated by you. Think of it as manual signature. Everyone can say that this is your signature but only you can do the signature.

The hashing algorithm is the key ingredient, the cherry on the cake. A hashing algorithm (or “hashing function”) is a one way function that given a input A, will give you an unpredictable output B. But from B, it’s impossible to guess A. Simply put, it’s a function that allows you to encrypt without being able to decrypt. But why would bitcoin need that? Well, without going into too much detail here, bitcoin uses it mainly to ensure trust amongst the network. I will go into more detail in the paragraph about trust.

Account balance

How do I know my account balance? To know your balance, the system doesn’t count your coins. It has to check all the Bitcoins that were sent to you and those that you sent to other people since the beginning of the ledger (since the genesis block). Only then it is able to tell you how many coins you own.

There is no coin anyway

Before I started to explore about bitcoins, I thought they were some sort of tokens that people stored on their computers, USB or hard drives. But to my surprise they were not, which got me confused. Bitcoins are merely just decimal numbers recorded in every transaction of a distributed ledger. But what about the wallets then? Why do we have bitcoin wallets if there is no coin to put in them? Wallets make you think your bitcoins are in it, but really, only your private key is in it. Which means that no one can directly steal your coins, he would instead need to steal your private key in your wallet to transfer your coins to himself. As a consequence, if you happen to have a lot of bitcoins (good for you) it is recommended to have multiple wallets and keys because if you have just one wallet with one key and you lose it or someone steals it, he can have access to all your coins.

Trust issues

That is bitcoin biggest innovation, it has engineered trust. When it comes to money, assets, or anything else of value, you cannot trust anyone, even your friends, especially your friends:) So how did bitcoin build trust in a fully decentralised system with no trusted third party to take responsibility over your savings? Let’s tackle trust by understanding what we need to protect ourselves against and we’ll see if the protocol gives us enough intrinsic trust. Let’s say you create an account and you buy 10 bitcoins (I wish I did that 3 years ago).

Can someone spend your bitcoins?

No, because he will need your private key for that. But, if someone steals it, he will be able to sign transactions on your behalf and the rest of the network will think it was you. So the digital signature system prevents people from sending your money, but only if you make sure your private keys are safe.

Can someone send you a bitcoin and send this same bitcoin to someone else at the same time?

Yes, and this is called double spending but bitcoin has a solution for that. The problem is, no new bitcoin can be created to make sure you and the other person are happy. So, fortunately, the protocol is designed in a way that prevents that from happening. The network will over time, using a consensus mechanism, decide whether you or the other person actually received the bitcoin and it is impossible to predict who. To give you more details, the chain (ledger) is composed of blocks which contains transactions. In other words, to record a transaction in the ledger, it has to be included in a block. When creating a block, each miners checks if the transactions are valid (e.g. if the sender has signed the transaction and if he has the funds) and start mining to create a block. If a miner detects a double spending, he will only accept the first transaction he received before mining the block. The other one will be rejected. BUT, what if two miners mine both transactions at the same time and broadcast their own valid blocks to the network. Well in this case, we need to wait a little while before we know for sure which transaction was actually accepted by the network, it’s a solution to the byzantine general problem. As a good practice, it is recommended to wait 6 mined blocks after your transaction was validated to be sure it has indeed been. The following diagram can help better understand this concept.

Protection against double spending

Can someone get back a bitcoin he sent you?

Yes, this can happen. Someone can send you a bitcoin and then revert back on the ledger. But to do so, he needs to mine again the block he wants to remove the transaction from and build a longer chain than the network while the network continues to mines for future blocks. For example, if he wants to revert a transaction from the last mined block in the chain, he has to mine 2 blocks before the rest of the network mines 1, or he has to mine 3 blocks before the rest of the network mines 2, etc… In these cases he would have the network to accept his longest chain. But thanks to the proof of work (PoW), this is statistically very very unlikely unless this person owns a lot of the network hashing power (CPUs trying to mine blocks). We usually refer to the 51% attack but I don’t really like this name as it start to be possible with much less that 51% hashing power while still quite unlikely above 51%.

Can you be sure that your valid transaction will be processed by the network?

In theory no, but in practice yes. First, to incentivise miners to put your transaction in their next block, it is recommended to give them a little tip (also called transaction fee). Otherwise it might take a little time before a generous miner accepts to put it in his next block mining attempt. But there is another scenario. If, say, your enemy owns 51% of the hashing power. In theory he controls the network. So if he decides not to validate any of your transactions, he can. But in practice this will not happen. First it is very unlikely that someone will own 51% of the network, but if this happened and this someone starts messing with the system, everyone in the system will be affected, including himself. The coin will immediately lose value as the market will lose trust in it. The only plausible scenario this could happen is if someone is willing to buy enough CPU power to reach 51% only to destroy the system, maybe a bored multi billionaire or an angry country. As we see, this is how trust was engineered in the bitcoin protocol. Indeed, you cannot trust someone you don’t know that he will not steal your money. But you can trust that he will not want to steal your money if doing so diminish the value of the money itself.

1 Bitcoin is not the lowest unit

We’ll finish this post by noticing that in the Bitcoin protocol the lowest unit of currency is not a bitcoin but a Satoshi (1BTC = 100,000,000 Satoshis = 10ˆ8 Satoshis). That’s why you will sometimes hear people saying that they sent half a bitcoin to someone or that they just received 0.001 bitcoin.

Thanks for reading

I’m aware it takes much more than a single blog post to master the art of blockchain but I hope that at least some of your questions have been answered here. If not, if you still have some questions and do not find your answer online, do not hesitate to comment here. I will try to best address them here or in a future post.

--

--

Marc Gamet
Slash

Co-Founder and Tech Director of Slash | What world are we building?