Skip to content

Commit

Permalink
lib: embed simplistic assert library into code
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinmetcalf authored and indutny committed Jan 12, 2015
1 parent aaf1488 commit 1ac6e48
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/elliptic/curve/base.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
var assert = require('assert');
var bn = require('bn.js');
var elliptic = require('../../elliptic');

var getNAF = elliptic.utils.getNAF;
var getJSF = elliptic.utils.getJSF;
var assert = elliptic.utils.assert;

function BaseCurve(type, conf) {
this.type = type;
Expand Down
2 changes: 1 addition & 1 deletion lib/elliptic/curve/edwards.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var assert = require('assert');
var curve = require('../curve');
var elliptic = require('../../elliptic');
var bn = require('bn.js');
var inherits = require('inherits');
var Base = curve.base;

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

function EdwardsCurve(conf) {
// NOTE: Important as we are creating point in Base.call()
Expand Down
2 changes: 1 addition & 1 deletion lib/elliptic/curve/mont.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var assert = require('assert');
var curve = require('../curve');
var elliptic = require('../../elliptic');
var bn = require('bn.js');
var inherits = require('inherits');
var Base = curve.base;

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

function MontCurve(conf) {
Base.call(this, 'mont', conf);
Expand Down
2 changes: 1 addition & 1 deletion lib/elliptic/curve/short.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var assert = require('assert');
var curve = require('../curve');
var elliptic = require('../../elliptic');
var bn = require('bn.js');
var inherits = require('inherits');
var Base = curve.base;

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

function ShortCurve(conf) {
Base.call(this, 'short', conf);
Expand Down
3 changes: 2 additions & 1 deletion lib/elliptic/curves.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
var curves = exports;

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

var assert = elliptic.utils.assert;

function PresetCurve(options) {
if (options.type === 'short')
this.curve = new elliptic.curve.short(options);
Expand Down
2 changes: 1 addition & 1 deletion lib/elliptic/ec/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var assert = require('assert');
var bn = require('bn.js');
var elliptic = require('../../elliptic');
var utils = elliptic.utils;
var assert = utils.assert;

var KeyPair = require('./key');
var Signature = require('./signature');
Expand Down
2 changes: 1 addition & 1 deletion lib/elliptic/ec/key.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var assert = require('assert');
var bn = require('bn.js');

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

function KeyPair(ec, priv, pub) {
if (priv instanceof KeyPair)
Expand Down
2 changes: 1 addition & 1 deletion lib/elliptic/ec/signature.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var assert = require('assert');
var bn = require('bn.js');

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

function Signature(r, s) {
if (r instanceof Signature)
Expand Down
3 changes: 1 addition & 2 deletions lib/elliptic/hmac-drbg.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
var assert = require('assert');

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

function HmacDRBG(options) {
if (!(this instanceof HmacDRBG))
Expand Down
6 changes: 5 additions & 1 deletion lib/elliptic/utils.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
var assert = require('assert');
var bn = require('bn.js');

var utils = exports;

utils.assert = function assert(val, msg) {
if (!val)
throw new Error(msg || 'Assertion failed');
};

function toArray(msg, enc) {
if (Array.isArray(msg))
return msg.slice();
Expand Down

0 comments on commit 1ac6e48

Please sign in to comment.