Skip to content

Commit

Permalink
Temporary workaround for BN#_move (#236)
Browse files Browse the repository at this point in the history
Solve issues for using with old bn.js versions (<5.0.0).
See details at: indutny/elliptic#191
  • Loading branch information
fanatid authored Dec 24, 2019
1 parent 3a9a4f7 commit a4d10c6
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/bn.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,15 @@
dest.red = this.red;
};

function move (dest, src) {
dest.words = src.words;
dest.length = src.length;
dest.negative = src.negative;
dest.red = src.red;
}

BN.prototype._move = function _move (dest) {
dest.words = this.words;
dest.length = this.length;
dest.negative = this.negative;
dest.red = this.red;
move(dest, this);
};

BN.prototype.clone = function clone () {
Expand Down Expand Up @@ -3243,7 +3247,7 @@
Red.prototype.imod = function imod (a) {
if (this.prime) return this.prime.ireduce(a)._forceRed(this);

a.umod(this.m)._forceRed(this)._move(a);
move(a, a.umod(this.m)._forceRed(this));
return a;
};

Expand Down

0 comments on commit a4d10c6

Please sign in to comment.