{
  public static final byte[] I2OSP(final BigInteger s, final int k)  {    byte[] result = s.toByteArray();    if (result.length < k)      {        final byte[] newResult = new byte[k];        System.arraycopy(result, 0, newResult, k - result.length, result.length);        result = newResult;      }    else if (result.length > k)      { // leftmost extra bytes should all be 0        final int limit = result.length - k;        for (int i = 0; i < limit; i++)          {            if (result[i] != 0x00)              {                throw new IllegalArgumentException("integer too large");              }          }        final byte[] newResult = new byte[k];        System.arraycopy(result, limit, newResult, 0, k);        result = newResult;      }    return result;  }