amany9000amany9000

You must have heard about Bitcoin, Ethereum and other cryptocurrencies and the technology behind all of them: blockchain. If you have little or no idea about blockchain technology and want to start your deep dive into the world of decentralisation, this is the introductory article for you!

A blockchain is basically a clever combination of a number of concepts taken mainly from the fields of cryptography and computer networking. We’ll cover the cryptography concepts in this article.

Cryptography is the study of the design of techniques which ensure the secrecy and authenticity of all information. In simpler terms, cryptography deals with keeping information safe, private and unchanged over systems and network communications.

The three topics we’ll focus on are -**1. Hash Functions**

A cryptographic hash function is a one-way mathematical function which maps an input of any given size to a unique fixed-length output. This fixed-length output, called the message digest, is totally random and can’t be mapped back to the original input, i.e. irreversible.

The point for you to remember here is that the output, i.e. the digest, is totally random and changing just one bit in the input message changes its digest completely. So figuring out an input message whose digest satisfies a given “condition” is very hard and requires a brute force search. One example of such “condition” as used in Bitcoin is a digest whose numerical value is less than a prespecified small number, called target.

Bitcoin uses the SHA-256 cryptographic hash function. Hashing is also a step in creating digital signatures. Check out this article on hash functions for a deeper dive. Other use cases of hash functions are checking message integrity, authentication, and HashMaps.

**2. Asymmetric Encryption**

In the process of asymmetric encryption, an arbitrary message called plaintext is converted into an encoded message called ciphertext through a pair of keys. One of the keys is made known to everyone, this one is called the public key and the other one is kept secret, hence it is called private key.

The point for you to remember here is that as there is a mathematical relationship between both keys, any message encrypted with the private key can be decrypted using the public key. The opposite of this also true - any message encrypted with the public key can be decrypted using the private key.

One of the most common and most used asymmetric encryption algorithms is RSA.

**3. Digital Signatures**

Digital signatures are a technique used to provide message authentication and integrity over networks. Simply, digital signatures provide assurance that the message was in fact sent by the sender and not even a single bit of the message has been changed.

Let’s look at an example to understand how it works - Bran wants to send Arya a message M. To provide Arya with a proof that Bran himself has sent the letter and no one else, he hashes M using a hashing function H and then encrypts the message digest (output of the hash function) using his private key. This encrypted hash is known as the digital signature - DS of the message M and is sent to Arya along with M. As Bran’s public key and hashing function H is known to Arya, she would hash the received message using H and compare it to the result of decryption of DS using Bran’s public key. If the two values match then Arya can be sure that Bran sent the message.

The main point here is that digital signatures are used to institute digital identity in blockchains. So all messages (blocks, transactions, etc.) signed through a specific private key -> Priv_Key are considered to be from an individual address on the blockchain. In the case of Bitcoin, an “address” is the Base58 encoded hash of the public key corresponding to Priv_Key.

Bitcoin uses ECDSA algorithm for digital signatures. Another very important use case of digital signatures is digital certificates which are quite important in maintaining the security and privacy of the modern web.

© 2022 TopcoderPolicies