Skip to content

Commit

Permalink
Merge 8a6bb93 into 776c9b0
Browse files Browse the repository at this point in the history
  • Loading branch information
xg-wang committed May 27, 2018
2 parents 776c9b0 + 8a6bb93 commit 477be42
Show file tree
Hide file tree
Showing 13 changed files with 524 additions and 576 deletions.
1,025 changes: 490 additions & 535 deletions dist/elliptic.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions dist/elliptic.min.js

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions lib/elliptic/curve/base.js
@@ -1,8 +1,7 @@
'use strict';

var BN = require('bn.js');
var elliptic = require('../../elliptic');
var utils = elliptic.utils;
var utils = require('../utils');
var getNAF = utils.getNAF;
var getJSF = utils.getJSF;
var assert = utils.assert;
Expand Down
7 changes: 3 additions & 4 deletions lib/elliptic/curve/edwards.js
@@ -1,12 +1,11 @@
'use strict';

var curve = require('../curve');
var elliptic = require('../../elliptic');
var utils = require('../utils');
var BN = require('bn.js');
var inherits = require('inherits');
var Base = curve.base;
var Base = require('./base');

var assert = elliptic.utils.assert;
var assert = utils.assert;

function EdwardsCurve(conf) {
// NOTE: Important as we are creating point in Base.call()
Expand Down
6 changes: 2 additions & 4 deletions lib/elliptic/curve/mont.js
@@ -1,12 +1,10 @@
'use strict';

var curve = require('../curve');
var BN = require('bn.js');
var inherits = require('inherits');
var Base = curve.base;
var Base = require('./base');

var elliptic = require('../../elliptic');
var utils = elliptic.utils;
var utils = require('../utils');

function MontCurve(conf) {
Base.call(this, 'mont', conf);
Expand Down
7 changes: 3 additions & 4 deletions lib/elliptic/curve/short.js
@@ -1,12 +1,11 @@
'use strict';

var curve = require('../curve');
var elliptic = require('../../elliptic');
var utils = require('../utils');
var BN = require('bn.js');
var inherits = require('inherits');
var Base = curve.base;
var Base = require('./base');

var assert = elliptic.utils.assert;
var assert = utils.assert;

function ShortCurve(conf) {
Base.call(this, 'short', conf);
Expand Down
11 changes: 6 additions & 5 deletions lib/elliptic/curves.js
Expand Up @@ -3,17 +3,18 @@
var curves = exports;

var hash = require('hash.js');
var elliptic = require('../elliptic');
var curve = require('./curve');
var utils = require('./utils');

var assert = elliptic.utils.assert;
var assert = utils.assert;

function PresetCurve(options) {
if (options.type === 'short')
this.curve = new elliptic.curve.short(options);
this.curve = new curve.short(options);
else if (options.type === 'edwards')
this.curve = new elliptic.curve.edwards(options);
this.curve = new curve.edwards(options);
else
this.curve = new elliptic.curve.mont(options);
this.curve = new curve.mont(options);
this.g = this.curve.g;
this.n = this.curve.n;
this.hash = options.hash;
Expand Down
13 changes: 7 additions & 6 deletions lib/elliptic/ec/index.js
Expand Up @@ -2,8 +2,9 @@

var BN = require('bn.js');
var HmacDRBG = require('hmac-drbg');
var elliptic = require('../../elliptic');
var utils = elliptic.utils;
var utils = require('../utils');
var curves = require('../curves');
var rand = require('brorand');
var assert = utils.assert;

var KeyPair = require('./key');
Expand All @@ -15,13 +16,13 @@ function EC(options) {

// Shortcut `elliptic.ec(curve-name)`
if (typeof options === 'string') {
assert(elliptic.curves.hasOwnProperty(options), 'Unknown curve ' + options);
assert(curves.hasOwnProperty(options), 'Unknown curve ' + options);

options = elliptic.curves[options];
options = curves[options];
}

// Shortcut for `elliptic.ec(elliptic.curves.curveName)`
if (options instanceof elliptic.curves.PresetCurve)
if (options instanceof curves.PresetCurve)
options = { curve: options };

this.curve = options.curve.curve;
Expand Down Expand Up @@ -59,7 +60,7 @@ EC.prototype.genKeyPair = function genKeyPair(options) {
hash: this.hash,
pers: options.pers,
persEnc: options.persEnc || 'utf8',
entropy: options.entropy || elliptic.rand(this.hash.hmacStrength),
entropy: options.entropy || rand(this.hash.hmacStrength),
entropyEnc: options.entropy && options.entropyEnc || 'utf8',
nonce: this.n.toArray()
});
Expand Down
3 changes: 1 addition & 2 deletions lib/elliptic/ec/key.js
@@ -1,8 +1,7 @@
'use strict';

var BN = require('bn.js');
var elliptic = require('../../elliptic');
var utils = elliptic.utils;
var utils = require('../utils');
var assert = utils.assert;

function KeyPair(ec, options) {
Expand Down
3 changes: 1 addition & 2 deletions lib/elliptic/ec/signature.js
Expand Up @@ -2,8 +2,7 @@

var BN = require('bn.js');

var elliptic = require('../../elliptic');
var utils = elliptic.utils;
var utils = require('../utils');
var assert = utils.assert;

function Signature(options, enc) {
Expand Down
6 changes: 3 additions & 3 deletions lib/elliptic/eddsa/index.js
@@ -1,8 +1,8 @@
'use strict';

var hash = require('hash.js');
var elliptic = require('../../elliptic');
var utils = elliptic.utils;
var curves = require('../curves');
var utils = require('../utils');
var assert = utils.assert;
var parseBytes = utils.parseBytes;
var KeyPair = require('./key');
Expand All @@ -14,7 +14,7 @@ function EDDSA(curve) {
if (!(this instanceof EDDSA))
return new EDDSA(curve);

var curve = elliptic.curves[curve].curve;
var curve = curves[curve].curve;
this.curve = curve;
this.g = curve.g;
this.g.precompute(curve.n.bitLength() + 1);
Expand Down
3 changes: 1 addition & 2 deletions lib/elliptic/eddsa/key.js
@@ -1,7 +1,6 @@
'use strict';

var elliptic = require('../../elliptic');
var utils = elliptic.utils;
var utils = require('../utils');
var assert = utils.assert;
var parseBytes = utils.parseBytes;
var cachedProperty = utils.cachedProperty;
Expand Down
3 changes: 1 addition & 2 deletions lib/elliptic/eddsa/signature.js
@@ -1,8 +1,7 @@
'use strict';

var BN = require('bn.js');
var elliptic = require('../../elliptic');
var utils = elliptic.utils;
var utils = require('../utils');
var assert = utils.assert;
var cachedProperty = utils.cachedProperty;
var parseBytes = utils.parseBytes;
Expand Down

0 comments on commit 477be42

Please sign in to comment.