bitcoinjs/bitcoinjs-message

Name: bitcoinjs-message

Owner: BitcoinJS

Description: null

Created: 2015-09-05 04:55:01.0

Updated: 2018-05-20 01:10:46.0

Pushed: 2017-12-26 14:38:15.0

Homepage: null

Size: 25

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

bitcoinjs-message

NPM Package Build Status Dependency status

js-standard-style

Examples
bitcoin = require('bitcoinjs-lib') // v3.x.x
bitcoinMessage = require('bitcoinjs-message')

sign(message, privateKey, compressed[, network.messagePrefix])

Sign a Bitcoin message

keyPair = bitcoin.ECPair.fromWIF('5KYZdUEo39z3FPrtuX2QbbwGnNP5zTd7yyr2SC1j299sBCnWjss')
privateKey = keyPair.d.toBuffer(32)
message = 'This is an example of a signed message.'

signature = bitcoinMessage.sign(message, privateKey, keyPair.compressed)
ole.log(signature.toString('base64'))
> 'G9L5yLFjti0QTHhPyFrZCT1V/MMnBtXKmoiKDZ78NDBjERki6ZTQZdSMCtkgoNmp17By9ItJr8o7ChX0XxY91nk='

verify(message, address, signature[, network.messagePrefix])

Verify a Bitcoin message

address = '1HZwkjkeaoZfTSaJxDw6aKkxp45agDiEzN'
signature = 'HJLQlDWLyb1Ef8bQKEISzFbDAKctIlaqOpGbrk3YVtRsjmC61lpE5ErkPRUFtDKtx98vHFGUWlFhsh3DiW6N0rE'
message = 'This is an example of a signed message.'

ole.log(bitcoinMessage.verify(message, address, signature))
> true
LICENSE MIT

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.