bitcore-message-btcp/README.md

50 lines
1.8 KiB
Markdown
Raw Permalink Normal View History

<img src="http://bitcore.io/css/images/module-message.png" alt="bitcore message" height="35">
2018-03-04 13:04:05 -08:00
# btcp Message Verification and Signing for Bitcore
2015-02-05 06:35:54 -08:00
2015-02-04 09:09:58 -08:00
[![NPM Package](https://img.shields.io/npm/v/bitcore-message.svg?style=flat-square)](https://www.npmjs.org/package/bitcore-message)
[![Build Status](https://img.shields.io/travis/bitpay/bitcore-message.svg?branch=master&style=flat-square)](https://travis-ci.org/bitpay/bitcore-message)
[![Coverage Status](https://img.shields.io/coveralls/bitpay/bitcore-message.svg?style=flat-square)](https://coveralls.io/r/bitpay/bitcore-message?branch=master)
bitcore-message adds support for verifying and signing bitcoin messages in [Node.js](http://nodejs.org/) and web browsers.
See [the main bitcore repo](https://github.com/bitpay/bitcore) for more information.
## Getting Started
```sh
2018-03-04 13:04:05 -08:00
npm install bitcore-message-btcp
2015-02-04 09:09:58 -08:00
```
```sh
2018-03-04 13:04:05 -08:00
bower install bitcore-message-btcp
2015-02-04 09:09:58 -08:00
```
To sign a message:
```javascript
2018-03-04 13:04:05 -08:00
var bitcore = require('bitcore-lib-btcp');
var Message = require('bitcore-message-btcp');
var privateKey = bitcore.PrivateKey.fromWIF('cPBn5A4ikZvBTQ8D7NnvHZYCAxzDZ5Z2TSGW2LkyPiLxqYaJPBW4');
2015-02-04 09:09:58 -08:00
var signature = Message('hello, world').sign(privateKey);
```
To verify a message:
```javascript
var address = 'n1ZCYg9YXtB5XCZazLxSmPDa8iwJRZHhGx';
2015-02-04 10:48:45 -08:00
var signature = 'H/DIn8uA1scAuKLlCx+/9LnAcJtwQQ0PmcPrJUq90aboLv3fH5fFvY+vmbfOSFEtGarznYli6ShPr9RXwY9UrIY=';
var verified = Message('hello, world').verify(address, signature);
2015-02-04 09:09:58 -08:00
```
## Contributing
2015-02-04 14:09:11 -08:00
See [CONTRIBUTING.md](https://github.com/bitpay/bitcore/blob/master/CONTRIBUTING.md) on the main bitcore repo for information about how to contribute.
2015-02-04 09:09:58 -08:00
## License
Code released under [the MIT license](https://github.com/bitpay/bitcore/blob/master/LICENSE).
Copyright 2013-2015 BitPay, Inc. Bitcore is a trademark maintained by BitPay, Inc.