rename Message to message

This commit is contained in:
Daniel Cousens 2014-10-18 21:54:13 +11:00
parent 5f8484645d
commit bdb372da7d
3 changed files with 13 additions and 13 deletions

View file

@ -7,7 +7,7 @@ module.exports = {
ECKey: require('./eckey'),
ECPubKey: require('./ecpubkey'),
ECSignature: require('./ecsignature'),
Message: require('./message'),
message: require('./message'),
opcodes: require('./opcodes'),
HDNode: require('./hdnode'),
Script: require('./script'),

View file

@ -9,7 +9,7 @@ describe('bitcoinjs-lib (advanced)', function () {
var key = bitcoin.ECKey.fromWIF('5KYZdUEo39z3FPrtuX2QbbwGnNP5zTd7yyr2SC1j299sBCnWjss')
var message = 'This is an example of a signed message.'
var signature = bitcoin.Message.sign(key, message)
var signature = bitcoin.message.sign(key, message)
assert.equal(signature.toString('base64'), 'G9L5yLFjti0QTHhPyFrZCT1V/MMnBtXKmoiKDZ78NDBjERki6ZTQZdSMCtkgoNmp17By9ItJr8o7ChX0XxY91nk=')
})
@ -18,7 +18,7 @@ describe('bitcoinjs-lib (advanced)', function () {
var signature = 'HJLQlDWLyb1Ef8bQKEISzFbDAKctIlaqOpGbrk3YVtRsjmC61lpE5ErkPRUFtDKtx98vHFGUWlFhsh3DiW6N0rE'
var message = 'This is an example of a signed message.'
assert(bitcoin.Message.verify(address, signature, message))
assert(bitcoin.message.verify(address, signature, message))
})
it('can create an OP_RETURN transaction', function (done) {

View file

@ -1,21 +1,21 @@
/* global describe, it */
var assert = require('assert')
var message = require('../src/message')
var networks = require('../src/networks')
var Address = require('../src/address')
var BigInteger = require('bigi')
var ECKey = require('../src/eckey')
var Message = require('../src/message')
var fixtures = require('./fixtures/message.json')
describe('Message', function () {
describe('message', function () {
describe('magicHash', function () {
fixtures.valid.magicHash.forEach(function (f) {
it('produces the correct magicHash for "' + f.message + '" (' + f.network + ')', function () {
it('produces the correct magicHash for \"' + f.message + '\" (' + f.network + ')', function () {
var network = networks[f.network]
var actual = Message.magicHash(f.message, network)
var actual = message.magicHash(f.message, network)
assert.equal(actual.toString('hex'), f.magicHash)
})
@ -28,24 +28,24 @@ describe('Message', function () {
var network = networks[f.network]
var address = Address.fromBase58Check(f.address)
assert(Message.verify(address, f.signature, f.message, network))
assert(message.verify(address, f.signature, f.message, network))
})
fixtures.valid.verify.forEach(function (f) {
it('verifies a valid signature for "' + f.message + '" (' + f.network + ')', function () {
var network = networks[f.network]
assert(Message.verify(f.address, f.signature, f.message, network))
assert(message.verify(f.address, f.signature, f.message, network))
if (f.compressed) {
assert(Message.verify(f.compressed.address, f.compressed.signature, f.message, network))
assert(message.verify(f.compressed.address, f.compressed.signature, f.message, network))
}
})
})
fixtures.invalid.verify.forEach(function (f) {
it(f.description, function () {
assert(!Message.verify(f.address, f.signature, f.message))
assert(!message.verify(f.address, f.signature, f.message))
})
})
})
@ -56,12 +56,12 @@ describe('Message', function () {
var network = networks[f.network]
var privKey = new ECKey(new BigInteger(f.d), false)
var signature = Message.sign(privKey, f.message, network)
var signature = message.sign(privKey, f.message, network)
assert.equal(signature.toString('base64'), f.signature)
if (f.compressed) {
var compressedPrivKey = new ECKey(new BigInteger(f.d))
var compressedSignature = Message.sign(compressedPrivKey, f.message)
var compressedSignature = message.sign(compressedPrivKey, f.message)
assert.equal(compressedSignature.toString('base64'), f.compressed.signature)
}