# CRYPTOGRAPHY IN BLOCKCHAIN

This Blog is written and publish byTY-38:

Harsh Mandviya

Md Mubasheeruddin Siddiqui

Jayna Medtia

Harshal Nana Patil

Prashant Kumar

# BLOCKCHAIN

## WHAT IS BLOCKCHAIN?

Blockchain is a peer-to-peer network. The word **blockchain** is of two separate terms, block and chain. A **block** being mentioned as a collection of data, alias data records or transactions, and **chain** being here is as referred as a public database of those blocks which are stored in form as list. A blockchain is an append-only database of transactions that’s distributed to all or any participants in a blockchain network. There’s no owner, administrator, or centralized data storage. Blockchain is additionally referred to as distributed ledger, because the database can be thought of as an electronic ledger of transactions (state changes) to the data.

## ARCHITECTURE OF BLOCKCHAIN

Every Block consists of different elements such as** Block Header**, **Hash of Previous Block Heade**r, **Merkle root** of the transaction. All these blocks are connected to the following block with the help of the pointer (like a Linked List).**Previous Block Hash**: Its similar to previous pointer in linked list but here instead of storing the address of previous block ,previous block hash field stores the hash of the data of previous block inside it.**Merkle Tree:** All of the transactions in this block are hashed together. So it basically provides a single-line summary of all the transactions in this block.

# CRYPTOGRAPHY

## WHAT IS CRYPTOGRAPHY?

**Cryptography **is a process of converting **ordinary plain text** into cypher text (**unintelligible text)** and vice-versa. It is a method of storing and sending data in a peculiar form so that only those for whom are intended can read and process it. **Cryptography** not only protects data from theft or alteration, but can also be used for user authentication or verification.

## SYMMETRIC-KEY CRYPTOGRAPHY

Both the sender and receiver share a **single key **and this key is same. The sender uses this **same** **key to encrypt **plaintext and send the cipher text to the receiver. On the other side the receiver applies the **same key to decrypt **the message and can get the same plain text

## ASYMMETRIC-KEY CRYPTOGRAPHY

In Public-Key or Asymmetric Cryptography two different related keys (**public and private key)** are used. **Public key** may be freely distributed i.e. it can be shared with anyone, while its paired **private key**, remains a secret ,so no one can decrypt only indented can decrypt it . The **public key** is used for encryption and for the decryption **private key** is used.

# HASHING

## WHAT IS HASHING?

Hashing is that the process of converting a given key into another value. A **hash function** is employed to get the new value corresponding to a mathematical algorithm. The results of a hash function is called as **hash value** or simply, a **hash**.

## GOOD HASHING FUNCTION?

A good hash function uses a **one-way** hashing algorithm, or in other words, the hash can’t be converted back to the original key.

## HASH FUNCTION

No key is used in this algorithm. A constant-length hash value or fixed length hash value is computed as per the plain text that creates or makes it impossible for the data of the plain text to be recovered.

# CRYPTOGRAPHY IN BLOCKCHAIN

Blockchains make use of two sort of cryptographic algorithms, **asymmetric-key algorithms**, and **hash functions**.

## HASHING USED IN BLOCKCHAIN

A given blockchain functions supported on the verification of a **hash*** *and **digital signatures**. Hashing is a process that the blockchain uses to **confirm its state**. Each transaction requires one or more digital signatures. Signatures make sure that the transaction is only and only made by the owner of the address. And that it is received by the correct recipient.

**Example of Hashing Algorithm**: **SHA-256**: Used in Bitcoin technology and **Keccak-256**: Utilized in Ethereum

We’d wished to prevent any kind of tampering with in the data stored inside the block, and detection will be the first step to that. To detect if any of the data in the block has been tampered with, you can use cryptographic hash functions.

A **hash function** is a function that takes data of any size and produces data of a constant(fixed) size from it (a hash), which is generally used to identify the input.

For example, if we use the **SHA-256** algorithm for hashing process it will always gives an output of **256-bits length**.

## USES IN BLOCKCHAIN

- Hashing helps in establishing
**cryptographic signatures**that help in determining**valid transactions.** - The
**hash of a transaction**makes it very easy to keep track of transactions of the blockchain. Instead of finding for a transaction that was the “1030th in block 14573”, it is very easy just to copy the hash into a blockchain explorer from where you can view the transaction details. - Hashing functions are very crucial in crypto mining where a valid nonce is being discovered by computing several hashes. This helps to form a
**consensus**on the blockchain. - The use of
**hash of the data**helps to store large amounts of data on the blockchain. This data is time-stamped and can be hashed for future reference. It makes the permanent data storage less bulky or simply more economical.

# ASYMMETRIC KEY CRYPTOGRAPHY USED IN BLOCKCHAIN

## WHY WE USE ??

In Blockchain Network, Public Key Cryptography also known as asymmetric key cryptography is useful in creating a secured Digital reference about the identity of users. Secured digital reference includes “who owns what” and “who is who” in the P2P network. This identity is more important in Public Blockchain.

## WHAT IS DIGITAL SIGNATURE

Digital Signature is an electronic document that you hold a digital key. Digital signatures are used for digitally signing a document using the sender’s private key, as we use our exclusive sign in the paper documents. Anyone having the pairing public key of the sender can decrypt. A digital signature is used for authentication. So an encrypted content is digitally signed for authentication while adding other characteristics like non-repudiation and Integrity

## WHAT IS THE USE DIGITAL SIGNATURE IN BLOCKCHAIN

Digital signatures allow one to prove his/her ownership of the block . For example in bitcoin, if I want to sell it to some other person , I will send hash of data along with digital signature and data combine . The receiver will decrypt the digital signature with his private key and then with my public will will tell that I have send the data. then the receiver will use same hash function to calculate the hash of data that was send along with digital signature . And then the two hash value are compared if they match then data is not tampered else the data send is malicious

## Example of Asymmetric Cryptography Algorithms

RSA, Diffie-Hellman, Elliptic Curve Cryptography (ECC) are some of the Asymmetric Cryptography algorithms. Most of these algorithms have different variants and versions. The typical key lengths used by these algorithms may vary from 8 bit to 512 bits. The strength of any algorithm is in the inability of the hacker to decrypt, in spite of having one key. The larger is the length of the key, the stronger the encryption process will be, and hence less vulnerable to hackers attack i.e. less chance of hacker to attack. But larger key will also demands higher computational power for encryption process.

# CONCLUSION

Cryptography is very important and an integral part of the inner or actual workings of blockchain technology. Public-key encryption also known as asymmetric key cryptography serves as the basis for blockchain wallets and transactions and also for generate digital signatures to known about who send or modified any message. Cryptographic hash functions provide the trait of immutability and verify or determine valid transaction , and Merkle trees organize transactions while enabling blockchains to be more efficient.