Skip to content

Latest commit

 

History

History
54 lines (36 loc) · 1.64 KB

README.md

File metadata and controls

54 lines (36 loc) · 1.64 KB

Flux Message Verification and Signing for Bitcore

bitcore-message adds support for verifying and signing Flux messages in Node.js 24 or newer.

See the main bitcore repo for more information.

Getting Started

npm install @runonflux/bitcore-message

To sign a message:

var bitcore = require('@runonflux/bitcore-lib');
var Message = require('@runonflux/bitcore-message');

var privateKey = bitcore.PrivateKey.fromWIF('cPBn5A4ikZvBTQ8D7NnvHZYCAxzDZ5Z2TSGW2LkyPiLxqYaJPBW4');
var signature = Message('hello, world').sign(privateKey);

To verify a message:

var address = 'n1ZCYg9YXtB5XCZazLxSmPDa8iwJRZHhGx';
var signature = 'H/DIn8uA1scAuKLlCx+/9LnAcJtwQQ0PmcPrJUq90aboLv3fH5fFvY+vmbfOSFEtGarznYli6ShPr9RXwY9UrIY=';
var verified = Message('hello, world').verify(address, signature);

Tests

Requires Node.js 24 or later.

npm test

npm test runs every file under test/ in its own mocha process and checks each outcome against test/inherited-failures.json, the inherited tests that fail at runonflux/bitcore-message ec2fb0a with bitcore-lib 8f5453f. test/differential.js checks this package against bitcore-message ec2fb0a with bitcore-lib 8f5453f, installed as the devDependency bitcore-message-ec2fb0a: magic hashes, signatures byte for byte with the random nonce fixed, cross verification, and rejection of wrong addresses and malformed signatures.

License

Code released under the MIT license.

Copyright 2013-2015 BitPay, Inc. Bitcore is a trademark maintained by BitPay, Inc.