Overview of blockchain and bitcoin (Part 1)
Articles in this series use contents from many resources in the internet, whose roots are hard to trace. Majority of ideas are from secondary research. We also do not provide any financial information, such as which cryptocurrency to invest, when to buy or sell, or price prediction. We are only taking a look on technology and application viewpoint.
First, let’s start with what blockchain and bitcoin are.
What is it
Blockchain is a technology. It is proposed by an anonymous person/group named Satoshi Nakamoto.
Bitcoin is an application of blockchain, among many others.
Bitcoin’s purpose is to improve current payment system. It is decentralized, persistence, anonymous, auditable…
When using bitcoin, you do not need an intermediate organization to validate your account and transfer money. Everything is done inside itself. Bitcoin system is incorporated and self-operated by its participants. Everything is ready to work after you join.
To achieve these goals, bitcoin has employed some techniques.
At the bottom of a blockchain architecture is blockchain. It acts like a data structure and works as a database. This database is stored in every full nodes in bitcoin system. On top of the blockchain is bitcoin protocol, which is bitcoin core project. With that protocol, coin (bitcoin, specifically) is created and transferred.
Difference between token and coin:
Tokens are used to bind physical to digital world. Token can bind money (in case of coin), a company’s share, a physical product, a song, an idea… anything.
Coin (any kind of it: bitcoin, ether, litecoin…) is a special token, which is used like money.
On the top of bitcoin are applications like wallets, exchange platform, merchants accepting bitcoin… We usually interact with applications at this level while not interacting with lower stuffs.
There are many other types of coin systems (altcoins), which also have similar architecture like bitcoin.
Ethereum has another story, with different philosophy, design and algorithm. Ethereum is platform, Ether is cryptocurrency developed based on that platform. It has many useful application which I will research about.
That is overall architecture. Let’s go to detailed design of bitcoin.
Any digital currency must solve double spending problem.
Double spending is when a digital currency is replicated and spent more than once.
This problem becomes harder on a decentralized environment, without any central authority. To avoid it, every smallest piece of coins are traced from their creation, through every transaction, to recent status. Any coin is authenticated before spending.
After joining this flow, a coin have to be an output of a transaction before becoming input of another one. Total number of output is always less than or equal to number of input. Coin can just be transferred from transaction to transaction, cannot be validly replicated. Origin of every coins are traceable. Mining is the only way to create coins from nothing.
In case there are many transactions using the same output, the first transaction with earliest timestamp will take effect, others will be discarded.
Many output is when someone transfer money to more than one address.
Many input is when amount required for a transaction is not enough and need to be gathered from many transactions, of the same source address.
Unspent transaction output (UTXO) is output amount which is not spent in any transaction. In other words, that amount is not used as input of any transaction.
Transaction fee is the difference between total input and total output. Which is paid to miners for validating a transaction.
Every transaction includes sender address, receiver address, bitcoin amount (input-output), signature of sender, and other ton of things. They are chained together by input-output mechanism. Output of previous transaction is input of next one. If someone modifies amount of a transaction, he/she must modify all transactions subsequent to that one, every one of them. And must somehow make whole network accept that modification. This is theoretical impossible.
Every address (address is a public key) has a private key to prove ownership of that address. Sender provides transaction with that private key to authorize a transaction. This private key is used to sign information attached with transaction. If owner lost that private key, or it is stolen, everything stored in that address will be lost forever, non-refundable.
Not only addresses (public keys), and transfer amount, private key is used to sign many information related to transaction: previous transaction id, output index number, amount… If someone modify a transaction, he/she not only need to modify all subsequent transactions, but also need private key of everybody receiving that coin. Getting private key of that large amount of people, who is anonymous, is extremely hard, needs huge effort, and somehow impossible.
Coinbase transaction is the first transaction in all blocks (transaction 0). It is the only place where bitcoins are created from nothing, as reward for validating transactions, putting them into blocks, and solving hard hashing problems. Coinbase transaction also includes fees of all transactions that are included in this block.
Rewarded bitcoins starting from 50 bitcoins each block in 2009, halved every 4 years. This will limit total number of bitcoins to 21 millions.