User Keys
Last updated
Last updated
Using our KeyPair
class, create your users' keys, and use them for encrypting and decrypting messages.
Protico is a decentralized communication protocol, and as such, these keys can be used by multiple dApps. The first step is to check if the user already possesses a key pair, by checking their .
Assuming you already have the user's , you can quickly check if they have a public key associated with their account. If this is the case, a key pair was already generated, if not, a new one needs to be created.
Note that changing an existing key pair will render all the previous messages inaccessible to the user.
If the keypair already exists, it can be recovered from its mnemonics as follows:
It has to be noted that this key pair is only used for encryption and decryption purposes. By importing his keys into a dApp, the user signifies his trust in the dApp to process encryption and decryption operations on their behalf.
If there is no existing keypair for the user, create a new one:
Then, update the user's Basic Profile to include the new public key:
Make sure the user saves the mnemonic
for later recovery or use in another dApp, and to safely store the messaging private key on your dApp side.