# core imports import sys import base, data, filenames # use the meeting1 and meeting2 data structures too import meeting1, meeting2 election, committed_p_table = meeting1.election, meeting1.p_table # third meeting meeting_three_in_xml = base.file_in_dir(base.DATA_PATH, filenames.MEETING_THREE_IN, 'Meeting Three In') meeting_three_out_xml = base.file_in_dir(base.DATA_PATH, filenames.MEETING_THREE_OUT, 'Meeting Three Out') meeting_three_out_codes_xml = base.file_in_dir(base.DATA_PATH, filenames.MEETING_THREE_OUT_CODES, 'Meeting Three Out Codes') # parse the ballot confirmation code commitments ballots = data.parse_ballot_table(meeting2.meeting_two_out_commitments_xml) # get the P table of actual votes p_table_votes = data.PTable() p_table_votes.parse(meeting_three_in_xml.find('print')) # get the opening of the ballot confirmation code commitments ballots_with_codes = data.parse_ballot_table(meeting_three_out_codes_xml) def verify(output_stream, codes_output_stream=None): # make sure none of the actual votes use ballots that were audited in Meeting2: assert set(p_table_votes.rows.keys()).isdisjoint(set(meeting2.challenge_row_ids)) if codes_output_stream: BALLOTS = {} def new_code(webSerial, pid, q_id, s_id, confirmation_code):
# based on meeting2, and meeting3 for the ballots which aren't needed for parsing until then, nothing in meeting4 needed import meeting1, meeting2 # use provisional ballots try: import meeting3provisional as meeting3 except: filenames.reset() import meeting3 election = meeting1.election ballots, cast_ballots = meeting3.ballots, meeting3.ballots_with_codes # contested ballots reveal contested_ballots_reply_xml = base.file_in_dir(base.DATA_PATH, filenames.CONTESTED_BALLOTS_REPLY, 'Reply to Contested Ballots') contested_ballots = data.parse_ballot_table(contested_ballots_reply_xml) def verify(output_stream, codes_output_stream=None): if codes_output_stream: codes_output_stream.write('Serial #,P-table ID') for q_id in sorted(contested_ballots.values()[0].questions.keys()): codes_output_stream.write(",question %s"%q_id) codes_output_stream.write("\n") # for each contested ballot: for contested_ballot in contested_ballots.values(): # is it a cast ballot? assert cast_ballots.has_key(contested_ballot.pid) # does it verify against the original ballots
CODES_FILE_PATH is the path to a file which, when provided, will be where this script writes its list of confirmation codes for each ballot. """ # core imports import sys import base, data, filenames # based on meeting2, and meeting3 for the ballots import meeting1, meeting2, meeting3 election = meeting1.election ballots, cast_ballots = meeting3.ballots, meeting3.ballots_with_codes # spoiled ballots codes spoiled_ballots_codes_xml = base.file_in_dir(base.DATA_PATH, filenames.SPOILED_BALLOTS_CODES, 'Spoiled Ballots Codes') spoiled_ballots = data.parse_ballot_table(spoiled_ballots_codes_xml) # spoiled ballots mixnet spoiled_ballots_mixnet_xml = base.file_in_dir(base.DATA_PATH, filenames.SPOILED_BALLOTS_MIXNET, 'Spoiled Ballots Mixnet') spoiled_p_table, spoiled_partitions = data.parse_database(spoiled_ballots_mixnet_xml) def verify(output_stream, codes_output_stream=None): if codes_output_stream: BALLOTS = {} def new_code(webSerial, pid, q_id, s_id, confirmation_code): if not BALLOTS.has_key(webSerial): BALLOTS[webSerial] = {'pid': pid, 'questions': {}} if not BALLOTS[webSerial]['questions'].has_key(q_id): BALLOTS[webSerial]['questions'][q_id] = []
CODES_FILE_PATH is the path to a file which, when provided, will be where this script writes its list of confirmation codes for each ballot. """ # core imports import sys import base, data, filenames # based on meeting2, and meeting3 for the ballots import meeting1, meeting2, meeting3 election = meeting1.election ballots, cast_ballots = meeting3.ballots, meeting3.ballots_with_codes # unused ballots codes unused_ballots_codes_xml = base.file_in_dir(base.DATA_PATH, filenames.UNUSED_BALLOTS_CODES, 'Unused Ballots Codes') unused_ballots = data.parse_ballot_table(unused_ballots_codes_xml) # unused ballots mixnet unused_ballots_mixnet_xml = base.file_in_dir(base.DATA_PATH, filenames.UNUSED_BALLOTS_MIXNET, 'Unused Ballots Mixnet') unused_p_table, unused_partitions = data.parse_database(unused_ballots_mixnet_xml) def verify(output_stream, codes_output_stream=None): if codes_output_stream: BALLOTS = {} def new_code(webSerial, pid, q_id, s_id, confirmation_code): if not BALLOTS.has_key(webSerial): BALLOTS[webSerial] = {'pid': pid, 'questions': {}} if not BALLOTS[webSerial]['questions'].has_key(q_id): BALLOTS[webSerial]['questions'][q_id] = []