How to use the jsbn/lib/big-integer.ZERO function in jsbn

To help you get started, we’ve selected a few jsbn examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wowserhq / wowser / lib / client / crypto / big-num.js View on Github external
key: 'fromRand',

    // Creates a new random BigNum of the given number of bytes
    value: function fromRand(length) {
      // TODO: This should use a properly seeded, secure RNG
      bytes = [];
      for (var i = 0; i < length; ++i) {
        bytes.push(Math.floor(Math.random() * 128));
      }
      return new BigNum(bytes);
    }
  }, {
    key: 'ZERO',

    // Convenience BigInteger.ZERO decorator
    value: new BigNum(BigInteger.ZERO),
    enumerable: true
  }]);

  return BigNum;
})();
github wowserhq / wowser / src / lib / crypto / big-num.js View on Github external
import BigInteger from 'jsbn/lib/big-integer';

// C-like BigNum decorator for JSBN's BigInteger
class BigNum {

  // Convenience BigInteger.ZERO decorator
  static ZERO = new BigNum(BigInteger.ZERO);

  // Creates a new BigNum
  constructor(value, radix) {
    if (typeof value === 'number') {
      this._bi = BigInteger.fromInt(value);
    } else if (value.constructor === BigInteger) {
      this._bi = value;
    } else if (value.constructor === BigNum) {
      this._bi = value.bi;
    } else {
      this._bi = new BigInteger(value, radix);
    }
  }

  // Short string description of this BigNum
  toString() {

jsbn

The jsbn library is a fast, portable implementation of large-number math in pure JavaScript, enabling public-key crypto and other applications on desktop and mobile browsers.

MIT
Latest version published 7 years ago

Package Health Score

67 / 100
Full package analysis