Methods
generateEncKeyPair() → {Promise.<EncKeyPair>}
Generate a new asymmetric encryption key pair
- Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
try {
const encKeyPair = await app.crypto.generateEncKeyPair();
} catch (err) {
throw err;
}
};
generateEncKeyPairFromRaw() → {Promise.<EncKeyPair>}
Generate asymmetric encryption key pair instance from raw keys
- Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
try {
let encKeyPair = await app.crypto.generateEncKeyPair();
const pubEncKey = encKeyPair.pubEncKey;
const secEncKey = encKeyPair.secEncKey;
const rawPubEncKey = await pubEncKey.getRaw();
const rawSecEncKey = await secEncKey.getRaw();
encKeyPair = await app.crypto.generateEncKeyPairFromRaw(
rawPubEncKey.buffer,
rawSecEncKey.buffer
);
} catch (err) {
throw err;
}
};
generateNonce() → {Promise.<Nonce>}
Generate a nonce that can be used when creating private MutableData
- Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
try {
const nonce = await app.crypto.generateNonce();
} catch (err) {
throw err;
}
};
generateSignKeyPair() → {Promise.<SignKeyPair>}
Generate a new sign key pair
- Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
try {
const signKeyPair = await app.crypto.generateSignKeyPair();
} catch (err) {
throw err;
}
};
generateSignKeyPairFromRaw() → {Promise.<SignKeyPair>}
Generate sign key pair from raw keys
- Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
try {
let signKeyPair = await app.crypto.generateSignKeyPair();
const pubSignKey = signKeyPair.pubSignKey;
const secSignKey = signKeyPair.secSignKey;
const rawPubSignKey = await pubSignKey.getRaw();
const rawSecSignKey = await secSignKey.getRaw();
signKeyPair = await app.crypto.generateSignKeyPairFromRaw(
rawPubSignKey.buffer,
rawSecSignKey.buffer
);
} catch (err) {
throw err;
}
};
getAppPubEncKey() → {Promise.<PubEncKey>}
Get current app's public encryption key
- Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
try {
const pubEncKey = await app.crypto.getAppPubEncKey();
} catch (err) {
throw err;
}
};
getAppPubSignKey() → {Promise.<PubSignKey>}
Get current app's public signing key
- Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
try {
const pubSignKey = await app.crypto.getAppPubSignKey();
} catch (err) {
throw err;
}
};
pubEncKeyFromRaw(rawPubEncKey) → {Promise.<PubEncKey>}
Generates a public encryption key instance from raw buffer
Parameters:
Name | Type | Description |
---|---|---|
rawPubEncKey |
Buffer |
- Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
try {
const encKeyPair = await app.crypto.generateEncKeyPair();
let pubEncKey = encKeyPair.pubEncKey;
const rawPubEncKey = await pubEncKey.getRaw();
pubEncKey = await app.crypto.pubEncKeyFromRaw(rawPubEncKey.buffer);
} catch (err) {
throw err;
}
};
pubSignKeyFromRaw(rawPubSignKey) → {Promise.<PubSignKey>}
Generates a public sign key instance from a raw buffer
Parameters:
Name | Type | Description |
---|---|---|
rawPubSignKey |
Buffer |
- Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
try {
const signKeyPair = await app.crypto.generateSignKeyPair();
let pubSignKey = signKeyPair.pubSignKey;
const rawPubSignKey = await pubSignKey.getRaw();
pubSignKey = await app.crypto.pubSignKeyFromRaw(rawPubSignKey.buffer);
} catch (err) {
throw err;
}
};
secEncKeyFromRaw(raw) → {Promise.<SecEncKey>}
Generates a secret encryption key instance from raw buffer
Parameters:
Name | Type | Description |
---|---|---|
raw |
Buffer |
secret encryption key raw bytes as string |
- Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
try {
const encKeyPair = await app.crypto.generateEncKeyPair();
let secEncKey = encKeyPair.secEncKey;
const rawSecEncKey = await secEncKey.getRaw();
secEncKey = await app.crypto.secEncKeyFromRaw(rawSecEncKey.buffer);
} catch (err) {
throw err;
}
};
secSignKeyFromRaw(rawSecSignKey) → {Promise.<SecSignKey>}
Generates a secret sign key from a raw buffer
Parameters:
Name | Type | Description |
---|---|---|
rawSecSignKey |
Buffer |
- Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
try {
const signKeyPair = await app.crypto.generateSignKeyPair();
let secSignKey = signKeyPair.secSignKey;
const rawSecSignKey = await secSignKey.getRaw();
secSignKey = await app.crypto.secSignKeyFromRaw(rawSecSignKey.buffer);
} catch (err) {
throw err;
}
};
sha3Hash() → {Promise.<Buffer>}
Hash the given input with SHA3 Hash
- Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
try {
const hashedString = await app.crypto.sha3Hash('1010101010101')
} catch (err) {
throw err;
}
};