Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Node.prototype._init = function init(body) {
var state = this._baseState;
assert(state.parent === null);
body.call(this);
// Filter children
state.children = state.children.filter(function(child) {
return child._baseState.parent === this;
}, this);
assert.equal(state.children.length, 1, 'Root node can have only one child');
};
Node.prototype._init = function init(body) {
var state = this._baseState;
assert(state.parent === null);
body.call(this);
// Filter children
state.children = state.children.filter(function(child) {
return child._baseState.parent === this;
}, this);
assert.equal(state.children.length, 1, 'Root node can have only one child');
};
function EDEState(type, key) {
assert.equal(key.length, 24, 'Invalid key length');
var k1 = key.slice(0, 8);
var k2 = key.slice(8, 16);
var k3 = key.slice(16, 24);
if (type === 'encrypt') {
this.ciphers = [
DES.create({ type: 'encrypt', key: k1 }),
DES.create({ type: 'decrypt', key: k2 }),
DES.create({ type: 'encrypt', key: k3 })
];
} else {
this.ciphers = [
DES.create({ type: 'decrypt', key: k3 }),
DES.create({ type: 'encrypt', key: k2 }),
DES.create({ type: 'decrypt', key: k1 })
function Game(options) {
EventEmitter.call(this);
this.options = options;
assert.equal(typeof this.options.index, 'number',
'options.index is required (number)');
assert.equal(typeof this.options.playerCount, 'number',
'options.players is required (number)');
assert.equal(typeof this.options.rules, 'object',
'options.rules is required (object)');
this.rules = this.options.rules;
this.index = this.options.index;
this.playerCount = this.options.playerCount;
this.players = new Array(this.playerCount);
for (var i = 0; i < this.players.length; i++)
this.players[i] = new Player();
this.prev = this.index === 0 ? this.playerCount - 1 : this.index - 1;
this.next = (this.index + 1) % this.playerCount;
DES.prototype._unpad = function _unpad(buffer) {
var pad = buffer[buffer.length - 1];
for (var i = buffer.length - pad; i < buffer.length; i++)
assert.equal(buffer[i], pad);
return buffer.slice(0, buffer.length - pad);
};
function Visual(options) {
EventEmitter.call(this);
this.options = options;
assert.equal(typeof this.options.cardCount, 'number',
'options.cardCount is required (number)');
this.cards = new Array(this.options.cardCount);
for (var i = 0; i < this.cards.length; i++)
this.cards[i] = new Card();
}
inherits(Visual, EventEmitter);
function Deck(options) {
this.options = options;
assert.equal(typeof this.options.curve, 'object',
'options.curve is required (object)');
assert.equal(typeof this.options.cardCount, 'number',
'options.cardCount is required (number)');
assert(this.options.cardCount <= 0xff, 'Can\'t have more than 255 cards');
this.curve = this.options.curve;
this.cards = [];
this.rng = new cryptoDeck.RNG(this.options.entropy);
this._shuffle = new Shuffle(this.rng, this.options.cardCount);
this._shuffleSecret = this._randScalar();
this._lockSecrets = [];
this._locked = [];
function fromDer(input, len) {
var p = {};
p.place = 0;
assert.equal(input[p.place++], 0x30);
getLength(input, p);
assert.equal(input[p.place++], 0x02);
var rlen = getLength(input, p);
var r = input.slice(p.place, rlen + p.place);
p.place += rlen;
assert.equal(input[p.place++], 0x02);
var slen = getLength(input, p);
assert.equal(input.length, slen + p.place);
var s = input.slice(p.place, slen + p.place);
if (!r[0] && (r[1] & 0x80)) {
r = r.slice(1);
}
if (!s[0] && (s[1] & 0x80)) {
s = s.slice(1);
}
while (r.length < len) {
r = Buffer.concat([new Buffer([0]), r]);
}
while (s.length < len) {
s = Buffer.concat([new Buffer([0]), s]);
}
return Buffer.concat([r, s]);
}
function getLength(buf, p) {
DES.prototype.deriveKeys = function deriveKeys(state, key) {
state.keys = new Array(16 * 2);
assert.equal(key.length, this.blockSize, 'Invalid key length');
var kL = utils.readUInt32BE(key, 0);
var kR = utils.readUInt32BE(key, 4);
utils.pc1(kL, kR, state.tmp, 0);
kL = state.tmp[0];
kR = state.tmp[1];
for (var i = 0; i < state.keys.length; i += 2) {
var shift = shiftTable[i >>> 1];
kL = utils.r28shl(kL, shift);
kR = utils.r28shl(kR, shift);
utils.pc2(kL, kR, state.keys, i);
}
};
function fromDer(input, len) {
var p = {};
p.place = 0;
assert.equal(input[p.place++], 0x30);
getLength(input, p);
assert.equal(input[p.place++], 0x02);
var rlen = getLength(input, p);
var r = input.slice(p.place, rlen + p.place);
p.place += rlen;
assert.equal(input[p.place++], 0x02);
var slen = getLength(input, p);
assert.equal(input.length, slen + p.place);
var s = input.slice(p.place, slen + p.place);
if (!r[0] && (r[1] & 0x80)) {
r = r.slice(1);
}
if (!s[0] && (s[1] & 0x80)) {
s = s.slice(1);
}
while (r.length < len) {