example.py 799 Bytes
from PC import PCProver, PCVerifier

#Set up the params
pc = PCProver()
params = pc.getParams()
verifier = PCVerifier(params)

#Dictionary of messages and their respective "random" integers
exchange = [{"M":"Hello!", "r":7}, 
            {"M":"Goodbye!", "r":9}]

commitments = []
messages = []

#Create commitments and keep the results
for i in range(len(exchange)):
    ex = exchange[i]
    (m, c) = pc.commit(ex["M"], ex["r"])
    commitments.append(c)
    messages.append(m)

#Send commitments to the verifier
for c in commitments:
    verifier.add(c)

#Interim period before prover wants to reveal message

#Send messages to the verifier
for m in messages:
    verifier.add(m)

#Verifier computes the challenges with the messages and compares them with the commitments
print(verifier.verify())