public byte[] toBytes() {
    byte[] xBytes = x.toBytes();
    byte[] yBytes = y.toBytes();

    byte[] result = new byte[xBytes.length + yBytes.length];
    Arraycopy.arraycopy_custom(xBytes, 0, result, 0, xBytes.length);
    Arraycopy.arraycopy_custom(yBytes, 0, result, xBytes.length, yBytes.length);

    return result;
  }
  public byte[] toBytesCompressed() {
    byte[] xBytes = x.toBytes();
    byte[] result = new byte[getLengthInBytesCompressed()];
    Arraycopy.arraycopy_custom(xBytes, 0, result, 0, xBytes.length);

    if (y.sign() > 0) result[xBytes.length] = 1;
    else result[xBytes.length] = 0;

    return result;
  }