(Disclosure: Some of the links below may be affiliate links)
If you read financial news or finance blogs, you have heard (a lot) about cryptocurrencies and especially Bitcoin. You probably have read some success stories where people made a fortune investing in one cryptocurrency. You also probably have read stories where people have lost a fortune with them. But what is a cryptocurrency? And how do they work?
In this post, I will answer these questions for you. It could be interesting to know precisely how they work. You probably have heard of the words blockchain, miner, or even hash function. We will see how they come into play for cryptocurrencies.
I will not cover the investment quality of cryptocurrencies in this post. I plan to discuss that in another post. Finally, in a later post, I will also discuss the history of cryptocurrencies since their creation.
This article talks about the central model of cryptocurrencies, primarily based on early technology and Bitcoin. Over time, some cryptocurrencies have become more complicated.
As their name indicates, cryptocurrencies are a form of currency. What is important here is that they are entirely digital. They only exist in a computer data format. You cannot have notes representing cryptocurrencies. You cannot put them in your wallet unless you put a USB key in your wallet!
Another essential fact is that they are entirely decentralized. There is no central authority that can emit currencies. There is not even a central computer. The entire network is collaborating to produce and manage the cryptocurrency. And each transaction is validated cryptographically by miners.
These miners use their computers (or farm of computers) to validate transactions and gain extra currencies. The system sets the maximum number of currencies. The system also sets the cryptocurrency creation rate, decreasing over time.
The other part of the name tells you they use cryptography. Cryptocurrencies are based on cryptography to make them a safe and decentralized system. As it is, cryptography is used to validate signatures and prevent invalid or fraudulent transactions.
The most important part of each cryptocurrency is its ledger. There is a ledger containing the entire history of the transactions. That means you can find the number of currencies of each user by reading the whole ledger.
How does it work?
That is all good, but how does it work under the hood? I will give you an overview of the main concepts. This is a general idea. Some cryptocurrencies may have a different concept. But they are generally using this concept. It is all about math! More specifically, it is all about cryptography.
Cryptography is the science behind secure communications. It is heavily based on mathematics and computer science. Without cryptography, you would not be able to safely buy things online. It is also used in credit cards transaction. It is being used more and more.
The cryptocurrency ledger
Cryptocurrencies keep up a ledger of all the transactions. A transaction contains the following information: the sender, the receiver, and the amount of currency. And anyone part of the system can add a new line to the ledger. But the system must verify these lines. Otherwise, anyone can add transactions to the ledger without being valid. In such a system, you do not want to trust anybody. Therefore, everything needs to be verified, ideally several times.
Every user should sign their transactions to make sure that they are valid. Every transaction will have a digital signature, generally around 256 bits of data (a bit is a 1 or 0). Every user has one pair of keys: A public key (PK) and a secret key (SK), also called a private key. When a user wants to sign a transaction, he uses a cryptographic signature function. This function produces a strong signature based on the content of the transaction and the user’s secret key.
The cryptographic function is made so that using the transaction content, the signature, and the public key of a user, it is possible to verify that the signature is coming from this user. In other words, you only need the public key to verify the transaction. And you can only sign documents with your private key. So, of course, it is essential to keep your secret key as secret as possible. If someone gets access to your private key, he can create new transactions on your behalf.
But if a transaction has a signature and content, anyone can still copy it. Therefore, it is also essential that the transactions get a unique ID to avoid this situation. The unique ID will be part of the content of the transaction and will affect the signature. Like this, nobody can copy a transaction without knowing the secret key. This unique ID is the timestamp of the transaction.
When someone adds a cryptocurrency transaction to the ledger, it is necessary to check whether it is valid or not. You do not want someone transferring some currencies that he does not have. It is the same principle as your bank. You cannot spend what you do not have.
The system needs to validate every transaction before adding it to the ledger. Cryptocurrency systems do not keep track of balances. They use the ledger for this. So, it is necessary to look at the entire transaction history of the user to see how much remains and if the transaction is valid.
The proof of work
I said there is a ledger, but the currency is not centralized. So there is no central place to store the ledger. Therefore, many people must have a copy of the ledger. For this, each transaction is sent to everyone. We call this process a broadcast. But then, there is the problem of making sure that each local ledger is up to date. There needs to be a protocol for knowing which ledger is correct. For this, cryptocurrencies use a system called proof of work.
The idea is to validate the ledger with some extra information (the proof of work) that takes a very long time to compute. One example is to find the number that, added to the transaction list, will produce a hash starting with 30 leading zeroes. This number is proof of work.
A hash is like a signature indicating the content of something. The system uses a cryptographic hash function for this. The function matches the input with a fixed-size number (for most crypto-currencies, it is 256 bits).
When using a strong cryptographic hash function, computing this proof of work is very computationally intensive. But verifying this proof of work is very fast. It is crucial for a good hash function to be impossible (or very difficult) to reverse. If you could easily reverse it, this would break the entire system.
The cryptocurrency blockchain
Since the ledger can be very big, it is split into blocks. A proof of work accompanies each of these blocks. One block is only valid if it has valid proof of work. To keep the order of the blocks, each block also contains the hash of the previous block. The blocks are forming a chain. That is why the ledger is called a blockchain in cryptocurrencies. You may have heard the word blockchain before.
Some people are listening to the new transactions. Once they have enough of them, they organize them as blocks. Then, they compute the proof of work of the block. But before that, they add a transaction to the top of the block. This transaction is their reward. The system allows miners some amount of the cryptocurrency for each block.
This special transaction does not need a signature. And this currency does not come from another user. This is the creation of a new currency. That is the way new cryptocurrency is created. They are miners that are mining for currency. Once a miner finishes with a block, it broadcasts it to each user so that they can then complete their blockchain. Of course, the miner must abide by the network rules.
There is also a validation mechanism to decide which block to add to the blockchain. In practice, many miners work on the same list of transactions. There could be that two miners complete the same work and try to add the same block to the blockchain. In that case, the first one is taken. If two blockchains are diverging, the longest blockchain is the valid one. The discarded blocks are sent back to the miners so that the transactions are not lost.
The blockchain reward is generally decreasing over time to guarantee a limit on the total amount of cryptocurrencies in the system. Moreover, the difficulty of computing the proof of work is also increasing over time. The idea is to keep the time to create a new block constant over time. In addition to the blockchain reward, miners can also take a fee (in cryptocurrency units). This transaction fee is an incentive to include the transaction into the block they are working on.
You should now have a better understanding of what cryptocurrencies are and how they work. The model I have described here is the basic model. Some cryptocurrencies can be a bit different, of course.
Cryptocurrencies are not so difficult to understand. They are a digital currency with a shared ledger of all the transactions. Cryptocurrencies rely on computing power to validate all the transactions from the network. They are very safe, using advanced cryptography to ensure that nobody can forge transactions.
Of course, they are more complicated than your usual currency. But the concept is very interesting. I am not saying it is a good investment. I actually think it is not a good investment. But I will discuss that in more detail in another post.
And these days, there have been a lot more interesting things added to the technology side of cryptocurrencies, but this becomes quickly complex and is the subject of other blogs.
To continue learning about cryptocurrencies, read about the history of cryptocurrencies. How it all started and what is going with them now. And finally, we will look at the problems when investing in cryptocurrencies.
Do you understand better how cryptocurrencies work? Are you investing in them?