Skip to content

Commit 43e11ea

Browse files
added encryption mechanism to readme.md
1 parent aef2a72 commit 43e11ea

5 files changed

Lines changed: 22 additions & 4 deletions

File tree

README.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
1-
#UI of the app
2-
![alt text](signup.png)
1+
# UI of the app
2+
### Signup Page
3+
![Signup Page](./resources/imgs/signup.png)
4+
### Chatting Page
5+
![Chatting Page](./resources/imgs/chatPage.png)
6+
![Chatting Page](./resources/imgs/chatPage2.png)
7+
### Message Storage in the database
8+
The message is encrypted as soon as it leaves the client's device and thus server gets the encrypted message which is stored to the database as shown below.
9+
![Message on Database](./resources/imgs/databas.png)
10+
The message is decrypted when it reaches the client's friend device.
11+
12+
## How the encryption-decryption work
13+
Two friends chatting must have the same key such that a message sent (after encryption) by one user can be read by the other. But we cannot send the decryption key over the network or to the server for security reasons. Therefore, to create a common key that will be used by each of the friends, **Diffie-Hellman Key Exchange** algorithm is used. Once the commmon key is generated, it will be used for both encryption and decryption using a symmetric key encryption, **AES-algorithm**.
14+
### How a common key is generated via Diffie-Hellman Key Exchange
15+
Suppose userA and userB are chatting to each other. userA has a secret key $secA = 13$ and userB has a secret key $secB = 20$. And assume $g = 2$ and $p = 83$ are a generator and a prime number respectively (g and p need not be private or secret).
16+
1. Before the start of chatting, userA sends $g^{secA}(mod\ p) = 2^{13}(mod\ 83) = 58$ and receives $g^{secB}(mod\ p) = 2^{20}(mod\ 83) = 37$ from userB.
17+
2. userA applies a power of $secA (mod\ p)$ to the received key and gets the common key as: $37^{13}(mod\ 83) = 33$
18+
3. userB applies a power of $secB (mod\ p)$ to the key received from A and gets the common key as: $58^{20}(mod\ 83) = 33$
19+
4. Thus, each one of them has generated a common key $33$ **without actually sending** their secret keys.
20+
21+
In this app, secret key of a user is the same as his hashed password. Now the common key 33 will be used for encrypting and decrypting all the chats between the two users using a symmetric encryption algorithm.
322
\
423
\
524
\
@@ -14,8 +33,7 @@
1433
\
1534
\
1635
\
17-
\
18-
36+
\.
1937
# Getting Started with Create React App
2038

2139
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

resources/imgs/chatPage.png

94.5 KB
Loading

resources/imgs/chatPage2.png

123 KB
Loading

resources/imgs/databas.png

65.1 KB
Loading

signup.png

-47.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)