Bitcoin deep dive | Part 2 — Blockchain

Blockchain

Mark Vaykhansky
3 min readFeb 20, 2022

A blockchain is an append only data structure who’s authenticity can be simply verified. It is literally a chain of blocks. Each block contains some data, the hash of the previous block and it’s own hash. The hash is calculated using a cryptographic hash function.

Lets look at a hypothetical blockchain which contains data regarding transactions:

Credit: thebalance.com

The initial block contains the first transaction, a previous hash of 0 and it’s own hash. The second block contains the hash of the first block, the second transaction and it’s own hash.

Let’s denote the i-th transaction as t(i), the cryptographic hash function as h, the hash of the i-th block as h(i) and the contents of the i-th block as b(i).

b(i) = h(i — 1) + t(i) + h(h(i-1) + t(i))

As you can see, the contents of the i-th block are determined by the hash of the of the previous block and hence by the content of the previous hash. If someone changes the transaction of block i than:

  1. If the hash of the i-th block did not change than the i-th block is now invalid making the chain invalid.
  2. If the hash of the i-th block did change according to the new transaction, the hash of the i+1’s block is now invalid.

Since cryptographic hash functions are very quick to compute and have no collisions, as we’ve covered in the previous article, an entire blockchain can be easily verified.

Those characteristics make the blockchain essentially append only and verifiable database.

Ledgers, Blockchain and Bitcoin

Some of the most ancient writings found in history were those of ledgers. Man kind has been tracking ownership of commodities and goods forever. Keeping track of resources is essential for a well functioning society let alone a stable economy.

Banks are essentially centralized and regulated entities that keep ‘giant’ ledgers of all the money (and other financial assets) transactions that ever occurred. Given that information the concrete balance of each bank account can be derived for any point in time.

Two of the most important characteristics of a ledger are being append only and verifiable. A ledger being append only is one crucial step towards dealing with the double spend problem.

Briefly explaining, if I could gave 1$ to Alice and then changed the record in the ledger stating that I gave that 1$ to Bob it would essentially be as if I made 1$ out of thin air, that is called a double spend.

We would like our ledger to be append only with chronological transactions. That way, assuming for the sake of simplicity that there is only a single ledger in existence, no one can spend more money than they actually have preventing the double spend problem.

Verifiability is just as important. Given a transaction it is valuable to be able to verify it’s validity. That way no one can transfers more funds than he owns or transfer someone else’s funds.

Bitcoin is a digital ledger which is stored on a blockchain. Each block on the Bitcoin blockchain contains transactions between two Bitcoin addresses. The characteristics of the Blockchain, being append only and verifiably, are exactly what is needed of a good ledger.

Take Home Message

Blockchain is an append only and verifiable database. Those characteristics make it a good candidate for using it to store a digital ledger. Bitcoin is essentially a blockchain of transactions between Bitcoin addresses.

In the next part we will explore Bitcoin addresses and transaction hashing.

--

--

Mark Vaykhansky

I'm a Software Engineer passionate about technology and leadership