import tallydata # correcting the argv base.DATA_PATH QUESTION_ID = sys.argv[1] DATA_PATHS = sys.argv[2:] # for default election params base.DATA_PATH = DATA_PATHS[0] # use the meeting1 data structures from electionparams import * # import just the R tables # there could be a few given the multiple data_paths r_tables_xml = [base.file_in_dir(data_path, filenames.MEETING_THREE_OUT, 'Meeting Three Out') for data_path in DATA_PATHS] r_tables_list = [data.parse_r_tables(r_tables) for r_tables in r_tables_xml] # print "ok now tallying\n\n" # the list of partitions, each of which is a list of the max number of answers each question allows partition_map = election.partition_map_choices # we only tally per question now, so BALLOTS is just an array BALLOTS = [] # go through each partition for r_tables in r_tables_list: for p_id, r_table in r_tables.iteritems(): for row_id, row in r_table.rows.iteritems(): # split the result among questions for this partition, according to partition map split_result = r_table.get_permutations_by_row_id(row_id, partition_map[p_id])
meeting_four_out_xml = base.file_in_dir(base.DATA_PATH, filenames.MEETING_FOUR_OUT, 'Meeting Four Out') meeting_four_random_data = base.file_in_dir(base.DATA_PATH, filenames.MEETING_FOUR_RANDOM_DATA, "Random Data for Meeting Four Challenges", xml=False, correct_windows=False) # from meeting1 and meeting 2 election, d_table_commitments, already_open_d_tables = meeting1.election, meeting1.partitions, meeting2.response_partitions p_table_votes = meeting3.p_table_votes # from meeting3, the D tables with intermediate decrypted votes cast_ballot_partitions = data.parse_d_tables(meeting3.meeting_three_out_xml) # challenge and response to those rows d_table_challenges = data.parse_d_tables(meeting_four_in_xml) d_table_responses = data.parse_d_tables(meeting_four_out_xml) # r tables r_tables_by_partition = data.parse_r_tables(meeting3.meeting_three_out_xml) def verify(output_stream): # verify that challenges are appropriately generated challenges_match_randomness = True # we assume that one D table always opens on the same side # we do a bit of an odd thing here to keep the partitions and d tables in order # because that's how counter is decided counter = 0 # a dictionary of partition_ids, with values a dictionary of d_table ID expected_challenge_sides = {} seed = meeting_four_random_data + election.constant