Skip to content

Commit

Permalink
rm fast primes
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinmetcalf committed Nov 5, 2014
1 parent c40a075 commit 08779de
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 27 deletions.
9 changes: 2 additions & 7 deletions dh.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@ module.exports = DH;

function DH(prime, crypto) {
this.setGenerator(new Buffer([2]));
if (typeof prime === 'string') {
this.__prime = BN._prime(prime).p;
this._prime = BN.red(prime);
} else {
this.__prime = new BN(prime);
this._prime = BN.mont(this.__prime);
}
this.__prime = new BN(prime);
this._prime = BN.mont(this.__prime);
this._pub = void 0;
this._priv = void 0;
this._makeNum = function makeNum() {
Expand Down
15 changes: 1 addition & 14 deletions generatePrime.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@

module.exports = generatePrime;
module.exports = findPrime;

var goodPrimes = {
256: 'k256',
224: 'p224',
192: 'p192',
25519: 'p25519'
};
function generatePrime(len, crypto) {
if (len in goodPrimes) {
return goodPrimes[len];
} else {
return findPrime(len, crypto);
}
}
// based on find-prime by Kenan Yildirim
// https://github.com/KenanY/find-prime

Expand Down
9 changes: 3 additions & 6 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ var myCrypto = require('./');
var mods = [
'modp1', 'modp2', 'modp5', 'modp14', 'modp15', 'modp16'/*, 'modp17', 'modp18'*/
];
var lens = [
64, 128, 384, 512, 1024, //slow
192, 224, 256, 25519 //fast
];
var lens2 = [

var lens = [
64, 128, 384, 512, 1024,
192, 224, 256];
function run(i) {
Expand Down Expand Up @@ -84,7 +81,7 @@ if (process.version && process.version.split('.').length === 3 && parseInt(proce
}
test('create primes other way', function (t) {
var f = bylen2(t);
lens2.forEach(f);
lens.forEach(f);
});
var i = 0;
while (++i < 2) {
Expand Down

0 comments on commit 08779de

Please sign in to comment.