diff --git a/lib/bcoin/script.js b/lib/bcoin/script.js index c68b91f4..9e700aef 100644 --- a/lib/bcoin/script.js +++ b/lib/bcoin/script.js @@ -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');