src/vendor/leemon.js
function randBigInt_(b, n, s) {
  var i, a;
  for (i=0; i<b.length; i++)
    b[i]=0;
  a=Math.floor((n-1)/bpe)+1; //# array elements to hold the BigInt
  for (i=0; i<a; i++) {
    b[i]=Math.floor(Math.random()*(1<<(bpe-1)));
  }
  b[a-1] &= (2<<((n-1)%bpe))-1;
  if (s==1)
    b[a-1] |= (1<<((n-1)%bpe));
}
function randBigInt_(b, n, s) {
  var i, a;
  for (i=0; i<b.length; i++)
    b[i]=0;
  a=Math.floor((n-1)/bpe)+1; //# array elements to hold the BigInt
  for (i=0; i<a; i++) {
    b[i]=Math.floor(Math.random()*(1<<(bpe-1)));
  }
  b[a-1] &= (2<<((n-1)%bpe))-1;
  if (s==1)
    b[a-1] |= (1<<((n-1)%bpe));
}
function randBigInt_ ( b , n , s ) { var i , a ; for ( i = 0 ; i < b . length ; i ++ ) b [ i ] = 0 ; a = Math . floor ( ( n - 1 ) / bpe ) + 1 ; //# array elements to hold the BigInt for ( i = 0 ; i < a ; i ++ ) { b [ i ] = Math . floor ( Math . random ( ) * ( 1 << ( bpe - 1 ) ) ) ; } b [ a - 1 ] &= ( 2 << ( ( n - 1 ) % bpe ) ) - 1 ; if ( s == 1 ) b [ a - 1 ] |= ( 1 << ( ( n - 1 ) % bpe ) ) ; }
Set b to an n-bit random BigInt.  If s=1, then the most significant of those n bits is set to 1. Array b must be big enough to hold the result. Must have n>=1
Set b to an n - bit random BigInt . If s = 1 then the most significant of those n bits is set to 1 . Array b must be big enough to hold the result . Must have n > = 1