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 message
with privkey
and return the signature as a Buffer
.
compressed
defaults to true.
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
.
Return a "BEGIN BITCOIN SIGNED MESSAGE ..." formatted message.
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.