Search code examples
gnupgpgpopenpgp

using kbpgp • how do I specify which key-pair to encrypt_with when calling kbpgp.box(params,cb)


var params = {
  msg:         "If you see me, I am working.",
  encrypt_for: bob,
  sign_with: alice
};

// where bob and alice are KeyManager objects with public and unlocked private keys

kbpgp.box(params, function(err, result_string, result_buffer) {
  console.log('\nencrypted message\n===========')
  console.log(result_string)
})

In this snippet I can specify which keypair I am using to sign.

How do I specify which KeyManager object I want to encrypt the message with, but not sign?

Is there an encrypt_with option I am missing?


Solution

  • That's the encrypt_for parameter, which it expects to be a keymanager wrapping the recipient's public key.

    The correct comment above the kbpgp.box() call would be:

    // where bob and alice are KeyManager objects with public and unlocked private keys, respectively

    In order to sign, you need an unlocked private key. But in order to encrypt, you simply need a public key.