The blockchain is a distributed network of nodes (computers) that facilitates the transfer of Bitcoins from peer to peer. The Bitcoin blockchain has no central authority that governs transfers or settles disputes between parties. This makes it radically different from today’s financial system and gives it some interesting characteristics. The key example is that the Blockchain is completely trustless. Every transaction is backed by math and verifiable by anyone and everyone.
There are two main cryptographic tricks that the blockchain uses to become trustless: hash functions and digital signatures. To understand how the blockchain works, it is a good idea to know a little about these =)
Hash Functions Oversimplified
Hash functions verify the completeness of a message, or transaction. They do this by creating a fingerprint of the message that is sent with the message. The receiver can compare the message and the hash and decide if the message is valid.
How does this work?
A message’s hash is a seemingly random output in hexadecimal form (a number made of letters and numbers). The process of hashing is ‘one way’, meaning that it is easy to take data and hash it, but impossible to take a hash and find the original data. If any part of the message changed, the hash will be different. Even simple changes to a message produce wildly different results.
In short, if someone fiddled with your message, transaction, or data, it will show up in the hash.
A Quick Rundown on Digital Signatures
Again glossing over the details, signatures prevent all sorts of fraud on the Blockchain. Signatures provide a way for you to prove that the Bitcoin you are sending (or hodling) is yours.
Signing a transaction (claiming it came from you) uses a public-private key pair (sets of numbers) that are inexplicably tied together through high level curvy math on finite fields (Link to future article here). The private key is kept secret and proves your ownership while the public key can be known by all and confirms your signature. Knowing the public key does not reveal the private key.
Think of the public-private key pair as a lock on a bucket of Bitcoin. The lock has an ID inscribed into it, which is the public key. The lock can only be opened by a single key, the private key. Everyone can see the Bitcoin (we have a clear bucket for the digital currency), everyone can count it, and everyone knows the ID of the lock.
Now, someone comes along, unlocks the bucket with the private key, and transfers some Bitcoin. No one needs to know who that person is or what the key looked like. They just know that only a single key unlocks those Bitcoin, and so that person must be the owner.
In other words, the private key is what allows access to the Bitcoin and is a secret, yet the blockchain is trustless and needs verification of ownership. The public key, the lock everyone can see, proves ownership without revealing the private key.
Along the same-ish lines, ‘owning’ a purely digital currency is a bit strange.
Bitcoin Ownership as Explained by a Blogger
The Bitcoins someone ‘owns’ are just the Bitcoins the person is allowed to spend. When you pay for something in Bitcoin, you are really just changing the permission on the Bitcoin so that only the person you are paying can spend them.
We define an electronic coin as a chain of digital signatures. Each owner transfers the coin to the next by digitally signing a hash of the previous transaction and the public key of the next owner and adding these to the end of the coin. A payee can verify the signatures to verify the chain of ownership.
Each Bitcoin has a complete transaction history attached to it (cool!). When you send some Bitcoin, you are just adding the next layer of history to the coin.
Back to The Blockchain
The Blockchain uses signatures to verify who sent what and hashes to prove that the transactions are unaltered. However, signatures and hashes do not prevent someone from simply copying and pasting their digital currency, or sending many transactions all at once using the same Bitcoin. There is no trusted central authority to claim which transactions are real and which are not. So, how can the system even work?
This is where the Blockchain gets its name. The Blockchain collects all transactions during a set time into ‘blocks’. Proof of work (basically the ‘nonce’ of a block) is done in order to meet some criteria set by the Blockchain. The proof of work ultimately makes transaction history immutable (unchangeable), and adding proof of work to a block is called mining (link to future article).
After the proof of work is completed, all transactions in the block need to be confirmed by several nodes in the network. Each Bitcoin transaction in the block contains the entire transaction history of that Bitcoin (these are hashed and so tamper proof). The nodes check that the history of each transaction is valid (no double spending or copy-pasting) and then confirms the block.
All the transactions in the block are hashed together into a single hash called a Merkel Root. This is then used in creating the next block of transactions. Using the Merkel Root of the previous block chains the two blocks together (Block-chain). If any transaction in a past block changes, it will change that transaction’s hash. This will then change the Merkel Root, which will then change all the hashes of all the blocks after that point.
Summing up the Blockchain
The blockchain is trustless because the blockchain keeps track of all Bitcoin transactions. The transactions are all hashed together in such a way that changing any history will be detected and rejected. Transactions are made using public-private key pairs that prove that a user owns the Bitcoin they are sending without giving away secret information.
The proof of work incorporated into building the blockchain creates an insurmountable obstacle for attackers to overcome. Any transactions made on the blockchain are completely irreversible and final. No trust required and all powered by math (and probably a lot of coffee).