index.js
// (public) convert to bigendian byte array
(public) convert to bigendian byte array
( public ) convert to bigendian byte array
function bnToByteArray()
{
  var i = this.t,
    r = [];
  r[0] = this.s;
  var p = this.DB - (i * this.DB) % 8,
    d, k = 0;
  if (i-- > 0)
  {
    if (p < this.DB && (d = this[i] >> p) != (this.s & this.DM) >> p) r[k++] = d | (this.s << (this.DB - p));
    while (i >= 0)
    {
      if (p < 8)
      {
        d = (this[i] & ((1 << p) - 1)) << (8 - p);
        d |= this[--i] >> (p += this.DB - 8);
      }
      else
      {
        d = (this[i] >> (p -= 8)) & 0xff;
        if (p <= 0)
        {
          p += this.DB;
          --i;
        }
      }
      if ((d & 0x80) != 0) d |= -256;
      if (k == 0 && (this.s & 0x80) != (d & 0x80))++k;
      if (k > 0 || d != this.s) r[k++] = d;
    }
  }
  return r;
}
function bnToByteArray ( ) { var i = this . t , r = [ ] ; r [ 0 ] = this . s ; var p = this . DB - ( i * this . DB ) % 8 , d , k = 0 ; if ( i -- > 0 ) { if ( p < this . DB && ( d = this [ i ] >> p ) != ( this . s & this . DM ) >> p ) r [ k ++ ] = d | ( this . s << ( this . DB - p ) ) ; while ( i >= 0 ) { if ( p < 8 ) { d = ( this [ i ] & ( ( 1 << p ) - 1 ) ) << ( 8 - p ) ; d |= this [ -- i ] >> ( p += this . DB - 8 ) ; } else { d = ( this [ i ] >> ( p -= 8 ) ) & 0xff ; if ( p <= 0 ) { p += this . DB ; -- i ; } } if ( ( d & 0x80 ) != 0 ) d |= - 256 ; if ( k == 0 && ( this . s & 0x80 ) != ( d & 0x80 ) ) ++ k ; if ( k > 0 || d != this . s ) r [ k ++ ] = d ; } } return r ; }
(public) convert to bigendian byte array
( public ) convert to bigendian byte array