In this era of ubiquitous social media and messaging applications, users are becoming increasingly aware of the data privacy issues associated with such apps. Major messaging applications are moving towards end-to-end encryption (E2EE) to give their users the privacy they are demanding.
What it does
Phase 1 - Certificate Generation and Registration Phase 2 - Sending a Secure Message Phase 3 - Receiving a Secure Message Phase 4 - Backup and Restoration
How we built it
We will define 3 functions :
- The checkUserExists(pubkey) function is used to check if a user is registered with our application or not. It will help make sure duplicate users are not created and it will also be called from other functions to check their existence.
- The createAccount(username) function registers a new user on the platform with the provided username.
- The getUsername(pubkey) function will return the username of the given user if it exists. Adding friends.
- The checkAlreadyFriends(pubkey1, pubkey2) function checks whether two users are already friends with each other or not. This is needed to prevent duplicate channel between the same parties and will also be used to prevent a user from sending messages to other users unless they are friends.
- The addFriend(pubkey, name) function mark the two users as friend if they both are registered on the platform and are already not friends with each other. The getMyFriendList() function will return an array of friends of the given user. # Messaging: The final part of the Solidity contract will enable the exchange of messages between users. We will divide the task into two functions sendMessage() and readMessage().
- The sendMessage() function allows a user to send messages to another registered user (friend). This is done with checkUserExists(pubkey) and checkAlreadyFriends(pubkey1, pubkey2).
The readMessage() function returns the chat history that has happened between the two users so far.
User Data Collections:
We will have three types of user-defined data :
user will have the properties name which stores the username, and friendList which is an array of other users. friend will have the properties pubkey which is the friends' public address, and name which the user would like to refer them as. message has three properties: sender, timestamp and msg, which is short for "message". We would maintain 2 collections in our database:
userList where all the users on the platform are mapped with their public address. allMessages stores the messages. *As Solidity does not allow user-defined keys in a mapping, we can instead hash the public keys of the two users. This value can then be stored in the mapping.
Accomplishments that we're proud of
This demand for private instant communication fueled the rise of popular encrypted messaging apps such as Telegram and WhatsApp. Now it appears that blockchain technology is trying to revolutionize the way we communicate once more. As a result, blockchain messaging apps are on the rise.
What we learned
A ecentralized application does not have a centralized server. It is basically a peer-to-peer network. Also the data that is stored in block is almost impossible to view as a very secure encryption and hashing functions (256 bits) are used.
What's next for Harmony Chatting Dapp
i will adding some cool ui designand more responsible