From b70bf1affbedca187c48d6222a560bcb0b0d7c49 Mon Sep 17 00:00:00 2001 From: Kirill Fomichev Date: Mon, 23 Dec 2019 14:14:23 +0300 Subject: [PATCH] Temporary workaround for BN#_move Solve issues for using with old bn.js versions (<5.0.0). See details at: https://github.com/indutny/elliptic/issues/191 --- lib/bn.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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; };