def cred_secret_issue(params, pub, EGenc, publics, secrets, messages):

    # Parse variables
    G, g, h, o = params
    sk, x0_bar = secrets
    Cx0, iparams = publics
    (sKis, Cis) = EGenc

    assert len(sKis) == len(Cis)
    assert len(iparams) == len(messages) + len(Cis)

    # Get a blinding b
    b = o.random()
    u = b * g

    bx0_bar = b.mod_mul(x0_bar, o)
    bsk = []
    for xi in sk:
        bsk += [b.mod_mul(xi, o)]

    bCx0 = b * Cx0
    bXi = []
    for Xi in iparams:
        bXi += [b * Xi]

    bsk0 = bsk[0]
    open_bsk = bsk[1:len(messages)+1]
    sec_bsk  = bsk[len(messages)+1:len(messages)+1+len(Cis)]
    assert [bsk0] + open_bsk + sec_bsk == bsk

    # First build a proto-credential in clear using all public attribs
    r_prime = o.random()    
    EG_a = r_prime * g
    EG_b = r_prime * pub + bsk0 * g

    for mi, bxi in zip(messages, open_bsk):
        EG_b = EG_b + (bxi.mod_mul(mi,o) *  g)

    for (eg_ai, eg_bi, bxi) in zip(sKis, Cis, sec_bsk):
        EG_a = EG_a + bxi * eg_ai
        EG_b = EG_b + bxi * eg_bi

    # Now build an epic proof for all this.
    zk = cred_secret_issue_proof(params, len(Cis), len(messages))

    env = ZKEnv(zk)

    env.pub = pub
    env.g, env.h = g, h 
    env.u = u
    env.b = b

    # These relate to the proof of x0 ...
    env.x_0 = sk[0]
    env.bx_0 = bsk0
    env.x_0_bar = x0_bar
    env.bx_0_bar = b.mod_mul(x0_bar, o)
    env.Cx_0 = Cx0
    env.bCx_0 = bCx0
    
    # These relate to the knowledge of Xi, xi ...
    env.xi = sk[1:]
    env.Xi = iparams
    env.bxi = bsk[1:]
    env.bXi = bXi

    # These relate to the knowledge of the plaintext ...
    env.r_prime = r_prime
    env.mi = messages   
    env.CredA = EG_a
    env.CredB = EG_b
    env.EGai = sKis
    env.EGbi = Cis

    ## Extract the proof
    sig = zk.build_proof(env.get())
    if __debug__:
        assert zk.verify_proof(env.get(), sig, strict=False)

    return u, (EG_a, EG_b), sig
Encode a mixture of secret (EGenc) and public (messages) attributes
dataset/ETHPy150Open gdanezis/petlib/examples/amacscreds.py/cred_secret_issue