<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def randomZ(maximum=None, bits=256):
 """ Retrieve a random BigInt. @maximum: If specified, the value will be no larger than this modulus. @bits: If no maximum is specified, the value will have @bits. """

    result = BigInt()

    # Select a random number smaller than the maximum.
    if maximum:
        maximum = coerceBigInt(maximum)
        librelic.bn_rand_mod(byref(result), byref(maximum))

    # Otherwise, select a random BigInt of the appropriate size in bits.
    else:
        librelic.bn_rand_abi(byref(result), BigInt.POSITIVE_FLAG, c_int(bits))
    
    return result