0% found this document useful (0 votes)
82 views9 pages

Rendering Blockchain Immutability in Chatserver: A Nodejs Approach

The document discusses implementing immutability in a chat server using Node.js and blockchain technology. It proposes recording chat messages in a blockchain to provide an immutable record. Key aspects include using cryptographic hashing and a consensus mechanism to add blocks of messages to the blockchain and ensure integrity of the chat history. The paper outlines how Node.js libraries could be used to build a blockchain-backed chat server for secure, immutable messaging.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views9 pages

Rendering Blockchain Immutability in Chatserver: A Nodejs Approach

The document discusses implementing immutability in a chat server using Node.js and blockchain technology. It proposes recording chat messages in a blockchain to provide an immutable record. Key aspects include using cryptographic hashing and a consensus mechanism to add blocks of messages to the blockchain and ensure integrity of the chat history. The paper outlines how Node.js libraries could be used to build a blockchain-backed chat server for secure, immutable messaging.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Rendering Blockchain Immutability in chatserver: A

NodeJs Approach.

Umesh Kumar Chopra


Lucknow Campus
Amity University,,Uttar Pradesh, Lucknow -226028
[email protected]

Ayush Kumar Rathore


Scholar
Amity University,Uttar Pradesh, Lucknow -226028
[email protected]

Rajiv Pandey, PhD


Senior Member IEEE
Amity University,Uttar Pradesh
Lucknow-226028
[email protected]

Abstract. Distributed ledger approach of Blockchain has ensured immutability


of data. The chain originates from the genesis block and keeps adding blocks
starting from the genesis block based on records of transactions over a given
time frame. The hash of each transaction is further represented and many such
transaction after due consensus are included in the block of the chain. The
Merkel tree approach enables the mathematical resultant of each transaction
into the block. This paper explores the implementation of the Blockchain in a
Chatserver using Node.js where by the Timestamp and Hash sequences enable
the immutable trail of the chats. The aspects of immutability have been
embedded through the build in features of consensus in a Chatserver.

Keywords- Blockchain, Immutability, Chatserver, Data, Node.js

1. Introduction

The amount of digital data has reached staggering amounts globally. A recent report
claims that 90% of the world’s data was generated over the past 2 years (Brandtzæg,
2013). In the era of AI, ML and Big Data this data is constantly being generated,
stored and processed, the data being at the core of any decision making calls for
serious data breaches. Centralized organizations, both public and private sector,
collect huge amounts of sensitive personal data and information. Data has been an
inseparable part of global headlines lately, the most famous being the Facebook-
Cambridge Analytica Scam (Solon, 2018). The data breach scam caused a global
outcry and the people questioned the amount of control they have over their sensitive
information. WannaCry Ransomware, another famous incident covered extensively
by the public media, infected millions of computers globally (Jones, 2017).
Cybercriminals are getting more active and more competent by the day whereas for
people and organizations, the odds have never been higher. Today, data has become
one of the most valuable assets of an economy (Economist, 2017) and its protection is
a necessity. The security of data even in chat trails need to incorporate immutability,
as the use case in defence may apply were the trails are valuable when debriefs are
carried out.
This paper contains seven sections, Section-1, “Introduction” describe the
organization of the paper. Section-2, “Blockchain” section describes features and
presents a brief analysis of the Blockchain. Section-2, “Blockchain Security”
highlights the security features with some demonstration. Section-4, “Node.js” section
explores Node.js as the platform for Blockchain implementation. Section-5,
“Chatserver” section of the paper demonstrates how Blockchain can be used in
implementation of the Chatserver. Section-6, “Blockchain use-case”: Chatserver
evaluates the relevance of immutability during communication between Client and
Server.

2. Blockchain

“Blockchain is a shared, trusted, public ledger of transactions that everyone can


inspect but which no single user controls, it is a distributed database that maintains a
continuously growing list of transactions data records, cryptographically secured
from tampering and revision.” [1]

Features of a Blockchain:
3. Each node receives a replica of all transactions.
4. All nodes intercept fresh transactions into block.
5. Every node seeks to evolve a consensus for its block.
6. If a node encounters a consensus, it transmits it to every node on the
network.
7. All transactions are evaluated for their validity and subsequently committed.
(Fig 7)
8. Upon validation of the Hash values the Nodes render their acceptance by
appending it as the next block.

9. Blockchain security

Blockchain uses the concept of distributed ledger to increase its security. Third parties
and Central Organizations validate transactions through their own servers with only a
small knowledge of legitimacy but in a Blockchain environment, a P2P network of
nodes functioning on the same Blockchain protocol do all the legitimate work and
through consensus or Majority vote. Consensus uses Smart Contracts to maintain
legitimacy.

Consensus mechanism or algorithms are primarily:


1. PoW: Proof of Work
2. PoS: Proof of Stake
3. PoET: Proof of Elapsed Time

Therefore, pre-defining consensus rules for approving transactions on peer to peer


network enforces legitimate transactions by all the participants in the network making
the Blockchain immutable.

Fig 1: Bitcoin block data[3]

Fig 1 clearly highlights the various components of a block namely:

1. Previous Hash: hash value of the previous block.


2. Timestamp: It ensures immutability via the clause of stating that the block
existed at the given time T.
3. Tx_Root: It is the Merkel tree of all the transactions in the block.
4. Nonce: It is the actual data.

The above components are elucidated in detail in the Node.js code snippet.

Blockchain technology will helps users maintain a collective, reliable and a


decentralized database. It is thus a scattered database that maintains a constantly
growing list of records, cryptographically secured from manipulation [1]. A typical
Blockchain system consists of a series of blocks which are connected in a specific
order. This chained representation is from where Blockchain derives its name. The
users in the system, also known as ‘nodes’, perform the task of validation and storing
the data in blocks. The consensus algorithm used to confirm transactions and add new
blocks to the chain is called Proof of Work (PoW) algorithm. Each Block contains a
hash value of the previous block generated through cryptographic function, a
timestamp and transaction related information (Telegraph, n.d.). This cyclic behaviour
ensures the integrity of the previous block, all the way back to the original genesis
block (Nirupama Devi Bhaskar, 2015).

The various security advantages of Blockchain are listed below:


 Privacy Protection: Blockchain adopts Peer to Peer networking system which
eliminates the need of a centralized database for storing confidential
information. This in turn eliminates centralized points that a hacker might
target and steal valuable information. Similarly, a Blockchain does not have
a central point of failure making it more robust than centralized networking
systems. Blockchain employ Asymmetric Cryptography wherein each user
has 2 keys: a public key that is visible to everyone on the network and is
used to encrypt messages/transactions for the particular user as well as a
private key which can only be used to decrypt the message encrypted via the
user’s public key. A user’s public key has no relation to his/her public
address and, computing a user’s private key from his/her public key is an
impossible task. Thus, Blockchain maintains user anonymity and privacy.

 Crash Recovery: Data on a Blockchain is distributed amongst peer nodes


unlike a traditional database where all the data is stored at a central location.
Each user on the Blockchain has the right to generate and maintain a full
copy of the data. Although this causes data redundancy, it vastly improves
the reliability and fault tolerance of the network. In case some of the nodes
are attacked or compromised, it will not cause damage to rest of the network.

 Immutability: Blockchain has a unique data writing mechanism which


prevents the data in a block from being modified once written. This
mechanism involves the generation of a timestamp the instant a new
record is created. (B. Gipp, 2015) Modification of data henceforth is
prohibited. Also, the recording of a new transaction is decided using a
consensus mechanism which generally requires the mutual agreement of
over 50% of the users of the network.

10. Node.js

“As an asynchronous event driven JavaScript runtime, Node is designed to build


scalable network applications” [2]. Node.js is a server side scripting platform built
atop Google Chrome’s V8 JavaScript engine. It can be used to build fast and scalable
network applications. Node.js provides a rich library of various JavaScript modules.
Some of these modules can be used for Blockchain development. This paper uses the
crypto-js, express, http, socket.io modules to implement a Blockchain Chatserver .
11. Chatserver

This section demonstrates a Blockchain Chatserver approach and not a complete


code.

Things needed before making the server (locally):

 Ubuntu 16.04 or above


 Node.js
 Npm
 Text editor

Fig 2: Block in the Blockchain

This class represents a block in the Blockchain. It has 2 member functions namely
constructor and calculate hash. Constructor has index, timestamp, data and previous
hash as parameters. Index represents the address of the block. The timestamp contains
information related to when the block was created. Data can contain any information
a user wishes to secure by uploading it on the Blockchain. The previous hash
parameter stores the hash value of the previous block except in the case of genesis
block where the hash value is NULL. The calculate hash function calculates the hash
value for the current block using SHA256 encryption module.

Fig 3: Code for creating a genesis block.


Fig 5: Chain Validity (Immutability)

The code snippet in Fig 5 demonstrates the consensus aspect of Blockchain and
distributed ledgers, this code shall be executed to verify the validity of the block, only
if found valid will it be added to the chain. The Consensus algorithm of either POW
or POS shall of course be embedded for detailed implementation of the Blockchain.

Fig 6: Adding a New Block

Fig 7: Blockchain of chats

The above Fig 7 illustrates blocks in a Blockchain. The first block, namely Genesis
block has an index value of ‘0’ implying that it is the first in the chain of blocks. The
previous hash of the Genesis block is “0000” further asserting the fact that it is indeed
the first block as the previous hash cannot be zero except in the case of the first block
in the Blockchain. The Genesis block also contains a hash value that can be verified
by everyone present on the Blockchain. The next block has an “index” value equal to
‘1’ implying that it is the second block in the chain. Its previous hash parameter
contains the exact same hash value of the previous (Genesis) block.

Fig 8: Block creation process

The Fig 8 shows the code snippet of a block creation process for sake of
demonstration. The addBlock function is called only when the receiver is receiving
the sender’s message. The code will be changed in fully fledged application as per the
need of the application.

12. Blockchain usecase

This section of the paper emphasizes that the chat server approach through block
chain and be effectively used in any confidential environments, typically where the
trail of communication is determined to be immutable. The trail is modified at any
future representation should lead to an alarm and the associating management bodies
should take a cognizance.

13. Conclusion

This paper has explored the architecture of a typical Blockchain whereby the
components of a block have been elaborated with a purpose of implementing the same
through the Node JS approach. The immutability aspect of a Blockchain is the key
feature for acceptability in all business environments where security and privacy is
the main concern.

The future scope of extendibility of the said Node.js Applications shall


demonstrate the integration with DAPPs and other web applications. The paper
presents the demonstrative approach of a Blockchain Chatserver and not a complete
code by itself. The code needs to be extended for complete implementation of the
Blockchain and is beyond the scope of this paper.
14. References

1. Shermin Voshmgir, . . (2017, September 30). What is Blockchain? Retrieved


from Blockchain Hub: https://blockchainhub.net/blockchain-intro/

2. Node.js https://nodejs.org/en/

3. licensed under Creative Commons Attribution-Share-Alike 3.0 Unported,


retrieved from Wikipedia

4. B. Gipp, N. M. (2015). Decentralized Trusted Timestamping using the


Crypto Currency Bitcoin. iConference. Newport Beach, CA.

5. Brandtzæg, P. B. (2013, May 22). Big Data, for better or worse: 90% of
world's data generated over last two years. Retrieved from Science Daily:
https://www.sciencedaily.com/releases/2013/05/130522085217.htm

6. Economist, T. (2017, May 6). The world’s most valuable resource is no


longer oil, but data. Retrieved from The Economist:
https://www.economist.com/leaders/2017/05/06/the-worlds-most-valuable-
resource-is-no-longer-oil-but-data

7. Jones, S. (2017, May 14). Global alert to prepare for fresh cyber-attacks.
Retrieved from Financial Times: https://www.ft.com/content/bb4dda38-
389f-11e7-821a-6027b8a20f23

8. Nirupama Devi Bhaskar, D. L. (2015). Handbook of Digital Currency.


Elsevier.

9. Solon, O. (2018, April 4). Facebook says Cambridge Analytica may have
gained 37m more users' data. Retrieved from The Guardian:
https://www.theguardian.com/technology/2018/apr/04/facebook-cambridge-
analytica-user-data-latest-more-than-thought

10. Tapscott, D. &. (2016). BLOCKCHAIN REVOLUTION: How the


Technology Behind Bitcoin is Changing Money, Business, and the World.

11. Telegraph, C. (n.d.). How Blockchain Technology Works. Guide for


Beginners. Retrieved from Coin Telegraph:
https://cointelegraph.com/bitcoin-for-beginners/how-blockchain-technology-
works-guide-for-beginners#nodes
12. What is Blockchain Technology? A Step-by-Step Guide For Beginners.
(n.d.). Retrieved from blockgeeks.com: https://blockgeeks.com/guides/what-
is-blockchain-technology/

You might also like