public static byte[] bigIntegerToByteArray(BigInteger value){
  byte[] result=value.toByteArray();
  if (result[0] == 0x0) {
    byte[] tmp=new byte[result.length - 1];
    System.arraycopy(result,1,tmp,0,tmp.length);
    result=tmp;
  }
  return result;
}

public static byte [ ] bigIntegerToByteArray ( BigInteger value ) { byte [ ] result = value . toByteArray ( ) ; if ( result [ 0 ] == 0x0 ) { byte [ ] tmp = new byte [ result . length - 1 ] ; System . arraycopy ( result , 1 , tmp , 0 , tmp . length ) ; result = tmp ; } return result ; }
takes a biginteger value and returns its byte array representation , if necessary the sign byte is removed .
