Skip to content

Instantly share code, notes, and snippets.

@wanderer
Created October 11, 2014 01:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wanderer/dd752a4a9c0bfab84f9e to your computer and use it in GitHub Desktop.
Save wanderer/dd752a4a9c0bfab84f9e to your computer and use it in GitHub Desktop.
var ecdsa = require('./');
var emptyMsg = new Buffer([0]);
var privKey = "c85ef7d79691fe79573b1a7064c19c1a9819ebdbd1faaab1a8ec92344438aaf4";
var pubKey = ecdsa.createPublicKey(new Buffer(privKey, 'hex'), true);
var sig = ecdsa.signCompact(new Buffer(privKey, 'hex'), emptyMsg);
console.log('recid: ', sig.recoveryId)
var recoveredPubKey = ecdsa.recoverCompact(emptyMsg, sig.signature, true, sig.recoveryId);
console.log('pub: ', pubKey.toString('hex'))
console.log('recoveredPubKey: ', recoveredPubKey.toString('hex'))
console.log('pass? ', pubKey.toString() === recoveredPubKey.toString())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment