{"id":23020695,"url":"https://github.com/resilientapp/reschat","last_synced_at":"2025-03-22T03:14:43.146Z","repository":{"id":208682085,"uuid":"703395084","full_name":"ResilientApp/ResChat","owner":"ResilientApp","description":"A decentralized chatting system based on ResilientDB","archived":false,"fork":false,"pushed_at":"2024-07-26T13:08:31.000Z","size":26094,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"ResChat_v2","last_synced_at":"2024-08-28T01:11:10.339Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ResilientApp.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-11T06:57:43.000Z","updated_at":"2024-07-26T13:08:35.000Z","dependencies_parsed_at":"2024-01-14T11:24:39.957Z","dependency_job_id":"d4e1bf7b-e0f2-4e44-9fb1-61cb90bc4b4b","html_url":"https://github.com/ResilientApp/ResChat","commit_stats":null,"previous_names":["nobuginmycode/ecs189f_project","nobuginmycode/resilientdb_reschat","resilientdb/reschat"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ResilientApp%2FResChat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ResilientApp%2FResChat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ResilientApp%2FResChat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ResilientApp%2FResChat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ResilientApp","download_url":"https://codeload.github.com/ResilientApp/ResChat/tar.gz/refs/heads/ResChat_v2","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244898458,"owners_count":20528341,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-15T12:14:54.209Z","updated_at":"2025-03-22T03:14:43.126Z","avatar_url":"https://github.com/ResilientApp.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"readme_images/reschat_logo.svg\" alt=\"ResChat\" width=\"200\"/\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003eA ResilientDB blockchain based chatting system\u003c/p\u003e\n\u003cp align=\"center\"\u003eBy Jiazhi(Kenny) Sun\u003c/p\u003e\n\n\n## 1. Project Description\n### 1.1 Overview\nIn today's life, when we try to send a message on most chat software, the message will first be sent to the central server, \nand then forwarded to the target user by the central server. \nThe disadvantage of this is that all data will be captured and stored by the central server, \nwhich greatly increases the risk of data leakage and leakage of private information. \nNow, we will create a decentralized chat system based on the ResilientDB blockchain. \nThis decentralized chat system does not store any personal information, \nand only the sender and recipient can encrypt and decrypt the message during the transmission of the message.\n\n### 1.2 Key Features\n1. Decentralized Architecture: Our system avoids the need for a central server. All messages are transmitted through ResilientDB blockchain.\n2. Security: By using the combined encryption algorithm(RSA + AES), we can ensure that information cannot be easily cracked during blockchain transmission. Only the sender and recipient of the message can use their keys to encrypt and decrypt\n3. Privacy-first Approach: User data is never stored on any central server. No chat history will be stored.\n4. Open-source: To ensure utmost transparency and security, our system is fully open-source, allowing community participation and review.\n5. Flexibility: Users can create their own ResilientDB blockchain and use ResChat as an intranet chatting software, or users can connect to the main blockchain and use ResChat as an internet chatting software.\n6. Extremely low disk space usage: Users only need to store their private key locally, and everything else is stored in the blockchain.\n\n## 2. Overall Idea\n### 2.1 Message and Page\nThe key of messages is a custom class called `Page`. `Page` serves as a container to store and transfer messages. \nEach `Page` has 20 messages and each message has 7 different fields. When a page is full, a new page will be created.\n1. Receiver's public key: Who will receive this message, base on this we can identify who is the sender and receiver of this message.\n2. Message type: `TEXT` or `FILE` to identify how to process this message.\n3. Time stamp: When this message been sent.\n4. Message type extension: Only in use when message type is `FILE` to store file name and extension such like `testFile.pdf`\n5. Encrypted message: If message type is `TEXT`, this field will store the encrypted text string. \n   If message type is `FILE`, this field will store a key(A ResilientDB key) and the corresponding value is encrypted file string.\n   In this way, it will not give a high pressure to the internet, and computing power. Users can choose to download the file or not.\n6. Encrypted AES key with sender's RSA public key: Use sender's RSA public key to encrypt randomly generated AES key. \n   So, sender can decrypt AES key with his/her RSA private key.\n7. Encrypted AES key with receiver's RSA public key: Use receiver's RSA public key to encrypt the AES key. Only receiver can decrypt this message.\nIn this approach, sender and receiver can both encrypt and decrypt certain message with their own RSA private keys without expose the keys to each other.\n\nBoth sender and receiver will obtain some shared pages. This project is using kv service of the ResilientDB, \nand the command line instructions are set `key` `value` and get `key`. \nThe `key` part constructed with two fields `page name` and `page number`. \nThe `page name` is constructed by sender and receiver's username(sorted in ASCII order) to ensure that both receiver and sender will have the same page name. \nPage name will never change throughout the chatting. On the other hand, `page number` starts at 1, \nand it will increase by 1 everytime the page is full. \nResChat will load most recent two pages everytime user start up the client(current page and current page -1) In this way, \nall chat history are stored on the chain(ResilientDB) and user can load as many as previous chatting history as he/she wants.\n\n[//]: # (### 2.2 File Transfer)\n\n[//]: # (As mentioned above, when user want to download a file. System will first read the corresponding value\u0026#40;encrypted file string\u0026#41;)\n\n[//]: # (of the file location. However, to avoid overload the RAM during the encryption and decryption process, a large file will be break into )\n\n[//]: # (different small chunks. For example, if the file location is `123456 654321 FILE 1`, system will first get the value from this key, )\n\n[//]: # (which is a checker to show this file has been uploaded completely or not. If this field is `FINISHED` means file has been uploaded completely,)\n\n[//]: # (then, system will check `123456 654321 FILE 1 1` which is the first file chunk next is `123456 654321 FILE 1 2` which is the second file chunk... )\n\n[//]: # (Such process will keep going until a key's corresponding value is none.)\n\n[//]: # ()\n[//]: # (Example:)\n\n[//]: # (Let's assume my username is 123456 and the friend I am currently chatting with has username 654321. Below image shows)\n\n[//]: # (how pages and files are stored in the ResilientDB in a key value pair form.)\n\n[//]: # ()\n[//]: # (![page and file image]\u0026#40;readme_images/page_and_file.png\u0026#41;)\n\n### 2.2 Encryption/Decryption\nThis project uses RSA + AES as the encryption algorithm. The message will be first encrypted by a randomly generated 16 bytes(128 bits) AES key. \nThen, this AES key will be encrypted by 2048 bits RSA public key(AES key will be encrypted twice, one with sender's public key, another with receiver's public key).\nIn this approach, ResChat can achieve not only secure text messages transfer but also secure file transfer(RSA can not encrypt a string that is too long).\n![encryption diagram](readme_images/encryption.png)\n\n\n## 3. How to run\n1.  [Install Anaconda](https://www.anaconda.com/download#downloads)\n\n2. Install Bazel 5.0.0 on [Ubuntu](https://bazel.build/install/ubuntu) or [Mac](https://bazel.build/install/os-x)\n\n\n3. Setup Anaconda Environment\n```\nconda create --name YOUR_ENV_NAME python=3.8\nconda activate YOUR_ENV_NAME\ncd ResChat\npip install -r requirements.txt\n```\n4. Build Bazel(Make sure run bazel build command with the Anaconda environment just crated )\n```angular2html\ncd ResChat\nbazel build :pybind_kv_so\n```\n\n5. Run Front-end Service\n```angular2html\ncd frontend\nnpm run install\nnpm run start\n```\n\n6. Run Back-end Service\n```angular2html\npython3 http_request.py\n```\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fresilientapp%2Freschat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fresilientapp%2Freschat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fresilientapp%2Freschat/lists"}