|
|
@ -1,9 +1,11 @@ |
|
|
|
'use strict'; |
|
|
|
|
|
|
|
var ECDSA = require('./ecdsa'); |
|
|
|
var Keypair = require('./keypair'); |
|
|
|
var BufferWriter = require('./bufferwriter'); |
|
|
|
var Hash = require('./hash'); |
|
|
|
var Address = require('./address'); |
|
|
|
var Signature = require('./signature'); |
|
|
|
var Keypair = require('../keypair'); |
|
|
|
var BufferWriter = require('../protocol/bufferwriter'); |
|
|
|
var Hash = require('../crypto/hash'); |
|
|
|
var Address = require('../address'); |
|
|
|
var Signature = require('../signature'); |
|
|
|
|
|
|
|
var Message = function Message(obj) { |
|
|
|
if (!(this instanceof Message)) |
|
|
@ -39,7 +41,10 @@ Message.magicHash = function(messagebuf) { |
|
|
|
}; |
|
|
|
|
|
|
|
Message.sign = function(messagebuf, keypair) { |
|
|
|
var m = Message({messagebuf: messagebuf, keypair: keypair}); |
|
|
|
var m = Message({ |
|
|
|
messagebuf: messagebuf, |
|
|
|
keypair: keypair |
|
|
|
}); |
|
|
|
m.sign(); |
|
|
|
var sigbuf = m.sig.toCompact(); |
|
|
|
var sigstr = sigbuf.toString('base64'); |
|
|
@ -58,7 +63,10 @@ Message.verify = function(messagebuf, sigstr, address) { |
|
|
|
|
|
|
|
Message.prototype.sign = function() { |
|
|
|
var hashbuf = Message.magicHash(this.messagebuf); |
|
|
|
var ecdsa = ECDSA({hashbuf: hashbuf, keypair: this.keypair}); |
|
|
|
var ecdsa = ECDSA({ |
|
|
|
hashbuf: hashbuf, |
|
|
|
keypair: this.keypair |
|
|
|
}); |
|
|
|
ecdsa.signRandomK(); |
|
|
|
ecdsa.calci(); |
|
|
|
this.sig = ecdsa.sig; |
|
|
|