-
Notifications
You must be signed in to change notification settings - Fork 0
Message History
Client-side message history security:
We could do:
- client authenticates as alice on client
- alice says I want to save history
- client prompts alice for a password/passphrase to save the chat history
- the client uses the password/passphrase + nonce? to generate a private key and public key pair?
- the public key is saved in the config.json file for alice that @Alex made
- we tell the user to write down the private key?
then when alice wants to view history:
- alice gets authenticated
- alice selects to view chat history on the client
- client prompts alice for the private key
- alice enters the private key that they wrote down
- history is displayed
Then whenever alice is messaging and sees a plaintext, the client encrypts it using the public key and adds it to the db or .txt or whatever, but no one can read it without the private key
Server-side message history security:
Here's what I'm thinking to get the server-side history:
- bob is messaging alice
- bob sends a message encrypted with a shared message key to alice through the server
- alice decrypts the message with the shared message key and can see the plaintext message
- alice re-encrypts the message with an alice-only private key
- alice makes an API call to the server to save this encrypted message on the server
- if alice ever wants to view history, they will make an API request for the server to send the history to alice
- alice decrypts it with an alice-only private key to view it
I think a db like you did could work: query for chat history by using the sender and recipient fields. So if alice wants only history with bob, the query would be like SELECT * FROM chat_history WHERE (sender = 'alice' and recipient = 'bob') OR (sender = 'bob AND recipient = 'alice). For group chats, we could just delimit recipient fields? Like bob, charlie, etc. in the same field or something?Not sure about that
Or a text file would work, but each individual chat would need its own text file I think. Could also do individual dbs but sounds crazier