I developing an encrypted messaging for ZeroNet (aP2P file-based network, website: zeronet.io) and would like to have some guidelines if any of this could work.
My first idea:
- In ZeroNet every user has his/her own files signed by ECC this ensures the messages authenticity.
- When Bob visits the site first time then a new (Bitcoin BIP32 based) public key will be generated, written to his file, signed and published to the network.
- If Alice want to message to Bob then reads the Bob's public key, creates a new message using
ecc_encrypt_using_bob_pubkey("ZNE1" + generated_aes256key + generated_aes256iv + aesencrypted_text), puts it to her file, sign and publish to network.
- If a new file is published to the network then Bob checks the added messages in it and try to decode them using his ECC privatekey.
To make privacy better the sender does not specify the messages recipient, so have to check every messages added to the network. The messages are signed with one ECC private key and encrypted with an another one.
My other idea:
- If Alice wants to send a message to Bob, then she puts
ecc_encrypt_using_bob_pubkey("ZNE1" + generated_aes256key + generated_aes256iv)encrypted shared secret to her file. (or better to use per-message, unencrypted IV?)
- Then from now Alice will use this shared secret to encrypt messages to Bob (random prefix + protocol id + message)
- If a new file is published then Bob checks encrypted shared secrets in it and see if he able to decrypt any of them.
- If he successfully decrypt a shared AES secret from Alice file then he checks Alice's encrypted messages and decrypt the messages in Alice file.
The pros of second idea: - Shorter messages - Don't have to store the messages twice (one for other user, one for our sent folder) - AES provides 100x faster message checking.
The cons of second idea: - If the AES key is broken then all messages can be decrypted (applies both if privkey broken). - Anyone able to see if you added a new shared secret (start messaging with new people)
Thanks for any suggestions!