Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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()};
}
}
}
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;
}
}
}
function pickRandomInRange(min = 0, max = Consts.MAXIMUM_NUMBER) {
return BigInteger.randBetween(min, max);
}
generateSeed () {
return bigInt.randBetween(0, MAX_VALUE).valueOf()
},
function pickRandom(max = Consts.MAXIMUM_NUMBER,min=0) {
return BigInteger.randBetween(min, max);
}
function turnToBig(number){
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;
}
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)]
}
generateSeed () {
return bigInt.randBetween(0, MAX_VALUE).valueOf()
},