Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as brorand from 'brorand';
{
let result: Buffer|Uint8Array = brorand(42);
}
{
let Rand = new brorand.Rand({getByte: () => 255});
let rand: {getByte: () => number} = Rand.rand;
let result: Buffer|Uint8Array = Rand.generate(42);
}
function MillerRabin(rand) {
this.rand = rand || new brorand.Rand();
}
module.exports = MillerRabin;
function KeyGen(options) {
this.options = options || {};
this.rand = new brorand.Rand(this.options.prng);
this.primal = primal.create({ 'miller-rabin': this.rand });
}
module.exports = KeyGen;
/*
* This is to patch stupid behavior by brorand
* (https://github.com/indutny/brorand)
* which is used underneath elliptic for generating keys.
*
* It seems to not believe that we're in nodejs when we really are
*/
import crypto from 'crypto';
import rand from 'brorand';
rand.Rand.prototype._rand = function _rand(n) {
return crypto.randomBytes(n);
};
function MillerRabin(rand) {
this.rand = rand || new brorand.Rand();
}
module.exports = MillerRabin;
function MillerRabin(rand) {
this.rand = rand || new brorand.Rand();
}
module.exports = MillerRabin;