Encrypt/Decrypt

Panda Wallet can encrypt and decrypt data using your identity private keys. Additionally, it can encrypt or decrypt using any of your Tagged Derivation Keys™

If encoding is not passed it will default to utf8

Encrypting and decrypting will default to use your identity keys, however, if a tag is passed, it will use those keys to encrypt/decrypt.

Encrypt

{
  message: string;
  pubKeys: string[];
  encoding?: 'utf8' | 'hex' | 'base64';
  tag?: DerivationTag;
}

In practice:

const wallet = initProvider(); // see "Detecting the Provider"

try {
    const toEncrypt = { 
        message: "Panda Wallet Is Awesome!",
        pubKeys: [
            "0350a6af311b5eb69a666d241e1f0781b71352de01d54665fcb6aa1eac32a05515", 
            "035077b656031c6e197e611c34f83970e5f304ccfce68d4264f34ae1e33d14e8ee"
        ];
    };
    const encryptedMessages = await panda.encrypt(toEncrypt);
    console.log(encryptedMessages);
// Returns encrypted base64 strings
// [
//    "QklFMQN3CoXGAWxjXeufmMePMp4yW6Au+mMHyH07k9h9Pi+cfP4Acz41OHjD5dgXUCshWJAZqumIYnJdVfAqFvGgHI8tHIulyHgSdeYL/LNTOIWeVWCctQEXcKGSgGX1nxJSPSA=", 
//    "QklFMQN3CoXGAWxjXeufmMePMp4yW6Au+mMHyH07k9h9Pi+cfO1DjrAxgZdybMjqsvBLiIEtDXFzrvP/195I8mbxVLPVABgHfHlV6bMbY/9XwSLoeH+Sw9CZqB7khsB+sTrrYrs="
// ]
} catch (err) {
    console.log(err);
}

Decrypt

{
  messages: string[]; // base64 strings
  tag?: DerivationTag;
}

In practice:

const wallet = initProvider(); // see "Detecting the Provider"

try {
    const toDecrypt = {
        messages: [
            "QklFMQN3CoXGAWxjXeufmMePMp4yW6Au+mMHyH07k9h9Pi+cfKQw8JWtuS5IdU03P4+Q6YT3nQP9Sp4Z7AFSk0k+2PSYHU20ojBChixkNaOeO+omkoG7U3l2Iikl7U3bbbcwejw="
         ];
     };
    const decryptedMessages = await panda.decrypt(toDecrypt);
    console.log(encryptedMessages);
    // Returns decrypted base64 strings
    // ['UGFuZGEgV2FsbGV0IElzIEF3ZXNvbWUh']
} catch (err) {
    console.log(err);
}

Last updated