def verify(x, t, y, pi, errorOnFail=True):
<EOL>p,_,_ = pi<EOL>assertType(x, str)<EOL>assertType(t, str)<EOL>assertType(y, G1Element)<EOL>assertType(p, G2Element)<EOL>beta = hashG1(t, x)<EOL>q1 = pair(beta, p)<EOL>q2 = pair(y, generatorG2())<EOL>if q1 == q2:<EOL><INDENT>return True<EOL><DEDENT>if errorOnFail:<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT>
Verifies a zero-knowledge proof.
@errorOnFail: Raise an exception if the proof does not hold.