How to use the bcrypto/lib/random.randomRange function in bcrypto

To help you get started, we’ve selected a few bcrypto 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 handshake-org / goosig / test / util / index.js View on Github external
function genKey(bits) {
  assert((bits >>> 0) === bits);
  assert(bits === 2048 || bits === 4096);

  const primes = [primes1024, primes2048][bits >>> 12];

  for (;;) {
    const i = rng.randomRange(0, primes.length);
    const j = rng.randomRange(0, primes.length);

    if (i === j)
      continue;

    const p = BN.decode(primes[i]);
    const q = BN.decode(primes[j]);
    const n = p.mul(q);
    const pm1 = p.subn(1);
    const qm1 = q.subn(1);
    const phi = pm1.mul(qm1);

    let e = null;
    let d = null;

    for (let i = 1; i < smallPrimes.length; i++) {
      try {
github handshake-org / goosig / test / util / index.js View on Github external
function genKey(bits) {
  assert((bits >>> 0) === bits);
  assert(bits === 2048 || bits === 4096);

  const primes = [primes1024, primes2048][bits >>> 12];

  for (;;) {
    const i = rng.randomRange(0, primes.length);
    const j = rng.randomRange(0, primes.length);

    if (i === j)
      continue;

    const p = BN.decode(primes[i]);
    const q = BN.decode(primes[j]);
    const n = p.mul(q);
    const pm1 = p.subn(1);
    const qm1 = q.subn(1);
    const phi = pm1.mul(qm1);

    let e = null;
    let d = null;

    for (let i = 1; i < smallPrimes.length; i++) {
github handshake-org / hsd / lib / mining / miner.js View on Github external
getAddress() {
    if (this.addresses.length === 0)
      return new Address();
    return this.addresses[rng.randomRange(0, this.addresses.length)];
  }
github handshake-org / goosig / scripts / fuzz.js View on Github external
function rand(num) {
  return rng.randomRange(0, num);
}
github handshake-org / hsd / lib / net / hostlist.js View on Github external
function random(max) {
  return rng.randomRange(0, max);
}
github handshake-org / hsd / lib / net / pool.js View on Github external
function random(max) {
  return rng.randomRange(0, max);
}