Before you can perform any crypto, you need a KeyManager.

A KeyManager contains a public key and possibly the secret key and subkeys for a given person. Once you have a KeyManager instance, you can perform actions with the keys inside. For a sign-and-encrypt action, you'll need two KeyManagers: one containing the private key (for the signer), and one containing the public key (for the recipient).

For example, assuming we have two KeyManager instances, alice and chuck, we might perform an encryption.

params =
  encrypt_for:    chuck
  sign_with:      alice
  msg:            "Hey Chuck - my bitcoin address is 1alice12345234..."

kbpgp.box params, (err, result_string, result_buffer) ->
  console.log err, result_string, result_buffer

kbpgp's box function performs all the work. Note that it calls back with both a string and a Buffer representation. The Buffer is either a Node.js Buffer or, a browser-friendly object with similar features.

Pretty simple, right? So, how do you get a KeyManager? There are 2 ways:

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