What is Bitcoin?
(Detailed answer below - short answer here)
The notes and coins we use today are: 1. physical; 2. transacted peer-to-peer; 3. memory-less and; 4. difficult to duplicate. Below, some parallels are drawn with Bitcoin.
1. By physical I mean paper notes and metal coins you can hold in your hand. Bitcoin differs here - it is a digital cryptocurrency. In practice what that means is a digital file containing two things: a digital signature (based on cryptography) which binds an identity to the file so you can establish ownership and; an amount, or a number, saying how many Bitcoins you own. The digital currency only has value because we all believe and all agree it has value (just like fiat currency) - it is not backed by anything tangible such as gold.
2. By peer-to-peer I mean anyone can send/receive notes and coins to/from anyone else. Bitcoin is also transacted peer-to-peer: it is decentralised and transactions are not made from one centralised institution to another, such as from my bank to your bank, but instead from me to you directly.
3. By memory-less I mean notes and coins do not contain ownership and transaction histories - we don’t know who owned that 20 dollar bill before you did - it’s not written on the note! Unlike the paper notes we use, Bitcoin does record the history of who owned and transacted what amount of Bitcoin in a public ledger (think accounting book/register/log/spreadsheet) that anyone can see.
4. We’ve established that Bitcoin is a digital currency and not a physical currency. Digital files are easy to copy (think music files) and so could be spent twice. So something called “proof-of-work” is used by the Bitcoin system to prevent double-spending and thus provide trust in the currency. The “proof-of-work” process verifies ownership and transaction amounts and writes them into the public ledger. This work is done by Bitcoin verifiers, also known as Bitcoin miners. The reason you cannot double-spend, or cheat the system, boils down to computing power: a cheater or hacker would never be able to outpace the Bitcoin system. With its millions of miners and computers, the Bitcoin system has so much more computing power than a would-be cheater or hacker could ever dream of having.
How does Bitcoin work?
We mentioned a little on “How Bitcoin Works” above, but now we’ll delve into the detail. The Bitcoin system runs on a technology known as the blockchain.
What is the blockchain?
The blockchain comprises of the following technologies: 1. public-key cryptography; 2. a peer-to-peer network; 3. a public ledger; and 4. a process called “proof-of-work” that verifies and confirms transactions. Below I explain.
1. Public-key cryptography
So first off then, you need to understand how public-key cryptography works, or how digital signatures work. If you already understand it then skip this section, otherwise please read on.
What is public-key cryptography? What is a digital signature and how does it work?
The digital signature system uses public-key cryptographic technology. In public-key cryptography the signer generates two cryptographic keys (basically long random numbers) that are unique but related to each other: a key-pair. The keys are known as the private key, which is used for signing, and the public key, which is used for verifying a digital signature. The signer holds on to the private key, and keeps it confidential. The public key is made available to anyone - it is practically impossible to use the public key to generate its private key. Because the key-pair are mathematically related (they will only work with each other), it allows them to perform two functions: 1. anyone can encrypt a message with the public key to ensure that only the holder of the private key can decrypt it; 2. digital signature: a message is digitally signed by the holder of the private key, using the private key, so that the recipient can use the corresponding public key to verify that the message was signed by the private key holder. Only the corresponding public key will be able to decrypt the private key’s digital signature and thus verify it.
I’ll explain how the digital signature process works by way of an example:
1. Alan wants to send 8 Bitcoins to Bob and so writes this in a Bitcoin transaction-message (a digital file) to Bob: “8 Bitcoins to Bob”.
2. By using a publicly known mathematical hashing function Alan transforms this message into a long number known as a ‘hash’ or hash number (or even a digest) - let’s call it Hash 1. If the message contained just one different character it would generate a wildly different hash number. This hash number is thus unique to the message. This is a one-way process so that the message cannot be reverse-engineered from the hash number.
3. Next, Alan generates two keys, known as a key-pair: a private signing key and a public verification key. Alan keeps the signing key private and makes the verification key public.
4. The hash number from above, Hash 1, is then encrypted with Alan’s private key by using a signing algorithm. This creates what is his digital signature. Note: the message itself could have been encrypted in this way too but it would be a less efficient way to do it because it would consume more computational power and time than just encrypting a smaller hash number (which is a unique representation of the larger message data).
5. Alan’s digital signature is attached to the transaction-message.
6. Both the transaction-message (which can be read by anyone that has the publically known hashing function) along with the attached digital signature (which can be verified by anyone with the corresponding public key) are sent to Bob.
7. Bob receives the transaction-message with the attached digital signature. But how does Bob know that the message was really signed by Alan? And that it has not been intercepted and altered?
8. Bob needs to perform a check using two pieces of information he has: the publicly known mathematical hashing function; and the public key.
9. Bob applies the hashing function to the message (in the same way Alan did) to generate a hash number - let’s call it Hash 2.
10. Bob then decrypts the digital signature with the public key he holds (corresponding to Alan’s private key) to reveal a hash number - let’s call it Hash 3.
11. These two hash numbers are compared. If both hash numbers are equal (Hash 2 = Hash 3, and therefore also equal to Hash 1) then Bob knows that the transaction message was indeed the one sent by Alan (not altered) and that it had to be Alan’s private key that signed it (authentication) and so Alan cannot deny sending the message (non-repudiation). The digital signature is accepted. If they are not equal then Bob would reject the digital signature and the message.
12. But why is this so?
a. Because the public key Bob holds can only decrypt the digital signature created by its corresponding private key: it had to be Alan’s private key that signed the message - if anyone else had intercepted the message and re-signed it with their own (and different) private key then Alan’s public key would not work.
b. Also, if someone had intercepted and altered the transaction message by even just one character to say “7 Bitcoins to Bob”, then the hash number produced (call it Hash 4) using the publicly known hashing function would be wildly different to Alan’s original Hash 1 - both hashes would not be the same (Hash 4 does not equal Hash 1) and the digital signature would be rejected.
Unlike traditional handwritten signatures which are always the same no matter what message or document you sign, digital signatures are dependent on the message: if the message changes then the digital signature is different even though the same private key is used to sign. In this way digital signatures are different to handwritten signatures and bind your identity to the underlying message. So we now know how digital signatures work!
We can move on to the next section which explains in more detail how a transaction in the Bitcoin system (or Blockchain) works. We will bring into the picture the roles played by the public ledger and the peer-to-peer network.