[Pkg-javascript-commits] [node-diffie-hellman] 26/88: just add 4 until p mod 24 === 11

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


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

rouca pushed a commit to branch master
in repository node-diffie-hellman.

commit 4a7c1429ae7eabcbe9157db7498b20b902b2347d
Author: Calvin Metcalf <calvin.metcalf at state.ma.us>
Date:   Sat Nov 8 13:48:57 2014 -0500

    just add 4 until p mod 24 === 11
---
 generatePrime.js | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/generatePrime.js b/generatePrime.js
index 44a030f..bf32f48 100644
--- a/generatePrime.js
+++ b/generatePrime.js
@@ -8,9 +8,10 @@ var millerRabin = new MillerRabin();
 var ONE = new BN(1);
 var TWO = new BN(2);
 var ELEVEN = new BN(11);
+var FOUR = new BN(4);
 function findPrime(bits, crypto) {
 
-  function _generateRandom(bits) {
+  function generateRandom(bits) {
     var bytes = bits >> 3;
     bytes = bytes || 1;
     var out = new BN(crypto.randomBytes(bytes));
@@ -23,12 +24,8 @@ function findPrime(bits, crypto) {
     if (!out.testn(1)) {
       out.iadd(TWO);
     }
-    return out;
-  }
-  function generateRandom(bits) {
-    var out = _generateRandom(bits);
     while (out.mod(TWENTYFOUR).cmp(ELEVEN)) {
-      out = _generateRandom(bits);
+      out.iadd(FOUR);
     }
     return out;
   }

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



More information about the Pkg-javascript-commits mailing list