[Pkg-javascript-commits] [node-miller-rabin] 07/37: lib: remove fermat test

Bastien Roucariès rouca at moszumanska.debian.org
Thu May 4 10:20:40 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-miller-rabin.

commit 4a3d707cd643d273b8fc7cc7e472c61628402b1d
Author: Fedor Indutny <fedor at indutny.com>
Date:   Fri Nov 7 16:21:43 2014 +0300

    lib: remove fermat test
---
 lib/mr.js        | 4 ----
 test/api-test.js | 1 -
 2 files changed, 5 deletions(-)

diff --git a/lib/mr.js b/lib/mr.js
index 67db2b9..d3f51d2 100644
--- a/lib/mr.js
+++ b/lib/mr.js
@@ -21,10 +21,6 @@ exports.test = function test(n, k, cb) {
   var red = bn.mont(n);
   var rone = new bn(1).toRed(red);
 
-  // Fermat test
-  if (new bn(2).toRed(red).redPow(n.subn(1)).cmp(rone) !== 0)
-    return false;
-
   if (!k)
     k = Math.max(1, (len / 48) | 0);
 
diff --git a/test/api-test.js b/test/api-test.js
index 476a9ef..de9dba7 100644
--- a/test/api-test.js
+++ b/test/api-test.js
@@ -14,6 +14,5 @@ describe('Miller-Rabin', function() {
                    '79d695bb732449f0e015745b86bfa371dc6ca7386e9c7309' +
                    '5549c2e4b8002873', 16);
     assert(mr.test(p));
-    assert(!mr.test(p.subn(1)));
   });
 });

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-miller-rabin.git



More information about the Pkg-javascript-commits mailing list