def send_extra_data_to_mediator(data: dict, complaint, my_name): util.get_keys(my_name.split(":")[-1]) util.post_url( dict(complaint=util.vote_to_string(complaint), data=util.vote_to_string(data), server=my_name, sender=my_name), util.mediator + "/extra_data")
def test_message_inconsistency(self): for num, server in enumerate(local_servers): util.post_url(dict(complaint=util.vote_to_string(util.Complaint( server, dict(test="test1"), util.Protocol.check_votes, num+1 % 4 )), server=server, sender=server.split(":")[-1]), mediator + "/messageinconsistency") time.sleep(0.2) print(requests.get(mediator + "/test/printcomplaints"))
def answer_complaint(complaint, malicious_server, votes_for_deletion): for server in util.servers: util.post_url( dict(complaint=util.vote_to_string(complaint), malicious_server=malicious_server, sender=my_name, votes_for_deletion=votes_for_deletion), server + "/mediator_answer_votes")
def complain_consistency(complaint: util.Complaint, servers, mediator, my_name): util.get_keys(my_name.split(":")[-1]) for server in servers + [mediator]: util.post_url( dict(complaint=util.vote_to_string(complaint), server=my_name, sender=my_name), server + "/messageinconsistency")
def postvote(client_name: str, vote: list, servers: list): ### Parameters: ### client_name: unique identifier for client ### vote: a list consisting of matrices containing the different secret shared r_i-element of the vote ### servers: a list with all servers which the secrets should be distributed to ### ### Returns: ### void. Should only distribute secret shares to servers for i,share in enumerate(vote): rest = vote.copy() rest.pop(i) ids = [0,1,2,3] ids.remove(i) rest_strings = [] for vote_partition in rest: rest_strings.append(util.vote_to_string(vote_partition)) m = dict(client=client_name, ids=ids, server=servers[i], votes=rest_strings, sender=client_name) util.get_keys(client_name) util.post_url(m, servers[i] + '/vote')
def broadcast_to_servers(data: dict, url: str): for server in servers: util.post_url(data=data, url=url)
def zero_sum_db_print(servers: list): for s in servers: util.post_url(data=dict(), url=s + '/z0print')
def send_value_to_server(data, url): return util.post_url(data=data, url=url)
def send_illegal_votes_to_mediator(illegal_votes: list, server: str, url: str, name): return util.post_url(data=dict(illegal_votes=illegal_votes, server=server, sender=name), url=url + "/votevalidity")