decodes and integer from serialization

def decode_int(v):
    """decodes and integer from serialization"""
    if len(v) > 0 and (v[0] == b'\x00' or v[0] == 0):
        raise Exception("No leading zero bytes allowed for integers")
    return big_endian_to_int(v)