def ProveOneOfN(ck, cis, el, r, message = ""):
    n = int(math.ceil(math.log(len(cis)) / math.log(2)))
    assert Com(ck, 0, r) == cis[el]
    (G, g, h, o) = ck

    ## Commit to the bits of the index
    el = Bn(el)
    eli = [Bn(int(el.is_bit_set(i))) for i in range(n)]
    
    ri  = [o.random() for i in range(n)]
    ai  = [o.random() for i in range(n)]
    si  = [o.random() for i in range(n)]
    ti  = [o.random() for i in range(n)]

    Celi = [Com(ck, elix, rix) for elix, rix in zip(eli, ri)]
    Cai = [Com(ck, a, s) for a, s in zip(ai, si)]
    Cbi = [Com(ck, l * a , s) for l, a, s in zip(eli, ai, ti)]

    # Compute p_idxi(x)
    p_idx_i = []
    for idx in range(len(cis)):
        idx = Bn(idx)
        idxi = [Bn(int(idx.is_bit_set(i))) for i in range(n)]

        p = [Bn(1)]
        for j, idxi_j in enumerate(idxi):
            if idxi_j == 0:
                p = poly_mul(o, p, [ -ai[j] , - eli[j] + 1] )
            else:
                p = poly_mul(o, p, [ ai[j] , eli[j] ])

        p_idx_i += [p]
        
    # Compute all Cdi's
    roi = []
    cdi = []
    for i in range(n):
        roi_i = o.random()
        roi += [ roi_i ]
        # cdi_i = Com(ck, 0, roi_i)

        wis = []

        for idx, cidx in enumerate(cis):
            wis += [ p_idx_i[idx][i] ]
            # cdi_i += p_idx_i[idx][i] * cidx

        # assert G.wsum(wis, cis) + Com(ck, 0, roi_i) == cdi_i
        cdi_i = G.wsum(wis, cis) + Com(ck, 0, roi_i)

        cdi += [ cdi_i ]

    ## The challenge
    x = challenge(list(ck) + cis + Celi + Cai + Cbi + cdi + [ message ])

    ## The responses
    fi = [(elj * x + aj) % o for elj, aj in zip(eli, ai)]
    zai = [(rj * x + sj) % o for rj, sj in zip(ri, si)]
    zbi = [(rj * (x - fj) + tj) % o for rj, fj, tj in zip(ri, fi, ti)]

    zd = r * pow(x, n, o) % o
    for k in range(n):
        zd = (zd - roi[k] * pow(x, k, o)) % o

    proof = (Celi, Cai, Cbi, cdi, fi, zai, zbi, zd)

    return proof
Return a resource given its name.
dataset/ETHPy150Open gdanezis/petlib/examples/GK15ringsig.py/ProveOneOfN--crossover with--dataset/ETHPy150Open openstack/neutron/neutron/quota/resource_registry.py/ResourceRegistry.get_resource