(Editor’s note: This is a four post series on Bitcoin, which will cover the virtual currency’s protocol and ecosystem as well as where Europe stands in terms of Bitcoin innovation, research and opportunities. This first post sheds light on how Bitcoin works and its underlying technology.)

Many are saying Bitcoin is the new black. But how many people really understand what the digital currency means for the future?

I’m tired of reading post after post on the economic ramifications of Bitcoin; on how this new virtual currency is unsafe for trading due to its volatile nature…

mtgox

Fig. 1: Mt.Gox trading after the attack that made them bankrupt

How about the volatile nature of the current markets after the Crimea incident, which made the FTSE 100 slip by 1.4%, or when NASDAQ halted trading for three hours disrupting the $16 billion Facebook IPO?

ftse100

Fig. 2: FTSE 100 trading when Russia invaded the Crimea peninsula

It seems very few people writing and covering Bitcoin really understand what cryptocurrencies are all about, the genius of its design and the potential for it to change the digital landscape.

The problem with digital currencies

To really understand Bitcoin, we have to go back to basics – how does currency work in the physical world?

Imagine you go to a cafe and buy a coffee. The purchasing of a coffee implies a transaction where two goods have been exchanged. In particular, the vendor hands you a beverage and you, the customer, give a token in exchange, which represents an accorded value (be it coins or bills).

Currency Transaction

One property of physical currency that prevents – to some degree – fraudulent usage is its physical nature. When you pay with a coin or bill, the physical token gets transferred to a new pocket, the vendor’s, and there is a kind of validation that you were the true owner of the token since it came out of your pocket. The token can also be verified for its authenticity with certain instruments.

Digital currency attempts to replicate the previous transaction but the main difference is that the token exists only in digital form. For instance, imagine we scanned a five euro bill and named the digital image ‘five-euros.jpg’. Being digital has many benefits, but also comes with drawbacks, namely, that files are easily cloned and the copies are indistinguishable from the original.

This poses two big problems for its use as currency:

Firstly, there can be infinite digital copies of  ‘five-euros.jpg’, which means potentially having two (or more) customers owning the same exact five euro bill image file and not being able to distinguish who the owner is.

Secondly, since the digital file can be copied many times over, theoretically, it’s possible to clone the bill and spend it as many times as desired – this is referred to as double spending (step 2 and 3).

 

Digital Currency Problems

Fig. 3: Problems with digital currency transactions 

Cryptography to the rescue

Luckily for us, modern computer science has figured out a way to deal with some of the previously-mentioned issues through the use of cryptography. The ownership problem can be solved with the use of what’s known as public-key cryptography.

It’s a way to protect a digital asset from prying eyes via a complex mathematical process called ‘ciphering’, which scrambles the original digital content in plain text so only the person with the right password, called a key, can unlock (or decipher) it.

One of the most common uses of public-key algorithms are digital signatures, which are the equivalent of a real-life signature allowing anyone with the right key to sign digital assets and prove they are the rightful owners of it.

The catch about public-key cryptography is that there isn’t a single key but two – the private key and the public key.

The private key, as its name implies, is kept private and used by the owner to sign any digital file under their name. The public key, which is mathematically related to the private key, verifies that the digital file was, indeed, signed with the private key. Additionally, this public key can and should be shared among anyone who wants to verify ownership claims.

Digital Signature validation 

Fig. 4: How digital signature algorithms can be used to verify ownership of a digital token

So what exactly is Bitcoin?

Bitcoin is a digital currency that effectively employs cryptography (as seen above), which is why it’s called a cryptocurrency. In truth though, with Bitcoins, there are neither physical or digital tokens being exchanged.

Instead, the only representation of the currency is an entry on a ledger, which records a monetary transaction. In it, Person A sends X amount of Bitcoins to Person B – this is similar to what a typical bank ledger contains. 

In the case of a bank, both Person A and Person B would own a bank account and be identified through a numeric ID. The ownership is clearly stated via ID cards, signed contracts, etc. when you open the bank account. 

But in the case of Bitcoin, any person can generate a pair of public-private cryptographic keys that can be used to create the equivalent of a bank account, dubbed a ‘Bitcoin address’. It’s essentially an acronym of the public-key and it uniquely identifies the owner of an account.

Bitcoin address generation

Fig. 5: Generation of ECDSA public-key pairs to obtain Bitcoin addresses

At its core, a Bitcoin address is a numbered bank account, but without a bank and or any ties to the identity of the owner.

As you’re probably figuring out, the fact that anyone with a simple computer (OpenPGP, GnuPG, ssh-keygen, OpenSSL, etc.) can generate a number of sets of keys to use as Bitcoin addresses with total anonymity is one of the reasons why many banking organizations (in Russia, China and Europe) are banning the crytocurrency.

Delving into transactions

As previously mentioned, Bitcoin is not a tangible digital asset, rather, it’s a transaction that gets recorded on a ledger called Blockchain. This transaction basically holds the origin of funds (inputs) as a Bitcoin address and the destination (outputs) as another address.

Simple Bitcoin transaction

Fig. 6: An example of a simple Bitcoin transaction

To ensure the ownership of funds, the whole transaction file is digitally signed with a private key by the user sending the funds (the customer in our case). Then, the signature along with public key are enclosed in the transaction. This allows anyone to validate the transferred Bitcoins are really owned by the sender.

Though the origin of funds address is derived from the enclosed public key, in theory, no one knows the true identity of the owner of that public key. The same goes for the destination, which is represented by another Bitcoin address, and doesn’t even have a public key to match with the owner.

To keep it simple, we’ve shown the point of view of the two parties involved in the transaction. If we saw this transaction from the outside, we would only see random Bitcoin addresses and have no idea who owned them.

Transactions, though, don’t exists on their own. Each transaction input is a pointer to a previous transaction. In other words, the input used in a transaction was the output of a previous transaction. Blockchain stores this linked list of transactions so any Bitcoin can actually be traced to its origin.

Linked Bitcoin transactions

Fig. 7: An cxample of two linked transactions

The Bitcoin transactions stored in the Blockchain can be very simple (above), or become very complex with multiple input and output sources (below).

Single input - Multiple output Bitcoin transaction

Fig. 8: A single input-multiple output Bitcoin transaction

Multiple input - output Bitcoin transaction

Fig. 9: A multiple input-multiple output Bitcoin transaction

Why would we want multiple inputs or outputs for a transaction? Because Bitcoin transactions don’t specify how much you transfer from the inputs, which means it will transfer all the Bitcoins associated with an address. It’s similar to trying to pay a three-euro coffee with a 20 euro bill.

To prevent this from happening, it’s possible to add extra output pointing to an address owned by a customer where the ‘change’ will be received (Fig. 8). Likewise, because there might not be enough Bitcoins in a single address, it’s possible to add multiple inputs owned by a customer to match the desired output (Fig. 9).

The role of Blockchain

The original Bitcoin paper highlighted two major goals behind the design of the cryptocurrency: 1) To create a digital currency preventing the double spending problem 2) To achieve the first goal without a centralized third-party financial institution.

In previous attempts to build digital currencies, the ledger was always stored by a centralized third-party. Bitcoin circumvents this by deploying a peer-to-peer network of shared ledgers.

Every client in the Bitcoin network owns a copy of Blockchain, which is public and accessible to anyone in the network allowing unprecedented transparency to the currency.

Bitcoin network

Fig. 10: A broad overview of the Bitcoin network

The Bitcoin network is made out of interconnected clients, called full clients or nodes, that are in charge of validating any transactions received. Once validated, the clients broadcast the transaction to neighbouring until each one in the network has a copy of it.

Instead of storing the transactions as they are, Blockchain bundles them into what is dubbed a ‘Bitcoin block‘. Once a block is created, it will be broadcasted to all the other nodes so everyone can update their Blockchain. Each block is then linked to the previous block, creating a chain that can be traced to the first block ever created – the ‘genesis block‘.

Bitcoin blockchain recreation

Fig. 11: Bitcoin Blockchain recreation since the ‘genesis block’

Users in charge of creating these blocks are called ‘miners’ and the process, unsurprisingly, is called ‘mining a block’.

In the early days, every client in the network was a miner. Currently, miners have dedicated clients that connect to the Bitcoin network with specific protocols. Once a transaction gets bundled into a block and is accepted by a large majority of the network, it is considered official. 

Bitcoin block mining

Fig. 12: Bitcoin simplified block mining process

Once a node receives a block from a miner, it will add it to its local Blockchain and broadcast it to the rest of the network. As we can see below, each block can contain any number of transactions.

Bitcoin blockchain live

Fig. 13: Bitcoin Blockchain live data from Blockchain.info

Transaction fees

So how does a miner select which transactions to bundle into a block? Mostly, it depends on how much money the parties are willing to pay the miner to process their transaction.

In theory, every transaction is processed for free. However, Bitcoin allows its users to ‘tip’ the miners for validating their transaction.

These tips are called transaction fees and taken when the sum of all the inputs of the transaction is bigger than the outputs. The difference between inputs and outputs will be cashed by the miner that processes the transaction into a block.

Bitcoin transaction fees

Fig. 14: Example of transaction fees

By default, many of the Bitcoin software clients will automatically add transaction fees if certain criteria are met.

Safeguarding: Proof of Work

Of course, there’s still a trust issue with the Bitcoin network. If miners are the real validators of the transactions, then any single entity owning enough miners could potentially subvert the Blockchain. With ownership of the network, old transactions could be manipulated and even open up the possibility of double spending.

To avoid this, Bitcoin introduced a safeguard mechanism called Proof of Work (PoW), a small mathematical problem every miner has to solve before sending a block back to the node. PoW is designed so it takes miners, on average, 10 minutes to complete.

Bitcoin proof of work

Fig. 15: Bitcoin’s Proof of Work

The computing power and randomness required to obtain the solution of the problem prevents having rogue agents fully controlling the Blockchain. Essentially, the more computer power you own, the faster you can compute the PoW.

But there’s a catch: Every 2016 blocks (around two weeks), the network checks how fast the miners have worked. If they’ve mined blocks faster than expected, it means the miners have increased their computational power.

To prevent this from happening and tipping the balance, the network modifies the difficulty of the PoW and increases it so the average time to solve it remains at 10 minutes.

Bitcoin Proof of Work difficulty

Fig. 16: Bitcoin PoW difficulty factor evolution.

If mining a block costs computational power, then why would anyone want to do it? Well, miners are rewarded with Bitcoins.

Originally, for every block, miners would be awarded 50 Bitcoins plus any transaction fees. This reward is called a coinbase transaction.

Coinbase transactions introduce new Bitcoins into the system, control the inflation of the currency and, at the same time, deter any attempt to subvert the network. The system is designed under a controlled supply – this means that every four years, the mining reward gets halved.

Be sure to check back for more

For the sake of clarity, we’ve omitted many details about the Bitcoin protocol. That said, we encourage you to ask any additional questions you may have so we can update this post and make it as complete as possible.

Don’t forget, more advanced concepts (and their ramifications) are covered in the next post of the series.

In true Bitcoin fashion, you can also donate Bitcoins if you’re liking the series: 13kbYPnPbhPALfCpSeMgairFYj3W7etRTx

Featured image credit: Julia Zakharova / Shutterstock

  • Joren De Wachter

    great article

    • abarrera

      Thanks!

  • Luís Machado Vaz

    Awesome, finally someone explained me how this works. Great research job