remove alternative script num methods.

This commit is contained in:
Christopher Jeffrey 2016-05-15 22:33:20 -07:00
parent c6ccb0fccf
commit 6c997e20b5
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -1912,11 +1912,10 @@ Script.num = function num(value, flags, size) {
// If the input vector's most significant byte is
// 0x80, remove it from the result's msb and return
// a negative.
if (value[value.length - 1] & 0x80) {
// n = new bn(0x80).ushln(8 * (value.length - 1)).notn(64);
// return result.uand(n).neg();
// Equivalent to:
// -(result & ~(0x80 << (8 * (value.length - 1))))
if (value[value.length - 1] & 0x80)
result.setn((value.length * 8) - 1, 0).ineg();
}
return result;
};
@ -1963,17 +1962,6 @@ Script.array = function(value) {
// interpreted as a negative when
// converting to an integral.
// neg = value.cmpn(0) < 0;
// if (value.testn((value.byteLength() * 8) - 1)) {
// result = value.toArray('le');
// result.push(neg ? 0x80 : 0);
// return new Buffer(result);
// }
// result = value.toBuffer('le');
// if (neg)
// result[result.length - 1] |= 0x80;
// return result;
neg = value.cmpn(0) < 0;
result = value.toArray('le');