Beginner’s Guide: Use of cryptography in cryptocurrency

0

What is cryptography in cryptocurrency?

If you are a crypto trader or a blockchain-cryptocurrency developer then you have already heard two claims. The first is that the private key-public key encryption keeps the transactions safe. The second is that cryptography keeps blockchain network safe. In this article, I will explain the use of cryptography in cryptocurrency.

After reading this article, the crypto traders will know how securing their private key is enough to keep their crypto transactions safe. The blockchain-cryptocurrency developers will know after reading this that as long as they use a standard cryptographic algorithm their blockchain network is safe. Modern cryptography relies heavily on advanced mathematics, and an explanation of those mathematical concepts is beyond the scope of this article.

Hacking cryptocurrency: What are the risks?

There are two events that can cause a loss to the crypto traders and a blockchain cryptocurrency network. These are as follows:

Blockchain Certification Course
  1. Hackers crack the digital signature of the crypto trader and initiate malicious transactions from the account of the trader.
  2. Hackers compromise the blockchain network underlying a cryptocurrency and manipulate transactions there.

In this article, I will show how encryption, which is an outcome of the modern cryptography, protects the digital signature of the crypto trader. I will also show how cryptographic hash functions protect the blockchain network.

What is a cryptographic hash function?

A ‘hash function’ converts a variable-length data set into an alphanumeric string of fixed size. In the science of cryptography, some specific hash functions are used, and these are called ‘cryptographic hash functions’. The cryptographic hash functions have certain specific characteristics, and those are as follows:

  1. These functions are ‘deterministic’, i.e. a specific input always produces the same output.
  2. Even if the input is changed marginally, the output hash will be drastically different.
  3. The computation of the hash value is fast.
  4. Computing the input from the hash is practically impossible because of extreme difficulty.

Cryptographic hash functions are used in the context of blockchain to produce the digital signature of the users using the encryption of the public-private key. These functions are also used to uniquely identify each block in the blockchain in a scrambled manner so that the content of the block can’t be reproduced using the hash.

How does the public-private key encryption protect the transactions of the crypto traders:

The crypto traders have public keys that they share with the others so that they can receive cryptocurrencies. This public key is also known as the users’ address. On the contrary, the users must not share their private key. They must secure it, because if a hacker gets the private key, then our crypto trader can lose all their funds.

The public key is just a cryptographic hash of the private key. It’s very easy to generate the public key from the private one, however, it’s practically impossible to do the opposite.

 

Private key encryption

Image Credit: Wikipedia

To send their transactions to the miners the crypto traders do the following:

  1. Create a cryptographic hash of the transaction message through a cryptographic hash function;
  2. Run the hash and the private key through a signature algorithm;
  3. Send the public key, the message, and the digital signature generated through the signature algorithm.

When the miners receive the transactions, they do the following:

  1. Run the incoming message through a cryptographic hash function;
  2. Run the incoming signature and the public key through a signature verification algorithm, which produces a hash,

The miners then compare the two hashes, and they match then the transaction is valid.

Blockchain Certification Course

If hackers were to tamper the transaction from the crypto trader, they will need to first change the message according to their unethical need, and then find a digital signature that will match the hash. Remember that cryptographic hash functions are ‘one-way’. The hackers have to go through a long process of trial and errors to find one such signature. How long? Well, to hack a digital signature in the Bitcoin network, using the entire computing power of the network, the hacker will need 5 ‘quindecillion’ (1 quindecillion = 10^48) years! The crypto traders can rest assured, the public-private key encryption is indeed safe.

How does the hash of a block protect the blockchain network:

I will use the example of Bitcoin to explain this part. A Bitcoin block has the following information:

  1. The hash of the previous block;
  2. The transactions details;
  3. The address of the miner that solved the block;
  4. A random number, essential for creating a hash of this block.

The next block will have the hash of this block, and so on.

Now, suppose a group of hackers has planned to introduce a new block between the 7th and 8th blocks, to record some transactions that will benefit them unethically. If they create this new block, it will be rejected immediately by the network due to the following reasons:

  1. The miners only accept blocks with small hash values, i.e. lots of zeroes upfront.
  2. The ‘new’ 8th block doesn’t have the hash value of the 7th block.

Now the hackers will need to solve these two problems. Finding a small hash value is tremendously hard, and requires many trial-and-errors. Even harder is the second problem!

what is cryptography?

The hackers will have to use their computing powers to solve the 8th block so that it starts with the hash of the 7th block. That’s very hard and requires a lot of computing power. Moreover, as soon as the hackers solve this issue and create the ‘new’ 8th block, they will need to change what is now the 9th block, to introduce the hash of the ‘new’ 8th block at its’ start. They need to do this for every subsequent block too!

Now, consider the fact that the Bitcoin network has thousands of miners, all simultaneously trying to mine new blocks. By the time the hackers manipulate the blocks earlier in the chain, many more new blocks have been added to the chain one after the other. For the hackers, it’s an interminable chain of trying to modify existing blocks. It’s practically impossible unless the hackers manage to gather more computing power than the entire Bitcoin network. Besides, such unusual activity targeting blocks earlier in the chain is bound to alert the other miners and the hackers will be found out in no time.

If you are a crypto trader, make sure you keep your private key safe. If you are a developer, use a standard cryptographic algorithm in your blockchain. Modern cryptography will do the rest.


About Author

Anujit has been a developer, project manager and consultant in the IT industry for over 2 decades. He keenly watches how new technologies put the power in the hands of the people and democratizes the society. Outside of his working hours, Anujit plays, sings, draws, writes, and reads.

Leave A Reply