Investigating the blockchain

Investigating the blockchain

What is the blockchain?

There is plenty of blog posts describing the block chain - or blockchain as we have come to know it - who 'invented' it, what it is used for, and what not. My point of view is one of trying to understand the principles and drivers of the blockchain and document my findings. In that sense you will not find new information here, no Heurekas!, no warp drives and no blueprints to the Death Star.
What I hope to illustrate is the motifs and nuts and bolts of the blockchain - and thus why it is so very different then what we know and are customed to, today!

A digital, decentralised ledger

A post with wide reaching implications and profound knowledge of and insight into the blockchain by the cryptoeconomics.com.au team! I will return to this post a number of times in the following.

Why a blockchain at all?

You do have a point! The blockchain is really nothing but a stack of hashes and timestamps - and what are we really looking to achieve?

The keyword ledger keeps popping up. By now we know what ledgers are but what makes the blockchain especially suitable for managing ledgers? Well, we demand a lot from ledgers, but particularly

  • immutability
  • portability
  • proof of ownership
  • serialization
  • permissiveness

and it so happens that blockchains are very good at managing these issues as we will see in the following;

Immutability

Once you have stored a piece of information you'd like that chunk of data to sit tight and not erode, not at all! Not by the hands of others not by accident on your own behalf and not due to some glitches in the power grid!

If you are entirely on your own, in the whole world, you'd probably carve each piece of information in stone - that would last you a lifetime, but birds, weather, even sun light will degrade your persisted data over time!

You should devise some mechanism to make sure the chunk of data that you carved in stone has not be altered by some one or something. Writing all of it twice, thrice, or whatever number of times might work - but will cost you a lot! Your transaction costs will increase by the cost of each 'backup'.

Hashes

Loosing the entire stream of data can easily be avoided if you compute hashes of parts of the stream. So you decide to divide the chunk of data into 2, 4, 10 smaller chunks and compute a hash of each smaller chunk. Now your transaction costs will only increase by the cost of carving each hash. It's not like you get backups for free and the hashes are not really that easy to unhash to get to the chunk of data hiding behind the hash but cost-wise it is very attractive compared to doing 1:1 backups of all the real data.

Merkle Tree

Hash_Tree.svgThe hashes (that verifies the data structures from which the hashes where built) are organised like a tree's roots and the concept behind these hashes was patented by Ralph Merkle in 1979, hence the name Merkle Tree!

Portability

Now that you have all your data secured by a Merkle Tree of hashes, it is a lot easier to share data between yourself and your peers. As it turned out the two of you were not alone in the World after all!
So you hand over an entire copy of all your data.
Next up is some change! Your peer tells you that she has changed some of your data and now she asks you what to do!? Should she travel all the way back to you with all the (new)data?
You tell her back that all she needs to tell you is the hashes - one at a time. By the time she has finished, you know exactly what data block to ask her to bring. It was that block #4972 she'd been messin' with, wasn't it?

Coming back to ledgers and portability, and bitcoin in particular, the blockchain is really just a chain of data blocks.

Blocks

In the illustration on the left, there are really 4 chains but only one main chain. The three orphaned chains are the result of the blockchain being distributed. The girl you trusted with an entire copy of your data, did herself forward it to 3-4 of her friends. One of them made a change (let's pretend it was the first purple on the left from the bottom). 150px-Blockchain.svgNeither you nor your girlfriend made a note of that change and later on when you both made several more changes, their change became more and more out-of-date. Next up is the first couple of purple blocks on the right as seen from the bottom. Let's pretend you made a change which neither your girlfriend nor all of her friends did make a note of. Later on you and her made a change, but the rest did not make note of that change. Then finally at the last 'y' from the bottom, your girlfriend and all of her friends did make a change (that you also did not make a note of and by now your 'chain' was getting out-of-date, and you had to double back down and make notes of changes your girlfriend and her friends did, in effect getting your chain back on track).

Proof of Ownership

220px-Bitcoin_Transaction_Visual.svgThe blockchain used by Bitcoin uses a proof of ownership to demonstrate who did what. This proof is a public/private key combination which is compiled into the published blocks. Any user can generate a key pair (public/private) and because it is highly unlikely that this key pair will be broken - ie someone will be able to find the private key from the public key part alone - the public key can be distributed and used as proof of ownership. When questioned a user will provide a chunk of data encrypted with her private key and once decrypted with the public key pair, demonstrate that some data signed with the public key is in fact her.

Serialization

In a 'paper' ledger it is effortless to verify which transaction predates some other transaction. If the transaction is written on line 10 in the ledger every transaction before line 10 predates the one on line 10.

Digital ledgers do not enjoy this comfort! Blocks may arrive from right and left, hence the blockchain uses timestamps to decide which block made it first to the chain. This timestamping is at the core of the blockchain utilized by Bitcoin. It incorporates a proof of work allowing someone to publish a block.

I have no clue how the algebra works but it goes a little like this:

  1. you post at transaction to the bitcoin network (which I currently do not know where sits but concists of coindealers)
  2. miners grab your transaction there (they can see that the transaction is unconfirmed) and starts to building a block from it (together with up to a MB of transaction data all together). In order to publish the block a miner will have to find a nonce that when hashed together with the lump of data has some particular characteristics.
  3. Euphorically when he succeeds the miner will publish his success and if she is the first miner to publish a new block (and other miners do make a note of his work) she wins - and am able to collect on the reward (a small sum of bitcoins) he anticipatently sneaked onto the top of the transaction, to compensate his effort
  4. The coindealers make a note of the newly minted block and tell you that your transaction is now a fully, confirmed, and legit member of the blockchain. The entire process is about 8-10 minutes in the making but until 6-10 miners have 'confirmed' the work done by the first miner, your transaction is not safe from becoming purple (using a metaphor from the illustration above).

Permissiveness

permissioned ledger - is a ledger where 'users' are permitted access based on some logic, whereas permissionless ledgers trust the choice of 51% of all users to telling the truth.

Permissioned ledgers require monitors, assessors, rulers. Permissionless ledgers do not. Illustrated above permissionless ledgers are "built" from the chain of blocks from which the most (at least 51%) use the hash to building the next block.

An example

YouTube is about to burst from the load of instructional videos on all sorts of topics - and "how the blockchain works for Bitcoin" is no different. I probably missed the best one but I kind a like the simplicity of this one though!