title: Use cryto.generateKeyPair with jsonwebtoken
body: <p>In node 10 there is a new method <code>generateKeyPair</code>, that I am using like this:</p>
  
  <pre><code>const { publicKey, privateKey } = crypto.generateKeyPairSync("rsa", {
    modulusLength: 4096,
    publicKeyEncoding: {
      type: "spki",
      format: "pem"
    },
    privateKeyEncoding: {
      type: "pkcs8",
      format: "pem",
      cipher: "aes-256-cbc",
      passphrase: "top secret"
    }
  });
  </code></pre>
  
  <p>I am now trying to create a jwt from <code>jsonwebtoken</code> using this privateKey:</p>
  
  <pre><code>function createJWT(id) {
    return new Promise((resolve, reject) =&gt; {
      jwt.sign(
        { id: id + "" },
        privateKey,
        { algorithm: "RS256", expiresIn: "2h" },
        (err, token) =&gt; {
          if (err) reject(err);
          resolve(token);
        }
      );
    });
  }
  </code></pre>
  
  <p>Unfortunately, this doesn't seem to work:</p>
  
  <pre><code>Error: error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt
      at Sign.sign (internal/crypto/sig.js:83:26)
      at Object.sign (/Users/francoisbillioud/Documents/Tests/SimpleQL/node_modules/jwa/index.js:76:45)
      at jwsSign (/Users/francoisbillioud/Documents/Tests/SimpleQL/node_modules/jws/lib/sign-stream.js:32:24)
      at SignStream.sign (/Users/francoisbillioud/Documents/Tests/SimpleQL/node_modules/jws/lib/sign-stream.js:58:21)
      at SignStream.&lt;anonymous&gt; (/Users/francoisbillioud/Documents/Tests/SimpleQL/node_modules/jws/lib/sign-stream.js:46:12)
      at Object.onceWrapper (events.js:273:13)
      at DataStream.emit (events.js:182:13)
      at DataStream.&lt;anonymous&gt; (/Users/francoisbillioud/Documents/Tests/SimpleQL/node_modules/jws/lib/data-stream.js:32:12)
      at process._tickCallback (internal/process/next_tick.js:61:11)
  </code></pre>
  
  <p>You can have a look <a href="https://codesandbox.io/s/4zr98zn884" rel="nofollow noreferrer">here</a>.</p>
  
  <p>What am I missing?</p>