randBitsSync

This commit is contained in:
juanelas 2020-04-07 19:41:29 +02:00
parent eaf7c53ca2
commit 7e792b5e2e
6 changed files with 8 additions and 8 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -321,7 +321,7 @@ function primeSync (bitLength, iterations = 16) {
if (bitLength < 1) { throw new RangeError(`bitLength MUST be > 0 and it is ${bitLength}`) }
let rnd = 0n
do {
rnd = fromBuffer(randBits(bitLength, true))
rnd = fromBuffer(randBitsSync(bitLength, true))
} while (!_isProbablyPrime(rnd, iterations))
return rnd
}

View File

@ -113,7 +113,7 @@ function primeSync (bitLength, iterations = 16) {
if (bitLength < 1) { throw new RangeError(`bitLength MUST be > 0 and it is ${bitLength}`) }
let rnd = 0n
do {
rnd = fromBuffer(randBits(bitLength, true))
rnd = fromBuffer(randBitsSync(bitLength, true))
} while (!_isProbablyPrime(rnd, iterations))
return rnd
}

View File

@ -65,7 +65,7 @@ function prime (bitLength, iterations = 16) {
if (!_useWorkers) {
let rnd = 0n
do {
rnd = fromBuffer(randBits(bitLength, true))
rnd = fromBuffer(randBitsSync(bitLength, true))
} while (!_isProbablyPrime(rnd, iterations))
return new Promise((resolve) => { resolve(rnd) })
}
@ -131,7 +131,7 @@ function primeSync (bitLength, iterations = 16) {
if (bitLength < 1) { throw new RangeError(`bitLength MUST be > 0 and it is ${bitLength}`) }
let rnd = 0n
do {
rnd = fromBuffer(randBits(bitLength, true))
rnd = fromBuffer(randBitsSync(bitLength, true))
} while (!_isProbablyPrime(rnd, iterations))
return rnd
}

View File

@ -81,7 +81,7 @@ export function prime (bitLength, iterations = 16) {
if (!process.browser && !_useWorkers) {
let rnd = 0n
do {
rnd = fromBuffer(randBits(bitLength, true))
rnd = fromBuffer(randBitsSync(bitLength, true))
} while (!_isProbablyPrime(rnd, iterations))
return new Promise((resolve) => { resolve(rnd) })
}
@ -154,7 +154,7 @@ export function primeSync (bitLength, iterations = 16) {
if (bitLength < 1) { throw new RangeError(`bitLength MUST be > 0 and it is ${bitLength}`) }
let rnd = 0n
do {
rnd = fromBuffer(randBits(bitLength, true))
rnd = fromBuffer(randBitsSync(bitLength, true))
} while (!_isProbablyPrime(rnd, iterations))
return rnd
}