Skip to content

Commit a4d10c6

Browse files
authored
Temporary workaround for BN#_move (#236)
Solve issues for using with old bn.js versions (<5.0.0). See details at: indutny/elliptic#191
1 parent 3a9a4f7 commit a4d10c6

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

lib/bn.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,15 @@
327327
dest.red = this.red;
328328
};
329329

330+
function move (dest, src) {
331+
dest.words = src.words;
332+
dest.length = src.length;
333+
dest.negative = src.negative;
334+
dest.red = src.red;
335+
}
336+
330337
BN.prototype._move = function _move (dest) {
331-
dest.words = this.words;
332-
dest.length = this.length;
333-
dest.negative = this.negative;
334-
dest.red = this.red;
338+
move(dest, this);
335339
};
336340

337341
BN.prototype.clone = function clone () {
@@ -3243,7 +3247,7 @@
32433247
Red.prototype.imod = function imod (a) {
32443248
if (this.prime) return this.prime.ireduce(a)._forceRed(this);
32453249

3246-
a.umod(this.m)._forceRed(this)._move(a);
3250+
move(a, a.umod(this.m)._forceRed(this));
32473251
return a;
32483252
};
32493253

0 commit comments

Comments
 (0)