def dividenconquer(delta, startSigNum, endSigNum, incorrectIndices, dotBCache, dotACache, sumECache, dotDCache, A, IDlist, Mlist, S1list, S2list, S3list, g2, u1b, u2b, ub): dotBLoopVal = 1 dotALoopVal = 1 sumELoopVal = 0 dotDLoopVal = 1 for z in range(startSigNum, endSigNum): dotBLoopVal = (dotBLoopVal * dotBCache[z]) dotALoopVal = (dotALoopVal * dotACache[z]) sumELoopVal = (sumELoopVal + sumECache[z]) dotDLoopVal = (dotDLoopVal * dotDCache[z]) dotFLoopVal = 1 for y in range(0, l): dotCLoopVal = 1 for z in range(startSigNum, endSigNum): k = stringToInt(group, IDlist[z], l, zz) m = stringToInt(group, Mlist[z], l, zz) dotCLoopVal = (dotCLoopVal * ((S2list[z] ** (delta[z] * k[y])) * (S3list[z] ** (delta[z] * m[y])))) dotFLoopVal = (dotFLoopVal * pair(dotCLoopVal, ub[y])) if ( ( ((pair(dotALoopVal, g2) * ((pair(dotBLoopVal, u1b) * dotFLoopVal) * pair(dotDLoopVal, u2b)))) == ((A ** sumELoopVal)) ) ): return else: midwayFloat = ((endSigNum - startSigNum) / 2) midway = int(midwayFloat) if ( ( (midway) == (0) ) ): incorrectIndices.append(startSigNum) output = None else: midSigNum = (startSigNum + midway) dividenconquer(delta, startSigNum, midSigNum, incorrectIndices, dotBCache, dotACache, sumECache, dotDCache, A, IDlist, Mlist, S1list, S2list, S3list, g2, u1b, u2b, ub) dividenconquer(delta, midSigNum, endSigNum, incorrectIndices, dotBCache, dotACache, sumECache, dotDCache, A, IDlist, Mlist, S1list, S2list, S3list, g2, u1b, u2b, ub) output = None
def verify(A, g2, ub, u1b, u2b, ID, M, S1, S2, S3): kver = stringToInt(group, ID, l, zz) mver = stringToInt(group, M, l, zz) dotProd2 = 1 dotProd3 = 1 for i in range(0, l): dotProd2 = (dotProd2 * (ub[i] ** kver[i])) dotProd3 = (dotProd3 * (ub[i] ** mver[i])) if ( ( ((pair(S1, g2) * (pair(S2, (u1b * dotProd2)) * pair(S3, (u2b * dotProd3))))) == (A) ) ): output = True else: output = False return output return output
def verify(A, g2, ub, u1b, u2b, ID, M, S1, S2, S3): kver = stringToInt(group, ID, l, zz) mver = stringToInt(group, M, l, zz) dotProd2 = 1 dotProd3 = 1 for i in range(0, l): dotProd2 = (dotProd2 * (ub[i]**kver[i])) dotProd3 = (dotProd3 * (ub[i]**mver[i])) if ((((pair(S1, g2) * (pair(S2, (u1b * dotProd2)) * pair(S3, (u2b * dotProd3))))) == (A))): output = True else: output = False return output return output
def keygen(mpk, u, msk, ID): g1, g2, A, u1t, u2t, u1b, u2b = mpk k = stringToInt(group, ID, l, zz) dotProd = 1 for i in range(0, l): dotProd = (dotProd * (u[i] ** k[i])) r = group.random(ZR) k1 = (msk * ((u1t * dotProd) ** r)) k2 = (g1 ** -r) sk = [k1, k2] output = sk return output
def keygen(mpk, u, msk, ID): g1, g2, A, u1t, u2t, u1b, u2b = mpk k = stringToInt(group, ID, l, zz) dotProd = 1 for i in range(0, l): dotProd = (dotProd * (u[i]**k[i])) r = group.random(ZR) k1 = (msk * ((u1t * dotProd)**r)) k2 = (g1**-r) sk = [k1, k2] output = sk return output
def dividenconquer(delta, startSigNum, endSigNum, incorrectIndices, dotBCache, dotACache, sumECache, dotDCache, A, IDlist, Mlist, S1list, S2list, S3list, g2, u1b, u2b, ub): dotBLoopVal = 1 dotALoopVal = 1 sumELoopVal = 0 dotDLoopVal = 1 for z in range(startSigNum, endSigNum): dotBLoopVal = (dotBLoopVal * dotBCache[z]) dotALoopVal = (dotALoopVal * dotACache[z]) sumELoopVal = (sumELoopVal + sumECache[z]) dotDLoopVal = (dotDLoopVal * dotDCache[z]) dotFLoopVal = 1 for y in range(0, l): dotCLoopVal = 1 for z in range(startSigNum, endSigNum): k = stringToInt(group, IDlist[z], l, zz) m = stringToInt(group, Mlist[z], l, zz) dotCLoopVal = (dotCLoopVal * ((S2list[z]**(delta[z] * k[y])) * (S3list[z]**(delta[z] * m[y])))) dotFLoopVal = (dotFLoopVal * pair(dotCLoopVal, ub[y])) if ((((pair(dotALoopVal, g2) * ((pair(dotBLoopVal, u1b) * dotFLoopVal) * pair(dotDLoopVal, u2b))) ) == ((A**sumELoopVal)))): return else: midwayFloat = ((endSigNum - startSigNum) / 2) midway = int(midwayFloat) if (((midway) == (0))): incorrectIndices.append(startSigNum) output = None else: midSigNum = (startSigNum + midway) dividenconquer(delta, startSigNum, midSigNum, incorrectIndices, dotBCache, dotACache, sumECache, dotDCache, A, IDlist, Mlist, S1list, S2list, S3list, g2, u1b, u2b, ub) dividenconquer(delta, midSigNum, endSigNum, incorrectIndices, dotBCache, dotACache, sumECache, dotDCache, A, IDlist, Mlist, S1list, S2list, S3list, g2, u1b, u2b, ub) output = None
def sign(mpk, u, sk, M): g1, g2, A, u1t, u2t, u1b, u2b = mpk m = stringToInt(group, M, l, zz) k1, k2 = sk s = group.random(ZR) dotProd1 = 1 for i in range(0, l): dotProd1 = (dotProd1 * (u[i] ** m[i])) S1 = (k1 * ((u2t * dotProd1) ** s)) S2 = k2 S3 = (g1 ** -s) output = (S1, S2, S3) return output
def sign(mpk, u, sk, M): g1, g2, A, u1t, u2t, u1b, u2b = mpk m = stringToInt(group, M, l, zz) k1, k2 = sk s = group.random(ZR) dotProd1 = 1 for i in range(0, l): dotProd1 = (dotProd1 * (u[i]**m[i])) S1 = (k1 * ((u2t * dotProd1)**s)) S2 = k2 S3 = (g1**-s) output = (S1, S2, S3) return output