Skip to content

Instantly share code, notes, and snippets.

@Leask
Created December 6, 2019 02:44
Show Gist options
  • Save Leask/c9f01cda1999312e89013d286342a80c to your computer and use it in GitHub Desktop.
Save Leask/c9f01cda1999312e89013d286342a80c to your computer and use it in GitHub Desktop.
const { randomBytes } = require('crypto')
const secp256k1 = require('secp256k1')
// or require('secp256k1/elliptic')
// if you want to use pure js implementation in node
// generate message to sign
const msg = randomBytes(32)
// generate privKey
let privKey
do {
privKey = randomBytes(32)
} while (!secp256k1.privateKeyVerify(privKey))
// output
console.log(privKey.toString('hex'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment