In creating an email flow that maintains PRIVACY and SECURITY whilst also being convenient to use, the following principles were observed:
- Keypair must be generated client-side
- Keypair must be protected by a password
- There must be protection from keyloggers
- It must be possible to change the password
- It must remain possible to work offline
- Network traffic must not contain identifying metadata
All of the above is achieved using a high level flow as follows:
1. Generate temporary key pair for secure server communication
2. Validate email using a 6 digit code
3. Provide some server side entropy to client
4. Combine entropy + complex user password to encrypt the final keypair
5. Store the encrypted keypair on the server
The password is only used to encrypt the key and is never stored or sent anywhere. Hence, the server cannot decrypt the backup. All key signing / encryption operations happen on client side using [private class properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_properties).
Note over DB: USER entry#58;<br>#128274;user.id=uid()<br>user.email=session.email<br>user.pubkey=""<br>user.activated=false<br>user.created_at=now()<br>user.bkp=""<br>user.entropy=uid()
Note over W: Nostr Keypair Generated <br>& Encrypted inside a <br> PRIVATE METHOD,<br>using password + entropy.<br> Password variable is not <br>stored, sent or printed <br> anywhere. Temporary <br>variables are destroyed.
W->>D: Request account activation
Note right of W: Event uses PoW and<br> encrypts both PUBKEY<br> and the already-<br>encrypted BACKUP<br> to the DVM pubkey
D -x DB: Ensure event pubkey <br> in SESSION table
D->>DB: Update Account
Note over DB: user.activated=true <br>user.pubkey=$pubkey<br>user.bkp=$backup
D->>W: Account activated
Note left of D: Payload is an empty string or<br> an encrypted (and detailed)<br> error message
W->>U: User is automatically logged in
Note over W: Ephemeral key is destroyed<br>Default relay list applied