diff --git a/lib/bn.js b/lib/bn.js index bba8981..51b8648 100644 --- a/lib/bn.js +++ b/lib/bn.js @@ -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 () { @@ -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; };