CipherOptInterface

CipherOptInterface

Provides encryption methods for committing ImmutableData

Constructor

new CipherOptInterface()

Source:

Methods

newAsymmetric(pubEncKey) → {Promises.<CipherOpt>}

Create a new asymmetric cipher for the given public encryption key

Parameters:
Name Type Description
pubEncKey PubEncKey
Source:
Throws:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
    // For this example you're encrypting data with our own public encryption key,
    // which only you will be able to deciper, however,
    // the use case is for encrypting with the intended recipient's public encryption key.
    const pubEncKey = await app.crypto.getAppPubEncKey();
    const cipherOpt = await app.cipherOpt.newAsymmetric(pubEncKey);
    const immdWriter = await app.immutableData.create();
    const data = 'Data only decipherable by the holder of the private encryption key
    which is paired to the public encryption key supplied to asymmetric cipher.';
    await idWriter.write(data);
    const idAddress = await idWriter.close(cipherOpt);
};

newPlainText() → {Promises.<CipherOpt>}

Create a plaintext cipher

Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
    const cipherOpt = await app.cipherOpt.newPlainText();
    const immdWriter = await app.immutableData.create();
    await idWriter.write('<public file buffer data>');
    const idAddress = await idWriter.close(cipherOpt);
};

newSymmetric() → {Promises.<CipherOpt>}

Create a new symmetric cipher

Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
    const cipherOpt = await app.cipherOpt.newSymmetric();
    const immdWriter = await app.immutableData.create();
    await idWriter.write('Data for my eyes only.');
    const idAddress = await idWriter.close(cipherOpt);
};