How to use the big-integer.randBetween function in big-integer

To help you get started, we’ve selected a few big-integer 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 clearmatics / mobius / test / mobius.js View on Github external
function RandomPoint () {
    const P = bigInt("21888242871839275222246405745257275088696311157297823662689037894645226208583");
    const N = bigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617");
    const A = bigInt("5472060717959818805561601436314318772174077789324455915672259473661306552146");
    while( true ) {
        const x = bigInt.randBetween(1, N.prev());
        const beta = x.multiply(x).mod(P).multiply(x).mod(P).add(3).mod(P);
        const y = beta.modPow(A, P);
        const y_squared = y.multiply(y).mod(P);
        if( y_squared.eq(beta) ) {
            return {x: x.toString(), y: y.toString()};
        }
    }
}
github denysdovhan / rsa-labwork / index.js View on Github external
static randomPrime(bits) {
    const min = bigInt.one.shiftLeft(bits - 1);
    const max = bigInt.one.shiftLeft(bits).prev();
    
    while (true) {
      let p = bigInt.randBetween(min, max);
      if (p.isProbablePrime(256)) {
        return p;
      } 
    }
  }
github omershlo / simple-bulletproof-js / utils.js View on Github external
function pickRandomInRange(min = 0, max = Consts.MAXIMUM_NUMBER) {
  return BigInteger.randBetween(min, max);
}
github omershlo / simple-bulletproof-js / utils.js View on Github external
function pickRandom(max = Consts.MAXIMUM_NUMBER,min=0) {
  return BigInteger.randBetween(min, max);
}
function turnToBig(number){
github alikhil / sttp / src / util.js View on Github external
function getRandomBigIntPrime(min, max) {
	var prime = bigInt.randBetween(min, max);
	do {
		while(prime.isEven() || !prime.isProbablePrime(50)) {
			prime = bigInt.randBetween(min, max);
		}
	} while(!prime.isPrime());
	return prime;
}
github framp / zero-knowledge-node / paillier-zero-knowledge / index.js View on Github external
const rEncrypt = function ({ n, g }, message) {
  const _n2 = n.pow(2)
  let r
  do {
      r = bigInt.randBetween(2, n)
  } while (r.leq(1))
  return [r, g.modPow(bigInt(message), _n2).multiply(r.modPow(n, _n2)).mod(_n2)]
}