title: Create EC keys using Node.js
body: <p>I'm using Node.js and trying to mimic the functionality of the following openssl command to generate a public key:</p>
  
  <pre><code>$&gt; openssl ecparam -name prime256v1 -genkey -noout -out keys
  $&gt; openssl ec -in keys -pubout -out pubkey
  </code></pre>
  
  <p>The closest I have is:</p>
  
  <pre><code>var ec = crypto.createECDH('prime256v1');
  var pub = ec.generateKeys("base64");
  </code></pre>
  
  <p>But this key is far shorter and doesn't work. Any ideas how I could mimic the functionality exactly?</p>