Photo by Scott Rodgerson on Unsplash

Cryptocurrency and Blockchain — Role of Cryptography

Rajan Kashyap
CryptoDigest
Published in
4 min readDec 6, 2017

--

In my last post, I tried to establish the basics of the Cryptocurrency and Blockchain. Many of you would be asking the question why is it called Cryptocurrency and how is Cryptography used in this whole scenario. This post will try to explain this.

Before I delve into the details, let’s have a quick look at what cryptography is? As per Wikipedia definition, Cryptography is the practice and study of techniques for secure communication in the presence of third parties called adversaries, i.e., it is a technique to send a message from one party to another in the presence of third parties, but only understandable to the side it is intended.

For example, if I am presenting something to a customer and one of my colleagues says, “Excellent Point, Rajan.”, It means “Shut Up!!”. This communication is possible because we have agreed the keywords and its meaning in advance. However, in the real word cryptography, it is far more complicated than just a sequence of phrases.

Coming back to point why these electronic currencies are called Cryptocurrencies because Cryptography is the fundamental part of how these work.

Let’s understand the two cryptographic concepts before we dig deeper, Cryptographic hash functions and Digital Signatures.

A cryptographic hash function takes an arbitrary input string and return a fixed length string and have following properties:

1. The function is computationally efficient, i.e., the hash is generated within a reasonable time.

2. It is extremely difficult to reverse engineer the input by looking at the output.

3. It is extremely unlikely to find two strings that have same had output.

In simple terms, the hash function is a black box that take any length string input and produces a fixed length string output.

Digital Signature is pretty much like a paper signature albeit in a computer/soft format. It is however implemented as set of pairs of keys (public and private). Anyone can generate a new key-pair using a computer and publish the public key to everyone. The owner of public key will create a new transaction / document and sign it with his/her private key. Once signed it can only be unlocked by the public key. So if you can open a message with a particular public key, one can be sure that the message has come from owner of the public key. This way the public key can act as an identity of someone in the cryptocurrency network.

The actual details involve a lot more complex maths but to keep the post simple, let’s just take these two concepts and try to understand the cryptocurrencies.

Recall the cryptocurrency description in my earlier post. Each node/participant in the network will have an identity as their public keys. One thing to note here is that a person can create multiple public/private keys and can assume multiple identities in the network, but let’s ignore that for now. Everytime someone needs to publish a transactions to transfer cryptocurrency; they will need to sign the transaction so that validating/miner node can check that you have right to initiate the transaction.

There will be many transactions published by many nodes simultaneously. These transactions (bundled together) will be picked by the miner nodes to validate the transactions and compute the cryptographic hash of the transaction block + hash of previous block.

But here is the catch… the output hash has to be of a such that it starts with 6 zeroes. (Note: 6 Zeros is just an example, the actual number is decided by the network depending upon how difficult the network need to this computation to be and is adjusted periodically)

- To generate that specific hash, the miner node will add a number ( called nonace ) to the overall block and compute the hash

- If the output hash starts with 6 zeros then the node publishes the block, claims the mining incentive e.g. 12.5 BTC in case of bitcoin.

- If the output is not the desired hash then change the nonance and try again.

- Miner keeps on repeating till either some other node else publishes a new block or the node finds the required hash.

Now if you look at the steps above, the miner will have to compute the hash multiple times, each time with a different nonance, to get the required hash. Since there are many nodes trying it at the same time, it is extremely unlikely that the same node will get to publish two consecutive blocks. This way the randomness is created in the network the chances of someone controlling the network go down exponentially.

There, however, is still a possibility if more then 50% nodes are controlled by a single owner and can play maliciously. But, if you re-think, the person controlling the network will be at loss if he/she plays maliciously, because by doing so the other nodes will lose faith in the network and stop participating and as a result the value of currency will go down.

Please remember, the miner nodes are paid in cryptocurrency and not fiat currency, so it is in their interest to keep the network honest.

That’s it for this post. I will come back with next post on how a blockchain looks like as how the consensus between network nodes is achieved on which transaction to be included in the block and which block to be appended to the chain.

PS: There are many technical details in each step, but I keep my posts purposely simple to be understandable by everyone. Please comment if you would like me to start another blogpost so go into the technical details.

--

--

Rajan Kashyap
CryptoDigest

Expert in Blockchain, Cloud, Artificial Intelligence and Robotic Process Automation.