Message signing for Bitcoin and other cryptocurrencies.
npm install --save coinmsg
var coinmsg = require('coinmsg'),
privkey = new Buffer('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'hex'),
addr = '1F3sAm6ZtwLAUnj7d38pGFxtP3RVEvtsbV',
message = 'Hello, World!'
var sig = coinmsg.sign(privkey, message) // => Buffer
coinmsg.verify(addr, sig, message) // => true
// With other cryptocurrencies:
var coinmsg = require('coinmsg')({
coinname: 'DOGECOIN',
curve: 'secp256k1', // optional, defaults to secp256k1
magicPrefix: '\x19Dogecoin Signed Message:\n'
})
// ... and use coinmsg as above
sign(privkey, message[, compressed])Sign message with privkey and return the signature as a Buffer.
compressed defaults to true.
verify(address|pubkey, sig, message)Verify that sig is valid signature for the message signed by address|pubkey.
sig can be provided as a Buffer or base64 string.
The first argument, address|pubkey, can either be an address provided as a String,
or a public key provided as a Buffer.
format(addr, sig, message)Return a "BEGIN BITCOIN SIGNED MESSAGE ..." formatted message.
coinmsg({ coinname: ..., curve: ..., magicPrefix: ... })Returns an object with sign(), verify() and format() for the
provided options.
curve is optional and defaults to secp256k1
$ git clone https://github.com/cryptocoinjs/coinmsg.git && cd coinmsg
$ npm install && npm test
MIT
Based on the bitcoinjs-lib implementation.