EncKeyPair

EncKeyPair

Asymmetric encryption keypair

Constructor

new EncKeyPair()

Source:

Members

pubEncKey

Get the public encryption key instance of this keypair

Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
  try {
    const encKeyPair = await app.crypto.generateEncKeyPair();
    const pubEncKey = encKeyPair.pubEncKey;
  } catch (err) {
    throw err;
  }
};

secEncKey

Get the secret encryption key instance of this keypair

Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
  try {
    const encKeyPair = await app.crypto.generateEncKeyPair();
    const secEncKey = encKeyPair.secEncKey;
  } catch (err) {
    throw err;
  }
};

Methods

decryptSealed(cipher) → {Promise.<Buffer>}

Decrypt the input using this generated encryption key pair. Only recipient will be able to decrypt data. Read more about sealed boxes.

Parameters:
Name Type Description
cipher String | Buffer

Encrypted data

Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
    const cipher = <Encrypted data as sealed box>;
    try {
       const encKeyPair = await app.crypto.generateEncKeyPair();
      const decryptedData = await encKeyPair.decryptSealed(cipher);
    } catch(err) {
      throw err;
    }
};