How does Hashcash tie into cryptocurrency?
Cryptocurrencies using the concept of Hashcash to generate coins and maintain blockchain. Some of the important concepts which are re-used from Hashcash:
- The software used for Hashcash was referred to as mint. One correct hash meant 1 token or coin (cash) to send one email.
- The process for finding correct nonce is called mining.
- Correct hash is used to prove that the sender’s computer has done some work on finding the right combination, hence the name Proof of Work
While this method worked flawlessly for emails there was an issue when using it in a currency setting. If your bank said that each coin can be spent only once, how would that turn out? You buy a dollar worth of groceries, your grocer takes the dollar to bank to exchange, then the grocer buys a dollar worth of gas, again the dollar has to be exchanged…so and so forth. See the problem? Things get needlessly complicated.
To resolve this, in comes RPOW – Reusable Proof of Work by Hal Finney. Now the coin could be used repeatedly. To achieve this every coin was attached to each other. For example, an email flow in RPOW would be like this:
The output hash from the original message will be chained into the next email. The nonce 119598 was calculated on the extended message.
In a traditional money system, the bank has a general ledger detailing each transaction – debit and credits etc. They have a separate identity store which holds balance. Here’s what a traditional transaction actually looks like:
In cryptocurrency having each part being done separately is not feasible. So blockchain contains both information:
- Everyone’s public key (used to verify identity – check part 1)
- Transaction information
So, a blockchain transaction between Red and Green looks like this:
Every peer is having a copy of the blockchain and uses it to verify the ownership of coins as well as balances. Once confirmed they add entries to the blockchain to reflect new balance for Red’s key. Hence, blockchain is also sometimes referred to as distributed ledger.
To ensure trust transaction and identity information is hashed into a block. That way unless someone knows all the information it is impossible to find the hash.
Furthermore, all blocks are chained to each other like in our RPOW example. So, the block”chain” looks like this:
To reiterate a block contains two information:
- All transactions which have happened
- The nonce which used along with the transaction info to create a valid hash.
Since each block is chained to the previous and next block, it makes hacking or changing even more difficult. As the data cannot be changed it is also referred to as immutable.
How does Trust work?
Say at the 11th block Blue wants to get back her 2 coins included in block1. As everything is connected to each other, all hashes will need to be re-done since block1. This is almost impossible. Not to mention the peers would catch on and kick Blue out from the network.
Hence, blockchain has to work in conjunction with p2p network to achieve the distributed consensus.
Now remains the question of money flow – how are coins created, transactions etc in a cryptocurrency. We will discuss that in part 4.
Also published on Medium.