Blockchain Basics
By: Andras Kristof
Tags: Ethereum, Blockchain, Bitcoin

The Fundamental Problem

In 2008, Satoshi Nakamoto published his now famous whitepaper titled “Bitcoin: A Peer-to-Peer Electronic Cash System”.

In this he laid out the structure of Bitcoin, the first blockchain system. The paper proposed a solution for the problem of double spending in a trustless environment.

This does not seem very interesting, let alone revolutionary; so let’s spend some time with describing the problems:

The double spending problem is that if I have a piece of data in a digital form, I can send the same data to multiple people. For example nothing prevents me from sending the exact same photo of a cute kitten to multiple recipients by email.

That is the expected behavior. But if I could do the same thing with my 1 bitcoin, then it would be a problem. It is not by accident that the title of Satoshi’s paper has the word “cash” in it. It is because bitcoin must behave exactly like cash: If I have one 100-dollar note and I give it to Alice, then it is impossible to give the same note to Bob. We don’t need a central authority to control that. By the nature of things, I can’t give the same physical object to two different people.

That is the normal and expected behavior of objects in the real world. You can’t “double spend” real world objects.

Note that double spending in a centralized system is not even an issue. If you have only 1 dollar on your bank account, it is trivial to make sure that you can’t send that 1 dollar to Alice and to Bob. The bank, the central authority of the system makes sure that you can’t do that.

So that was Satoshi’s great discovery: He (she? they? it?) found a way to solve the double spending problem in a decentralized (trustless) system. (Decentralized in this context means that there is no central authority that controls the system.)

Enter The Blockchain

Satoshi’s solution was to record the transactions in a ledger that exists in many copies. Every person using the blockchain will have the ledger downloaded to their computers.

Every person who has the full ledger has the record of every single blockchain transaction ever made, starting from the very first one between Satoshi and the legendary Hal Finney, to the last one, whatever that is.

The transactions are organized into blocks. A checksum number (hash) is calculated from the full block. Then this hash is included into the next block. this way the blocks are chained together — hence the name.

Transactions

Technically every record in the bitcoin blockchain is a record of transaction. The transaction has to happen between two bitcoin addresses or wallets.

The owner of the wallet can prove their ownership by signing the transaction with their private key.

Wallets, Addresses, Public and Private Keys

Bitcoin uses Public Key Cryptography. In this system, every address has a private key. If someone knows the private key of an address, then that person owns the coins in that address.

Since there is no central authority, if the private key is lost, the funds on that address can not be recovered. There is no password reset.

New addresses and their corresponding private keys can be generated by publicly available algorithms. Anyone can generate a new address and the corresponding private key. Because of this, it is technically possible to generate keys that have already been in use. For example it is possible to generate the key that holds Satoshi’s million bitcoins.

Possible, but very, very unlikely.

But it’s a fact that the only thing protecting our wallets from others is the large number of possible combinations of keys. So a collision is very, very unlikely.

Public and private keys work by using asymmetric algorithms. An asymmetric algorithm is where it is very easy to prove that the solution is right, but very difficult to find the solution.

For example it is easy to find the sum of these two prime number: 131,071 + 280,859 =411,930 , But if we are only given the result, there is no trivial way to find out what primes we need to get the result.

Another example is that if we are given an old printed phone book (“Yellow Pages”), finding the phone number of a given name is trivial (we just have to search in alphabetic order). But finding out what name belongs to a given phone number is very difficult. The only strategy is to search every page one by one until we stumble upon the number and its name.

Blockchain technology is using asymmetric algorithms and public key cryptography extensively.

Mining

Creating a New Block

Mining is a process of confirming transactions. The miner’s job is to collect unconfirmed transactions, verify them, and put them into a block. For this work, the miner gets to collect the transaction fees, and the “block reward”. The block reward is newly minted bitcoin, created by the network.

Mining As A Competitive Sport

In a centralized system it’s easy to come up with an algorithm that decides which miner gets the privilege to mine the next block.

But in a decentralized system, it’s a real challenge. Fair and random distribution is needed for two reasons:

It is important to fairly compensate all miners for their work. It would be a security risk if it would be known which miner is going to mine the next several blocks.

Satoshi’s solution was very good: he came up with a “distributed lottery”. He used an algorithm similar to the Yellow Pages example above. Finding the solution can only be done by going through all permutations, but verifying the solution is trivial.

Anyone can participate in the “draw”, and more processing power grants better chances to “win the lottery” and get the privilege to “mine the block” — verify the transactions and create the block.

Proof Of Work, Proof Of Stake

The above mining algorithm is a “Proof Of Work (POW)” algorithm. It worked well, although it did start a digital arms race, which we will cover later.

There are other “Proofs” as well, most notably “Proof Of Stake (POS)”, which approaches securing the network from a different angle. Both systems are designed to reward participants that help the network, and punish the ones that go against the network.

Here is a very good definition from the OmiseGo blog:

In PoS, we skip all the hardware and burned energy. Validators just put their investment (in the form of tokens) directly into the system, where they are rewarded in the form of transaction fees for non-faulty behavior and are penalized for faulty behavior. That penalty can take the form of either hard slashing (loss of all staked tokens) or soft slashing (loss of returns).

Conclusion

Bitcoin, the first known blockchain system was created to solve the double spending problem in decentralized systems.

It was made to recreate the functionality of cash on a decentralized network, like the internet.

The same way as I can hand over cash to anyone I like, I can send bitcoin as well, without the need of a 3rd party approver. This differentiates Bitcoin from centralized networks, for example banks.

The blockchain is transactions organized into blocks that are chained together with hashes.

The bitcoin blockchain stores transactions, not bitcoins. You have 1 btc if a transaction of 1 btc points to your address.

Miners are the transaction validators. They get the privilege to create a new block by participating in a distributed lottery.