static byte[] toByteArray(BigInteger bi){
  byte[] b=bi.toByteArray();
  if ((b.length > 1) && (b[0] == 0)) {
    int n=b.length - 1;
    byte[] newarray=new byte[n];
    System.arraycopy(b,1,newarray,0,n);
    b=newarray;
  }
  return b;
}

static byte [ ] toByteArray ( BigInteger bi ) { byte [ ] b = bi . toByteArray ( ) ; if ( ( b . length > 1 ) && ( b [ 0 ] == 0 ) ) { int n = b . length - 1 ; byte [ ] newarray = new byte [ n ] ; System . arraycopy ( b , 1 , newarray , 0 , n ) ; b = newarray ; } return b ; }
utility method to convert a biginteger to a byte array in unsigned format as needed in the handshake messages . biginteger uses 2 ' s complement format , i . e . it prepends an extra zero if the msb is set . we remove that .
