Jun 13, 2021

6 min read

Cryptography and Blockchain —A Primer

The world has come a long way with cryptocurrencies — from being labelled as an absolute scam or “fraud” to today’s narratives that Bitcoin is equivalent to “digital gold” and that every investor could make $BTC at least 1% of their portfolio. However, we continue to see great volatility in the crypto market. To put things into perspective, as at 1 May 2021, the total crypto market capitalisation has grown by almost 1000% (from ~$240 billion to ~$2.4 trillion) compared to the same day last year, before the so-called “market crash” happened over the last month which brought the total market cap down to ~$1.5 trillion as at 1 June 2021 (which, by the way, still represents a a growth rate of more than 500% year-to-date).

We all may have different views as to the future of Bitcoin, but there seems to be one thing that everyone agrees on — blockchain technology is here to stay and it is going to be revolutionary and disruptive to the world of finance and (potentially) just about everything else.


A brief history of cryptography

Cryptography has long been used in humankind. Back in as early as 400 BC, the Spartans used a cipher device called the scytale to send secret military commands. Julius Caesar applied cryptography by left shifting each alphabet in a word by 3 positions (e.g. the word “EAST” will be ciphered into “ZXPQ”) in his letters — a method known as the Caesar’s cipher. This “substitution cipher” method was also implemented by the Enigma Machine, which was essentially a typewriter that automatically and algorithmically converts text into ciphertext that is much harder to decrypt. 158,962,555,217,826,360,000 permutations may seem tough enough, and yet we could all remember the heroic scene in The Imitation Game (rewatch it here) when Alan Turing finally cracked the Enigma Code.

Cryptography is the science of communication in the presence of adversaries.

Modern day cryptography

Almost a century later, how many more zeroes do we need in order to keep cryptography relevant? Can there still ever be a mathematical problem that can withstand modern day computational power?

Asymmetric cryptography (public key cryptography)

Asymmetric cryptography uses a mathematically related pair of keys for encryption and decryption — a public key and a private key. If the public key is used for encryption, then the related private key is used for decryption.

Source: Wikipedia

As you can see in the simple diagram, Bob’s message was encrypted using Alice’s public key, and can only be decrypted using Alice’s private key. Only Alice (with her private key) can decrypt the ciphertext back to plaintext. This one-way nature of the encryption function also means that Bob is unable to read/decipher the messages of Charlie (another sender), even though they both have Alice’s public key.

Cryptocurrencies are not the first use case of this method of encryption. In fact, we are already applying cryptography in our everyday lives when we send encrypted e-mails, or surf websites secured by the SSL/TSL cryptographic protocols (web addresses that start with “https”).


A blockchain is a decentralised, append-only database that stores transactions across a peer-to-peer network. I will try to explain blockchain in a simple analogy below:

In a village that has no chief, the villagers agree to record all their trades in a public ledger, where every villager may choose to maintain a copy of it (a node). At the end of each day, all the transactions (hashes) that took place in the village on that day will be recorded in an extra page of log (a block), which will be replicated and appended onto the back of every villager’s copy of the ledger. The process repeats itself everyday, and each new page is chained together with the last page. The villagers therefore name this system as a “chain of blocks” or a blockchain.

The benefits having such distributed, append-only ledger called the blockchain are as follows:

(1) It is immutable — being a time stamped, append-only ledger, once a transaction is added to the ledger, you can’t really amend the content in the ledger (unless you manage to convince more than half of the villagers to amend it in their copies as well);

(2) It is trustless and (can be) permissionless — no one central authority is entrusted to maintain the ledger or to sanction any of the transactions;

(3) It is transparent — anyone can choose to keep a copy of the ledger, and everyone can read the ledger to verify any transactions made in the past;

(4) It is highly traceable — Blockchain creates an incorruptible audit trail over any the assets or transactions that are stored thereon, which can provide an irrefutable proof of authenticity and ownership over any assets; and

(5) It can be more efficient— cryptocurrency transactions are done directly (peer-to-peer) without the need of any trusted middlemen. This can potentially make transactions much cheaper and faster.

Cryptography in blockchain

Blockchain technology today uses modern day cryptographic algorithms to secure the network and prevent its content from being tempered with as a whole. Public-private key encryption, cryptographic hash functions and digital signatures together constitute the foundation for the blockchain. These cryptographic features make it possible for each block to be securely linked or “chained” with the previous block, and also ensure the reliability and immutability of the data stored on the blockchain.

If you are interested to learn more about the technical side of things, check out this MIT OpenCourseWare lecture conducted by Gary Gensler on how the SHA-256 hash functions are used to record transactions in the Bitcoin blockchain.

Satoshi Nakamoto’s 2008 Bitcoin whitepaper

Bitcoin is the first successful use case of blockchain technology, and definitely one we should look into when learning about how blockchain works, both technically and economically.

In the 2008 whitepaper (which I strongly encourage everyone to read it at least once), Satoshi Nakamoto introduced the use of blockchain technology in a peer-to-peer electronic cash system, where the native currency in the system is then called Bitcoin.

The Bitcoin network runs on a proof-of-work consensus mechanism which requires the participant nodes (i.e. miners) to prove the work done and submitted by them (by way of GPU computational power). This in turn qualifies them to receive the right to add new transactions to the blockchain. The whitepaper explains the process of mining as follows:

The steps to run the network are as follows: 1) New transactions are broadcast to all nodes. 2) Each node collects new transactions into a block. 3) Each node works on finding a difficult proof-of-work for its block. 4) When a node finds a proof-of-work, it broadcasts the block to all nodes. 5) Nodes accept the block only if all transactions in it are valid and not already spent. 6) Nodes express their acceptance of the block by working on creating the next block in the chain, using the hash of the accepted block as the previous hash.

In step 4 above, the first transaction in each new block will be the release of new (mined) Bitcoins to the creator of that block as a reward for the proof-of-work. This serves as incentives for the villagers to diligently maintain their copies, contributing to the integrity of the network and keeping the network decentralised at all times.

Insofar as security is concerned, Satoshi acknowledged that, whilst it may be impossible to keep the blockchain immune from a 51% attack, it was explained that the underlying incentive model aims to make it computationally impractical for any dishonest node operators to do so in a profitable manner.

The potential of blockchain technology

While blockchain technology has come to be thought of as the foundation for Bitcoin​, it has evolved far beyond underpinning a digital currency like Bitcoin.

What I described above is really just a tip of the iceberg when it comes to what blockchain technology can do. With the adoption of self-executing smart contracts that run on blockchain, the potential use cases of blockchain technology are virtually unlimited — from decentralised finance (DeFi) and non-fungible tokens (NFT) to supply chain management and public elections — you name it. Blockchain-based Web 3.0 is going to be game changing.