Last updated on May 24th, 2018
Bitcoin is two things:
1) it is a public ledger of messages (blockchain)
2) it is a currency (a unit of exchange)
How does the public ledger work?
Let us create a simple code where each letter of the alphabet has a number value.
A=64, B=65, C=66, D=67, E=68 up to Z=90
We will also need codes for the digits too:
‘0’ = 48, ‘1’ = 49, ‘2’ = 50, ‘3’=51, up to ‘9’ = 57
And let us say I want to send you the message ‘ABCDE’
I add together the number values of the letters of the message, thus 64+65+66+67+68 = 330.
So I send you the following ‘ABCDE’ 330
Now you can add up the “values” of the letters too which you will find is 64+65+66+67+68 = 330
This give you some confidence that ABCDE is the original message.
If instead you received the message ‘ABBDE’ 330, ABBDE is 64+65+65+67+68 = 329, which does not equal 330. Because the numbers do not match you know that ABBDE is not the original message.
Now you might note that 330 can represent messages other than ‘ABCDE’, for example the message ‘ABBEE’ also adds up to 330. 64+65+65+68+68 = 330.
So 330 does not tell you what the message is, but it can “help” tell you if the message has been changed.
The number 330 above is called a checksum. The sum of the values of the characters in the message.
Historically it was used to help you determine if a message was corrupted or changed.
Later a different method of calculating the 330 was developed called the Cyclic-Redundancy-Check or CRC.
More recently a method called ‘hashing’ has come about which is even better at making sure the original message was not changed.
A hash can be used over very large messages and can help you be very certain the message has not been changed.
For example, in bitcoin a message (called a block) is made up of approximately 1 million characters.
The type of hash used in bitcoin is called ‘SHA256’. All SHA256 means is that the hash value (330 from our example) is a number in the range of 0 to 115792089237316195423570985008687907853269984665640564039457584007913129639935 and describes how the value is calculated.
(yes SHA256 numbers can be quite large)
In the simple checksum example above we added the values of each character in the message together to make a sum. The SHA256 algorithm works similarly. Exactly how it works is not important for this discussion.
What is important is that given a large message and its SHA256 value (hash) you can be highly certain that the large message has not been changed.
In other words, whatever letters were put into the large message originally are the same letters you got out when you looked at it. You can be confident the message is unchanged.
Even the smallest change to the message will cause the hash value to no longer match.
It is theoretically possible to make specially crafted changes to the original message that would still produce the correct hash value, however because of the design of the SHA256 algorithm it is nearly impossible to do so.
It is so nearly impossible to do that for all practical purposes it is impossible.
So the SHA256 hash gives us a method of adding up the characters of a large message and giving us a number which can be used to verify that the characters in the large message have not been changed.
In bitcoin the “message” is called a “block”.
You may have heard the term “blockchain”.
Bitcoin uses an extra step to create a chain of blocks.
When a bitcoin block (message) is created the hash value is calculated from the characters that make up the new block **and** the value of hash of the previous block.
If someone hands you a bitcoin block (message) and its hash you have 3 pieces of information:
You have the original message, you have the hash of the previous block (because it was added to the original message), and you have the hash of the block you where handed.
Here is an example extending the simple checksum example:
The first message is
The second message is
(65+66+67+64+64+51+51+48 = 476)
Note that we are not adding the number 330, but we are adding the 3 characters ‘3’, ‘3’, ‘0’ using our code from above where 3’s are coded by adding 51 and 0’s are coded by adding 48.
The 476 tells you the BCDAA330 message is unchanged. The 330 is the “hash” of the previous block.
This is how bitcoin blocks become a blockchain.
Now our checksum method can be easily fooled, but not the SHA256 hash value. It is basically impossible to fake the blocks of the bitcoin chain.
So bitcoin is a chain of messages (blocks) which contain data that can be shown to be unchanged from when they were created.
This is the irreversible public ledger part of bitcoin.
It is simply a list of messages (blocks) whose data cannot be changed without causing the hashes to fail to match.
If the hashes do not match you are looking at fake or corrupt data.
What are bitcoin transactions?
Or what is inside a bitcoin block?
bitcoin messages (blocks) are made up of transactions.
A bitcoin transaction is a message that transfers a number from one address to another.
An address in bitcoin is a long random number, though when humans look at them they look like long random strings. Unlike a number, which has only digits, the random string contains digits and alphabet characters.
Let us assume that we each have a bitcoin address. Mine might look like ‘1ExAmpLe0FaBiTco1NADr3sSV5tsGaMF6hd’ and yours could be ‘1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2’.
A bitcoin is just a number. A bitcoin is not a thing. Just a number.
Let us assume I wanted to send you 1 bitcoin.
I would create a message (also called a transaction) like the following
When a bitcoin miner is building a block (large message) he makes it by collecting up transaction messages (like mine to you) and stuffs as many as will fit into the block that he is making.
A bitcoin block can hold a million characters so many many transactions can fit in each block.
After the bitcoin miner fills up the block he is creating with transactions he performs a few extra steps.
One, he makes sure that my address 1ExAmpLe0FaBiTco1NADr3sSV5tsGaMF6hd actually has a bitcoin in it. He does this by working backwards through the blockchain to find an earlier transaction related to my address which shows that it has at least 1 bitcoin in it. If he fails to find such a reference, he will not accept the transaction.
After he has created a block of transactions he adds in the hash from the previous block and calculates a hash of his new block.
There are a few other things a miner must do, one of which is be the first to create a new block of data with a proper hash value and with all transactions properly verified.
When such a block is submitted into the system of bitcoin miners, the other miners will verify that the transactions contained in the proposed block are correct, that the new hash is correct, and that the block contains the correct hash from the previous block.
If the proposed block meets all the rules and is accepted by the **majority** of miners it will became a permanent part of the block chain and the miners will begin working on the next block.
Being accepted by the majority of miners is a very important concept.
Let us assume there are 100 miners. For a miner to get his block accepted he would have to convince 50 other miners to accept his proposed block. That would be 50 plus himself, making for 51 miners or a majority.
Because of this majority rule, bitcoin suffers from the “51% problem” as it is called. If a person or entity could get control of 50% of the miners plus 1 that person or entity would be solely in control of the blockchain and could write whatever they wanted to into the blockchain.
Bitcoin operates by **hoping** this never happens.
Where do bitcoins come from?
Bitcoins are a bitcoin address with a number associated with it. The associated number is the number of bitcoins at that address.
Bitcoins are given to miners who create valid blocks that are accepted into the blockchain. At the time I wrote this article a bitcoin miner would get 12.5 bitcoins for creating a valid block that is accepted into the chain. In effect when a miner successfully submits a block to the blockchain the number 12.5 is added to the number associated with the miner’s bitcoin address.
That is how bitcoins come into existence.
The Genesis Block
Since every block in the blockchain contains the hash of the previous block what about the first block in the chain?
There has to be a first block, right?
The first block is called the genesis block and it does not contain a hash of a previous block as there is no previous block.
What makes bitcoins worth $10,000?
Or whatever the value of bitcoin is when you read this article?
The value of a bitcoin is, like many things, entirely defined by what someone else is willing to trade you for it.
At the time I wrote this article there were a lot of people willing to trade you $10,000 (US dollars) for a bitcoin.
They would send you $10,000 and you would create a transaction message to transfer 1 bitcoin from your bitcoin address to their bitcoin address.
Bitcoin has no value other than what others are willing to trade for it.
What is a transaction fee?
Remember when I mentioned above that a miner creates his large block (message) by stuffing it full of transaction messages?
What if there are more transaction messages than will fit into the block? In that case the miner looks at all the pending transactions out there and picks the ones that are offering to pay him a fee for being put into the block the miner is creating. Generally miners fill up their blocks with the highest fee paying transactions first.
In effect our example transaction above might look like
By offering the extra fee to the miners you can move to the head of the line and get into a block sooner rather than later (or possibly not at all).
Indeed, if you offer a zero fee to the miners your transaction may never be accepted by any miner and may never get into a block.
What is a Satoshi?
You can spend fractional bitcoins. Similar to how a dollar can be divided into cents, a bitcoin can be divided into Satoshis. A single Satoshi is 0.00000001 bitcoin. While there are one hundred cents in a dollar, there are one hundred million Satoshis in a bitcoin. A Satoshi is a very small unit.
Why does mining bitcoin use so much power?
All the miners are competing against each other to calculate the hash for the next block. Being the first is how you win. Bitcoin miners use the most powerful computers they can get to do their hash calculations. Some run hundreds or thousands of special computers in parallel all working towards this single goal.
Why are new blocks created only once every 10 minutes?
This was a design goal of the original bitcoin design. Blocks are to be created on average one every 10 minutes.
This is accomplished by making the hash calculation more difficult. If blocks are being produced too quickly, the difficulty of calculating the next hash is increased to slow block production back down to one block every 10 minutes.
Why does it take an hour to confirm a bitcoin transaction?
It may well take longer than an hour. It takes some time (sometimes days) to get your transaction into a block on the blockchain. After that it takes another hour for the transaction to be confirmed.
The reason for this delay has to do with how all the miners come to an agreement as to who was the winner at creating the next block.
The miners do not necessarily all agree at first. They generally all agree eventually. Sometimes early agreements or partial agreements can be reversed. Agreements become increasingly difficult to change as more blocks are accepted onto the chain (that is agreed to).
The industry has generally determined that 6 subsequent blocks accepted onto the blockchain means your transaction has been confirmed, by which they really mean the agreement regarding the block holding your transaction is unlikely to be undone.
In more concise terms it works like this: You submit your transaction message. A miner includes your transaction message in a block that is accepted onto the block chain. Six more blocks are created by the same or other miners and are accepted onto the blockchain. At this point your transaction is considered “confirmed”. Each of those subsequent 6 blocks took 10 minutes each to be created and accepted onto the blockchain. So your transaction had to wait 60 minutes to be considered confirmed.
It cannot really be as simple as you describe above
It really is that simple. Even the difficulty of the hash function used by bitcoin is pretty simple to understand.
The difficulty of the bitcoin hash function is regulated in a way that is similar to flipping coins and getting some number of heads in a row.
Flipping a coin and getting 3 heads in a row is not all that difficult. In fact getting 3 heads in a row is not so much difficult as it is time consuming.
Flipping a coin and getting 10 heads in a row is way more time consuming than getting 3 heads in a row.
This is how they adjust the difficulty or time-consumed generating the next valid block.
This is the secret to slowing down the block generation process. It is not really the difficulty of the problem, but the time consumed in finding the solution that is adjusted.
And it is adjusted by making the miners get more heads in a row.
In other words, to “solve” a bitcoin block’s hash one might have to flip coins until one get 6 heads in a row. To make finding the hash more difficult the requirement might be changed to require 10 heads in a row.
Congratulations on getting though this presentation.
You might be wondering how I decided which numbers to associate with which characters way back at the start of this article. That is why I chose ‘A’ to be the value 64 or so on for the other characters when calculating the checksum?
Long ago, when the dinosaurs still roamed the earth, a group of people invented a coding system called ‘ASCII’ (American Standard Code for Information Interchange) which was derived from an even more ancient coding system for telegraphy. You may have heard of another popular telegraphy coding standard called ‘Morse code’.
I simply used the numbers from the ASCII coding standard for my character to number math.