Exemple #1
0
def runCHP_Batch(verifyArgsDict, group, verifyFuncArgs):
    N = len(verifyArgsDict)

    H = lambda prefix, x: group.H((str(prefix), str(x)), G1)
    H3 = lambda a, b: group.H(('3', str(a), str(b)), ZR)

    deltaz = {}
    dotC = {}
    dotB = {}
    dotA = {}

    for sigIndex in range(0, N):
        deltaz[sigIndex] = prng_bits(group, 80)

    incorrectIndices = []

    dotA_runningProduct = group.init(G1, 1)
    dotB_runningProduct = group.init(G2, 1)
    dotC_runningProduct = group.init(G2, 1)
    for z in range(0, N):
        if (type(verifyArgsDict[z]['message'][bodyKey]['str']) != str):
            sys.exit("member check failed")

        if (type(verifyArgsDict[z]['message'][bodyKey]['t3']) != str):
            sys.exit("member check failed")

        if (group.ismember(verifyArgsDict[z]['sig'][bodyKey]) == False):
            sys.exit("member check failed")

        if (group.ismember(verifyArgsDict[z]['pk'][bodyKey]) == False):
            sys.exit("member check failed")

        if (type(verifyArgsDict[z]['message'][bodyKey]['t1']) != str):
            sys.exit("member check failed")

        if (type(verifyArgsDict[z]['message'][bodyKey]['t2']) != str):
            sys.exit("member check failed")

        if (group.ismember(verifyArgsDict[z]['mpk'][bodyKey]['g']) == False):
            sys.exit("member check failed")

        b = H3(verifyArgsDict[z]['message'][bodyKey]['str'],
               verifyArgsDict[z]['message'][bodyKey]['t3'])

        dotA[z] = verifyArgsDict[z]['sig'][bodyKey]**deltaz[z]

        preA = verifyArgsDict[z]['pk'][bodyKey]**deltaz[z]

        dotB[z] = preA

        dotC[z] = preA**b

    a = H(1, verifyArgsDict[z]['message'][bodyKey]['t1'])
    h = H(2, verifyArgsDict[z]['message'][bodyKey]['t2'])

    verifySigsRecursive(verifyFuncArgs, verifyArgsDict, dotA, dotB, dotC,
                        verifyArgsDict[z]['mpk'][bodyKey]['g'], a, h, 0, N,
                        group, incorrectIndices)

    return incorrectIndices
Exemple #2
0
def runBLS_Batch(verifyArgsDict, group, verifyFuncArgs):
    N = len(verifyArgsDict)

    deltaz = {}
    dotB = {}
    dotA = {}

    for sigIndex in range(0, N):
        deltaz[sigIndex] = prng_bits(group, 80)

    dotA_runningProduct = group.init(G1, 1)
    dotB_runningProduct = group.init(G1, 1)
    for z in range(0, N):

        if type(verifyArgsDict[z][message][bodyKey]) != str:
            sys.exit(
                "The message member of signature number " + z + " has failed the group membership check.  Exiting.\n"
            )

        h = group.hash(verifyArgsDict[z][message][bodyKey], G1)
        dotA[z] = h ** deltaz[z]

        if group.ismember(verifyArgsDict[z]["sig"][bodyKey]) == False:
            sys.exit("The sig member of signature number " + z + " has failed the group membership check.  Exiting.\n")

        dotB[z] = verifyArgsDict[z]["sig"][bodyKey] ** deltaz[z]

    incorrectSigIndices = []

    if group.ismember(verifyArgsDict[0]["pk"][bodyKey]["g^x"]) == False:
        sys.exit("The g^x member of signature number 0 has failed the group membership check.  Exiting.\n")

    if group.ismember(verifyArgsDict[0]["pk"][bodyKey]["g"]) == False:
        sys.exit("The g member of signature number 0 has failed the group membership check.  Exiting.\n")

    verifySigsRecursive(
        verifyFuncArgs,
        verifyArgsDict,
        dotA,
        dotB,
        verifyArgsDict[0]["pk"][bodyKey]["g^x"],
        verifyArgsDict[0]["pk"][bodyKey]["g"],
        0,
        N,
        group,
        incorrectSigIndices,
    )

    return incorrectSigIndices
Exemple #3
0
def runBLS_Batch(verifyArgsDict, group, verifyFuncArgs):
	N = len(verifyArgsDict)

	deltaz = {}
	dotB = {}
	dotA = {}

	for sigIndex in range(0, N):
		deltaz[sigIndex] = prng_bits(group, 80)

	dotA_runningProduct = group.init(G1, 1)
	dotB_runningProduct = group.init(G1, 1)
	for z in range(0, N):
		#if group.isMember(verifyArgsDict[z]['message'][bodyKey]) == False:
			#sys.exit("The message member of signature number " + z + " has failed the group membership check.  Exiting.\n")
		h = group.hash( verifyArgsDict[z]['message'][bodyKey] , G1 )
		dotA[z] =  h ** deltaz[z]

		
		#print("Message:  " + verifyArgsDict[z]['message'][bodyKey])
		#print("DotA:  ", dotA[z])

		#if group.isMember(verifyArgsDict[z]['sig'][bodyKey]) == False:
			#sys.exit("The sig member of signature number " + z + " has failed the group membership check.  Exiting.\n") 

		#print("Sig:  ", verifyArgsDict[z]['sig'][bodyKey])
		#print("Delta:  ", deltaz[z])

		dotB[z] =  verifyArgsDict[z]['sig'][bodyKey] ** deltaz[z] 

		#print("DotB:  ", dotB[z])


	incorrectSigIndices = []

	#if group.isMember( verifyArgsDict[0]['pk'][bodyKey]['g^x'] ) == False:
		#sys.exit("The g^x member of signature number 0 has failed the group membership check.  Exiting.\n")



	#if group.isMember( verifyArgsDict[0]['pk'][bodyKey]['g'] ) == False:
		#sys.exit("The g member of signature number 0 has failed the group membership check.  Exiting.\n")

	verifySigsRecursive(verifyFuncArgs, verifyArgsDict, dotA, dotB,  verifyArgsDict[0]['pk'][bodyKey]['g^x'],  verifyArgsDict[0]['pk'][bodyKey]['g'], 0, N, group, incorrectSigIndices)

	return incorrectSigIndices
Exemple #4
0
def runBLS_Batch(verifyArgsDict, group, verifyFuncArgs):
    N = len(verifyArgsDict)

    deltaz = {}
    dotB = {}
    dotA = {}

    for sigIndex in range(0, N):
        deltaz[sigIndex] = prng_bits(group, 80)

    dotA_runningProduct = group.init(G1, 1)
    dotB_runningProduct = group.init(G1, 1)
    for z in range(0, N):
        #if group.isMember(verifyArgsDict[z]['message'][bodyKey]) == False:
        #sys.exit("The message member of signature number " + z + " has failed the group membership check.  Exiting.\n")
        h = group.hash(verifyArgsDict[z]['message'][bodyKey], G1)
        dotA[z] = h**deltaz[z]

        #print("Message:  " + verifyArgsDict[z]['message'][bodyKey])
        #print("DotA:  ", dotA[z])

        #if group.isMember(verifyArgsDict[z]['sig'][bodyKey]) == False:
        #sys.exit("The sig member of signature number " + z + " has failed the group membership check.  Exiting.\n")

        #print("Sig:  ", verifyArgsDict[z]['sig'][bodyKey])
        #print("Delta:  ", deltaz[z])

        dotB[z] = verifyArgsDict[z]['sig'][bodyKey]**deltaz[z]

        #print("DotB:  ", dotB[z])

    incorrectSigIndices = []

    #if group.isMember( verifyArgsDict[0]['pk'][bodyKey]['g^x'] ) == False:
    #sys.exit("The g^x member of signature number 0 has failed the group membership check.  Exiting.\n")

    #if group.isMember( verifyArgsDict[0]['pk'][bodyKey]['g'] ) == False:
    #sys.exit("The g member of signature number 0 has failed the group membership check.  Exiting.\n")

    verifySigsRecursive(verifyFuncArgs, verifyArgsDict, dotA, dotB,
                        verifyArgsDict[0]['pk'][bodyKey]['g^x'],
                        verifyArgsDict[0]['pk'][bodyKey]['g'], 0, N, group,
                        incorrectSigIndices)

    return incorrectSigIndices
Exemple #5
0
	H2 = lambda x,y: group.H((x,y), ZR)
	N = 3

	deltaz = {}
	dotB = {}
	dotA = {}

	for sigIndex in range(0, numSigs):
		deltaz[sigIndex] = prng_bits(group, 80)

	dotA_runningProduct = group.init(G1, 1)
	dotB_runningProduct = group.init(G1, 1)
	for z in range(0, N):
		for arg in verifyFuncArgs:
			if (sigNumKey in verifyArgsDict[z][arg]):
				argSigIndexMap[arg] = int(verifyArgsDict[z][arg][sigNumKey])
			else:
				argSigIndexMap[arg] = z

		S1 = verifyArgsDict[argSigIndexMap['sig']]['sig'][bodyKey][ 'S1' ]
		S2 = verifyArgsDict[argSigIndexMap['sig']]['sig'][bodyKey][ 'S2' ]
		a = H2( verifyArgsDict[argSigIndexMap['M']]['M'][bodyKey] , verifyArgsDict[argSigIndexMap['sig']]['sig'][bodyKey][ 'S1' ]  )


		dotA[z] =  S2 ** deltaz[z] 

		dotB[z] =  ( S1 * verifyArgsDict[argSigIndexMap['pk']]['pk'][bodyKey] ** a ) ** deltaz[z] 


	verifySigsRecursive(verifyFuncArgs, argSigIndexMap, verifyArgsDict, dotA, dotB,  verifyArgsDict[argSigIndexMap['mpk']]['mpk'][bodyKey]['g2'],  verifyArgsDict[argSigIndexMap['mpk']]['mpk'][bodyKey]['P'], 0, N)
Exemple #6
0
	dotA_runningProduct = group.init(G1, 1)
	dotB_runningProduct = group.init(G1, 1)
	dotD_runningProduct = group.init(G1, 1)
	sumE_runningProduct = group.init(ZR, 0)
	for z in range(0, N):
		for arg in verifyFuncArgs:
			if (sigNumKey in verifyArgsDict[z][arg]):
				argSigIndexMap[arg] = int(verifyArgsDict[z][arg][sigNumKey])
			else:
				argSigIndexMap[arg] = z

		S1 = verifyArgsDict[argSigIndexMap['sig']]['sig'][bodyKey][ 'S1' ]
		S2 = verifyArgsDict[argSigIndexMap['sig']]['sig'][bodyKey][ 'S2' ]
		S3 = verifyArgsDict[argSigIndexMap['sig']]['sig'][bodyKey][ 'S3' ]


		dotA[z] =  S1 ** deltaz[z] 

		dotB[z] =  S2 ** deltaz[z] 

		dotD[z] =  S3 ** deltaz[z] 

		sumE[z] =  deltaz[z] 


	A = verifyArgsDict[argSigIndexMap['mpk']]['mpk'][bodyKey][ 'A' ]


	verifySigsRecursive(group, deltaz, verifyFuncArgs, argSigIndexMap, verifyArgsDict, dotA, dotB, dotD, sumE,  verifyArgsDict[argSigIndexMap['mpk']]['mpk'][bodyKey]['g2'],  verifyArgsDict[argSigIndexMap['mpk']]['mpk'][bodyKey]['u1b'],  verifyArgsDict[argSigIndexMap['mpk']]['mpk'][bodyKey]['u2b'], A, 0, N)
Exemple #7
0
def runCHP_Batch(verifyArgsDict, group, verifyFuncArgs):
	N = len(verifyArgsDict)

	H = lambda prefix,x: group.H((str(prefix), str(x)), G1)
	H3 = lambda a,b: group.H(('3', str(a), str(b)), ZR)

	deltaz = {}
	dotC = {}
	dotB = {}
	dotA = {}

	for sigIndex in range(0, N):
		deltaz[sigIndex] = prng_bits(group, 80)

	incorrectIndices = []

	dotA_runningProduct = group.init(G1, 1)
	dotB_runningProduct = group.init(G2, 1)
	dotC_runningProduct = group.init(G2, 1)
	for z in range(0, N):
		if (type(verifyArgsDict[z]['message'][bodyKey][ 'str' ]) != str):
			sys.exit("member check failed")

		if (type(verifyArgsDict[z]['message'][bodyKey][ 't3' ]) != str):
			sys.exit("member check failed")

		if (group.ismember(verifyArgsDict[z]['sig'][bodyKey]) == False):
			sys.exit("member check failed")

		if (group.ismember(verifyArgsDict[z]['pk'][bodyKey]) == False):
			sys.exit("member check failed")

		if (type(verifyArgsDict[z]['message'][bodyKey][ 't1' ]) != str):
			sys.exit("member check failed")

		if (type(verifyArgsDict[z]['message'][bodyKey][ 't2' ]) != str):
			sys.exit("member check failed")

		if (group.ismember(verifyArgsDict[z]['mpk'][bodyKey]['g']) == False):
			sys.exit("member check failed")


		b = H3( verifyArgsDict[z]['message'][bodyKey][ 'str' ] , verifyArgsDict[z]['message'][bodyKey][ 't3' ]  )


		dotA[z] =  verifyArgsDict[z]['sig'][bodyKey] ** deltaz[z] 

		preA =  verifyArgsDict[z]['pk'][bodyKey] ** deltaz[z] 

		dotB[z] =  preA 

		dotC[z] =  preA ** b 


	a = H( 1 , verifyArgsDict[z]['message'][bodyKey][ 't1' ]  )
	h = H( 2 , verifyArgsDict[z]['message'][bodyKey][ 't2' ]  )


	verifySigsRecursive(verifyFuncArgs, verifyArgsDict, dotA, dotB, dotC,  verifyArgsDict[z]['mpk'][bodyKey]['g'], a, h, 0, N, group, incorrectIndices)

	return incorrectIndices
Exemple #8
0
			else:
				argSigIndexMap[arg] = z



		# Group membership checks
		if (type( verifyArgsDict[argSigIndexMap['message']]['message'][bodyKey] ) != str):
			sys.exit("Group membership check failed")

		if (group.ismember( verifyArgsDict[argSigIndexMap['sig']]['sig'][bodyKey] ) == False):
			sys.exit("Group membership check failed")

		if (group.ismember( verifyArgsDict[argSigIndexMap['pk']]['pk'][bodyKey]['g^x'] ) == False):
			sys.exit("Group membership check failed")

		if (group.ismember( verifyArgsDict[argSigIndexMap['pk']]['pk'][bodyKey]['g'] ) == False):
			sys.exit("Group membership check failed")
		


		# Begin scheme-specific code used for precomputed dot products
		h = group.hash( verifyArgsDict[argSigIndexMap['message']]['message'][bodyKey] , G1 )
		dotA[z] =  h ** deltaz[z] 
		dotB[z] =  verifyArgsDict[argSigIndexMap['sig']]['sig'][bodyKey] ** deltaz[z] 


	#Recursive algorithm that handles divide-and-conquer
	verifySigsRecursive(group, verifyFuncArgs, argSigIndexMap, verifyArgsDict, dotA, dotB,  verifyArgsDict[argSigIndexMap['pk']]['pk'][bodyKey]['g^x'],  verifyArgsDict[argSigIndexMap['pk']]['pk'][bodyKey]['g'], 0, N)

	print("here")
Exemple #9
0
    dotB = {}
    dotA = {}

    for sigIndex in range(0, numSigs):
        deltaz[sigIndex] = prng_bits(group, 80)

    dotA_runningProduct = group.init(G1, 1)
    dotB_runningProduct = group.init(G1, 1)
    for z in range(0, N):
        for arg in verifyFuncArgs:
            if (sigNumKey in verifyArgsDict[z][arg]):
                argSigIndexMap[arg] = int(verifyArgsDict[z][arg][sigNumKey])
            else:
                argSigIndexMap[arg] = z

        S1 = verifyArgsDict[argSigIndexMap['sig']]['sig'][bodyKey]['S1']
        S2 = verifyArgsDict[argSigIndexMap['sig']]['sig'][bodyKey]['S2']
        a = H2(verifyArgsDict[argSigIndexMap['M']]['M'][bodyKey],
               verifyArgsDict[argSigIndexMap['sig']]['sig'][bodyKey]['S1'])

        dotA[z] = S2**deltaz[z]

        dotB[z] = (
            S1 *
            verifyArgsDict[argSigIndexMap['pk']]['pk'][bodyKey]**a)**deltaz[z]

    verifySigsRecursive(
        verifyFuncArgs, argSigIndexMap, verifyArgsDict, dotA, dotB,
        verifyArgsDict[argSigIndexMap['mpk']]['mpk'][bodyKey]['g2'],
        verifyArgsDict[argSigIndexMap['mpk']]['mpk'][bodyKey]['P'], 0, N)
Exemple #10
0
            if (sigNumKey in verifyArgsDict[z][arg]):
                argSigIndexMap[arg] = int(verifyArgsDict[z][arg][sigNumKey])
            else:
                argSigIndexMap[arg] = z

        u = verifyArgsDict[argSigIndexMap['sig']]['sig'][bodyKey]['u']
        S = verifyArgsDict[argSigIndexMap['sig']]['sig'][bodyKey]['S']
        Lt = ""
        for i in verifyArgsDict[argSigIndexMap['L']]['L'][bodyKey]:
            Lt = Lt + ":" + i
        num_signers = len(verifyArgsDict[argSigIndexMap['L']]['L'][bodyKey])
        h = [group.init(ZR, 1) for i in range(num_signers)]
        for i in range(num_signers):
            h[i] = H2(verifyArgsDict[argSigIndexMap['M']]['M'][bodyKey], Lt,
                      u[i])
        pk = [
            H1(i) for i in verifyArgsDict[argSigIndexMap['L']]['L'][bodyKey]
        ]  # get all signers pub keys

        dotA_runningProduct = group.init(G1, 1)
        for y in range(0, l):
            dotA[y] = (u[a] * pk[a]**h[a])
            dotA_runningProduct = dotA_runningProduct * dotA[y]

        dotB[z] = dotA_runningProduct**deltaz[z]

        dotC[z] = S**deltaz[z]

    verifySigsRecursive(verifyFuncArgs, argSigIndexMap, verifyArgsDict, dotB,
                        dotC, 0, N)
Exemple #11
0
		S = verifyArgsDict[argSigIndexMap['sig']]['sig'][bodyKey][ 'S' ]
		t = verifyArgsDict[argSigIndexMap['sig']]['sig'][bodyKey][ 't' ]


		preA =  S[y] ** deltaz[z] 

		dotA[z] =  preA 

		dotB[z] =  preA ** verifyArgsDict[argSigIndexMap['M']]['M'][bodyKey] 

		dotC[z] =  preA ** t 


	sumE_runningProduct = group.init(ZR, 0)
	for z in range(0, N):
		for arg in verifyFuncArgs:
			if (sigNumKey in verifyArgsDict[z][arg]):
				argSigIndexMap[arg] = int(verifyArgsDict[z][arg][sigNumKey])
			else:
				argSigIndexMap[arg] = z



		sumE[z] =  deltaz[z] 


	D = pair( verifyArgsDict[argSigIndexMap['mpk']]['mpk'][bodyKey][ 'g1' ] , verifyArgsDict[argSigIndexMap['mpk']]['mpk'][bodyKey][ 'g2' ]  )


	verifySigsRecursive(verifyFuncArgs, argSigIndexMap, verifyArgsDict, dotA, dotB, dotC, sumE, D, 0, N)
Exemple #12
0
    dotB_runningProduct = group.init(G1, 1)
    dotD_runningProduct = group.init(G1, 1)
    sumE_runningProduct = group.init(ZR, 0)
    for z in range(0, N):
        for arg in verifyFuncArgs:
            if (sigNumKey in verifyArgsDict[z][arg]):
                argSigIndexMap[arg] = int(verifyArgsDict[z][arg][sigNumKey])
            else:
                argSigIndexMap[arg] = z

        S1 = verifyArgsDict[argSigIndexMap['sig']]['sig'][bodyKey]['S1']
        S2 = verifyArgsDict[argSigIndexMap['sig']]['sig'][bodyKey]['S2']
        S3 = verifyArgsDict[argSigIndexMap['sig']]['sig'][bodyKey]['S3']

        dotA[z] = S1**deltaz[z]

        dotB[z] = S2**deltaz[z]

        dotD[z] = S3**deltaz[z]

        sumE[z] = deltaz[z]

    A = verifyArgsDict[argSigIndexMap['mpk']]['mpk'][bodyKey]['A']

    verifySigsRecursive(
        group, deltaz, verifyFuncArgs, argSigIndexMap, verifyArgsDict, dotA,
        dotB, dotD, sumE,
        verifyArgsDict[argSigIndexMap['mpk']]['mpk'][bodyKey]['g2'],
        verifyArgsDict[argSigIndexMap['mpk']]['mpk'][bodyKey]['u1b'],
        verifyArgsDict[argSigIndexMap['mpk']]['mpk'][bodyKey]['u2b'], A, 0, N)
Exemple #13
0
def batch(verifyParamFilesArg, groupParamArg):
	#if ( (len(sys.argv) != 3) or (sys.argv[1] == "-help") or (sys.argv[1] == "--help") ):
		#sys.exit("\nUsage:  python BatchVerifyTemplate.py [filename of pickled Python dictionary with verify function arguments] [path and filename of group param file]\n")
	#verifyParamFilesArg = sys.argv[1]
	verifyParamFiles = open(verifyParamFilesArg, 'rb').read()
	groupParamArg = PairingGroup(groupParamArg)
	verifyParamFilesDict = deserializeDict( unpickleObject( verifyParamFiles ) , groupParamArg )
	verifyArgsDict = {}
	numSigs = len(verifyParamFilesDict)
	lenRepeatSuffix = len(repeatSuffix)
	verifyFuncArgs = list(verifyParamFilesDict[1].keys())

	for sigIndex in range(0, numSigs):
		verifyArgsDict[sigIndex] = {}
		for arg in verifyFuncArgs:
			verifyArgsDict[sigIndex][arg] = {}
			verifyParamFile = str(verifyParamFilesDict[sigIndex][arg])
			if (verifyParamFile.endswith(charmPickleSuffix)):
				verifyParamPickle = open(verifyParamFile, 'rb').read()
				verifyArgsDict[sigIndex][arg][bodyKey] = deserializeDict( unpickleObject( verifyParamPickle ) , groupParamArg )
				#if groupParamArg.isMember( verifyArgsDict[sigIndex][arg][bodyKey] ) == False:
					#sys.exit("The " + arg + " member of signature number " + sigIndex + " has failed the group membership check.  Exiting.\n")
			elif (verifyParamFile.endswith(pythonPickleSuffix)):
				verifyParamPickle = open(verifyParamFile, 'rb')
				verifyArgsDict[sigIndex][arg][bodyKey] = pickle.load(verifyParamPickle)
			elif (verifyParamFile.endswith(repeatSuffix)):
				verifyArgsDict[sigIndex][arg][sigNumKey] = verifyParamFile[0:(len(verifyParamFile) - lenRepeatSuffix)]
			else:
				tempFile = open(verifyParamFile, 'rb')
				tempBuf = tempFile.read()
				verifyArgsDict[sigIndex][arg][bodyKey] = tempBuf

	argSigIndexMap = {}

	group = pairing('/Users/matt/Documents/charm/param/a.param')
	H1 = lambda x: group.H(('1', str(x)), G1)
	H2 = lambda a, b, c: group.H(('2', a, b, c), ZR)
	lam_func = lambda i,a,b,c: a[i] * (b[i] ** c[i]) # => u * (pk ** h) for all signers
	N = 3
	l = 5

	deltaz = {}
	dotC = {}
	dotB = {}
	dotA = {}

	for sigIndex in range(0, numSigs):
		deltaz[sigIndex] = prng_bits(group, 80)

	dotB_runningProduct = group.init(G1, 1)
	dotC_runningProduct = group.init(G1, 1)
	for z in range(0, N):
		for arg in verifyFuncArgs:
			if (sigNumKey in verifyArgsDict[z][arg]):
				argSigIndexMap[arg] = int(verifyArgsDict[z][arg][sigNumKey])
			else:
				argSigIndexMap[arg] = z

		u = verifyArgsDict[argSigIndexMap['sig']]['sig'][bodyKey][ 'u' ]
		S = verifyArgsDict[argSigIndexMap['sig']]['sig'][bodyKey][ 'S' ]
		Lt = ""
		for i in verifyArgsDict[argSigIndexMap['L']]['L'][bodyKey] :
			Lt = Lt + ":" + i
		num_signers = len( verifyArgsDict[argSigIndexMap['L']]['L'][bodyKey] )
		h = [ group.init( ZR , 1 ) for i in range( num_signers )  ]
		for i in range( num_signers )  :
			h [ i ] = H2( verifyArgsDict[argSigIndexMap['M']]['M'][bodyKey] , Lt , u [ i ]  )
		pk = [ H1( i ) for i in verifyArgsDict[argSigIndexMap['L']]['L'][bodyKey] ] # get all signers pub keys


		dotA_runningProduct = group.init(G1, 1)
		for y in range(0, l):
			dotA =  ( u[y] * pk[y] ** h[y] ) 
			dotA_runningProduct = dotA_runningProduct * dotA

		dotB[z] =  dotA_runningProduct ** deltaz[z] 

		dotC[z] =  S ** deltaz[z] 


	verifySigsRecursive(verifyFuncArgs, argSigIndexMap, verifyArgsDict, dotB, dotC,  verifyArgsDict[argSigIndexMap['mpk']]['mpk'][bodyKey]['Pub'],  verifyArgsDict[argSigIndexMap['mpk']]['mpk'][bodyKey]['g'], 0, N)
Exemple #14
0
def batch(verifyParamFilesArg, groupParamArg):
    #if ( (len(sys.argv) != 3) or (sys.argv[1] == "-help") or (sys.argv[1] == "--help") ):
    #sys.exit("\nUsage:  python BatchVerifyTemplate.py [filename of pickled Python dictionary with verify function arguments] [path and filename of group param file]\n")
    #verifyParamFilesArg = sys.argv[1]
    verifyParamFiles = open(verifyParamFilesArg, 'rb').read()
    groupParamArg = PairingGroup(groupParamArg)
    verifyParamFilesDict = deserializeDict(unpickleObject(verifyParamFiles),
                                           groupParamArg)
    verifyArgsDict = {}
    numSigs = len(verifyParamFilesDict)
    lenRepeatSuffix = len(repeatSuffix)
    verifyFuncArgs = list(verifyParamFilesDict[1].keys())

    for sigIndex in range(0, numSigs):
        verifyArgsDict[sigIndex] = {}
        for arg in verifyFuncArgs:
            verifyArgsDict[sigIndex][arg] = {}
            verifyParamFile = str(verifyParamFilesDict[sigIndex][arg])
            if (verifyParamFile.endswith(charmPickleSuffix)):
                verifyParamPickle = open(verifyParamFile, 'rb').read()
                verifyArgsDict[sigIndex][arg][bodyKey] = deserializeDict(
                    unpickleObject(verifyParamPickle), groupParamArg)
                #if groupParamArg.isMember( verifyArgsDict[sigIndex][arg][bodyKey] ) == False:
                #sys.exit("The " + arg + " member of signature number " + sigIndex + " has failed the group membership check.  Exiting.\n")
            elif (verifyParamFile.endswith(pythonPickleSuffix)):
                verifyParamPickle = open(verifyParamFile, 'rb')
                verifyArgsDict[sigIndex][arg][bodyKey] = pickle.load(
                    verifyParamPickle)
            elif (verifyParamFile.endswith(repeatSuffix)):
                verifyArgsDict[sigIndex][arg][sigNumKey] = verifyParamFile[0:(
                    len(verifyParamFile) - lenRepeatSuffix)]
            else:
                tempFile = open(verifyParamFile, 'rb')
                tempBuf = tempFile.read()
                verifyArgsDict[sigIndex][arg][bodyKey] = tempBuf

    argSigIndexMap = {}

    group = pairing('/Users/matt/Documents/charm/param/a.param')
    H1 = lambda x: group.H(('1', str(x)), G1)
    H2 = lambda a, b, c: group.H(('2', a, b, c), ZR)
    lam_func = lambda i, a, b, c: a[i] * (b[i]**c[i]
                                          )  # => u * (pk ** h) for all signers
    N = 3
    l = 5

    deltaz = {}
    dotC = {}
    dotB = {}
    dotA = {}

    for sigIndex in range(0, numSigs):
        deltaz[sigIndex] = prng_bits(group, 80)

    dotB_runningProduct = group.init(G1, 1)
    dotC_runningProduct = group.init(G1, 1)
    for z in range(0, N):
        for arg in verifyFuncArgs:
            if (sigNumKey in verifyArgsDict[z][arg]):
                argSigIndexMap[arg] = int(verifyArgsDict[z][arg][sigNumKey])
            else:
                argSigIndexMap[arg] = z

        u = verifyArgsDict[argSigIndexMap['sig']]['sig'][bodyKey]['u']
        S = verifyArgsDict[argSigIndexMap['sig']]['sig'][bodyKey]['S']
        Lt = ""
        for i in verifyArgsDict[argSigIndexMap['L']]['L'][bodyKey]:
            Lt = Lt + ":" + i
        num_signers = len(verifyArgsDict[argSigIndexMap['L']]['L'][bodyKey])
        h = [group.init(ZR, 1) for i in range(num_signers)]
        for i in range(num_signers):
            h[i] = H2(verifyArgsDict[argSigIndexMap['M']]['M'][bodyKey], Lt,
                      u[i])
        pk = [
            H1(i) for i in verifyArgsDict[argSigIndexMap['L']]['L'][bodyKey]
        ]  # get all signers pub keys

        dotA_runningProduct = group.init(G1, 1)
        for y in range(0, l):
            dotA = (u[y] * pk[y]**h[y])
            dotA_runningProduct = dotA_runningProduct * dotA

        dotB[z] = dotA_runningProduct**deltaz[z]

        dotC[z] = S**deltaz[z]

    verifySigsRecursive(
        verifyFuncArgs, argSigIndexMap, verifyArgsDict, dotB, dotC,
        verifyArgsDict[argSigIndexMap['mpk']]['mpk'][bodyKey]['Pub'],
        verifyArgsDict[argSigIndexMap['mpk']]['mpk'][bodyKey]['g'], 0, N)