def gen_mlsag_assert(pk, xx, kLRki, mscout, index, dsRows):
    """
    Conditions check for gen_mlsag_ext.
    :param pk:
    :param xx:
    :param kLRki:
    :param mscout:
    :param index:
    :param dsRows:
    :return:
    """
    cols = len(pk)
    if cols <= 1:
        raise ValueError('Cols == 1')
    if index >= cols:
        raise ValueError('Index out of range')
    rows = len(pk[0])
    if rows == 0:
        raise ValueError('Empty pk')
    for i in range(cols):
        if len(pk[i]) != rows:
            raise ValueError('pk is not rectangular')
    if len(xx) != rows:
        raise ValueError('Bad xx size')
    if dsRows > rows:
        raise ValueError('Bad dsRows size')
    if (not kLRki or not mscout) and (kLRki or mscout):
        raise ValueError('Only one of kLRki/mscout is present')
    if kLRki and dsRows != 1:
        raise ValueError('Multisig requires exactly 1 dsRows')
    return rows, cols
