🥖

Home Posts About

Blockchain technology in five minutes

Blockchain is a relatively new technology that all the big newspapers tend to talk about, without actually explaining anything about the technical part behind. And it’s honestly irritating for people with a bit of technical background to find out that nearly all articles and videos about it are overly simplified.

This post won’t be about Bitcoin, cryptographic algorithms or other crypto-currencies. However, if you don’t know some of these terms, please find more information about them here:

Why?

As you will find out while reading Satoshi Nakamoto’s white paper, the Blockchain was originally created because a crypto-currency needed a solid base in order for people to trust it:

What is needed is an electronic payment system based on cryptographic proof instead of trust, allowing any two willing parties to transact directly with each other without the need for a trusted third party.

This technology would also need to prove that each transaction:

  • hasn’t been double-spent
  • hasn’t be falsified
  • happened in some kind of order

These changes would also allow for nearly no transaction costs, as the need for a trusted third party should be removed.

Who?

The person behind Blockchain and Bitcoin technologies is named “Satoshi Nakamoto”. Sadly, that is not a real name, and even if some people claim to be this creator every few months, none has been able to prove it.

What we do know about him is that he:

  • started to look into that decentralized currency idea in 2007, mainly on IRC
  • published his White Paper in Oct. 2008, along with the first batch of code on Sourceforge
  • created the first Blockchain “block” in Jan. 2009 (the “Genesis Block”)
  • began to fade from the scene in late 2010, and disappeared in 2011, saying that he “moved on to other things.”

Do we need to know who he is to use his legacy? Definitely not. But this is still a mystery :)

How?

The Blockchain is made of blocks that contain transactions. Let’s look into these!

Transactions

Blockchain transaction

Alice would like to send 3 bitcoins to Bob. We’re gonna assume that someone else, Chloe sent them beforehand to Alice.

The transaction will have three main parts:

  • the inputs, which are links to the outputs of previous transactions, and kind of “explain” where the coins used in the outputs come from.
  • the outputs, which give instructions to where the coins should be sent. One of these outputs will be to give you back the “change” of what you haven’t used in the inputs.
  • a cryptographic signature to show evidence that you indeed have those coins.

Blocks

Blockchain block

Just think of these blocks as transaction ledgers. What would we need in an information system to have them cryptographically secure?

How to know who has the right block?

The original Blockchain solves that with multiple properties:

  • a hash (to put it simply… a reference) to the previous block
  • some additional pieces of information, such as the number of transactions, the version, and timestamp
  • a difficulty target, which will need to be found by miners for the block to be accepted by the network. You can think of this as an arbitrary puzzle, that is always adjusted so that one block should be found every 10 minutes.
  • a nonce, to help the miners resolve that puzzle
  • a Merkle tree root (don’t worry, it doesn’t bite), that’s just a hash for the transactions
  • a list of all the transactions, including the one that will reward the miner (and when there will be no more coins to mine, fees will adjust to keep the mining going on)

Merkle trees?

Blockchain merkle tree How do you turn a list of transactions into a single hash?

You could just hash a big list of all of the transactions and put it in the Bitcoin header. But that way, you would need to hash the entire list of transactions in order to verify its integrity. Using a tree, you could just verify a chunk and its siblings and you would be sure of their integrity, since hash functions are one-way functions.

How to create a Merkle tree ? Your transactions are gonna be the leaves of that tree, that you will hash and combine until you only have one resulting hash : the Merkle root!

The mathematical problem, or proof-of-work

What we want now is to have our block accepted by the whole network. Do you remember that difficulty target? It indicates how many zeros we need at the beginning of our block hash so that it’s accepted.

Two elements are mostly gonna help us find different hashes until we -maybe- get a good one:

  • the nonce, which is a 32 bit integer in the header made just for that
  • the Merkle tree, because changing the order of any transactions will result in a new root

However, it can be a long and tedious process. As bitcoin.it explained it well:

It’s important to realize that block generation is not a long, set problem (like doing a million hashes), but more like a lottery. Each hash basically gives you a random number between 0 and the maximum value of a 256-bit number (which is huge). If your hash is below the target, then you win.

Is there an easier way to win that lottery? Maybe mining pools, where the transaction reward is split between all the pool members (which is small compared to the full block reward), but you’re sure to at least have a steady stream of income.

Blockchain

As you may expect, the blockchain is simply the combination of all these blocks, where any (except the first one, aka “Genesis” block) is linked to its previous one.

If you want to know what happends when two different miners would try to impose their block on the blockchain (causing a fork), please look at this part of “Mastering Bitcoin”.

And now?

Two other projects are trying to improve the Blockchain technology, not to use it only as a cryptocurrency but with nearly all information systems:

  • Ethereum : https://www.ethereum.org/
  • Hyperledgber, by The Linux Foundation and IBM : https://www.hyperledger.org/

These blockchains have pretty similar goals, which are to change the proof-of-work to something less CPU-intensive, add smart contracts (aka programming in the blockchain), and faster transactions in order to compete with regular systems.

Sources:

  • https://www.oreilly.com/ideas/understanding-the-blockchain
  • https://bitcoin.org/bitcoin.pdf
  • http://chimera.labs.oreilly.com/books/1234000001802/ch08.html
  • https://bitcoin.org/en/developer-guide
  • https://en.bitcoin.it/wiki/Protocol_documentation
  • http://letstalkpayments.com/an-overview-of-blockchain-technology/
  • https://github.com/ethereum/wiki/wiki/White-Paper