cronos icon indicating copy to clipboard operation
cronos copied to clipboard

Problem: no e2e encrypted messaging support

Open yihuang opened this issue 1 year ago • 4 comments

add commands for users to generate a separate keypair for asymmetric encryption, the pubkey is published to on-chain state for encryption, private key is saved in local keyring for decryption.

Libraries/Tools

We need something that can be used programmatically in golang.

  • age seems to be a well-maintained library and tool for asymmetric encryption.

New Commands

  • cronosd gen-encryption-key [name] This command will generate a new key for age encryption, the private key is saved in the keyring, and the public key is outputted.
  • cronosd set-encryption-key [pub-key] --from user-address The tx should be signed by the user, and the encryption key is stored associated with the user address.
  • cronosd encrypt [recipients] [message] This command will load the associated encryption keys for one or many recipients, and encrypt the message to all of them.

User Flow

  1. User generates a new keypair locally using age-keygen:

    $ age-keygen -o privatekey.txt
    Public key: [PUBLIC KEY]
    
  2. User can publish a [PUBLIC KEY] to chain:

    $ cronosd set-encryption-key [PUBLIC KEY]
    
  3. User save the private key in the keyring:

    $ cronosd keyring-add-raw "encryptionkey" "$(cat privatekey.txt)"
    
  4. Third party then can encrypt private messages to multiple users:

    $ cronosd encrypt [recipients] [MESSAGE]
    

    The encrypted message can be published anywhere, depending on the application.

Tracking

  • [x] #1407 basic e2ee module structure
  • [x] #1413
  • [x] #1411
  • [x] #1409
  • [ ] #1415

yihuang avatar Apr 26 '24 02:04 yihuang