Programming Club

https://pclub.in

https://pclubiitk.slack.com

https://www.facebook.com/groups/pclubiitk/

IITKBucks

A blockchain based cryptocurrency

Overview

In this project we built a custom cryptocurrency using a blockchain model. Everyone developed their own node. The model can be used for secure transactions that can be verified by anyone without the need of a central body. A major advantage of such a network is that it maintains strict anonymity, as a public key is all that is needed to make a transaction.

Goals

  1. Understanding the working of blockchains: One of our aims was to understand terms like target, mining etc., and to learn about how the history of a blockchain is practically unmodifiable even though it is publicly available.
  2. Understanding practical application of modern cryptography: We also aimed to analyze the use of cryptographic methods like hash calculation, and the usage of digital signatures to prove ownership.
  3. Understanding peer-to-peer networks: We tried to learn how independent nodes in a P2P network function without the need of any supervising body, and why a single peer cannot go against the majority consensus.
  4. Implementing a large project: We gained hands-on experience of the development of multithreaded applications, and were introduced to the entire workflow of building such a large project from scratch.

What we did

We first built various parts of the application singularly as assignments. Then all of us built our own node. The nodes can be deployed on any computer and tunnelled through ngrok to get a hostname. We also built an interaction tool to help end users to make transactions. The interaction tool can be deployed or run separate from the miner. It only needs the url of any one node, to which it will send the request.

Timeline

  1. Assignments phase

In the first phase, we learn about blockchains and solved assignments to singularly implement different parts of the project.

  1. Project Building phase

In the second phase, we put together the various parts implemented at assignments into a main application.

  1. Deployment phase

One node of the project had been deployed on https://iitkbucks.pclub.in from 13th July 2020 till 26th July 2020. Through trying to communicate with that node, we found and eliminated the bugs in our applications. In this phase, we brought our programs to completion.

Implementation

  1. Nodes

All of us built our own nodes, in a language of our preference, following the API specification given below. In total, there were 9 nodes implemented in Javascript, 4 in python, 1 in Java and 1 in Go.

  1. API Documentation

We implemented the following endpoints in our nodes:

  1. Miner

The part for mining a new block had to run in parallel with the HTTP server. In order to prevent the main thread from blocking, we needed to implement multithreading in our applications. For this purpose, we used worker threads in Javascript, the threading module in python, and the java.util.concurrent package in Java.

  1. Frontend

The frontend is the part with which the user interacts. This could be a desktop GUI application, a web app, or a Command Line Interface. The choice was left to the students to choose which type of frontend they would want to build. Most students chose to build a CLI.

What we learnt

  1. We learned about an entire new domain of cryptocurrency. We can now critically analyse Block Chain Models in real life and suggest improvements.
  2. We understood aspects about multi-threading to efficiently be able to mine blocks or do computationally intensive tasks simultaneously and learnt to use libraries for threading and cryptography
  3. We learned a lot about cryptography and its crucial application in daily life for provision of a secure service over an unsecure network like the internet..
  4. We learnt about how to obtain universal hostnames through tunneling softwares like ngrok and also various subtle aspects of the programming languages used to develop our respective applications.

Final Result

One node had been deployed at https://iitkbucks.pclub.in for about 2 weeks. The nodes can be deployed as and when required. They will pick up the chain from one of the peers and can start building the chain further. The following is a list of the people involved in the project, and links to their repositories, containing the code for their nodes: