Skip to content

Instantly share code, notes, and snippets.

@mozzius
mozzius / ecdsa.js
Last active February 21, 2018 11:27
Implementation of secp256k1 in node.js
const crypto = require('crypto')
const bigInt = require('big-integer')
// we need big-integer as the numbers that we're dealing with are too big for JS' default numbers
function sha256(data) {
// creates a sha256 hash, updates it with data, and turns it into a bigint
var hash = crypto.createHash('sha256').update(data).digest('hex')
return bigInt(hash,16)
}