How Does Bitcoin Work?

Uludag University Blockchain
Coinmonks
7 min readJun 28, 2022

--

Bitcoin is promoted as a peer-to-peer electronic cash payment system, according to Satoshi Nakamoto’s article dated October 28, 2008. He mentions in his introduction that online purchases are not processed without a trusted party. The trust needed in the system it offers is based on cryptographic evidence. In this way, an utterly peer-to-peer payment system is recommended without the need for trust.

For simplicity, let’s talk about the existence of a communal ledger that you keep with your friends and check the transactions every week, pay the debtors, etc. Anyone can write a new transaction in this ledger and this ledger must be visible to everyone. There is a big problem here. If we assume that there is not and cannot be an environment where everyone trusts each other, how can you be sure that someone else will not write a transaction on your behalf? At this point, the digital signature comes into play. Namely, if you put your signature at the end of the transaction, it will make that transaction reliable.

The implementation of the digital signature is done with a public and private key pair. While our real-life signatures are the same in every way, digital signatures vary from message to message. Therefore, it becomes difficult to fake. The signing process occurs when the message to be signed and your secret key are entered into a function. The signature of that message is given as output. The validation process consists of entering the message, public key, and signature of the message into a function. Its output will be either true or false. (See this section for details.)

In the article, electronic money is defined as a chain of digital signatures. During the transaction, each owner sends the money to the next, signing the hash value of the previous transaction and the public key of the next owner with its own digital signature. This signature is added to the end of the money just like the signature in the ledger. The person receiving the payment can also verify the signatures.

The problem that arises here is that the person receiving the payment cannot verify whether the previous owner or owners used the money more than once. The payee must verify that the previous owners of the money have not signed the transaction in advance. As a solution to this, it is worked on based on the oldest transaction. In order to know the oldest transaction, it is necessary to be aware of all transactions. To implement this in a distributed system, all transactions must be publicly announced to the ledger owners. That is, everyone joining the network must maintain the same ledgers.

If there is no additional suggestion in this model, it is almost impossible to have honest information in the ledgers that everyone has. Imagine that the ledger is distributed to all your friends. It would be a mistake to distinguish false transactions from honest transactions and to rely on each person holding the same information. Then we need a system in which people can agree on the transactions.

In order to determine the order of operations, a timestamp should be placed on the transaction that is performed. So how should the timestamp be set?

To agree on transactions and verify timestamps, Bitcoin’s proposed solution is to trust the ledger that does the most work. This model, also called proof-of-work, which we mentioned in one of the previous articles, is used for the timestamp server. This model aims to start the hash output of the SHA-256 algorithm with a certain number of 0s. To find a certain number of 0’s, it is necessary to replace an arbitrary number called the nonce included in the block and compare it with the summary output found. The nonce is included in the block because other entries in the block cannot be changed. For example, if we changed the timestamp in the block, it would be impossible to obtain the necessary data for transaction sequence and tracking.

Since the blocks added later to the chain create a hash with the hash data of the previous blocks, the person who wants to manipulate must also calculate the previous blocks again (see for details).

In such a case, we can say that the majority should have a say. Assuming that the majority will continue this process, the longest chain where the most work is done will be considered the honest chain. As long as the majority of the processing power is covered by honest nodes, it will beat other chains. Thus, we understand that the majority is honest and the longest chain belongs to the majority. To manipulate a transaction, the dishonest node must also compute previous blocks and catch up with the honest or even pass. In this model, if blocks are produced very quickly, the difficulty value is increased, that is, 0 values ​​in the hash value are increased to prevent the impostor from competing with the honest.

The steps to operate this network are described in the article as follows:

1) New transactions are broadcast to all nodes.

2) Each node collects new transactions into a block.

3) Each node works on finding a difficult proof-of-work for its block.

4) When a node finds a proof-of-work, it broadcasts the block to all nodes.

5) Nodes accept the block only if all transactions in it are valid and not already spent.

6) Nodes express their acceptance of the block by working on creating the next block in the chain, using the hash of the accepted block as the previous hash.

Elongation continues on the longest chain. If two nodes broadcast the same block to other nodes at the same time, a fork occurs. Those who try to place the next block on it continue to work on the first block that comes to them. The other block is also kept until the tie is broken. Whichever branch becomes longer, it continues to grow from there.

(Image from: [0] )

This work done with processing power is actually a special process required to run the system. After all, these nodes are effective in the participation of money in circulation. They also get incentives because the electricity is wasted and the people doing this work grow the honest chain. This incentive is called the block reward and it keeps nodes honest. People who listen to transactions and compete to create blocks are also called ‘miners’. The block reward, which is halved every time 210,000 blocks are mined, is initially presented as 50BTC. Then, if we express the maximum number of bitcoins to be produced mathematically:

210,000*50 + 210,000*25+ 210,000*12.5 + . . . . . (So on)

= 210,000*(50 + 25 + 12.5 + 6.25 + 3.125 + . . . .)

As a result of infinite sum, the part next to 210,000 subtracts 100,

= 210,000*(100)

= 21,000,000

Thus we understand that the maximum amount of bitcoin is to be produced is capped at 21,000,000.

If the dishonest person somehow makes up the majority of the processing power, he can manipulate them in new transactions or create new money. If it does the first, it’s obvious that traders will notice it and say it’s fraudulent on the network. To what extent does the validity of money exist in a network with a large number of victims, although this cannot be proven? Would not the dishonest person undermine the validity of his own wealth? Then, he should use the second method and prefer to play the game according to the rules.

New to trading? Try crypto trading bots or copy trading

Calculations

Considering the scenario where the dishonest person builds a chain longer than the honest chain, and assuming that p is the honest node’s probability of finding the next block and q is the impostor’s probability of finding the next block, then the work required for the dishonest person to beat the honest chain increases exponentially, so that his chances are beginning exponentially decrease.

If the dishonest person wishes to deceive a buyer with manipulated information, the buyer should listen to the longest chain in which the most work has been put in. The dishonest person, therefore, creates a fork with other miners. Because he is in an effort to fraud others and make what he says true. Since the buyer is aware of this fork, they should wait a bit and watch for new incoming blocks. The buyer prefers the long and honest chain that has left the impostor chain behind, as the impostor’s effort to compete with other miners to obtain the longest chain will require exponential work after a while and it will be difficult to put in new blocks.

Briefly

We will cover a few parts that are not included in this article, which I prepared by addressing the basics of the work, in later articles. To understand detailed how proof of work and blockchain work, you can take a look at this article. Thank you for reading.

Arif Emre Abduşoğlu

Sources:

https://bitcoin.org/bitcoin.pdf

https://youtu.be/bBC-nXj3Ng4 — But how does Bitcoin Actually Work? By 3Blue1Brown

[0]: https://www.coinbase.com/tr/learn/crypto-basics/what-is-a-fork

Join Coinmonks Telegram Channel and Youtube Channel learn about crypto trading and investing

Also, Read

--

--