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
		mixedAnswers = json.loads(get_file("/mixnets/" + str(i) + "/answers"))
		shufflingProof = json.loads(get_file("/mixnets/" + str(i) + "/proof"))
		mixnets.append((mixedAnswers, shufflingProof))
	
	# Trustees
	trustees = json.loads(get_file("/trustees"))
	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"]:
Example #4
0
			if ballot['vote']['election_hash'] != fingerprint:
				sc2.fail("Election fingerprint does not match")
			vote_json = json.dumps(ballot["vote"], sort_keys=True, separators=(',', ':')) # This is generated by Javascript, so no spaces
			vote_fingerprint = base64.b64encode(hashlib.sha256(vote_json).digest())[:-1]
			if ballot['vote_hash'] != vote_fingerprint:
				sc2.fail("Vote fingerprint does not match")

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"]: