coinmsg
Message signing for Bitcoin and other cryptocurrencies
Last updated 6 years ago by nadav .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install coinmsg 
SYNC missed versions from official npm registry.

coinmsg

Message signing for Bitcoin and other cryptocurrencies.

Install

npm install --save coinmsg

Example

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

API

Methods

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.

Other cryptocurrencies

coinmsg({ coinname: ..., curve: ..., magicPrefix: ... })

Returns an object with sign(), verify() and format() for the provided options.

curve is optional and defaults to secp256k1

Test

$ git clone https://github.com/cryptocoinjs/coinmsg.git && cd coinmsg
$ npm install && npm test

License

MIT

Credits

Based on the bitcoinjs-lib implementation.

Current Tags

  • 0.1.3                                ...           latest (6 years ago)

3 Versions

  • 0.1.3                                ...           6 years ago
  • 0.1.2                                ...           6 years ago
  • 0.1.1                                ...           6 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (5)
Dev Dependencies (1)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |