|
@ -31,10 +31,17 @@ Signature.prototype.set = function(obj) { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
Signature.fromCompact = function(buf) { |
|
|
Signature.fromCompact = function(buf) { |
|
|
|
|
|
$.checkArgument(BufferUtil.isBuffer(buf), 'Argument is expected to be a Buffer'); |
|
|
|
|
|
|
|
|
var sig = new Signature(); |
|
|
var sig = new Signature(); |
|
|
//TODO: handle uncompressed pubkeys
|
|
|
|
|
|
var compressed = true; |
|
|
var compressed = true; |
|
|
var i = buf.slice(0, 1)[0] - 27 - 4; |
|
|
var i = buf.slice(0, 1)[0] - 27 - 4; |
|
|
|
|
|
if (i < 0) { |
|
|
|
|
|
compressed = false; |
|
|
|
|
|
i = i + 4; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var b2 = buf.slice(1, 33); |
|
|
var b2 = buf.slice(1, 33); |
|
|
var b3 = buf.slice(33, 65); |
|
|
var b3 = buf.slice(33, 65); |
|
|
|
|
|
|
|
@ -142,8 +149,9 @@ Signature.prototype.toCompact = function(i, compressed) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var val = i + 27 + 4; |
|
|
var val = i + 27 + 4; |
|
|
if (compressed === false) |
|
|
if (compressed === false) { |
|
|
val = val - 4; |
|
|
val = val - 4; |
|
|
|
|
|
} |
|
|
var b1 = new Buffer([val]); |
|
|
var b1 = new Buffer([val]); |
|
|
var b2 = this.r.toBuffer({ |
|
|
var b2 = this.r.toBuffer({ |
|
|
size: 32 |
|
|
size: 32 |
|
|