This post is a translation of this post: Bitcoin explained in a correct and intelligible way:
What is Bitcoin?
Every unhappy guide on Bitcoin starts with this common question, and usually starts with the answer that it is a “virtual currency” 1 , a stupid concept that does not clarify anything.
Forget this chat. Bitcoin is not a currency. Bitcoin is a protocol 2 .
Why then do they say it is a coin? Because these very hasty people like to say that everything that is easily divisible and transferable, and whose various units are identical to each other, is a currency. So, in that sense, Bitcoin is a currency, but ignore that currency talk.
The Bitcoin protocol says that there are “credits” (or “points”, or “units”) that can be transferred between participants, and multiple computers, each operating independently of the other, as long as they follow the protocol (i.e.: that they are all running the same program, or compatible programs), will always be in agreement as to who spent each credit and how they spent it.
This is basically the idea: a bunch of “virtual points” that are transferred from one to another, without there being an organizing entity, “the owner of Bitcoin”, “the supreme boss of Bitcoin”, who controls nothing, coordinates nothing, or have power over such transfers.
How it works
Imagine several computers running the same program (or compatible programs). Now imagine that these programs communicate with each other over the internet: they send messages to each other and wait for responses. Every now and then the response doesn't come, or it comes in a format the program doesn't understand, that means the other computer has gone offline, or is running an incompatible version of the program, and then everyone else will ignore it. But in general the answer comes straight and everyone manages to talk to everyone.
Now that you've figured that out, it's easy to imagine, for example, that each of those computers keeps a list of all the bitcoins in existence and who owns each one. They get the list of other computers on the network and then update it as new transactions are made. Every time someone wants to make a transaction, he must do it through one of these computers, the person goes to the computer running the program and says: “I'm so and so, I have x bitcoins, and I want to send them to such and such a place ”, the program goes there and sends this message to the other computers, which update their list. End.
This would be a naive version of the protocol that would work if all participants were very honest and no one ever tried to spend bitcoins they don't have.
For something like this to work in the real world, the great invention of Bitcoin had to come in, the brilliant insight of Satoshi Nakamoto, which is the chain of blocks, known around as blockchain .
It works like this: instead of each computer keeping a list of where each bitcoin is, each computer keeps the chain of blocks. A “block” is just a fancy name for a dataset. Each block consists of a reference to the previous block and a list of transactions. As they contain a reference to the previous one, there is a sequence, an Indian queue, and the computer can be calm knowing the order of the transactions (the transactions that happened in the third block are later than those that happened in the second block, for example) and know that the same bitcoins were not spent twice in a row by the same person, which would be invalid. When a new block appears, all the computers just check if there is no invalid transaction there and, if so,
who makes the blocks
In theory, either computer can do the next block. The idea is that each person who wants to make a transaction goes there and uses a computer on the network to send his transaction proposal (“I want to transfer bitcoins to such and such a place”) to everyone else, and that, when someone goes a block, take all such valid transaction proposals and place them in the block which will then be accepted by all other computers and included in the global blockchain. This global string has to be exactly the same on all computers.
In practice, there is a rule that makes not everyone able to make blocks: it is that the block data hash + a magic number must be less than a very small value x
. The magic number is any number that the computer trying to make the block can adjust, by trial and error, so that the hash comes out the way it wants. The x
can be bigger or smaller according to the frequency of the last blocks produced. The smaller x
, the more statistically difficult it is to find a magic number that, along with the block data, has a hash smaller than x
.
That is: to make a block, many different magic numbers must be tried until one is found that satisfies the conditions.
What is a hash ? A hash is a mathematical function that is easy to do one way and hard to do the other. Multiplication, for example, is easy to do and easy to do, and its opposite operation, division, too (so much so that anyone with a pen and paper can do it, there's that thing of passing the numbers down and subtracting and such ). An exponentiation operation on the other hand – a number raised to 1000, for example – is easy to do, but to undo it only with trial and error (and it is by trial and error that the computer or the calculator do).
In the case of Bitcoin, the computer that is trying to produce a block has to find a number such that (this magic number + predetermined block factors) raised to 50 results in a value lower than the difficulty factor, another factor predetermined by the general state of the blockchain.
Suppose a computer finds a number 1798465042647412146620280340569649349251249, for example, and it is smaller than the difficulty factor. He then says to the others: “here is my block, the hash of my block is 1798465042647412146620280340569649349251249, the predetermined factors of the block are 4 (these factors everyone can check), and my magic number is 3. (4 + 3) raised the 50 is 1798465042647412146620280340569649349251249, as everyone can see, so my block is valid”. Then everyone accepts that block as valid and starts trying to find the magic number for the next block (and this time the block factors are different, since a new block was added to the chain and caused everything to change).
The rules for defining x
mean that on average each new block is ready in 10 minutes. So, if there is only one computer trying to produce blocks, the protocol will say that x
it is relatively high, so that computer will be able, in 10 minutes, on average, to find a magic number. If, however, thousands of super-powerful computers are trying to produce blocks, it x
will be set to a much lower value, so that the effort of all those computers doing thousands of trial-and-errors per second will only succeed in finding one magic number every 10 minutes.
Today there are computers specially made to look for magic numbers that can calculate hashes much faster than your home computer, which makes it impracticable for any non-specialized person to try to produce blocks, see this graph of the evolution of the number of hashes that are tried each second.
For some reason, computers that are engaged in making new blocks are called “miners”.
If two computers on the network make blocks at the same time, which one counts?
If you already know who makes the blocks, it's easy to imagine that this is a little unlikely. But still it can happen. Even if the blocks are not ready exactly at the same time, problems can happen because the other computers on the network will receive the two new blocks in different orders, and then it will not be possible to determine which is valid or which is not valid, in that order.
The computers are then left in a state of indeterminacy about the two possible chains of blocks, A and B, say, both identical up to block number 723, but different as far as block 724 is concerned, for which there are two alternatives. The protocol determines that the chain that has done the most work is the one that counts, but for a while we may have a state in which some computers on the network only know about the existence of block A, while others only know about the existence of block B, which It's a big mess that can only be resolved by the advent of the next block, the 725.
As each block refers to a previous block, it is necessary that one of these two 724 blocks be chosen by the miners to be the “parent” of the 725 block when the magic number is found and it is done. Even if each miner chooses a different parent, this process will probably only leave a 725 block, and when it is spread out it will determine, by its ancestry, which was the 724 block that was valid. If two or more 725 blocks are produced at the same time, the system continues in this indecision state until 726, and so on.
For this reason, you shouldn't trust that a transaction is actually committed just because it was included in a block. You have no way of knowing whether there is another alternative block that will be preferred over yours until at least a few more blocks have been added.
Transactions
Many people believe that there are addresses and that these addresses have an owner and he owns the bitcoins. This erroneous belief is the result of an analogy with traditional banks and bank accounts (accounts are addresses that have an owner and hold money).
In fact, once transactions are included in a block they are not "at one address", but wandering around in a large limbo of transactions. From this limbo they can be withdrawn by anyone who meets the conditions that were previously specified by the creator of the transaction.
A more useful analogy than the bank account analogy is the cash analogy: imagine you have a 20-penny bill and you want to use it to pay someone 10 bucks. You need to break that 20 note into two 10s and then one stays with you and the other person, or, if you have two 5s, you can put the two together and give it to the other person. All those bills you're spending have a prior history: they came from somewhere at some point into your control.
Bitcoin transactions are like that too: you need to specifically mention a previous transaction.
For example,
- Carlos pays Dandara 10 bitcoins, Dandara now has a transaction worth 10
- Elisa pays Dandara 17 bitcoins, Dandara has one transaction worth 10 and one worth 17
- Dandara pays Felipe 23 bitcoins, she merges her two transactions and makes two new ones, one worth 23, which goes to Felipe's control, and another worth 4, which goes back to her control, Dandara now has a transaction worth 4, Felipe has a transaction worth 23
- Felipe pays 14 bitcoins to Geraldo, he splits his transaction into two, one worth 14 and another worth 9, and so on.
One difference, however, is that in Bitcoin nobody knows who owns the note, you just know that you can spend it if you really can (if a previous transaction specifies a condition that you can meet, you must meet that condition in the time you are mentioning the previous transaction). This is why a Bitcoin wallet can say that you “have” x number of bitcoins: the wallet knows which private keys you control and which transactions out of all the unspent transactions on the entire blockchain can be spent using that key.
A common form of transaction is that it specifies the condition that anyone who has the private key capable of signing the public key whose hash is said here can spend this transaction. Other common conditions are those that specify n keys, of which m need to sign the transaction for it to be spent (for example, between Fulano, Beltrano and Ciclano, any two of them need to agree, but not just one), which is called.
payment channel
A payment channel is a sequence of payment promises made between two Bitcoin users that do not need to be published on the blockchain and are therefore instantaneous and free.
Before you ask yourself what happens if someone breaks a promise, I should say that "promise" is a bad term, because real promises can be broken, but these promises are self-fulfilling, they are signed transactions that can be redeemed at a later date. any time by the recipient simply by publishing them on the blockchain.
The idea is that most of the time you won't need it, and you can keep making new transactions that invalidate old ones until you decide to publish the last valid transaction. This way your money is safe in a payment method
The big problem is that if the other party decides to steal and publish an old transaction, you need to appear within a reasonable amount of time (this depends on the agreement between the two users, but I think the default is 24 hours) and publish the last transaction. There are incentives to prevent someone from trying to steal (for example, whoever tries to steal and is caught loses all the money that was in that lane) and other mechanisms, such as watchtowers that watch over other people's payment routes to see if no one is stealing.
Example:
- Angela and Bóris decide to create a payment method, as they expect to make many small payments between them, both forward and backward, over the course of several months.
- Angela creates a transaction to an address shared between her and Bóris, worth 1000 satoshis, and from that address she and Bóris create a transaction returning the 1000 to Angela
- When deciding to pay 200 satoshis to Bóris, they create a new transaction that transfers 800 to Angela and 200 to Bóris
- Now Boris wants to pay 17 satoshis to Angela, they create a new transaction that transfers 817 to Angela and 173 to Boris
- And so on, they create new transactions that invalidate the previous ones and change the “balance” of the payment method. When either of you wants to withdraw the money you have in your balance, just publish the last transaction and that's it.
The Lightning network is a large network of payment channels that allows people to make payments to people not directly connected to them through direct channels, but through a route that traverses various other channels and adjusts their balances.
Are there other cryptocurrencies besides Bitcoin?
For starters, never use that word again. “cryptocurrency” is even worse than “virtual currency” 1 .
Now, answering: yes, in a way there are, they are called “altcoins” (or “poop coins”, friendly translation), because they are, in fact, worthless.
Otherwise, it can be said that they are not comparable to Bitcoin, because there can only be one currency in a free currency market, and that position already belongs to Bitcoin, and also because Bitcoin is free, without owners, without great powers that control it, which cannot be said of any altcoin.
After Bitcoin was invented and its ingenious insight was embraced by the interested community, thousands of people copied the protocol, with minor modifications, to create their own coins.
Thus came Litecoin, Ethereum and many others. Basically, they are just copies of Bitcoin that try to improve it in some way or add other functions.
Further References: