From db7cff9582bacbb56f6183c746c742e20d050d67 Mon Sep 17 00:00:00 2001 From: ricmoo Date: Wed, 9 Nov 2016 16:39:33 -0500 Subject: [PATCH] BN.js fixed nmask for us, so we use that now instead of our mask hack. --- lib/contract.js | 14 ++------------ package.json | 2 +- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/lib/contract.js b/lib/contract.js index a8d2c243c..b7e296fb3 100644 --- a/lib/contract.js +++ b/lib/contract.js @@ -44,21 +44,11 @@ function zpad(buffer, length) { return buffer; } -// There seems to be a but in maskn, so we are doing this for now. -var bitmasks = []; -(function() { - var mask = ''; - for (var i = 0; i < 33; i++) { - bitmasks.push(new utils.BN(mask, 16)); - mask += 'ff'; - } -})(); - function coderNumber(size, signed) { return { encode: function(value) { value = numberOrBN(value) - value = value.toTwos(size * 8).and(bitmasks[size]); + value = value.toTwos(size * 8).maskn(size * 8); if (signed) { value = value.fromTwos(size * 8).toTwos(256); } @@ -70,7 +60,7 @@ function coderNumber(size, signed) { if (signed) { value = value.fromTwos(size * 8); } else { - value = value.and(bitmasks[size]); + value = value.maskn(size * 8); } return { consumed: 32, diff --git a/package.json b/package.json index 1e137ecce..2e86ac3ad 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ }, "dependencies": { "aes-js": "2.0.0", - "elliptic": "6.3.1", + "elliptic": "6.3.2", "inherits": "2.0.1", "pbkdf2": "3.0.4", "rlp": "2.0.0",