Cryptocurrency and blockchain in a nutshell

karthik · updated · flag

Expanding on the concept of digital currency from the previous lesson, let’s follow a real-world transaction of a digital currency like bitcoin and understand what a cryptocurrency is.

The wallet

Let’s say you want to send 1 bitcoin to your friend Diego. He gives you an address to send it to. As a bitcoin user, you will have your own crypto wallet. Think of it as a digital wallet that not only holds bitcoins but also does all the work of generating addresses, announcing your transactions to all bitcoin users, signing your transactions to send it to the public ledger, receive confirmation, etc.

Cryptographic signature

Once you select 1 BTC in your wallet and paste Diego’s address and hit send, the wallet would generate a transaction payload with the following info and send it to the bitcoin network.

  • Your (sender) wallet address.
  • No. of bitcoins being sent.
  • Diego’s (recipient) wallet address.
  • A signature, which is a hash generated from the above info and your private key.
Wait! What's a cryptographic hash? What's a private key?Remember how you signed buddycoin transactions with a secret word as the signature? Similarly, in a real transaction of a cryptocurrency, you cryptographically sign it using an asymmetric encryption. The 'crypto' part comes from this.

Bitcoin network

The bitcoin network is a special peer-to-peer network of all bitcoin users around the globe. Each computer on this network, called nodes, listen to new transactions all the time. So when a bunch of nodes pick your transaction request, they receive it and check it against some bitcoin rules like the following.

  • Does the sender has enough bitcoin to make the transaction?
  • Is the signature valid?
  • Are there any duplicate transactions?

Mining

Once everything is checked, a group of users in the network, called the miners, sort your transaction with a few other transactions in the queue in a neat package called block and prepares it to validate and add to that public mega ledger we talked about. This whole process of validating is called mining. And every miner would be competing against each other to push a valid block to the ledger. Whoever does that first, gets a reward in bitcoins.

And this validation process is similar to the hashing process you used to sign your transaction, except that this one is for the miners to sign the block in a predefined way using a hash from the last valid block from the ledger. And it requires more computational resource and time.

Ledger and blockchain

Once a miner calculates a successful hash, they announce the victory and push the block to the public ledger. You might think the public ledger as some sort of a huge table of records. It’s not. It’s chunks (blocks) of records orderly chained with their hashes linked. This way any alterations to any of the previous blocks in the ledger can be invalidated. And this huge chain of blocks is called the blockchain.