private static byte[] toByteArray(BigInteger bi,int len){
  byte[] b=bi.toByteArray();
  int n=b.length;
  if (n == len) {
    return b;
  }
  if ((n == len + 1) && (b[0] == 0)) {
    byte[] t=new byte[len];
    System.arraycopy(b,1,t,0,len);
    return t;
  }
  assert (n < len);
  byte[] t=new byte[len];
  System.arraycopy(b,0,t,(len - n),n);
  return t;
}

private static byte [ ] toByteArray ( BigInteger bi , int len ) { byte [ ] b = bi . toByteArray ( ) ; int n = b . length ; if ( n == len ) { return b ; } if ( ( n == len + 1 ) && ( b [ 0 ] == 0 ) ) { byte [ ] t = new byte [ len ] ; System . arraycopy ( b , 1 , t , 0 , len ) ; return t ; } assert ( n < len ) ; byte [ ] t = new byte [ len ] ; System . arraycopy ( b , 0 , t , ( len - n ) , n ) ; return t ; }
return the encoding of this biginteger that is exactly len bytes long . prefix / strip off leading 0x00 bytes if necessary . precondition : bi must fit into len bytes
