Skip to content

Commit

Permalink
bn: add method move
Browse files Browse the repository at this point in the history
  • Loading branch information
fanatid authored and dcousens committed Jun 6, 2018
1 parent d87ed90 commit a472c1b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/bn.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,13 @@
dest.red = this.red;
};

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

BN.prototype.clone = function clone () {
var r = new BN(null);
this.copy(r);
Expand Down Expand Up @@ -3170,8 +3177,7 @@
Red.prototype.imod = function imod (a) {
if (this.prime) return this.prime.ireduce(a)._forceRed(this);

var mod = a.umod(this.m)._forceRed(this);
if (mod !== a) mod.copy(a);
a.umod(this.m)._forceRed(this).move(a);
return a;
};

Expand Down

0 comments on commit a472c1b

Please sign in to comment.