kbpgp.js

KeyManager

The API

Given the KeyManager class (kbpgp.KeyManager), and an instance, alice, you can access the following functions.

First, options notes

  1. When opts is expected as an argument, it is a dictionary. You may pass the empty dictionary, {}
  2. In any kbpgp function, you may set opts.asp as an ASP object to monitor progress and optionally cancel it. See the examples for more info.
KeyManager.generate(opts, cb)
KeyManager.generate_rsa(opts, cb)
KeyManager.generate_ecc(opts, cb)
calls back with err, key_manager (see examples)
KeyManager.import_from_armored_pgp(opts, cb)
calls back with err, key_manager. If you're importing a private key, you'll want to check if it has a passphrase and unlock it. (see examples)
alice.has_pgp_private()
returns true if alice's key_manager contains a private key
alice.is_pgp_locked()
returns true if alice's private key is passphrase-protected and locked
alice.unlock_pgp(opts, cb)
unlocks alice's private key if it's locked; calls back with any error (see examples)
opts.passphrase: a string with alice's private key passphrase
alice.check_pgp_public_eq(chuck)
returns true if alice and another KeyManager instance (chuck) have identical primary and sub keys
alice.merge_pgp_private(opts, cb)
if alice has been loaded without a private key, this function lets you merge her private key in, after the fact. Once merged, if it is password protected, you'll want to (a) recognize this with alice.is_pgp_locked() and then (b) unlock it with alice.unlock_pgp_key()
opts.armored: a string with her private key, armored
alice.export_pgp_public(opts, cb)
calls back with err, str. This generates the standard PGP armored format of alice's public key. (see example)
alice.export_pgp_private(opts, cb)
calls back with err, str. This generates the standard PGP armored format of alice's key, protected with a passphrase. (see example)
opts.passphrase: a passphrase to protect they key

We're just getting started with this tutorial and examples. Hit us up on github if anything is missing.