def test_Pedersen_Env_missing():

    # Define an EC group
    G = EcGroup(713)
    order = G.order()

    ## Proof definitions
    zk = ZKProof(G)
    g, h = zk.get(ConstGen, ["g", "h"])
    x, o = zk.get(Sec, ["x", "o"])
    Cxo = zk.get(Gen, "Cxo")
    zk.add_proof(Cxo, x*g + o*h)

    # A concrete Pedersen commitment
    ec_g = G.generator()
    ec_h = order.random() * ec_g
    bn_x = order.random()
    bn_o = order.random()
    ec_Cxo = bn_x * ec_g + bn_o * ec_h

    env = ZKEnv(zk)
    env.g, env.h = ec_g, ec_h 
    env.Cxo = ec_Cxo
    env.x = bn_x 
    # env.o = bn_o ## MISSING THIS ONE

    with pytest.raises(Exception) as excinfo:
        env.NOTEXISTING = bn_x
    assert "Variable name 'NOTEXISTING' not known" in str(excinfo.value)

    ## Ensure we catch missing variables
    with pytest.raises(Exception) as excinfo:
        zk.build_proof(env.get())
    assert 'Could not find variable "o"' in str(excinfo.value)

    ## Ensure we catch false statements
    env.o = bn_o + 1    
    with pytest.raises(Exception) as excinfo:
        zk.build_proof(env.get())
    assert "Proof about 'Cxo' does not hold" in str(excinfo.value)
dataset/ETHPy150Open gdanezis/petlib/examples/genzkp.py/test_Pedersen_Env_missing/original