Registering communication key
First of all, let’s check if this key had already been saved into the Ylide Registry:
const pk = await reader.extractPublicKeyFromAddress(account.address);
if (!pk) {
// There is no public key connected to this address in the Registry
} else {
if (
pk.bytes.length === key.publicKey.length
&& pk.bytes.every((e, idx) => e === key.publicKey[idx])
) {
// This key connected to this address in the Registry
} else {
// Another key connected to this address in the Registry
}
}
If user’s public key is not in the Registry - you should register it:
await wallet.attachPublicKey(account.address, key.publicKey);
Now, user can send and receive messages using Ylide Protocol.
Last modified 6mo ago