Skip to content

Instantly share code, notes, and snippets.

@JackTanRoo
Created August 24, 2014 06:40
Show Gist options
  • Save JackTanRoo/1e77dc0371a1b0ff45b9 to your computer and use it in GitHub Desktop.
Save JackTanRoo/1e77dc0371a1b0ff45b9 to your computer and use it in GitHub Desktop.
how should i generate the array of random numbers in Node, without access to window.crypto?
//helloblock tutorial
var privateKey = "cND8kTK2zSJf1bTqaz5nZ2Pdqtv43kQNcwJ1Dp5XWtbRokJNS97N"
var ecKey = new bitcoin.ECKey(privateKey)
// .ECKey() now either takes an array of randomly generated numbers or a bigDecimal as parameter
// from bitcoinjs tutorial
var randArr = new Uint8Array(32)
window.crypto.getRandomValues(randArr) //
var privateKeyBytes = []
for (var i = 0; i < randArr.length; ++i)
privateKeyBytes[i] = randArr[i]
var ecKey = new bitcoin.ECKey(privateKeyBytes) //So question: how should i generate the array of random numbers in Node, without access to window.crypto?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment