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

Blockchain Immutability in Chatservers

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)
18 views9 pages

Blockchain Immutability in Chatservers

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

Rendering Blockchain Immutability in chatserver: A

NodeJs Approach.

Umesh Kumar Chopra


Lucknow Campus
Amity University,,Uttar Pradesh, Lucknow -226028
[Link]@[Link]

Ayush Kumar Rathore


Scholar
Amity University,Uttar Pradesh, Lucknow -226028
ayushkumarrathore@[Link]

Rajiv Pandey, PhD


Senior Member IEEE
Amity University,Uttar Pradesh
Lucknow-226028
rpandey@[Link]

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 [Link] 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, [Link]

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, “[Link]” section
explores [Link] 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 [Link] 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. [Link]

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


scalable network applications” [2]. [Link] 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. [Link] 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, [Link] 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


 [Link]
 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 [Link] 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: [Link]

2. [Link] [Link]

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:
[Link]

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


longer oil, but data. Retrieved from The Economist:
[Link]
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: [Link]
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:
[Link]
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:
[Link]
works-guide-for-beginners#nodes
12. What is Blockchain Technology? A Step-by-Step Guide For Beginners.
(n.d.). Retrieved from [Link]: [Link]
is-blockchain-technology/

Common questions

Powered by AI

The use of Node.js in developing a decentralized chat system leveraging blockchain technology brings several benefits. Node.js, with its non-blocking, event-driven architecture, allows for efficient management of concurrent connections, a vital feature for real-time chat applications where responsive, low-latency interactions are crucial. Its rich library of modules supports rapid development and integration with blockchain components, such as crypto-js for cryptographic functions. Node.js's capability to handle high-throughput data processing helps in accommodating the needs of a distributed ledger system within chat applications, ensuring that messages are quickly processed and recorded across the network. Additionally, JavaScript's ubiquity and the large Node.js community facilitate faster problem-solving and innovation .

Consensus mechanisms like Proof of Work (PoW) play a critical role in maintaining blockchain data immutability by ensuring that all nodes agree on the validity of transactions before they are added to the blockchain. In a Chatserver context, PoW requires computational effort from nodes to solve cryptographic puzzles, thus confirming transactions. The puzzle solution acts as proof that a certain amount of work was performed. Since P2P networks rely on consensus for recording transactions, PoW ensures that all the transactions in a block are validated and only then appended to the blockchain. This consensus makes unauthorized modifications practically impossible as altering a block would require redoing the PoW for all subsequent blocks, which is computationally prohibitive .

The concept of the genesis block in a blockchain Chatserver can ensure data integrity from the outset of communications by serving as the initial, foundational block that all subsequent blocks reference. Its hash sets the baseline for the chain, as each subsequent block contains the hash of the previous block, which includes the genesis block. Therefore, any alteration in the blockchain would require changing the hash of the genesis block, thereby invalidating the entire chain. By maintaining an immutable genesis block, it establishes a trusted starting point for data integrity, ensuring that all subsequent communications can be traced back securely to their origins without any tampering .

Applying smart contracts within a blockchain Chatserver presents challenges such as ensuring the correct execution of automated transactions without errors or vulnerabilities, which can be exploited. The complexity of writing secure smart contract code can lead to bugs, requiring thorough code reviews and testing. Additionally, since smart contracts are immutable once deployed, errors can result in permanent issues. To mitigate these challenges, developers can implement comprehensive unit testing, employ static analysis tools to check for vulnerabilities, and utilise security audits from third-party experts. Another approach is to develop smart contracts in a modular fashion, allowing updates or changes to be implemented more easily by isolating functionalities across different contracts .

Merkle Trees enhance the integrity of data in a Blockchain Chatserver by providing a means to efficiently and securely verify the integrity of transactions within a block. Each transaction is hashed and then pairwise hashed until a single root hash, the Merkle root, is derived. This structure allows users to verify the presence and integrity of a transaction without having to process the entire block. If any transaction is altered, it would change the subsequent hashes in the Merkle Tree, up to the Merkle root, thus indicating that the data integrity has been compromised .

Blockchain's immutability is crucial for securing chat trails in sensitive applications because it ensures that once a chat message is recorded, it cannot be altered or deleted, providing an indisputable record of communication. This characteristic is vital for environments such as military or legal sectors where the integrity of communications could impact decision-making and accountability. The immutability is achieved through cryptographic hashing and consensus mechanisms; any attempt to alter a recorded message would disrupt the chain, raising an alarm for the management bodies to act accordingly. Thus, it provides a trusted audit trail necessary for compliance and security .

The implementation of blockchain in a Chatserver using Node.js ensures data immutability through the use of timestamps and hash sequences. Each transaction is hashed, and many such transactions are included in a block after reaching consensus. The hash from each transaction helps maintain the integrity of the block, as any change would alter the hash, making unauthorized changes evident. This approach, combined with the consensus mechanism on the network, such as Proof of Work, ensures that once a transaction is recorded, it cannot be altered without changing each subsequent block, making such fraud easily detectable .

The decentralization achieved through blockchain in managing chat data offers several security and operational advantages. Firstly, decentralization removes single points of failure, improving security against targeted attacks that are more feasible in centralized structures. With all nodes holding copies of the chat data, the network is more resilient to data loss or corruption. Operationally, decentralization promotes redundancy, ensuring data availability even if some nodes go offline. This model also enhances trust, as transactions are verified through consensus rather than a central authority, mitigating risks of fraud and unauthorized access. Finally, decentralization can potentially reduce costs associated with centralized data storage and management, by distributing the load across the network .

Integrating blockchain technology through Node.js can impact the scalability of a Chatserver by leveraging Node.js's asynchronous, event-driven architecture, which is well-suited for handling numerous simultaneous connections efficiently. Node.js allows the Chatserver to manage many tasks concurrently, which is essential for scalability. When combined with blockchain, each chat message is effectively stored in blocks distributed across the network, which can grow as needed. However, while the P2P structure of blockchain can provide robustness and data distribution benefits, it may also introduce latency and data consistency challenges as the network grows, particularly when nodes need to reach consensus, potentially impacting the real-time responsiveness of the Chatserver .

A Peer-to-Peer (P2P) network contributes to the security and privacy of blockchain technology by eliminating the need for a centralized point of control and thereby removing central points of failure or attack. Data is distributed across all nodes in the network, which enhances crash recovery and redundancy. Additionally, the use of asymmetric cryptography ensures that users can encrypt messages with a public key visible to all, while maintaining privacy with a private key only known to them. This architecture greatly reduces attack vectors that could be exploited in centralized systems, thus preserving user anonymity and increasing the system's robustness against unauthorized tampering in applications like Chatservers .

You might also like