Skip to content

Commit 882f45c

Browse files
committed
docs: change client-side encryption diagrams to mermaid charts
1 parent 820cd8f commit 882f45c

File tree

1 file changed

+38
-12
lines changed

1 file changed

+38
-12
lines changed

README.md

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,53 @@
3232

3333
## Client-side Encryption
3434

35-
* Darim supports client-side encryption to protect the user's secrect from others including server.
36-
37-
### Generate keys
38-
39-
![key generation flow](https://user-images.githubusercontent.com/6410412/91041309-c37dee80-e64a-11ea-9ac0-75dc0d810aa8.png)
40-
41-
1. When a user finishes the sign-up process, the secret key and public key are generated on the client-side.
42-
1. The client encrypts the secret key by public key and saevs the encrypted secret key in local storage.
35+
Darim supports client-side encryption to protect the user's secrect from others including server.
36+
37+
### Key generation
38+
39+
```mermaid
40+
%%{init: {'theme': 'neutral'}}%%
41+
sequenceDiagram
42+
Note over client: generates<br>secret and public
43+
Note over client: encrypts secret<br>using public
44+
client ->> local storage: set(encrypted_secret)
45+
client ->> server: POST /public_key { public }
46+
server ->> rdb: INSERT public
47+
rdb -->> server: [OK 200]
48+
server -->> client: [OK 200]
49+
```
50+
51+
1. When a user finishes the sign-up process, a secret key and public key are generated on the client-side.
52+
1. The client encrypts the secret key using the public key and saves the encrypted secret key to local storage.
4353
1. The public key is sent to the server, and the server stores it.
4454

4555
### Read & Write
4656

47-
![read and write flow](https://user-images.githubusercontent.com/6410412/91042440-b530d200-e64c-11ea-86f5-dfbcf025bdf4.png)
48-
49-
1. When a user creates the plaintext post, the client requests the public key to the server.
57+
```mermaid
58+
%%{init: {'theme': 'neutral'}}%%
59+
sequenceDiagram
60+
Note over client: creates a new post
61+
client ->> local storage: get(encrypted_secret)
62+
local storage -->> client: encrypted_secret
63+
client ->> server: GET /public_key
64+
server ->> rdb: SELECT public
65+
rdb -->> server: [OK 200] { public }
66+
server -->> client: [OK 200] { public }
67+
Note over client: decrypts<br>encrypted_secret<br>using public
68+
Note over client: encrypts the post<br>using secret
69+
client ->> server: POST /post { encrypted_post }
70+
server ->> rdb: INSERT encrypted_post
71+
rdb -->> server: [OK 200]
72+
server -->> client: [OK 200]
73+
```
74+
75+
1. After a user creates a new plaintext post, the client requests the public key to the server.
5076
1. The client decrypts the encrypted secret key in the local storage using the public key from the server.
5177
1. The plaintext post is encrypted by the secret key decrypted by the public key.
5278
1. The encrypted post is sent to the server, and the server stores it.
5379

5480
> * At this point, the server can only know encrypted post.
55-
> * When the client requests the server to read the post, whole flows are reversed.
81+
> * If the client reads a post, the flow is the same until the client requests to create a post to the server.
5682
5783
## License
5884

0 commit comments

Comments
 (0)