Skip to content

Project on BlockChain offered by the Association of Computer Activities(ACA), IIT Kanpur in 2020-21 II.

Notifications You must be signed in to change notification settings

RoyalPhoenix-bot/BlockChain

Repository files navigation

BlockChain

Learnt and Implemented the concepts of BlockChain, through various assignments, primarily in JavaScript.

Aim: Finding the nonce for a string.

Given some data as string input, we had to find a key x, such that when x is appended to the data, the SHA-256 hash of the string is less than a target value. The target value in the code is 0x0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF.

Aim: Understanding the Asymmetric Encryption security system used in BlockChain.

Verifying if the Public Key can decrypt a text encrypted with its complementary Private Key, thereby verifying signatures.

  • Code - KeyPairGeneration Generates a Public and Private Key Pair.
  • Code - PrivateEncrypt Signs(Encrypts) given data(input) with the Private Key.
  • Code - PublicDecrypt Decrypts the encrypted data and verifies if the decrypted string is same as the given input.

Aim: Creating a binary data file .dat of a block transaction data.

  • Code - CreateBinaryFile
    1. Takes the Transaction Data as input.
    2. Creates a Binary File .dat.
    3. Calculates the SHA-256 hash of the binary data and saves the file as 'hash'.dat.

Aim: Getting back the transaction data from a binary data file .dat. Code - ReadData Reads a binary data file .dat and gives back the Transaction Data.

(Complementary Code of Assignment 3).

Aim: Calculating block header and suitable nonce.

Code - blockHeader

  • Calculates the block header from given block index, hash of parent block and block body(.dat).
  • Finds a suitable nonce with a certain pseudo-randomness in the loop. The hash depends(varies) on 2 factors: The Nonce value tried and the Timestamp at which it is tried.

The pseudo-randomness introduced ensures that the fastest system mining doesn't win the race everytime. The faster computer will have an upper-hand, but won't win every time.

Aim: Creating a local server, which listens on port 8787 which calculates the SHA-256 hash of given input.

Code - index takes some data, calculates its SHA-256 hash, converts it to hexadecimal and outputs it as JSON encoded data.

  • Readme gives instruction on running the code.

Web Broswer Implementation Implemented the same code which runs on a local web broswer, using JavaScript and HTML. Folder - Trial Code With Browser contains the codes and instructions on how to run it.

About

Project on BlockChain offered by the Association of Computer Activities(ACA), IIT Kanpur in 2020-21 II.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published