Understanding Bitcoin

Ronak Vijay
8 min readJun 13, 2022

Bitcoin is the breakthrough innovation that started the crypto movement. It’s a protocol that is censorship-resistant and purely works on the basis of mathematical concepts(the only absolute truth we can trust).

People call it a currency, token or digital gold, but it is best defined as a digital asset. Its value comes from the community’s trust in its design. Bitcoin was proposed at the time when we were in the middle of the financial crisis (the year 2008) and lost faith in banks.

Bitcoin white paper defines it as a peer-to-peer electronic cash system that is independent of any financial institution. For the first time in history, you can make payments digitally without relying on any third party.

Bitcoin vs Fiat money

To call anything money it should have value and mutual trust. We value fiat money because we have trust in our governments if we don’t trust, the paper money has no intrinsic value. Given the rising inflation, the value of fiat currencies has decreased over time making them a poor store of value.

However, with Bitcoin instead of trusting any one single party, we trust the open-source Bitcoin protocol and the consensus (the community that runs Bitcoin, you can also be one). Bitcoin design makes it hard for any one single node to alter the state of the network without the mutual agreement of other nodes. Moreover, bitcoin has a hard cap of 21 million which means there can only be 21 million bitcoin that can ever exist(~4m are lost forever) this makes it comparable to gold and make it valuable.

Bitcoin solves the Double Spending Problem

When you transact in a physical cash world things are easy and smooth. The receiver gets the money in exchange for items and the transaction happens instantly. However, things get interesting when done digitally. In a digital world, data is easy to copy and duplicate. How a receiver can be sure that the digital money sent is legit and not spent anywhere else. When the same digital money can be spent more than once it’s called the double-spending problem. This is only a concern of digital money as physical money cannot be in two places at once.

The current solution to the double-spending problem introduced central authorities that process and monitor each transaction that users trust. Bitcoin removes this dependence on authority and provides a solution to the double-spending problem by using an immutable distributed ledger running over a network of independent nodes.

We may argue that what’s the point in removing the mediator for digital payments, we trust the banks and it’s good to have someone who can monitor the transactions and thus preventing fraudulent attempts. Due to this monitoring, digital payments accrue unnecessary cost which goes to the financial institutions, and takes time to process (sometimes even days if transacting across borders) plus there is often an amount limit for a transaction. With Bitcoin, you can make a payment in roughly 10 minutes to anyone in the world for any arbitrary amount. How it all works? Let’s dive in…

First, some cryptography concepts

  • Cryptography — Cryptography is a branch of computer science that provides techniques to protect information. It’s all about secure communication safe from attackers and is at the heart of the Bitcoin protocol. Originated from Greek words ‘kryptos’ (hidden/secret) and ‘graphien’ (to write).
  • Public-private key pair: Two random strings mathematically linked are used to encrypt and decrypt messages. This is called asymmetric encryption where separate keys are required for encrypting and decrypting the message. You make your public key public i.e., you share it with people so that they can send you encrypted messages. To decrypt the message you are required to use your private key which is private to you and only you have access to. You store your private key in a safe place.
  • Hashing — Hashing is the process of converting any form of data into a unique fixed-size output that cannot be decrypted again. Hash functions are deterministic which means they will always produce the same output for any given input.
  • Digital signature — A mathematical technique to sign digital data using the private key and make it encrypted. Digital signatures confirm that the message originated from the right source with the signer’s approval and is not altered. The only way to decrypt and authenticate is to use the signer’s public key. This makes digital signatures tamper-proof and secure.

check the encryption example here

Bitcoin address

When you open a bank account, the bank gives you a unique account number that you use to send and request payments. In Bitcoin (or any other cryptocurrency in general) you have addresses that are generated by applying a hash function on your public key. The address consists of between 26–35 alphanumeric characters which you can share to receive funds.

Bitcoin.org BTC address 3E8ociqZa9mZUSwGdSmAEMAoAxBK3FNDcd

Bitcoin software runs on a number of computers across the globe, the most popular being Bitcoin Core. Each computer in the network is called a node and they are the ones who maintain the network and validate transactions. There are roughly 16k nodes present in the network as of now.

Each node contains the full copy of Bitcoin’s ledger which have all the transaction data and connects to other via a peer-to-peer network. If any one node shutdowns there are others running and maintaining the network.

Wallet creates the public-private key pair and then creates the Bitcoin address using the public key which can be shared to receive bitcoin. To make a transaction you use the private key to digitally sign it and send it to the nearby node, all is being done by the wallet.

UTXO Model

Bitcoin does not store accounts with balances as in the traditional accounting model. In contrast, it uses the UTXO model (Unspent transaction output) to keep track of each and every bitcoin. UTXOs as the name says are unspent amounts of an account stored on Bitcoin’s ledger. When you make a transaction your account updates are not done in BTC but in UTXOs.

For example, your account is showing a total of 1.5 BTC this balance is made from two previous incoming transactions of 0.7 BTC and 0.8 BTC now if you want to send 1 BTC to Bob, both of these amounts will be the input to the new transaction with having two outputs 1 BTC and 0.5 BTC. Your account UTXOs 0.7 and 0.8 will be destroyed and will now have 0.5 UTXO, which shows as 0.5 BTC as the new account balance. Bob sees his account balance as 1 BTC which he can further use to make new transactions, he now has 1 UTXO unspent bitcoin.

A Bitcoin transaction can have multiple inputs to make up the total payment amount and at most two outputs one is the payment amount itself and the other one leftover if any which goes back to the sender.

Bitcoin uses the UTXO model, source Bitcoin whitepaper

Bitcoin Protocol: behind the scenes

There are two main actors involved in the Bitcoin ecosystem — Validators (network nodes/bookkeepers) and Miners (specialized nodes/block creators).

For any software system/or protocol to be accessed it needs to be hosted somewhere, as bitcoin is decentralized it uses a peer-to-peer network where instead of it running on a single computer it is distributed and runs over thousands of computers across the globe (Similar to BitTorrent file sharing). These computers are called nodes.

Each node is independent of others and stores the full copy of the ledger (Bitcoin’s blockchain) from the genesis block to the latest. Anyone can become a node by running a Bitcoin client software, the most popular being Bitcoin Core. Nodes do the following:

  • Validate a transaction ensuring that bitcoin is legit
  • Once Validated, updating the state of the transaction to ‘pending’
  • Broadcast the transaction to nearby nodes via gossip protocol until each node in the network knows the transaction and moves it to ‘mempool’ (a pool of pending transactions)

Miners randomly pick transactions from mempool which aren’t included in previous blocks and encapsulate them in a block of transactions. Instead of executing individual transactions Bitcoin process a bunch of them at a time. A block can contain thousands of transactions.

Miners solve a puzzle to validate the block the process is called Proof of work — all miners will compete to solve this puzzle basically calculating a cryptographic hash (a number) less than a target number. The target number is based on the number of miners available in the network its difficulty increases with more miners and decreases with fewer.

All minors randomly come up with a hash and check if it’s smaller than the target number if not they do this until they get a smaller number. As we now know that Bitcoin block consists of a number of transactions, there is a special part in each block reserved for miners that is a place to input an arbitrary number called a nonce (number once) which miners input in the hashing function and then check if the result is less than the target number if not they keep doing it until they find a valid block. This process is called mining.

Once the miner finds the target number the block gets created and the miner passes the block and nonce back to the nodes. All miners stop mining and move on to creating new blocks and the process repeats.

Nodes again verify the hash using the nonce provided, once verified each node updates its ledger, and the transactions in the block get confirmed. Miner gets the reward of solving this puzzle in newly minted bitcoins plus the transaction fees of all combined transactions in the block. The new bitcoins that miners earn is a special kind of transaction called a coinbase transaction. After the block is verified it gets chained to the previous blocks forming the longest chain of CPU power. Altering this chain is computationally impossible.

Bitcoin chain of blocks, source Bitcoin whitepaper

The proof-of-work difficulty gets adjusted every two weeks to target an average of 6 blocks per hour (for the whole network). The coins given to miners per block are cut in half every 4 years. Initially, the block reward was 50 BTC per block and now it’s 6.25 BTC, it will halve again in 2024 to 3.125 BTC. It’s estimated that by the year 2140 all the bitcoins will be mined and be in circulation leaving transaction fees as the only reward to miners.

Bitcoin transactions are public

Bitcoin transactions are public and traceable by design. Although your information is not shared like IP and name. Block explorer is a service that acts as a search engine for Blockchains. They allow anyone to query blockchain data like transaction history and balances. Block explorers provide API support so that can be queried and used to retrieve blockchain data. These block explorers use a node from the network or deploy a node themselves in the network. as each node in the network stores the whole transaction history, block explorers then organize this data in an easily searchable format. Here’s an example to checkout.

Final Thoughts

Humans are the one who gives value to things. At one time in history, we used cowry shells as money which was accepted everywhere in the world. We then started using gold as a form of money and then now paper money. Bitcoin is secure, decentralized, and finite making it comparable to gold in the digital world. Many times in history Bitcoin crashed but the belief of the community kept it going. Whether it will completely replace fiat currency or not nobody knows but one thing is clear, the future of money will be decentralized and independent of any one entity.

Resources

  • Bitcoin whitepaper
  • The basics of Bitcoins and Blockchains — Antony Lewis

--

--