High-level Technical recap on the Bitcoin Protocol (that even your grandma can understand)

Christopher Agnus 🐟
Zero to Code
Published in
5 min readMar 13, 2018

Bitcoin is the world’s first successful cryptocurrency in the world — it is a decentralised peer-to-peer network that allows transactions to take place without a central bank or intermediary. Transactions are recorded using cryptography and a public distributed ledger known as the blockchain. In this technical recap, I will explain how the main features of the Bitcoin protocol work.

Addresses and Private Keys

Anyone joining the Bitcoin network needs a wallet, which contains a Bitcoin address: a string of 34 letters and numbers, with a corresponding private key.

For example: an actual Bitcoin address is:

16R5PtokaUnXXXjQe4Hg5jZrfW69fNpAtF

The private key for this address is:

5JJ5rLKjyMmSxhauoa334cdZNCoVEw6oLfMpfL8H1w9pyDoPMf3

The private key is used to sign off transactions from that Bitcoin address. Each Bitcoin address has one corresponding private key. Complex maths equations make it impossible to reverse engineer a public Bitcoin address to find the private key. A Bitcoin user can generate an endless number of Bitcoin addresses & private keys; the length of addresses and potential addresses make it impossible for the same address to be generated twice.

How a transaction works

Using a private key, a user can send money from their address without revealing their private key with anyone else. Let’s call the user Sam. Before he sends out a transaction, the private key in his wallet runs the information through complex maths equations to produce a digital signature. This digital signature is the unique and one-of-a-kind product of his private key and transaction taking place, like a signature on a check.

The signed transaction is broadcast to the network; sophisticated maths equations make it impossible for computers on the network to work backwards to get Sam’s private key.

So, how do they verify that the digital signature was created by the correct private key attached to its address? Again, maths equations are used to verify the digital signature was indeed created by the private key. It is necessary for computers to verify each transaction because there is no central authority to do so. This process checks if Sam has the right private key, then whether the Bitcoin address has coins available to send by scanning all transactions in and out of Sam’s address.

The Bitcoin Mining Process

When Satoshi devised Bitcoin, he realised it would be problematic if each computer recorded every transaction as it arrived. A transaction that was recorded earlier than before reaching another computer would lead to disagreements about the balance in each address. To resolve this problem, Satoshi came up with a clever contest that any member of the network could compete in and simultaneously ensure each transaction was valid.

To win the contest, all the computers were required to compile recent transactions into long lists called blocks. After compiling the transactions into a block, the block is run through another complex math equation known as a hash (which can take any data) and turn it into a 64-character digest, such as below:

000006d77563afa1914846b010bd164f395bd34c2102e5e99e0cb9cf173c1d87000007ac6b77f49380ea90f3544a51ef0bfbfc8304816d1aab73daf77c2099319

The computers/nodes/miners taking part in the contest look for a block that can put into a hash function called SHA-256 and generate a 64-character digest with a specific numbers at the beginning. For example, if the computers were looking for a digest with five zeros at the beginning, the digest above would be a winner.

Like other hash functions, it is impossible to reverse-engineer to find what block will lead to a digest with five zeros at the beginning. However, the same same digest is always generated from a particular input so if all computers put the same transaction into their block, every computer would get the same digest. To differentiate their blocks, a random number is added to the end of the block. Because hashes are sensitive to changes, changing the random number at the end of the block from 20 to 22 could result in a digest from one zero to ten zeroes at the beginning.

To win the contest, miners try different random numbers repeatedly to get a digest with required number of zeros until a winner results. Since finding a winning solution is more than luck than skill, the miner with the fastest computer could run the hash function the fastest would increase its chances of winning — just like someone with 100 raffle tickets is more likely to win than someone with 1 ticket.

The number of zeroes made it easy to adjust the difficulty of the contest and ensure new blocks were produced approximately every 10 mins. As more and more faster computers joined the network, more blocks may be created at a higher frequency than usual. In response, the Bitcoin protocol would adjust the difficulty to demand miners to find digests with more zeroes at the beginning to limit block production to one every 10 mins & vice versa. This is also described as proof-of-work. As of 2018, Bitcoin difficulty has continued to increase exponentially.

Winning Blocks

Proof-of-work is named a such because it is costly and difficult for miners to produce the winning digest, but easy for other miners to verify that block did generate a digest with a desired number of zeroes in the beginning. Satisfied with the digest, the computers would add the winning block to the blockchain stored on every single computer, thus recording the list of transactions included in the block. The added block becomes the official record of recent transactions. Any transactions occurring left out would be added in the same process in future blocks. The block also adds a reference to previous block and data, which is built on previous preceding blocks.

If there are any disagreements over a winning block (such a rogue actor trying to falsify records) the computers would vote for the correct block by majority-rule to be added to the main blockchain.

Why would people mine Bitcoins?

It keeps the network secure by validating transactions. Additionally, winning miners that generate a block also win a bundle of bitcoins — 50 BTC when the system first began, and then to halve every 4 years or so. When the miners are assembling a list of transactions, they include a transaction granting their own Bitcoin addresses 50 BTC from thin air. The transaction that created new Bitcoins is called the coinbase of a block.

--

--

Christopher Agnus 🐟
Zero to Code

Hi, I’m Christopher (Agnus) Lam. I write about startups, entrepreneurship and marketing.