Example #1
0
def shuffleQuestion(question):
    orig = CiphertextCollection(pk)
    for ballot in ballots[question]:
        ciphertext = Ciphertext(nbits, orig._pk_fingerprint)

        for choice in ballot["choices"]:
            ciphertext.append(long(choice["alpha"]), long(choice["beta"]))

        orig.add_ciphertext(ciphertext)

    print("Shuffling answers for question " + str(question))
    shuf, proof = orig.shuffle_with_proof()

    shufs_list.append(shuf.to_dict())
    proofs_list.append(proof.to_dict())

    print("Shuffle complete for question " + str(question))
Example #2
0
def shuffleQuestion(question):
	orig = CiphertextCollection(pk)
	for ballot in ballots[question]:
		ciphertext = Ciphertext(nbits, orig._pk_fingerprint)
		
		for choice in ballot["choices"]:
			ciphertext.append(long(choice["alpha"]), long(choice["beta"]))
		
		orig.add_ciphertext(ciphertext)
	
	print("Shuffling answers for question " + str(question))
	shuf, proof = orig.shuffle_with_proof()
	
	shufs_list.append(shuf.to_dict())
	proofs_list.append(proof.to_dict())
	
	print("Shuffle complete for question " + str(question))
Example #3
0
	trusteeThreshold = int(election['trustee_threshold'])

# Verify mixes
for i in xrange(0, numMixnets):
	index = numMixnets - i - 1
	for q in xrange(0, numQuestions):
		with statusCheck("Verifying mix " + str(index) + " question " + str(q)):
			proof = ShufflingProof.from_dict(mixnets[index][1][q], pk, nbits)
			
			orig = CiphertextCollection(pk)
			if i == 0:
				for ballot in ballots:
					ciphertext = Ciphertext(nbits, orig._pk_fingerprint)
					for block in ballot["vote"]["answers"][q]["choices"]:
						ciphertext.append(long(block["alpha"]), long(block["beta"]))
					orig.add_ciphertext(ciphertext)
			else:
				for ballot in mixnets[index + 1][0][q]["answers"]:
					ciphertext = Ciphertext(nbits, orig._pk_fingerprint)
					for block in ballot["choices"]:
						ciphertext.append(long(block["alpha"]), long(block["beta"]))
					orig.add_ciphertext(ciphertext)
			
			shuf = CiphertextCollection(pk)
			for ballot in mixnets[index][0][q]["answers"]:
				ciphertext = Ciphertext(nbits, shuf._pk_fingerprint)
				for block in ballot["choices"]:
					ciphertext.append(long(block["alpha"]), long(block["beta"]))
				shuf.add_ciphertext(ciphertext)
			
			# Check the challenge ourselves to provide a more informative error message
Example #4
0
with statusCheck("Verifying mixes") as sc0:
	for i in xrange(0, numMixnets):
		index = numMixnets - i - 1
		with statusCheck("Verifying mix " + str(index), sc0) as sc:
			for q in xrange(0, numQuestions):
				with statusCheck("Verifying mix " + str(index) + " question " + str(q), sc) as sc2:
					proof = ShufflingProof.from_dict(mixnets[index][1][q], pk, nbits)
					
					orig = CiphertextCollection(pk)
					if i == 0:
						for ballot in ballots:
							ciphertext = Ciphertext(nbits, orig._pk_fingerprint)
							for block in ballot["vote"]["answers"][q]["choices"]:
								ciphertext.append(long(block["alpha"]), long(block["beta"]))
							orig.add_ciphertext(ciphertext)
					else:
						for ballot in mixnets[index + 1][0][q]["answers"]:
							ciphertext = Ciphertext(nbits, orig._pk_fingerprint)
							for block in ballot["choices"]:
								ciphertext.append(long(block["alpha"]), long(block["beta"]))
							orig.add_ciphertext(ciphertext)
					
					shuf = CiphertextCollection(pk)
					for ballot in mixnets[index][0][q]["answers"]:
						ciphertext = Ciphertext(nbits, shuf._pk_fingerprint)
						for block in ballot["choices"]:
							ciphertext.append(long(block["alpha"]), long(block["beta"]))
						shuf.add_ciphertext(ciphertext)
					
					# Check the challenge ourselves to provide a more informative error message