Keyknox SDK allows developers to communicate with Virgil Keyknox Service to upload, download, and synchronize encrypted sensitive data (private keys) between different devices.
> This README is for Keyknox v1.0.0. Check the v0.3.x branch for Keyknox v0.3.x docs.



Introduction | SDK Features | Installation | Usage Example | Docs | Support
Virgil Security provides an SDK which allows you to communicate with Virgil Keyknox Service.script tag in browser.@virgilsecurity/keyknox.sh
npm install @virgilsecurity/keyknox
`You will also need to install
virgil-crypto and virgil-sdk from npm.
`sh
npm install virgil-crypto virgil-sdk
`
> Note that minimum supported version of virgil-crypto is 4.0.0 and minimum supported version of virgil-sdk is 6.0.0.$3
You will need to add @virgilsecurity/keyknox script.
`html
`You will also need to add
virgil-crypto and virgil-sdk scripts.
`html
`Now you can use global variables
Keyknox, Virgil and VirgilCrypto as namespace objects, containing all of @virgilsecurity/keyknox, virgil-sdk and virgil-crypto exports as properties.Usage Example
To begin using Virgil Keyknox SDK you'll need to initialize SyncKeyStorage class. This class is responsible for synchronization between device storage - IndexedDB in a browser or file system in Node.js - and Keyknox Cloud. In order to initialize SyncKeyStorage class you'll need the following values:
- identity of the user
- accessTokenProvider to provide access token for Virgil services
- keyEntryStorage to store data locally
- privateKey of current device/user
- publicKeys of all devices/users that should have access to data
- virgilCrypto to perform all cryptographic operations`js
const { SyncKeyStorage } = require('@virgilsecurity/keyknox');
const { initCrypto, VirgilCrypto } = require('virgil-crypto');initCrypto().then(() => {
// Identity of the user
const identity = ...;
// Setup Access Token provider to provide access token for Virgil services
// Check https://github.com/VirgilSecurity/virgil-sdk-javascript
const accessTokenProvider = ...;
// Setup Key Entry Storage to store data locally
// Check https://github.com/VirgilSecurity/virgil-sdk-javascript
const keyEntryStorage = ...;
// Public keys of users that should have access to data
const publicKeys = ...;
// Private key of current user
const privateKey = ...;
// An instance of
VirgilCrypto class
const virgilCrypto = new VirgilCrypto(); const syncKeyStorage = SyncKeyStorage.create({
identity,
accessTokenProvider,
keyEntryStorage,
privateKey,
publicKeys,
virgilCrypto,
});
});
`
You can find a complete example of simple client-server application here.$3
If you lost your private key, you are not able to decrypt saved data anymore. So you need to reset your stored data in the Virgil Keyknox Service and start over.
`js
import { KeyknoxClient } from '@virgilsecurity/keyknox';const tokenPromise = accessTokenProvider.getToken({ operation: 'delete' });
const resetPromise = tokenPromise.then(token => new KeyknoxClient().resetValue(token.toString()));
const syncKeyStorage = SyncKeyStorage.create(...);
resetPromise.then(() => syncKeyStorage.sync());
``* Virgil Security Documentation
You can find us on Twitter or send us email support@VirgilSecurity.com.
Also, get extra help from our support team on Slack.