docs: static BigInteger castToBigInteger(final byte[] chunk, final int maxLength, final boolean requireMinimal) throws ScriptException {
          if (chunk.length > maxLength)
              throw new ScriptException(ScriptError.SCRIPT_ERR_UNKNOWN_ERROR, "Script attempted to use an integer larger than " + maxLength + " bytes");
  
          if (requireMinimal && chunk.length > 0) {
              // Check that the number is encoded with the minimum possible
              // number of bytes.
              //
              // If the most-significant-byte - excluding the sign bit - is zero
              // then we're not minimal. Note how this test also rejects the
              // negative-zero encoding, 0x80.
              if ((chunk[chunk.length - 1] & 0x7f) == 0) {
                  // One exception: if there's more than one byte and the most
                  // significant bit of the second-most-significant-byte is set
                  // it would conflict with the sign bit. An example of this case
                  // is +-255, which encode to 0xff00 and 0xff80 respectively.
                  // (big-endian).
                  if (chunk.length <= 1 || (chunk[chunk.length - 2] & 0x80) == 0) {
                      throw  new ScriptException(ScriptError.SCRIPT_ERR_UNKNOWN_ERROR, "non-minimally encoded script number");
                  }
              }
          }
  
          return Utils.decodeMPI(Utils.reverseBytes(chunk), false);
      }