def main(): global group group = PairingGroup('BN256') chch.group = group hess.group = group (g2, alpha, P) = chch.setup() pklist = {} sklist = {} for z in range(0, N): (pklist[z], sklist[z]) = chch.keygen(alpha, "test" + str(z)) Mlist = ["test" + str(z) for z in range(0, N)] S1clist = {} S2clist = {} for z in range(0, N): (S1clist[z], S2clist[z]) = chch.sign(pklist[z], sklist[z], Mlist[z]) assert chch.verify(P, g2, pklist[z], Mlist[z], S1clist[z], S2clist[z]), "invalid signature generated" print("sign & verify for chch: ", z) S1hlist = {} S2hlist = {} for z in range(0, N): (S1hlist[z], S2hlist[z]) = hess.sign(pklist[z], sklist[z], Mlist[z], g2) assert hess.verify(P, g2, pklist[z], Mlist[z], S1hlist[z], S2hlist[z]), "invalid signature generated" print("sign & verify for hess: ", z) assert verify(S1hlist[0], S2hlist[0], S1clist[0], S2clist[0], pklist[0], P, g2, Mlist[0]), "indiv. verification failed for chch-hess combo" print("Successful combo verification!!!") incorrectIndices = batchverify(g2, P, S1clist, pklist, Mlist, S2clist, S2hlist, S1hlist, []) print("incorrectIndices: ", incorrectIndices)
def genValidSignature(message, index, pk, sk, P, g2): sig1 = hess.sign(pk[index], sk[index], message, g2) (S1h, S2h) = sig1 assert hess.verify(P, g2, pk[index], message, S1h, S2h) sig2 = chch.sign(pk[index], sk[index], message) (S1c, S2c) = sig2 assert chch.verify(P, g2, pk[index], message, S1c, S2c) return (S1c, S2c, S1h, S2h)
def genValidSignature(message, index, pk, sk, P, g2): sig = hess.sign(pk[index], sk[index], message, g2) (S1, S2) = sig assert hess.verify(P, g2, pk[index], message, S1, S2) return sig