BN.js fixed nmask for us, so we use that now instead of our mask hack.
This commit is contained in:
parent
dc2583ddd8
commit
db7cff9582
@ -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,
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user